- case LUA_TTABLE:
- p += sprintf(p, "Table");
- break;
-
- default: /* other values */
- p += sprintf(p, "???");
-/* if ((ptr = luaL_checkudata(L,i,TASK_MODULE_NAME))) {
- p+=sprintf(p,"task");
- } else {
- p+=printf(p,"%s", lua_typename(L, t));
- }*/
- break;
-
- }
- p += sprintf(p, " "); /* put a separator */
- }
- INFO2("%s%s", msg, buff);
+/*
+static void *my_checkudata (lua_State *L, int ud, const char *tname) {
+ void *p = lua_touserdata(L, ud);
+ lua_getfield(L, LUA_REGISTRYINDEX, tname);
+ const void* correct_mt = lua_topointer(L, -1);
+
+ int has_mt = lua_getmetatable(L, ud);
+ const void* actual_mt = NULL;
+ if (has_mt) { actual_mt = lua_topointer(L, -1); lua_pop(L, 1); }
+ XBT_DEBUG("Checking the task's metatable: expected %p, found %p", correct_mt, actual_mt);
+ stack_dump("my_checkudata: ", L);
+
+ if (p == NULL || !lua_getmetatable(L, ud) || !lua_rawequal(L, -1, -2))
+ luaL_typerror(L, ud, tname);
+ lua_pop(L, 2);
+ return p;