diff options
author | Sven Gothel <[email protected]> | 2009-08-05 07:31:49 -0700 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2009-08-05 07:31:49 -0700 |
commit | aac675e3ae8be73d3e498cc8f1062a20839f8482 (patch) | |
tree | dbf68c2183499179a28632b2d3dbc491e0f225dd /src/java/com/sun/gluegen/MethodBinding.java | |
parent | edaf82f5a86cd3e239072608e5299a9553ece32c (diff) |
Cleanup for a better OpenGL 3.2 integration,
for subsuming extensions:
- Allow RenameExtensionIntoCore generate duplicate names,
ie those will not be generated.
- Add proper comment showing the extension of the symbol.
- Fail if no 'GLHeader' is specified, but we are processing a GL/ProcAddress config
- Fail if a GL function is not part of an extension
MethodBinding, ConstantDefinition cleanup:
- getName() returns the renamed name
- getOrigName() returns the original
- getAliasedNames() returns the aliased ones
MethodBinding:
- Change: equals() operates on renamed name
- Add: hashCode() function - same criteria as equals()
Impact:
- All config options etc shall trigger with the renamed name,
but ignore, rename etc.
- Generated Java impl. uses the renamed base name as well
Change: emitDefine() uses the ConstantDefinition
Add: JavaConfiguration: dumpRenames()
Change JavaConfiguration.shouldIgnoreInInterface/Impl():
- respect the renamed symbol name as well
Change JavaEmitter.emitFunctions():
- only emit a generated MethodBinding once,
therefor store emitted method bindings in a HashSet
Fix BuildStaticGLInfo:
- Allow white space at the end of #ifndef and #define
- Trim strings
- Allow 'const' qualifier in function pattern
Fix GLEmitter:
- Fail if no 'GLHeader' is specified, but a RenameIntoCore option ..
- Don't emit marker defines, marking an extension (ie not part of an extension)
Fix GLJavaMethodBindingEmitter:
- Fail if a GL function is not part of an extension
Fix PCPP:
- Pass constant type qualifiers for hex-constants: 'l' 'L' ...
Fix ProcAddressEmitter:
- Operate on the aliased/renamed name for querying ProcAddress usage
and generating code.
Diffstat (limited to 'src/java/com/sun/gluegen/MethodBinding.java')
-rw-r--r-- | src/java/com/sun/gluegen/MethodBinding.java | 54 |
1 files changed, 46 insertions, 8 deletions
diff --git a/src/java/com/sun/gluegen/MethodBinding.java b/src/java/com/sun/gluegen/MethodBinding.java index 5431874..228f581 100644 --- a/src/java/com/sun/gluegen/MethodBinding.java +++ b/src/java/com/sun/gluegen/MethodBinding.java @@ -51,6 +51,7 @@ public class MethodBinding { private FunctionSymbol sym; private String renamedMethodName; + private HashSet aliasedNames; private JavaType javaReturnType; private List javaArgumentTypes; private boolean computedSignatureProperties; @@ -76,6 +77,8 @@ public class MethodBinding { this.sym = bindingToCopy.sym; this.renamedMethodName = bindingToCopy.renamedMethodName; + this.aliasedNames=new HashSet(); + this.aliasedNames.addAll(bindingToCopy.aliasedNames); this.containingType = bindingToCopy.containingType; this.containingCType = bindingToCopy.containingCType; this.javaReturnType = bindingToCopy.javaReturnType; @@ -96,6 +99,7 @@ public class MethodBinding { /** Constructor for calling a C function. */ public MethodBinding(FunctionSymbol sym) { this.sym = sym; + this.aliasedNames=new HashSet(); } /** Constructor for calling a function pointer contained in a @@ -104,6 +108,7 @@ public class MethodBinding { this.sym = sym; this.containingType = containingType; this.containingCType = containingCType; + this.aliasedNames=new HashSet(); } public void setJavaReturnType(JavaType type) { @@ -156,11 +161,11 @@ public class MethodBinding { return "arg" + i; } - public String getName() { + public String getOrigName() { return sym.getName(); } - public String getRenamedMethodName() { + public String getName() { // Defaults to same as C symbol unless renamed if (renamedMethodName != null) { return renamedMethodName; @@ -169,8 +174,19 @@ public class MethodBinding { } /** Supports renaming C function in Java binding. */ - public void setRenamedMethodName(String name) { - renamedMethodName = name; + public void renameMethodName(String name) { + if(null!=name) { + renamedMethodName = name; + aliasedNames.add(sym.getName()); + } + } + + public void addAliasedName(String name) { + aliasedNames.add(name); + } + + public Collection getAliasedNames() { + return aliasedNames; } /** Creates a new MethodBinding replacing the specified Java @@ -451,9 +467,10 @@ public class MethodBinding { } MethodBinding other = (MethodBinding)obj; - if (!(sym.equals(other.sym))) { return false; } + if ( !getName().equals(other.getName()) || + !sym.getType().equals(other.sym.getType()) ) { return false; } if (!(javaReturnType.equals(other.getJavaReturnType()))) { return false; } - if (containingType != null && + if (containingCType != null && other.getContainingCType() != null && (!(containingCType.equals(other.getContainingCType())))) { return false; @@ -473,14 +490,35 @@ public class MethodBinding { return true; } - // FIXME!! Implement hashCode() to match equals(Object) + public int hashCode() { + StringBuffer buf = new StringBuffer(200); + buf.append(getName()); + buf.append(sym.getType().getName(true)); + buf.append(getJavaReturnType().getName()); + if (containingCType != null) { + buf.append(containingCType.getName(true)); + } + + for (int i = 0; i < getNumArguments(); i++) { + JavaType type = getJavaArgumentType(i); + if (type.isVoid()) { + // Make sure this is the only param to the method; if it isn't, + // there's something wrong with our parsing of the headers. + assert(getNumArguments() == 1); + continue; + } + + buf.append(type.getName()); + } + return buf.toString().hashCode(); + } /** Returns the signature of this binding. */ public String toString() { StringBuffer buf = new StringBuffer(200); buf.append(getJavaReturnType().getName()); buf.append(" "); - buf.append(getRenamedMethodName()); + buf.append(getName()); buf.append("("); boolean needComma = false; for (int i = 0; i < getNumArguments(); i++) { |