aboutsummaryrefslogtreecommitdiffstats
path: root/src/junit/com
Commit message (Collapse)AuthorAgeFilesLines
* GlueGen JavaCallback: Add optional custom 'Callback-UserParamClass` for ↵Sven Gothel2023-07-104-309/+308
| | | | non-compound `UserParam` types to have more clarity in resulting API
* GlueGen JavaCallback: Add capability to have UserParam as (part of) keySven Gothel2023-07-086-60/+492
| | | | | | | | | 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.
* GlueGen JavaCallback: Remove ambiguity: Config ↵Sven Gothel2023-07-064-22/+25
| | | | JavaCallbackDef/JavaCallbackKey: Always define both parameter indices; emitJavaStaticCallback(): Use cbFuncBinding and cbFuncKeyIndices from callback parameter to build key
* GlueGen: Add 'PascalString' string semantics (length + value-ptr), added ↵Sven Gothel2023-07-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* GlueGen JavaCallback: Revised: Static Java callback dispatcher, dropping ↵Sven Gothel2023-07-044-27/+517
| | | | | | | | | | | | | | | | | | | | | | | | | 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.
* GlueGen JavaCallback: CMethodBindingEmitter: Check, describe & clear ↵Sven Gothel2023-07-021-7/+98
| | | | | | exception if occurring - we must assume async off-thread source in general Covered by unit tests now
* GlueGen Struct [18]: Drop redundant 'static get*ElemCount() { return 1 }` ↵Sven Gothel2023-07-021-1/+1
| | | | for: isPrimitive && !isPointer && staticElemCount && maxOneElement
* GlueGen JavaCallback: Native callback: Check ObjectRef validity and ↵Sven Gothel2023-07-021-10/+18
| | | | synchronize (MonitorEnter/Exit) with same Object of Java impl. -> thread safe
* GlueGen JavaCallback: Use `SetCallback-KeyClass` if manually specified, even ↵Sven Gothel2023-07-012-1/+26
| | | | if no keys are defined!
* GlueGen JavaCallback: Only produce default 'Key' class if keys are used, ↵Sven Gothel2023-07-012-103/+334
| | | | | | | | | | | 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
* GlueGen JavaCallback: Resolve key mapping of callback and associated ↵Sven Gothel2023-06-304-26/+597
| | | | | | | | | | | | | | | | 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.
* Test4JavaCallback: Just rename myUserParam -> myUserParam01 for future tests..Sven Gothel2023-06-291-22/+22
|
* GlueGen JavaCallback: Set-Callback: Ensure a previously mapped 'userParam' ↵Sven Gothel2023-06-291-9/+39
| | | | instance is released before binding new one; Add test changing callback function.
* GlueGen JavaCallback: 1st Working Draft: Changed 'JavaCallbackDef' config, ↵Sven Gothel2023-06-295-36/+235
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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*).
* GlueGen Struct [17]: Handle void pointers, i.e. `void*`, within a struct as ↵Sven Gothel2023-06-291-0/+6
| | | | | | `Opaque` configured pointer-types .. includes cross-ref'ed doc and unit test
* GlueGen JavaCallback: Add preliminary implementation (WIP): Produces proper ↵Sven Gothel2023-06-252-4/+12
| | | | | | interfaces, TODO implementation Note: JavaCallbackDef is commented out on test2.cfg example, since implementation is missing.
* GlueGen Struct [16]: Add support for pointer-pointer and function-pointer valuesSven Gothel2023-06-235-11/+234
| | | | See documentation and unit test test2.h, Test2FuncPtr.java and Test3PtrStorage.java
* GlueGen Test: Test2 -> Test2FuncPtrSven Gothel2023-06-231-3/+3
|
* GlueGen junit test2.h: Add an anonymous struct pointer w/ opaque long configSven Gothel2023-06-202-5/+4
|
* GlueGen Struct [15b]: FunctionPointer: Drop is<FuncName>Null() -> use ↵Sven Gothel2023-06-203-20/+19
| | | | get<FuncName>()
* GlueGen Struct [15]: Add FunctionPointer getter and setter support w/ ↵Sven Gothel2023-06-205-47/+235
| | | | documentation
* CustomJNICode: Add missing (separated) test1p1-CustomJNICode.c.stubSven Gothel2023-06-181-0/+5
|
* CustomJNICode: Fix/complete commit d7bc10d7ff0e3a30d74c4e4c439230f3983bcfb4: ↵Sven Gothel2023-06-184-17/+9
| | | | Add emitCustomJNICode(..) for JavaEmitter.endFunctions() not just structs and fix the JNI-c stub code
* Merge remote-tracking branch 'Mathieu_Fery/feature/add_customJNICode_directive'Sven Gothel2023-06-188-0/+51
|\
| * feat(jni): Add directive for dedicated JNI Code with CustomJNICodeMathieu Féry2023-06-168-0/+51
| |
* | Merge remote-tracking branch 'Mathieu_Fery/feature/support_of_bitwise_not'Sven Gothel2023-06-182-0/+17
|\ \
| * | feat(constants): Add supports of ~ inside ConstantDefinitionMathieu Féry2023-06-162-0/+17
| |/
* | Merge remote-tracking branch 'remotes/Mathieu_Fery/feature/enable_pragma_once'Sven Gothel2023-06-183-4/+32
|\ \
| * | feat(feature): Enable pragma once managementMathieu Féry2023-06-163-4/+32
| |/
* | GlueGen Struct [9b]: Add unit test for fixed 'void*' regression commit ↵Sven Gothel2023-06-182-3/+9
| | | | | | | | | | | | | | | | | | eec3f21c3597ff9bf9760a06e00dd341214ea90d See impact to T2_InitializeOptions struct fields: - 'void* Reserved1' shall be ignored (*this is the regression fix*) - 'void* Reserved2' will be taked due to config 'Opaque long T2_InitializeOptions.Reserved2' - 'T2_CustomFunc CustomFunc2' will produce a member function call as previously
* | GlueGen Struct [8]: Revised setter (resolved shrinking array, using 'subset' ↵Sven Gothel2023-06-171-22/+314
|/ | | | | | | | | | | | | | | | | | | | | | flag), added (detailed) JavaDoc in generated code Revised setter: A) int32_t val[10] -> setter for a subset change only, as-is with args[src, srcPos, destPos, length] - no new memory, reuse only - no special action to be performed B) int32_t* val -> setter with toggle 'subset' with args[subset, src, srcPos, destPos, length], - replace memory w/ 'subset==false' where it also may copy 'destPos' gap from old -> new - reuse memory w/ 'subset==true', where destPos+length <= elementCount C) const int32_t* val -> setter to replace referenced memory only args[src, srcPos, length] - always replaces memory, no copy of a gap (no destPos) Hence: - case (A) stays as is - case (B) will be revised and argument 'boolean subset' added - case (C) will be revised (simplified) and argument 'destPos' removed
* GlueGen Struct [5]: Revised Struct Mapping + DocumentationSven Gothel2023-06-1610-520/+1897
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GlueGen Revised Struct Mapping (esp pointer to array or single element), Struct String Charset, .. and Documentation - Documentation: - Added README.md Let's have a proper face for the git repo - Added doc/GlueGen_Mapping.md (and its html conversion doc/GlueGen_Mapping.html) Created a new document covering application and implementation details suitable for users/devs. - Added doc/JogAmpMacOSVersions.md conversion to doc/JogAmpMacOSVersions.html - Updated www/index.html - Use *CodeUnit instead of PrintWriter, representing a Java or C code unit covering a set of functions and structs. The CCodeUnit also handles common code shared by its unit across functions etc. - Dropping 'static initializer', as its no more required due to simplified `JVMUtil_NewDirectByteBufferCopy()` variant. - Revised Struct Mapping: - Pure Java implementation to map primitive and struct fields within a struct by utilizing ElementBuffer. Only 'Function Pointer' fields within a struct require native code. Exposes `static boolean usesNativeCode()` to query whether native code is used/required. - Transparent native memory address API Expose `long getDirectBufferAddress()` and `static TK_Struct derefPointer(long addr)`, allowing to - pass the native struct-pointer with native code - reconstruct the struct from a native struct-pointer - have a fully functional `TK_Struct.derefPointer(struct.getDirectBufferAddress())` cycle. - Add 'boolean is<Val>Null() to query whether a pointer (array) is NULL - *Changed* array get/set method for more flexibility alike `System.arraycopy(src, srcPos, dest, destPos, len)`, where 'src' is being dropped for the getter and 'dest' is being dropped for the setter as both objects are reflected by the struct instance. - *Changed* `get<Val>ArrayLength()` -> `get<Val>ElemCount()` for clarity - Considering all ConstElemCount values with config 'ReturnedArrayLength <int>' to be owned by native code -> NativeOwnership -> Not changing the underlying memory region! JavaOwnership is considered for all pointer-arrays not of NativeOwnership. Hence any setter on a NativeOwnership pointer-array will fail with non-matching elem-count. - Add 'release<Val>()' for JavaOwnership pointer-arrays, allowing to release the Java owned native memory incl. null-ing pointer and set<Val>ElemCount(0). - Support setter for 'const <type>*' w/ JavaOwnership, i.e. pointer to const value of a primitive or struct, setter and getter using pointer to array or single element in general. - Added Config `ImmutableAccess symbol` to disable all setter for whole struct or a field - Added Config `MaxOneElement symbol` to restrict a pointer to maximum one element and unset initial value (zero elements) - Added Config `ReturnsStringOnly symbol` to restrict mapping only to a Java String, dropping the ByteBuffer variant for 'char' - String mapping default is UTF-8 and can be read and set via [get|set]Charset(..) per class. - Dynamic string length retrieval in case no `ReturnedArrayLength` has been configured has changed from `strlen()` to `strnlen(aptr, max_len)` to be on the safe site. The maximum length default is 8192 bytes and can be read and set via [get|set]MaxStrnlen(..) per class. FIXME: strnlen(..) using EOS byte non-functional for non 8-bit codecs like UTF-8, US-ASCII. This is due to e.g. UTF-16 doesn't use an EOS byte, but interprets it as part of a code point. - TODO: Perhaps a few more unit tests - TODO: Allow plain 'int' to be mapped in structs IFF their size is same for all MachineDescriptions used. Currently this is the case -> 4 bytes like int32_t.
* GlueGen Struct [1]: Enhance com.jogamp.common.nio.* to serve a most ↵Sven Gothel2023-06-161-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | native-free-code Struct-Code generation Recfactored all NIO buffer utils to Buffers, i.e. buffer <-> address, memcpy, strnlen, etc Buffers: - Added copyNativeToDirectByteBuffer(..), allowing to copy a native memory slice into a direct buffer. - Added typeNameToBufferClass(String) and sizeOfBufferElem(Class<? extends Buffer>) - Completed slize2<Type>(..) buffer-mapping methods - Exposure of safe getDirectByteBuffer(..) w/ null-check (package private) Added NativeBuffer.storeDirectAddress(..), allowing to write the array address into a native buffer (struct, etc), allowing to referencing the ElementBuffer (linear array of elements) and PointerBuffer (array of pointer). Hint: This can be read via PointerBuffer.wrap(..).get(0) Added ElementBuffer (a NativeBuffer) mapping an array of elements, completing native abstraction next to PointerBuffer (array of pointer). ElementBuffer can dereference an existing element-array by native address via ElementBuffer.derefPointer(..). Views of its content can be directly accessed via ElementBuffer.slice(..). +++ These utilities and buffer abstractions will allow to reuse code and simplify the GlueGen struct get/set implementations and help to reduce native code injection.
* IOUtil.copyStreamChunk2ByteBuffer(..): Added new method to copy a chunk ↵Sven Gothel2023-05-041-0/+112
| | | | | | | | | | (segment) of the input stream (skipBytes, byteCount) This method is inspired by Bug 1280, <https://github.com/sgothel/joal/pull/16>, 'copy only needed bytes' for JOAL's com.jogamp.openal.util.WAVData.loadFromStream(..). This method is a revised version of the proposed IOHelpers.copyFromStream2ByteBuffer(..), see <https://github.com/OndrejSpanel/joal/commit/1616659e98904270af4faca25b770d0983609735>
* IOUtil.copyStream2{File|Stream)(..): Drop unused and misleading ↵Sven Gothel2023-05-042-2/+2
| | | | 'totalNumBytes' argument, since we have no user-feedback callback passed.
* Clock: Use Clock.currentNanos() instead of System.nanoTime()Sven Gothel2023-03-073-26/+34
|
* Formatting: BindingJNILibLoader, AWTEDTExecutorSven Gothel2023-01-231-19/+19
|
* src/junit/com/jogamp/gluegen/test/junit/generation/test1.h: Fix warnings re ↵Sven Gothel2023-01-151-3/+3
| | | | 'const' qualifier
* TestRecursiveLock01, TestRecursiveThreadGroupLock01: 'yield()' -> ↵Sven Gothel2023-01-152-6/+6
| | | | 'yield_thread()' to avoid potential Java>17 collision (JEP 361)
* TestIteratorIndexCORE: Fix template usageSven Gothel2023-01-151-11/+11
|
* Replace AccessController.doPrivileged() w/ SecurityUtil.doPrivileged()Sven Gothel2023-01-141-4/+8
|
* Fix unit test1.hSven Gothel2023-01-141-2/+2
|
* minor autocleanup (final removed from static)Sven Gothel2019-11-281-1/+1
|
* Windows Regression: Mingw64 8.1.0 using statical linked tool lib ↵Sven Gothel2019-08-191-0/+271
| | | | | | | | | | | | | | | | | | | Test1p1Test1p1JavaEmitter 'com.jogamp.gluegen.test.junit.generation.Test1p1JavaEmitter' exposes a regression using MingW64 8.1.0: System.loadLibrary() gives a "Can't find dependent libraries". Here, 'Bindingtest1p1' is linked against 'test1' and fails to load due to its wrong dependent library name within 'Bindingtest1p1'. MingW64 8.1.0 dropped 'libtest1.so' into 'Bindingtest1p1.dll', which is surely wrong. Even passing '-Wl,-soname=test1.dll' didn't help. Note: Such constellation would only work with adding the lib-path to PATH on Windows. Since we don't utilize the method in any of our projects, but use the dynamic library lookup method - this is not a blocker, but wasted some good time.
* Bug 1363: Java 11: Resolve Buffers.Cleaner implementationSven Gothel2019-08-193-5/+22
| | | | | | | | | | | As of Java9, sun.misc.Cleaner has moved to jdk.internal.ref.Cleaner. However, access has been made (under the table) via sun.misc.Unsafe, which we are using for now as we cannot set the jdk.internal.ref.Cleaner method accessible. In this regard, we had to change our Cleaner.clean(..) method using a ByteBuffer instead of a Buffer object paramter. All tests have passed, no more illegal access case running on Java11 has been exposed.
* Bug 1363: Java 11: Complete renaming JEP 178 compatible native lib basename ↵Sven Gothel2019-08-181-1/+1
| | | | | | | | | | gluegen-rt -> gluegen_rt - Fix finding native library for Elf parsing - Fix one unit test - Fix comments Completes commit 330dad069dee5a0cc0480cf5cd9052000004223a
* Fixed CStruct annotation processor to not use dummy Java variable typesWade Walker2019-08-161-1/+1
| | | | | | | | | When annotations were placed on dummy Java variables, the annotation processor was emitting a RenameJavaType directive into the gluegen config file that caused the emitted file to be named boolean.java instead of RenderingConfig.java or Pixel.java. Turned off this behavior when jname is given in the @CStruct annotation. I'm uncertain how much this processor is even used, since I can't find any occurrences of @CStruct outside the test code for it in gluegen.
* Bug 1369: SCC: Hide SHA Algorithm bit size in literals of SpecificationSven Gothel2019-04-031-6/+6
| | | | | Implementation currently uses 256 bit Secure Hash (SHA) algorithm, but this may change in the future. Hence only use 'SHA' in the names, not 'SHA256'.
* Bug 1367: TempJarCache: Fix Unit Test using ReflectionsSven Gothel2019-04-031-4/+4
|
* Bug 1369: Source Certification Contract (SCC): Initial SHA256 fingerprint & ↵Sven Gothel2019-04-031-1/+21
| | | | | | | | | | | | | | | | | | | | | runtime validation This change implements a strong SHA256 signature over: 1) source tree inclusive make recipe (SHA256-Source) 2) all class files (SHA256-Classes) 3) all native libraries (SHA256-Natives) 4) the class files as deployed in the jar (SHA256-Classes-this) 5) the native libraries as deployed in the jar (SHA256-Natives-this) and drops all of these in the deployed Jar file. This allows SHA256 validation of (4) + (5) at runtime and further complete validation (1), (2) and (3) offline. Full SCC would now required (1) - (3) to be placed on a server for further validation. Optionally we may use GPG <https://gnupg.org/> or PGP to validate the build entity to implement the chain of trust <https://en.wikipedia.org/wiki/Chain_of_trust> The SHA256 runtime validation is tested via: com.jogamp.common.util.TestVersionInfo