/** Get a value in a table without metatag processing. * @param key the key to look up, must not be null * @return {@link LuaValue} for that key, or {@link #NIL} if not found * @throws LuaError if {@code this} is not a table */ public LuaValue rawget( String key ) { return rawget(valueOf(key)); }
/** Get a value in a table without metatag processing. * @param key the key to look up * @return {@link LuaValue} for that key, or {@link #NIL} if not found * @throws LuaError if {@code this} is not a table */ public LuaValue rawget( int key ) { return rawget(valueOf(key)); }
/** Get a value in a table without metatag processing. * @param key the key to look up * @return {@link LuaValue} for that key, or {@link #NIL} if not found * @throws LuaError if {@code this} is not a table */ public LuaValue rawget( int key ) { return rawget(valueOf(key)); }
/** * Get particular metatag, or return {@link LuaValue#NIL} if it doesn't exist * @param tag Metatag name to look up, typically a string such as * {@link LuaValue#INDEX} or {@link LuaValue#NEWINDEX} * @return {@link LuaValue} for tag {@code reason}, or {@link LuaValue#NIL} */ public LuaValue metatag(LuaValue tag) { LuaValue mt = getmetatable(); if ( mt == null ) return NIL; return mt.rawget(tag); }
/** Get a value in a table without metatag processing. * @param key the key to look up, must not be null * @return {@link LuaValue} for that key, or {@link #NIL} if not found * @throws LuaError if {@code this} is not a table */ public LuaValue rawget( String key ) { return rawget(valueOf(key)); }
/** * Get particular metatag, or return {@link LuaValue#NIL} if it doesn't exist * @param tag Metatag name to look up, typically a string such as * {@link LuaValue#INDEX} or {@link LuaValue#NEWINDEX} * @return {@link LuaValue} for tag {@code reason}, or {@link LuaValue#NIL} */ public LuaValue metatag(LuaValue tag) { LuaValue mt = getmetatable(); if ( mt == null ) return NIL; return mt.rawget(tag); }
/** Get a value in a table without metatag processing. * @param key the key to look up * @return {@link LuaValue} for that key, or {@link NIL} if not found * @throws LuaError if {@code this} is not a table */ public LuaValue rawget( int key ) { return rawget(valueOf(key)); }
/** Get a value in a table without metatag processing. * @param key the key to look up, must not be null * @return {@link LuaValue} for that key, or {@link NIL} if not found * @throws LuaError if {@code this} is not a table */ public LuaValue rawget( String key ) { return rawget(valueOf(key)); }
/** * Get particular metatag, or return {@link LuaValue#NIL} if it doesn't exist * @param tag Metatag name to look up, typically a string such as * {@link LuaValue#INDEX} or {@link LuaValue#NEWINDEX} * @param reason Description of error when tag lookup fails. * @return {@link LuaValue} for tag {@code reason}, or {@link LuaValue#NIL} */ public LuaValue metatag(LuaValue tag) { LuaValue mt = getmetatable(); if ( mt == null ) return NIL; return mt.rawget(tag); }
/** Perform equality testing metatag processing * @param lhs left-hand-side of equality expression * @param lhsmt metatag value for left-hand-side * @param rhs right-hand-side of equality expression * @param rhsmt metatag value for right-hand-side * @return true if metatag processing result is not {@link #NIL} or {@link #FALSE} * @throws LuaError if metatag was not defined for either operand * @see #equals(Object) * @see #eq(LuaValue) * @see #raweq(LuaValue) * @see #EQ */ public static final boolean eqmtcall(LuaValue lhs, LuaValue lhsmt, LuaValue rhs, LuaValue rhsmt) { LuaValue h = lhsmt.rawget(EQ); return h.isnil() || h!=rhsmt.rawget(EQ)? false: h.call(lhs,rhs).toboolean(); }
/** Perform equality testing metatag processing * @param lhs left-hand-side of equality expression * @param lhsmt metatag value for left-hand-side * @param rhs right-hand-side of equality expression * @param rhsmt metatag value for right-hand-side * @return true if metatag processing result is not {@link #NIL} or {@link #FALSE} * @throws LuaError if metatag was not defined for either operand * @see #equals(Object) * @see #eq(LuaValue) * @see #raweq(LuaValue) * @see #EQ */ public static final boolean eqmtcall(LuaValue lhs, LuaValue lhsmt, LuaValue rhs, LuaValue rhsmt) { LuaValue h = lhsmt.rawget(EQ); return h.isnil() || h!=rhsmt.rawget(EQ)? false: h.call(lhs,rhs).toboolean(); }
public LuaValue call(LuaValue arg) { LuaValue mt = arg.getmetatable(); return mt != null ? mt.rawget(METATABLE).optvalue(mt) : NIL; } }
/** Perform equality testing metatag processing * @param lhs left-hand-side of equality expression * @param lhsmt metatag value for left-hand-side * @param rhs right-hand-side of equality expression * @param rhsmt metatag value for right-hand-side * @return true if metatag processing result is not {@link NIL} or {@link FALSE} * @throws LuaError if metatag was not defined for either operand * @see #equals(Object) * @see #eq(LuaValue) * @see #raweq(LuaValue) * @see #EQ */ public static boolean eqmtcall(LuaValue lhs, LuaValue lhsmt, LuaValue rhs, LuaValue rhsmt) { LuaValue h = lhsmt.rawget(EQ); return h.isnil() || h!=rhsmt.rawget(EQ)? false: h.call(lhs,rhs).toboolean(); }
public LuaValue call(LuaValue arg) { LuaValue mt = arg.getmetatable(); return mt!=null? mt.rawget(METATABLE).optvalue(mt): NIL; } }
@Override public LuaValue call(LuaValue arg) { LuaValue mt = arg.getmetatable(); return mt!=null? mt.rawget(METATABLE).optvalue(mt): NIL; } }
/** Construct a Metatable instance from the given LuaValue */ protected static Metatable metatableOf(LuaValue mt) { if ( mt != null && mt.istable() ) { LuaValue mode = mt.rawget(MODE); if ( mode.isstring() ) { String m = mode.tojstring(); boolean weakkeys = m.indexOf('k') >= 0; boolean weakvalues = m.indexOf('v') >= 0; if ( weakkeys || weakvalues ) { return new WeakTable(weakkeys, weakvalues, mt); } } return (LuaTable)mt; } else if ( mt != null ) { return new NonTableMetatable( mt ); } else { return null; } }
@Override public LuaValue call(LuaValue table, LuaValue metatable) { final LuaValue mt0 = table.getmetatable(); if ( mt0!=null && !mt0.rawget(METATABLE).isnil() ) error("cannot change a protected metatable"); return table.setmetatable(metatable.isnil()? null: metatable.checktable()); } }
public LuaValue call(LuaValue table, LuaValue metatable) { final LuaValue mt0 = table.checktable().getmetatable(); if ( mt0!=null && !mt0.rawget(METATABLE).isnil() ) error("cannot change a protected metatable"); return table.setmetatable(metatable.isnil()? null: metatable.checktable()); } }
public LuaValue call(LuaValue table, LuaValue metatable) { final LuaValue mt0 = table.checktable().getmetatable(); if (mt0 != null && !mt0.rawget(METATABLE).isnil()) { error("cannot change a protected metatable"); } return table.setmetatable(metatable.isnil() ? null : metatable.checktable()); } }
/** get value from metatable operations, or NIL if not defined by metatables */ protected static LuaValue gettable(LuaValue t, LuaValue key) { LuaValue tm; int loop = 0; do { if (t.istable()) { LuaValue res = t.rawget(key); if ((!res.isnil()) || (tm = t.metatag(INDEX)).isnil()) return res; } else if ((tm = t.metatag(INDEX)).isnil()) t.indexerror(); if (tm.isfunction()) return tm.call(t, key); t = tm; } while ( ++loop < MAXTAGLOOP ); error("loop in gettable"); return NIL; }