/[enigma]/enigma/lib-src/lua/tolua_tt.c
ViewVC logotype

Diff of /enigma/lib-src/lua/tolua_tt.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by dheck, Sun Feb 9 21:30:32 2003 UTC revision 1.2 by reallysoft, Mon May 19 12:12:43 2003 UTC
# Line 6  Line 6 
6  ** $Id$  ** $Id$
7  */  */
8    
9  /* This code is free software; you can redistribute it and/or modify it.  /* This code is free software; you can redistribute it and/or modify it.
10  ** The software provided hereunder is on an "as is" basis, and  ** The software provided hereunder is on an "as is" basis, and
11  ** the author has no obligation to provide maintenance, support, updates,  ** the author has no obligation to provide maintenance, support, updates,
12  ** enhancements, or modifications.  ** enhancements, or modifications.
13  */  */
14    
15  #include "tolua.h"  #include "tolua.h"
# Line 58  const char* toluaI_tt_getobjtype (lua_St Line 58  const char* toluaI_tt_getobjtype (lua_St
58    return gettype(L,lua_tag(L,lo));    return gettype(L,lua_tag(L,lo));
59  }  }
60    
61  int toluaI_tt_gettag (lua_State* L, char* type)  int toluaI_tt_gettag (lua_State* L, const char* type)
62  {  {
63   int tag;   int tag;
64   toluaI_getregistry(L,"tolua_tbl_itag");   toluaI_getregistry(L,"tolua_tbl_itag");
# Line 84  static int istype (lua_State* L, int lo, Line 84  static int istype (lua_State* L, int lo,
84   int otag = lua_tag(L,lo);   int otag = lua_tag(L,lo);
85   if (tag==otag)         /* check simplest case */   if (tag==otag)         /* check simplest case */
86    return 1;    return 1;
87   else if (lua_isnil(L,lo) &&   else if (lua_isnil(L,lo) &&
88            tag!=LUA_TNUMBER &&            tag!=LUA_TNUMBER &&
89            tag!=LUA_TTABLE &&            tag!=LUA_TTABLE &&
90            tag!=LUA_TFUNCTION            tag!=LUA_TFUNCTION
# Line 113  static int istype (lua_State* L, int lo, Line 113  static int istype (lua_State* L, int lo,
113    /* check for base classes */    /* check for base classes */
114    toluaI_getregistry(L,"tolua_tbl_hierarchy");    toluaI_getregistry(L,"tolua_tbl_hierarchy");
115    tbl_hierarchy = lua_gettop(L);    tbl_hierarchy = lua_gettop(L);
116    otag = basetag(L,tbl_hierarchy,otag);      otag = basetag(L,tbl_hierarchy,otag);
117    while (otag)    while (otag)
118    {    {
119     if (tag==otag || (tag2 && tag2==otag))     if (tag==otag || (tag2 && tag2==otag))
# Line 140  void toluaI_tt_init (lua_State* L) Line 140  void toluaI_tt_init (lua_State* L)
140   lua_pushnumber(L,LUA_TUSERDATA); toluaI_setregistry(L,"tolua_tag_userdata");   lua_pushnumber(L,LUA_TUSERDATA); toluaI_setregistry(L,"tolua_tag_userdata");
141   lua_pushnumber(L,LUA_TTABLE); toluaI_setregistry(L,"tolua_tag_table");   lua_pushnumber(L,LUA_TTABLE); toluaI_setregistry(L,"tolua_tag_table");
142   lua_pushnumber(L,LUA_TFUNCTION); toluaI_setregistry(L,"tolua_tag_function");   lua_pushnumber(L,LUA_TFUNCTION); toluaI_setregistry(L,"tolua_tag_function");
143    
144   toluaI_tt_register(L,toluaI_tt_gettag(L,"tolua_tag_nil"),"nil");   toluaI_tt_register(L,toluaI_tt_gettag(L,"tolua_tag_nil"),"nil");
145   toluaI_tt_register(L,toluaI_tt_gettag(L,"tolua_tag_number"),"number");   toluaI_tt_register(L,toluaI_tt_gettag(L,"tolua_tag_number"),"number");
146   toluaI_tt_register(L,toluaI_tt_gettag(L,"tolua_tag_string"),"string");   toluaI_tt_register(L,toluaI_tt_gettag(L,"tolua_tag_string"),"string");
# Line 159  void toluaI_tt_init (lua_State* L) Line 159  void toluaI_tt_init (lua_State* L)
159  }  }
160    
161    
162  void toluaI_tt_register (lua_State* L, int tag, char* type)  void toluaI_tt_register (lua_State* L, int tag, const char* type)
163  {  {
164   toluaI_getregistry(L,"tolua_tbl_itype");   toluaI_getregistry(L,"tolua_tbl_itype");
165   lua_pushnumber(L,tag);   lua_pushnumber(L,tag);
# Line 175  void toluaI_tt_register (lua_State* L, i Line 175  void toluaI_tt_register (lua_State* L, i
175  }  }
176    
177    
178  void toluaI_tt_class (lua_State* L, int lo, char* derived, char* base)  void toluaI_tt_class (lua_State* L, int lo, const char* derived, const char* base)
179  {  {
180   char* cderived = toluaI_tt_concat("const ",derived);   char* cderived = toluaI_tt_concat("const ",derived);
181   int tag = toluaI_tt_gettag(L,derived);   int tag = toluaI_tt_gettag(L,derived);
# Line 208  char* toluaI_tt_concat (const char* s1, Line 208  char* toluaI_tt_concat (const char* s1,
208   return strcat(strcpy(s,s1),s2);   return strcat(strcpy(s,s1),s2);
209  }  }
210    
211  void tolua_usertype (lua_State* L, char* type)  void tolua_usertype (lua_State* L, const char* type)
212  {  {
213   /* check if type is already registered */   /* check if type is already registered */
214   toluaI_getregistry(L,"tolua_tbl_itag");   toluaI_getregistry(L,"tolua_tbl_itag");
# Line 223  void tolua_usertype (lua_State* L, char* Line 223  void tolua_usertype (lua_State* L, char*
223    toluaI_tt_register(L,ctag,ctype);    toluaI_tt_register(L,ctag,ctype);
224    /* set const table */    /* set const table */
225    toluaI_getregistry(L,"tolua_tbl_const");    toluaI_getregistry(L,"tolua_tbl_const");
226    lua_pushnumber(L,ctag);    lua_pushnumber(L,ctag);
227    lua_pushnumber(L,tag);    lua_pushnumber(L,tag);
228    lua_settable(L,-3);    lua_settable(L,-3);
229    lua_pop(L,1);    lua_pop(L,1);
230   }   }
# Line 233  void tolua_usertype (lua_State* L, char* Line 233  void tolua_usertype (lua_State* L, char*
233    
234  int toluaI_tt_isusertype (lua_State* L, int lo)  int toluaI_tt_isusertype (lua_State* L, int lo)
235  {  {
236   if (lua_isuserdata(L,lo) &&   if (lua_isuserdata(L,lo) &&
237       toluaI_tt_gettag(L,"tolua_tag_userdata")!=lua_tag(L,lo)       toluaI_tt_gettag(L,"tolua_tag_userdata")!=lua_tag(L,lo)
238      )      )
239   {   {
# Line 307  int tolua_isnoobj (lua_State* L, int nar Line 307  int tolua_isnoobj (lua_State* L, int nar
307   if (lua_gettop(L)>=abs(narg))   if (lua_gettop(L)>=abs(narg))
308   {   {
309    toluaI_eh_set(L,narg,toluaI_tt_getobjtype(L,narg),    toluaI_eh_set(L,narg,toluaI_tt_getobjtype(L,narg),
310                  toluaI_tt_getobjtype(L,lua_gettop(L)+1));                  toluaI_tt_getobjtype(L,lua_gettop(L)+1));
311    return 0;    return 0;
312   }   }
313   return 1;   return 1;

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26