Changeset 212 for trunk/src/lua/lua_state.cc
- Timestamp:
- 09/09/13 19:29:23 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lua/lua_state.cc
r209 r212 251 251 } 252 252 253 254 void lua::state_wrapper::register_native_function( lfunction f, const char* name ) 255 { 256 if ( m_global ) push_global_table(); 257 lua_pushcfunction( m_state, f ); 258 lua_setfield( m_state, -2, name ); 259 if ( m_global ) pop_global_table(); 260 } 261 253 262 void lua::state::log_stack() 254 263 { … … 287 296 if ( t == nullptr ) return ref_none; 288 297 return register_object( o, t->name.c_str() ); 298 } 299 300 void lua::state::register_native_object_method( const char* lua_name, const char* name, lfunction f ) 301 { 302 stack_guard guard( this ); 303 lua_getglobal( m_state, lua_name ); 304 if ( lua_isnil( m_state, -1 ) ) 305 { 306 NV_THROW( runtime_error, std::string( lua_name ) + " type not registered!" ); 307 } 308 lua_pushcfunction( m_state, f ); 309 lua_setfield( m_state, -2, name ); 289 310 } 290 311 … … 411 432 lua_settop( m_state, m_level ); 412 433 } 434 435 int nv::lua::upvalue_index( int i ) 436 { 437 return lua_upvalueindex(i); 438 }
Note: See TracChangeset
for help on using the changeset viewer.