org.luaj.vm2
Class LuaUserdata

java.lang.Object
  extended by org.luaj.vm2.Varargs
      extended by org.luaj.vm2.LuaValue
          extended by org.luaj.vm2.LuaUserdata

public class LuaUserdata
extends LuaValue


Field Summary
 java.lang.Object m_instance
           
 LuaValue m_metatable
           
 
Fields inherited from class org.luaj.vm2.LuaValue
ADD, CALL, CONCAT, DIV, EMPTYSTRING, EQ, FALSE, INDEX, LE, LEN, LT, METATABLE, MINUSONE, MOD, MODE, MUL, NEWINDEX, NIL, NILS, NONE, NOVALS, ONE, POW, SUB, TBOOLEAN, TFUNCTION, TINT, TLIGHTUSERDATA, TNIL, TNONE, TNUMBER, TOSTRING, TRUE, TSTRING, TTABLE, TTHREAD, TUSERDATA, TVALUE, TYPE_NAMES, UNM, ZERO
 
Constructor Summary
LuaUserdata(java.lang.Object obj)
           
LuaUserdata(java.lang.Object obj, LuaValue metatable)
           
 
Method Summary
 java.lang.Object checkuserdata()
          Check that this is a LuaUserdata, or throw LuaError if it is not
 java.lang.Object checkuserdata(java.lang.Class c)
          Check that this is a LuaUserdata, or throw LuaError if it is not
 boolean eq_b(LuaValue val)
          Equals: Perform equality comparison with another value including metatag processing using EQ, and return java boolean
 LuaValue eq(LuaValue val)
          Equals: Perform equality comparison with another value including metatag processing using EQ.
 boolean eqmt(LuaValue val)
           
 boolean equals(java.lang.Object val)
           
 LuaValue get(LuaValue key)
          Get a value in a table including metatag processing using INDEX.
 LuaValue getmetatable()
          Get the metatable for this LuaValue
 int hashCode()
           
 boolean isuserdata()
          Check if this is a userdata
 boolean isuserdata(java.lang.Class c)
          Check if this is a userdata of type c
 java.lang.Object optuserdata(java.lang.Class c, java.lang.Object defval)
          Check that optional argument is a userdata whose instance is of a type and return the Object instance
 java.lang.Object optuserdata(java.lang.Object defval)
          Check that optional argument is a userdata and return the Object instance
 boolean raweq(LuaUserdata val)
          Equals: Perform direct equality comparison with a LuaUserdata value without metatag processing.
 boolean raweq(LuaValue val)
          Equals: Perform direct equality comparison with another value without metatag processing.
 void set(LuaValue key, LuaValue value)
          Set a value in a table without metatag processing using NEWINDEX.
 LuaValue setmetatable(LuaValue metatable)
          Set the metatable for this LuaValue
 java.lang.String tojstring()
          Convert to human readable String for any type.
 java.lang.Object touserdata()
          Convert to userdata instance, or null.
 java.lang.Object touserdata(java.lang.Class c)
          Convert to userdata instance if specific type, or null.
 int type()
          Get the enumeration value for the type of this value.
 java.lang.String typename()
          Get the String name of the type of this value.
 java.lang.Object userdata()
           
 
Methods inherited from class org.luaj.vm2.LuaValue
add, add, add, and, arg, arg1, argerror, argerror, aritherror, aritherror, arithmt, arithmtwith, assert_, buffer, call, call, call, call, callmt, checkboolean, checkclosure, checkdouble, checkfunction, checkint, checkinteger, checkjstring, checklong, checkmetatag, checknotnil, checknumber, checknumber, checkstring, checktable, checkthread, checkvalidkey, compareerror, compareerror, comparemt, concat, concat, concatmt, concatTo, concatTo, concatTo, div, div, div, divInto, eqmtcall, error, get, get, getfenv, getn, gettable, gt_b, gt_b, gt_b, gt, gt, gt, gteq_b, gteq_b, gteq_b, gteq, gteq, gteq, illegal, inext, invoke, invoke, invoke, invoke, invoke, invoke, invokemethod, invokemethod, invokemethod, invokemethod, invokemethod, invokemethod, isboolean, isclosure, isfunction, isint, isinttype, islong, isnil, isnumber, isstring, istable, isthread, isweaknil, len, lenerror, length, listOf, listOf, load, lt_b, lt_b, lt_b, lt, lt, lt, lteq_b, lteq_b, lteq_b, lteq, lteq, lteq, metatag, method, method, method, method, method, method, mod, mod, mod, modFrom, mul, mul, mul, narg, neg, neq_b, neq, next, not, onInvoke, optboolean, optclosure, optdouble, optfunction, optint, optinteger, optjstring, optlong, optnumber, optstring, opttable, optthread, optvalue, or, pow, pow, pow, powWith, powWith, presize, raweq, raweq, raweq, rawget, rawget, rawget, rawset, rawset, rawset, rawset, rawset, rawset, rawset, rawsetlist, set, set, set, set, set, set, setfenv, settable, strcmp, strcmp, strongkey, strongvalue, strvalue, sub, sub, sub, subFrom, subFrom, tableOf, tableOf, tableOf, tableOf, tableOf, tableOf, tailcallOf, testfor_b, toboolean, tobyte, tochar, todouble, tofloat, toint, tolong, tonumber, toshort, tostring, toString, typerror, unimplemented, userdataOf, userdataOf, valueOf, valueOf, valueOf, valueOf, valueOf, valueOf, varargsOf, varargsOf, varargsOf, varargsOf, varargsOf, varargsOf
 
Methods inherited from class org.luaj.vm2.Varargs
argcheck, checkboolean, checkclosure, checkdouble, checkfunction, checkint, checkinteger, checkjstring, checklong, checknotnil, checknumber, checkstring, checktable, checkthread, checkuserdata, checkuserdata, checkvalue, eval, isfunction, isnil, isnoneornil, isnumber, isstring, istable, isTailcall, isthread, isuserdata, isvalue, optboolean, optclosure, optdouble, optfunction, optint, optinteger, optjstring, optlong, optnumber, optstring, opttable, optthread, optuserdata, optuserdata, optvalue, subargs, toboolean, tobyte, tochar, todouble, tofloat, toint, tojstring, tolong, toshort, touserdata, touserdata, type
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

m_instance

public final java.lang.Object m_instance

m_metatable

public LuaValue m_metatable
Constructor Detail

LuaUserdata

public LuaUserdata(java.lang.Object obj)

LuaUserdata

public LuaUserdata(java.lang.Object obj,
                   LuaValue metatable)
Method Detail

tojstring

public java.lang.String tojstring()
Description copied from class: LuaValue
Convert to human readable String for any type.

Overrides:
tojstring in class LuaValue
Returns:
String for use by human readers based on type.
See Also:
LuaValue.tostring(), LuaValue.optjstring(String), LuaValue.checkjstring(), LuaValue.isstring(), TSTRING

type

public int type()
Description copied from class: LuaValue
Get the enumeration value for the type of this value.

Specified by:
type in class LuaValue
Returns:
value for this type, one of TNIL, TBOOLEAN, TNUMBER, TSTRING, TTABLE, TFUNCTION, TUSERDATA, TTHREAD
See Also:
LuaValue.typename()

typename

public java.lang.String typename()
Description copied from class: LuaValue
Get the String name of the type of this value.

Specified by:
typename in class LuaValue
Returns:
name from type name list LuaValue.TYPE_NAMES corresponding to the type of this value: "nil", "boolean", "number", "string", "table", "function", "userdata", "thread"
See Also:
LuaValue.type()

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

userdata

public java.lang.Object userdata()

isuserdata

public boolean isuserdata()
Description copied from class: LuaValue
Check if this is a userdata

Overrides:
isuserdata in class LuaValue
Returns:
true if this is a userdata, otherwise false
See Also:
LuaValue.isuserdata(Class), LuaValue.touserdata(), LuaValue.checkuserdata(), LuaValue.optuserdata(Object), LuaValue.TUSERDATA

isuserdata

public boolean isuserdata(java.lang.Class c)
Description copied from class: LuaValue
Check if this is a userdata of type c

Overrides:
isuserdata in class LuaValue
Parameters:
c - Class to test instance against
Returns:
true if this is a userdata and the instance is assignable to c, otherwise false
See Also:
LuaValue.isuserdata(), LuaValue.touserdata(Class), LuaValue.checkuserdata(Class), #optuserdata(Object,Class), LuaValue.TUSERDATA

touserdata

public java.lang.Object touserdata()
Description copied from class: LuaValue
Convert to userdata instance, or null.

Overrides:
touserdata in class LuaValue
Returns:
userdata instance if userdata, or null if not LuaUserdata
See Also:
LuaValue.optuserdata(Object), LuaValue.checkuserdata(), LuaValue.isuserdata(), LuaValue.TUSERDATA

touserdata

public java.lang.Object touserdata(java.lang.Class c)
Description copied from class: LuaValue
Convert to userdata instance if specific type, or null.

Overrides:
touserdata in class LuaValue
Returns:
userdata instance if is a userdata whose instance derives from c, or null if not LuaUserdata
See Also:
LuaValue.optuserdata(Class,Object), LuaValue.checkuserdata(Class), LuaValue.isuserdata(Class), LuaValue.TUSERDATA

optuserdata

public java.lang.Object optuserdata(java.lang.Object defval)
Description copied from class: LuaValue
Check that optional argument is a userdata and return the Object instance

Overrides:
optuserdata in class LuaValue
Parameters:
defval - Object to return if this is nil or none
Returns:
Object instance of the userdata if a LuaUserdata, defval if nil or none, throws LuaError if some other type
See Also:
LuaValue.checkuserdata(), LuaValue.isuserdata(), LuaValue.optuserdata(Class, Object), LuaValue.TUSERDATA

optuserdata

public java.lang.Object optuserdata(java.lang.Class c,
                                    java.lang.Object defval)
Description copied from class: LuaValue
Check that optional argument is a userdata whose instance is of a type and return the Object instance

Overrides:
optuserdata in class LuaValue
Parameters:
c - Class to test userdata instance against
defval - Object to return if this is nil or none
Returns:
Object instance of the userdata if a LuaUserdata and instance is assignable to c, defval if nil or none, throws LuaError if some other type
See Also:
LuaValue.checkuserdata(Class), LuaValue.isuserdata(Class), LuaValue.optuserdata(Object), LuaValue.TUSERDATA

getmetatable

public LuaValue getmetatable()
Description copied from class: LuaValue
Get the metatable for this LuaValue

For LuaTable and LuaUserdata instances, the metatable returned is this instance metatable. For all other types, the class metatable value will be returned.

Overrides:
getmetatable in class LuaValue
Returns:
metatable, or null if it there is none
See Also:
LuaBoolean.s_metatable, LuaNumber.s_metatable, LuaNil.s_metatable, LuaFunction.s_metatable, LuaThread.s_metatable

setmetatable

public LuaValue setmetatable(LuaValue metatable)
Description copied from class: LuaValue
Set the metatable for this LuaValue

For LuaTable and LuaUserdata instances, the metatable is per instance. For all other types, there is one metatable per type that can be set directly from java

Overrides:
setmetatable in class LuaValue
Parameters:
metatable - LuaValue instance to serve as the metatable, or null to reset it.
Returns:
this to allow chaining of Java function calls
See Also:
LuaBoolean.s_metatable, LuaNumber.s_metatable, LuaNil.s_metatable, LuaFunction.s_metatable, LuaThread.s_metatable

checkuserdata

public java.lang.Object checkuserdata()
Description copied from class: LuaValue
Check that this is a LuaUserdata, or throw LuaError if it is not

Overrides:
checkuserdata in class LuaValue
Returns:
this if it is a LuaUserdata
See Also:
LuaValue.isuserdata(), LuaValue.optuserdata(Object), LuaValue.checkuserdata(Class), LuaValue.TUSERDATA

checkuserdata

public java.lang.Object checkuserdata(java.lang.Class c)
Description copied from class: LuaValue
Check that this is a LuaUserdata, or throw LuaError if it is not

Overrides:
checkuserdata in class LuaValue
Returns:
this if it is a LuaUserdata
See Also:
LuaValue.isuserdata(Class), LuaValue.optuserdata(Class, Object), LuaValue.checkuserdata(), LuaValue.TUSERDATA

get

public LuaValue get(LuaValue key)
Description copied from class: LuaValue
Get a value in a table including metatag processing using INDEX.

Overrides:
get in class LuaValue
Parameters:
key - the key to look up, must not be NIL or null
Returns:
LuaValue for that key, or NIL if not found and no metatag
See Also:
LuaValue.get(int), LuaValue.get(String), LuaValue.rawget(LuaValue)

set

public void set(LuaValue key,
                LuaValue value)
Description copied from class: LuaValue
Set a value in a table without metatag processing using NEWINDEX.

Overrides:
set in class LuaValue
Parameters:
key - the key to use, must not be NIL or null
value - the value to use, can be NIL, must not be null

equals

public boolean equals(java.lang.Object val)
Overrides:
equals in class LuaValue

eq

public LuaValue eq(LuaValue val)
Description copied from class: LuaValue
Equals: Perform equality comparison with another value including metatag processing using EQ.

Overrides:
eq in class LuaValue
Parameters:
val - The value to compare with.
Returns:
TRUE if values are comparable and (this == rhs), FALSE if comparable but not equal, LuaValue if metatag processing occurs.
See Also:
LuaValue.eq_b(LuaValue), LuaValue.raweq(LuaValue), LuaValue.neq(LuaValue), LuaValue.eqmtcall(LuaValue, LuaValue, LuaValue, LuaValue), LuaValue.EQ

eq_b

public boolean eq_b(LuaValue val)
Description copied from class: LuaValue
Equals: Perform equality comparison with another value including metatag processing using EQ, and return java boolean

Overrides:
eq_b in class LuaValue
Parameters:
val - The value to compare with.
Returns:
true if values are comparable and (this == rhs), false if comparable but not equal, result converted to java boolean if metatag processing occurs.
See Also:
LuaValue.eq(LuaValue), LuaValue.raweq(LuaValue), LuaValue.neq_b(LuaValue), LuaValue.eqmtcall(LuaValue, LuaValue, LuaValue, LuaValue), LuaValue.EQ

raweq

public boolean raweq(LuaValue val)
Description copied from class: LuaValue
Equals: Perform direct equality comparison with another value without metatag processing.

Overrides:
raweq in class LuaValue
Parameters:
val - The value to compare with.
Returns:
true if (this == rhs), false otherwise
See Also:
LuaValue.eq(LuaValue), LuaValue.raweq(LuaUserdata), LuaValue.raweq(LuaString), LuaValue.raweq(double), LuaValue.raweq(int), LuaValue.EQ

raweq

public boolean raweq(LuaUserdata val)
Description copied from class: LuaValue
Equals: Perform direct equality comparison with a LuaUserdata value without metatag processing.

Overrides:
raweq in class LuaValue
Parameters:
val - The LuaUserdata to compare with.
Returns:
true if this is userdata and their metatables are the same using == and their instances are equal using LuaValue.equals(Object), otherwise false
See Also:
LuaValue.eq(LuaValue), LuaValue.raweq(LuaValue)

eqmt

public boolean eqmt(LuaValue val)


Copyright © 2007-2008 Luaj.org. All Rights Reserved.