- Timestamp:
- 06/02/13 00:53:25 (12 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/nv/lua/lua_state.hh
r77 r79 19 19 namespace lua 20 20 { 21 const int ref_none = -2; 22 const int ref_nil = -1; 21 const int ref_none = -2; 22 const int ref_nil = -1; 23 const int ret_multi = -1; 23 24 24 25 class state; 25 26 typedef int reference; 26 static const int null_reference = -2;27 27 28 28 class stack_guard … … 63 63 state( bool load_libs = false ); 64 64 state( lua_State* state ); 65 int load_string( const std::string& code, const std::string& name ); 66 int load_stream( std::istream& stream, const std::string& name ); 67 int load_file( const std::string& filename ); 68 bool do_string( const std::string& code, const std::string& name ); 65 bool do_string( const std::string& code, const std::string& name, int rvalues = 0 ); 69 66 bool do_stream( std::istream& stream, const std::string& name ); 70 67 bool do_file( const std::string& filename ); … … 76 73 ~state(); 77 74 private: 78 int do_current( const std::string& name ); 75 int load_string( const std::string& code, const std::string& name ); 76 int load_stream( std::istream& stream, const std::string& name ); 77 int load_file( const std::string& filename ); 78 int do_current( const std::string& name, int rvalues = 0 ); 79 79 bool push( const std::string& path, bool global = true ); 80 80 void deep_pointer_copy( int index, void* obj ); -
trunk/src/lua/lua_state.cc
r78 r79 76 76 } 77 77 78 bool lua::state::do_string( const std::string& code, const std::string& name )78 bool lua::state::do_string( const std::string& code, const std::string& name, int rvalues ) 79 79 { 80 80 lua::stack_guard( this ); … … 85 85 return false; 86 86 } 87 return do_current( name ) == 0;87 return do_current( name, rvalues ) == 0; 88 88 } 89 89 … … 112 112 } 113 113 114 int lua::state::do_current( const std::string& name )115 { 116 int result = lua_pcall(L, 0, 0, 0);114 int lua::state::do_current( const std::string& name, int rvalues ) 115 { 116 int result = lua_pcall(L, 0, rvalues, 0); 117 117 if (result) 118 118 { -
trunk/tests/lualib_test/lualib_test.cc
r78 r79 53 53 std::cout << "> " << input << std::endl; 54 54 55 int code = luaL_loadstring( state.get_raw(), input.c_str() ); 56 if (code == 0) code = lua_pcall( state.get_raw(), 0, LUA_MULTRET, 0); 57 if (code != 0) 55 bool result = state.do_string( input, "", nv::lua::ret_multi ); 56 if ( !result ) 58 57 { 59 58 std::string error = lua_tostring( state.get_raw(), -1 );
Note: See TracChangeset
for help on using the changeset viewer.