Changeset 358 for trunk/src/lua
- Timestamp:
- 04/29/15 14:53:06 (10 years ago)
- Location:
- trunk/src/lua
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lua/lua_nova.cc
r323 r358 83 83 lua_pushvalue( L, itype ); 84 84 lua_pushvalue( L, iid ); 85 lua_push string( L, "." );85 lua_pushliteral( L, "." ); 86 86 lua_pushvalue( L, ifield ); 87 87 lua_concat( L, 3 ); … … 292 292 { 293 293 // storage.__counter++ 294 lua_push string( L, "__counter" );294 lua_pushliteral( L, "__counter" ); 295 295 lua_pushvalue( L, -1 ); 296 296 lua_rawget( L, 1 ); … … 303 303 304 304 // element.nid = __counter 305 lua_push string( L, "nid" );305 lua_pushliteral( L, "nid" ); 306 306 lua_pushinteger( L, count ); 307 307 lua_rawset( L, 2 ); … … 322 322 323 323 // element.id = element.id 324 lua_push string( L, "id" );324 lua_pushliteral( L, "id" ); 325 325 lua_rawget( L, 2 ); 326 326 if ( lua_isnil( L, -1 ) ) … … 413 413 414 414 lua_pushvalue( L, 1 ); 415 lua_push string( L, "." );415 lua_pushliteral( L, "." ); 416 416 lua_pushvalue( L, 2 ); 417 417 lua_concat( L, 3 ); // new ident index 5 … … 449 449 450 450 lua_pushvalue( L, 1 ); 451 lua_push string( L, "." );451 lua_pushliteral( L, "." ); 452 452 lua_pushvalue( L, 2 ); 453 453 lua_concat( L, 3 ); // new ident index 6 … … 579 579 if ( lua_type( L, 1 ) == LUA_TSTRING ) 580 580 { 581 // TODO: Optimzie 581 582 lua_getglobal( L, lua_tostring( L, 1 ) ); 582 583 lua_replace( L, 1 ); … … 809 810 } 810 811 811 void nv::lua::register_storage( state* a_state, const string& name, const string&constructor_name )812 void nv::lua::register_storage( state* a_state, string_ref name, string_ref constructor_name ) 812 813 { 813 814 // TODO: error checking … … 816 817 // TODO: check if nova is loaded 817 818 lua_pushcfunction( L, nova_register_storage ); 818 lua_push string( L, name.c_str() );819 lua_pushlstring( L, name.data(), name.size() ); 819 820 lua_call( L, 1, 1 ); 820 lua_setglobal( L, constructor_name. c_str() );821 lua_setglobal( L, constructor_name.data() ); 821 822 lua_settop( L, stack ); 822 823 } -
trunk/src/lua/lua_values.cc
r319 r358 75 75 } 76 76 77 void nv::lua::detail::push_string_ref( lua_State *L, string_ref s ) 78 { 79 lua_pushlstring( L, s.data(), s.size() ); 80 } 81 77 82 void nv::lua::detail::push_pointer ( lua_State *L, void* p ) 78 83 { … … 108 113 std::string nv::lua::detail::to_string ( lua_State *L, int index ) 109 114 { 110 return lua_tostring( L, index ); 115 size_t length = 0; 116 const char* result = lua_tolstring( L, index, &length ); 117 return std::string( result, length ); 111 118 } 112 119 113 120 const char* nv::lua::detail::to_cstring ( lua_State *L, int index ) 114 121 { 115 return lua_tostring( L, index ); 122 return lua_tolstring( L, index, nullptr ); 123 } 124 125 nv::string_ref nv::lua::detail::to_string_ref( lua_State *L, int index ) 126 { 127 size_t length = 0; 128 const char* result = lua_tolstring( L, index, &length ); 129 return string_ref( result, length ); 116 130 } 117 131
Note: See TracChangeset
for help on using the changeset viewer.