Ignore:
Timestamp:
06/19/14 00:02:55 (11 years ago)
Author:
epyon
Message:
  • major decoupling lua system independent of nv::object nv::object support for lua opt-in lua system independent of types.hh
File:
1 edited

Legend:

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

    r213 r262  
    88
    99#include "nv/lua/lua_raw.hh"
    10 #include "nv/object.hh"
    1110
    1211using nv::lua::linteger;
     
    7170}
    7271
    73 void nv::lua::detail::push_object  ( lua_State *L, object* o )
    74 {
    75         if ( o == nullptr )
    76         {
    77                 lua_pushnil( L );
    78         }
    79         else
    80         {
    81                 lua_rawgeti( L, LUA_REGISTRYINDEX, o->get_lua_index() );
    82         }
    83 }
    84 
    8572void nv::lua::detail::push_pointer ( lua_State *L, void* p )
    8673{
     
    118105}
    119106
    120 nv::object* nv::lua::detail::to_object ( lua_State *L, int index )
     107void*       nv::lua::detail::to_pointer ( lua_State *L, int index )
    121108{
    122         object* o = nullptr;
     109        return lua_touserdata( L, index );
     110}
     111
     112void* nv::lua::detail::to_ref_object  ( lua_State *L, int index )
     113{
     114        void* o = nullptr;
    123115        if ( lua_istable( L , index ) )
    124116        {
     
    127119                if ( lua_isuserdata( L, -1 ) )
    128120                {
    129                         o = static_cast<object*>( lua_touserdata( L, -1 ) );
     121                        o = lua_touserdata( L, -1 );
    130122                }
    131123                lua_pop( L, 1 );
    132124        }
    133125        return o;
    134 }
    135 
    136 void*       nv::lua::detail::to_pointer ( lua_State *L, int index )
    137 {
    138         return lua_touserdata( L, index );
    139126}
    140127
     
    169156}
    170157
    171 nv::object* nv::lua::detail::to_object  ( lua_State *L, int index, nv::object* def )
     158void*       nv::lua::detail::to_pointer ( lua_State *L, int index, void* def )
    172159{
    173         object* o = def;
     160        return ( lua_type( L, index ) == LUA_TUSERDATA ? lua_touserdata( L, index ) : def );
     161}
     162
     163void* nv::lua::detail::to_ref_object( lua_State *L, int index, void* def )
     164{
     165        void* o = def;
    174166        if ( lua_istable( L , index ) )
    175167        {
     
    178170                if ( lua_isuserdata( L, -1 ) )
    179171                {
    180                         o = static_cast<object*>( lua_touserdata( L, -1 ) );
     172                        o = lua_touserdata( L, -1 );
    181173                }
    182174                lua_pop( L, 1 );
     
    184176        return o;
    185177}
    186 
    187 void*       nv::lua::detail::to_pointer ( lua_State *L, int index, void* def )
    188 {
    189         return ( lua_type( L, index ) == LUA_TUSERDATA ? lua_touserdata( L, index ) : def );
    190 }
Note: See TracChangeset for help on using the changeset viewer.