Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#Actualfalconmick

Posted 06 April 2012 - 10:41 AM

ok, this is what is causing the problem.. maybe if u know luabind u can help...
I have multiple lua_States... This is because I don't want those who write scripts to be able to call functions that were not designed for execution during what they are doing, for example, I don't want the constructor calling keybinding configuration variables... to combat this I made an array of lua_State's
#HEADER#
lua_State **states;
#IMPLIMENTATION#
LuaInstances::LuaInstances()
{
states = new lua_State*[10]; // increase this to add more states
states[construction] = lua_open();
states[keyboard] = lua_open();
.....
when I debug, I can see that there are two diferent pointers inside of the states array...
then I call:
CompCompiler *example;
example = new CompCompiler();
which calls:
void CompCompiler::setupLuaBinds(lua_State *L)
{
luaL_openlibs(L);
luabind::open(L);
luabind::module(L)
  [
  luabind::class_<CompCompiler>("CompCompiler")
		.def(luabind::constructor<>())
	 .def("setSomeData",&CompCompiler::setSomeData)
		.def("setMoreData", &CompCompiler::setMoreData)
  .def("getSomeData", &CompCompiler::getSomeData)
  .def("getMoreData", &CompCompiler::getMoreData)
	 ];
lua_close(L);
}

This executes fine...

this is the problem:
luabind::open(L);
luabind::globals(L)["CompCompiler"] = example;
lua_close(L);
when I call luabind::open(L); it causes an Unhandled exception.. if I remove the lua_close(L); at the end of void CompCompiler::setupLuaBinds(lua_State *L), and remove the subsequent luabind::open(L); it goes through without a hitch... but I need to be able to close and open luabind states so I can keep the tools in which users use in a lua restricted... maybe namespaces can do this.. but I don't know.. because theres not enough documentation on it.

do you have ANY idea how I can setup a system which has multiple lua states so that I am able to restrict access to globals and functions when executing a lua file or a lua string?

EDIT:
so all of it works when I don't close the lua state.. so I know that my code is working (ive tested that it executes a lua, and it does, it even modifies the objects I give it) its just that I can't open/close a lua state, which I kinda need to be able to do

#1falconmick

Posted 06 April 2012 - 10:40 AM

ok, this is what is causing the problem.. maybe if u know luabind u can help...
I have multiple lua_States... This is because I don't want those who write scripts to be able to call functions that were not designed for execution during what they are doing, for example, I don't want the constructor calling keybinding configuration variables... to combat this I made an array of lua_State's
#HEADER#
lua_State **states;
#IMPLIMENTATION#
LuaInstances::LuaInstances()
{
states = new lua_State*[10]; // increase this to add more states
states[construction] = lua_open();
states[keyboard] = lua_open();
.....
when I debug, I can see that there are two diferent pointers inside of the states array...
then I call:
CompCompiler *example;
example = new CompCompiler();
which calls:
void CompCompiler::setupLuaBinds(lua_State *L)
{
luaL_openlibs(L);
luabind::open(L);
luabind::module(L)
  [
  luabind::class_<CompCompiler>("CompCompiler")
	    .def(luabind::constructor<>())
	 .def("setSomeData",&CompCompiler::setSomeData)
	    .def("setMoreData", &CompCompiler::setMoreData)
  .def("getSomeData", &CompCompiler::getSomeData)
  .def("getMoreData", &CompCompiler::getMoreData)
	 ];
lua_close(L);
}

This executes fine...

this is the problem:
luabind::open(L);
luabind::globals(L)["CompCompiler"] = example;
lua_close(L);
when I call luabind::open(L); it causes an Unhandled exception.. if I remove the lua_close(L); at the end of void CompCompiler::setupLuaBinds(lua_State *L), and remove the subsequent luabind::open(L); it goes through without a hitch... but I need to be able to close and open luabind states so I can keep the tools in which users use in a lua restricted... maybe namespaces can do this.. but I don't know.. because theres not enough documentation on it.

do you have ANY idea how I can setup a system which has multiple lua states so that I am able to restrict access to globals and functions when executing a lua file or a lua string?

PARTNERS