Ignore:
Timestamp:
03/08/16 13:19:59 (9 years ago)
Author:
epyon
Message:
  • temporary Lua 5.1 hardcode
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lua/lua_raw.cc

    r449 r490  
    3838void nlua_pushreversed( lua_State *L, int index )
    3939{
    40         index = lua_absindex( L, index );
    41         int len = static_cast<int>( lua_rawlen( L, index ) );
     40        index = nlua_absindex( L, index );
     41        int len = static_cast<int>( nlua_rawlen( L, index ) );
    4242        int i   = len;
    4343        lua_createtable( L, len, 0 );
     
    5353void nlua_shallowcopy( lua_State *L, int index )
    5454{
    55         index = lua_absindex( L, index );
     55        index = nlua_absindex( L, index );
    5656        lua_createtable( L, 0, 0 );
    5757        lua_pushnil( L );
     
    6767void nlua_shallowicopy( lua_State *L, int index )
    6868{
    69         index = lua_absindex( L, index );
     69        index = nlua_absindex( L, index );
    7070        lua_createtable( L, 0, 0 );
    7171        int i = 0;
     
    8585void nlua_shallowmerge( lua_State *L, int index )
    8686{
    87         index = lua_absindex( L, index );
     87        index = nlua_absindex( L, index );
    8888        lua_pushnil( L );
    8989
     
    9898void nlua_deepcopy( lua_State *L, int index )
    9999{
    100         index = lua_absindex( L, index );
     100        index = nlua_absindex( L, index );
    101101        lua_createtable( L, 0, 0 );
    102102        lua_pushnil( L );
     
    118118void nlua_toset( lua_State *L, int index )
    119119{
    120         index = lua_absindex( L, index );
     120        index = nlua_absindex( L, index );
    121121        lua_createtable( L, 0, 0 );
    122122        int i = 0;
     
    137137void nlua_tokeyset( lua_State *L, int index )
    138138{
    139         index = lua_absindex( L, index );
     139        index = nlua_absindex( L, index );
    140140        lua_createtable( L, 0, 0 );
    141141        lua_pushnil( L );
     
    151151void nlua_register( lua_State *L, const char* fname, lua_CFunction func, int index )
    152152{
    153         index = lua_absindex( L, index );
     153        index = nlua_absindex( L, index );
    154154        lua_pushstring( L, fname );
    155155        lua_pushcfunction( L, func );
     
    159159void nlua_register( lua_State *L, const luaL_Reg *l, int index )
    160160{
    161         index = lua_absindex( L, index );
     161        index = nlua_absindex( L, index );
    162162        for (; l->name != NULL; l++)
    163163        {
     
    200200void nlua_toflags( lua_State *L, int index, nv::uint8* data, nv::uint32 count )
    201201{
    202         index = lua_absindex( L, index );
     202        index = nlua_absindex( L, index );
    203203        nv::uint32 flag;
    204204        if ( lua_istable( L, index ) )
     
    222222void nlua_toflags_set( lua_State *L, int index, nv::uint8* data, nv::uint32 count )
    223223{
    224         index = lua_absindex( L, index );
     224        index = nlua_absindex( L, index );
    225225        nv::uint32 flag;
    226226        if ( lua_istable( L, index ) )
     
    241241void nlua_toflags_array( lua_State *L, int index, nv::uint8* data, nv::uint32 count )
    242242{
    243         index = lua_absindex( L, index );
     243        index = nlua_absindex( L, index );
    244244        nv::uint32 flag;
    245245        if ( lua_istable( L, index ) )
     
    260260nv::vector<nv::uint8> nlua_tobytearray( lua_State *L, int index )
    261261{
    262         index = lua_absindex( L, index );
     262        index = nlua_absindex( L, index );
    263263        nv::vector<nv::uint8> result;
    264264        if ( lua_istable( L, index ) )
     
    273273        return result;
    274274}
     275
     276void * nlua_testudata( lua_State *L, int ud, const char *tname )
     277{
     278        void *p = lua_touserdata( L, ud );
     279        if ( p != NULL )
     280        {
     281                if ( lua_getmetatable( L, ud ) )
     282                {
     283                        luaL_getmetatable( L, tname );
     284                        if ( !lua_rawequal( L, -1, -2 ) )
     285                                p = NULL;
     286                        lua_pop( L, 2 );
     287                        return p;
     288                }
     289        }
     290        return NULL;
     291}
     292
     293void nlua_setmetatable( lua_State *L, const char *tname )
     294{
     295        int only_works_for_51;
     296        luaL_getmetatable( L, tname );
     297        lua_setmetatable( L, -2 );
     298}
     299
     300void nlua_requiref( lua_State *L, const char *modname, lua_CFunction openf, int glb )
     301{
     302        int only_works_for_51;
     303        lua_pushcfunction( L, openf );
     304        lua_pushstring( L, modname );
     305        lua_call( L, 1, 1 );
     306        if ( glb != 0 )
     307        {
     308                lua_pushvalue( L, LUA_GLOBALSINDEX );
     309                lua_pushvalue( L, -2 );
     310                lua_setfield( L, -2, modname );
     311                lua_pop( L, 1 );
     312        }
     313}
     314
     315int nlua_rawlen( lua_State* L, int index )
     316{
     317        return lua_objlen( L, index );
     318}
     319
     320void nlua_pushglobaltable( lua_State* L )
     321{
     322        int only_works_for_51;
     323        lua_pushvalue( L, LUA_GLOBALSINDEX );
     324}
Note: See TracChangeset for help on using the changeset viewer.