summaryrefslogtreecommitdiff
path: root/iup/srclua5/il_tree_aux.c
diff options
context:
space:
mode:
authorNicolas "Pixel" Noble <pixel@nobis-crew.org>2010-09-09 02:26:30 +0200
committerNicolas "Pixel" Noble <pixel@nobis-crew.org>2010-09-09 02:32:26 +0200
commit7505e88db66798b2b8fcdff2d92a7136cd826b5b (patch)
treeb6ced565318f8e8112e35cb0ad53abe4212ef8de /iup/srclua5/il_tree_aux.c
parente9a184546b18cf3b796bd560561f312934004c54 (diff)
Upgrading to IUP 3.2 - and cleaning up.
Diffstat (limited to 'iup/srclua5/il_tree_aux.c')
-rwxr-xr-xiup/srclua5/il_tree_aux.c40
1 files changed, 19 insertions, 21 deletions
diff --git a/iup/srclua5/il_tree_aux.c b/iup/srclua5/il_tree_aux.c
index 6ebaa09..439d897 100755
--- a/iup/srclua5/il_tree_aux.c
+++ b/iup/srclua5/il_tree_aux.c
@@ -19,33 +19,33 @@
Given an ID, to retreive a Lua object is quite simple.
But given a user_id to obtain the ID is more complicated.
- The IUPTREEREFTABLE is used to do this mapping.
+ The iup.TREEREFTABLE is used to do this mapping.
We use the object as the index to this table.
*/
-/* iup.IUPTREEREFTABLE[object at pos] = ref */
+/* iup.TREEREFTABLE[object at pos] = ref */
static void tree_settableref(lua_State *L, int pos, int ref)
{
lua_getglobal(L, "iup");
- lua_pushstring(L, "IUPTREEREFTABLE");
+ lua_pushstring(L, "TREEREFTABLE");
lua_gettable(L, -2);
- lua_remove(L, -2);
+ lua_remove(L, -2); /* remove "iup" from stack */
lua_pushvalue(L, pos);
if(ref == LUA_NOREF)
lua_pushnil(L);
else
- lua_pushnumber(L, ref);
+ lua_pushinteger(L, ref);
lua_settable(L, -3);
lua_pop(L, 1);
}
-/* ref = iup.IUPTREEREFTABLE[object at pos] */
+/* ref = iup.TREEREFTABLE[object at pos] */
static int tree_gettableref(lua_State *L, int pos)
{
lua_getglobal(L, "iup");
- lua_pushstring(L, "IUPTREEREFTABLE");
+ lua_pushstring(L, "TREEREFTABLE");
lua_gettable(L, -2);
- lua_remove(L, -2);
+ lua_remove(L, -2); /* remove "iup" from stack */
lua_pushvalue(L, pos);
lua_gettable(L, -2);
if (lua_isnil(L, -1))
@@ -55,7 +55,7 @@ static int tree_gettableref(lua_State *L, int pos)
}
else
{
- int ref = (int) lua_tonumber(L, -1);
+ int ref = lua_tointeger(L, -1);
lua_pop(L, 1);
return ref;
}
@@ -91,7 +91,7 @@ static int TreeGetId(lua_State *L)
if (id == -1)
lua_pushnil(L);
else
- lua_pushnumber(L, id);
+ lua_pushinteger(L, id);
}
return 1;
}
@@ -99,7 +99,7 @@ static int TreeGetId(lua_State *L)
static int TreeGetUserId(lua_State *L)
{
Ihandle *ih = iuplua_checkihandle(L,1);
- int id = (int)luaL_checknumber(L,2);
+ int id = luaL_checkinteger(L,2);
tree_push_userid(L, IupTreeGetUserId(ih, id));
return 1;
}
@@ -107,7 +107,7 @@ static int TreeGetUserId(lua_State *L)
static int TreeSetUserId(lua_State *L)
{
Ihandle *ih = iuplua_checkihandle(L,1);
- int id = (int)luaL_checknumber(L,2);
+ int id = luaL_checkinteger(L,2);
int ref = (int)IupTreeGetUserId(ih, id);
if (ref != 0) /* userid is not NULL */
{
@@ -130,7 +130,7 @@ static int TreeSetUserId(lua_State *L)
tree_settableref(L, 3, ref);
if (ref >= 0) ref++; /* only positive references are shifted */
- IupTreeSetUserId(ih, id, (char*)ref);
+ IupTreeSetUserId(ih, id, (void*)ref);
}
return 0;
@@ -143,11 +143,11 @@ static int tree_multiselection_cb(Ihandle *ih, int* ids, int p1)
lua_newtable(L);
for (i = 0; i < p1; i++)
{
- lua_pushnumber(L,i+1);
- lua_pushnumber(L,ids[i]);
+ lua_pushinteger(L,i+1);
+ lua_pushinteger(L,ids[i]);
lua_settable(L,-3);
}
- lua_pushnumber(L, p1);
+ lua_pushinteger(L, p1);
return iuplua_call(L, 2);
}
@@ -158,11 +158,11 @@ static int tree_multiunselection_cb(Ihandle *ih, int* ids, int p1)
lua_newtable(L);
for (i = 0; i < p1; i++)
{
- lua_pushnumber(L,i+1);
- lua_pushnumber(L,ids[i]);
+ lua_pushinteger(L,i+1);
+ lua_pushinteger(L,ids[i]);
lua_settable(L,-3);
}
- lua_pushnumber(L, p1);
+ lua_pushinteger(L, p1);
return iuplua_call(L, 2);
}
@@ -175,8 +175,6 @@ static int tree_noderemoved_cb(Ihandle *ih, void* p1)
void iuplua_treefuncs_open (lua_State *L)
{
- iuplua_dostring(L, "IUPTREEREFTABLE={}", "");
-
iuplua_register_cb(L, "MULTISELECTION_CB", (lua_CFunction)tree_multiselection_cb, NULL);
iuplua_register_cb(L, "MULTIUNSELECTION_CB", (lua_CFunction)tree_multiunselection_cb, NULL);
iuplua_register_cb(L, "NODEREMOVED_CB", (lua_CFunction)tree_noderemoved_cb, NULL);