summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-12-11 19:05:26 +0100
committerSven Gothel <[email protected]>2014-12-11 19:05:26 +0100
commit558d51e384e8c4e2bf3d4f646724c3351101b605 (patch)
tree9530af2389ce4ce0dbb6c09d41b88245d99118e2 /src
parent150ea4f231c9629ef9ef354e3f1a92a516d46f91 (diff)
GlueGen JavaEmitter: Use proper class access modifiers for emitted classes incl. ProcAddressTable
Emitted Java classes as well as optional ProcAddressTable shall use unique generated access modifiers covering all MethodAccess cases.
Diffstat (limited to 'src')
-rw-r--r--src/java/com/jogamp/gluegen/JavaConfiguration.java9
-rw-r--r--src/java/com/jogamp/gluegen/JavaEmitter.java33
-rw-r--r--src/java/com/jogamp/gluegen/procaddress/ProcAddressEmitter.java10
3 files changed, 32 insertions, 20 deletions
diff --git a/src/java/com/jogamp/gluegen/JavaConfiguration.java b/src/java/com/jogamp/gluegen/JavaConfiguration.java
index 53af4fc..b64c041 100644
--- a/src/java/com/jogamp/gluegen/JavaConfiguration.java
+++ b/src/java/com/jogamp/gluegen/JavaConfiguration.java
@@ -319,9 +319,12 @@ public class JavaConfiguration {
return emissionStyle;
}
- /** Returns the access control for the emitted Java method. Returns one of JavaEmitter.ACC_PUBLIC, JavaEmitter.ACC_PROTECTED, JavaEmitter.ACC_PRIVATE, or JavaEmitter.ACC_PACKAGE_PRIVATE. */
- public MethodAccess accessControl(final String methodName) {
- final MethodAccess ret = accessControl.get(methodName);
+ /**
+ * Returns the access control for the given method-name
+ * or fully qualified class-name.
+ */
+ public MethodAccess accessControl(final String name) {
+ final MethodAccess ret = accessControl.get(name);
if (ret != null) {
return ret;
}
diff --git a/src/java/com/jogamp/gluegen/JavaEmitter.java b/src/java/com/jogamp/gluegen/JavaEmitter.java
index f9dd13b..1ec1087 100644
--- a/src/java/com/jogamp/gluegen/JavaEmitter.java
+++ b/src/java/com/jogamp/gluegen/JavaEmitter.java
@@ -2311,6 +2311,23 @@ public class JavaEmitter implements GlueEmitter {
writer.println(" // ---- End CustomJavaCode .cfg declarations");
}
+ public String[] getClassAccessModifiers(final String classFQName) {
+ String[] accessModifiers;
+ final MethodAccess acc = cfg.accessControl(classFQName);
+ if( PUBLIC_ABSTRACT == acc ) {
+ accessModifiers = new String[] { PUBLIC.getJavaName(), PUBLIC_ABSTRACT.getJavaName() };
+ } else if( PACKAGE_PRIVATE == acc ) {
+ accessModifiers = new String[] { PACKAGE_PRIVATE.getJavaName() };
+ } else if( PRIVATE == acc ) {
+ throw new IllegalArgumentException("Class access "+classFQName+" cannot be private");
+ } else if( PROTECTED == acc ) {
+ accessModifiers = new String[] { PROTECTED.getJavaName() };
+ } else { // default PUBLIC
+ accessModifiers = new String[] { PUBLIC.getJavaName() };
+ }
+ return accessModifiers;
+ }
+
/**
* Write out any header information for the output files (class declaration
* and opening brace, import statements, etc).
@@ -2346,13 +2363,7 @@ public class JavaEmitter implements GlueEmitter {
}
};
- String[] accessModifiers = null;
- if(cfg.accessControl(cfg.className()) == PUBLIC_ABSTRACT) {
- accessModifiers = new String[] { "public", "abstract" };
- } else {
- accessModifiers = new String[] { "public" };
- }
-
+ final String[] accessModifiers = getClassAccessModifiers(cfg.className());
CodeGenUtils.emitJavaHeaders(
javaWriter,
cfg.packageName(),
@@ -2390,13 +2401,7 @@ public class JavaEmitter implements GlueEmitter {
interfaces[userSpecifiedInterfaces.size()] = cfg.className();
}
- String[] accessModifiers = null;
- if(cfg.accessControl(cfg.implClassName()) == PUBLIC_ABSTRACT) {
- accessModifiers = new String[] { "public", "abstract" };
- } else {
- accessModifiers = new String[] { "public" };
- }
-
+ final String[] accessModifiers = getClassAccessModifiers(cfg.implClassName());
CodeGenUtils.emitJavaHeaders(
javaImplWriter,
cfg.implPackageName(),
diff --git a/src/java/com/jogamp/gluegen/procaddress/ProcAddressEmitter.java b/src/java/com/jogamp/gluegen/procaddress/ProcAddressEmitter.java
index a0adbd0..4145cc4 100644
--- a/src/java/com/jogamp/gluegen/procaddress/ProcAddressEmitter.java
+++ b/src/java/com/jogamp/gluegen/procaddress/ProcAddressEmitter.java
@@ -307,8 +307,8 @@ public class ProcAddressEmitter extends JavaEmitter {
if (implPackageName == null) {
implPackageName = getImplPackageName();
}
- final String fullTableClassName = implPackageName + "." + tableClassName;
- final MethodAccess tableClassAccess = cfg.accessControl(fullTableClassName);
+ final String tableClassFQN = implPackageName + "." + tableClassName;
+ final String[] accessModifiers = getClassAccessModifiers(tableClassFQN);
final String jImplRoot = getJavaOutputDir() + File.separator + CodeGenUtils.packageAsPath(implPackageName);
@@ -330,7 +330,11 @@ public class ProcAddressEmitter extends JavaEmitter {
tableWriter.println(" * This table is a cache of pointers to the dynamically-linkable C library.");
tableWriter.println(" * @see " + ProcAddressTable.class.getSimpleName());
tableWriter.println(" */");
- tableWriter.println(tableClassAccess.getJavaName() + " final class " + tableClassName + " extends "+ ProcAddressTable.class.getSimpleName() + " {");
+ for (int i = 0; accessModifiers != null && i < accessModifiers.length; ++i) {
+ tableWriter.print(accessModifiers[i]);
+ tableWriter.print(' ');
+ }
+ tableWriter.println("final class " + tableClassName + " extends "+ ProcAddressTable.class.getSimpleName() + " {");
tableWriter.println();
for (final String string : getProcAddressConfig().getForceProcAddressGen()) {