Changeset 262 for trunk/src/lua/lua_values.cc
- Timestamp:
- 06/19/14 00:02:55 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lua/lua_values.cc
r213 r262 8 8 9 9 #include "nv/lua/lua_raw.hh" 10 #include "nv/object.hh"11 10 12 11 using nv::lua::linteger; … … 71 70 } 72 71 73 void nv::lua::detail::push_object ( lua_State *L, object* o )74 {75 if ( o == nullptr )76 {77 lua_pushnil( L );78 }79 else80 {81 lua_rawgeti( L, LUA_REGISTRYINDEX, o->get_lua_index() );82 }83 }84 85 72 void nv::lua::detail::push_pointer ( lua_State *L, void* p ) 86 73 { … … 118 105 } 119 106 120 nv::object* nv::lua::detail::to_object( lua_State *L, int index )107 void* nv::lua::detail::to_pointer ( lua_State *L, int index ) 121 108 { 122 object* o = nullptr; 109 return lua_touserdata( L, index ); 110 } 111 112 void* nv::lua::detail::to_ref_object ( lua_State *L, int index ) 113 { 114 void* o = nullptr; 123 115 if ( lua_istable( L , index ) ) 124 116 { … … 127 119 if ( lua_isuserdata( L, -1 ) ) 128 120 { 129 o = static_cast<object*>( lua_touserdata( L, -1 ));121 o = lua_touserdata( L, -1 ); 130 122 } 131 123 lua_pop( L, 1 ); 132 124 } 133 125 return o; 134 }135 136 void* nv::lua::detail::to_pointer ( lua_State *L, int index )137 {138 return lua_touserdata( L, index );139 126 } 140 127 … … 169 156 } 170 157 171 nv::object* nv::lua::detail::to_object ( lua_State *L, int index, nv::object* def )158 void* nv::lua::detail::to_pointer ( lua_State *L, int index, void* def ) 172 159 { 173 object* o = def; 160 return ( lua_type( L, index ) == LUA_TUSERDATA ? lua_touserdata( L, index ) : def ); 161 } 162 163 void* nv::lua::detail::to_ref_object( lua_State *L, int index, void* def ) 164 { 165 void* o = def; 174 166 if ( lua_istable( L , index ) ) 175 167 { … … 178 170 if ( lua_isuserdata( L, -1 ) ) 179 171 { 180 o = static_cast<object*>( lua_touserdata( L, -1 ));172 o = lua_touserdata( L, -1 ); 181 173 } 182 174 lua_pop( L, 1 ); … … 184 176 return o; 185 177 } 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.