Top Description Interfaces Classes
[default module]

Package com.jogamp.gluegen


JogAmp GlueGen Code Generator

GlueGen Data Type Mapping

Gluegen has build-in types (terminal symbols) for:

type java bits native bits type signed origin
x32 x64
void 0 0 0 void void ANSI-C
char 8 8 8 integerany ANSI-C
short 16 16 16 integerany ANSI-C
int 32 32 32 integerany ANSI-C
long 64 32 321 integerany ANSI-C - Windows
long 64 32 64 integerany ANSI-C - Unix
float 32 32 32 float signed ANSI-C
double 64 64 64 double signed ANSI-C
__int32 32 32 32 integerany windows
__int64 64 64 64 integerany windows
int8_t 8 8 8 integersigned stdint.h
uint8_t 8 8 8 integerunsigned stdint.h
int16_t 16 16 16 integersigned stdint.h
uint16_t 16 16 16 integerunsigned stdint.h
int32_t 32 32 32 integersigned stdint.h
uint32_t 32 32 32 integerunsigned stdint.h
int64_t 64 64 64 integersigned stdint.h
uint64_t 64 64 64 integerunsigned stdint.h
intptr_t 64 32 64 integersigned stdint.h
uintptr_t 64 32 64 integerunsigned stdint.h
ptrdiff_t 64 32 64 integersigned stddef.h
size_t 64 32 64 integerunsigned stddef.h
wchar_t 32 32 32 integersigned stddef.h

Warning: Try to avoid unspecified bit sized types, especially long, since it differs on Unix and Windows!
Notes:

  1. Type long will result in broken code on Windows, since we don't differentiate the OS and it's bit size is ambiguous.
  2. Anonymous void-pointer void* are mapped to NIO Buffer.
  3. Pointers to pointer-size types like intptr_t*, uintptr_t*, ptrdiff_t* and size_t* are mapped to PointerBuffer, to reflect the architecture depending storage size.

GlueGen Internal Alignment for Compound Data

In general, depending on CPU and it's configuration (OS), alignment is set up for each type (char, short, int, long, ..).

Compounds (structures) are aligned naturally, i.e. their inner components are aligned
and are itself aligned to it's largest element.

See:
Simple alignment arithmetic
Modulo operation, where the 2nd handles the case offset == alignment:
padding = ( alignment - ( offset % alignment ) ) % alignment ;
aligned_offset = offset + padding ;
Optimization utilizing alignment as a multiple of 2 -> x % 2n == x & ( 2n - 1 )
remainder = offset & ( alignment - 1 ) ;
padding = ( remainder > 0 ) ? alignment - remainder : 0 ;
aligned_offset = offset + padding ;
Without branching, using the 2nd modulo operation for the case offset == alignment:
padding = ( alignment - ( offset & ( alignment - 1 ) ) ) & ( alignment - 1 ) ;
aligned_offset = offset + padding ;
See com.jogamp.gluegen.cgram.types.SizeThunk.align(..).
Type Size & Alignment for x86, x86_64, armv6l-32bit-eabi and Window(mingw/mingw64)
Runtime query is implemented as follows:
  typedef struct {
    char   fill;  // nibble one byte
                  // padding to align s1: padding_0 
    type_t s1;    // 
  } test_struct_type_t;

            padding_0 = sizeof(test_struct_type_t) - sizeof(type_t) - sizeof(char) ;
  alignmentOf(type_t) = sizeof(test_struct_type_t) - sizeof(type_t) ;
 
type 32 bits64 bits
sizealignmentsizealignment
char 1 1 1 1
short 2 2 2 2
int 4 4 4 4
float 4 4 4 4
long 4 4 8†,4∗ 8†,4∗
pointer 4 4 8 8
long long 8 4†,8∗+ 8 8
double 8 4†,8∗+ 8 8
long double12†∗,8+,16- 4†∗,8+,16- 16 16

† Linux, Darwin
+armv7l-eabi
- MacOsX-32bit-gcc4
∗ Windows

GlueGen Platform Header Files

GlueGen provides convenient platform headers,
which can be included in your C header files for native compilation and GlueGen code generation.

Example:
  #include <gluegen_stdint.h>
  #include <gluegen_stddef.h>

  uint64_t test64;
  size_t size1;
  ptrdiff_t ptr1;
 

To compile this file you have to include the following folder to your compilers system includes, ie -I:
   gluegen/make/stub_includes/platform
 

To generate code for this file you have to include the following folder to your GlueGen includeRefid element:
   gluegen/make/stub_includes/gluegen
 

GlueGen Pre-Defined Macros

To identity a GlueGen code generation run, GlueGen defines the following macros:
    #define __GLUEGEN__ 2
 


Interface Summary

Modifier and TypeInterface and Description
public interface
public interface
GenericCPP

Generic C preprocessor interface for GlueGen

public interface
GlueEmitter

Specifies the interface by which GlueGen requests glue code to be generated.

public interface
GlueEmitterControls

Specifies the interface by which a GlueEmitter can request additional information from the glue generator.

public interface
SymbolFilter

Provides a mechanism by which the GlueEmitter can look at all of the #defines, enum values and function symbols and perform certain filtering and processing which requires all of them to be visible simultaneously.

Class Summary

Modifier and TypeClass and Description
public class
ArrayTypes

Convenience class containing the Class objects corresponding to arrays of various types (e.g., booleanArrayClass is the Class of Java type "boolean[]").

public class
ASTLocusTag

An AST location tag.

public class
CMethodBindingEmitter

Emits the C-side component of the Java<->C JNI binding.

public class
public class
ConstantDefinition

Represents a [native] constant expression, comprises the [native] expression, see getNativeExpr() and the optional CNumber representation, see getNumber().

public class
DebugEmitter

Debug emitter which prints the parsing results to standard output.

public abstract class
public class
GlueGen

Glue code generator for C functions and data structures.

public class
GlueGenException

A generic exception for Jogamp errors used throughout the binding as a substitute for RuntimeException.

public class
JavaConfiguration

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

public class
public class
JavaMethodBindingEmitter

An emitter that emits only the interface for a Java<->C JNI binding.

public class
JavaType

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.

public class
public class
MethodBinding

Represents the binding of a C function to a Java method.

public class
public class
TypeConfig

Static Type config helper binding JavaConfiguration#relaxedEqualSemanticsTest() system wide.

public class
TypeInfo

Utility class for handling Opaque directives for JavaEmitter.