public class TypeMapper extends java.lang.Object implements TypeMapping
Constructor and Description |
---|
TypeMapper() |
Modifier and Type | Method and Description |
---|---|
TypeMapper |
addMapping(TypeMapping mapping,
java.lang.String... signatures)
Adds a TypeMapping that is meant to handle one or more signatures.
|
java.lang.Object |
cToJ(java.lang.Object cVar,
java.lang.String signature,
TypeMapping root)
Converts a C variable to the corresponding Java type based on the
specified signature.
|
static TypeMapper |
getInstance()
Obtains the singleton instance of the TypeMapper
|
java.lang.Object |
jToC(java.lang.Object jVar,
java.lang.String signature,
TypeMapping root)
Converts a Java variable to the corresponding C type based on the
specified signature.
|
public static TypeMapper getInstance()
public TypeMapper addMapping(TypeMapping mapping, java.lang.String... signatures)
mapping
- The TypeMapping object meant to handle conversions for
the given signatures.signatures
- One or more signatures following Objective-C type encodings.public java.lang.Object cToJ(java.lang.Object cVar, java.lang.String signature, TypeMapping root)
cToJ
in interface TypeMapping
cVar
- The C variable that is to be converted.signature
- The signature that provides the context of what
the variable is expected to be in the Objective-C runtime. This
follows Objective-C type encoding conventions.root
- This should be the root TypeMapping. Usually you just pass
TypeMapper.getInstance() here.public java.lang.Object jToC(java.lang.Object jVar, java.lang.String signature, TypeMapping root)
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.:
jToC
in interface TypeMapping
jVar
- The C variable that is to be converted.signature
- The signature that provides the context of what
the variable is expected to be in the Objective-C runtime. This
follows Objective-C type encoding conventions.root
- This should be the root TypeMapping. Usually you just pass
TypeMapper.getInstance() here.