eris: add lua_genlt comparison function to lua API
This commit is contained in:
@@ -312,6 +312,28 @@ LUA_API void lua_arith (lua_State *L, int op) {
|
|||||||
lua_unlock(L);
|
lua_unlock(L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LUA_API int lua_genlt (lua_State *L, int index1, int index2) {
|
||||||
|
StkId o1, o2;
|
||||||
|
int i = 0;
|
||||||
|
lua_lock(L); /* may call tag method */
|
||||||
|
o1 = index2addr(L, index1);
|
||||||
|
o2 = index2addr(L, index2);
|
||||||
|
int t1 = ttypenv(o1);
|
||||||
|
int t2 = ttypenv(o2);
|
||||||
|
if (t1 != t2) {
|
||||||
|
i = (t1 < t2);
|
||||||
|
} else if (t1 == LUA_TNUMBER) {
|
||||||
|
i = luai_numlt(L, nvalue(o1), nvalue(o2));
|
||||||
|
} else if (t1 == LUA_TSTRING) {
|
||||||
|
i = luaV_lessthan(L, o1, o2);
|
||||||
|
} else if (t1 == LUA_TBOOLEAN) {
|
||||||
|
i = bvalue(o1) < bvalue(o2);
|
||||||
|
} else {
|
||||||
|
luaG_ordererror(L, o1, o2);
|
||||||
|
}
|
||||||
|
lua_unlock(L);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
LUA_API int lua_compare (lua_State *L, int index1, int index2, int op) {
|
LUA_API int lua_compare (lua_State *L, int index1, int index2, int op) {
|
||||||
StkId o1, o2;
|
StkId o1, o2;
|
||||||
|
|||||||
@@ -20,6 +20,11 @@
|
|||||||
#include "lualib.h"
|
#include "lualib.h"
|
||||||
|
|
||||||
|
|
||||||
|
static int luaB_printaddr (lua_State *L) {
|
||||||
|
int n = lua_gettop(L);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
static int luaB_print (lua_State *L) {
|
static int luaB_print (lua_State *L) {
|
||||||
int n = lua_gettop(L); /* number of arguments */
|
int n = lua_gettop(L); /* number of arguments */
|
||||||
int i;
|
int i;
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ LUA_API void (lua_arith) (lua_State *L, int op);
|
|||||||
|
|
||||||
LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2);
|
LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2);
|
||||||
LUA_API int (lua_compare) (lua_State *L, int idx1, int idx2, int op);
|
LUA_API int (lua_compare) (lua_State *L, int idx1, int idx2, int op);
|
||||||
|
LUA_API int (lua_genlt) (lua_State *L, int idx1, int idx2);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** push functions (C -> stack)
|
** push functions (C -> stack)
|
||||||
|
|||||||
Reference in New Issue
Block a user