| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
| |
Native pascal strings shall be just treated as normal Java strings on the Java side.
Hence drop the length parameter across generated API, i.e.
- C Function bindings
- Java Callbacks
|
|
|
|
|
|
|
|
| |
STRING_CHARS_PREFIX or javaCallbackEmitter.emitCOptArgumentSuffix(..)
We only produce one variant in code.
Use case: String type as userParam (barely tested and not useful)
|
|
|
|
|
|
|
| |
'CMethodBindingEmitter jcbFuncCMethodEmitter', use local 'info.cbFuncBinding'
Was added in commit ad69716fda64b517c33ed847c4b215ea398aac99 'callback without userData',
while adding ad-hoc compound conversion.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
emitJavaCallbackBodyPassJavaArguments}(): Fix exclusion of ad-hoc compound conversion for userParam
Passed CMethodBindingEmitter denotes the callback-function, including the binding.
The new iteration to handle the ad-hoc compound conversion,
introduced in commit ad69716fda64b517c33ed847c4b215ea398aac99 'callback without userData',
iterates over the callback-function argument list.
Hence it shall only exclude the ad-hoc compound conversion
if index != info.cbFuncUserParamIdx.
Dropping the addition exclusion 'i != info.setFuncUserParamIdx'.
|
|
|
|
| |
NIO ByteBuffer generation (isNIOBuffer || isCompoundTypeWrapper)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
prelim code for JavaCallback use-case emitBodyMapCToJNIType()
It is common in toolkit APIs that a string might not be passed as a 'nul' terminated (EOS) C string,
but as a Pascal string with a given length argument.
A C string is specied as
ArgumentIsString alEventCallbackInject 3
while allowing multiple indices ..
A Pascal string can be specified as
ArgumentIsPascalString ALEVENTPROCSOFT 3 4
while allowing multiple indice-tuples for length and value ..
The tuple consist of the length agrument-index first (usually an int)
followed by the value argument-index (usually a 'char*').
+++
CMethodBindingEmitter.emitBodyMapCToJNIType(), where PascalString is implemented,
is currently being used for
- JNI return statement (no PascalString impact possible)
- JavaCallback C type -> JNI type, PascalString impacting
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
native heap, support Struct UserParam ...
Implementation now generates a static Java callback dispatcher for each defined SetCallbackFunction, which gets invoked by the generated native static counterpart with all arguments required.
The static callback utilizes its own synchronization for thread-safety and fetches the required data set stored at SetCallbackFunction to dispatch the call to the users' CallbackFunction.
In case the callback has been removed already, the static callback simply bails out quietly.
The native code does not create, release or manage heap memory and therefore is considered safe.
+++
Further Struct Type UserParam are now supported including Heterogeneous UserParam mapping (read GlueGen_Mapping.*).
+++
Cleaned up code by extracting all JavaCallback emitter code into JavaCallbackEmitter class in one place,
leaving JavaMethodbindingEmitter and CMethodbindingEmitter mostly in their original stage (non-convoluted).
In this regard, I had to refactor a few function, i.e. moving CMethodbindingEmitter.getJNIMangledArg(..)
into JavaType.appendDescriptor(..) and JavaType.appendJNIDescriptor(..) while reusing the toJNIMethodDescriptor(..) conversion.
Test4JavaCallback covers and passes all cases.
|
| |
|
|
|
|
|
|
| |
exception if occurring - we must assume async off-thread source in general
Covered by unit tests now
|
|
|
|
| |
GetObjectRefType(), avoid certain (older) Hotspot issues
|
| |
|
|
|
|
| |
read-after-free to critical lockObj only
|
|
|
|
| |
(caught), zero-mem @ release
|
|
|
|
| |
synchronize (MonitorEnter/Exit) with same Object of Java impl. -> thread safe
|
|
|
|
|
|
|
|
|
|
|
| |
expose 'Key' to public and use it. Expose release*() and get*Keys() methods
Further we use a dedicated lock Object used in the Java implementation.
TODO: Native static callback dispatch code shall
- (also) acquire the lock
- handle case where the data has been released already
to render this solution thread-safe and data-race free
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
resources via 'JavaCallbackKey' config and custom `SetCallback-KeyClass`
Updated unit test and doc accordingly.
Unit tests handle OpenAL's AL_SOFT_callback_buffer and AL_SOFT_events.
Tested global scope (no key, default) and 1 key (default) and 1 key (custom class).
Added more query functions, which all only take the `SetCallbackFunction` key arguments as specified.
Cleaned up JavaCallback* config class field naminig scheme.
Added 'synchronized (..Map) { }' block in crucial `SetCallbackFunction`,
rendering implementation thread safe.
|
|
|
|
| |
way via a ParameterConsumer visitor, also usable for other iterative parameter generator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
added code generation incl. native to Java dispatch and resource management
Tested via Test4JavaCallback.java (using test2.[hc]).
Please read the GlueGen_Mapping.md as well as Test4JavaCallback.java .
+++
Some implementation details:
JavaConfiguration maps JavaCallbackDef to JavaCallback set-function and maintains a list.
JavaCallbackDef itself holds all configured details.
JavaConfiguration also maps JavaCallbackInfo to JavaCallback set-function.
JavaCallbackInfo itself holds all compile time information, as produced by JavaEmitter.beginFunctions(..).
This extends JavaCallbackDef and avoid repetetive computation for the callback-function-type and its MethodBinding,
parameter indices for the callback interface and userParam, etc.
CMethodBindingEmitter: Native callback to Java dispatch
- The JavaCallback setter function creates a native 'UserParam' struct instance,
which holds the callback-interface-jobject, its callback-jmethodID and
the userParam-jobject for invocation of the actual JavaCallback interface method.
- To produce the C-Type -> JNI-Type conversion, An internal CMethodBindingEmitter instance
for the native-callback function binding is created inside the CMethodBindingEmitter of the callback setter method.
It is being used to map the types to JNI within the generated native callback function,
passed to the actual JavaCallback method.
JavaMethodBindingEmitter: Native callback to Java dispatch
- The JavaCallbacl setter passes the callback-interface-object, the userParam-object and the
callback-method-signature (to have the native method retrieve the jmethodID).
- It receives the native pointer of the native `UserParam` struct instance,
which gets mapped to the userParam-object. (*TODO: Refine ownership + release*).
|
|
|
|
| |
emitBodyMapCToJNIType(): Reuse to converting any C-type argument to java JNI type (i.e. native callback to JavaCallback)
|
|
|
|
| |
names, used in CMethodBindingEmitter; Use JavaCallback's function-pointer-type capital-name as simple-class-name and its FQN for JNI resolution.
|
|
|
|
|
|
|
|
|
|
|
|
| |
generated callback interface mapping the callback function.
This passes the jobject for the callback function/interface and the userParam (from 'void*')
down to the native implementation.
TODO: Add specific native implementation for JavaCallback,
wrapping the jobject's into a native struct as user-param
and a universal C-function as the native callback to dispatch
the call to the java method with known arguments.
|
|
|
|
| |
to be reusable
|
|
|
|
|
|
|
|
|
|
| |
enhance API doc; Add getArrayBaseOrPointerTargetType() and getTargetFunction()
Added getArrayBaseOrPointerTargetType() returns getBaseType() for arrays or getTargetType() for pointer,
i.e. stops traversing if an elementType is a pointer and returns the elementType as target-type.
This resolves 'int* intPtrArray[10]', but also simplifies all cases of 'int** intPtrPtr' and 'int intPtr[10]' etc.
Since get{Base,Target}Type() returns the functionPointer, getTargetFunction() allows to retrieve the actual target function type.
|
|
|
|
| |
getElementType(); Rename getBase{Elem ->}Type() to align with getTargetType()
|
|
|
|
| |
PrintWriter...)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
delegates impl. / Adding ReturnsOpaque
- DelegateImplementation requires own MethodBinding for delegates impl.
The delegation name must be included within
the FunctionSymbol's aliases _only_ for implementations,
where delegation applies.
This allows all subsequent type/cfg checks to hit on AliasedSymbol!
Hence we need to create individual MethodBinding instances
for interfaces and public/private implementations.
- Adding ReturnsOpaque
Configuration:
ReturnsOpaque <Primitive Java Type> <Function Name>
This feature is necessary to achieve 'Opaque' functionality
for function's return type - instead of types in general.
- Fix AliasedSymbolImpl copy-ctor, i.e. this.name = o.name !
|
|
|
|
|
|
|
|
| |
MethodBinding/FunctionBinding Semantics
- Clarify name semantics: name -> [interfaceName, implName, nativeName]
- JavaMethodBindingEmitter: Refine native identity via isNativeMethod + isPrivateNativeMethod
- ProcAddressEmitter: Remove hack whether we need to wrap .. use isNativeMethod + isPrivateNativeMethod
|
|
|
|
|
|
|
|
|
| |
Commit 414a0146660cadd35d5ae270f7f819717e9c7374
removed the const/volatile of the local return variable.
This change also casts the function calling result
to the same - hence removing a possible c-compiler warning
of dropping qualifier const.
|
|
|
|
|
| |
We cannot have the local variable holding the return type 'const'
and assign a value to it later.
|
|
|
|
|
|
|
|
|
|
|
|
| |
- Fix IntType 'unsigned'
- Need to handle 'unsigned' for typedef and !typedef,
when exposing 'unsigned' for code emission.
- Consider IntType.typedefUnsigned in hash/equals
- Type: Use copy-ctor instead of Clonable enhancing strong typing.
- add 'Type clone(final ASTLocusTag newLoc)'
- Consider Type.typedefCVAttributes in hash/equals
|
|
|
|
|
|
|
| |
when desired, not at 'log' call
Removes load to assemble the getDebugString() of Type and JavaType
when invoking log function. Note: the log may be skipped if log-level is not reached.
|
|
|
|
|
|
|
|
| |
ASTLocationTag log/exception formatting.
Since commit eca019cdea4017227e951d8a9eb30cb34fca4a07, we have ASTLocationTag available.
Hence use it for all logging purposes and emit a standard compiler output,
which shall be parsable by other tools.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
newCVVariant(..), don't pass given cv-attr as typedef
Add getCName(..) for proper C-type code
- Add 'unsigned ' if not typedef and is unsigned.
- Allows removal of special case in CMethodBindingEmitter
- Fixes ProcAddressCMethodBindingEmitter typedef emission
and removes clang warnings, caused by this (many).
Fix its newCVVariant(..), don't pass given cv-attr as typedef
- Proper delegation of 'const', regression of prev. commits
|
|
|
|
|
| |
Enhances semantic exception in code generation
by adding the AST location of the type or function declaration.
|
|
|
|
| |
where appropriate
|
|
|
|
|
|
|
|
|
| |
- Regression of commit 72d3635279ffc8ad88e47dff9bbe95d211226d11
CMethodBindingEmitter emits statically linked function calls,
hence needs to use the original name of AliasedSymbol.
AliasedSymbol: Add 'getOrigName()' at creation!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- We shall be able to import 'most' vanilla GL header,
i.e. only change the typedef part using our GlueGen types
- Type Safety:
- GlueGen now detects '#define' and 'enum' redefines
and throw an exception in this case.
This helps detecting wrongly renamed GL extensions into core!
- GlueGen now detects function redefines (overloading)
and throw an exception in this case.
Hence the semantics of duplicate functions has to be equal!
This helps detecting wrongly renamed GL extensions into core!
- Semantic equality for all types is provided
via interface TypeComparator.SemanticEqualityOp, i.e. 'boolean equalSemantics(..)'
implemented by com.jogamp.gluegen.cgram.types.Type.
Semantic equality can be relaxed via config "RelaxedEqualSemanticsTest true",
i.e. ignoring integer size, and const / volatile qualifiers.
- All equality/hash methods of 'com.jogamp.gluegen.cgram.types.*'
are restructured.
- Track and simplify renamed 'symbol', i.e. use a common
sub-interface for all renamed symbols (ConstantDefinition, FunctionSymbol, ..)
- This is provided in a unified manner
via interface com.jogamp.gluegen.cgram.types.AliasedSymbol
and its common implementation AliasedSymbolImpl
- All JavaConfiguration.shouldIgnore* methods operate w/
'AliasedSymbol' trying to match all aliases.
- Support 'struct NAME [ { ... } ]' w/o typedef's
- New GL / CL headers do not use typedef's for anonymous opaque types
- Opaque Type handling
- JavaConfiguration.typeInfo(..), identifying opaque types,
no more back references from target-type -> typedef.
Hence the following is possible now:
typedef void * Opaque01; // Opaque
typedef void * APointerBuffer; // A Buffer
- All Logger instances are no more static
and derive their warning level from the package's root Logger
via Logging.getLogger(..).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
matching StaticConfig at runtime; Fix PPC (Bug 1056) and MIPSLE (Bug 1014) issues.
Currently the StaticConfig is being queried
via the key[OSType, CPUType ..]
as pre-determined by Java properties or the ELF parser.
This adds complication to maintain different platforms
and the key query might not even be sufficient.
The MachineDescriptor's StaticConfig only purpose shall be
to speed-up native data size and offset/alignment retrieval.
This is done by using the StaticConfig index within
all StaticConfig[]s as a lookup-index for the precomputed
struct's size and offset tables.
+++
Solution:
Rename: MachineDescriptor -> MachineDataInfo
Rename: MachineDescriptorRuntime -> MachineDataInfoRuntime
After having defined os.and.arch (OSType, CPUType and ABIType)
w/ the optional help of the now self containing ELF Reader (Bug 1125),
the native gluegen-rt library gets loaded enabling JNI methods.
It is satisfactory to retrieve MachineDataInfo
at runtime w/ JNI and find the matching/compatible StaticConfig.
Only in case none is found, the program needs to abort.
Otherwise the found MachineDataInfo.StaticConfig and MachineDataInfo
are stored for further use (see above).
This removes above complication and key to StaticConfig mapping.
New platforms simply need to add a new unique entry into the
StaticConfig[] table.
++
Also fixes Bug 1056 (PPC), thanks to tmancill [@] debian [.] org,
and Bug 1014 (MIPSLE), thanks to Dejan Latinovic.
Parts of the patch for Bug 1014 from Dejan Latinovic are included.
also solved by this change set.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
c47bc86ae2ee268a1f38c5580d11f93d7f8d6e74)
Code Clean-Up based on our Recommended Settings (jogamp-scripting c47bc86ae2ee268a1f38c5580d11f93d7f8d6e74)
- Change non static accesses to static members using declaring type
- Change indirect accesses to static members to direct accesses (accesses through subtypes)
- Add final modifier to private fields
- Add final modifier to method parameters
- Add final modifier to local variables
- Remove unnecessary casts
- Remove unnecessary '$NON-NLS$' tags
- Remove trailing white spaces on all lines
|
|
|
|
| |
usage (cast to void*)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
and string (code generation)
Enhance compound access as delivered by Bug 1022,
to also generate accessors (getter and setter) for
array, pointer and string types.
Allow configuration of array length either via
their internal size (c-header) or config 'ReturnedArrayLength'.
'ReturnedArrayLength' allows specifying a java expression.
Canonical field names of compounds are _now_ specified as
follows for configuration entries:
COMPOUND.FIELD
e.g.
StructA.fieldB
Also allow configuration of pointer fields to be treated as
referenced arrays via 'ReturnedArrayLength'.
Further, allow specifying 'pointer fields' as String values
via 'ReturnsString' configuration.
++++
Implementation details:
- handle above described accessor features
- enhance JavaDoc for generated accessors
- generate native JNI compound and string accessor on demand
- encapsule accessor code generation in their own methods
- enhance exception messages
- enhance type verbosity in debug mode
- verbose debug output via GlueGen.debug()
Tests:
- Features covered by test1.[ch]
and Test1p1JavaEmitter and Test1p2ProcAddressEmitter
- Validated compilation and unit tests for modules:
- joal
- jogl (minor config changes req.)
- jocl (minor config changes req.)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Completing commit c3054a01990e55ab35756ea23ab7d7c05f24dd37
by allowing passing compound arrays via 'call-by-value.
- Creating linear temp heap, copying NIO values into it
and passing to C function.
Copy-back if not 'const', see below.
- Respect 'const' qualifier to skip write-back of
temp heap passed to C function
- See tag: // FIXME: Compound and Compound-Arrays
for code changes and validation of completeness
- triggers for compound arrays are:
- javaType.isArrayOfCompoundTypeWrappers()
- type.isArray()
- simplified const query by c-type: FunctionEmitter.isBaseTypeConst(ctype)
+++
Tests: Added call-by-value to test1.[ch] binding test!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
returning struct instance
'compound call-by-value' is not efficient.
However, to allow mapping APIs utilizing passing small structs
as arguments and return values - this feature has been added.
+++
To return the struct value, native code needs to
allocate a NIO ByteBuffer and copy the data.
The stack return value can be dismissed afterwards and the
NIO buffer is returned.
We include this functionality for all generated [impl] classes,
native method:
'static jobject JVMUtil_NewDirectByteBufferCopy(JNIEnv *env, void * source_address, jlong capacity)'
(See: 'JavaEmitter.initClassAccessCode')
Since this code requires knowledge of java classes and methods,
for which a reference needs to be acquired, a static initialization method
has been introduced for all generated [impl] classes:
'private static native boolean initializeImpl();'
Per default the this method will be called in the new
static initializer block of the class,
which can be supressed via the configuration element:
'ManualStaticInit <class-name>'
'ManualStaticInit' can be used to issue the 'initializeImpl()'
call in a custom static initializer written by the user.
However, at the time 'initializeImpl()' gets called
the JNI native library must have been loaded, of course!
+++
- See tag: // FIXME: Compound call-by-value
for code changes and validation of completeness
Trigger for compond call-by-value in CMethodBindingEmitter is:
!cArgType.isPointer() && javaArgType.isCompoundTypeWrapper()
Trigger for compond call-by-value in JavaEmitter is:
t.isCompound()
+++
Further more we do tolerate 'javaType.isCPrimitivePointerType()',
i.e. adding comments for offset/size and field entries,
which are all NOP.
This allows to utilize the remaining fields of the native structure.
+++
Tests: Added call-by-value to test1.[ch] binding test!
|
| |
|
| |
|
|
|
|
|
|
|
|
| |
Fix 1: Only emit "int * _offsetHandle = NULL" if it will be used, to
avoid unused variable warning. Fix 2: Add "unsigned" to typecasts in C
function calls when needed to avoid implicit typecast warning. This
commit also adds a unit test for a method that uses an "unsigned char
**" parameter, to mimic the JOCL clCreateProgramWithBinary() function
that caused the typecast warnings.
|
|
|
|
| |
Signed-off-by: Harvey Harrison <[email protected]>
|
|
|
|
| |
Signed-off-by: Harvey Harrison <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
GetPrimitiveArrayCritical(..)
The 'carray' pointer returned from GetPrimitiveArrayCritical(..) was moved about the array offset
and used in ReleasePrimitiveArrayCritical(..) to release the pinpointed memory.
Even though this 'is' a bug by violating the _sparse_ specification, Hotspot impl. doesn't use the value at all (NOP)
and hence this code didn't produce an error since .. (Same w/ Dalvik).
Now the array offset is added while passing the carray pointer to the native function call
and hence is no more modified and the orig. value is passed to ReleasePrimitiveArrayCritical(..).
Tested w/ GlueGen unit tests and all JOGL unit tests (on Linux x64 w/ 'a' hotspot VM).
|