summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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 );
}
}