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