Ejemplo n.º 1
0
static void settag (void)
{
  lua_Object o = luaL_tablearg(1);
  lua_pushobject(o);
  lua_settag((int32)luaL_check_number(2));
  lua_pushobject(o);  /* returns first argument */
}
Ejemplo n.º 2
0
static void closefile(const char *name) {
	LuaFile *f = getfile(name);
	f->close();
	lua_pushobject(lua_getglobal(name));
	lua_settag(gettag(CLOSEDTAG));
	delete f;
}
Ejemplo n.º 3
0
int luaCompat_newTypedObject(lua_State* L, void* object)
{  /* lua4 */
  int newreference = 0;
  int tag = 0;

  LUASTACK_SET(L);

  luaL_checktype(L, -1, LUA_TNUMBER);

  tag = (int) lua_tonumber(L, -1);

  lua_pop(L, 1);

  /* pushes userdata */
  lua_pushusertag(L, object, LUA_ANYTAG);

  if(lua_tag(L, -1) != tag)
  {
    /* this is the first userdata with this value,
       so corrects the tag */
    lua_settag(L, tag);
    newreference = 1;
  }

  LUASTACK_CLEAN(L, 0);

  return newreference;
}
Ejemplo n.º 4
0
static int luaB_settag (lua_State *L)
{
    luaL_checktype(L, 1, LUA_TTABLE);
    lua_pushvalue(L, 1);  /* push table */
    lua_settag(L, luaL_check_int(L, 2));
    return 1;  /* return table */
}
Ejemplo n.º 5
0
SCRIPT_USER_DATA CScriptSystem::CreateUserData(CDynamicType* userData)
{
    USER_DATA_CHUNK* pUDC = (USER_DATA_CHUNK*)lua_newuserdata(m_pLS, sizeof(USER_DATA_CHUNK));
    pUDC->userData = userData;
    lua_settag(m_pLS, m_nGCTag);
    pUDC->nRef = lua_ref(m_pLS, 0);
    return pUDC->nRef;
}
Ejemplo n.º 6
0
static int closefile (lua_State *L, IOCtrl *ctrl, FILE *f) {
  if (f == stdin || f == stdout || f == stderr)
    return 1;
  else {
    lua_pushusertag(L, f, ctrl->iotag);
    lua_settag(L, ctrl->closedtag);
    return (CLOSEFILE(L, f) == 0);
  }
}
Ejemplo n.º 7
0
Archivo: liolib.c Proyecto: jeske/hz
static void closefile (char *name)
{
  FILE *f = getfile(name);
  if (f == stdin || f == stdout) return;
  if (pclose(f) == -1)
    fclose(f);
  lua_pushobject(lua_getglobal(name));
  lua_settag(gettag(CLOSEDTAG));
}
Ejemplo n.º 8
0
void tolua_instance (lua_State* L, int instance, int classobj)
{
 int tag;
 lua_pushvalue(L,classobj);
 lua_pushstring(L,".itag");
 lua_gettable(L,-2);
 tag = (int) lua_tonumber(L,-1);
 lua_pop(L,2);  /* number and table */
 if (tag==0)
  tolua_error(L,"unregistered 'classobj' in function 'tolua_instance'.");
 lua_pushvalue(L,instance);
 lua_settag(L,tag);
 lua_pop(L,1);
}
Ejemplo n.º 9
0
void tolua_globalarray (lua_State* L, const char* name, lua_CFunction get, lua_CFunction set)
{
 int tag = lua_newtag(L);
 lua_newtable(L);
 lua_settag(L,tag);
 lua_setglobal(L,name);
 
 lua_pushcfunction(L,get);
 lua_settagmethod(L,tag,"gettable"); 
 if (set)
  lua_pushcfunction(L,set);
 else
  lua_pushcfunction(L,toluaI_const_global_array);
 lua_settagmethod(L,tag,"settable");
}
Ejemplo n.º 10
0
void luaCompat_setType(lua_State* L, int index)
{ /* lua4 */

  LUASTACK_SET(L);

  int tag = lua_tonumber(L, -1);

  lua_pushvalue(L, index);

  lua_settag(L, tag);

  lua_pop(L, 2);

  LUASTACK_CLEAN(L, -1);
}
Ejemplo n.º 11
0
static int py_convert_custom(lua_State *L, PyObject *pobj, int asindx) {
    Py_INCREF(pobj);
    Py_INCREF(pobj);

    lua_Object ltable = lua_createtable(L);

    set_table_userdata(L, ltable, POBJECT, pobj);
    set_table_number(L, ltable, ASINDX, asindx);

    // register all tag methods
    int tag = get_base_tag(L);
    lua_pushobject(L, ltable);
    lua_settag(L, tag);

    // returning table
    lua_pushobject(L, ltable);
    return 1;
}
Ejemplo n.º 12
0
void tolua_tablearray
(lua_State* L, const char* table, const char* name, lua_CFunction get, lua_CFunction set)
{
 int tag = lua_newtag(L);
 lua_getglobal(L,table);
 lua_pushstring(L,".array");
 lua_rawget(L,-2);
 lua_pushstring(L,name);
 lua_newtable(L);
 lua_settag(L,tag);
 lua_settable(L,-3);
 lua_pop(L,2);

 lua_pushcfunction(L,get);
 lua_settagmethod(L,tag,"gettable");
 if (set)
  lua_pushcfunction(L,set);
 else
  lua_pushcfunction(L,toluaI_const_array);
 lua_settagmethod(L,tag,"settable");

 tolua_tablevar(L,table,name,toluaI_get_array,NULL);
}
Ejemplo n.º 13
0
/* Register module */
LUA_API int luaopen_python(lua_State *L) {
    lua_Object python = lua_createtable(L);

    lua_pushobject(L, python);
    lua_setglobal(L, "python");  // api python

    int index = 0;
    while (py_lib[index].name) {
        set_table_fn(L, python, py_lib[index].name, py_lib[index].func);
        index++;
    }

    set_table_userdata(L, python, "True", Py_True);
    set_table_userdata(L, python, "False", Py_False);

    // base python object
    lua_Object ltable = lua_createtable(L);
    set_table_object(L, python, POBJECT, ltable);

    // register all tag methods
    int ntag = lua_newtag(L);
    index = 0;
    while (lua_tag_methods[index].name) {
        lua_pushcfunction(L, lua_tag_methods[index].func);
        lua_settagmethod(L, ntag, lua_tag_methods[index].name);
        index++;
    }

    // set tag
    lua_pushobject(L, ltable);
    lua_settag(L, ntag);

    // try startup system
    // python_system_init(L);
    return 0;
}
Ejemplo n.º 14
0
static void settag() {
	lua_Object o = luaL_tablearg(1);
	lua_pushobject(o);
	lua_settag((int32)luaL_check_number(2));
}
Ejemplo n.º 15
0
static void luaB_settag (void) {
  lua_Object o = luaL_tablearg(1);
  lua_pushobject(o);
  lua_settag(luaL_check_int(2));
  lua_pushobject(o);  /* return first argument */
}