/* tolua: type & tag manipulation. ** Support code for Lua bindings. ** Written by Waldemar Celes ** TeCGraf/PUC-Rio ** Jul 1998 ** $Id: tolua_tt.c,v 1.2 2001/11/26 23:00:27 darkgod Exp $ */ /* This code is free software; you can redistribute it and/or modify it. ** The software provided hereunder is on an "as is" basis, and ** the author has no obligation to provide maintenance, support, updates, ** enhancements, or modifications. */ #include "tolua.h" #include "tolua_tt.h" #include "tolua_tm.h" #include "tolua_eh.h" #include "tolua_rg.h" #include #include #include /* Global tables created in Lua registry: tolua_tbl_itype: indexed by instance tags, stores the instance types. tolua_tbl_itag: indexed by instance types, stores the instance tags. tolua_tbl_const: indexed by constant tags, stores the tags. tolua_tbl_hierarchy: indexed by instance tags, stores the base tags. */ /* exported basic type tags */ int tolua_tag_nil; int tolua_tag_number; int tolua_tag_string; int tolua_tag_userdata; int tolua_tag_table; int tolua_tag_function; static const char* gettype (lua_State* L, int tag) { const char* type; toluaI_getregistry(L,"tolua_tbl_itype"); lua_pushnumber(L,tag); lua_gettable(L,-2); type = lua_tostring(L,-1); if (type==NULL) type = "[undefined]"; lua_pop(L,2); return type; } const char* toluaI_tt_getobjtype (lua_State* L, int lo) { if (lua_gettop(L)=abs(narg)) { toluaI_eh_set(L,narg,toluaI_tt_getobjtype(L,narg), toluaI_tt_getobjtype(L,lua_gettop(L)+1)); return 0; } return 1; }