summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2004-03-15 18:49:31 +0000
committerKenneth Russel <[email protected]>2004-03-15 18:49:31 +0000
commit0a7c6d77aab5b922f3225ed8ed6076f8ee984ab6 (patch)
treef2c7a495cd368f9977159f91d63338ad4a5a140e
parentedfa42f91c09df70073691db069db4295805f827 (diff)
Fixed Issue 68: Window system-specific JAWT classes must implement JAWT_PlatformInfo
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@90 232f8b59-042b-4e1e-8c03-345bb8c30851
-rw-r--r--make/jawt-macosx.cfg2
-rw-r--r--make/jawt-win32.cfg2
-rw-r--r--make/jawt-x11.cfg2
-rw-r--r--src/net/java/games/gluegen/JavaConfiguration.java26
-rw-r--r--src/net/java/games/gluegen/JavaEmitter.java37
5 files changed, 63 insertions, 6 deletions
diff --git a/make/jawt-macosx.cfg b/make/jawt-macosx.cfg
index 92ec9b49e..829e4f80a 100644
--- a/make/jawt-macosx.cfg
+++ b/make/jawt-macosx.cfg
@@ -18,8 +18,10 @@ IgnoreField JAWT_DrawingSurfaceInfo platformInfo
CustomCCode #include <inttypes.h>
CustomCCode #include <jawt.h>
+Import net.java.games.jogl.impl.JAWT_PlatformInfo
StructPackage JAWT_MacOSXDrawingSurfaceInfo net.java.games.jogl.impl.macosx
EmitStruct JAWT_MacOSXDrawingSurfaceInfo
+Implements JAWT_MacOSXDrawingSurfaceInfo JAWT_PlatformInfo
CustomJavaCode JAWT_DrawingSurfaceInfo public JAWT_PlatformInfo platformInfo() {
CustomJavaCode JAWT_DrawingSurfaceInfo return platformInfo0(getBuffer());
diff --git a/make/jawt-win32.cfg b/make/jawt-win32.cfg
index 30323eefa..4fe44b085 100644
--- a/make/jawt-win32.cfg
+++ b/make/jawt-win32.cfg
@@ -19,8 +19,10 @@ CustomCCode #if _MSC_VER <= 1200
CustomCCode typedef int intptr_t;
CustomCCode #endif
+Import net.java.games.jogl.impl.JAWT_PlatformInfo
StructPackage JAWT_Win32DrawingSurfaceInfo net.java.games.jogl.impl.windows
EmitStruct JAWT_Win32DrawingSurfaceInfo
+Implements JAWT_Win32DrawingSurfaceInfo JAWT_PlatformInfo
CustomJavaCode JAWT_DrawingSurfaceInfo public JAWT_PlatformInfo platformInfo() {
CustomJavaCode JAWT_DrawingSurfaceInfo return platformInfo0(getBuffer());
CustomJavaCode JAWT_DrawingSurfaceInfo }
diff --git a/make/jawt-x11.cfg b/make/jawt-x11.cfg
index 4f43da1b3..4161d7d13 100644
--- a/make/jawt-x11.cfg
+++ b/make/jawt-x11.cfg
@@ -12,8 +12,10 @@ IgnoreField JAWT GetComponent
IgnoreField JAWT_X11DrawingSurfaceInfo GetAWTColor
CustomCCode #include <inttypes.h>
CustomCCode #include <jawt.h>
+Import net.java.games.jogl.impl.JAWT_PlatformInfo
StructPackage JAWT_X11DrawingSurfaceInfo net.java.games.jogl.impl.x11
EmitStruct JAWT_X11DrawingSurfaceInfo
+Implements JAWT_X11DrawingSurfaceInfo JAWT_PlatformInfo
CustomJavaCode JAWT_DrawingSurfaceInfo public JAWT_PlatformInfo platformInfo() {
CustomJavaCode JAWT_DrawingSurfaceInfo return platformInfo0(getBuffer());
diff --git a/src/net/java/games/gluegen/JavaConfiguration.java b/src/net/java/games/gluegen/JavaConfiguration.java
index 35586cb80..cdf2f091e 100644
--- a/src/net/java/games/gluegen/JavaConfiguration.java
+++ b/src/net/java/games/gluegen/JavaConfiguration.java
@@ -109,6 +109,7 @@ public class JavaConfiguration {
private Map/*<String, List<String>>*/ temporaryCVariableDeclarations = new HashMap();
private Map/*<String, List<String>>*/ temporaryCVariableAssignments = new HashMap();
private Map/*<String,List<String>>*/ extendedInterfaces = new HashMap();
+ private Map/*<String,List<String>>*/ implementedInterfaces = new HashMap();
private Map/*<String,String>*/ javaTypeRenames = new HashMap();
/** Reads the configuration file.
@@ -413,6 +414,18 @@ public class JavaConfiguration {
return res;
}
+ /** Returns a List of Strings indicating the interfaces the passed
+ class should declare it implements. May return null or a list
+ of zero length if there are none. */
+ public List/*<String>*/ implementedInterfaces(String className) {
+ List res = (List) implementedInterfaces.get(className);
+ if (res == null) {
+ res = new ArrayList();
+ implementedInterfaces.put(className, res);
+ }
+ return res;
+ }
+
/** Returns true if this #define, function, struct, or field within
a struct should be ignored during glue code generation. */
public boolean shouldIgnore(String symbol) {
@@ -602,6 +615,8 @@ public class JavaConfiguration {
doIncludeAs(tok, file, filename, lineNo);
} else if (cmd.equalsIgnoreCase("Extends")) {
readExtend(tok, filename, lineNo);
+ } else if (cmd.equalsIgnoreCase("Implements")) {
+ readImplements(tok, filename, lineNo);
} else if (cmd.equalsIgnoreCase("RenameJavaType")) {
readRenameJavaType(tok, filename, lineNo);
} else if (cmd.equalsIgnoreCase("RuntimeExceptionType")) {
@@ -1032,6 +1047,17 @@ public class JavaConfiguration {
}
}
+ protected void readImplements(StringTokenizer tok, String filename, int lineNo) {
+ try {
+ String className = tok.nextToken();
+ List intfs = implementedInterfaces(className);
+ intfs.add(tok.nextToken());
+ } catch (NoSuchElementException e) {
+ throw new RuntimeException("Error parsing \"Implements\" command at line " + lineNo +
+ " in file \"" + filename + "\": missing expected parameter", e);
+ }
+ }
+
protected void readRenameJavaType(StringTokenizer tok, String filename, int lineNo) {
try {
String fromName = tok.nextToken();
diff --git a/src/net/java/games/gluegen/JavaEmitter.java b/src/net/java/games/gluegen/JavaEmitter.java
index 63350b2e8..b1384375e 100644
--- a/src/net/java/games/gluegen/JavaEmitter.java
+++ b/src/net/java/games/gluegen/JavaEmitter.java
@@ -515,12 +515,29 @@ public class JavaEmitter implements GlueEmitter {
writer.println();
writer.println("import net.java.games.gluegen.runtime.*;");
writer.println();
+ List/*<String>*/ imports = cfg.imports();
+ for (Iterator iter = imports.iterator(); iter.hasNext(); ) {
+ writer.print("import ");
+ writer.print(iter.next());
+ writer.println(";");
+ }
List/*<String>*/ javadoc = cfg.javadocForClass(containingTypeName);
for (Iterator iter = javadoc.iterator(); iter.hasNext(); ) {
writer.println((String) iter.next());
}
writer.println();
- writer.println("public class " + containingTypeName + " {");
+ writer.print("public class " + containingTypeName + " ");
+ boolean firstIteration = true;
+ List/*<String>*/ userSpecifiedInterfaces = cfg.implementedInterfaces(containingTypeName);
+ for (Iterator iter = userSpecifiedInterfaces.iterator(); iter.hasNext(); ) {
+ if (firstIteration) {
+ writer.print("implements ");
+ }
+ firstIteration = false;
+ writer.print(iter.next());
+ writer.print(" ");
+ }
+ writer.println("{");
writer.println(" private StructAccessor accessor;");
writer.println();
writer.println(" public static int size() {");
@@ -1048,13 +1065,14 @@ public class JavaEmitter implements GlueEmitter {
try {
if (cfg.allStatic() || cfg.emitInterface()) {
String[] interfaces;
+ List userSpecifiedInterfaces = null;
if (cfg.emitInterface()) {
- List userSpecifiedInterfaces = cfg.extendedInterfaces(cfg.className());
- interfaces = new String[userSpecifiedInterfaces.size()];
- userSpecifiedInterfaces.toArray(interfaces);
+ userSpecifiedInterfaces = cfg.extendedInterfaces(cfg.className());
} else {
- interfaces = null;
+ userSpecifiedInterfaces = cfg.implementedInterfaces(cfg.className());
}
+ interfaces = new String[userSpecifiedInterfaces.size()];
+ userSpecifiedInterfaces.toArray(interfaces);
final List/*<String>*/ intfDocs = cfg.javadocForClass(cfg.className());
CodeGenUtils.EmissionCallback docEmitter =
@@ -1089,6 +1107,13 @@ public class JavaEmitter implements GlueEmitter {
}
};
+ String[] interfaces;
+ List userSpecifiedInterfaces = null;
+ userSpecifiedInterfaces = cfg.implementedInterfaces(cfg.implClassName());
+ interfaces = new String[1 + userSpecifiedInterfaces.size()];
+ userSpecifiedInterfaces.toArray(interfaces);
+ interfaces[userSpecifiedInterfaces.size()] = cfg.className();
+
CodeGenUtils.emitJavaHeaders(
javaImplWriter,
cfg.implPackageName(),
@@ -1096,7 +1121,7 @@ public class JavaEmitter implements GlueEmitter {
true,
(String[]) cfg.imports().toArray(new String[] {}),
new String[] { "public" },
- new String[] { cfg.className() },
+ interfaces,
null,
docEmitter);
}