Ejemplo n.º 1
0
luaA_Type dt_lua_init_type_typeid(lua_State* L, const char*type_name,size_t size)
{
  luaA_Type my_type = luaA_type_add(type_name,size);
  luaL_newmetatable(L,type_name);

  lua_pushstring(L,type_name);
  lua_setfield(L,-2,"__luaA_TypeName");

  lua_pushnumber(L,my_type);
  lua_setfield(L,-2,"__luaA_Type");


  luaA_conversion_typeid(my_type,dt_lua_autotype_full_pushfunc,dt_lua_autotype_tofunc);

  lua_pushcfunction(L,dt_lua_autotype_next);
  lua_setfield(L,-2,"__next");

  lua_pushcfunction(L,dt_lua_autotype_pairs);
  lua_setfield(L,-2,"__pairs");

  lua_pushcfunction(L,dt_lua_autotype_index);
  lua_setfield(L,-2,"__index");

  lua_pushcfunction(L,dt_lua_autotype_newindex);
  lua_setfield(L,-2,"__newindex");

  lua_newtable(L);
  lua_setfield(L,-2,"__get");

  lua_newtable(L);
  lua_setfield(L,-2,"__set");
  // remove the metatable
  lua_pop(L,1);
  return my_type;
}
Ejemplo n.º 2
0
luaA_Type dt_lua_init_type_typeid(lua_State* L, luaA_Type type_id)
{
  luaL_newmetatable(L,luaA_type_name(type_id));

  lua_pushstring(L,luaA_type_name(type_id));
  lua_setfield(L,-2,"__luaA_TypeName");

  lua_pushnumber(L,type_id);
  lua_setfield(L,-2,"__luaA_Type");


  luaA_conversion_typeid(type_id,dt_lua_autotype_full_pushfunc,dt_lua_autotype_tofunc);

  lua_pushcfunction(L,dt_lua_autotype_next);
  lua_setfield(L,-2,"__next");

  lua_pushcfunction(L,dt_lua_autotype_pairs);
  lua_setfield(L,-2,"__pairs");

  lua_pushcfunction(L,dt_lua_autotype_index);
  lua_setfield(L,-2,"__index");

  lua_pushcfunction(L,dt_lua_autotype_newindex);
  lua_setfield(L,-2,"__newindex");

  lua_newtable(L);
  lua_setfield(L,-2,"__get");

  lua_newtable(L);
  lua_setfield(L,-2,"__set");
  // remove the metatable
  lua_pop(L,1);
  return type_id;
}