Jelajahi Sumber

extra options in 'testC' for newmetatable and testudata

Roberto Ierusalimschy 17 tahun lalu
induk
melakukan
92a0d4c67f
1 mengubah file dengan 8 tambahan dan 1 penghapusan
  1. 8 1
      ltests.c

+ 8 - 1
ltests.c

@@ -1,5 +1,5 @@
 /*
-** $Id: ltests.c,v 2.47 2008/02/19 18:55:09 roberto Exp roberto $
+** $Id: ltests.c,v 2.48 2008/04/02 17:38:54 roberto Exp roberto $
 ** Internal Module for Debugging of the Lua Implementation
 ** See Copyright Notice in lua.h
 */
@@ -1010,6 +1010,13 @@ static int testC (lua_State *L) {
       if (!lua_checkstack(L1, getnum))
         luaL_error(L, "C stack overflow");
     }
+    else if EQ("newmetatable") {
+      lua_pushboolean(L1, luaL_newmetatable(L1, getname));
+    }
+    else if EQ("testudata") {
+      int i = getindex;
+      lua_pushboolean(L1, luaL_testudata(L1, i, getname) != NULL);
+    }
     else if EQ("throw") {
 #if defined(__cplusplus)
 static struct X { int x; } x;