Mapper¶
-
public interface
Mapper
¶ Mapper interface.
Implement this interface to add support for handling new native types. Adding
MappedReturn(MyMapper.class)
orMapped(MyMapper.class)
to a native method or one of its argument, respectively, will tell NatJ to use the mapper implementation whenever it has to convert the return or argument value between Java and native side. When converting to Java NatJ will use the implementation’stoJava(long, JavaObjectConstructionInfo)
method to convert native value to a Java one. Reasonably, thetoNative(Object, NativeObjectConstructionInfo)
method will be used for the other direction.JavaObjectConstructionInfo.data
andNativeObjectConstructionInfo.data
fields are not used by NatJ and free to use for anything.
Methods¶
toJava¶
-
public Object
toJava
(long instance, JavaObjectConstructionInfo info)¶ Has to convert a native value to Java value and return it.
Parameters: - instance – The pointer pointing to the native value
- info – Contains every information needed for conversion
Returns: The Java value
toNative¶
-
public long
toNative
(Object instance, NativeObjectConstructionInfo info)¶ Has to convert a Java value to native value and return its pointer.
Parameters: - instance – The Java value to convert
- info – Contains every information needed for conversion
Returns: The native value