From: Christophe ThiƩry Date: Thu, 10 Nov 2011 13:13:31 +0000 (+0100) Subject: Don't protect access to the metatable from Lua. X-Git-Tag: exp_20120216~345 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/efd201684c340bfd7508b656bdbc59f57e7e7c67?hp=d2d9f8b0f434e881d124d81f655fc9ebb6f31199 Don't protect access to the metatable from Lua. Lua code can never change the metatable of a userdata anyway (setmetatable is possible only for a table). getmetatable is now allowed for tasks and hosts: it's harmless and lets people extend them. --- diff --git a/src/bindings/lua/simgrid_lua.c b/src/bindings/lua/simgrid_lua.c index 9de044a556..3496588228 100644 --- a/src/bindings/lua/simgrid_lua.c +++ b/src/bindings/lua/simgrid_lua.c @@ -858,12 +858,6 @@ static void register_task_functions(lua_State* L) { // writing doesn't work lua_setfield(L, -2, "__index"); /* simgrid.task mt */ - lua_pushliteral(L, "__metatable"); - /* simgrid.task mt "__metatable" */ - lua_pushnumber(L, 0); - /* simgrid.task mt "__metatable" 0 */ - /* protect the metatable from Lua code (by setting any value to __metatable) */ - lua_rawset(L, -3); /* simgrid.task mt */ lua_pop(L, 2); /* -- */ } @@ -896,12 +890,6 @@ static void register_host_functions(lua_State* L) { // FIXME: cannot work currently, same problem as tasks lua_setfield(L, -2, "__index"); /* simgrid.host mt */ - lua_pushliteral(L, "__metatable"); - /* simgrid.host mt "__metatable" */ - lua_pushnumber(L, 0); - /* simgrid.host mt "__metatable" 0 */ - /* protect the metatable from Lua code (by setting any value to __metatable) */ - lua_rawset(L, -3); /* simgrid.host mt */ lua_pop(L, 2); /* -- */ }