void *luaL_testudata (lua_State *L, int ud, const char *tname) {
void *p = lua_touserdata(L, ud);
if (p != NULL) { /* value is a userdata? */
if (lua_getmetatable(L, ud)) { /* does it have a metatable? */
lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get correct metatable */
if (lua_rawequal(L, -1, -2)) { /* does it have the correct mt? */
lua_pop(L, 2); /* remove both metatables */
return p;
}
}
}
return NULL; /* to avoid warnings */
}
最近變更 · 喜好設定
編輯 · 歷史記錄
最近在 2009 年 1 月 11 日 格林威治標準時間上午 4:40 編輯 (diff)