Fix weak table creation, processing
This commit is contained in:
@@ -194,7 +194,7 @@ public class BaseLib extends LFunction {
|
|||||||
LTable t = vm.checktable(2);
|
LTable t = vm.checktable(2);
|
||||||
LValue v = vm.checkany(3);
|
LValue v = vm.checkany(3);
|
||||||
vm.argcheck(v.isTable() || v.isNil(), 3, "table or nil expected");
|
vm.argcheck(v.isTable() || v.isNil(), 3, "table or nil expected");
|
||||||
t.luaSetMetatable(v);
|
t = t.luaSetMetatable(v);
|
||||||
vm.resettop();
|
vm.resettop();
|
||||||
vm.pushlvalue(t);
|
vm.pushlvalue(t);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -267,7 +267,7 @@ public class LTable extends LValue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Valid for tables */
|
/** Valid for tables */
|
||||||
public LValue luaSetMetatable(LValue metatable) {
|
public LTable luaSetMetatable(LValue metatable) {
|
||||||
if ( m_metatable != null && m_metatable.containsKey(TM_METATABLE) )
|
if ( m_metatable != null && m_metatable.containsKey(TM_METATABLE) )
|
||||||
throw new LuaErrorException("cannot change a protected metatable");
|
throw new LuaErrorException("cannot change a protected metatable");
|
||||||
if ( metatable == null || metatable.isNil() )
|
if ( metatable == null || metatable.isNil() )
|
||||||
@@ -279,10 +279,10 @@ public class LTable extends LValue {
|
|||||||
return new LWeakTable(this);
|
return new LWeakTable(this);
|
||||||
}
|
}
|
||||||
this.m_metatable = t;
|
this.m_metatable = t;
|
||||||
|
} else {
|
||||||
|
throw new LuaErrorException("not a table: "+metatable.luaGetTypeName());
|
||||||
}
|
}
|
||||||
else
|
return this;
|
||||||
throw new LuaErrorException("nil or table expected, got "+metatable.luaGetTypeName());
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toJavaString() {
|
public String toJavaString() {
|
||||||
|
|||||||
@@ -177,9 +177,11 @@ public class LValue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Valid for tables
|
/** Valid for tables
|
||||||
* @return TODO*/
|
* @param the new LTable, or null or LNil.NIL to reset the metatable to none
|
||||||
public LValue luaSetMetatable(LValue metatable) {
|
* @return this if unchanged, or new LTable if copied using weak table
|
||||||
throw new LuaErrorException( "bad argument #1 to 'setmetatable' (table expected, got "+metatable.luaGetTypeName()+")");
|
*/
|
||||||
|
public LTable luaSetMetatable(LValue metatable) {
|
||||||
|
throw new LuaErrorException( "cannot set metatable for "+metatable.luaGetTypeName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Valid for all types: return the int value identifying the type of this value */
|
/** Valid for all types: return the int value identifying the type of this value */
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
|
|
||||||
|
|
||||||
-- normalized printing
|
-- normalized printing
|
||||||
function eles(t,f)
|
function eles(t,f)
|
||||||
f = f or pairs
|
f = f or pairs
|
||||||
|
|||||||
Reference in New Issue
Block a user