Changeset 8271 in orxonox.OLD for trunk/src/lib/script_engine
- Timestamp:
- Jun 8, 2006, 4:50:50 PM (19 years ago)
- Location:
- trunk/src/lib/script_engine
- Files:
-
- 4 deleted
- 3 edited
- 9 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/script_engine/Makefile.am
r8061 r8271 1 1 MAINSRCDIR=../.. 2 2 include $(MAINSRCDIR)/defs/include_paths.am 3 4 5 LIB_PREFIX=$(MAINSRCDIR)/lib 6 include $(MAINSRCDIR)/lib/BuildLibs.am 7 8 3 9 4 10 INCLUDES= -I../../../extern_libs … … 6 12 noinst_LIBRARIES = libORXscript.a 7 13 8 libORXscript_a_SOURCES = 14 libORXscript_a_SOURCES = \ 15 script.cc\ 16 script_manager.cc\ 17 script_class.cc\ 18 account.cc \ 19 object.cc 20 9 21 10 22 AM_CPPFLAGS= @LUA_INCLUDES@ 11 23 12 bin_PROGRAMS = account 13 account_SOURCES = \ 14 account.cc\ 15 Script.cc 24 noinst_HEADERS = \ 25 lunar.h\ 26 script.h\ 27 script_manager.h\ 28 script_class.h 16 29 17 30 18 31 19 account_LDADD = libORXscript.a -L../../../extern_libs @LUA_LIBS@20 32 21 #main_LDFLAGS = 33 check_PROGRAMS = example 22 34 23 35 24 noinst_HEADERS = \ 25 lunar.h\ 26 Script.h 36 37 38 39 40 41 example_DEPENDENCIES = \ 42 $(MAINSRCDIR)/world_entities/libORXwe.a \ 43 $(libORXlibs_a_LIBRARIES_) \ 44 $(MAINSRCDIR)/util/libORXutils.a 45 46 example_LDADD = \ 47 $(MAINSRCDIR)/util/libORXutils.a \ 48 $(libORXlibs_a_LIBRARIES_) \ 49 libORXscript.a -L../../../extern_libs @LUA_LIBS@ \ 50 $(MAINSRCDIR)/world_entities/libORXwe.a \ 51 $(libORXlibs_a_LIBRARIES_) \ 52 $(MAINSRCDIR)/util/libORXutils.a 53 54 example_SOURCES= \ 55 example.cc \ 56 \ 57 ../util/executor/executor_lua.cc -
trunk/src/lib/script_engine/lunar.h
r8061 r8271 3 3 4 4 #include <string> 5 #include "Script.h" 5 #include <cassert> 6 #include "script.h" 6 7 7 8 #include "luaincl.h" 9 #include "executor/executor_lua.h" 8 10 9 11 … … 12 14 typedef struct { T *pT; } userdataType; 13 15 public: 14 typedef int (T::*mfp)(lua_State *L);16 typedef Executor* mfp; 15 17 typedef struct { const char *name; mfp mfunc; } RegType; 16 18 … … 139 141 static int insertObject(Script* script, T* obj, const std::string& name, bool gc=false) 140 142 { 141 if(script != NULL) 142 return insertObject(script->getLuaState(), obj, name, gc); 143 144 143 assert (script != NULL); 144 return insertObject(script->getLuaState(), obj, name, gc); 145 145 } 146 146 … … 163 163 // get member function from upvalue 164 164 RegType *l = static_cast<RegType*>(lua_touserdata(L, lua_upvalueindex(1))); 165 return (obj->*(l->mfunc))(L); // call member function 165 int value; 166 (*l->mfunc)(obj, value, L); // call member function 167 return value; 166 168 } 167 169 -
trunk/src/lib/script_engine/lunartest2.lua
r8061 r8271 15 15 getmetatable(Account).__index = parent 16 16 17 18 function test() 19 io.write("Hi i'm test\n") 20 end 21 22 17 23 function main(arg) 24 -- use parameter 18 25 io.write("main received ", arg) 19 26 io.write(" as parameter\n") 27 28 --call member of an inserted object 20 29 Obj:printName() 30 31 --create object of a registered type 32 o = Object() 33 o:printName() 34 35 --take returnvalue from c 36 callCount = Obj:getCallCount() 37 io.write("callCount is now ",callCount) 38 io.write("\n") 39 40 --pass parameters to a c++ method 41 Obj:takeParam(3) 42 43 --print object information 21 44 print('a =', a) 22 45 print('b =', b) … … 28 51 Obj:printName() 29 52 30 return 2 53 return 2,false,2.72 54 31 55 --debug.debug() 32 56 end
Note: See TracChangeset
for help on using the changeset viewer.