From af9ff963c4120731ec65ed1a9628e82d1f5b66e1 Mon Sep 17 00:00:00 2001 From: Michael Bien Date: Wed, 31 Mar 2010 19:05:36 +0200 Subject: refactoring and code cleanup in gluegen.opengl and gluegen.procaddress package. --- .../gluegen/opengl/GLJavaMethodBindingEmitter.java | 146 ++++++++++----------- 1 file changed, 68 insertions(+), 78 deletions(-) (limited to 'src/java/com/sun/gluegen/opengl/GLJavaMethodBindingEmitter.java') diff --git a/src/java/com/sun/gluegen/opengl/GLJavaMethodBindingEmitter.java b/src/java/com/sun/gluegen/opengl/GLJavaMethodBindingEmitter.java index 33f94fb19..51182c153 100755 --- a/src/java/com/sun/gluegen/opengl/GLJavaMethodBindingEmitter.java +++ b/src/java/com/sun/gluegen/opengl/GLJavaMethodBindingEmitter.java @@ -36,7 +36,6 @@ * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ - package com.sun.gluegen.opengl; import java.io.*; @@ -45,89 +44,80 @@ import com.sun.gluegen.cgram.types.*; import com.sun.gluegen.procaddress.*; /** A specialization of the proc address emitter which knows how to - change argument names to take into account Vertex Buffer Object / - Pixel Buffer Object variants. */ - +change argument names to take into account Vertex Buffer Object / +Pixel Buffer Object variants. */ public class GLJavaMethodBindingEmitter extends ProcAddressJavaMethodBindingEmitter { - protected boolean bufferObjectVariant; - protected GLEmitter glEmitter; - protected CommentEmitter glCommentEmitter = new GLCommentEmitter(); - - public GLJavaMethodBindingEmitter(JavaMethodBindingEmitter methodToWrap, - boolean callThroughProcAddress, - String getProcAddressTableExpr, - boolean changeNameAndArguments, - boolean bufferObjectVariant, - GLEmitter emitter) { - super(methodToWrap, - callThroughProcAddress, - getProcAddressTableExpr, - changeNameAndArguments, - emitter); - this.bufferObjectVariant = bufferObjectVariant; - this.glEmitter=emitter; - setCommentEmitter(glCommentEmitter); - } - - public GLJavaMethodBindingEmitter(ProcAddressJavaMethodBindingEmitter methodToWrap, - GLEmitter emitter, - boolean bufferObjectVariant) { - super(methodToWrap); - this.bufferObjectVariant = bufferObjectVariant; - this.glEmitter=emitter; - setCommentEmitter(glCommentEmitter); - } - - public GLJavaMethodBindingEmitter(GLJavaMethodBindingEmitter methodToWrap) { - this(methodToWrap, methodToWrap.glEmitter, methodToWrap.bufferObjectVariant); - } - - @Override - protected String getArgumentName(int i) { - String name = super.getArgumentName(i); - - if (!bufferObjectVariant) { - return name; + + protected boolean bufferObjectVariant; + protected GLEmitter glEmitter; + protected CommentEmitter glCommentEmitter = new GLCommentEmitter(); + + public GLJavaMethodBindingEmitter(JavaMethodBindingEmitter methodToWrap, boolean callThroughProcAddress, + String getProcAddressTableExpr, boolean changeNameAndArguments, boolean bufferObjectVariant, GLEmitter emitter) { + + super(methodToWrap, callThroughProcAddress, getProcAddressTableExpr, changeNameAndArguments, emitter); + this.bufferObjectVariant = bufferObjectVariant; + this.glEmitter = emitter; + setCommentEmitter(glCommentEmitter); } - // Emitters for VBO/PBO-related routines change the outgoing - // argument name for the buffer - if (binding.getJavaArgumentType(i).isLong()) { - Type cType = binding.getCArgumentType(i); - if (cType.isPointer() && - (cType.asPointer().getTargetType().isVoid() || - cType.asPointer().getTargetType().isPrimitive())) { - return name + "_buffer_offset"; - } + public GLJavaMethodBindingEmitter(ProcAddressJavaMethodBindingEmitter methodToWrap, GLEmitter emitter, boolean bufferObjectVariant) { + super(methodToWrap); + this.bufferObjectVariant = bufferObjectVariant; + this.glEmitter = emitter; + setCommentEmitter(glCommentEmitter); } - return name; - } + public GLJavaMethodBindingEmitter(GLJavaMethodBindingEmitter methodToWrap) { + this(methodToWrap, methodToWrap.glEmitter, methodToWrap.bufferObjectVariant); + } - protected class GLCommentEmitter extends JavaMethodBindingEmitter.DefaultCommentEmitter { - @Override - protected void emitBindingCSignature(MethodBinding binding, PrintWriter writer) { - super.emitBindingCSignature(binding, writer); - - String symbolRenamed = binding.getName(); - StringBuffer newComment = new StringBuffer(); - newComment.append("
Part of "); - if(0==glEmitter.addExtensionsOfSymbols2Buffer(newComment, ", ", symbolRenamed, binding.getAliasedNames())) { - if(glEmitter.getGLConfig().getAllowNonGLExtensions()) { - newComment.append("CORE FUNC"); - } else { - StringBuffer sb = new StringBuffer(); - JavaEmitter.addStrings2Buffer(sb, ", ", symbolRenamed, binding.getAliasedNames()); - RuntimeException ex = new RuntimeException("Couldn't find extension to: "+binding+" ; "+sb.toString()); - ex.printStackTrace(); - glEmitter.getGLConfig().getGLInfo().dump(); - // glEmitter.getGLConfig().dumpRenames(); - throw ex; - } - } - newComment.append(""); - writer.print(newComment.toString()); + protected String getArgumentName(int i) { + String name = super.getArgumentName(i); + + if (!bufferObjectVariant) { + return name; + } + + // 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(); + if (cType.isPointer() && (targetType.isVoid() || targetType.isPrimitive())) { + return name + "_buffer_offset"; + } + } + + return name; + } + + protected class GLCommentEmitter extends JavaMethodBindingEmitter.DefaultCommentEmitter { + + @Override + protected void emitBindingCSignature(MethodBinding binding, PrintWriter writer) { + + super.emitBindingCSignature(binding, writer); + + String symbolRenamed = binding.getName(); + StringBuilder newComment = new StringBuilder(); + + newComment.append("
Part of "); + if (0 == glEmitter.addExtensionsOfSymbols2Buffer(newComment, ", ", symbolRenamed, binding.getAliasedNames())) { + if (glEmitter.getGLConfig().getAllowNonGLExtensions()) { + newComment.append("CORE FUNC"); + } else { + StringBuilder sb = new StringBuilder(); + JavaEmitter.addStrings2Buffer(sb, ", ", symbolRenamed, binding.getAliasedNames()); + RuntimeException ex = new RuntimeException("Couldn't find extension to: " + binding + " ; " + sb.toString()); + glEmitter.getGLConfig().getGLInfo().dump(); + // glEmitter.getGLConfig().dumpRenames(); + throw ex; + } + } + newComment.append(""); + writer.print(newComment.toString()); + } } - } } -- cgit v1.2.3