From e4a213c56042b1eba4c06421c69f09160dea9376 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 14 Jul 2013 20:06:39 +0200 Subject: FunctionSymbol: Fix equals/hashCode comparison, i.e. skip args/type due to non overloading of c-funcs. --- .../jogamp/gluegen/cgram/types/FunctionSymbol.java | 32 +++++++++++++++++----- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'src') 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. + *

+ * 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()}.
+ * Hence we assume all method occurrences w/ same name are of equal or compatible type.
+ * Deep comparison can be performed via {@link #isCompletelyEqual(Object o)}; + *

+ **/ 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 ); } } -- cgit v1.2.3