lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



Gyorgy Bozoki wrote:
Is there a way to learn what functions are defined when I call lua_dofile() /
lua_dostring()? And using this information, is there a way to programmatically
undefine these functions?

Here is an example to help you get started.

  lua_newtable(L);  /* new stuff */
  lua_newtable(L);  /* metatable */
  lua_pushliteral(L, "__index");
  lua_pushvalue(L, -3);
  lua_settable(L, -3);
  lua_pushliteral(L, "__newindex");
  lua_pushvalue(L, -3);
  lua_settable(L, -3);
  lua_setmetatable(L, LUA_GLOBALSINDEX);
  lua_setglobal(L, "newstuff");

  lua_dofile(L, "x.lua");

  lua_pushnil(L);
  lua_setmetatable(L, LUA_GLOBALSINDEX);

- Peter