remove dependence on Type class.
This commit is contained in:
@@ -1,4 +1,7 @@
|
|||||||
package lua;
|
package lua;
|
||||||
|
|
||||||
|
import lua.value.Type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constants for lua limits and opcodes
|
* Constants for lua limits and opcodes
|
||||||
*
|
*
|
||||||
@@ -367,5 +370,16 @@ public class Lua {
|
|||||||
public static final int LUA_TUSERDATA = 7;
|
public static final int LUA_TUSERDATA = 7;
|
||||||
public static final int LUA_TTHREAD = 8;
|
public static final int LUA_TTHREAD = 8;
|
||||||
|
|
||||||
|
public static final String[] TYPE_NAMES = {
|
||||||
|
"nil",
|
||||||
|
"boolean",
|
||||||
|
"lightuserdata",
|
||||||
|
"number",
|
||||||
|
"string",
|
||||||
|
"table",
|
||||||
|
"function",
|
||||||
|
"userdata",
|
||||||
|
"thread",
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,15 @@ public class LString extends LValue {
|
|||||||
|
|
||||||
private static LTable s_stringMT;
|
private static LTable s_stringMT;
|
||||||
|
|
||||||
|
public static final LString[] LTYPENAMES;
|
||||||
|
|
||||||
|
static {
|
||||||
|
int n = Lua.TYPE_NAMES.length;
|
||||||
|
LTYPENAMES = new LString[n];
|
||||||
|
for ( int i=0; i<n; i++ )
|
||||||
|
LTYPENAMES[i] = new LString(Lua.TYPE_NAMES[i]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a Lua string from the given Java string. Characters are encoded
|
* Construct a Lua string from the given Java string. Characters are encoded
|
||||||
* using UTF-8.
|
* using UTF-8.
|
||||||
|
|||||||
@@ -179,9 +179,10 @@ public class LValue {
|
|||||||
/** 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 */
|
||||||
public abstract int luaGetType();
|
public abstract int luaGetType();
|
||||||
|
|
||||||
|
|
||||||
/** Valid for all types: return the type of this value as an LString */
|
/** Valid for all types: return the type of this value as an LString */
|
||||||
public LString luaGetTypeName() {
|
public LString luaGetTypeName() {
|
||||||
return Type.VALUES[luaGetType()].toLString();
|
return LString.LTYPENAMES[luaGetType()];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,8 @@ public class Type implements Serializable, Comparable {
|
|||||||
|
|
||||||
public static Type valueOf(String strValue) {
|
public static Type valueOf(String strValue) {
|
||||||
Type[] values = Type.VALUES;
|
Type[] values = Type.VALUES;
|
||||||
for (Type value : values) {
|
for ( int i=0; i<values.length; i++ ) {
|
||||||
|
Type value = values[i];
|
||||||
if (value.toString().equals(strValue)) {
|
if (value.toString().equals(strValue)) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user