Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 9, 2009, 4:29:42 PM (15 years ago)
Author:
rgrieder
Message:

Update to tolua 1.0.93

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/pch/src/tolua/tolua_is.c

    r2710 r3127  
    8686}
    8787
    88 TOLUA_API void tolua_error (lua_State* L, char* msg, tolua_Error* err)
     88TOLUA_API void tolua_error (lua_State* L, const char* msg, tolua_Error* err)
    8989{
    9090        if (msg[0] == '#')
     
    117117
    118118/* the equivalent of lua_is* for usertable */
    119 static  int lua_isusertable (lua_State* L, int lo, const char* type)
     119static  int lua_isusertable (lua_State* L, int lo, const const char* type)
    120120{
    121121        int r = 0;
     
    213213 return 0;
    214214}
     215
     216TOLUA_API int tolua_isboolean (lua_State* L, int lo, int def, tolua_Error* err)
     217{
     218        if (def && lua_gettop(L)<abs(lo))
     219                return 1;
     220        if (lua_isnil(L,lo) || lua_isboolean(L,lo))
     221                return 1;
     222        err->index = lo;
     223        err->array = 0;
     224        err->type = "boolean";
     225        return 0;
     226}
     227
     228TOLUA_API int tolua_isnumber (lua_State* L, int lo, int def, tolua_Error* err)
     229{
     230        if (def && lua_gettop(L)<abs(lo))
     231                return 1;
     232        if (lua_isnumber(L,lo))
     233                return 1;
     234        err->index = lo;
     235        err->array = 0;
     236        err->type = "number";
     237        return 0;
     238}
     239
     240TOLUA_API int tolua_isstring (lua_State* L, int lo, int def, tolua_Error* err)
     241{
     242        if (def && lua_gettop(L)<abs(lo))
     243                return 1;
     244 if (lua_isnil(L,lo) || lua_isstring(L,lo))
     245                return 1;
     246        err->index = lo;
     247        err->array = 0;
     248        err->type = "string";
     249        return 0;
     250}
     251
     252TOLUA_API int tolua_istable (lua_State* L, int lo, int def, tolua_Error* err)
     253{
     254        if (def && lua_gettop(L)<abs(lo))
     255                return 1;
     256        if (lua_istable(L,lo))
     257                return 1;
     258        err->index = lo;
     259        err->array = 0;
     260        err->type = "table";
     261        return 0;
     262}
     263
     264TOLUA_API int tolua_isusertable (lua_State* L, int lo, const char* type, int def, tolua_Error* err)
     265{
     266        if (def && lua_gettop(L)<abs(lo))
     267                return 1;
     268        if (lua_isusertable(L,lo,type))
     269                return 1;
     270        err->index = lo;
     271        err->array = 0;
     272        err->type = type;
     273        return 0;
     274}
     275
     276
     277TOLUA_API int tolua_isuserdata (lua_State* L, int lo, int def, tolua_Error* err)
     278{
     279        if (def && lua_gettop(L)<abs(lo))
     280                return 1;
     281        if (lua_isnil(L,lo) || lua_isuserdata(L,lo))
     282                return 1;
     283        err->index = lo;
     284        err->array = 0;
     285        err->type = "userdata";
     286        return 0;
     287}
     288
     289TOLUA_API int tolua_isvaluenil (lua_State* L, int lo, tolua_Error* err) {
     290
     291        if (lua_gettop(L)<abs(lo))
     292                return 0; /* somebody else should chack this */
     293        if (!lua_isnil(L, lo))
     294                return 0;
     295       
     296        err->index = lo;
     297        err->array = 0;
     298        err->type = "value";
     299        return 1;
     300};
     301
    215302TOLUA_API int tolua_isvalue (lua_State* L, int lo, int def, tolua_Error* err)
    216303{
     
    220307        err->array = 0;
    221308        err->type = "value";
    222         return 0;
    223 }
    224 
    225 TOLUA_API int tolua_isboolean (lua_State* L, int lo, int def, tolua_Error* err)
    226 {
    227         if (def && lua_gettop(L)<abs(lo))
    228                 return 1;
    229         if (lua_isnil(L,lo) || lua_isboolean(L,lo))
    230                 return 1;
    231         err->index = lo;
    232         err->array = 0;
    233         err->type = "boolean";
    234         return 0;
    235 }
    236 
    237 TOLUA_API int tolua_isnumber (lua_State* L, int lo, int def, tolua_Error* err)
    238 {
    239         if (def && lua_gettop(L)<abs(lo))
    240                 return 1;
    241         if (lua_isnumber(L,lo))
    242                 return 1;
    243         err->index = lo;
    244         err->array = 0;
    245         err->type = "number";
    246         return 0;
    247 }
    248 
    249 TOLUA_API int tolua_isstring (lua_State* L, int lo, int def, tolua_Error* err)
    250 {
    251         if (def && lua_gettop(L)<abs(lo))
    252                 return 1;
    253  if (lua_isnil(L,lo) || lua_isstring(L,lo))
    254                 return 1;
    255         err->index = lo;
    256         err->array = 0;
    257         err->type = "string";
    258         return 0;
    259 }
    260 
    261 TOLUA_API int tolua_istable (lua_State* L, int lo, int def, tolua_Error* err)
    262 {
    263         if (def && lua_gettop(L)<abs(lo))
    264                 return 1;
    265         if (lua_istable(L,lo))
    266                 return 1;
    267         err->index = lo;
    268         err->array = 0;
    269         err->type = "table";
    270         return 0;
    271 }
    272 
    273 TOLUA_API int tolua_isusertable (lua_State* L, int lo, const char* type, int def, tolua_Error* err)
    274 {
    275         if (def && lua_gettop(L)<abs(lo))
    276                 return 1;
    277         if (lua_isusertable(L,lo,type))
    278                 return 1;
    279         err->index = lo;
    280         err->array = 0;
    281         err->type = type;
    282         return 0;
    283 }
    284 
    285 
    286 TOLUA_API int tolua_isuserdata (lua_State* L, int lo, int def, tolua_Error* err)
    287 {
    288         if (def && lua_gettop(L)<abs(lo))
    289                 return 1;
    290         if (lua_isnil(L,lo) || lua_isuserdata(L,lo))
    291                 return 1;
    292         err->index = lo;
    293         err->array = 0;
    294         err->type = "userdata";
    295309        return 0;
    296310}
Note: See TracChangeset for help on using the changeset viewer.