Changeset 8401 in orxonox.OLD
- Timestamp:
- Jun 14, 2006, 5:03:50 PM (18 years ago)
- Location:
- branches/script_engine/src/lib/script_engine
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/script_engine/src/lib/script_engine/account.cc
r8400 r8401 39 39 }; 40 40 41 tScriptClass<Account> global_ACCOUNT_ScriptableClass("Account", CL_ACCOUNT, new ScriptMethod("deposit", ExecutorLua1<Account, float>(&Account::deposit)));41 tScriptClass<Account> global_ACCOUNT_ScriptableClass("Account", CL_ACCOUNT, (new ScriptMethod())->addMethod("deposit", ExecutorLua1<Account, float>(&Account::deposit))); 42 42 43 43 -
branches/script_engine/src/lib/script_engine/object.cc
r8393 r8401 8 8 9 9 10 class Object : public BaseObject { 11 public: 12 static const char className[]; 13 static Lunar<Object>::RegType methods[]; 10 class Object : public BaseObject 11 { 12 public: 13 static const char className[]; 14 static Lunar<Object>::RegType methods[]; 14 15 15 16 17 16 Object(lua_State* L) {callCount = 0; } 17 Object(){callCount = 0;this->setClassID(CL_TEST_OBJECT, "Object");}; 18 ~Object() { printf("deleted Object (%p)\n", this); } 18 19 19 20 21 22 23 20 //meber functions 21 void takeParam(int i) 22 { 23 printf("Lua passed %i to c++\n",i); 24 } 24 25 25 26 27 28 29 26 int printName(lua_State* L) 27 { 28 this->printName(); 29 return 0; 30 } 30 31 31 32 33 34 35 32 void printName() 33 { 34 callCount ++; 35 printf("Hi i'm object %p ! This is the %i. call.\n",this,callCount); 36 } 36 37 37 38 int getCallCount(){ return callCount; } 38 39 39 40 40 private: 41 int callCount; 41 42 42 43 }; 43 44 44 45 const char Object::className[] = "Object"; 45 46 46 47 {"printName", new ExecutorLua0<Object>(&Object::printName)},48 {"getCallCount", new ExecutorLua0ret<Object, int>(&Object::getCallCount)},49 {"takeParam", new ExecutorLua1<Object, int>(&Object::takeParam)},50 {0,0}51 };47 Lunar<Object>::RegType Object::methods[] = { 48 {"printName", new ExecutorLua0<Object>(&Object::printName)}, 49 {"getCallCount", new ExecutorLua0ret<Object, int>(&Object::getCallCount)}, 50 {"takeParam", new ExecutorLua1<Object, int>(&Object::takeParam)}, 51 {0,0} 52 }; 52 53 53 CREATE_SCRIPTABLE_CLASS(Object, CL_TEST_OBJECT, ScriptMethod("printName", ExecutorLua0<Object>(&Object::printName))); 54 CREATE_SCRIPTABLE_CLASS(Object, CL_TEST_OBJECT, 55 addMethod("printName", ExecutorLua0<Object>(&Object::printName)) 56 ->addMethod("getCallCount", ExecutorLua0ret<Object, int>(&Object::getCallCount)) 57 ->addMethod("takeParam", ExecutorLua1<Object, int>(&Object::takeParam))); -
branches/script_engine/src/lib/script_engine/script_class.h
r8399 r8401 19 19 */ 20 20 #define CREATE_SCRIPTABLE_CLASS(CLASS_NAME, CLASS_ID, SCRIPT_METHODS) \ 21 tScriptClass<CLASS_NAME> global_##CLASS_NAME##_ScriptableClass(#CLASS_NAME, CLASS_ID, newSCRIPT_METHODS)21 tScriptClass<CLASS_NAME> global_##CLASS_NAME##_ScriptableClass(#CLASS_NAME, CLASS_ID, (new ScriptMethod)->SCRIPT_METHODS) 22 22 23 23 -
branches/script_engine/src/lib/script_engine/script_method.cc
r8393 r8401 22 22 * @todo this constructor is not jet implemented - do it 23 23 */ 24 ScriptMethod::ScriptMethod(const std::string& methodName, const Executor& executor) 25 { 26 this->addMethod(methodName, executor); 27 } 24 ScriptMethod::ScriptMethod() 25 { } 28 26 29 27 ScriptMethod* ScriptMethod::addMethod(const std::string& methodName, const Executor& executor) … … 50 48 }; 51 49 } 52 53 54 -
branches/script_engine/src/lib/script_engine/script_method.h
r8398 r8401 15 15 { 16 16 public: 17 ScriptMethod( const std::string& methodName, const Executor& executor);17 ScriptMethod(); 18 18 ~ScriptMethod(); 19 19
Note: See TracChangeset
for help on using the changeset viewer.