From 10060b091b76bee35246c5165d49ab546ebc4e37 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 9 Mar 2015 03:18:42 +0100 Subject: Bug 1134 - ProcAddressCMethodBindingEmitter: Use available 'ProcAddrTypedef' for type validation w/ local generated variant (robustness) ProcAddressCMethodBindingEmitter code regarding having the public 'ProcAddrTypedef' (from input header) was simply broken, since it always used the local generated 'ProcAddrTypedef', if 'ProcAddrTypedef' was forced. Hence the public 'ProcAddrTypedef' was ignored in most cases. ProcAddressCMethodBindingEmitter's semantic changed from: needsLocalTypedef -> hasProcAddrTypedef New Code generation: - always generated the local 'ProcAddrTypedef' - if hasProcAddrTypedef, use public 'ProcAddrTypedef' for return type variable - cast local 'ProcAddrTypedef' to public 'ProcAddrTypedef', which renders the native compiler to validate the local and public types. --- .../gluegen/procaddress/ProcAddressEmitter.java | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'src/java/com/jogamp/gluegen/procaddress/ProcAddressEmitter.java') diff --git a/src/java/com/jogamp/gluegen/procaddress/ProcAddressEmitter.java b/src/java/com/jogamp/gluegen/procaddress/ProcAddressEmitter.java index 180c48f..51e47e9 100644 --- a/src/java/com/jogamp/gluegen/procaddress/ProcAddressEmitter.java +++ b/src/java/com/jogamp/gluegen/procaddress/ProcAddressEmitter.java @@ -249,16 +249,13 @@ public class ProcAddressEmitter extends JavaEmitter { final FunctionSymbol cSymbol = baseCEmitter.getBinding().getCSymbol(); // See whether we need a proc address entry for this one - final boolean needsLocalTypedef = getProcAddressConfig().forceProcAddressGen(cSymbol) || - !hasFunctionPointerTypedef(cSymbol); - final boolean callThroughProcAddress = needsLocalTypedef || callThroughProcAddress(cSymbol); - LOG.log(Level.INFO, cSymbol.getASTLocusTag(), "genModProcAddrEmitter: needsTypedef {0}, callThrough {1}: {2}", - needsLocalTypedef, callThroughProcAddress, cSymbol.getAliasedString()); - - String forcedCallingConvention = null; - if (needsLocalTypedef) { - forcedCallingConvention = getProcAddressConfig().getLocalProcAddressCallingConvention(cSymbol); - } + final boolean hasProcAddrTypedef = hasFunctionPointerTypedef(cSymbol); + final boolean callThroughProcAddress = hasProcAddrTypedef || callThroughProcAddress(cSymbol); + final String localProcCallingConvention = getProcAddressConfig().getLocalProcAddressCallingConvention(cSymbol); + + LOG.log(Level.INFO, cSymbol.getASTLocusTag(), "genModProcAddrEmitter: callThrough {0}, hasTypedef {1}, localCallConv {2}: {3}", + callThroughProcAddress, hasProcAddrTypedef, localProcCallingConvention, cSymbol.getAliasedString()); + // Note that we don't care much about the naming of the C argument // variables so to keep things simple we ignore the buffer object // property for the binding @@ -267,7 +264,7 @@ public class ProcAddressEmitter extends JavaEmitter { // extra final argument, which is the address (the OpenGL procedure // address) of the function it needs to call final ProcAddressCMethodBindingEmitter res = new ProcAddressCMethodBindingEmitter( - baseCEmitter, callThroughProcAddress, needsLocalTypedef, forcedCallingConvention, this); + baseCEmitter, callThroughProcAddress, hasProcAddrTypedef, localProcCallingConvention, this); final MessageFormat exp = baseCEmitter.getReturnValueCapacityExpression(); if (exp != null) { -- cgit v1.2.3