Changeset 7820 in orxonox.OLD for branches/script_engine/src
- Timestamp:
- May 24, 2006, 5:56:07 PM (19 years ago)
- Location:
- branches/script_engine/src/lib/script_engine
- Files:
-
- 1 added
- 1 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/script_engine/src/lib/script_engine/luna.h
r7815 r7820 19 19 public: 20 20 /* member function map */ 21 struct RegType { 22 const char* name; 21 struct RegType { 22 const char* name; 23 23 int(T::*mfunc)(lua_State*); 24 }; 24 }; 25 25 /* register class T */ 26 26 static void Register(lua_State* L) { … … 30 30 31 31 /* if (otag == 0) { 32 33 34 lua_settagmethod(L, otag, "gc"); /* tm to release objects 32 otag = lua_newtag(L); 33 lua_pushcfunction(L, &Luna<T>::gc_obj); 34 lua_settagmethod(L, otag, "gc"); /* tm to release objects 35 35 }*/ 36 36 } … … 38 38 private: 39 39 static int otag; /* object tag */ 40 40 41 41 /* member function dispatcher */ 42 42 static int thunk(lua_State* L) { 43 43 /* stack = closure(-1), [args...], 'self' table(1) */ 44 44 //int i = static_cast<int>(lua_tonumber(L,-1)); 45 45 46 46 int i = lua_upvalueindex (1); 47 47 … … 52 52 lua_pop(L, 1); /* pop closure value and obj */ 53 53 54 54 printf("FUNCTION:: %d\n", i ); 55 55 printf("OBJECT %p\n", obj); 56 56 … … 58 58 return (obj->*(T::Register[i].mfunc))(L); 59 59 } 60 60 61 61 62 62 static int setScriptable(T* obj) … … 64 64 //return registerObject(obj); 65 65 } 66 66 67 67 static int setScriptable(const std::string& objectName) 68 68 { 69 #warning 'implement do not use'69 //#warning 'implement do not use' 70 70 // return registerObject(obj); 71 71 } … … 86 86 return 0; 87 87 } 88 protected: 88 protected: 89 89 Luna(); /* hide default constructor */ 90 90 … … 104 104 //std::cout<<"test"<<std::endl; 105 105 106 /* Set up garbage collection 106 /* Set up garbage collection 107 107 if(lua_getmetatable(L, objRef) != 0) 108 108 { … … 115 115 //lua_rawgeti (L, LUA_REGISTRYINDEX, objRef); 116 116 /* register the member functions */ 117 for (int i=0; T::Register[i].name; i++) 117 for (int i=0; T::Register[i].name; i++) 118 118 { 119 120 121 122 119 lua_pushstring(L, T::Register[i].name); 120 lua_pushnumber(L, i); 121 lua_pushcclosure(L, &Luna<T>::thunk, 1); 122 lua_settable(L,-3); 123 123 } 124 124 return 1; /* return the table object */
Note: See TracChangeset
for help on using the changeset viewer.