diff options
author | Sven Gothel <[email protected]> | 2015-03-10 17:27:50 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2015-03-10 17:27:50 +0100 |
commit | c3b2a86bb9051d6f03c3f104eff2dbe6cefc1803 (patch) | |
tree | 110890d231f3655f7de43b3b8a44a0fa0792d5ef /src/java/com/jogamp/gluegen | |
parent | 454fac44efd1728d8f5c09ed4abd4041f6187e44 (diff) |
Bug 1144 - Add 'DelegateImplementation': Sort JavaMethodBindingEmitter argument list; forImplementingMethodCall -> isNativeMethod
Diffstat (limited to 'src/java/com/jogamp/gluegen')
4 files changed, 51 insertions, 48 deletions
diff --git a/src/java/com/jogamp/gluegen/JavaEmitter.java b/src/java/com/jogamp/gluegen/JavaEmitter.java index 933e35e..c8a2da8 100644 --- a/src/java/com/jogamp/gluegen/JavaEmitter.java +++ b/src/java/com/jogamp/gluegen/JavaEmitter.java @@ -592,21 +592,22 @@ public class JavaEmitter implements GlueEmitter { } } + final boolean emitBody = !signatureOnly && needsBody; final JavaMethodBindingEmitter emitter = new JavaMethodBindingEmitter(binding, writer, cfg.runtimeExceptionType(), cfg.unsupportedExceptionType(), - !signatureOnly && needsBody, + emitBody, // emitBody cfg.tagNativeBinding(), - false, // eraseBufferAndArrayTypes + false, // eraseBufferAndArrayTypes cfg.useNIOOnly(binding.getName()), cfg.useNIODirectOnly(binding.getName()), - false, - false, - false, - isUnimplemented, - signatureOnly, + false, // forDirectBufferImplementation + false, // forIndirectBufferAndArrayImplementation + isUnimplemented, // isUnimplemented + signatureOnly, // isInterface + false, // isNativeMethod cfg); switch (accessControl) { case PUBLIC: emitter.addModifier(JavaMethodBindingEmitter.PUBLIC); break; @@ -674,16 +675,16 @@ public class JavaEmitter implements GlueEmitter { writer, cfg.runtimeExceptionType(), cfg.unsupportedExceptionType(), - false, + false, // emitBody cfg.tagNativeBinding(), - true, // eraseBufferAndArrayTypes + true, // eraseBufferAndArrayTypes cfg.useNIOOnly(binding.getName()), cfg.useNIODirectOnly(binding.getName()), - true, - true, - false, - false, - false, + true, // forDirectBufferImplementation + false, // forIndirectBufferAndArrayImplementation + false, // isUnimplemented + false, // isInterface + true, // isNativeMethod cfg); emitter.addModifier(JavaMethodBindingEmitter.PRIVATE); if (cfg.allStatic()) { @@ -1142,6 +1143,7 @@ public class JavaEmitter implements GlueEmitter { } } javaWriter.println(); + // getDelegatedImplementation if( !cfg.manuallyImplement(JavaConfiguration.canonicalStructFieldSymbol(containingJTypeName, "size")) ) { javaWriter.println(" public static int size() {"); javaWriter.println(" return "+containingJTypeName+"_size[mdIdx];"); @@ -1421,16 +1423,16 @@ public class JavaEmitter implements GlueEmitter { javaWriter, cfg.runtimeExceptionType(), cfg.unsupportedExceptionType(), - true, + true, // emitBody cfg.tagNativeBinding(), false, // eraseBufferAndArrayTypes useNIOOnly, useNIODirectOnly, - false, - false, // FIXME: should unify this with the general emission code + false, // forDirectBufferImplementation false, // forIndirectBufferAndArrayImplementation - false, // FIXME: should unify this with the general emission code - false, + false, // isUnimplemented + false, // isInterface + false, // isNativeMethod cfg); emitter.addModifier(JavaMethodBindingEmitter.PUBLIC); emitter.emit(); @@ -1441,16 +1443,16 @@ public class JavaEmitter implements GlueEmitter { javaWriter, cfg.runtimeExceptionType(), cfg.unsupportedExceptionType(), - false, + false, // emitBody cfg.tagNativeBinding(), - true, // eraseBufferAndArrayTypes + true, // eraseBufferAndArrayTypes useNIOOnly, useNIODirectOnly, - true, - true, // FIXME: should unify this with the general emission code + true, // forDirectBufferImplementation false, // forIndirectBufferAndArrayImplementation - false, // FIXME: should unify this with the general emission code - false, + false, // isUnimplemented + false, // isInterface + true, // isNativeMethod cfg); emitter.addModifier(JavaMethodBindingEmitter.PRIVATE); emitter.addModifier(JavaMethodBindingEmitter.NATIVE); @@ -1503,16 +1505,16 @@ public class JavaEmitter implements GlueEmitter { javaWriter, cfg.runtimeExceptionType(), cfg.unsupportedExceptionType(), - false, - cfg.tagNativeBinding(), - true, // eraseBufferAndArrayTypes + false, // emitBody + cfg.tagNativeBinding(), // tagNativeBinding + true, // eraseBufferAndArrayTypes useNIOOnly, useNIODirectOnly, - true, - true, // FIXME: should unify this with the general emission code - false, // forIndirectBufferAndArrayImplementation - false, // FIXME: should unify this with the general emission code - false, + false, // forDirectBufferImplementation + false, // forIndirectBufferAndArrayImplementation + false, // isUnimplemented + true, // isInterface + true, // isNativeMethod cfg); if( null != docArrayLenExpr ) { emitter.setReturnedArrayLengthExpression(docArrayLenExpr, true); diff --git a/src/java/com/jogamp/gluegen/JavaMethodBindingEmitter.java b/src/java/com/jogamp/gluegen/JavaMethodBindingEmitter.java index 3768222..c570016 100644 --- a/src/java/com/jogamp/gluegen/JavaMethodBindingEmitter.java +++ b/src/java/com/jogamp/gluegen/JavaMethodBindingEmitter.java @@ -76,7 +76,7 @@ public class JavaMethodBindingEmitter extends FunctionEmitter { protected boolean eraseBufferAndArrayTypes; protected boolean useNIOOnly; protected boolean useNIODirectOnly; - protected boolean forImplementingMethodCall; + protected boolean isNativeMethod; protected boolean forDirectBufferImplementation; protected boolean forIndirectBufferAndArrayImplementation; protected boolean isUnimplemented; @@ -109,11 +109,11 @@ public class JavaMethodBindingEmitter extends FunctionEmitter { final boolean eraseBufferAndArrayTypes, final boolean useNIOOnly, final boolean useNIODirectOnly, - final boolean forImplementingMethodCall, final boolean forDirectBufferImplementation, final boolean forIndirectBufferAndArrayImplementation, final boolean isUnimplemented, final boolean isInterface, + final boolean isNativeMethod, final JavaConfiguration configuration) { super(output, isInterface, configuration); this.binding = binding; @@ -124,15 +124,16 @@ public class JavaMethodBindingEmitter extends FunctionEmitter { this.eraseBufferAndArrayTypes = eraseBufferAndArrayTypes; this.useNIOOnly = useNIOOnly; this.useNIODirectOnly = useNIODirectOnly; - this.forImplementingMethodCall = forImplementingMethodCall; this.forDirectBufferImplementation = forDirectBufferImplementation; this.forIndirectBufferAndArrayImplementation = forIndirectBufferAndArrayImplementation; this.isUnimplemented = isUnimplemented; - if (forImplementingMethodCall) { + this.isNativeMethod = isNativeMethod; + if (isNativeMethod) { setCommentEmitter(defaultJavaCommentEmitter); } else { setCommentEmitter(defaultInterfaceCommentEmitter); } + // !forImplementingMethodCall && !isInterface } public JavaMethodBindingEmitter(final JavaMethodBindingEmitter arg) { @@ -145,7 +146,7 @@ public class JavaMethodBindingEmitter extends FunctionEmitter { eraseBufferAndArrayTypes = arg.eraseBufferAndArrayTypes; useNIOOnly = arg.useNIOOnly; useNIODirectOnly = arg.useNIODirectOnly; - forImplementingMethodCall = arg.forImplementingMethodCall; + isNativeMethod = arg.isNativeMethod; forDirectBufferImplementation = arg.forDirectBufferImplementation; forIndirectBufferAndArrayImplementation = arg.forIndirectBufferAndArrayImplementation; isUnimplemented = arg.isUnimplemented; @@ -157,7 +158,7 @@ public class JavaMethodBindingEmitter extends FunctionEmitter { public final MethodBinding getBinding() { return binding; } - public boolean isForImplementingMethodCall() { return forImplementingMethodCall; } + public boolean isForNativeMethod() { return isNativeMethod; } public boolean isForDirectBufferImplementation() { return forDirectBufferImplementation; } public boolean isForIndirectBufferAndArrayImplementation() { return forIndirectBufferAndArrayImplementation; } @@ -237,7 +238,7 @@ public class JavaMethodBindingEmitter extends FunctionEmitter { /** Accessor for subclasses. */ public void setForImplementingMethodCall(final boolean impl) { - this.forImplementingMethodCall = impl; + this.isNativeMethod = impl; } /** Accessor for subclasses. */ @@ -325,8 +326,8 @@ public class JavaMethodBindingEmitter extends FunctionEmitter { @Override protected void emitName(final PrintWriter writer) { - if (forImplementingMethodCall) { - writer.print(getImplMethodName()); + if (isNativeMethod) { + writer.print(getNativeMethodName()); } else { writer.print(getName()); } @@ -337,7 +338,7 @@ public class JavaMethodBindingEmitter extends FunctionEmitter { boolean needComma = false; int numEmitted = 0; - if (forImplementingMethodCall && binding.hasContainingType()) { + if (isNativeMethod && binding.hasContainingType()) { // Always emit outgoing "this" argument writer.print("ByteBuffer "); writer.print(javaThisArgumentName()); @@ -398,7 +399,7 @@ public class JavaMethodBindingEmitter extends FunctionEmitter { } - protected String getImplMethodName() { + protected String getNativeMethodName() { return binding.getName() + ( useNIODirectOnly ? "0" : "1" ); } @@ -547,7 +548,7 @@ public class JavaMethodBindingEmitter extends FunctionEmitter { } protected void emitCall(final MethodBinding binding, final PrintWriter writer) { - writer.print(getImplMethodName()); + writer.print(getNativeMethodName()); writer.print("("); emitCallArguments(binding, writer); writer.print(");"); diff --git a/src/java/com/jogamp/gluegen/procaddress/ProcAddressEmitter.java b/src/java/com/jogamp/gluegen/procaddress/ProcAddressEmitter.java index 51e47e9..6418a53 100644 --- a/src/java/com/jogamp/gluegen/procaddress/ProcAddressEmitter.java +++ b/src/java/com/jogamp/gluegen/procaddress/ProcAddressEmitter.java @@ -221,7 +221,7 @@ public class ProcAddressEmitter extends JavaEmitter { final ProcAddressJavaMethodBindingEmitter emitter = new ProcAddressJavaMethodBindingEmitter(baseJavaEmitter, callThroughProcAddress, getProcAddressConfig().getProcAddressTableExpr(), - baseJavaEmitter.isForImplementingMethodCall(), + baseJavaEmitter.isForNativeMethod(), this); if( needsJavaWrapper ) { emitter.setEmitBody(true); diff --git a/src/java/com/jogamp/gluegen/procaddress/ProcAddressJavaMethodBindingEmitter.java b/src/java/com/jogamp/gluegen/procaddress/ProcAddressJavaMethodBindingEmitter.java index a70c18d..f3cc8e9 100644 --- a/src/java/com/jogamp/gluegen/procaddress/ProcAddressJavaMethodBindingEmitter.java +++ b/src/java/com/jogamp/gluegen/procaddress/ProcAddressJavaMethodBindingEmitter.java @@ -106,8 +106,8 @@ public class ProcAddressJavaMethodBindingEmitter extends JavaMethodBindingEmitte } @Override - protected String getImplMethodName() { - final String name = super.getImplMethodName(); + protected String getNativeMethodName() { + final String name = super.getNativeMethodName(); if (callThroughProcAddress) { return ProcAddressEmitter.WRAP_PREFIX + name; } |