Better support for serialization and sorting of the Token data type
This commit is contained in:
@@ -329,13 +329,19 @@ LUA_API void lua_arith (lua_State *L, int op) {
|
||||
lua_unlock(L);
|
||||
}
|
||||
|
||||
/* Numbers are first, to help out pretty-printers that want
|
||||
* to print the keys of a table in order. */
|
||||
static int sortorder(int t) {
|
||||
switch (t) {
|
||||
case LUA_TNIL: return 0;
|
||||
case LUA_TNUMBER: return 1;
|
||||
case LUA_TSTRING: return 2;
|
||||
case LUA_TBOOLEAN: return 3;
|
||||
case LUA_TTABLE: return 1000000;
|
||||
case LUA_TNUMBER: return 0;
|
||||
case LUA_TSTRING: return 1;
|
||||
case LUA_TBOOLEAN: return 2;
|
||||
case LUA_TLIGHTUSERDATA: return 3;
|
||||
case LUA_TFUNCTION: return 4;
|
||||
case LUA_TTHREAD: return 5;
|
||||
case LUA_TUSERDATA: return 6;
|
||||
case LUA_TTABLE: return 7;
|
||||
case LUA_TNIL: return 1000000;
|
||||
default: return t+1000;
|
||||
}
|
||||
}
|
||||
@@ -356,6 +362,8 @@ LUA_API int lua_genlt (lua_State *L, int index1, int index2) {
|
||||
i = luaV_lessthan(L, o1, o2);
|
||||
} else if (t1 == LUA_TBOOLEAN) {
|
||||
i = bvalue(o1) < bvalue(o2);
|
||||
} else if (t1 == LUA_TLIGHTUSERDATA) {
|
||||
i = pvalue(o1) < pvalue(o2);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user