/[enigma]/enigma/src/lua.cc
ViewVC logotype

Diff of /enigma/src/lua.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.8 by dheck, Thu Mar 13 18:07:39 2003 UTC revision 1.9 by dheck, Sat Apr 26 17:19:00 2003 UTC
# Line 17  Line 17 
17   *   *
18   * $Id$   * $Id$
19   */   */
 //#include "config.h"  
20  #include "lua.hh"  #include "lua.hh"
21  #include "world.hh"  #include "world.hh"
22  #include "objects.hh"  #include "objects.hh"
# Line 45  using world::GridPos; Line 44  using world::GridPos;
44    
45  namespace lua  namespace lua
46  {  {
47        class LuaState {
48        public:
49            LuaState (size_t stacksize = 0);
50            ~LuaState();
51            
52            lua_State *get_state() const { return m_state; }
53        private:
54            LuaState (const LuaState &);
55            LuaState &operator = (const LuaState &);
56        
57            /*
58            ** Variables
59            */
60            lua_State *m_state;
61        };
62        
63        typedef int LuaTag;
64    
65    
66        class NumberType {
67        
68        };
69        
70        class UserType {
71        public:
72            UserType (LuaState *state);
73            
74            LuaTag get_tag() const { return m_tag; }
75    
76            bool is_type (int idx) {
77                lua_State *L = m_state->get_state();
78                return lua_isuserdata(L, idx) && lua_tag(L,idx)==m_tag;
79            }
80            
81        private:
82            LuaState *m_state;
83            LuaTag m_tag;
84        };
85    }
86    
87    LuaState::LuaState (size_t stacksize)
88    {
89        m_state = lua_open(stacksize);
90    }
91    
92    LuaState::~LuaState()
93    {
94        lua_close(state);
95    }
96    
97    namespace lua
98    {
99      lua_State *state = 0;       // global Lua state      lua_State *state = 0;       // global Lua state
100      int object_tag;             // Lua tag for `Object's      int object_tag;             // Lua tag for `Object's
101  }  }

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26