Changeset 86


Ignore:
Timestamp:
06/02/13 18:38:01 (12 years ago)
Author:
epyon
Message:
  • lua::state constructors made explicit
  • lua::state can implicitly cast to lua_State*
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/nv/lua/lua_state.hh

    r79 r86  
    3030                public:
    3131                        stack_guard( state* L );
     32                        stack_guard( state& L );
    3233                        int get_level() const { return m_level; }
    3334                        ~stack_guard();
     
    6162                        friend class table_guard;
    6263                public:
    63                         state( bool load_libs = false );
    64                         state( lua_State* state );
     64                        explicit state( bool load_libs = false );
     65                        explicit state( lua_State* state );
    6566                        bool do_string( const std::string& code, const std::string& name, int rvalues = 0 );
    6667                        bool do_stream( std::istream& stream, const std::string& name );
     
    7172                        reference register_object( object * o );
    7273                        void unregister_object( object * o );
     74                        operator lua_State*() { return L; }
    7375                        ~state();
    7476                private:
  • trunk/src/lua/lua_state.cc

    r79 r86  
    1717lua::stack_guard::stack_guard( lua::state* L )
    1818        : L(L), m_level( lua_gettop(L->L) )
     19{
     20
     21}
     22
     23lua::stack_guard::stack_guard( lua::state& L )
     24        : L(&L), m_level( lua_gettop((&L)->L) )
    1925{
    2026
  • trunk/tests/lualib_test/lualib_test.cc

    r79 r86  
    2828        {
    2929                nv::lua::state state( true );
    30                 nlua_register_glm( state.get_raw() );
     30                nlua_register_glm( state );
    3131                // run the Lua script
    3232                state.do_file( "init.lua" );
     
    3434                for (;;)
    3535                {
    36                         nv::lua::stack_guard guard( &state );
     36                        nv::lua::stack_guard guard( state );
    3737                        int stack = guard.get_level();
    3838                        std::string input;
     
    5656                        if ( !result )
    5757                        {
    58                                 std::string error = lua_tostring( state.get_raw(), -1 );
     58                                std::string error = lua_tostring( state, -1 );
    5959                                std::cout << "ERROR : " << error << std::endl;
    6060                                continue;
    6161                        }
    6262
    63                         if (lua_gettop( state.get_raw() ) > stack)
     63                        if (lua_gettop( state ) > stack)
    6464                        {
    65                                 for ( int i = stack+1; i <= lua_gettop( state.get_raw() ); ++i )
     65                                for ( int i = stack+1; i <= lua_gettop( state ); ++i )
    6666                                {
    67                                         std::cout << nlua_typecontent( state.get_raw(), i ) << std::endl;
     67                                        std::cout << nlua_typecontent( state, i ) << std::endl;
    6868                                }
    6969                        }
Note: See TracChangeset for help on using the changeset viewer.