Top Description Fields Constructors Methods
com.jogamp.gluegen

public Class JavaConfiguration

extends Object
Class Inheritance
Known Direct Subclasses
com.jogamp.gluegen.procaddress.ProcAddressConfiguration
Imports
com.jogamp.gluegen.ASTLocusTag.ASTLocusTagProvider, .JavaEmitter.EmissionStyle, .JavaEmitter.MethodAccess, .Logging.LoggerIf, java.io.*, java.lang.reflect.Array, java.util.*, java.util.regex.*, com.jogamp.gluegen.jgram.*, com.jogamp.gluegen.cgram.types.*

Parses and provides access to the contents of .cfg files for the JavaEmitter.

Field Summary

Modifier and TypeField and Description
private final Map<String, JavaEmitter.MethodAccess>
private final Map<String, List<Integer>>
argumentsAreString

Key is function that has some byte[] or short[] arguments that should be converted to String args; value is List of Integer argument indices

private final Map<String, List<String>>
private String
private final List<String>
private final Map<String, List<String>>
private static final boolean
private final Map<String, String>
private JavaEmitter.EmissionStyle
emissionStyle

Style of code emission.

private final Set<String>
private final Set<String>
private final Map<String, List<String>>
private final Set<String>
private final Set<String>
private final List<String>
private final Set<String>
private boolean
private boolean
private String
gluegenRuntimePackage

The package in which the generated glue code expects to find its run-time helper classes (Buffers, Platform, StructAccessor).

private final Map<String, Pattern>
private final Set<Pattern>
private final Set<Pattern>
private String
private final Map<String, List<String>>
private String
private final List<String>
imports

List of imports to emit at the head of the output files.

private final Map<String, List<String>>
private String
javaOutputDir

Root directory for the hierarchy of generated java classes.

private final Map<String, List<String>>
private final Map<String, Set<String>>
private final Map<String, String>
private final Map<String, String>
protected final Logging.LoggerIf
private static boolean
private static boolean
private final Set<String>
private final Set<String>
private final Map<String, List<String>>
private String
nativeOutputDir

Directory into which generated native JNI code will be written.

private boolean
nativeOutputUsesJavaHierarchy

If true, then each native *.c and *.h file will be generated in the directory nativeOutputDir/packageAsPath(packageName).

private int
public static String
private String
outputRootDir

Top output root directory for all generated files.

private String
private final Map<String, String>
private boolean
relaxedEqualSemanticsTest

If true, TypeConfig.SemanticEqualityOp#equalSemantics(TypeConfig.SemanticEqualityOp) will attempt to perform a relaxed semantic equality test, e.g. skip the const and volatile qualifiers.

private final Map<String, String>
private final Map<String, JavaType>
private final Set<String>
private final Map<String, String>
private final Map<String, String>
private String
runtimeExceptionType

The kind of exception raised by the generated code if run-time checks fail.

private final Map<String, String>
private final Map<String, String>
private boolean
tagNativeBinding

If true, then the comment of a native method binding will include a @native tag to allow taglets to augment the javadoc with additional information regarding the mapped C function.

private final Map<String, List<String>>
private final Map<String, List<String>>
private final Map<String, TypeInfo>
private final Set<Pattern>
private final Set<Pattern>
private String
private final Set<String>
private final Set<String>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public JavaEmitter.MethodAccess
accessControl(final String name)

Returns the access control for the given method-name or fully qualified class-name.

protected void
addClassJavadoc(final String className, final String code)

protected void
addCustomJavaCode(final String className, final String code)

public void
addDelegateImplementation(final String origName, final String renamedImpl)

Programmatically adds a delegate implementation directive for the given symbol.

protected void
addJavaPrologueOrEpilogue(final String methodName, final String code, final boolean prologue)

public void
addJavaSymbolRename(final String origName, final String newName)

Programmatically adds a rename directive for the given symbol.

protected void
addMethodJavadoc(final String methodName, final String code)

public TypeInfo
addTypeInfo(final String alias, final Type superType)

protected void
addTypeInfo(final TypeInfo info)

public void
public void
addUseNIOOnly(final String fname)

public boolean
allStatic()

Returns true if the emission style is AllStatic.

public TypeInfo
canonicalNameOpaque(final String canonicalName)

If the given canonicalName should be considered opaque, returns the TypeInfo describing the replacement type.

public static String
canonicalStructFieldSymbol(final String structName, final String fieldName)

Returns the canonical configuration name for a struct field name, i.e. 'struct-name'.'field-name'

public String
className()

Returns the class name parsed from the configuration file.

private TypeInfo
closestTypeInfo(final String name, final int pointerDepth)

public List<String>
customCCode()

Returns, as a List of Strings, the custom C code to be emitted along with the glue code for the main class.

public List<String>
customJavaCodeForClass(final String className)

Returns a list of Strings containing user-implemented code for the given Java type name (not fully-qualified, only the class name); returns either null or an empty list if there is no custom code for the class.

protected void
dispatch(final String cmd, final StringTokenizer tok, final File file, final String filename, final int lineNo)

protected void
doInclude(final StringTokenizer tok, final File file, final String filename, final int lineNo)

protected void
doIncludeAs(final StringTokenizer tok, final File file, final String filename, final int lineNo)

public JavaEmitter.EmissionStyle
emissionStyle()

Returns the code emission style (constants in JavaEmitter) parsed from the configuration file.

public boolean
emitImpl()

Returns true if an implementing class should be emitted during glue code generation.

public boolean
emitInterface()

Returns true if an interface should be emitted during glue code generation.

public List<String>
extendedInterfaces(final String interfaceName)

Returns a List of Strings indicating the interfaces the passed interface should declare it extends.

public String
extendedParentClass(final String className)

Returns a List of Strings indicating the interfaces the passed class should declare it implements.

public List<String>
forcedStructs()

Returns, as a List of Strings, the structs for which glue code emission should be forced.

public boolean
forceStaticInitCode(final String clazzName)

Returns true if the static initialization java code implementing initializeImpl() and the native code implementing:

  static jobject JVMUtil_NewDirectByteBufferCopy(JNIEnv *env, void * source_address, jlong capacity);
public Set<String>

Returns:

set of aliased-names or null.
getAliasedDocNames
(final AliasedSymbol
the aliased symbol to retrieve the aliases
symbol
)

Return a set of aliased-name for comment in docs.

protected static ASTLocusTag
public String
getDelegatedImplementation(final String functionName)

Variant of getDelegatedImplementation(AliasedSymbol), where this method only considers the current-name of the given symbol, not the renamed-symbol.

public String
getDelegatedImplementation(final AliasedSymbol symbol)

Returns the RENAMED-IMPL-SYMBOL if the implementation of the glue code of the given function shall be manually delegated by the end user.

public String
getJavaSymbolRename(final String origName)

Returns a replacement name for this function or definition which should be used as the Java name for the bound method or constant.

public JavaType
getOpaqueReturnType(final String functionName)

Variant of getOpaqueReturnType(AliasedSymbol), where this method only considers the current-name of the given symbol, not the renamed-symbol.

public JavaType
getOpaqueReturnType(final AliasedSymbol symbol)

Returns the opaque JavaType for the given function AliasedSymbol or null if not opaque.

public Set<String>
getRenamedJavaSymbols(final String aliasedName)

Returns a set of replaced names to the given aliasedName.

public String
gluegenRuntimePackage()

Returns the package in which the generated glue code expects to find its run-time helper classes (Buffers, Platform, StructAccessor).

public String
implClassName()

Returns the implementation class name parsed from the configuration file.

public List<String>
implementedInterfaces(final String className)

Returns a List of Strings indicating the interfaces the passed class should declare it implements.

public String
implPackageName()

Returns the implementation package name parsed from the configuration file.

public List<String>
imports()

Returns the list of imports that should be emitted at the top of each .java file.

public boolean
public boolean
isUnimplemented(final AliasedSymbol symbol)

Returns true if this function should be given a body which throws a run-time exception with an "unimplemented" message during glue code generation.

public List<String>
javadocForClass(final String className)

Returns a list of Strings containing Javadoc documentation for the given Java type name (not fully-qualified, only the class name); returns either null or an empty list if there is no Javadoc documentation for the class.

public List<String>
javadocForMethod(final String methodName)

public List<String>
javaEpilogueForMethod(final MethodBinding binding, final boolean forImplementingMethodCall, final boolean eraseBufferAndArrayTypes)

Returns a list of Strings which should be emitted as an epilogue to the body for the Java-side glue code for the given method.

public String
javaOutputDir()

Returns the Java code output directory parsed from the configuration file.

public List<String>
javaPrologueForMethod(final MethodBinding binding, final boolean forImplementingMethodCall, final boolean eraseBufferAndArrayTypes)

Returns a list of Strings which should be emitted as a prologue to the body for the Java-side glue code for the given method.

public void
public void
public void
public void
public boolean
manuallyImplement(final String functionName)

Variant of manuallyImplement(AliasedSymbol), where this method only considers the current-name of the given symbol, not the renamed-symbol.

public boolean
manuallyImplement(final AliasedSymbol symbol)

Returns true if the glue code for the given aliased function will be manually implemented by the end user.

public boolean
manualStaticInitCall(final String clazzName)

Returns true if the static initialization java code calling initializeImpl() for the given class will be manually implemented by the end user as requested via configuration directive ManualStaticInitCall 'class-name'.

public String
nativeOutputDir()

Returns the native code output directory parsed from the configuration file.

public boolean
nativeOutputUsesJavaHierarchy()

Returns whether the native code directory structure mirrors the Java hierarchy.

private static int
nextIndexAfterDescriptor(final String s, final int idx)

private static int
nextIndexAfterType(final String s, int idx)

public static <K, V> V
oneInMap(final Map<K, V> map, final Set<K> symbols)

public static <K> boolean
oneInSet(final Set<K> set1, final Set<K> set2)

private static boolean
onePatternMatch(final Pattern ignoreRegexp, final Set<String> set)

public String
packageForStruct(final String structName)

Returns the package into which to place the glue code for accessing the specified struct.

public String
packageName()

Returns the package name parsed from the configuration file.

protected static TypeInfo
parseTypeInfo(final String cType, final JavaType javaType)

private TypeInfo
promoteTypeInfo(final TypeInfo info, final int numPointersStripped)

public final void
read(final String
path to file that should be read
filename
)

Reads the configuration file.

protected final void
read(final String
path to file that should be read
filename
,
final String
if not null, treat each line read as if it were prefixed with the specified string.
linePrefix
)

Reads the specified file, treating each line as if it started with the specified string.

protected void
readAccessControl(final StringTokenizer tok, final String filename, final int lineNo)

protected void
readArgumentIsString(final StringTokenizer tok, final String filename, final int lineNo)

When const char* arguments in the C function prototypes are encountered, the emitter will normally convert them to byte[] arguments.

protected Boolean
readBoolean(final String cmd, final StringTokenizer tok, final String filename, final int lineNo)

protected void
readClassJavadoc(final StringTokenizer tok, final String filename, final int lineNo)

protected void
readCustomCCode(final StringTokenizer tok, final String filename, final int lineNo)

protected void
readCustomJavaCode(final StringTokenizer tok, final String filename, final int lineNo)

public void
readDelegateImplementation(final StringTokenizer tok, final String filename, final int lineNo)

protected void
readExtend(final StringTokenizer tok, final String filename, final int lineNo)

protected void
readExtendedIntfImplSymbols(final StringTokenizer tok, final String filename, final int lineNo, final boolean forInterface, final boolean forImplementation, final boolean onlyList)

protected void
readForceStaticInitCode(final StringTokenizer tok, final String filename, final int lineNo)

protected void
readIgnore(final StringTokenizer tok, final String filename, final int lineNo)

protected void
readIgnoreField(final StringTokenizer tok, final String filename, final int lineNo)

protected void
readIgnoreNot(final StringTokenizer tok, final String filename, final int lineNo)

protected void
readImplements(final StringTokenizer tok, final String filename, final int lineNo)

protected void
readJavaPrologueOrEpilogue(final StringTokenizer tok, final String filename, final int lineNo, final boolean prologue)

protected void
readManuallyImplement(final StringTokenizer tok, final String filename, final int lineNo)

protected void
readManualStaticInitCall(final StringTokenizer tok, final String filename, final int lineNo)

protected void
readMethodJavadoc(final StringTokenizer tok, final String filename, final int lineNo)

protected void
readOpaque(final StringTokenizer tok, final String filename, final int lineNo)

protected void
readParentClass(final StringTokenizer tok, final String filename, final int lineNo)

protected void
readRangeCheck(final StringTokenizer tok, final String filename, final int lineNo, final boolean inBytes)

protected void
readRenameJavaSymbol(final StringTokenizer tok, final String filename, final int lineNo)

protected void
readRenameJavaType(final StringTokenizer tok, final String filename, final int lineNo)

protected void
readReturnedArrayLength(final StringTokenizer tok, final String filename, final int lineNo)

protected void
readReturnsOpaque(final StringTokenizer tok, final String filename, final int lineNo)

protected void
readReturnsString(final StringTokenizer tok, final String filename, final int lineNo)

protected void
readReturnValueCapacity(final StringTokenizer tok, final String filename, final int lineNo)

protected void
readReturnValueLength(final StringTokenizer tok, final String filename, final int lineNo)

protected String
readString(final String cmd, final StringTokenizer tok, final String filename, final int lineNo)

protected void
readStructMachineDataInfoIndex(final StringTokenizer tok, final String filename, final int lineNo)

protected void
readStructPackage(final StringTokenizer tok, final String filename, final int lineNo)

protected void
readTemporaryCVariableAssignment(final StringTokenizer tok, final String filename, final int lineNo)

protected void
readTemporaryCVariableDeclaration(final StringTokenizer tok, final String filename, final int lineNo)

protected void
readUnignore(final StringTokenizer tok, final String filename, final int lineNo)

protected void
readUnimplemented(final StringTokenizer tok, final String filename, final int lineNo)

public boolean
relaxedEqualSemanticsTest()

Returns whether TypeConfig.SemanticEqualityOp#equalSemantics(TypeConfig.SemanticEqualityOp) shall attempt to perform a relaxed semantic equality test, e.g. skip the const and volatile qualifier - or not.

public String
renameJavaType(final String javaTypeName)

Returns a replacement name for this type, which should be the name of a Java wrapper class for a C struct, or the name unchanged if no RenameJavaType directive was specified for this type.

public String
returnedArrayLength(final String functionName)

Returns a MessageFormat string of the Java expression calculating the number of elements in the returned array from the specified function name.

public boolean
returnsString(final String functionName)

Indicates whether the given function (which returns a char* in C) should be translated as returning a java.lang.String.

public boolean
returnsString(final AliasedSymbol symbol)

Indicates whether the given function (which returns a char* in C) should be translated as returning a java.lang.String.

public String
returnStructMachineDataInfoIndex(final String structName)

Returns a MessageFormat string of the Java code defining mdIdx, i.e. the index of the static MachineDescriptor index for structs.

public String
returnValueCapacity(final String functionName)

Returns a MessageFormat string of the C expression calculating the capacity of the java.nio.ByteBuffer being returned from a native method, or null if no expression has been specified.

public String
returnValueLength(final String symbol)

Returns a MessageFormat string of the C expression calculating the length of the array being returned from a native method.

public String
runtimeExceptionType()

Returns the kind of exception to raise if run-time checks fail in the generated code.

public void
public boolean
shouldIgnoreInImpl(final AliasedSymbol
the symbolic aliased name to check for exclusion
symbol
)

Returns true if this aliased symbol should be ignored during glue code generation of implementation only.

protected final boolean
public final boolean
shouldIgnoreInInterface(final String symbol)

Variant of shouldIgnoreInInterface(AliasedSymbol), where this method only considers the current-name of the given symbol, not the renamed-symbol.

public boolean
shouldIgnoreInInterface(final AliasedSymbol
the symbolic aliased name to check for exclusion
symbol
)

Returns true if this aliased symbol should be ignored during glue code generation of interfaces and implementation.

protected final boolean
protected static boolean
public List<Integer>
stringArguments(final String functionName)

Returns a list of Integers which are the indices of const char* arguments that should be converted to Strings.

protected Class<?>
public boolean
public boolean
tagNativeBinding()

Returns whether the comment of a native method binding should include a @native tag.

public List<String>
temporaryCVariableAssignments(final String functionName)

Returns a List of Strings of expressions containing assignments to temporary C variables in the glue code for the specified function.

public List<String>
temporaryCVariableDeclarations(final String functionName)

Returns a List of Strings of expressions declaring temporary C variables in the glue code for the specified function.

public TypeInfo
typeInfo(Type type)

If this type should be considered opaque, returns the TypeInfo describing the replacement type.

public String
unsupportedExceptionType()

Returns the kind of exception to raise if run-time checks fail in the generated code.

public boolean
useNIODirectOnly(final String functionName)

Returns true if the given function should only create a java.nio variant, and no array variants, for void* and other C primitive pointers.

public boolean
useNIOOnly(final String functionName)

Returns true if the given function should only create a java.nio variant, and no array variants, for void* and other C primitive pointers.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait