diff options
author | Sven Gothel <[email protected]> | 2015-03-11 08:48:36 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2015-03-11 08:48:36 +0100 |
commit | 405512e1c8a2e24834b0d057f0b020b4a0f4c25b (patch) | |
tree | ea933c02fa486c034f8d490ddc59a2afd95a4d3e /src/java/com/jogamp/gluegen/JavaEmitter.java | |
parent | f664f7e950ff60d73e488801cf7f37878588203d (diff) |
Bug 1144 - Add 'DelegateImplementation', manually impl. may delegate to renamed original
'DelegateImplementation' is a variation of 'ManuallyImplement'.
'ManuallyImplement' emits the interface method, but suppresses
the Java and native-code implementation.
The latter shall be implemented manually by the user.
'DelegateImplementation' emits the interface method,
and the _private_ renamed Java and native-code implementation.
Both can be called from the manual user implementation,
hence delegation.
Configuration:
DelegateImplementation <ORIG-SYMBOL> <RENAMED-IMPL-SYMBOL>
I.e. delegation model shall apply to <ORIG-SYMBOL>
and the Java and native-code implementation renamed to <RENAMED-IMPL-SYMBOL>.
The user manual implementation of <ORIG-SYMBOL>
may delegate to <RENAMED-IMPL-SYMBOL>.
Diffstat (limited to 'src/java/com/jogamp/gluegen/JavaEmitter.java')
-rw-r--r-- | src/java/com/jogamp/gluegen/JavaEmitter.java | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/java/com/jogamp/gluegen/JavaEmitter.java b/src/java/com/jogamp/gluegen/JavaEmitter.java index fa4ecab..2601929 100644 --- a/src/java/com/jogamp/gluegen/JavaEmitter.java +++ b/src/java/com/jogamp/gluegen/JavaEmitter.java @@ -568,12 +568,6 @@ public class JavaEmitter implements GlueEmitter { return; } - final MethodAccess accessControl = cfg.accessControl(binding.getName()); - // We should not emit anything except public APIs into interfaces - if (signatureOnly && (accessControl != PUBLIC)) { - return; - } - // It's possible we may not need a body even if signatureOnly is // set to false; for example, if the routine doesn't take any // arrays or buffers as arguments @@ -596,6 +590,20 @@ public class JavaEmitter implements GlueEmitter { final boolean emitBody = !signatureOnly && needsBody; final boolean isNativeMethod = !isUnimplemented && !needsBody && !signatureOnly; + final MethodAccess accessControl; + + if ( !signatureOnly && null != binding.getDelegationImplName() ) { + // private access for delegation implementation methods + accessControl = PRIVATE; + } else { + accessControl = cfg.accessControl(binding.getName()); + } + + // We should not emit anything except public APIs into interfaces + if ( signatureOnly && PUBLIC != accessControl ) { + return; + } + final PrintWriter writer = ((signatureOnly || cfg.allStatic()) ? javaWriter() : javaImplWriter()); final JavaMethodBindingEmitter emitter = @@ -2801,8 +2809,9 @@ public class JavaEmitter implements GlueEmitter { javaArgumentTypes.add(mappedType); //System.out.println("During binding of [" + sym + "], added mapping from C type: " + cArgType + " to Java type: " + mappedType); } + final String delegationImplName = null == containingType && null == containingCType ? + cfg.getDelegatedImplementation(sym) : null; final MethodBinding mb = new MethodBinding(sym, delegationImplName, - final MethodBinding mb = new MethodBinding(sym, javaReturnType, javaArgumentTypes, containingType, containingCType); mangleBinding(mb); |