diff options
author | Sven Gothel <[email protected]> | 2014-07-03 16:21:36 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-07-03 16:21:36 +0200 |
commit | 556d92b63555a085b25e32b1cd55afce24edd07a (patch) | |
tree | 6be2b02c62a77d5aba81ffbe34c46960608be163 /src/jogl/classes/com/jogamp/gluegen | |
parent | a90f4a51dffec3247278e3c683ed4462b1dd9ab5 (diff) |
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
Diffstat (limited to 'src/jogl/classes/com/jogamp/gluegen')
10 files changed, 317 insertions, 317 deletions
diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java index 023913d7b..f082f358f 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java @@ -106,37 +106,37 @@ public class BuildComposablePipeline { // Desktop OpenGL and GLES1 have GL_STACK_OVERFLOW and GL_STACK_UNDERFLOW errors private boolean hasGL2ES1StackOverflow; - public static Class<?> getClass(String name) { + public static Class<?> getClass(final String name) { Class<?> clazz = null; try { clazz = Class.forName(name); - } catch (Exception e) { + } catch (final Exception e) { throw new RuntimeException( "Could not find class \"" + name + "\"", e); } return clazz; } - public static Method getMethod(Class<?> clazz, Method m) { + public static Method getMethod(final Class<?> clazz, final Method m) { Method res = null; try { res = clazz.getMethod(m.getName(), m.getParameterTypes()); - } catch (Exception e) { + } catch (final Exception e) { } return res; } - public static void main(String[] args) { - String classToComposeAroundName = args[0]; + public static void main(final String[] args) { + final String classToComposeAroundName = args[0]; Class<?> classPrologOpt, classDownstream; - Class<?> classToComposeAround = getClass(classToComposeAroundName); + final Class<?> classToComposeAround = getClass(classToComposeAroundName); - String outputDir = args[1]; + final String outputDir = args[1]; String outputPackage, outputName; int mode; if (args.length > 2) { - String outputClazzName = args[2]; + final String outputClazzName = args[2]; outputPackage = getPackageName(outputClazzName); outputName = getBaseClassName(outputClazzName); classPrologOpt = getClass(args[3]); @@ -159,19 +159,19 @@ public class BuildComposablePipeline { mode = GEN_DEBUG | GEN_TRACE ; } - BuildComposablePipeline composer = + final BuildComposablePipeline composer = new BuildComposablePipeline(mode, outputDir, outputPackage, outputName, classToComposeAround, classPrologOpt, classDownstream); try { composer.emit(); - } catch (IOException e) { + } catch (final IOException e) { throw new RuntimeException( "Error generating composable pipeline source files", e); } } - protected BuildComposablePipeline(int mode, String outputDir, String outputPackage, String outputName, - Class<?> classToComposeAround, Class<?> classPrologOpt, Class<?> classDownstream) { + protected BuildComposablePipeline(final int mode, final String outputDir, final String outputPackage, final String outputName, + final Class<?> classToComposeAround, final Class<?> classPrologOpt, final Class<?> classDownstream) { this.mode = mode; this.outputDir = outputDir; this.outputPackage = outputPackage; @@ -188,13 +188,13 @@ public class BuildComposablePipeline { try { hasImmediateMode = (classToComposeAround.getMethod("glBegin", new Class<?>[]{Integer.TYPE}) != null); - } catch (Exception e) { + } catch (final Exception e) { } try { hasGL2ES1StackOverflow = hasImmediateMode && (classToComposeAround.getField("GL_STACK_OVERFLOW") != null); - } catch (Exception e) { + } catch (final Exception e) { } } @@ -207,7 +207,7 @@ public class BuildComposablePipeline { final List<Method> publicMethodsRaw = Arrays.asList(classToComposeAround.getMethods()); final Set<PlainMethod> publicMethodsPlain = new HashSet<PlainMethod>(); - for (Iterator<Method> iter = publicMethodsRaw.iterator(); iter.hasNext();) { + for (final Iterator<Method> iter = publicMethodsRaw.iterator(); iter.hasNext();) { final Method method = iter.next(); // Don't hook methods which aren't real GL methods, // such as the synthetic "isGL2ES2" "getGL2ES2" @@ -232,8 +232,8 @@ public class BuildComposablePipeline { } } - public static String getPackageName(String clazzName) { - int lastDot = clazzName.lastIndexOf('.'); + public static String getPackageName(final String clazzName) { + final int lastDot = clazzName.lastIndexOf('.'); if (lastDot == -1) { // no package, class is at root level return null; @@ -241,8 +241,8 @@ public class BuildComposablePipeline { return clazzName.substring(0, lastDot); } - public static String getBaseClassName(String clazzName) { - int lastDot = clazzName.lastIndexOf('.'); + public static String getBaseClassName(final String clazzName) { + final int lastDot = clazzName.lastIndexOf('.'); if (lastDot == -1) { // no package, class is at root level return clazzName; @@ -256,7 +256,7 @@ public class BuildComposablePipeline { Method m; boolean runHooks; - PlainMethod(Method m, boolean runHooks) { + PlainMethod(final Method m, final boolean runHooks) { this.m = m; this.runHooks = runHooks; } @@ -270,10 +270,10 @@ public class BuildComposablePipeline { } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (obj instanceof PlainMethod) { - PlainMethod b = (PlainMethod) obj; - boolean res = + final PlainMethod b = (PlainMethod) obj; + final boolean res = m.getName().equals(b.m.getName()) && m.getModifiers() == b.m.getModifiers() && m.getReturnType().equals(b.m.getReturnType()) @@ -286,7 +286,7 @@ public class BuildComposablePipeline { @Override public int hashCode() { int hash = m.getName().hashCode() ^ m.getModifiers() ^ m.getReturnType().hashCode(); - Class<?>[] args = m.getParameterTypes(); + final Class<?>[] args = m.getParameterTypes(); for (int i = 0; i < args.length; i++) { hash ^= args[i].hashCode(); } @@ -295,8 +295,8 @@ public class BuildComposablePipeline { @Override public String toString() { - Class<?>[] args = m.getParameterTypes(); - StringBuilder argsString = new StringBuilder(); + final Class<?>[] args = m.getParameterTypes(); + final StringBuilder argsString = new StringBuilder(); argsString.append("("); for (int i = 0; i < args.length; i++) { if (i > 0) { @@ -340,7 +340,7 @@ public class BuildComposablePipeline { * @exception IllegalArgumentException if classToComposeAround is not an * interface. */ - PipelineEmitter(String outputDir, String outputPackage, Class<?> baseInterfaceClass, Class<?> prologClassOpt, Class<?> downstreamClass) { + PipelineEmitter(final String outputDir, final String outputPackage, final Class<?> baseInterfaceClass, final Class<?> prologClassOpt, final Class<?> downstreamClass) { this.outputDir = outputDir; this.outputPackage = outputPackage; this.baseInterfaceClass = baseInterfaceClass; @@ -357,31 +357,31 @@ public class BuildComposablePipeline { } } - public void emit(Iterator<PlainMethod> methodsToWrap) throws IOException { - String outputClassName = getOutputName(); + public void emit(final Iterator<PlainMethod> methodsToWrap) throws IOException { + final String outputClassName = getOutputName(); this.file = new File(outputDir + File.separatorChar + outputClassName + ".java"); - String parentDir = file.getParent(); + final String parentDir = file.getParent(); if (parentDir != null) { - File pDirFile = new File(parentDir); + final File pDirFile = new File(parentDir); pDirFile.mkdirs(); } - PrintWriter output = new PrintWriter(new BufferedWriter(new FileWriter(file))); + final PrintWriter output = new PrintWriter(new BufferedWriter(new FileWriter(file))); - List<Class<?>> baseInterfaces = Arrays.asList(baseInterfaceClass.getInterfaces()); - HashSet<Class<?>> clazzList = new HashSet<Class<?>>(); + final List<Class<?>> baseInterfaces = Arrays.asList(baseInterfaceClass.getInterfaces()); + final HashSet<Class<?>> clazzList = new HashSet<Class<?>>(); clazzList.add(baseInterfaceClass); clazzList.addAll(baseInterfaces); - int ifNamesNumber = clazzList.size(); + final int ifNamesNumber = clazzList.size(); // keep original order .. clazzList.clear(); - String[] ifNames = new String[ifNamesNumber]; + final String[] ifNames = new String[ifNamesNumber]; { int i = 0; - for (Iterator<Class<?>> iter = baseInterfaces.iterator(); iter.hasNext();) { - Class<?> ifClass = iter.next(); + for (final Iterator<Class<?>> iter = baseInterfaces.iterator(); iter.hasNext();) { + final Class<?> ifClass = iter.next(); if (!clazzList.contains(ifClass)) { ifNames[i++] = ifClass.getName(); clazzList.add(ifClass); @@ -399,12 +399,12 @@ public class BuildComposablePipeline { clazzList.add(prologClassOpt); } - ArrayList<String> imports = new ArrayList<String>(); + final ArrayList<String> imports = new ArrayList<String>(); imports.add("java.io.*"); imports.add("javax.media.opengl.*"); imports.add("com.jogamp.gluegen.runtime.*"); imports.add(Buffer.class.getPackage().getName()+".*"); - for (Class<?> clasS : clazzList) { + for (final Class<?> clasS : clazzList) { imports.add(clasS.getName()); } @@ -418,7 +418,7 @@ public class BuildComposablePipeline { null, new CodeGenUtils.EmissionCallback() { @Override - public void emit(PrintWriter w) { + public void emit(final PrintWriter w) { emitClassDocComment(w); } }); @@ -431,8 +431,8 @@ public class BuildComposablePipeline { emitGLGetMethods(output); while (methodsToWrap.hasNext()) { - PlainMethod pm = methodsToWrap.next(); - Method m = pm.getWrappedMethod(); + final PlainMethod pm = methodsToWrap.next(); + final Method m = pm.getWrappedMethod(); emitMethodDocComment(output, m); emitSignature(output, m); emitBody(output, m, pm.runHooks()); @@ -467,25 +467,25 @@ public class BuildComposablePipeline { return null; } - protected void emitMethodDocComment(PrintWriter output, Method m) { + protected void emitMethodDocComment(final PrintWriter output, final Method m) { } - protected void emitSignature(PrintWriter output, Method m) { + protected void emitSignature(final PrintWriter output, final Method m) { output.format(" @Override%n public %s %s(%s)%n", JavaType.createForClass(m.getReturnType()).getName(), m.getName(), getArgListAsString(m, true, true)); } - protected void emitBody(PrintWriter output, Method m, boolean runHooks) { + protected void emitBody(final PrintWriter output, final Method m, final boolean runHooks) { output.println(" {"); - Class<?> retType = m.getReturnType(); + final Class<?> retType = m.getReturnType(); - boolean callPreDownstreamHook = runHooks && hasPreDownstreamCallHook(m); - boolean callPostDownstreamHook = runHooks && hasPostDownstreamCallHook(m); - boolean callDownstream = (null != getMethod(downstreamClass, m)) + final boolean callPreDownstreamHook = runHooks && hasPreDownstreamCallHook(m); + final boolean callPostDownstreamHook = runHooks && hasPostDownstreamCallHook(m); + final boolean callDownstream = (null != getMethod(downstreamClass, m)) && !(0 != (GEN_PROLOG_XOR_DOWNSTREAM & getMode()) && callPreDownstreamHook); - boolean hasResult = (retType != Void.TYPE); + final boolean hasResult = (retType != Void.TYPE); if (!callDownstream) { if (!emptyDownstreamAllowed()) { @@ -546,14 +546,14 @@ public class BuildComposablePipeline { } - protected String getArgListAsString(Method m, boolean includeArgTypes, boolean includeArgNames) { - StringBuilder buf = new StringBuilder(256); + protected String getArgListAsString(final Method m, final boolean includeArgTypes, final boolean includeArgNames) { + final StringBuilder buf = new StringBuilder(256); if (!includeArgNames && !includeArgTypes) { throw new IllegalArgumentException( "Cannot generate arglist without both arg types and arg names"); } - Class<?>[] argTypes = m.getParameterTypes(); + final Class<?>[] argTypes = m.getParameterTypes(); for (int i = 0; i < argTypes.length; ++i) { if (includeArgTypes) { buf.append(JavaType.createForClass(argTypes[i]).getName()); @@ -588,7 +588,7 @@ public class BuildComposablePipeline { * Called after the class headers have been generated, but before any * method wrappers have been generated. */ - protected void preMethodEmissionHook(PrintWriter output) { + protected void preMethodEmissionHook(final PrintWriter output) { output.println(" public static final boolean DEBUG = jogamp.opengl.Debug.debug(\"" + getOutputName() + "\");"); } @@ -601,7 +601,7 @@ public class BuildComposablePipeline { * Called after the method wrappers have been generated, but before the * closing parenthesis of the class is emitted. */ - protected void postMethodEmissionHook(PrintWriter output) { + protected void postMethodEmissionHook(final PrintWriter output) { output.println(" @Override"); output.println(" public String toString() {"); output.println(" StringBuilder sb = new StringBuilder();"); @@ -641,7 +641,7 @@ public class BuildComposablePipeline { /** * Emits one of the isGL* methods. */ - protected void emitGLIsMethod(PrintWriter output, String type) { + protected void emitGLIsMethod(final PrintWriter output, final String type) { output.println(" @Override"); output.println(" public final boolean is" + type + "() {"); if( 0 != (GEN_GL_IDENTITY_BY_ASSIGNABLE_CLASS & getMode() ) ) { @@ -660,7 +660,7 @@ public class BuildComposablePipeline { /** * Emits all of the isGL* methods. */ - protected void emitGLIsMethods(PrintWriter output) { + protected void emitGLIsMethods(final PrintWriter output) { output.println(" @Override"); output.println(" public final boolean isGL() {"); output.println(" return true;"); @@ -712,7 +712,7 @@ public class BuildComposablePipeline { /** * Emits one of the getGL* methods. */ - protected void emitGLGetMethod(PrintWriter output, String type) { + protected void emitGLGetMethod(final PrintWriter output, final String type) { output.println(" @Override"); output.println(" public final javax.media.opengl." + type + " get" + type + "() {"); final Class<?> clazz = BuildComposablePipeline.getClass("javax.media.opengl." + type); @@ -732,7 +732,7 @@ public class BuildComposablePipeline { /** * Emits all of the getGL* methods. */ - protected void emitGLGetMethods(PrintWriter output) { + protected void emitGLGetMethods(final PrintWriter output) { output.println(" @Override"); output.println(" public final javax.media.opengl.GL getGL() {"); output.println(" return this;"); @@ -768,7 +768,7 @@ public class BuildComposablePipeline { String className; int mode; - CustomPipeline(int mode, String outputDir, String outputPackage, String outputName, Class<?> baseInterfaceClass, Class<?> prologClassOpt, Class<?> downstreamClass) { + CustomPipeline(final int mode, final String outputDir, final String outputPackage, final String outputName, final Class<?> baseInterfaceClass, final Class<?> prologClassOpt, final Class<?> downstreamClass) { super(outputDir, outputPackage, baseInterfaceClass, prologClassOpt, downstreamClass); className = outputName; this.mode = mode; @@ -795,12 +795,12 @@ public class BuildComposablePipeline { } @Override - protected void preMethodEmissionHook(PrintWriter output) { + protected void preMethodEmissionHook(final PrintWriter output) { super.preMethodEmissionHook(output); } @Override - protected void constructorHook(PrintWriter output) { + protected void constructorHook(final PrintWriter output) { output.print(" public " + getOutputName() + "("); output.print(downstreamName + " " + getDownstreamObjectName()); if (null != prologNameOpt) { @@ -823,7 +823,7 @@ public class BuildComposablePipeline { } @Override - protected void postMethodEmissionHook(PrintWriter output) { + protected void postMethodEmissionHook(final PrintWriter output) { super.postMethodEmissionHook(output); if (null != prologNameOpt) { output.print(" private " + prologNameOpt + " " + getPrologObjectNameOpt() + ";"); @@ -831,7 +831,7 @@ public class BuildComposablePipeline { } @Override - protected void emitClassDocComment(PrintWriter output) { + protected void emitClassDocComment(final PrintWriter output) { output.println("/**"); output.println(" * Composable pipeline {@link " + outputPackage + "." + outputName + "}, implementing the interface"); output.println(" * {@link " + baseInterfaceClass.getName() + "}"); @@ -866,12 +866,12 @@ public class BuildComposablePipeline { } @Override - protected boolean hasPreDownstreamCallHook(Method m) { + protected boolean hasPreDownstreamCallHook(final Method m) { return null != getMethod(prologClassOpt, m); } @Override - protected void preDownstreamCallHook(PrintWriter output, Method m) { + protected void preDownstreamCallHook(final PrintWriter output, final Method m) { if (null != prologNameOpt) { output.print(getPrologObjectNameOpt()); output.print('.'); @@ -883,12 +883,12 @@ public class BuildComposablePipeline { } @Override - protected boolean hasPostDownstreamCallHook(Method m) { + protected boolean hasPostDownstreamCallHook(final Method m) { return false; } @Override - protected void postDownstreamCallHook(PrintWriter output, Method m) { + protected void postDownstreamCallHook(final PrintWriter output, final Method m) { } } // end class CustomPipeline @@ -896,7 +896,7 @@ public class BuildComposablePipeline { String className; - DebugPipeline(String outputDir, String outputPackage, Class<?> baseInterfaceClass, Class<?> downstreamClass) { + DebugPipeline(final String outputDir, final String outputPackage, final Class<?> baseInterfaceClass, final Class<?> downstreamClass) { super(outputDir, outputPackage, baseInterfaceClass, null, downstreamClass); className = "Debug" + getBaseInterfaceName(); } @@ -922,12 +922,12 @@ public class BuildComposablePipeline { } @Override - protected void preMethodEmissionHook(PrintWriter output) { + protected void preMethodEmissionHook(final PrintWriter output) { super.preMethodEmissionHook(output); } @Override - protected void constructorHook(PrintWriter output) { + protected void constructorHook(final PrintWriter output) { output.print(" public " + getOutputName() + "("); output.println(downstreamName + " " + getDownstreamObjectName() + ")"); output.println(" {"); @@ -947,7 +947,7 @@ public class BuildComposablePipeline { } @Override - protected void postMethodEmissionHook(PrintWriter output) { + protected void postMethodEmissionHook(final PrintWriter output) { super.postMethodEmissionHook(output); output.println(" private int checkGLError() {"); if (hasImmediateMode) { @@ -1005,7 +1005,7 @@ public class BuildComposablePipeline { } @Override - protected void emitClassDocComment(PrintWriter output) { + protected void emitClassDocComment(final PrintWriter output) { output.println("/**"); output.println(" * <p>"); output.println(" * Composable pipeline which wraps an underlying {@link GL} implementation,"); @@ -1023,22 +1023,22 @@ public class BuildComposablePipeline { } @Override - protected boolean hasPreDownstreamCallHook(Method m) { + protected boolean hasPreDownstreamCallHook(final Method m) { return true; } @Override - protected void preDownstreamCallHook(PrintWriter output, Method m) { + protected void preDownstreamCallHook(final PrintWriter output, final Method m) { output.println(" checkContext();"); } @Override - protected boolean hasPostDownstreamCallHook(Method m) { + protected boolean hasPostDownstreamCallHook(final Method m) { return true; } @Override - protected void postDownstreamCallHook(PrintWriter output, Method m) { + protected void postDownstreamCallHook(final PrintWriter output, final Method m) { if (m.getName().equals("glBegin")) { output.println(" insideBeginEndPair = true;"); output.println(" // NOTE: can't check glGetError(); it's not allowed inside glBegin/glEnd pair"); @@ -1050,12 +1050,12 @@ public class BuildComposablePipeline { output.println(" final int err = checkGLError();"); output.println(" if (err != GL_NO_ERROR) {"); - StringBuilder fmtsb = new StringBuilder(); - StringBuilder argsb = new StringBuilder(); + final StringBuilder fmtsb = new StringBuilder(); + final StringBuilder argsb = new StringBuilder(); fmtsb.append("\"%s("); argsb.append("\"").append(m.getName()).append("\""); - Class<?>[] params = m.getParameterTypes(); + final Class<?>[] params = m.getParameterTypes(); for (int i = 0; i < params.length; i++) { if (i > 0) { fmtsb.append(", "); @@ -1089,7 +1089,7 @@ public class BuildComposablePipeline { String className; - TracePipeline(String outputDir, String outputPackage, Class<?> baseInterfaceClass, Class<?> downstreamClass) { + TracePipeline(final String outputDir, final String outputPackage, final Class<?> baseInterfaceClass, final Class<?> downstreamClass) { super(outputDir, outputPackage, baseInterfaceClass, null, downstreamClass); className = "Trace" + getBaseInterfaceName(); } @@ -1115,12 +1115,12 @@ public class BuildComposablePipeline { } @Override - protected void preMethodEmissionHook(PrintWriter output) { + protected void preMethodEmissionHook(final PrintWriter output) { super.preMethodEmissionHook(output); } @Override - protected void constructorHook(PrintWriter output) { + protected void constructorHook(final PrintWriter output) { output.print(" public " + getOutputName() + "("); output.println(downstreamName + " " + getDownstreamObjectName() + ", PrintStream " + getOutputStreamName() + ")"); output.println(" {"); @@ -1136,7 +1136,7 @@ public class BuildComposablePipeline { } @Override - protected void postMethodEmissionHook(PrintWriter output) { + protected void postMethodEmissionHook(final PrintWriter output) { super.postMethodEmissionHook(output); output.println("private PrintStream " + getOutputStreamName() + ";"); output.println("private int indent = 0;"); @@ -1171,7 +1171,7 @@ public class BuildComposablePipeline { } @Override - protected void emitClassDocComment(PrintWriter output) { + protected void emitClassDocComment(final PrintWriter output) { output.println("/**"); output.println(" * <p>"); output.println(" * Composable pipeline which wraps an underlying {@link GL} implementation,"); @@ -1189,12 +1189,12 @@ public class BuildComposablePipeline { } @Override - protected boolean hasPreDownstreamCallHook(Method m) { + protected boolean hasPreDownstreamCallHook(final Method m) { return true; } @Override - protected void preDownstreamCallHook(PrintWriter output, Method m) { + protected void preDownstreamCallHook(final PrintWriter output, final Method m) { if (m.getName().equals("glEnd") || m.getName().equals("glEndList")) { output.println(" indent-=2;"); output.println(" printIndent();"); @@ -1208,13 +1208,13 @@ public class BuildComposablePipeline { } @Override - protected boolean hasPostDownstreamCallHook(Method m) { + protected boolean hasPostDownstreamCallHook(final Method m) { return true; } @Override - protected void postDownstreamCallHook(PrintWriter output, Method m) { - Class<?> ret = m.getReturnType(); + protected void postDownstreamCallHook(final PrintWriter output, final Method m) { + final Class<?> ret = m.getReturnType(); if (ret != Void.TYPE) { output.println(" println(\" = \"+_res);"); } else { @@ -1230,8 +1230,8 @@ public class BuildComposablePipeline { } } // end class TracePipeline - public static final void printFunctionCallString(PrintWriter output, Method m) { - Class<?>[] params = m.getParameterTypes(); + public static final void printFunctionCallString(final PrintWriter output, final Method m) { + final Class<?>[] params = m.getParameterTypes(); output.print(" \"" + m.getName() + "(\""); for (int i = 0; i < params.length; i++) { output.print("+\"<" + params[i].getName() + ">"); diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildStaticGLInfo.java b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildStaticGLInfo.java index a5a26d18f..f9719c232 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildStaticGLInfo.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildStaticGLInfo.java @@ -138,41 +138,41 @@ public class BuildStaticGLInfo { * classes reside, and the remaining arguments are paths to the C header * files that should be parsed */ - public static void main(String[] args) throws IOException { + public static void main(final String[] args) throws IOException { if (args.length > 0 && args[0].equals("-test")) { - BuildStaticGLInfo builder = new BuildStaticGLInfo(); + final BuildStaticGLInfo builder = new BuildStaticGLInfo(); builder.setDebug(true); - String[] newArgs = new String[args.length - 1]; + final String[] newArgs = new String[args.length - 1]; System.arraycopy(args, 1, newArgs, 0, args.length - 1); builder.parse(newArgs); builder.dump(); System.exit(0); } - String packageName = args[0]; - String packageDir = args[1]; + final String packageName = args[0]; + final String packageDir = args[1]; - String[] cHeaderFilePaths = new String[args.length - 2]; + final String[] cHeaderFilePaths = new String[args.length - 2]; System.arraycopy(args, 2, cHeaderFilePaths, 0, cHeaderFilePaths.length); - BuildStaticGLInfo builder = new BuildStaticGLInfo(); + final BuildStaticGLInfo builder = new BuildStaticGLInfo(); try { builder.parse(cHeaderFilePaths); - File file = new File(packageDir + File.separatorChar + "StaticGLInfo.java"); - String parentDir = file.getParent(); + final File file = new File(packageDir + File.separatorChar + "StaticGLInfo.java"); + final String parentDir = file.getParent(); if (parentDir != null) { - File pDirFile = new File(parentDir); + final File pDirFile = new File(parentDir); pDirFile.mkdirs(); } - PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(file))); + final PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(file))); builder.emitJavaCode(writer, packageName); writer.flush(); writer.close(); - } catch (Exception e) { - StringBuilder buf = new StringBuilder("{ "); + } catch (final Exception e) { + final StringBuilder buf = new StringBuilder("{ "); for (int i = 0; i < cHeaderFilePaths.length; ++i) { buf.append(cHeaderFilePaths[i]); buf.append(" "); @@ -183,13 +183,13 @@ public class BuildStaticGLInfo { } } - public void setDebug(boolean v) { + public void setDebug(final boolean v) { DEBUG = v; } /** Parses the supplied C header files and adds the function associations contained therein to the internal map. */ - public void parse(String[] cHeaderFilePaths) throws IOException { + public void parse(final String[] cHeaderFilePaths) throws IOException { for (int i = 0; i < cHeaderFilePaths.length; i++) { parse(cHeaderFilePaths[i]); } @@ -197,8 +197,8 @@ public class BuildStaticGLInfo { /** Parses the supplied C header file and adds the function associations contained therein to the internal map. */ - public void parse(String cHeaderFilePath) throws IOException { - BufferedReader reader = new BufferedReader(new FileReader(cHeaderFilePath)); + public void parse(final String cHeaderFilePath) throws IOException { + final BufferedReader reader = new BufferedReader(new FileReader(cHeaderFilePath)); String line, activeAssociation = null; Matcher m = null; int block = 0; @@ -264,23 +264,23 @@ public class BuildStaticGLInfo { } public void dump() { - for (String name : extensionToDeclarationMap.keySet()) { - Set<String> decls = extensionToDeclarationMap.get(name); + for (final String name : extensionToDeclarationMap.keySet()) { + final Set<String> decls = extensionToDeclarationMap.get(name); System.out.println("<" + name + "> :"); - List<String> l = new ArrayList<String>(); + final List<String> l = new ArrayList<String>(); l.addAll(decls); Collections.sort(l); - for (String str : l) { + for (final String str : l) { System.out.println(" <" + str + ">"); } } } - public Set<String> getExtension(String identifier) { + public Set<String> getExtension(final String identifier) { return declarationToExtensionMap.get(identifier); } - public Set<String> getDeclarations(String extension) { + public Set<String> getDeclarations(final String extension) { return extensionToDeclarationMap.get(extension); } @@ -288,7 +288,7 @@ public class BuildStaticGLInfo { return extensionToDeclarationMap.keySet(); } - public void emitJavaCode(PrintWriter output, String packageName) { + public void emitJavaCode(final PrintWriter output, final String packageName) { output.println("package " + packageName + ";"); output.println(); output.println("import java.util.*;"); @@ -340,7 +340,7 @@ public class BuildStaticGLInfo { // Compute max capacity int maxCapacity = 0; - for (String name : declarationToExtensionMap.keySet()) { + for (final String name : declarationToExtensionMap.keySet()) { if (!name.startsWith("GL")) { ++maxCapacity; } @@ -348,17 +348,17 @@ public class BuildStaticGLInfo { output.println(" funcToAssocMap = new HashMap(" + maxCapacity + "); // approximate max capacity"); output.println(" String group;"); - ArrayList<String> sets = new ArrayList<String>(extensionToDeclarationMap.keySet()); + final ArrayList<String> sets = new ArrayList<String>(extensionToDeclarationMap.keySet()); Collections.sort(sets); - for (String groupName : sets) { - Set<String> funcs = extensionToDeclarationMap.get(groupName); - List<String> l = new ArrayList<String>(); + for (final String groupName : sets) { + final Set<String> funcs = extensionToDeclarationMap.get(groupName); + final List<String> l = new ArrayList<String>(); l.addAll(funcs); Collections.sort(l); - Iterator<String> funcIter = l.iterator(); + final Iterator<String> funcIter = l.iterator(); boolean printedHeader = false; while (funcIter.hasNext()) { - String funcName = funcIter.next(); + final String funcName = funcIter.next(); if (!funcName.startsWith("GL")) { if (!printedHeader) { output.println(); @@ -380,7 +380,7 @@ public class BuildStaticGLInfo { //---------------------------------------------------------------------- // Internals only below this point // - protected void addAssociation(String identifier, String association) { + protected void addAssociation(final String identifier, final String association) { Set<String> extensions = declarationToExtensionMap.get(identifier); if(null == extensions) { extensions = new HashSet<String>(); diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/GLConfiguration.java b/src/jogl/classes/com/jogamp/gluegen/opengl/GLConfiguration.java index f1a32fa9c..5da45abfe 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/GLConfiguration.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/GLConfiguration.java @@ -59,17 +59,17 @@ import java.util.StringTokenizer; public class GLConfiguration extends ProcAddressConfiguration { // The following data members support ignoring an entire extension at a time - private List<String> glHeaders = new ArrayList<String>(); - private Set<String> ignoredExtensions = new HashSet<String>(); - private Set<String> forcedExtensions = new HashSet<String>(); - private Set<String> extensionsRenamedIntoCore = new HashSet<String>(); + private final List<String> glHeaders = new ArrayList<String>(); + private final Set<String> ignoredExtensions = new HashSet<String>(); + private final Set<String> forcedExtensions = new HashSet<String>(); + private final Set<String> extensionsRenamedIntoCore = new HashSet<String>(); private BuildStaticGLInfo glInfo; // Maps function names to the kind of buffer object it deals with - private Map<String, GLEmitter.BufferObjectKind> bufferObjectKinds = new HashMap<String, GLEmitter.BufferObjectKind>(); - private Set<String> bufferObjectOnly = new HashSet<String>(); - private GLEmitter emitter; - private Set<String> dropUniqVendorExtensions = new HashSet<String>(); + private final Map<String, GLEmitter.BufferObjectKind> bufferObjectKinds = new HashMap<String, GLEmitter.BufferObjectKind>(); + private final Set<String> bufferObjectOnly = new HashSet<String>(); + private final GLEmitter emitter; + private final Set<String> dropUniqVendorExtensions = new HashSet<String>(); // This directive is off by default but can help automatically // indicate which extensions have been folded into the core OpenGL @@ -77,52 +77,52 @@ public class GLConfiguration extends ProcAddressConfiguration { private boolean autoUnifyExtensions = false; private boolean allowNonGLExtensions = false; - public GLConfiguration(GLEmitter emitter) { + public GLConfiguration(final GLEmitter emitter) { super(); this.emitter = emitter; try { setProcAddressNameExpr("PFN $UPPERCASE({0}) PROC"); - } catch (NoSuchElementException e) { + } catch (final NoSuchElementException e) { throw new RuntimeException("Error configuring ProcAddressNameExpr", e); } } @Override - protected void dispatch(String cmd, StringTokenizer tok, File file, String filename, int lineNo) throws IOException { + protected void dispatch(final String cmd, final StringTokenizer tok, final File file, final String filename, final int lineNo) throws IOException { if (cmd.equalsIgnoreCase("IgnoreExtension")) { - String sym = readString("IgnoreExtension", tok, filename, lineNo); + final String sym = readString("IgnoreExtension", tok, filename, lineNo); ignoredExtensions.add(sym); } else if (cmd.equalsIgnoreCase("ForceExtension")) { - String sym = readString("ForceExtension", tok, filename, lineNo); + final String sym = readString("ForceExtension", tok, filename, lineNo); forcedExtensions.add(sym); } else if (cmd.equalsIgnoreCase("RenameExtensionIntoCore")) { - String sym = readString("RenameExtensionIntoCore", tok, filename, lineNo); + final String sym = readString("RenameExtensionIntoCore", tok, filename, lineNo); extensionsRenamedIntoCore.add(sym); } else if (cmd.equalsIgnoreCase("AllowNonGLExtensions")) { allowNonGLExtensions = readBoolean("AllowNonGLExtensions", tok, filename, lineNo).booleanValue(); } else if (cmd.equalsIgnoreCase("AutoUnifyExtensions")) { autoUnifyExtensions = readBoolean("AutoUnifyExtensions", tok, filename, lineNo).booleanValue(); } else if (cmd.equalsIgnoreCase("GLHeader")) { - String sym = readString("GLHeader", tok, filename, lineNo); + final String sym = readString("GLHeader", tok, filename, lineNo); glHeaders.add(sym); } else if (cmd.equalsIgnoreCase("BufferObjectKind")) { readBufferObjectKind(tok, filename, lineNo); } else if (cmd.equalsIgnoreCase("BufferObjectOnly")) { - String sym = readString("BufferObjectOnly", tok, filename, lineNo); + final String sym = readString("BufferObjectOnly", tok, filename, lineNo); bufferObjectOnly.add(sym); } else if (cmd.equalsIgnoreCase("DropUniqVendorExtensions")) { - String sym = readString("DropUniqVendorExtensions", tok, filename, lineNo); + final String sym = readString("DropUniqVendorExtensions", tok, filename, lineNo); dropUniqVendorExtensions.add(sym); } else { super.dispatch(cmd, tok, file, filename, lineNo); } } - protected void readBufferObjectKind(StringTokenizer tok, String filename, int lineNo) { + protected void readBufferObjectKind(final StringTokenizer tok, final String filename, final int lineNo) { try { - String kindString = tok.nextToken(); + final String kindString = tok.nextToken(); GLEmitter.BufferObjectKind kind = null; - String target = tok.nextToken(); + final String target = tok.nextToken(); if (kindString.equalsIgnoreCase("UnpackPixel")) { kind = GLEmitter.BufferObjectKind.UNPACK_PIXEL; } else if (kindString.equalsIgnoreCase("PackPixel")) { @@ -140,7 +140,7 @@ public class GLConfiguration extends ProcAddressConfiguration { } bufferObjectKinds.put(target, kind); - } catch (NoSuchElementException e) { + } catch (final NoSuchElementException e) { throw new RuntimeException("Error parsing \"BufferObjectKind\" command at line " + lineNo + " in file \"" + filename + "\"", e); } @@ -150,10 +150,10 @@ public class GLConfiguration extends ProcAddressConfiguration { automatically generates prologue code for functions associated with buffer objects. */ @Override - public List<String> javaPrologueForMethod(MethodBinding binding, boolean forImplementingMethodCall, boolean eraseBufferAndArrayTypes) { + public List<String> javaPrologueForMethod(final MethodBinding binding, final boolean forImplementingMethodCall, final boolean eraseBufferAndArrayTypes) { List<String> res = super.javaPrologueForMethod(binding, forImplementingMethodCall, eraseBufferAndArrayTypes); - GLEmitter.BufferObjectKind kind = getBufferObjectKind(binding.getName()); + final GLEmitter.BufferObjectKind kind = getBufferObjectKind(binding.getName()); if (kind != null) { // Need to generate appropriate prologue based on both buffer // object kind and whether this variant of the MethodBinding @@ -161,7 +161,7 @@ public class GLConfiguration extends ProcAddressConfiguration { // // NOTE we MUST NOT mutate the array returned from the super // call! - ArrayList<String> res2 = new ArrayList<String>(); + final ArrayList<String> res2 = new ArrayList<String>(); if (res != null) { res2.addAll(res); } @@ -196,8 +196,8 @@ public class GLConfiguration extends ProcAddressConfiguration { // Must also filter out bogus rangeCheck directives for VBO/PBO // variants if (emitter.isBufferObjectMethodBinding(binding)) { - for (Iterator<String> iter = res.iterator(); iter.hasNext();) { - String line = iter.next(); + for (final Iterator<String> iter = res.iterator(); iter.hasNext();) { + final String line = iter.next(); if (line.indexOf("Buffers.rangeCheck") >= 0) { iter.remove(); } @@ -211,22 +211,22 @@ public class GLConfiguration extends ProcAddressConfiguration { @Override public void dumpIgnores() { System.err.println("GL Ignored extensions: "); - for (String str : ignoredExtensions) { + for (final String str : ignoredExtensions) { System.err.println("\t" + str); } System.err.println("GL Forced extensions: "); - for (String str : forcedExtensions) { + for (final String str : forcedExtensions) { System.err.println("\t" + str); } super.dumpIgnores(); } - protected boolean shouldIgnoreExtension(String symbol, boolean criteria) { + protected boolean shouldIgnoreExtension(final String symbol, final boolean criteria) { if (criteria && glInfo != null) { final Set<String> extensionNames = glInfo.getExtension(symbol); if( null != extensionNames ) { boolean ignoredExtension = false; - for(Iterator<String> i=extensionNames.iterator(); !ignoredExtension && i.hasNext(); ) { + for(final Iterator<String> i=extensionNames.iterator(); !ignoredExtension && i.hasNext(); ) { final String extensionName = i.next(); if ( extensionName != null && ignoredExtensions.contains(extensionName) ) { if (DEBUG_IGNORES) { @@ -245,7 +245,7 @@ public class GLConfiguration extends ProcAddressConfiguration { if( ignoredExtension ) { final Set<String> origSymbols = getRenamedJavaSymbols( symbol ); if(null != origSymbols) { - for(String origSymbol : origSymbols) { + for(final String origSymbol : origSymbols) { if( shouldForceExtension( origSymbol, true, symbol ) ) { ignoredExtension = false; break; @@ -258,11 +258,11 @@ public class GLConfiguration extends ProcAddressConfiguration { return true; } } - boolean isGLEnum = GLNameResolver.isGLEnumeration(symbol); - boolean isGLFunc = GLNameResolver.isGLFunction(symbol); + final boolean isGLEnum = GLNameResolver.isGLEnumeration(symbol); + final boolean isGLFunc = GLNameResolver.isGLFunction(symbol); if (isGLFunc || isGLEnum) { if (GLNameResolver.isExtensionVEN(symbol, isGLFunc)) { - String extSuffix = GLNameResolver.getExtensionSuffix(symbol, isGLFunc); + final String extSuffix = GLNameResolver.getExtensionSuffix(symbol, isGLFunc); if (getDropUniqVendorExtensions(extSuffix)) { if (DEBUG_IGNORES) { System.err.println("Ignore UniqVendorEXT: " + symbol + ", vendor " + extSuffix); @@ -279,7 +279,7 @@ public class GLConfiguration extends ProcAddressConfiguration { if (criteria && glInfo != null) { final Set<String> extensionNames = glInfo.getExtension(symbol); if( null != extensionNames ) { - for(Iterator<String> i=extensionNames.iterator(); i.hasNext(); ) { + for(final Iterator<String> i=extensionNames.iterator(); i.hasNext(); ) { final String extensionName = i.next(); if ( extensionName != null && forcedExtensions.contains(extensionName) ) { if (DEBUG_IGNORES) { @@ -299,20 +299,20 @@ public class GLConfiguration extends ProcAddressConfiguration { } @Override - public boolean shouldIgnoreInInterface(String symbol) { + public boolean shouldIgnoreInInterface(final String symbol) { return shouldIgnoreInInterface(symbol, true); } - public boolean shouldIgnoreInInterface(String symbol, boolean checkEXT) { + public boolean shouldIgnoreInInterface(final String symbol, final boolean checkEXT) { return shouldIgnoreExtension(symbol, checkEXT) || super.shouldIgnoreInInterface(symbol); } @Override - public boolean shouldIgnoreInImpl(String symbol) { + public boolean shouldIgnoreInImpl(final String symbol) { return shouldIgnoreInImpl(symbol, true); } - public boolean shouldIgnoreInImpl(String symbol, boolean checkEXT) { + public boolean shouldIgnoreInImpl(final String symbol, final boolean checkEXT) { return shouldIgnoreExtension(symbol, checkEXT) || super.shouldIgnoreInImpl(symbol); } @@ -330,32 +330,32 @@ public class GLConfiguration extends ProcAddressConfiguration { } /** shall the non unified (uniq) vendor extensions be dropped ? */ - public boolean getDropUniqVendorExtensions(String extName) { + public boolean getDropUniqVendorExtensions(final String extName) { return dropUniqVendorExtensions.contains(extName); } /** Returns the kind of buffer object this function deals with, or null if none. */ - GLEmitter.BufferObjectKind getBufferObjectKind(String name) { + GLEmitter.BufferObjectKind getBufferObjectKind(final String name) { return bufferObjectKinds.get(name); } - public boolean isBufferObjectFunction(String name) { + public boolean isBufferObjectFunction(final String name) { return (getBufferObjectKind(name) != null); } - public boolean isBufferObjectOnly(String name) { + public boolean isBufferObjectOnly(final String name) { return bufferObjectOnly.contains(name); } /** Parses any GL headers specified in the configuration file for the purpose of being able to ignore an extension at a time. */ - public void parseGLHeaders(GlueEmitterControls controls) throws IOException { + public void parseGLHeaders(final GlueEmitterControls controls) throws IOException { if (!glHeaders.isEmpty()) { glInfo = new BuildStaticGLInfo(); glInfo.setDebug(GlueGen.debug()); - for (String file : glHeaders) { - String fullPath = controls.findHeaderFile(file); + for (final String file : glHeaders) { + final String fullPath = controls.findHeaderFile(file); if (fullPath == null) { throw new IOException("Unable to locate header file \"" + file + "\""); } diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/GLEmitter.java b/src/jogl/classes/com/jogamp/gluegen/opengl/GLEmitter.java index 547382ed1..bc230c83a 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/GLEmitter.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/GLEmitter.java @@ -72,12 +72,12 @@ public class GLEmitter extends ProcAddressEmitter { // Keeps track of which MethodBindings were created for handling // Buffer Object variants. Used as a Set rather than a Map. - private Map<MethodBinding, MethodBinding> bufferObjectMethodBindings = new IdentityHashMap<MethodBinding, MethodBinding>(); + private final Map<MethodBinding, MethodBinding> bufferObjectMethodBindings = new IdentityHashMap<MethodBinding, MethodBinding>(); enum BufferObjectKind { UNPACK_PIXEL, PACK_PIXEL, ARRAY, ELEMENT, INDIRECT} @Override - public void beginEmission(GlueEmitterControls controls) throws IOException { + public void beginEmission(final GlueEmitterControls controls) throws IOException { getGLConfig().parseGLHeaders(controls); renameExtensionsIntoCore(); if (getGLConfig().getAutoUnifyExtensions()) { @@ -93,30 +93,30 @@ public class GLEmitter extends ProcAddressEmitter { // already in the core namespace in desktop OpenGL. It builds upon // renaming mechanisms that are built elsewhere. - GLConfiguration config = getGLConfig(); - Set<String> extensionsRenamedIntoCore = config.getExtensionsRenamedIntoCore(); - BuildStaticGLInfo glInfo = config.getGLInfo(); + final GLConfiguration config = getGLConfig(); + final Set<String> extensionsRenamedIntoCore = config.getExtensionsRenamedIntoCore(); + final BuildStaticGLInfo glInfo = config.getGLInfo(); if (null == glInfo) { if (extensionsRenamedIntoCore.size() > 0) { throw new RuntimeException("ExtensionRenamedIntoCore (num: " + extensionsRenamedIntoCore.size() + "), but no GLHeader"); } return; } - for (String extension : extensionsRenamedIntoCore) { + for (final String extension : extensionsRenamedIntoCore) { if(JavaConfiguration.DEBUG_RENAMES) { System.err.println("<RenameExtensionIntoCore: "+extension+" BEGIN"); } - Set<String> declarations = glInfo.getDeclarations(extension); + final Set<String> declarations = glInfo.getDeclarations(extension); if (declarations != null) { - for (Iterator<String> iterator = declarations.iterator(); iterator.hasNext();) { - String decl = iterator.next(); - boolean isGLFunction = GLNameResolver.isGLFunction(decl); + for (final Iterator<String> iterator = declarations.iterator(); iterator.hasNext();) { + final String decl = iterator.next(); + final boolean isGLFunction = GLNameResolver.isGLFunction(decl); boolean isGLEnumeration = false; if (!isGLFunction) { isGLEnumeration = GLNameResolver.isGLEnumeration(decl); } if (isGLFunction || isGLEnumeration) { - String renamed = GLNameResolver.normalize(decl, isGLFunction); + final String renamed = GLNameResolver.normalize(decl, isGLFunction); if (!renamed.equals(decl)) { config.addJavaSymbolRename(decl, renamed); } @@ -135,8 +135,8 @@ public class GLEmitter extends ProcAddressEmitter { private List<FunctionSymbol> functions; @Override - public void filterSymbols(List<ConstantDefinition> constants, - List<FunctionSymbol> functions) { + public void filterSymbols(final List<ConstantDefinition> constants, + final List<FunctionSymbol> functions) { this.constants = constants; this.functions = functions; doWork(); @@ -153,17 +153,17 @@ public class GLEmitter extends ProcAddressEmitter { } private void doWork() { - BuildStaticGLInfo glInfo = getGLConfig().getGLInfo(); + final BuildStaticGLInfo glInfo = getGLConfig().getGLInfo(); if (glInfo == null) { return; } // Try to retain a "good" ordering for these symbols - Map<String, ConstantDefinition> constantMap = new LinkedHashMap<String, ConstantDefinition>(); - for (ConstantDefinition def : constants) { + final Map<String, ConstantDefinition> constantMap = new LinkedHashMap<String, ConstantDefinition>(); + for (final ConstantDefinition def : constants) { constantMap.put(def.getName(), def); } - Map<String, FunctionSymbol> functionMap = new LinkedHashMap<String, FunctionSymbol>(); - for (FunctionSymbol sym : functions) { + final Map<String, FunctionSymbol> functionMap = new LinkedHashMap<String, FunctionSymbol>(); + for (final FunctionSymbol sym : functions) { functionMap.put(sym.getName(), sym); } @@ -175,15 +175,15 @@ public class GLEmitter extends ProcAddressEmitter { // that doesn't support the core version of these APIs, the runtime // will take care of looking up the extension version of these entry // points. - Set<String> extensionNames = glInfo.getExtensions(); + final Set<String> extensionNames = glInfo.getExtensions(); - for (String extension : extensionNames) { - Set<String> declarations = glInfo.getDeclarations(extension); + for (final String extension : extensionNames) { + final Set<String> declarations = glInfo.getDeclarations(extension); boolean isExtension = true; boolean shouldUnify = true; String cause = null; - for (String decl : declarations) { - boolean isFunc = !decl.startsWith("GL_"); + for (final String decl : declarations) { + final boolean isFunc = !decl.startsWith("GL_"); if (!GLNameResolver.isExtension(decl, isFunc)) { isExtension = false; break; @@ -202,7 +202,7 @@ public class GLEmitter extends ProcAddressEmitter { } } cause = decl; - String unifiedName = GLNameResolver.normalize(decl, isFunc); + final String unifiedName = GLNameResolver.normalize(decl, isFunc); // NOTE that we look up the unified name in the // BuildStaticGLInfo's notion of the APIs -- since // we might not be emitting glue code for the @@ -225,8 +225,8 @@ public class GLEmitter extends ProcAddressEmitter { } if (isExtension) { if (shouldUnify) { - for (String decl : declarations) { - boolean isFunc = !decl.startsWith("GL_"); + for (final String decl : declarations) { + final boolean isFunc = !decl.startsWith("GL_"); if (isFunc) { functionMap.remove(decl); } else { @@ -244,7 +244,7 @@ public class GLEmitter extends ProcAddressEmitter { } } - private void unifyExtensions(GlueEmitterControls controls) { + private void unifyExtensions(final GlueEmitterControls controls) { controls.runSymbolFilter(new ExtensionUnifier()); } @@ -264,7 +264,7 @@ public class GLEmitter extends ProcAddressEmitter { inform the CMethodBindingEmitter that it is overloaded in this case (though we default to true currently). */ @Override - protected List<MethodBinding> expandMethodBinding(MethodBinding binding) { + protected List<MethodBinding> expandMethodBinding(final MethodBinding binding) { final GLConfiguration glConfig = getGLConfig(); final List<MethodBinding> bindings = super.expandMethodBinding(binding); @@ -322,7 +322,7 @@ public class GLEmitter extends ProcAddressEmitter { } @Override - protected boolean needsModifiedEmitters(FunctionSymbol sym) { + protected boolean needsModifiedEmitters(final FunctionSymbol sym) { if ((!needsProcAddressWrapper(sym) && !needsBufferObjectVariant(sym)) || getConfig().isUnimplemented(sym.getName())) { return false; @@ -331,22 +331,22 @@ public class GLEmitter extends ProcAddressEmitter { return true; } - public boolean isBufferObjectMethodBinding(MethodBinding binding) { + public boolean isBufferObjectMethodBinding(final MethodBinding binding) { return bufferObjectMethodBindings.containsKey(binding); } @Override - public void emitDefine(ConstantDefinition def, String optionalComment) throws Exception { - BuildStaticGLInfo glInfo = getGLConfig().getGLInfo(); + public void emitDefine(final ConstantDefinition def, final String optionalComment) throws Exception { + final BuildStaticGLInfo glInfo = getGLConfig().getGLInfo(); if (null == glInfo) { throw new Exception("No GLInfo for: " + def); } - String symbolRenamed = def.getName(); - StringBuilder newComment = new StringBuilder(); + final String symbolRenamed = def.getName(); + final StringBuilder newComment = new StringBuilder(); newComment.append("Part of "); if (0 == addExtensionsOfSymbols2Buffer(newComment, ", ", "; ", symbolRenamed, def.getAliasedNames())) { if (def.isEnum()) { - String enumName = def.getEnumName(); + final String enumName = def.getEnumName(); if (null != enumName) { newComment.append(enumName); } else { @@ -362,7 +362,7 @@ public class GLEmitter extends ProcAddressEmitter { // ... // #endif if (JavaConfiguration.DEBUG_IGNORES) { - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); JavaEmitter.addStrings2Buffer(sb, ", ", symbolRenamed, def.getAliasedNames()); System.err.println("Dropping marker: " + sb.toString()); } @@ -379,12 +379,12 @@ public class GLEmitter extends ProcAddressEmitter { super.emitDefine(def, newComment.toString()); } - private int addExtensionListOfSymbol2Buffer(BuildStaticGLInfo glInfo, StringBuilder buf, String sep1, String name) { + private int addExtensionListOfSymbol2Buffer(final BuildStaticGLInfo glInfo, final StringBuilder buf, final String sep1, final String name) { int num = 0; - Set<String> extensionNames = glInfo.getExtension(name); + final Set<String> extensionNames = glInfo.getExtension(name); if(null!=extensionNames) { - for(Iterator<String> i=extensionNames.iterator(); i.hasNext(); ) { - String extensionName = i.next(); + for(final Iterator<String> i=extensionNames.iterator(); i.hasNext(); ) { + final String extensionName = i.next(); if (null != extensionName) { buf.append("<code>"); buf.append(extensionName); @@ -398,19 +398,19 @@ public class GLEmitter extends ProcAddressEmitter { } return num; } - private int addExtensionListOfAliasedSymbols2Buffer(BuildStaticGLInfo glInfo, StringBuilder buf, String sep1, String sep2, String name, Collection<String> exclude) { + private int addExtensionListOfAliasedSymbols2Buffer(final BuildStaticGLInfo glInfo, final StringBuilder buf, final String sep1, final String sep2, final String name, final Collection<String> exclude) { int num = 0; if(null != name) { num += addExtensionListOfSymbol2Buffer(glInfo, buf, sep1, name); // extensions of given name boolean needsSep2 = 0<num; - Set<String> origNames = cfg.getRenamedJavaSymbols(name); + final Set<String> origNames = cfg.getRenamedJavaSymbols(name); if(null != origNames) { - for(String origName : origNames) { + for(final String origName : origNames) { if(!exclude.contains(origName)) { if (needsSep2) { buf.append(sep2); // diff-name seperator } - int num2 = addExtensionListOfSymbol2Buffer(glInfo, buf, sep1, origName); // extensions of orig-name + final int num2 = addExtensionListOfSymbol2Buffer(glInfo, buf, sep1, origName); // extensions of orig-name needsSep2 = num<num2; num += num2; } @@ -420,8 +420,8 @@ public class GLEmitter extends ProcAddressEmitter { return num; } - public int addExtensionsOfSymbols2Buffer(StringBuilder buf, String sep1, String sep2, String first, Collection<String> col) { - BuildStaticGLInfo glInfo = getGLConfig().getGLInfo(); + public int addExtensionsOfSymbols2Buffer(StringBuilder buf, final String sep1, final String sep2, final String first, final Collection<String> col) { + final BuildStaticGLInfo glInfo = getGLConfig().getGLInfo(); if (null == glInfo) { throw new RuntimeException("No GLInfo for: " + first); } @@ -432,11 +432,11 @@ public class GLEmitter extends ProcAddressEmitter { num += addExtensionListOfAliasedSymbols2Buffer(glInfo, buf, sep1, sep2, first, col); boolean needsSep2 = 0<num; - for(Iterator<String> iter = col.iterator(); iter.hasNext(); ) { + for(final Iterator<String> iter = col.iterator(); iter.hasNext(); ) { if(needsSep2) { buf.append(sep2); // diff-name seperator } - int num2 = addExtensionListOfAliasedSymbols2Buffer(glInfo, buf, sep1, sep2, iter.next(), col); + final int num2 = addExtensionListOfAliasedSymbols2Buffer(glInfo, buf, sep1, sep2, iter.next(), col); needsSep2 = num<num2; num += num2; } @@ -447,12 +447,12 @@ public class GLEmitter extends ProcAddressEmitter { // Internals only below this point // @Override - protected void generateModifiedEmitters(JavaMethodBindingEmitter baseJavaEmitter, List<FunctionEmitter> emitters) { - List<FunctionEmitter> superEmitters = new ArrayList<FunctionEmitter>(); + protected void generateModifiedEmitters(final JavaMethodBindingEmitter baseJavaEmitter, final List<FunctionEmitter> emitters) { + final List<FunctionEmitter> superEmitters = new ArrayList<FunctionEmitter>(); super.generateModifiedEmitters(baseJavaEmitter, superEmitters); // See whether this is one of the Buffer Object variants - boolean bufferObjectVariant = bufferObjectMethodBindings.containsKey(baseJavaEmitter.getBinding()); + final boolean bufferObjectVariant = bufferObjectMethodBindings.containsKey(baseJavaEmitter.getBinding()); for (FunctionEmitter emitter : superEmitters) { if (emitter instanceof ProcAddressJavaMethodBindingEmitter) { @@ -462,7 +462,7 @@ public class GLEmitter extends ProcAddressEmitter { } } - protected boolean needsBufferObjectVariant(FunctionSymbol sym) { + protected boolean needsBufferObjectVariant(final FunctionSymbol sym) { return getGLConfig().isBufferObjectFunction(sym.getName()); } @@ -475,7 +475,7 @@ public class GLEmitter extends ProcAddressEmitter { */ @Override protected void endProcAddressTable() throws Exception { - PrintWriter w = tableWriter; + final PrintWriter w = tableWriter; w.println(" @Override"); w.println(" protected boolean isFunctionAvailableImpl(String functionNameUsr) throws IllegalArgumentException {"); diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/GLJavaMethodBindingEmitter.java b/src/jogl/classes/com/jogamp/gluegen/opengl/GLJavaMethodBindingEmitter.java index 389d35f99..d491a3712 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/GLJavaMethodBindingEmitter.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/GLJavaMethodBindingEmitter.java @@ -58,8 +58,8 @@ public class GLJavaMethodBindingEmitter extends ProcAddressJavaMethodBindingEmit protected GLEmitter glEmitter; protected CommentEmitter glCommentEmitter = new GLCommentEmitter(); - public GLJavaMethodBindingEmitter(JavaMethodBindingEmitter methodToWrap, boolean callThroughProcAddress, - String getProcAddressTableExpr, boolean changeNameAndArguments, boolean bufferObjectVariant, GLEmitter emitter) { + public GLJavaMethodBindingEmitter(final JavaMethodBindingEmitter methodToWrap, final boolean callThroughProcAddress, + final String getProcAddressTableExpr, final boolean changeNameAndArguments, final boolean bufferObjectVariant, final GLEmitter emitter) { super(methodToWrap, callThroughProcAddress, getProcAddressTableExpr, changeNameAndArguments, emitter); this.bufferObjectVariant = bufferObjectVariant; @@ -67,20 +67,20 @@ public class GLJavaMethodBindingEmitter extends ProcAddressJavaMethodBindingEmit setCommentEmitter(glCommentEmitter); } - public GLJavaMethodBindingEmitter(ProcAddressJavaMethodBindingEmitter methodToWrap, GLEmitter emitter, boolean bufferObjectVariant) { + public GLJavaMethodBindingEmitter(final ProcAddressJavaMethodBindingEmitter methodToWrap, final GLEmitter emitter, final boolean bufferObjectVariant) { super(methodToWrap); this.bufferObjectVariant = bufferObjectVariant; this.glEmitter = emitter; setCommentEmitter(glCommentEmitter); } - public GLJavaMethodBindingEmitter(GLJavaMethodBindingEmitter methodToWrap) { + public GLJavaMethodBindingEmitter(final GLJavaMethodBindingEmitter methodToWrap) { this(methodToWrap, methodToWrap.glEmitter, methodToWrap.bufferObjectVariant); } @Override - protected String getArgumentName(int i) { - String name = super.getArgumentName(i); + protected String getArgumentName(final int i) { + final String name = super.getArgumentName(i); if (!bufferObjectVariant) { return name; @@ -89,8 +89,8 @@ public class GLJavaMethodBindingEmitter extends ProcAddressJavaMethodBindingEmit // Emitters for VBO/PBO-related routines change the outgoing // argument name for the buffer if (binding.getJavaArgumentType(i).isLong()) { - Type cType = binding.getCArgumentType(i); - Type targetType = cType.asPointer().getTargetType(); + final Type cType = binding.getCArgumentType(i); + final Type targetType = cType.asPointer().getTargetType(); if (cType.isPointer() && (targetType.isVoid() || targetType.isPrimitive())) { return name + "_buffer_offset"; } @@ -102,10 +102,10 @@ public class GLJavaMethodBindingEmitter extends ProcAddressJavaMethodBindingEmit protected class GLCommentEmitter extends JavaMethodBindingEmitter.DefaultCommentEmitter { @Override - protected void emitBindingCSignature(MethodBinding binding, PrintWriter writer) { + protected void emitBindingCSignature(final MethodBinding binding, final PrintWriter writer) { - String symbolRenamed = binding.getName(); - StringBuilder newComment = new StringBuilder(); + final String symbolRenamed = binding.getName(); + final StringBuilder newComment = new StringBuilder(); final FunctionSymbol funcSym = binding.getCSymbol(); writer.print("<code> "); @@ -117,9 +117,9 @@ public class GLJavaMethodBindingEmitter extends ProcAddressJavaMethodBindingEmit if (glEmitter.getGLConfig().getAllowNonGLExtensions()) { newComment.append("CORE FUNC"); } else { - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); JavaEmitter.addStrings2Buffer(sb, ", ", symbolRenamed, binding.getAliasedNames()); - RuntimeException ex = new RuntimeException("Couldn't find extension to: " + binding + " ; " + sb.toString()); + final RuntimeException ex = new RuntimeException("Couldn't find extension to: " + binding + " ; " + sb.toString()); glEmitter.getGLConfig().getGLInfo().dump(); // glEmitter.getGLConfig().dumpRenames(); throw ex; diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/ant/StaticGLGenTask.java b/src/jogl/classes/com/jogamp/gluegen/opengl/ant/StaticGLGenTask.java index 21946ea89..66819a83e 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/ant/StaticGLGenTask.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/ant/StaticGLGenTask.java @@ -78,7 +78,7 @@ public class StaticGLGenTask extends Task * <p>The {@link org.apache.tools.ant.types.CommandlineJava} that is used * to execute {@link com.jogamp.gluegen.opengl.BuildStaticGLInfo}.</p> */ - private CommandlineJava glgenCommandline; + private final CommandlineJava glgenCommandline; // ========================================================================= /** @@ -94,7 +94,7 @@ public class StaticGLGenTask extends Task /** * <p>The {@link org.apache.tools.ant.types.FileSet} of GL headers.</p> */ - private FileSet headerSet = new FileSet(); + private final FileSet headerSet = new FileSet(); // ========================================================================= /** @@ -117,7 +117,7 @@ public class StaticGLGenTask extends Task * * @param packageName the name of the package for the generated files */ - public void setPackage(String packageName) + public void setPackage(final String packageName) { log( ("Setting package name to: " + packageName), Project.MSG_VERBOSE); this.packageName = packageName; @@ -128,7 +128,7 @@ public class StaticGLGenTask extends Task * * @param directory the output directory */ - public void setOutputDir(String directory) + public void setOutputDir(final String directory) { log( ("Setting output directory to: " + directory), Project.MSG_VERBOSE); @@ -163,7 +163,7 @@ public class StaticGLGenTask extends Task * * @param headers the string containing the header patterns */ - public void setHeaders(String headers) + public void setHeaders(final String headers) { headerSet.setIncludes(headers); } @@ -236,7 +236,7 @@ public class StaticGLGenTask extends Task * @return <code>true</code> if the string is valid. <code>false</code> * otherwise. */ - private boolean isValid(String string) + private boolean isValid(final String string) { // check for null if(string == null) @@ -265,8 +265,8 @@ public class StaticGLGenTask extends Task // add the header -files- from the FileSet headerSet.setDir(getProject().getBaseDir()); - DirectoryScanner directoryScanner = headerSet.getDirectoryScanner(getProject()); - String[] directoryFiles = directoryScanner.getIncludedFiles(); + final DirectoryScanner directoryScanner = headerSet.getDirectoryScanner(getProject()); + final String[] directoryFiles = directoryScanner.getIncludedFiles(); for(int i=0; i<directoryFiles.length; i++) { glgenCommandline.createArgument().setValue(directoryFiles[i]); @@ -279,11 +279,11 @@ public class StaticGLGenTask extends Task * * @throws BuildException */ - private int execute(String[] command) + private int execute(final String[] command) throws BuildException { // create the object that will perform the command execution - Execute execute = new Execute(new LogStreamHandler(this, Project.MSG_INFO, + final Execute execute = new Execute(new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_WARN), null); @@ -296,7 +296,7 @@ public class StaticGLGenTask extends Task try { return execute.execute(); - } catch(IOException ioe) + } catch(final IOException ioe) { throw new BuildException(ioe, location); } diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/nativesig/NativeSignatureEmitter.java b/src/jogl/classes/com/jogamp/gluegen/opengl/nativesig/NativeSignatureEmitter.java index 4ac9ae3f3..de9e3ed25 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/nativesig/NativeSignatureEmitter.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/nativesig/NativeSignatureEmitter.java @@ -61,14 +61,14 @@ import java.util.Set; public class NativeSignatureEmitter extends GLEmitter { @Override - protected List<? extends FunctionEmitter> generateMethodBindingEmitters(Set<MethodBinding> methodBindingSet, FunctionSymbol sym) throws Exception { + protected List<? extends FunctionEmitter> generateMethodBindingEmitters(final Set<MethodBinding> methodBindingSet, final FunctionSymbol sym) throws Exception { // Allow superclass to do most of the work for us - List<? extends FunctionEmitter> res = super.generateMethodBindingEmitters(methodBindingSet, sym); + final List<? extends FunctionEmitter> res = super.generateMethodBindingEmitters(methodBindingSet, sym); // Filter out all non-JavaMethodBindingEmitters - for (Iterator<? extends FunctionEmitter> iter = res.iterator(); iter.hasNext();) { - FunctionEmitter emitter = iter.next(); + for (final Iterator<? extends FunctionEmitter> iter = res.iterator(); iter.hasNext();) { + final FunctionEmitter emitter = iter.next(); if (!(emitter instanceof JavaMethodBindingEmitter)) { iter.remove(); } @@ -78,13 +78,13 @@ public class NativeSignatureEmitter extends GLEmitter { return res; } - PrintWriter writer = (getConfig().allStatic() ? javaWriter() : javaImplWriter()); + final PrintWriter writer = (getConfig().allStatic() ? javaWriter() : javaImplWriter()); - List<FunctionEmitter> processed = new ArrayList<FunctionEmitter>(); + final List<FunctionEmitter> processed = new ArrayList<FunctionEmitter>(); // First, filter out all emitters going to the "other" (public) writer - for (Iterator<? extends FunctionEmitter> iter = res.iterator(); iter.hasNext();) { - FunctionEmitter emitter = iter.next(); + for (final Iterator<? extends FunctionEmitter> iter = res.iterator(); iter.hasNext();) { + final FunctionEmitter emitter = iter.next(); if (emitter.getDefaultOutput() != writer) { processed.add(emitter); iter.remove(); @@ -93,12 +93,12 @@ public class NativeSignatureEmitter extends GLEmitter { // Now process all of the remaining emitters sorted by MethodBinding while (!res.isEmpty()) { - List<JavaMethodBindingEmitter> emittersForBinding = new ArrayList<JavaMethodBindingEmitter>(); - JavaMethodBindingEmitter emitter = (JavaMethodBindingEmitter) res.remove(0); + final List<JavaMethodBindingEmitter> emittersForBinding = new ArrayList<JavaMethodBindingEmitter>(); + final JavaMethodBindingEmitter emitter = (JavaMethodBindingEmitter) res.remove(0); emittersForBinding.add(emitter); - MethodBinding binding = emitter.getBinding(); - for (Iterator<? extends FunctionEmitter> iter = res.iterator(); iter.hasNext();) { - JavaMethodBindingEmitter emitter2 = (JavaMethodBindingEmitter) iter.next(); + final MethodBinding binding = emitter.getBinding(); + for (final Iterator<? extends FunctionEmitter> iter = res.iterator(); iter.hasNext();) { + final JavaMethodBindingEmitter emitter2 = (JavaMethodBindingEmitter) iter.next(); if (emitter2.getBinding() == binding) { emittersForBinding.add(emitter2); iter.remove(); @@ -111,17 +111,17 @@ public class NativeSignatureEmitter extends GLEmitter { return processed; } - protected void generateNativeSignatureEmitters(MethodBinding binding, List<JavaMethodBindingEmitter> allEmitters) { + protected void generateNativeSignatureEmitters(final MethodBinding binding, final List<JavaMethodBindingEmitter> allEmitters) { if (allEmitters.isEmpty()) { return; } - PrintWriter writer = (getConfig().allStatic() ? javaWriter() : javaImplWriter()); + final PrintWriter writer = (getConfig().allStatic() ? javaWriter() : javaImplWriter()); // Give ourselves the chance to interpose on the generation of all code to keep things simple - List<JavaMethodBindingEmitter> newEmitters = new ArrayList<JavaMethodBindingEmitter>(); - for (JavaMethodBindingEmitter javaEmitter : allEmitters) { + final List<JavaMethodBindingEmitter> newEmitters = new ArrayList<JavaMethodBindingEmitter>(); + for (final JavaMethodBindingEmitter javaEmitter : allEmitters) { NativeSignatureJavaMethodBindingEmitter newEmitter = null; if (javaEmitter instanceof GLJavaMethodBindingEmitter) { newEmitter = new NativeSignatureJavaMethodBindingEmitter((GLJavaMethodBindingEmitter) javaEmitter); @@ -138,11 +138,11 @@ public class NativeSignatureEmitter extends GLEmitter { // been called with signatureOnly both true and false. if (signatureContainsStrings(binding) && !haveEmitterWithBody(allEmitters)) { // This basically handles glGetString but also any similar methods - NativeSignatureJavaMethodBindingEmitter javaEmitter = findEmitterWithWriter(allEmitters, writer); + final NativeSignatureJavaMethodBindingEmitter javaEmitter = findEmitterWithWriter(allEmitters, writer); // First, we need to clone this emitter to produce the native // entry point - NativeSignatureJavaMethodBindingEmitter emitter = new NativeSignatureJavaMethodBindingEmitter(javaEmitter); + final NativeSignatureJavaMethodBindingEmitter emitter = new NativeSignatureJavaMethodBindingEmitter(javaEmitter); emitter.removeModifier(JavaMethodBindingEmitter.PUBLIC); emitter.addModifier(JavaMethodBindingEmitter.PRIVATE); emitter.setForImplementingMethodCall(true); @@ -158,22 +158,22 @@ public class NativeSignatureEmitter extends GLEmitter { } } - protected boolean signatureContainsStrings(MethodBinding binding) { + protected boolean signatureContainsStrings(final MethodBinding binding) { for (int i = 0; i < binding.getNumArguments(); i++) { - JavaType type = binding.getJavaArgumentType(i); + final JavaType type = binding.getJavaArgumentType(i); if (type.isString() || type.isStringArray()) { return true; } } - JavaType retType = binding.getJavaReturnType(); + final JavaType retType = binding.getJavaReturnType(); if (retType.isString() || retType.isStringArray()) { return true; } return false; } - protected boolean haveEmitterWithBody(List<JavaMethodBindingEmitter> allEmitters) { - for (JavaMethodBindingEmitter emitter : allEmitters) { + protected boolean haveEmitterWithBody(final List<JavaMethodBindingEmitter> allEmitters) { + for (final JavaMethodBindingEmitter emitter : allEmitters) { if (!emitter.signatureOnly()) { return true; } @@ -181,9 +181,9 @@ public class NativeSignatureEmitter extends GLEmitter { return false; } - protected NativeSignatureJavaMethodBindingEmitter findEmitterWithWriter(List<JavaMethodBindingEmitter> allEmitters, PrintWriter writer) { - for (JavaMethodBindingEmitter jemitter : allEmitters) { - NativeSignatureJavaMethodBindingEmitter emitter = (NativeSignatureJavaMethodBindingEmitter)jemitter; + protected NativeSignatureJavaMethodBindingEmitter findEmitterWithWriter(final List<JavaMethodBindingEmitter> allEmitters, final PrintWriter writer) { + for (final JavaMethodBindingEmitter jemitter : allEmitters) { + final NativeSignatureJavaMethodBindingEmitter emitter = (NativeSignatureJavaMethodBindingEmitter)jemitter; if (emitter.getDefaultOutput() == writer) { return emitter; } diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/nativesig/NativeSignatureJavaMethodBindingEmitter.java b/src/jogl/classes/com/jogamp/gluegen/opengl/nativesig/NativeSignatureJavaMethodBindingEmitter.java index 6d9d6f2bb..86080d84f 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/nativesig/NativeSignatureJavaMethodBindingEmitter.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/nativesig/NativeSignatureJavaMethodBindingEmitter.java @@ -53,31 +53,31 @@ import java.io.PrintWriter; /** Review: This Package/Class is not used and subject to be deleted. */ public class NativeSignatureJavaMethodBindingEmitter extends GLJavaMethodBindingEmitter { - public NativeSignatureJavaMethodBindingEmitter(GLJavaMethodBindingEmitter methodToWrap) { + public NativeSignatureJavaMethodBindingEmitter(final GLJavaMethodBindingEmitter methodToWrap) { super(methodToWrap); } - public NativeSignatureJavaMethodBindingEmitter(ProcAddressJavaMethodBindingEmitter methodToWrap, GLEmitter emitter, boolean bufferObjectVariant) { + public NativeSignatureJavaMethodBindingEmitter(final ProcAddressJavaMethodBindingEmitter methodToWrap, final GLEmitter emitter, final boolean bufferObjectVariant) { super(methodToWrap, emitter, bufferObjectVariant); } - public NativeSignatureJavaMethodBindingEmitter(JavaMethodBindingEmitter methodToWrap, NativeSignatureEmitter emitter) { + public NativeSignatureJavaMethodBindingEmitter(final JavaMethodBindingEmitter methodToWrap, final NativeSignatureEmitter emitter) { super(methodToWrap, false, null, false, false, emitter); } @Override - protected void emitSignature(PrintWriter writer) { + protected void emitSignature(final PrintWriter writer) { writer.print(getBaseIndentString()); emitNativeSignatureAnnotation(writer); super.emitSignature(writer); } - protected void emitNativeSignatureAnnotation(PrintWriter writer) { + protected void emitNativeSignatureAnnotation(final PrintWriter writer) { if (hasModifier(JavaMethodBindingEmitter.NATIVE)) { // Emit everything as a leaf for now // FIXME: make this configurable writer.print("@NativeSignature(\"l"); - MethodBinding binding = getBinding(); + final MethodBinding binding = getBinding(); if (callThroughProcAddress) { writer.print("p"); } @@ -94,7 +94,7 @@ public class NativeSignatureJavaMethodBindingEmitter extends GLJavaMethodBinding } } - protected void emitNativeSignatureElement(PrintWriter writer, JavaType type, Type cType, int index) { + protected void emitNativeSignatureElement(final PrintWriter writer, final JavaType type, final Type cType, final int index) { if (type.isVoid()) { if (index > 0) { throw new InternalError("Error parsing arguments -- void should not be seen aside from argument 0"); @@ -107,7 +107,7 @@ public class NativeSignatureJavaMethodBindingEmitter extends GLJavaMethodBinding } else if (type.isPrimitiveArray()) { writer.print("MO"); } else if (type.isPrimitive()) { - Class<?> clazz = type.getJavaClass(); + final Class<?> clazz = type.getJavaClass(); if (clazz == Byte.TYPE) { writer.print("B"); } else if (clazz == Character.TYPE) { writer.print("C"); } else if (clazz == Double.TYPE) { writer.print("D"); } @@ -132,9 +132,9 @@ public class NativeSignatureJavaMethodBindingEmitter extends GLJavaMethodBinding } @Override - protected String getReturnTypeString(boolean skipArray) { + protected String getReturnTypeString(final boolean skipArray) { if (isForImplementingMethodCall()) { - JavaType returnType = getBinding().getJavaReturnType(); + final JavaType returnType = getBinding().getJavaReturnType(); if (returnType.isString() || returnType.isNIOByteBuffer()) { // Treat these as addresses return "long"; @@ -144,10 +144,10 @@ public class NativeSignatureJavaMethodBindingEmitter extends GLJavaMethodBinding } @Override - protected void emitPreCallSetup(MethodBinding binding, PrintWriter writer) { + protected void emitPreCallSetup(final MethodBinding binding, final PrintWriter writer) { super.emitPreCallSetup(binding, writer); for (int i = 0; i < binding.getNumArguments(); i++) { - JavaType type = binding.getJavaArgumentType(i); + final JavaType type = binding.getJavaArgumentType(i); if (type.isNIOBuffer() && !useNIODirectOnly ) { // Emit declarations for variables holding primitive arrays as type Object // We don't know 100% sure we're going to use these at this point in the code, though @@ -160,12 +160,12 @@ public class NativeSignatureJavaMethodBindingEmitter extends GLJavaMethodBinding } } - protected String getNIOBufferArrayName(int argNumber) { + protected String getNIOBufferArrayName(final int argNumber) { return "__buffer_array_" + argNumber; } @Override - protected int emitArguments(PrintWriter writer) + protected int emitArguments(final PrintWriter writer) { boolean needComma = false; int numEmitted = 0; @@ -191,7 +191,7 @@ public class NativeSignatureJavaMethodBindingEmitter extends GLJavaMethodBinding } for (int i = 0; i < binding.getNumArguments(); i++) { - JavaType type = binding.getJavaArgumentType(i); + final JavaType type = binding.getJavaArgumentType(i); if (type.isVoid()) { // Make sure this is the only param to the method; if it isn't, // there's something wrong with our parsing of the headers. @@ -246,9 +246,9 @@ public class NativeSignatureJavaMethodBindingEmitter extends GLJavaMethodBinding } @Override - protected void emitReturnVariableSetupAndCall(MethodBinding binding, PrintWriter writer) { + protected void emitReturnVariableSetupAndCall(final MethodBinding binding, final PrintWriter writer) { writer.print(" "); - JavaType returnType = binding.getJavaReturnType(); + final JavaType returnType = binding.getJavaReturnType(); boolean needsResultAssignment = false; if (!returnType.isVoid()) { @@ -344,7 +344,7 @@ public class NativeSignatureJavaMethodBindingEmitter extends GLJavaMethodBinding } } - protected int emitCallArguments(MethodBinding binding, PrintWriter writer, boolean direct) { + protected int emitCallArguments(final MethodBinding binding, final PrintWriter writer, final boolean direct) { // Note that we override this completely because we both need to // move the potential location of the outgoing proc address as // well as change the way we pass out Buffers, arrays, Strings, etc. @@ -368,7 +368,7 @@ public class NativeSignatureJavaMethodBindingEmitter extends GLJavaMethodBinding ++numArgsEmitted; } for (int i = 0; i < binding.getNumArguments(); i++) { - JavaType type = binding.getJavaArgumentType(i); + final JavaType type = binding.getJavaArgumentType(i); if (type.isJNIEnv() || binding.isArgumentThisPointer(i)) { // Don't need to expose these at the Java level continue; @@ -460,9 +460,9 @@ public class NativeSignatureJavaMethodBindingEmitter extends GLJavaMethodBinding } @Override - protected void emitCallResultReturn(MethodBinding binding, PrintWriter writer) { + protected void emitCallResultReturn(final MethodBinding binding, final PrintWriter writer) { for (int i = 0; i < binding.getNumArguments(); i++) { - JavaType type = binding.getJavaArgumentType(i); + final JavaType type = binding.getJavaArgumentType(i); if (type.isString()) { writer.println(";"); writer.println(" BuffersInternal.freeCString(" + binding.getArgumentName(i) + "_c_str);"); @@ -475,14 +475,14 @@ public class NativeSignatureJavaMethodBindingEmitter extends GLJavaMethodBinding @Override public String getName() { - String res = super.getName(); + final String res = super.getName(); if (forImplementingMethodCall && bufferObjectVariant) { return res + "BufObj"; } return res; } - protected String getImplMethodName(boolean direct) { + protected String getImplMethodName(final boolean direct) { String name = null; if (direct) { name = binding.getName() + "$0"; diff --git a/src/jogl/classes/com/jogamp/gluegen/runtime/opengl/GLNameResolver.java b/src/jogl/classes/com/jogamp/gluegen/runtime/opengl/GLNameResolver.java index 9b57a2f2d..34ab3df9e 100644 --- a/src/jogl/classes/com/jogamp/gluegen/runtime/opengl/GLNameResolver.java +++ b/src/jogl/classes/com/jogamp/gluegen/runtime/opengl/GLNameResolver.java @@ -72,19 +72,19 @@ public class GLNameResolver { }; - public static final boolean isGLFunction(String str) { + public static final boolean isGLFunction(final String str) { return str.startsWith("gl") || /* str.startsWith("glu") || str.startsWith("glX") || */ str.startsWith("egl") || str.startsWith("wgl") || str.startsWith("agl") || str.startsWith("cgl") ; } - public static final boolean isGLEnumeration(String str) { + public static final boolean isGLEnumeration(final String str) { return str.startsWith("GL_") || str.startsWith("GLU_") || str.startsWith("GLX_") || str.startsWith("EGL_") || str.startsWith("WGL_") || str.startsWith("AGL_") || str.startsWith("CGL_") ; } - public static final int getExtensionIdx(String[] extensions, String str, boolean isGLFunc) { + public static final int getExtensionIdx(final String[] extensions, final String str, final boolean isGLFunc) { if(isGLFunc) { for(int i = extensions.length - 1 ; i>=0 ; i--) { if( str.endsWith(extensions[i]) ) { @@ -101,11 +101,11 @@ public class GLNameResolver { return -1; } - public static final boolean isExtension(String[] extensions, String str, boolean isGLFunc) { + public static final boolean isExtension(final String[] extensions, final String str, final boolean isGLFunc) { return getExtensionIdx(extensions, str, isGLFunc)>=0; } - public static final String getExtensionSuffix(String str, boolean isGLFunc) { + public static final String getExtensionSuffix(final String str, final boolean isGLFunc) { int idx = getExtensionIdx(extensionsARB, str, isGLFunc); if(idx>=0) { return extensionsARB[idx]; @@ -117,7 +117,7 @@ public class GLNameResolver { return null; } - public static final String normalize(String[] extensions, String str, boolean isGLFunc) { + public static final String normalize(final String[] extensions, String str, final boolean isGLFunc) { boolean touched = false; for(int i = extensions.length - 1 ; !touched && i>=0 ; i--) { if(isGLFunc) { @@ -136,19 +136,19 @@ public class GLNameResolver { } return str; } - public static final String normalizeARB(String str, boolean isGLFunc) { + public static final String normalizeARB(final String str, final boolean isGLFunc) { return normalize(extensionsARB, str, isGLFunc); } - public static final boolean isExtensionARB(String str, boolean isGLFunc) { + public static final boolean isExtensionARB(final String str, final boolean isGLFunc) { return isExtension(extensionsARB, str, isGLFunc); } - public static final String normalizeVEN(String str, boolean isGLFunc) { + public static final String normalizeVEN(final String str, final boolean isGLFunc) { return normalize(extensionsVEN, str, isGLFunc); } - public static final boolean isExtensionVEN(String str, boolean isGLFunc) { + public static final boolean isExtensionVEN(final String str, final boolean isGLFunc) { return isExtension(extensionsVEN, str, isGLFunc); } - public static final String normalize(String str, boolean isGLFunc) { + public static final String normalize(final String str, final boolean isGLFunc) { if (isExtensionARB(str, isGLFunc)) { return normalizeARB(str, isGLFunc); } @@ -157,12 +157,12 @@ public class GLNameResolver { } return str; } - public static final boolean isExtension(String str, boolean isGLFunc) { + public static final boolean isExtension(final String str, final boolean isGLFunc) { return isExtension(extensionsARB, str, isGLFunc) || isExtension(extensionsVEN, str, isGLFunc); } - public static final int getFuncNamePermutationNumber(String name) { + public static final int getFuncNamePermutationNumber(final String name) { if(isExtensionARB(name, true) || isExtensionVEN(name, true)) { // no name permutation, if it's already a known extension return 1; @@ -170,7 +170,7 @@ public class GLNameResolver { return 1 + extensionsARB.length + extensionsVEN.length; } - public static final String getFuncNamePermutation(String name, int i) { + public static final String getFuncNamePermutation(final String name, int i) { // identity if(i==0) { return name; diff --git a/src/jogl/classes/com/jogamp/gluegen/runtime/opengl/GLProcAddressResolver.java b/src/jogl/classes/com/jogamp/gluegen/runtime/opengl/GLProcAddressResolver.java index 3fb315c99..23d4fc3cf 100644 --- a/src/jogl/classes/com/jogamp/gluegen/runtime/opengl/GLProcAddressResolver.java +++ b/src/jogl/classes/com/jogamp/gluegen/runtime/opengl/GLProcAddressResolver.java @@ -43,16 +43,16 @@ public class GLProcAddressResolver implements FunctionAddressResolver { public static final boolean DEBUG = false; @Override - public long resolve(String name, DynamicLookupHelper lookup) { + public long resolve(final String name, final DynamicLookupHelper lookup) { long newProcAddress = 0; - int permutations = GLNameResolver.getFuncNamePermutationNumber(name); + final int permutations = GLNameResolver.getFuncNamePermutationNumber(name); for (int i = 0; 0 == newProcAddress && i < permutations; i++) { - String funcName = GLNameResolver.getFuncNamePermutation(name, i); + final String funcName = GLNameResolver.getFuncNamePermutation(name, i); try { newProcAddress = lookup.dynamicLookupFunction(funcName); - } catch (Exception e) { + } catch (final Exception e) { if (DEBUG) { e.printStackTrace(); } |