aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/gluegen/procaddress/ProcAddressEmitter.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/com/jogamp/gluegen/procaddress/ProcAddressEmitter.java')
-rw-r--r--src/java/com/jogamp/gluegen/procaddress/ProcAddressEmitter.java111
1 files changed, 53 insertions, 58 deletions
diff --git a/src/java/com/jogamp/gluegen/procaddress/ProcAddressEmitter.java b/src/java/com/jogamp/gluegen/procaddress/ProcAddressEmitter.java
index 4145cc4..ec29b08 100644
--- a/src/java/com/jogamp/gluegen/procaddress/ProcAddressEmitter.java
+++ b/src/java/com/jogamp/gluegen/procaddress/ProcAddressEmitter.java
@@ -47,6 +47,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.logging.Level;
import com.jogamp.gluegen.CMethodBindingEmitter;
import com.jogamp.gluegen.CodeGenUtils;
@@ -54,7 +55,6 @@ import com.jogamp.gluegen.FunctionEmitter;
import com.jogamp.gluegen.JavaConfiguration;
import com.jogamp.gluegen.JavaEmitter;
import com.jogamp.gluegen.JavaMethodBindingEmitter;
-import com.jogamp.gluegen.MethodBinding;
import com.jogamp.gluegen.cgram.types.FunctionSymbol;
import com.jogamp.gluegen.cgram.types.Type;
import com.jogamp.gluegen.cgram.types.TypeDictionary;
@@ -114,40 +114,45 @@ public class ProcAddressEmitter extends JavaEmitter {
}
@Override
- protected List<? extends FunctionEmitter> generateMethodBindingEmitters(final Set<MethodBinding> methodBindingSet, final FunctionSymbol sym) throws Exception {
- return generateMethodBindingEmittersImpl(methodBindingSet, sym);
+ protected List<? extends FunctionEmitter> generateMethodBindingEmitters(final FunctionSymbol sym) throws Exception {
+ return generateMethodBindingEmittersImpl(sym);
}
protected boolean needsModifiedEmitters(final FunctionSymbol sym) {
- if (!needsProcAddressWrapper(sym) || getConfig().isUnimplemented(getAliasedSymName(sym))) {
+ if ( !callThroughProcAddress(sym) || getConfig().isUnimplemented(sym) ) {
return false;
+ } else {
+ return true;
}
-
- return true;
}
- private List<? extends FunctionEmitter> generateMethodBindingEmittersImpl(final Set<MethodBinding> methodBindingSet, final FunctionSymbol sym) throws Exception {
- final List<? extends FunctionEmitter> defaultEmitters = super.generateMethodBindingEmitters(methodBindingSet, sym);
+ private List<? extends FunctionEmitter> generateMethodBindingEmittersImpl(final FunctionSymbol sym) throws Exception {
+ final List<? extends FunctionEmitter> defaultEmitters = super.generateMethodBindingEmitters(sym);
// if the superclass didn't generate any bindings for the symbol, let's
// honor that (for example, the superclass might have caught an Ignore
// direction that matched the symbol's name).
if (defaultEmitters.isEmpty()) {
+ LOG.log(Level.INFO, sym.getASTLocusTag(), "genModProcAddrEmitter: SKIP, empty binding set: {0}", sym);
return defaultEmitters;
}
- // Don't do anything special if this symbol doesn't require
- // modifications
- if (!needsModifiedEmitters(sym)) {
+ final boolean callThroughProcAddress = callThroughProcAddress(sym);
+ final boolean isUnimplemented = getConfig().isUnimplemented(sym);
+
+ // Don't do anything special if this symbol doesn't require modifications
+ if( !callThroughProcAddress || isUnimplemented ) {
+ LOG.log(Level.INFO, sym.getASTLocusTag(), "genModProcAddrEmitter: SKIP, not needed: callThrough {0}, isUnimplemented {1}: {2}",
+ callThroughProcAddress, isUnimplemented, sym);
return defaultEmitters;
}
final ArrayList<FunctionEmitter> modifiedEmitters = new ArrayList<FunctionEmitter>(defaultEmitters.size());
- if (needsProcAddressWrapper(sym)) {
+ if ( callThroughProcAddress ) {
if (getProcAddressConfig().emitProcAddressTable()) {
// emit an entry in the GL proc address table for this method.
- emitProcAddressTableEntryForString(getAliasedSymName(sym));
+ emitProcAddressTableEntryForString(sym.getName());
}
}
for (final FunctionEmitter emitter : defaultEmitters) {
@@ -172,7 +177,7 @@ public class ProcAddressEmitter extends JavaEmitter {
* whether or not the typedef is actually defined.
*/
protected String getFunctionPointerTypedefName(final FunctionSymbol sym) {
- return getProcAddressConfig().convertToFunctionPointerName(sym.getName());
+ return getProcAddressConfig().convertToFunctionPointerName(sym.getOrigName());
}
//----------------------------------------------------------------------
@@ -194,20 +199,14 @@ public class ProcAddressEmitter extends JavaEmitter {
protected void generateModifiedEmitters(final JavaMethodBindingEmitter baseJavaEmitter, final List<FunctionEmitter> emitters) {
// See whether we need a proc address entry for this one
- final boolean callThroughProcAddress = needsProcAddressWrapper(baseJavaEmitter.getBinding().getCSymbol());
+ final boolean callThroughProcAddress = callThroughProcAddress(baseJavaEmitter.getBinding().getCSymbol());
// If this emitter doesn't have a body (i.e., is a direct native
// call with no intervening argument processing), we need to force
- // it to emit a body, and produce another one to act as the entry
- // point
- // FIXME: the negative test against the PRIVATE modifier is a
- // nasty hack to prevent the ProcAddressJavaMethodBindingEmitter
- // from incorrectly introducing method bodies to the private
- // native implementing methods; want this to work at least for
- // public and package-private methods
+ // it to emit a body, and produce another one to act as the entry point
final boolean needsJavaWrapper = baseJavaEmitter.signatureOnly() &&
- !baseJavaEmitter.hasModifier(JavaMethodBindingEmitter.PRIVATE) &&
- baseJavaEmitter.hasModifier(JavaMethodBindingEmitter.NATIVE) &&
+ baseJavaEmitter.isNativeMethod() &&
+ !baseJavaEmitter.isPrivateNativeMethod() &&
callThroughProcAddress;
@@ -215,7 +214,7 @@ public class ProcAddressEmitter extends JavaEmitter {
final ProcAddressJavaMethodBindingEmitter emitter = new ProcAddressJavaMethodBindingEmitter(baseJavaEmitter,
callThroughProcAddress,
getProcAddressConfig().getProcAddressTableExpr(),
- baseJavaEmitter.isForImplementingMethodCall(),
+ baseJavaEmitter.isPrivateNativeMethod(),
this);
if( needsJavaWrapper ) {
emitter.setEmitBody(true);
@@ -232,7 +231,7 @@ public class ProcAddressEmitter extends JavaEmitter {
getProcAddressConfig().getProcAddressTableExpr(),
true,
this);
- emitter.setForImplementingMethodCall(true);
+ emitter.setPrivateNativeMethod(true);
fixSecurityModifiers(emitter);
emitters.add(emitter);
}
@@ -243,13 +242,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 callThroughProcAddress = needsProcAddressWrapper(cSymbol);
- final boolean forceProcAddress = getProcAddressConfig().forceProcAddressGen(cSymbol.getName());
+ 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);
- String forcedCallingConvention = null;
- if (forceProcAddress) {
- forcedCallingConvention = getProcAddressConfig().getLocalProcAddressCallingConvention(cSymbol.getName());
- }
// 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
@@ -258,7 +257,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, forceProcAddress, forcedCallingConvention, this);
+ baseCEmitter, callThroughProcAddress, hasProcAddrTypedef, localProcCallingConvention, this);
final MessageFormat exp = baseCEmitter.getReturnValueCapacityExpression();
if (exp != null) {
@@ -267,34 +266,30 @@ public class ProcAddressEmitter extends JavaEmitter {
emitters.add(res);
}
- private String getAliasedSymName(final FunctionSymbol sym) {
- String symName = getConfig().getJavaSymbolRename(sym.getName());
- if (null == symName) {
- symName = sym.getName();
+ protected boolean callThroughProcAddress(final FunctionSymbol sym) {
+ final ProcAddressConfiguration cfg = getProcAddressConfig();
+ boolean res = false;
+ int mode = 0;
+ if (cfg.forceProcAddressGen(sym)) {
+ res = true;
+ mode = 1;
+ } else {
+ if (cfg.skipProcAddressGen(sym)) {
+ res = false;
+ mode = 2;
+ } else {
+ res = hasFunctionPointerTypedef(sym);
+ mode = 3;
+ }
}
- return symName;
+ LOG.log(Level.INFO, sym.getASTLocusTag(), "callThroughProcAddress: {0} [m {1}]: {2}", res, mode, sym);
+ return res;
}
-
- protected boolean needsProcAddressWrapper(final FunctionSymbol sym) {
- final String symName = getAliasedSymName(sym);
-
- final ProcAddressConfiguration config = getProcAddressConfig();
-
- // We should only generate code to call through a function pointer
- // if the symbol has an associated function pointer typedef.
+ protected boolean hasFunctionPointerTypedef(final FunctionSymbol sym) {
final String funcPointerTypedefName = getFunctionPointerTypedefName(sym);
- boolean shouldWrap = typedefDictionary.containsKey(funcPointerTypedefName);
- //System.err.println(funcPointerTypedefName + " defined: " + shouldWrap);
-
- if (config.skipProcAddressGen(symName)) {
- shouldWrap = false;
- }
-
- if (config.forceProcAddressGen(symName)) {
- shouldWrap = true;
- }
-
- return shouldWrap;
+ final boolean res = typedefDictionary.containsKey(funcPointerTypedefName);
+ LOG.log(Level.INFO, sym.getASTLocusTag(), "hasFunctionPointerTypedef: {0}: {1}", res, sym);
+ return res;
}
protected void beginProcAddressTable() throws Exception {