Package com.jogamp.gluegen
Class JavaType
- java.lang.Object
-
- com.jogamp.gluegen.JavaType
-
public class JavaType extends Object
Describes a java-side representation of a type that is used to represent the same data on both the Java-side and C-side during a JNI operation. Also contains some utility methods for creating common types.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJavaType.PascalStringElemPascal string argument index tuple for length and value.
-
Field Summary
Fields Modifier and Type Field Description JavaType.PascalStringElempascalStrElem
-
Constructor Summary
Constructors Constructor Description JavaType(JavaType o)Copy ctorJavaType(JavaType o, JavaType.PascalStringElem pascalStrElem)Copy ctor w/ pascalString variant override
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static StringBuilderappendDescriptor(StringBuilder buf, Class<?> c, boolean useTrueType)Appends the descriptor (internal type signature) corresponding to the given Class> c.static StringBuilderappendJNIDescriptor(StringBuilder res, Class<?> c, boolean useTrueType)Appends the native (JNI) method-name descriptor corresponding to the given Class> c, i.e.Objectclone()static JavaTypecreateForCArray(Type elementType)Creates a JavaType corresponding to an array of the given element type.static JavaTypecreateForCCharPointer()static JavaTypecreateForCDoublePointer()static JavaTypecreateForCFloatPointer()static JavaTypecreateForCInt32Pointer()static JavaTypecreateForCInt64Pointer()static JavaTypecreateForClass(Class<?> clazz)Creates a JavaType corresponding to the given Java type.static JavaTypecreateForCShortPointer()static JavaTypecreateForCStruct(String name)Creates a JavaType corresponding to the specified C CompoundType name; for example, if "Foo" is supplied, then this JavaType represents a "Foo *" by way of a StructAccessor.static JavaTypecreateForCVoidPointer()static JavaTypecreateForJNIEnv()static JavaTypecreateForNamedClass(String name)Creates a JavaType corresponding to the given named Java class, not necessarily existing yet.static JavaTypecreateForOpaqueClass(Class<?> clazz)Creates a JavaType corresponding to the given opaque Java type.static JavaTypecreateForStringClass(Class<?> clazz, JavaType.PascalStringElem pascalStrElem)booleanequals(Object arg)static JavaTypeforNIOBufferClass()static JavaTypeforNIOByteBufferArrayClass()static JavaTypeforNIOByteBufferClass()static JavaTypeforNIODoubleBufferClass()static JavaTypeforNIOFloatBufferClass()static JavaTypeforNIOIntBufferClass()static JavaTypeforNIOLongBufferClass()static JavaTypeforNIOPointerBufferClass()static JavaTypeforNIOShortBufferClass()static JavaTypeforObjectClass()StringgetDebugString()StringgetDescriptor()Returns the descriptor (internal type signature) corresponding to this type.StringgetDescriptor(JavaConfiguration cfg)TypegetElementCType()JavaTypegetElementType()Class<?>getJavaClass()Returns the Java Class corresponding to this type.StringgetJNIMethodDesciptor()Returns the native (JNI) method-name descriptor corresponding to this type, i.e.StringgetName()Returns the Java type name corresponding to this type.StringgetName(JavaConfiguration cfg)StringBuildergetSignature(StringBuilder sb)inthashCode()booleanisArray()booleanisArrayOfCompoundTypeWrappers()booleanisByte()booleanisByteArray()booleanisCCharPointerType()booleanisCDoublePointerType()booleanisCFloatPointerType()booleanisCInt32PointerType()booleanisCInt64PointerType()booleanisCompoundTypeWrapper()booleanisCPrimitivePointerType()booleanisCShortPointerType()booleanisCVoidPointerType()booleanisDouble()booleanisDoubleArray()booleanisFloat()booleanisFloatArray()booleanisInt()booleanisIntArray()booleanisJNIEnv()booleanisLong()booleanisLongArray()booleanisNamedClass()booleanisNIOBuffer()booleanisNIOBufferArray()booleanisNIOByteBuffer()booleanisNIOByteBufferArray()booleanisNIOLongBuffer()booleanisNIOPointerBuffer()booleanisOpaqued()booleanisPascalLen()booleanisPascalStr()booleanisPascalStrArray()booleanisPascalStrElem()booleanisPrimitive()booleanisPrimitiveArray()booleanisShort()booleanisShortArray()booleanisString()booleanisStringArray()booleanisVoid()StringjniTypeName()Returns the String corresponding to the JNI type for this type, or NULL if it can't be represented (i.e., it's a boxing class that we need to call getBuffer() on.)static StringtoJNIMethodDescriptor(String descriptor)Converts the assumed descriptor (internal type signature) to a native (JNI) method-name descriptor, i.e.static StringBuildertoJNIMethodDescriptor(StringBuilder descriptor, int start)Converts the assumed descriptor (internal type signature) to a native (JNI) method-name descriptor, i.e.StringtoString()
-
-
-
Field Detail
-
pascalStrElem
public final JavaType.PascalStringElem pascalStrElem
-
-
Constructor Detail
-
JavaType
public JavaType(JavaType o)
Copy ctor
-
JavaType
public JavaType(JavaType o, JavaType.PascalStringElem pascalStrElem)
Copy ctor w/ pascalString variant override
-
-
Method Detail
-
getElementType
public JavaType getElementType()
-
getElementCType
public Type getElementCType()
-
createForOpaqueClass
public static JavaType createForOpaqueClass(Class<?> clazz)
Creates a JavaType corresponding to the given opaque Java type. This can be used to represent arrays of primitive values or Strings; the emitters understand how to perform proper conversion from the corresponding C type.
-
createForClass
public static JavaType createForClass(Class<?> clazz)
Creates a JavaType corresponding to the given Java type. This can be used to represent arrays of primitive values or Strings; the emitters understand how to perform proper conversion from the corresponding C type.
-
createForStringClass
public static JavaType createForStringClass(Class<?> clazz, JavaType.PascalStringElem pascalStrElem)
-
createForNamedClass
public static JavaType createForNamedClass(String name)
Creates a JavaType corresponding to the given named Java class, not necessarily existing yet.
-
createForCStruct
public static JavaType createForCStruct(String name)
Creates a JavaType corresponding to the specified C CompoundType name; for example, if "Foo" is supplied, then this JavaType represents a "Foo *" by way of a StructAccessor.
-
createForCArray
public static JavaType createForCArray(Type elementType)
Creates a JavaType corresponding to an array of the given element type. This is used to represent arrays of "Foo **" which should be mapped to Foo[] in Java.
-
createForCVoidPointer
public static JavaType createForCVoidPointer()
-
createForCCharPointer
public static JavaType createForCCharPointer()
-
createForCShortPointer
public static JavaType createForCShortPointer()
-
createForCInt32Pointer
public static JavaType createForCInt32Pointer()
-
createForCInt64Pointer
public static JavaType createForCInt64Pointer()
-
createForCFloatPointer
public static JavaType createForCFloatPointer()
-
createForCDoublePointer
public static JavaType createForCDoublePointer()
-
createForJNIEnv
public static JavaType createForJNIEnv()
-
forObjectClass
public static JavaType forObjectClass()
-
forNIOBufferClass
public static JavaType forNIOBufferClass()
-
forNIOByteBufferClass
public static JavaType forNIOByteBufferClass()
-
forNIOShortBufferClass
public static JavaType forNIOShortBufferClass()
-
forNIOIntBufferClass
public static JavaType forNIOIntBufferClass()
-
forNIOLongBufferClass
public static JavaType forNIOLongBufferClass()
-
forNIOPointerBufferClass
public static JavaType forNIOPointerBufferClass()
-
forNIOFloatBufferClass
public static JavaType forNIOFloatBufferClass()
-
forNIODoubleBufferClass
public static JavaType forNIODoubleBufferClass()
-
forNIOByteBufferArrayClass
public static JavaType forNIOByteBufferArrayClass()
-
getJavaClass
public Class<?> getJavaClass()
Returns the Java Class corresponding to this type. Returns null if this object corresponds to a C primitive array type.
-
getName
public String getName()
Returns the Java type name corresponding to this type.
-
getName
public String getName(JavaConfiguration cfg)
-
getDescriptor
public String getDescriptor()
Returns the descriptor (internal type signature) corresponding to this type.
-
getDescriptor
public String getDescriptor(JavaConfiguration cfg)
-
getJNIMethodDesciptor
public String getJNIMethodDesciptor()
Returns the native (JNI) method-name descriptor corresponding to this type, i.e. replacing charsgetDescriptor()as follows- `_` -> `_1`
- `/` -> `_`
- `;` -> `_2`
- `[` -> `_3`
- See Also:
Spec 2, Chapter 2, Resolving Native Method Names,toJNIMethodDescriptor(String)
-
appendDescriptor
public static StringBuilder appendDescriptor(StringBuilder buf, Class<?> c, boolean useTrueType)
Appends the descriptor (internal type signature) corresponding to the given Class> c.- Parameters:
buf- the StringBuilder sinkc- the Class> to append the descriptor foruseTrueType- if true, use the actual Class> name for non primitives, otherwise java.lang.Object will be used (flattened)- Returns:
- the given StringBuilder sink for chaining
-
appendJNIDescriptor
public static StringBuilder appendJNIDescriptor(StringBuilder res, Class<?> c, boolean useTrueType)
Appends the native (JNI) method-name descriptor corresponding to the given Class> c, i.e. replacing charsappendDescriptor(StringBuilder, Class, boolean)as follows- `_` -> `_1`
- `/` -> `_`
- `;` -> `_2`
- `[` -> `_3`
toJNIMethodDescriptor(StringBuilder, int).- Parameters:
buf- the StringBuilder sinkc- the Class> to append the descriptor foruseTrueType- if true, use the actual Class> name for non primitives, otherwise java.lang.Object will be used (flattened)- Returns:
- the given StringBuilder sink for chaining
- See Also:
Spec 2, Chapter 2, Resolving Native Method Names,#toJNIMethodDescriptor(StringBuilder)
-
toJNIMethodDescriptor
public static String toJNIMethodDescriptor(String descriptor)
Converts the assumed descriptor (internal type signature) to a native (JNI) method-name descriptor, i.e. replacing charsgetDescriptor()as follows- `_` -> `_1`
- `/` -> `_`
- `;` -> `_2`
- `[` -> `_3`
- Parameters:
descriptor- the char sequence holding the original descriptor- See Also:
Spec 2, Chapter 2, Resolving Native Method Names
-
toJNIMethodDescriptor
public static StringBuilder toJNIMethodDescriptor(StringBuilder descriptor, int start)
Converts the assumed descriptor (internal type signature) to a native (JNI) method-name descriptor, i.e. replacing charsgetDescriptor()as follows- `_` -> `_1`
- `/` -> `_`
- `;` -> `_2`
- `[` -> `_3`
- Parameters:
descriptor- the char buffer holding the original descriptorstart- start position of the segment to convert, use 0 if whole buffr shall be converted- Returns:
- returns passed descriptor buffer for chaining
- See Also:
Spec 2, Chapter 2, Resolving Native Method Names
-
jniTypeName
public String jniTypeName()
Returns the String corresponding to the JNI type for this type, or NULL if it can't be represented (i.e., it's a boxing class that we need to call getBuffer() on.)
-
isOpaqued
public boolean isOpaqued()
-
isNIOBuffer
public boolean isNIOBuffer()
-
isNIOByteBuffer
public boolean isNIOByteBuffer()
-
isNIOByteBufferArray
public boolean isNIOByteBufferArray()
-
isNIOBufferArray
public boolean isNIOBufferArray()
-
isNIOLongBuffer
public boolean isNIOLongBuffer()
-
isNIOPointerBuffer
public boolean isNIOPointerBuffer()
-
isString
public boolean isString()
-
isPascalStrElem
public boolean isPascalStrElem()
-
isPascalStr
public boolean isPascalStr()
-
isPascalLen
public boolean isPascalLen()
-
isArray
public boolean isArray()
-
isFloatArray
public boolean isFloatArray()
-
isDoubleArray
public boolean isDoubleArray()
-
isByteArray
public boolean isByteArray()
-
isIntArray
public boolean isIntArray()
-
isShortArray
public boolean isShortArray()
-
isLongArray
public boolean isLongArray()
-
isStringArray
public boolean isStringArray()
-
isPascalStrArray
public boolean isPascalStrArray()
-
isPrimitive
public boolean isPrimitive()
-
isPrimitiveArray
public boolean isPrimitiveArray()
-
isShort
public boolean isShort()
-
isFloat
public boolean isFloat()
-
isDouble
public boolean isDouble()
-
isByte
public boolean isByte()
-
isLong
public boolean isLong()
-
isInt
public boolean isInt()
-
isVoid
public boolean isVoid()
-
isNamedClass
public boolean isNamedClass()
-
isCompoundTypeWrapper
public boolean isCompoundTypeWrapper()
-
isArrayOfCompoundTypeWrappers
public boolean isArrayOfCompoundTypeWrappers()
-
isCPrimitivePointerType
public boolean isCPrimitivePointerType()
-
isCVoidPointerType
public boolean isCVoidPointerType()
-
isCCharPointerType
public boolean isCCharPointerType()
-
isCShortPointerType
public boolean isCShortPointerType()
-
isCInt32PointerType
public boolean isCInt32PointerType()
-
isCInt64PointerType
public boolean isCInt64PointerType()
-
isCFloatPointerType
public boolean isCFloatPointerType()
-
isCDoublePointerType
public boolean isCDoublePointerType()
-
isJNIEnv
public boolean isJNIEnv()
-
getSignature
public final StringBuilder getSignature(StringBuilder sb)
-
getDebugString
public String getDebugString()
-
-