| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
| |
JavaConfiguration.requiresJavaCallbackCode()"
This reverts commit 927bbc7160a812bb29c0e7120d4a3009bfb13bbf.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Method was encapsulated in commit d4e8ecc3b4f68b86d95ec951971a0fea20217988
and questioned whether it is required.
The non-userParam callback case adds no additional code requirements.
Both, callback with and without userParam shares same code path
and the respective native static fields.
Only that the non-userParam code path adds additional native static fields,
but all code sections are produced in both cases.
Passed all unit tests.
|
|
|
|
|
|
|
|
|
| |
types in equals and hashCode, i.e. use memory identity
Use case is having a compound-type as userParam, which also acts as key, see MessageCallback13, Test4JavaCallback.chapter13().
The Java compound instance is re-created using the actual identical native memory (address),
which has been stored or passed in the native toolkit.
|
|
|
|
|
|
|
|
|
| |
'String')
Use case: String type as userParam, barely tested and not useful.
However, let's pass through all cases in our code.
Added LOG INFO for mapped types.
|
|
|
|
|
|
|
|
| |
STRING_CHARS_PREFIX or javaCallbackEmitter.emitCOptArgumentSuffix(..)
We only produce one variant in code.
Use case: String type as userParam (barely tested and not useful)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
TBD: Is this even required?
- needsIntermediateOperation -> needsJavaCallbackCode
- Use JavaConfiguration.requiresJavaCallbackCode(..)
TBD: Is this even required?
As far as I see, the non-userParam callback case adds no additional code requirements.
Both, callback with and without userParam shares same code path
and the respective native static fields.
Only that the non-userParam code path adds additional native static fields,
but all code sections are produced in both cases.
|
|
|
|
|
|
|
|
| |
and passed 'jcbFuncCMethodEmitter' only to invoke CMethodBindingEmitter.emitBodyMapCToJNIType(..)
Passed 'jcbFuncCMethodEmitter' only used to access CMethodBindingEmitter.emitBodyMapCToJNIType(int, boolean), a non-ideal hack! (FIXME)
General processing shall use the local `info.cbFuncBinding`.
|
|
|
|
|
|
|
|
|
| |
arg 'MethodBinding jcbFuncCMethodBinding', use local 'info.cbFuncBinding'
Since emitJavaCallbackBodyPassJavaArguments() is private now,
only use case is to handle info.cbFuncBinding and we can drop the redundant argument.
Similar to cleanup commit e9a2294b3f18bb4c4f38347ccf347058cb4642b3
|
|
|
|
|
|
|
| |
'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'.
|
|
|
|
| |
emitJavaCallbackBodyPassJavaArguments}(): Use capitalized sub-string 'baseArgName' for (static) callback related entities
|
|
|
|
| |
'userParamDefined' case (cleanup)
|
|
|
|
| |
NIO ByteBuffer generation (isNIOBuffer || isCompoundTypeWrapper)
|
|\
| |
| |
| | |
'Mathieu_Fery/feature/java_callback_without_user_data' into pulled
|
| | |
|
|/
|
|
| |
compound attribute
|
|
|
|
| |
non-compound `UserParam` types to have more clarity in resulting API
|
|
|
|
|
|
|
|
|
| |
Resolves use case where UserParam reflects e.g. a context (AL_SOFT_events)
and will be (part of) the key mapping.
Implementation required an additional userParamID -> userParam mapping for default Object/ID usage.
Added 2 test cases.
|
|
|
|
| |
JavaCallbackDef/JavaCallbackKey: Always define both parameter indices; emitJavaStaticCallback(): Use cbFuncBinding and cbFuncKeyIndices from callback parameter to build key
|
|
|
|
|
|
| |
NewGlobalRef() for jclass (not required for static jmethodID)
Also use a longer jclass argument name 'clazz' -> 'staticCBClazz' to avoid potential collisions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
| |
agnostic 'emitJNIEnvDecl()' (declaration) in JNI code; Detach the thread from the JVM if newly attach in callback!
|
|
|
|
| |
descriptor ('/' not '_') i.e. non JNI method-name descriptor to avoid double conversion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
| |
for: isPrimitive && !isPointer && staticElemCount && maxOneElement
|
|
|
|
| |
read-after-free to critical lockObj only
|
|
|
|
| |
(caught), zero-mem @ release
|
|
|
|
| |
synchronize (MonitorEnter/Exit) with same Object of Java impl. -> thread safe
|
|
|
|
| |
if no keys are defined!
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
| |
actual toolkit setCallback call
.. to avoid a potential race condition
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
| |
instance is released before binding new one; Add test changing callback function.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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*).
|
|
|
|
| |
additional params if produced name containes '__', i.e. JNI mangled parameter
|
|
|
|
| |
drop 'void' and use typedef-name; MethodBinding: Add getCParameterList(..) and getJavaParameterList(..) for general usage similar to FunctionType.getParameterList()
|
|
|
|
| |
emitBodyMapCToJNIType(): Reuse to converting any C-type argument to java JNI type (i.e. native callback to JavaCallback)
|
| |
|
|
|
|
| |
`JNI_OnLoad_<LibraryBasename>(..)` for static libraries and `JVMUtil_GetJNIEnv(..)` to resolve the `JNIEnv*` as used by JavaCallback
|
|
|
|
|
|
| |
`Opaque` configured pointer-types
.. includes cross-ref'ed doc and unit test
|
|
|
|
| |
pass value at invocation, allowing to find the jmethodID of callback
|
|
|
|
| |
across *Emitter (needed for CMethodEmitter as well); Add JavaCallback.methodSignature to be passed to native function later on to find the callback jmethodID
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
| |
generated or existing) Class objects (existing at runtime)
New nature can be queried via isNamedClass().
Cleaned up equals() and completed hashValue() etc.
Ctor validation ensures exactly one nature is set!
|