summaryrefslogtreecommitdiffstats
path: root/src/java/com
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-07-14 20:06:39 +0200
committerSven Gothel <[email protected]>2013-07-14 20:06:39 +0200
commite4a213c56042b1eba4c06421c69f09160dea9376 (patch)
tree5a731e3312da99a30e8c6f0f6e2685f42f913be1 /src/java/com
parent461f57b12b95782c53d0380d5d796615ad2e4581 (diff)
FunctionSymbol: Fix equals/hashCode comparison, i.e. skip args/type due to non overloading of c-funcs.
Diffstat (limited to 'src/java/com')
-rw-r--r--src/java/com/jogamp/gluegen/cgram/types/FunctionSymbol.java32
1 files changed, 25 insertions, 7 deletions
diff --git a/src/java/com/jogamp/gluegen/cgram/types/FunctionSymbol.java b/src/java/com/jogamp/gluegen/cgram/types/FunctionSymbol.java
index 4abbfbd..f730c0e 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/FunctionSymbol.java
+++ b/src/java/com/jogamp/gluegen/cgram/types/FunctionSymbol.java
@@ -39,11 +39,18 @@
package com.jogamp.gluegen.cgram.types;
-/** Describes a function symbol, which includes the name and
-type. Since we are currently only concerned with processing
-functions this is the only symbol type, though plausibly more
-types should be added and a true symbol table constructed during
-parsing. */
+/**
+ * Describes a function symbol, which includes the name and
+ * type. Since we are currently only concerned with processing
+ * functions this is the only symbol type, though plausibly more
+ * types should be added and a true symbol table constructed during parsing.
+ * <p>
+ * Note: Since C does not support method-overloading polymorphism like C++ or Java,
+ * we ignore the {@link FunctionType} attribute in {@link #equals(Object)} and {@link #hashCode()}.<br/>
+ * Hence we assume all method occurrences w/ same name are of equal or compatible type. <br/>
+ * Deep comparison can be performed via {@link #isCompletelyEqual(Object o)};
+ * </p>
+ **/
public class FunctionSymbol {
private String name;
@@ -118,12 +125,23 @@ public class FunctionSymbol {
return false;
}
- FunctionSymbol other = (FunctionSymbol) arg;
+ final FunctionSymbol other = (FunctionSymbol) arg;
if (getName() == null && other.getName() != null) {
return false;
}
- return (getName().equals(other.getName()) || getName().equals(other.getName())) && type.equals(other.type);
+ return getName().equals(other.getName());
+ }
+
+ /**
+ * Compares the function type as well, since {@link #equals(Object)}
+ * and {@link #hashCode()} won't.
+ */
+ public boolean isCompletelyEqual(Object arg) {
+ if( !this.equals(arg) ) {
+ return false;
+ }
+ return type.equals( ((FunctionSymbol)arg).type );
}
}