- Timestamp:
- May 29, 2006, 9:42:29 PM (18 years ago)
- Location:
- branches/script_engine/src/lib/script_engine
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/script_engine/src/lib/script_engine/Makefile.am
r7829 r7962 2 2 INCLUDES= -I../../../extern_libs 3 3 4 #noinst_LIBRARIES = libORXscript.a4 noinst_LIBRARIES = libORXscript.a 5 5 6 #libORXscript_a_SOURCES =6 libORXscript_a_SOURCES = 7 7 8 8 AM_CPPFLAGS= @LUA_INCLUDES@ -
branches/script_engine/src/lib/script_engine/account.cc
r7821 r7962 1 1 #include "luaincl.h" 2 #include <iostream> 2 3 3 4 #include "lunar.h" … … 29 30 30 31 32 class Object { 33 public: 34 static const char className[]; 35 static Lunar<Object>::RegType methods[]; 36 37 Object(lua_State* L) { } 38 ~Object() { printf("deleted Object (%p)\n", this); } 39 40 int printName(lua_State* L){std::cout<<"Hi i'm object!"<<std::endl; return 0;} 41 }; 42 43 const char Object::className[] = "Object"; 44 45 Lunar<Object>::RegType Object::methods[] = { 46 method(Object, printName), 47 {0,0} 48 }; 49 31 50 int main(int argc, char *argv[]) 32 51 { … … 41 60 42 61 Lunar<Account>::Register(L); 62 Lunar<Object>::Register(L); 63 Object obj(L); 64 Lunar<Object>::insertObject(L,&obj,"Object",false); 65 66 67 43 68 44 69 if(argc>1) lua_dofile(L, argv[1]); -
branches/script_engine/src/lib/script_engine/lunar.h
r7821 r7962 1 #include "luaincl.h" 1 #include <string> 2 3 4 #include "luaincl.h" 5 2 6 3 7 template <typename T> class Lunar { … … 109 113 } 110 114 115 116 static int insertObject(lua_State* L, T* obj, const std::string& name, bool gc=false) 117 { 118 int objectRef = push(L, obj, gc); 119 120 lua_pushliteral(L, name.c_str() ); 121 lua_pushvalue(L, objectRef ); 122 lua_settable(L, LUA_GLOBALSINDEX ); 123 124 return objectRef; 125 } 126 111 127 // get userdata from Lua stack and return pointer to T object 112 128 static T *check(lua_State *L, int narg) { -
branches/script_engine/src/lib/script_engine/lunartest.lua
r7829 r7962 4 4 printf("Account balance = $%0.02f\n", self:balance()) 5 5 end 6 7 --o = Object() 8 Object:printName() 6 9 7 10 a = Account(100)
Note: See TracChangeset
for help on using the changeset viewer.