GlueGen v2.6.0-rc-20250712
GlueGen, Native Binding Generator for Java™ (public API).
com.jogamp.gluegen.JavaEmitter Class Reference
Inheritance diagram for com.jogamp.gluegen.JavaEmitter:
Collaboration diagram for com.jogamp.gluegen.JavaEmitter:

Classes

class  ConstFuncRenamer
 
enum  EmissionStyle
 Style of code emission. More...
 
enum  MethodAccess
 Access control for emitted Java methods. More...
 
enum  Ownership
 Resource ownership. More...
 

Public Member Functions

 JavaEmitter ()
 
 JavaEmitter (final JavaConfiguration cfg)
 
void readConfigurationFile (final String filename) throws Exception
 
JavaConfiguration getConfig ()
 
void beginEmission (final GlueEmitterControls controls) throws IOException
 Begin the emission of glue code. More...
 
void endEmission ()
 Finish the emission of glue code. More...
 
void beginDefines () throws Exception
 
void emitDefine (final ConstantDefinition def, final String optionalComment) throws Exception
 
void endDefines () throws Exception
 
void beginFunctions (final TypeDictionary typedefDictionary, final TypeDictionary structDictionary, final Map< Type, Type > canonMap, final List< FunctionSymbol > cFunctions) throws Exception
 
Iterator< FunctionSymbolemitFunctions (final List< FunctionSymbol > funcsToBind) throws Exception
 Emit glue code for the list of FunctionSymbols. More...
 
void endFunctions () throws Exception
 
void beginStructLayout () throws Exception
 Begins the process of computing field offsets and type sizes for the structs to be emitted. More...
 
void layoutStruct (final CompoundType t) throws Exception
 Lays out one struct which will be emitted later. More...
 
void endStructLayout () throws Exception
 Finishes the struct layout process. More...
 
void beginStructs (final TypeDictionary typedefDictionary, final TypeDictionary structDictionary, final Map< Type, Type > canonMap) throws Exception
 
void emitStruct (final CompoundType structCType, final Type structCTypedefPtr) throws Exception
 Emit glue code for the given CompoundType. More...
 
void endStructs () throws Exception
 
String[] getClassAccessModifiers (final String classFQName)
 
void readConfigurationFile (String filename) throws Exception
 
JavaConfiguration getConfig ()
 
void beginEmission (GlueEmitterControls controls) throws Exception
 Begin the emission of glue code. More...
 
void endEmission () throws Exception
 Finish the emission of glue code. More...
 
void beginDefines () throws Exception
 
void emitDefine (ConstantDefinition def, String optionalComment) throws Exception
 
void endDefines () throws Exception
 
void beginFunctions (TypeDictionary typedefDictionary, TypeDictionary structDictionary, Map< Type, Type > canonMap, List< FunctionSymbol > cFunctions) throws Exception
 
Iterator< FunctionSymbolemitFunctions (List< FunctionSymbol > cFunctions) throws Exception
 Emit glue code for the list of FunctionSymbols. More...
 
void endFunctions () throws Exception
 
void beginStructLayout () throws Exception
 Begins the process of computing field offsets and type sizes for the structs to be emitted. More...
 
void layoutStruct (CompoundType t) throws Exception
 Lays out one struct which will be emitted later. More...
 
void endStructLayout () throws Exception
 Finishes the struct layout process. More...
 
void beginStructs (TypeDictionary typedefDictionary, TypeDictionary structDictionary, Map< Type, Type > canonMap) throws Exception
 
void emitStruct (CompoundType t, Type typedefType) throws Exception
 Emit glue code for the given CompoundType. More...
 
void endStructs () throws Exception
 

Static Public Member Functions

static int addStrings2Buffer (StringBuilder buf, final String sep, final String first, final Collection< String > col)
 

Protected Member Functions

JavaConfiguration createConfig ()
 Create the object that will read and store configuration information for this JavaEmitter. More...
 
void generatePublicEmitters (final MethodBinding binding, final List< FunctionEmitter > allEmitters, final boolean signatureOnly)
 Generates the public emitters for this MethodBinding which will produce either simply signatures (for the interface class, if any) or function definitions with or without a body (depending on whether or not the implementing function can go directly to native code because it doesn't need any processing of the outgoing arguments). More...
 
void generatePrivateEmitters (final MethodBinding binding, final List< FunctionEmitter > allEmitters)
 Generates the private emitters for this MethodBinding. More...
 
void prepCEmitter (final String returnSizeLookupName, final JavaType javaReturnType, final CMethodBindingEmitter cEmitter)
 
List<? extends FunctionEmittergenerateMethodBindingEmitters (final FunctionSymbol sym) throws Exception
 Generate all appropriate Java bindings for the specified C function symbols. More...
 
CCodeUnit openCUnit (final String filename, final String cUnitName) throws IOException
 
JavaCodeUnit openJavaUnit (final String filename, final String packageName, final String simpleClassName) throws IOException
 
JavaCodeUnit javaUnit ()
 
JavaCodeUnit javaImplUnit ()
 
CCodeUnit cUnit ()
 
String getJavaOutputDir ()
 Returns the value that was specified by the configuration directive "JavaOutputDir", or the default if none was specified. More...
 
String getJavaPackageName ()
 Returns the value that was specified by the configuration directive "Package", or the default if none was specified. More...
 
String getImplPackageName ()
 Returns the value that was specified by the configuration directive "ImplPackage", or the default if none was specified. More...
 
void emitCustomJavaCode (final CodeUnit unit, final String className) throws Exception
 Emit all the strings specified in the "CustomJavaCode" parameters of the configuration file. More...
 
void emitCustomJNICode (final CodeUnit unit, final String className) throws Exception
 Emit all the strings specified in the "CustomJNICode" parameters of the configuration file. More...
 
void emitAllFileHeaders () throws IOException
 Write out any header information for the output files (class declaration and opening brace, import statements, etc). More...
 
void emitAllFileFooters ()
 Write out any footer information for the output files (closing brace of class definition, etc). More...
 
void mangleBinding (final MethodBinding binding)
 Allow specializations to modify the given MethodBinding before expanding and emission. More...
 
List< MethodBindingexpandMethodBinding (final MethodBinding binding)
 

Static Protected Member Functions

static String jniMangle (final String name)
 Mangle a class, package or function name for JNI usage, i.e. More...
 
static String getJNIMethodNamePrefix (final String javaPackageName, final String javaClassName)
 Returns the JNI method prefix consisting our of mangled package- and class-name. More...
 

Protected Attributes

JavaConfiguration cfg
 
final LoggerIf LOG
 

Detailed Description

Definition at line 107 of file JavaEmitter.java.

Constructor & Destructor Documentation

◆ JavaEmitter() [1/2]

com.jogamp.gluegen.JavaEmitter.JavaEmitter ( )

Definition at line 157 of file JavaEmitter.java.

Here is the call graph for this function:

◆ JavaEmitter() [2/2]

com.jogamp.gluegen.JavaEmitter.JavaEmitter ( final JavaConfiguration  cfg)

Definition at line 161 of file JavaEmitter.java.

Member Function Documentation

◆ addStrings2Buffer()

static int com.jogamp.gluegen.JavaEmitter.addStrings2Buffer ( StringBuilder  buf,
final String  sep,
final String  first,
final Collection< String >  col 
)
static

Definition at line 1254 of file JavaEmitter.java.

◆ beginDefines()

void com.jogamp.gluegen.JavaEmitter.beginDefines ( ) throws Exception

Implements com.jogamp.gluegen.GlueEmitter.

Definition at line 306 of file JavaEmitter.java.

Here is the call graph for this function:

◆ beginEmission()

void com.jogamp.gluegen.JavaEmitter.beginEmission ( final GlueEmitterControls  controls) throws IOException

Begin the emission of glue code.

This might include opening files, emitting class headers, etc.

Implements com.jogamp.gluegen.GlueEmitter.

Definition at line 273 of file JavaEmitter.java.

Here is the call graph for this function:

◆ beginFunctions()

void com.jogamp.gluegen.JavaEmitter.beginFunctions ( final TypeDictionary  typedefDictionary,
final TypeDictionary  structDictionary,
final Map< Type, Type canonMap,
final List< FunctionSymbol cFunctions 
) throws Exception

Implements com.jogamp.gluegen.GlueEmitter.

Reimplemented in com.jogamp.gluegen.procaddress.ProcAddressEmitter.

Definition at line 361 of file JavaEmitter.java.

Here is the call graph for this function:

◆ beginStructLayout()

void com.jogamp.gluegen.JavaEmitter.beginStructLayout ( ) throws Exception

Begins the process of computing field offsets and type sizes for the structs to be emitted.

Implements com.jogamp.gluegen.GlueEmitter.

Definition at line 762 of file JavaEmitter.java.

◆ beginStructs()

void com.jogamp.gluegen.JavaEmitter.beginStructs ( final TypeDictionary  typedefDictionary,
final TypeDictionary  structDictionary,
final Map< Type, Type canonMap 
) throws Exception

◆ createConfig()

JavaConfiguration com.jogamp.gluegen.JavaEmitter.createConfig ( )
protected

Create the object that will read and store configuration information for this JavaEmitter.

Reimplemented in com.jogamp.gluegen.procaddress.ProcAddressEmitter.

Definition at line 436 of file JavaEmitter.java.

Here is the caller graph for this function:

◆ cUnit()

CCodeUnit com.jogamp.gluegen.JavaEmitter.cUnit ( )
protected

Definition at line 2884 of file JavaEmitter.java.

Here is the call graph for this function:

◆ emitAllFileFooters()

void com.jogamp.gluegen.JavaEmitter.emitAllFileFooters ( )
protected

Write out any footer information for the output files (closing brace of class definition, etc).

Definition at line 3091 of file JavaEmitter.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ emitAllFileHeaders()

void com.jogamp.gluegen.JavaEmitter.emitAllFileHeaders ( ) throws IOException
protected

Write out any header information for the output files (class declaration and opening brace, import statements, etc).

Definition at line 2985 of file JavaEmitter.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ emitCustomJavaCode()

void com.jogamp.gluegen.JavaEmitter.emitCustomJavaCode ( final CodeUnit  unit,
final String  className 
) throws Exception
protected

Emit all the strings specified in the "CustomJavaCode" parameters of the configuration file.

Definition at line 2934 of file JavaEmitter.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ emitCustomJNICode()

void com.jogamp.gluegen.JavaEmitter.emitCustomJNICode ( final CodeUnit  unit,
final String  className 
) throws Exception
protected

Emit all the strings specified in the "CustomJNICode" parameters of the configuration file.

Definition at line 2951 of file JavaEmitter.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ emitDefine()

void com.jogamp.gluegen.JavaEmitter.emitDefine ( final ConstantDefinition  def,
final String  optionalComment 
) throws Exception
Parameters
optionalCommentIf optionalComment is non-null, the emitter can emit that string as a comment providing extra information about the define.

Implements com.jogamp.gluegen.GlueEmitter.

Definition at line 325 of file JavaEmitter.java.

Here is the call graph for this function:

◆ emitFunctions()

Iterator< FunctionSymbol > com.jogamp.gluegen.JavaEmitter.emitFunctions ( final List< FunctionSymbol cFunctions) throws Exception

Emit glue code for the list of FunctionSymbols.

Implements com.jogamp.gluegen.GlueEmitter.

Definition at line 393 of file JavaEmitter.java.

Here is the call graph for this function:

◆ emitStruct()

void com.jogamp.gluegen.JavaEmitter.emitStruct ( final CompoundType  t,
final Type  typedefType 
) throws Exception

Emit glue code for the given CompoundType.

typedefType is provided when the CompoundType (e.g. "struct foo_t") has not been typedefed to anything but the type of "pointer to struct foo_t" has (e.g. "typedef struct foo_t {} *Foo"); in this case typedefType would be set to pointer type Foo.

Implements com.jogamp.gluegen.GlueEmitter.

Definition at line 779 of file JavaEmitter.java.

Here is the call graph for this function:

◆ endDefines()

void com.jogamp.gluegen.JavaEmitter.endDefines ( ) throws Exception

Implements com.jogamp.gluegen.GlueEmitter.

Definition at line 357 of file JavaEmitter.java.

◆ endEmission()

void com.jogamp.gluegen.JavaEmitter.endEmission ( )

Finish the emission of glue code.

This might include closing files, closing open class definitions, etc.

Implements com.jogamp.gluegen.GlueEmitter.

Definition at line 293 of file JavaEmitter.java.

Here is the call graph for this function:

◆ endFunctions()

void com.jogamp.gluegen.JavaEmitter.endFunctions ( ) throws Exception

Implements com.jogamp.gluegen.GlueEmitter.

Reimplemented in com.jogamp.gluegen.procaddress.ProcAddressEmitter.

Definition at line 746 of file JavaEmitter.java.

Here is the call graph for this function:

◆ endStructLayout()

void com.jogamp.gluegen.JavaEmitter.endStructLayout ( ) throws Exception

Finishes the struct layout process.

Implements com.jogamp.gluegen.GlueEmitter.

Definition at line 768 of file JavaEmitter.java.

◆ endStructs()

void com.jogamp.gluegen.JavaEmitter.endStructs ( ) throws Exception

Implements com.jogamp.gluegen.GlueEmitter.

Definition at line 1252 of file JavaEmitter.java.

◆ expandMethodBinding()

List< MethodBinding > com.jogamp.gluegen.JavaEmitter.expandMethodBinding ( final MethodBinding  binding)
protected

Definition at line 3356 of file JavaEmitter.java.

Here is the call graph for this function:

◆ generateMethodBindingEmitters()

List<? extends FunctionEmitter > com.jogamp.gluegen.JavaEmitter.generateMethodBindingEmitters ( final FunctionSymbol  sym) throws Exception
protected

Generate all appropriate Java bindings for the specified C function symbols.

Reimplemented in com.jogamp.gluegen.procaddress.ProcAddressEmitter.

Definition at line 647 of file JavaEmitter.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ generatePrivateEmitters()

void com.jogamp.gluegen.JavaEmitter.generatePrivateEmitters ( final MethodBinding  binding,
final List< FunctionEmitter allEmitters 
)
protected

Generates the private emitters for this MethodBinding.

On the Java side these will simply produce signatures for native methods. On the C side these will create the emitters which will write the JNI code to interface to the functions. We need to be careful to make the signatures all match up and not produce too many emitters which would lead to compilation errors from creating duplicated methods / functions.

Definition at line 534 of file JavaEmitter.java.

Here is the call graph for this function:

◆ generatePublicEmitters()

void com.jogamp.gluegen.JavaEmitter.generatePublicEmitters ( final MethodBinding  binding,
final List< FunctionEmitter allEmitters,
final boolean  signatureOnly 
)
protected

Generates the public emitters for this MethodBinding which will produce either simply signatures (for the interface class, if any) or function definitions with or without a body (depending on whether or not the implementing function can go directly to native code because it doesn't need any processing of the outgoing arguments).

Definition at line 448 of file JavaEmitter.java.

Here is the call graph for this function:

◆ getClassAccessModifiers()

String[] com.jogamp.gluegen.JavaEmitter.getClassAccessModifiers ( final String  classFQName)

Definition at line 2964 of file JavaEmitter.java.

Here is the caller graph for this function:

◆ getConfig()

JavaConfiguration com.jogamp.gluegen.JavaEmitter.getConfig ( )

Implements com.jogamp.gluegen.GlueEmitter.

Definition at line 173 of file JavaEmitter.java.

Here is the caller graph for this function:

◆ getImplPackageName()

String com.jogamp.gluegen.JavaEmitter.getImplPackageName ( )
protected

Returns the value that was specified by the configuration directive "ImplPackage", or the default if none was specified.

Definition at line 2926 of file JavaEmitter.java.

Here is the caller graph for this function:

◆ getJavaOutputDir()

String com.jogamp.gluegen.JavaEmitter.getJavaOutputDir ( )
protected

Returns the value that was specified by the configuration directive "JavaOutputDir", or the default if none was specified.

Definition at line 2910 of file JavaEmitter.java.

Here is the caller graph for this function:

◆ getJavaPackageName()

String com.jogamp.gluegen.JavaEmitter.getJavaPackageName ( )
protected

Returns the value that was specified by the configuration directive "Package", or the default if none was specified.

Definition at line 2918 of file JavaEmitter.java.

◆ getJNIMethodNamePrefix()

static String com.jogamp.gluegen.JavaEmitter.getJNIMethodNamePrefix ( final String  javaPackageName,
final String  javaClassName 
)
staticprotected

Returns the JNI method prefix consisting our of mangled package- and class-name.

Definition at line 317 of file JavaEmitter.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ javaImplUnit()

JavaCodeUnit com.jogamp.gluegen.JavaEmitter.javaImplUnit ( )
protected

Definition at line 2877 of file JavaEmitter.java.

Here is the call graph for this function:

◆ javaUnit()

JavaCodeUnit com.jogamp.gluegen.JavaEmitter.javaUnit ( )
protected

Definition at line 2870 of file JavaEmitter.java.

Here is the call graph for this function:

◆ jniMangle()

static String com.jogamp.gluegen.JavaEmitter.jniMangle ( final String  name)
staticprotected

Mangle a class, package or function name for JNI usage, i.e.

replace all '_' w/ '1' and '.' w/ ''

Definition at line 313 of file JavaEmitter.java.

Here is the caller graph for this function:

◆ layoutStruct()

void com.jogamp.gluegen.JavaEmitter.layoutStruct ( final CompoundType  t) throws Exception

Lays out one struct which will be emitted later.

Implements com.jogamp.gluegen.GlueEmitter.

Definition at line 764 of file JavaEmitter.java.

Here is the call graph for this function:

◆ mangleBinding()

void com.jogamp.gluegen.JavaEmitter.mangleBinding ( final MethodBinding  binding)
protected

Allow specializations to modify the given MethodBinding before expanding and emission.

Definition at line 3349 of file JavaEmitter.java.

◆ openCUnit()

CCodeUnit com.jogamp.gluegen.JavaEmitter.openCUnit ( final String  filename,
final String  cUnitName 
) throws IOException
protected
Parameters
filenamethe class's full filename to open w/ write access
cUnitNamethe base c-unit name, i.e. c-file basename with suffix
generatorinformal optional object that is creating this unit, used to be mentioned in a warning message if not null.
Exceptions
IOException

Reimplemented in com.jogamp.gluegen.structgen.CStructAnnotationProcessor.AnnotationProcessorJavaStructEmitter.

Definition at line 2801 of file JavaEmitter.java.

Here is the caller graph for this function:

◆ openJavaUnit()

JavaCodeUnit com.jogamp.gluegen.JavaEmitter.openJavaUnit ( final String  filename,
final String  packageName,
final String  simpleClassName 
) throws IOException
protected
Parameters
filenamethe class's full filename to open w/ write access
packageNamethe package name of the class
simpleClassNamethe simple class name, i.e. w/o package name or c-file basename
generatorinformal optional object that is creating this unit, used to be mentioned in a warning message if not null.
Exceptions
IOException

Reimplemented in com.jogamp.gluegen.structgen.CStructAnnotationProcessor.AnnotationProcessorJavaStructEmitter.

Definition at line 2812 of file JavaEmitter.java.

Here is the caller graph for this function:

◆ prepCEmitter()

void com.jogamp.gluegen.JavaEmitter.prepCEmitter ( final String  returnSizeLookupName,
final JavaType  javaReturnType,
final CMethodBindingEmitter  cEmitter 
)
protected

Definition at line 612 of file JavaEmitter.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readConfigurationFile()

void com.jogamp.gluegen.JavaEmitter.readConfigurationFile ( final String  filename) throws Exception

Implements com.jogamp.gluegen.GlueEmitter.

Definition at line 167 of file JavaEmitter.java.

Here is the call graph for this function:

Member Data Documentation

◆ cfg

JavaConfiguration com.jogamp.gluegen.JavaEmitter.cfg
protected

Definition at line 111 of file JavaEmitter.java.

◆ LOG

final LoggerIf com.jogamp.gluegen.JavaEmitter.LOG
protected

Definition at line 155 of file JavaEmitter.java.


The documentation for this class was generated from the following file: