Add last Lua type: userdata. Changed LInstance to inherit from LUserData,

and changed instanceof/casts to LInstance to use LUserData instead. This
should enable various add-ons to be compatible without knowing much, or
anything, about each other.
This commit is contained in:
Ian Farmer
2007-07-17 04:04:18 +00:00
parent 8c3fe262f9
commit 2a64db32b5
3 changed files with 43 additions and 20 deletions

View File

@@ -0,0 +1,28 @@
package lua.value;
public class LUserData extends LValue {
public static final LString TYPE_NAME = new LString("userdata");
public final Object m_instance;
public LUserData(Object obj) {
m_instance = obj;
}
public String luaAsString() {
return m_instance.toString();
}
public boolean equals(Object obj) {
return (this == obj) ||
(obj instanceof LUserData && this.m_instance == ((LUserData) obj).m_instance);
}
public int hashCode() {
return System.identityHashCode( m_instance );
}
public LString luaGetType() {
return TYPE_NAME;
}
}