Improve weak table implementation
This commit is contained in:
@@ -30,7 +30,7 @@ public class LuaTable extends LuaValue {
|
|||||||
protected LuaValue[] array;
|
protected LuaValue[] array;
|
||||||
protected LuaValue[] hashKeys;
|
protected LuaValue[] hashKeys;
|
||||||
protected LuaValue[] hashValues;
|
protected LuaValue[] hashValues;
|
||||||
private int hashEntries;
|
protected int hashEntries;
|
||||||
protected LuaValue m_metatable;
|
protected LuaValue m_metatable;
|
||||||
|
|
||||||
public LuaTable() {
|
public LuaTable() {
|
||||||
@@ -170,7 +170,7 @@ public class LuaTable extends LuaValue {
|
|||||||
return hashget( key );
|
return hashget( key );
|
||||||
}
|
}
|
||||||
|
|
||||||
private LuaValue hashget(LuaValue key) {
|
protected LuaValue hashget(LuaValue key) {
|
||||||
if ( hashEntries > 0 ) {
|
if ( hashEntries > 0 ) {
|
||||||
LuaValue v = hashValues[hashFindSlot(key)];
|
LuaValue v = hashValues[hashFindSlot(key)];
|
||||||
return v!=null? v: NIL;
|
return v!=null? v: NIL;
|
||||||
|
|||||||
@@ -317,8 +317,9 @@ public class LuaValue extends Varargs {
|
|||||||
|
|
||||||
// lua number/string conversion
|
// lua number/string conversion
|
||||||
public LuaString strvalue() { typerror("strValue"); return null; }
|
public LuaString strvalue() { typerror("strValue"); return null; }
|
||||||
public LuaValue strongkey() { return this; }
|
public LuaValue strongkey() { return strongvalue(); }
|
||||||
public LuaValue strongvalue() { return this; }
|
public LuaValue strongvalue() { return this; }
|
||||||
|
public boolean isweaknil() { return false; }
|
||||||
|
|
||||||
// conversion from java values
|
// conversion from java values
|
||||||
public static LuaBoolean valueOf(boolean b) { return b? LuaValue.TRUE: FALSE; };
|
public static LuaBoolean valueOf(boolean b) { return b? LuaValue.TRUE: FALSE; };
|
||||||
|
|||||||
@@ -269,7 +269,6 @@ public class WeakTable extends LuaTable {
|
|||||||
this.weakvalue = weakvalue;
|
this.weakvalue = weakvalue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// when looking up the value, look in the keys metatable
|
|
||||||
public LuaValue strongvalue() {
|
public LuaValue strongvalue() {
|
||||||
LuaValue key = weakkey.strongkey();
|
LuaValue key = weakkey.strongkey();
|
||||||
if ( key.isnil() )
|
if ( key.isnil() )
|
||||||
|
|||||||
Reference in New Issue
Block a user