summaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/gluegen
Commit message (Collapse)AuthorAgeFilesLines
* gluegen: remove the unused reverse map from TypeDictionaryHarvey Harrison2014-07-071-9/+0
|
* gluegen: remove unused imports, unneeded semicolons, add missing @Override ↵Harvey Harrison2014-07-072-2/+2
| | | | annotations
* Code Clean-Up based on our Recommended Settings (jogamp-scripting ↵Sven Gothel2014-07-0352-1275/+1275
| | | | | | | | | | | | | | | 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
* Fix 'typo' in messages: 'Catched' -> 'Caught'Sven Gothel2014-06-281-1/+1
|
* CMethodBindingEmitter: Suppress compiler warning in NewDirectByteBuffer ↵Sven Gothel2014-06-251-2/+2
| | | | usage (cast to void*)
* Bug 1025 - GlueGen: Fix regression of single non-native sized compound fieldsSven Gothel2014-06-251-5/+21
| | | | | Single non-native sized compound fields, if an opaque array/pointer, must utilized the native size StructAccessor get/set method.
* Bug 1025 - GlueGen: Add accessor for compound fields of type array, pointer ↵Sven Gothel2014-06-2511-414/+1149
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.)
* GlueGen: Add support for compound-array in structs (accessors) ; Allow using ↵Sven Gothel2014-06-192-39/+124
| | | | | | | | | | | | | | | C-Enum values for array length - Parser (HeaderParser.g): Support using C-Enum values for array length specification - Will throw an exception if enum identifier is unknown or exceeds int-size - Add StructEmitter supports for compound-arrays - Add Debug stderr verbose info: - Struct Emitter prefix 'SE.' - to analyze emitting struct fields (offset+size and accessors) - Struct Layout prefix 'SL.' - to analyze memory layout (based on MachineDescription.StaticConfig.X86_64_UNIX) Tested via test1.[ch] BaseClass ..
* GlueGen: Refine compound [array] call-by-value native code injection and ↵Sven Gothel2014-06-182-7/+46
| | | | | | | | | | | initialization Follow-up of commit 1eadaf928f4f61aae4de1c8bf33c5b77bdfa882f - Refine MethodBinding detection for 'requiresStaticInitialization', i.e. return type is a "compound type" and not a pointer - JVMUtil_NewDirectByteBufferCopy: Throw FatalError if initializeImpl() has not been called
* GlueGen: Refine compound [array] call-by-value native code injection and ↵Sven Gothel2014-06-182-175/+237
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | initialization Follow-up of commit 9843e983a4fc71a64eb3de9cb364a1f4ffa56b3a Only add static initialization code (java, native) and hence native code 'JVMUtil_NewDirectByteBufferCopy(..)' if either required _or_ forced via configuration. This shall reduce possible sideffects and dead code. Add JavaConfiguration: /** * Returns true if the static initialization java code calling <code>initializeImpl()</code> * for the given class will be manually implemented by the end user * as requested via configuration directive <code>ManualStaticInitCall 'class-name'</code>. */ public boolean manualStaticInitCall(String clazzName); /** * Returns true if the static initialization java code implementing <code>initializeImpl()</code> * and the native code implementing: * <pre> * static jobject JVMUtil_NewDirectByteBufferCopy(JNIEnv *env, void * source_address, jlong capacity); * </pre> * for the given class will be included in the generated code, always, * as requested via configuration directive <code>ForceStaticInitCode 'class-name'</code>. * <p> * If case above code has been generated, static class initialization is generated * to call <code>initializeImpl()</code>, see {@link #manualStaticInitCall(String)}. * </p> */ public boolean forceStaticInitCode(String clazzName);
* Fix commit f4e753ff1f39be381307ffdb0fb6bb7a2d323eff: 'compound array ↵Sven Gothel2014-06-171-47/+55
| | | | call-by-value' JavaMethodBindingEmitter, array may still require NIO handling, also consider NIO array length.
* GlueGen: Add support for 'compound array call-by-value'Sven Gothel2014-06-179-110/+159
| | | | | | | | | | | | | | | | | | | | | | | | | 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!
* Merge remote-tracking branch 'hharrison/antlr-move'Sven Gothel2014-06-1714-6416/+15
|\
| * gluegen: update HeaderParser grammar to annotation EnumType map and ↵Harvey Harrison2014-05-311-2/+1
| | | | | | | | | | | | functions list Signed-off-by: Harvey Harrison <[email protected]>
| * gluegen: remove some unused importsHarvey Harrison2014-05-315-6/+0
| | | | | | | | Signed-off-by: Harvey Harrison <[email protected]>
| * gluegen: move all antlr grammars to a top-level directoryHarvey Harrison2014-05-316-6391/+0
| | | | | | | | | | | | | | | | /src/main/antlr/.. This gets the .g files unmixed from the non-generated java files for the cgram/jgram packages. Signed-off-by: Harvey Harrison <[email protected]>
| * gluegen: update antlr grammer to produce annotated enum and functionName setsHarvey Harrison2014-05-182-17/+15
| | | | | | | | | | | | | | The annotations are all commented out, uncomment them and reduce the type warnings during the build. Signed-off-by: Harvey Harrison <[email protected]>
| * gluegen: remove an unreferenced writer variableHarvey Harrison2014-05-181-1/+0
| | | | | | | | Signed-off-by: Harvey Harrison <[email protected]>
| * gluegen: avoid a suppressed warning annotation by using the ArrayList copy ↵Harvey Harrison2014-05-181-3/+3
| | | | | | | | | | | | | | | | | | | | constructor clone() can't be used without warnigns and is no more efficient that the copy constructor, replace the call and kill the suppressed warning annotation. While here, mark the modifier list as private final. Signed-off-by: Harvey Harrison <[email protected]>
* | GlueGen: Add support for 'compound call-by-value', i.e. passing and ↵Sven Gothel2014-06-175-56/+220
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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!
* | JavaEmitter.typeToJavaType: Simplify if-else block ; ↵Sven Gothel2014-06-162-5/+5
|/ | | | JavaType.getDumpString(): Add more info ..
* gluegen: avoid appending Strings in a loop, pull out a Stringbuilder we can ↵Harvey Harrison2014-05-171-11/+17
| | | | | | | | reuse Reuse a single stringbuilder to build all the comment strings and emit them if required. Signed-off-by: Harvey Harrison <[email protected]>
* Bug 923: Remove dependency of CStruct annotation processor _generation_ and ↵Sven Gothel2014-05-114-177/+281
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | generated_class_user due to Java8 issues. Java8's annotation processor as embedded within javac does not allow referencing not-yet existing generated classes in a class source code which will produce these generated classes via the annotation process. Example: +++ import com.jogamp.gluegen.structgen.CStruct; public class Lala { @CStruct(name="RenderingConfig", header="TestStruct01.h") public RenderingConfig config; } +++ Above example illustrates that the type 'RenderingConfig' does not exist at time of processing the annotation. The type will be created via the annotation process itself. Even though we pass '-proc:only', i.e. skip java compilation, Java8's annotation processing via javac fails in such case. We see this as a bug within javac's annotation processing itself! +++ This workaround splits the annotation process and using the class as generated by the former. To allow this to work, CStruct receives a new field 'jname' allowing to enforce the java-name of the structure using a dummy field type like boolean. @CStruct(name="RenderingConfig", jname="RenderingConfig", header="TestStruct01.h") public boolean dummy; Further more CStruct can be annotated on the package, i.e. 'package-info.java', avoiding the dependency problem altogether. To support multiple header files and types, 'CStructs' has been introduced using an array of 'CStruct'. @CStructs({@CStruct(name="RenderingConfig", header="TestStruct01.h"), @CStruct(name="Pixel", header="TestStruct02.h")}) package com.jogamp.gluegen.test.junit.structgen; Tests: - Build w/ Java7 and Java8 - Validated 'major version 50' (Java 6) class files (OK)
* Revert "Fix CStruct annotation processor warning."v2.1.5Sven Gothel2014-03-101-1/+1
| | | | This reverts commit fccb2460832aedd1b51372aa1e7881770cb638c9.
* Minor Cleanup after merging fixes for bugs 987, 990, 992 and 994Sven Gothel2014-03-104-11/+14
|
* Merge remote-tracking branch ↵Sven Gothel2014-03-101-1/+1
|\ | | | | | | 'remotes/wwalker/bug_994_fix_cstruct_annotation_warning'
| * Fix CStruct annotation processor warning.Wade Walker2014-03-061-1/+1
| | | | | | | | | | Updated the Java source version the annotation processor supports to stop it from throwing a warning during the build process.
* | Merge remote-tracking branch ↵Sven Gothel2014-03-101-0/+3
|\ \ | | | | | | | | | 'remotes/wwalker/bug_992_allow_ignore_of_unnamed_structs'
| * | Allow Ignore in config to ignore unnamed structs.Wade Walker2014-03-051-0/+3
| |/ | | | | | | | | | | | | | | | | | | Augments the behavior of the Ignore keyword to ignore when gluegen skips the emission of unnamed structs. These structs are usually unnamed because we've created opaque types for them, so we know they're not going to be emitted and want to be able to suppress the warning on a case-by-case basis.
* | Fix accidental tabs.Wade Walker2014-03-042-11/+11
| |
* | Remove warnings in emitted C code.Wade Walker2014-03-043-1/+23
|/ | | | | | | | 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.
* GlueGen: Add 'MethodJavadoc <method-name> comment-line..' configuration ↵Sven Gothel2014-01-212-38/+85
| | | | element, allowing to add custom API doc lines per method for the JavaMethodBindingEmitter
* gluegen: MethodBinding implements clone() without implenting ClonableHarvey Harrison2014-01-051-6/+1
| | | | | | Just directly call the copy-constructor and avoid using clone. Signed-off-by: Harvey Harrison <[email protected]>
* gluegen: use String.format to emit the error exception in implementation classesv2.1.3Harvey Harrison2013-11-301-1/+2
| | | | | | | | | | | | | | | | | Changes emitted code from: if (__addr_ == 0) { throw new Exception("Method \"" + "$methodName" + "\" not available"); to: if (__addr == 0) { throw new Exception(String.format("Method \"%s\" not available", "$methodName")); This removes all the redundant error message parts for each error string and only stores the unique method name in a string. Signed-off-by: Harvey Harrison <[email protected]>
* gluegen: add all missing @Override annotationsHarvey Harrison2013-10-1728-0/+120
| | | | Signed-off-by: Harvey Harrison <[email protected]>
* gluegen: remove trailing whitespaceHarvey Harrison2013-10-1756-607/+607
| | | | Signed-off-by: Harvey Harrison <[email protected]>
* Remedy for Bug 782: Issue Debug.initSingleton() or Debug.debug(..) before ↵Sven Gothel2013-07-171-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | calling 'PropertyAccess.isPropertyDefined(propName, default)' through Debug class. Calling 'Debug.isPropertyDefined(propName, default)' may be 'optimized' to 'PropertyAccess.isPropertyDefined(propName, default)', which would skip the modules Debug's class initialization. Iff that happens, an AccessControlException may happen, due to requesting an insecure property, since modules own Debug class has not been added it's trusted prefixes from within it's init block yet. This seems to be a bug of the JVM .. to me, however .. the above description is the only able to explain the issue at hand. +++ Fix calls Debug class own static methods, either Debug.initSingleton() or Debug.debug(), before calling 'isPropertyDefined(propName, default)'. +++ Also mark Debug class static methods final! +++
* gluegen: remove implied use of StringBuffer while appending to StringBuilderHarvey Harrison2013-07-151-2/+2
| | | | | | | - call append on the StringBuilder we are using rather than using String concatenation, which uses StringBuffer. Signed-off-by: Harvey Harrison <[email protected]>
* gluegen: annotate Hastable of attributes as Hashtable<String, Object>Harvey Harrison2013-07-151-11/+11
| | | | | | | - use copy-constructor rather than clone to suppress type warnings - annotate a Class as Class<?> Signed-off-by: Harvey Harrison <[email protected]>
* gluegen: remove unneeded casts to TNodeHarvey Harrison2013-07-151-4/+4
| | | | Signed-off-by: Harvey Harrison <[email protected]>
* FunctionSymbol: Fix equals/hashCode comparison, i.e. skip args/type due to ↵Sven Gothel2013-07-141-7/+25
| | | | non overloading of c-funcs.
* StringBuffer -> StringBuilderSven Gothel2013-07-143-5/+3
|
* ProcAddressTable: Fix regressions: getField(..) -> getDeclaredField(..), ↵Sven Gothel2013-06-211-13/+38
| | | | incl. access check; Utilize 'AccessibleObject.setAccessible(Field[], true)' for performance.
* ProcAddressTable: If using a SecurityManager 'checkAllLinkPermission()' ↵Sven Gothel2013-06-211-6/+19
| | | | instead of 'checkAllPermissions' if accessing the cached function handles.
* Fix regression of f69831574d4927d03d40c330d0b047d8c89622a4: Use ↵Sven Gothel2013-06-211-3/+5
| | | | getDeclaredField() and setAccessible(true) due to package private handle fields.
* ProcAddressTable: Make all handles package private, use local ↵Sven Gothel2013-06-203-38/+85
| | | | | | | | PROCADDRESS_VAR_PREFIX instance, add checkAllPermissions() for reset() and initEntry(..) - Generated ProcAddressTable's function handles are all package private - Generated ProcAddressTable's visibility can be set via 'AccessControl' config, default: public. - ProcAddressTable's reset() and initEntry(..) perform checkAllPermissions() 1st.
* Security: Gluegen generated native methods w/ 'pass through function ↵Sven Gothel2013-06-201-15/+37
| | | | pointer' _must_ be private!
* Fix CStruct APT File Location - Threw FileNotFoundException w/ Java7Sven Gothel2013-06-151-32/+38
|
* GlueGen (Compile Time): Add 'CStruct' Annotation Processor (APT) to ↵Sven Gothel2013-06-144-7/+306
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 'gluegen' C Structs on-the-fly (2-pass actually). Convenient annotation processing (APT) hooked to 'javac' (1.6) via gluegen.jar META-INF service provider 'javax.annotation.processing.Processor' -> 'com.jogamp.gluegen.structgen.CStructAnnotationProcessor'. Am implicit APT / JAVAC would be possible, however - to have a proper process the unit test utilizes an explicit 2 pass run: <!-- Annotation Processor Only - First --> <javac destdir="${build_t.java}"> <classpath refid="junit.compile.classpath"/> <compilerarg value="-proc:only"/> <compilerarg value="-J-Djogamp.gluegen.structgen.debug"/> <compilerarg value="-J-Djogamp.gluegen.structgen.output=${build_t.gen}/classes"/> <src path="${test.base.dir}/com/jogamp/gluegen/test/junit/structgen"/> </javac> <!-- Javac Only - Second --> <javac destdir="${build_t.java}"> <classpath refid="junit.compile.classpath"/> <compilerarg value="-proc:none"/> <src path="${test.base.dir}"/> <src path="${build_t.gen}" /> </javac> Original code from Michael Bien's 'superglue' git://github.com/mbien/superglue.git, finally merged to GlueGen (as once intended). Note: The APT javac pass requires to use 'gluegen.jar' instead of 'gluegen-rt.jar' ! The 2-pass process also alows using the runtime gluegen-rt.jar and hence ensures clean namespace check at compilation.
* Bug 752: Review Code Vulnerabilities (Permission Checks of new exposed code ↵Sven Gothel2013-06-111-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | and privileged access) This review focuses on how we perform permission checks, or better - do we circumvent some assuming full privileges ? Some native methods do need extra permission validation, i.e. loading native libraries. Further more AccessController.doPrivileged(..) shall not cover generic code exposing a critical feature to the user. Further more .. we should rely on the SecuritManager, i.e. AccessControlContext's 'checkPermission(Permission)' code to comply w/ fine grained permission access. It is also possible to have full permission w/o having any certificates (-> policy file). +++ We remove implicit AccessController.doPrivileged(..) from within our trusted code for generic methods, like Property access, temp. files. +++ SecurityUtil: - Remove 'getCommonAccessControlContext(Class<?> clz)', which returned a local AccessControlContext for later restriction if the passed class contains all certificates as the 'trusted' GlueGen class has. - Simply expose convenient permission check methods relying on SecurityManager / AccessControlContext. PropertyAccess: - 'protected static void addTrustedPrefix(..)' requires AllPermissions if SecurityManager is installed. - Remove implicit doPrivileged(..) triggered by passed AccessControlContext instance, only leave it for trusted prefixes. IOUtil: - Remove all doPrivileged(..) - Elevation shall be performed by caller. DynamicLinker: - 'public long openLibraryLocal(..)' and 'public long openLibraryGlobal(..)' may throw SecurityException, if a SecurityManager is installed and the dyn. link permission is not granted in the calling code. Implemented in their respective Unix, OSX and Windows manifestation. Caller has to elevate privileges via 'doPrivileged(..) {}' ! +++ Tests: - Property access - File access - Native library loading Manual Applet test (unsigned, but w/ SecurityManager and policy file): > gluegen/test/applet Applet has been tested w/ signed JAR w/ Firefox and Java7 on GNU/Linux as well. Manual Application test (unsigned, but w/ SecurityManager and policy file): com.jogamp.junit.sec.TestSecIOUtil01 - Run w/ SecurityManager and policy file: - gluegen/scripts/runtest-secmgr.sh - Run w/o SecurityManager: - gluegen/scripts/runtest.sh