aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/gluegen
Commit message (Collapse)AuthorAgeFilesLines
* feat(feature): Enable pragma once managementMathieu Féry2023-06-163-11/+47
|
* GlueGen Struct [6]: Simplify adding 'private ElementBuffer _eb*' memory ↵Sven Gothel2023-06-161-27/+3
| | | | buffer cache once @ 'releaseVal(..)' code creation
* GlueGen Struct [5]: Revised Struct Mapping + DocumentationSven Gothel2023-06-161-868/+959
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 [4]: JavaConfiguration Change: Drop 'ManualStaticInitCall', ↵Sven Gothel2023-06-163-103/+93
| | | | | | | | | | | | | 'ForceStaticInitCode'; Add 'ReturnsStringOnly', 'MaxOneElement' and 'ImmutableAccess' Drop 'ManualStaticInitCall', 'ForceStaticInitCode': With new CCodeUnit's `JVMUtil_NewDirectByteBufferCopy(..)` implementation and generalized Buffers' methods, no specific init code is required anymore. Add 'ReturnsStringOnly', 'MaxOneElement' and 'ImmutableAccess': - 'ReturnsStringOnly' only String getter, drop ByteBuffer/byte[] - 'MaxOneElement' only one element maximum for pointer reference - 'ImmutableAccess' strict read-only, also reduces generated code a lot
* GlueGen Struct [3]: Adopt to CodeUnit Abstraction (replacing plain ↵Sven Gothel2023-06-169-640/+678
| | | | PrintWriter...)
* GlueGen Struct [2]: Add CodeUnit: Representing a generated C or Java file, ↵Sven Gothel2023-06-164-1/+261
| | | | | | | | | covering multiple FunctionEmitter allowing to unify output, decoration and dynamic helper code injection per unit - Handles file open and have public ctor emitAutogeneratedWarning(..), being self-contained - Includes `JVMUtil_NewDirectByteBufferCopy(..)` implementation in CCodeUnit, may be injected if required in customCode via emitHeader(..)
* Replace AccessController.doPrivileged() w/ SecurityUtil.doPrivileged()Sven Gothel2023-01-141-3/+2
|
* Bug 1412 - JNI: GlueGen JavaEmitter: Check & Handle Exception after calling ↵Sven Gothel2019-12-061-0/+7
| | | | | | | back into Java The generated JNI code JVMUtil_NewDirectByteBufferCopy(..) calls Buffers.newDirectByteBuffer(..) and potential exceptions should be checked.
* Bug 1363: Java 11: Revert CStructAnnotationProcessor's ↵Sven Gothel2019-08-191-1/+1
| | | | | | | | | | | | | | | | | @SupportedSourceVersion back to 11 Behold, the issue as documented at commit 2d89df89453c099d4e357aa17eae88efcf1d1b70, one build machine failing to compile SourceVersion.RELEASE_11 was due to an incomplete installation of openjdk-11-jdk on Debian GNU/Linux. Wow. I have re-installed the openjdk-11-jre and openjdk-11-jdk packages on said machine, ensured they are being used .. and it works. Another note here regarding usage of OpenJDK11 compile time environment and Java8 target. If using Eclipse, I had to set the system runtime JDK to JDK 8. Otherwise the 'editor clean-up' jobs would run against the JDK 11 classes and wrongly so change certain type castings etc, incompatible with Java 8. If anybody knows a solution here .. shoot.
* Bug 1363: Java 11: Document Java8 target constraints; Fix one odd compile issueSven Gothel2019-08-191-1/+1
| | | | | | | | | | | | | | Document Java8 target constraints, i.e. where we need to set source, target and bootclasspath to ensure target runtime Java8 compliance. Fix one odd compile issue! Using two theorethical identical GNU/Linux Debian 10 machines with same set of installed software, one passes (like MacOS, Windows) and one fails. The failure was due to the CStructAnnotationProcessor's @SupportedSourceVersion tag. This downgrades the SourceVersion's previous bump from 6->11 (commit 610493b1724b5d91327f478338ff5d029bdcc032) down to 8. Interesting times ..
* 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.
* Fixed null pointer exception in logging printWade Walker2019-08-161-1/+4
|
* Fix warning in annotation processorWade Walker2019-08-161-1/+1
|
* Bug 1166: Refine fix of JavaEmitter's JVMUtil_NewDirectByteBufferCopy (2)Sven Gothel2015-07-161-3/+11
| | | | | | | Further refine code, see commit f6a5ac4473135bbc4bc1a5f537e060df45eb4824. - Perform a NULL check on Buffers.newDirectByteBuffer(..) result. - Only copy memory if capacity > 0, incl fetching direct buffer address
* JavaEmitter.staticClassInitCodeCCode: Reuse static stringsSven Gothel2015-07-161-7/+10
|
* Bug 1166: Refine fix of JavaEmitter's JVMUtil_NewDirectByteBufferCopySven Gothel2015-07-161-3/+11
| | | | | | | | | | | See commit e424c28f869269f5a22c22ef017230346b22847a (first patch) Since JVMUtil_NewDirectByteBufferCopy is being called w/ 'size_t' values, e.g. 'count * sizeof(Structure)', we shall validate whether 'capacity' is valid, i.e. <= MAX_INT. After validation, 'capacity' is being cast to 'jint' before being passed to the java method.
* BUG 1166: Fix JavaEmitter JVMUtil_NewDirectByteBufferCopyXerxes Rånby2015-07-081-2/+2
| | | | | | | | | | | Prevents jlong to jint truncation when capacity is passed from jni to java. com.jogamp.common.nio.Buffers newDirectByteBuffer and the underlying java.nio.ByteBuffer allocateDirect only work with capacitys of int size. Signed-off-by: Xerxes Rånby <[email protected]>
* Bug 1153 - GlueGen: Support [const] [native] expressions and conversion to ↵Sven Gothel2015-04-017-342/+942
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | java space, incl. [native] numbers Rewrite ConstantDefinition: Add sub-class CNumber: - containing integer/float values and their original qualifiers [long, double, unsigned] - conversion to java number ConstantDefinition: - holds native expression - optionally holds CNumber representing native expression, if [only] a number - can compute equivalent java expression with result type (JavaExpr) Add static native number reg-expression for number detection and parsing. Add static native number to CNumber conversion methods. +++ Retrieve full LISP tree and convert to serialized expression to be utilized for expressions used in enumerates. Parse enumerates, allowing const native expressions: - Utilize ConstantDefinition either for definite CNumber or expression - Simply add "+1" for new default values, if previous is an expression
* JavaEmitter: Always use 'containingJTypeName' for ↵Sven Gothel2015-03-261-6/+6
| | | | | | | JavaConfiguration.canonicalStructFieldSymbol(..) Patch harmonizes configuration, was also using 'structCTypeName' besides 'containingJTypeName', but surely it makes no sense to use different type names for struct-field configurations.
* Bug 1149: Fix parsing of hexadecimal w/ binary exponent floats in ↵Sven Gothel2015-03-252-36/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | regexp-constant and java-parser. (Due to PCPP -> JCPP) Lack of parsing binary exponent floats is exposed due to using JCPP and correct constant-definitions. - JavaParser.g: - Add support for hexadecimal w/ binary exponent floats - TAB -> 4 spaces - ConstantDefinition.java: - Add RegExp 'fpRegexp', patternDecimalNumber: decimal number w/ support for hexadecimal w/ binary exponent floats. - isDecimalNumber(..): Use patternDecimalNumber instead of try-and-error (NumberFormatException) - patternCPPOperand: exclude patternDecimalNumber! - JavaEmitter.java: - Respect explicit suffix [dD] for double type. - Drop floating point suffixes [fF] - Test: Added tests for hexadecimal w/ binary exponent floats
* Bug 1149 - Replacing PCPP w/ JCPP: Name used CPP impl.Sven Gothel2015-03-241-7/+9
|
* Fix Logging: PlainLogConsoleHandler shall start w/ Level.ALL, add explicit ↵Sven Gothel2015-03-241-7/+26
| | | | Level setter for handler.
* Bug 1149 - Replacing PCPP w/ JCPP, allowing complete macro handling (Part-2: ↵Sven Gothel2015-03-243-5/+7
| | | | JCPP submodule, build, test and doc)
* Bug 1149 - Replacing PCPP w/ JCPP, allowing complete macro handling (Part-1: ↵Sven Gothel2015-03-236-143/+320
| | | | Cleanup / Preparation)
* Bug 1144 - Add 'DelegateImplementation': Requires own MethodBinding for ↵Sven Gothel2015-03-118-58/+128
| | | | | | | | | | | | | | | | | | | | | | 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 !
* Bug 1134 - LOG AliasedSymbol: Don't issue getAliasedString(), logger takes ↵Sven Gothel2015-03-114-18/+18
| | | | care of that, when it logs.
* Bug 1144 - Add 'DelegateImplementation', manually impl. may delegate to ↵Sven Gothel2015-03-113-9/+106
| | | | | | | | | | | | | | | | | | | | | | | | renamed original 'DelegateImplementation' is a variation of 'ManuallyImplement'. 'ManuallyImplement' emits the interface method, but suppresses the Java and native-code implementation. The latter shall be implemented manually by the user. 'DelegateImplementation' emits the interface method, and the _private_ renamed Java and native-code implementation. Both can be called from the manual user implementation, hence delegation. Configuration: DelegateImplementation <ORIG-SYMBOL> <RENAMED-IMPL-SYMBOL> I.e. delegation model shall apply to <ORIG-SYMBOL> and the Java and native-code implementation renamed to <RENAMED-IMPL-SYMBOL>. The user manual implementation of <ORIG-SYMBOL> may delegate to <RENAMED-IMPL-SYMBOL>.
* Bug 1144 - Add 'DelegateImplementation': Cleanup ↵Sven Gothel2015-03-119-118/+197
| | | | | | | | 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
* Bug 1144 - Add 'DelegateImplementation': Sort JavaMethodBindingEmitter ↵Sven Gothel2015-03-104-48/+51
| | | | argument list; forImplementingMethodCall -> isNativeMethod
* Bug 1144 - Add 'DelegateImplementation': Cleanup JavaConfiguration and use ↵Sven Gothel2015-03-102-65/+83
| | | | manuallyImplement(AliasedSymbol) for FunctionSymbol
* Bug 1134 - Refine err/log message of 'previous definition is here'Sven Gothel2015-03-091-2/+2
|
* Bug 1134 - Add ASTLocusTagProvider for Define and fix newline in c-parser ↵Sven Gothel2015-03-092-3/+16
| | | | (Expose source location for log/error messages)
* Bug 1134 - Fix CMethodBindingEmitter return type '_res' qualifiers (part 2)Sven Gothel2015-03-092-2/+13
| | | | | | | | | 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.
* Bug 1134 - ProcAddressCMethodBindingEmitter: Use available 'ProcAddrTypedef' ↵Sven Gothel2015-03-092-39/+43
| | | | | | | | | | | | | | | | | for type validation w/ local generated variant (robustness) ProcAddressCMethodBindingEmitter code regarding having the public 'ProcAddrTypedef' (from input header) was simply broken, since it always used the local generated 'ProcAddrTypedef', if 'ProcAddrTypedef' was forced. Hence the public 'ProcAddrTypedef' was ignored in most cases. ProcAddressCMethodBindingEmitter's semantic changed from: needsLocalTypedef -> hasProcAddrTypedef New Code generation: - always generated the local 'ProcAddrTypedef' - if hasProcAddrTypedef, use public 'ProcAddrTypedef' for return type variable - cast local 'ProcAddrTypedef' to public 'ProcAddrTypedef', which renders the native compiler to validate the local and public types.
* Bug 1134 - Fix CMethodBindingEmitter return type '_res' qualifiersSven Gothel2015-03-091-2/+3
| | | | | We cannot have the local variable holding the return type 'const' and assign a value to it later.
* Bug 1134 - Fix aliased typedef struct emissionSven Gothel2015-03-093-71/+89
| | | | | | | | | | | | | | | | | | | | | | - Code regarding 'aliased typedef struct' is tagged in JavaEmitter and HeaderParser: 'NOTE: Struct Name Resolution (JavaEmitter, HeaderParser)' Prefers containing cstruct typedef pointer if available _and_ if cstruct is _not_ a typedef! - Removed: 'HeaderParser.resolveAnonCompound(..)' no more required, since CompoundType always sets its name! Commit cf9f28cf249393f42d7d2835775521dfadee6b92 - JavaEmitter.emitStruct: - Regard above 'aliased typedef struct' NOTE - JavaEmitter.typeToJavaType: - Regard above 'aliased typedef struct' NOTE - ReferencedStructs - Drop duplicate CompoundType instances of same name. This can happen due to const/volatile and ASTLocusTag variants.
* Bug 1134 - Fix IntType 'unsigned'; Type: Use copy-ctor instead of Clonable, ..Sven Gothel2015-03-0920-240/+277
| | | | | | | | | | | | - 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
* Bug 1134 - Make ASTLocusTag's text optionalSven Gothel2015-03-093-7/+15
|
* Bug 1134 - Logging's formatter now takes care of Type -> getDebugString() ↵Sven Gothel2015-03-083-43/+72
| | | | | | | 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.
* Bug 1134 - Use ASTLocationTag in Logging (PCPP, Emitter); Refine ↵Sven Gothel2015-03-0815-191/+289
| | | | | | | | 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.
* Fix Type.getDebugString() comma separationSven Gothel2015-03-071-53/+59
|
* Bug 1134 - Fix IntType: Add getCName(..) for proper C-type code; Fix its ↵Sven Gothel2015-03-073-44/+55
| | | | | | | | | | | | | | | 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
* Bug 1134 - Handle Opaque fields in structs; Print struct field name in ↵Sven Gothel2015-03-072-35/+59
| | | | apidoc of getter/setter
* Bug 1134 - Pass ASTLocationTag to all types, used for GlueGenExceptionSven Gothel2015-03-0720-188/+332
| | | | | Enhances semantic exception in code generation by adding the AST location of the type or function declaration.
* Bug 1134 - GlueGenException.toString(): Produce a 'gcc' like/compatible ↵Sven Gothel2015-03-062-5/+13
| | | | error message
* Bug 1134 - Fix ProcAddressEmitter.getFunctionPointerTypedefName() ; Fix ↵Sven Gothel2015-03-063-6/+17
| | | | | | | | | | | JavaEmitter's Function/Struct Emission Fix ProcAddressEmitter.getFunctionPointerTypedefName(): - needs to produce function-pointer-type name w/ original name Fix JavaEmitter's Function/Struct Emission: - needs to create FunctionSymbol w/ original native name, - then rename - preserving the original one.
* Bug 1134 - Utilize AliasedSymbol where required in *Configuration; Clarify ↵Sven Gothel2015-03-065-65/+115
| | | | ProcAddressEmitter criteria
* Bug 1134 - Refine Logging using 'LoggerIf' - Replace System.err w/ Logging ↵Sven Gothel2015-03-068-156/+263
| | | | where appropriate
* Bug 1134 - Add ASTLocationTag, locating source of [semantic] errors while ↵Sven Gothel2015-03-068-17/+253
| | | | | | | parsing / analyzing New GlueGenException supports ASTLocationTag, which will be throws in case of semantic and/or parsing errors.
* Bug 1134 - Fix regression: Static C-Function call must use original API nameSven Gothel2015-03-054-4/+24
| | | | | | | | | - Regression of commit 72d3635279ffc8ad88e47dff9bbe95d211226d11 CMethodBindingEmitter emits statically linked function calls, hence needs to use the original name of AliasedSymbol. AliasedSymbol: Add 'getOrigName()' at creation!