java.lang.Object
ca.weblite.objc.TypeMapper
- All Implemented Interfaces:
TypeMapping
Maps Objective-C types to Java types. This provides automatic conversion
to message inputs and outputs (unless coercion is disabled in the message
request). In many cases, it just passes the values straight through (e.g.
primitive types. Notably, Java Strings are mapped to NSStrings
if the signature of the argument context is an NSString, and NSObjects
are mapped as Proxy wrapper objects.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptioncToJ(Object cVar, String signature, TypeMapping root) Converts a C variable to the corresponding Java variable given the context of the specified signature.static TypeMapperObtains the singleton instance of the TypeMapper, i.e.jToC(Object jVar, String signature, TypeMapping root) Converts a Java variable to the corresponding Java variable given the context of the specified signature.
-
Field Details
-
INSTANCE
Singleton instance of the TypeMapper
-
-
Method Details
-
getInstance
Obtains the singleton instance of the TypeMapper, i.e.INSTANCE.- Returns:
- singleton
TypeMapperobject.
-
cToJ
Converts a C variable to the corresponding Java variable given the context of the specified signature. Converts a C variable to the corresponding Java type based on the specified signature. By default, this will map scalars straight across without change. Strings are mapped to NSStrings.- Specified by:
cToJin interfaceTypeMapping- Parameters:
cVar- The C variable to be converted.signature- The signature that tells what type of variable we are dealing with according to Objective-C Type Encoding conventions.root- The root TypeMapping object- Returns:
- The converted Java object.
-
jToC
Converts a Java variable to the corresponding Java variable given the context of the specified signature. Converts a Java variable to the corresponding C type based on the specified signature. By default, this will map scalars straight across without change. Strings are mapped to NSStrings.Example Usage
The following is a modified snippet from the NSObject class that shows (roughly) how the jToC method is used to take the output of a Java method and set the return value in an NSInvocation object to a corresponding C type.:
- Specified by:
jToCin interfaceTypeMapping- Parameters:
jVar- The Java variable to be converted.signature- The signature that tells what type of variable we are dealing with according to Objective-C Type Encoding conventions.root- aTypeMappingobject.- Returns:
- The converted C variable
-