示例#1
0
文件: luaT.c 项目: Johnson13/xLearn
int luaT_lua_isequal(lua_State *L)
{
  if(lua_isuserdata(L, 1) && lua_isuserdata(L, 2))
  {
    void **u1, **u2;
    luaL_argcheck(L, luaT_id(L, 1), 1, "Torch object expected");
    luaL_argcheck(L, luaT_id(L, 2), 2, "Torch object expected");

    u1 = lua_touserdata(L, 1);
    u2 = lua_touserdata(L, 2);
    if(*u1 == *u2)
      lua_pushboolean(L, 1);
    else
      lua_pushboolean(L, 0);
  }
  else if(lua_istable(L, 1) && lua_istable(L, 2))
    lua_pushboolean(L, lua_rawequal(L, 1, 2));
  else
    lua_pushboolean(L, 0);
  return 1;
}
示例#2
0
文件: luaT.c 项目: highlevel/torch
int luaT_lua_id(lua_State *L)
{
  const void *id;

  luaL_checkany(L, 1);
  id = luaT_id(L, 1);
  if(id)
    lua_pushlightuserdata(L, (void*)id);
  else
    lua_pushnil(L);

  return 1;
}
示例#3
0
文件: luaT.c 项目: Johnson13/xLearn
int luaT_lua_pointer(lua_State *L)
{
  if(lua_isuserdata(L, 1))
  {
    void **ptr;
    luaL_argcheck(L, luaT_id(L, 1), 1, "Torch object expected");
    ptr = lua_touserdata(L, 1);
    lua_pushnumber(L, (long)(*ptr));
    return 1;
  }
  else if(lua_istable(L, 1) || lua_isthread(L, 1) || lua_isfunction(L, 1))
  {
    const void* ptr = lua_topointer(L, 1);
    lua_pushnumber(L, (long)(ptr));
    return 1;
  }
  else
    luaL_error(L, "Torch object, table, thread or function expected");

  return 0;
}