Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8393 in orxonox.OLD


Ignore:
Timestamp:
Jun 14, 2006, 3:43:56 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: scriptMethod much better implemented

Location:
branches/script_engine/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/script_engine/src/lib/script_engine/account.cc

    r8271 r8393  
    3939 };
    4040
    41  CREATE_SCRIPTABLE_CLASS(Account, CL_ACCOUNT);
     41 CREATE_SCRIPTABLE_CLASS(Account, CL_ACCOUNT, ScriptMethod("deposit", ExecutorLua1<Account, float>(&Account::deposit)));
    4242
  • branches/script_engine/src/lib/script_engine/object.cc

    r8384 r8393  
    5151 };
    5252
    53  CREATE_SCRIPTABLE_CLASS(Object, CL_TEST_OBJECT);
     53 CREATE_SCRIPTABLE_CLASS(Object, CL_TEST_OBJECT, ScriptMethod("printName", ExecutorLua0<Object>(&Object::printName)));
  • branches/script_engine/src/lib/script_engine/script_class.cc

    r8390 r8393  
    1717
    1818#include "script_class.h"
     19#include <cassert>
    1920
    2021/**
    21  * standard constructor
     22 * @brief standard constructor
    2223 * @todo this constructor is not jet implemented - do it
    2324*/
    24 ScriptClass::ScriptClass(const std::string& name, ClassID classID)
    25  : BaseObject(name)
     25ScriptClass::ScriptClass(const std::string& name, ClassID classID, ScriptMethod* scriptMethods)
     26    : BaseObject(name)
    2627{
    27    this->setClassID(CL_SCRIPT_CLASS, "ScriptClass");
    28    this->classID = classID;
     28  assert(scriptMethods != NULL);
     29  this->setClassID(CL_SCRIPT_CLASS, "ScriptClass");
     30  this->classID = classID;
     31
     32  this->scriptMethods = scriptMethods;
    2933}
    3034
     
    3539ScriptClass::~ScriptClass ()
    3640{
    37   // delete what has to be deleted here
     41  delete this->scriptMethods;
    3842}
  • branches/script_engine/src/lib/script_engine/script_class.h

    r8390 r8393  
    1111#include "script.h"
    1212#include "lunar.h"
     13#include "script_method.h"
     14
    1315
    1416/**
     
    1618 * this should be used at the beginning of all the Classes that should be loadable (in the cc-file)
    1719 */
    18 #define CREATE_SCRIPTABLE_CLASS(CLASS_NAME, CLASS_ID) \
    19     tScriptable<CLASS_NAME> global_##CLASS_NAME##_ScriptableClass(#CLASS_NAME, CLASS_ID)
     20#define CREATE_SCRIPTABLE_CLASS(CLASS_NAME, CLASS_ID, SCRIPT_METHODS) \
     21    tScriptable<CLASS_NAME> global_##CLASS_NAME##_ScriptableClass(#CLASS_NAME, CLASS_ID, new SCRIPT_METHODS)
    2022
    2123
     
    3537
    3638protected:
    37   ScriptClass(const std::string& name, ClassID classID);
     39  ScriptClass(const std::string& name, ClassID classID, ScriptMethod* scriptMethods);
    3840
    3941private:
    4042  ClassID             classID;
     43  ScriptMethod*       scriptMethods;
    4144};
    4245
     
    4851{
    4952public:
    50   tScriptable(const std::string& name, ClassID classID)
    51       : ScriptClass(name, classID)
     53  tScriptable(const std::string& name, ClassID classID, ScriptMethod* scriptMethods)
     54      : ScriptClass(name, classID, scriptMethods)
    5255  { }
    5356
  • branches/script_engine/src/lib/script_engine/script_method.cc

    r8390 r8393  
    2727}
    2828
    29 ScriptMethod& ScriptMethod::addMethod(const std::string& methodName, const Executor& executor)
     29ScriptMethod* ScriptMethod::addMethod(const std::string& methodName, const Executor& executor)
    3030{
    3131  this->methods.push_back(ScriptMethod::Method(methodName, executor));
    3232
    33   return *this;
     33  return this;
    3434}
    3535
  • branches/script_engine/src/lib/script_engine/script_method.h

    r8390 r8393  
    1919  ~ScriptMethod();
    2020
    21   ScriptMethod& addMethod(const std::string& methodName, const Executor& executor);
     21  ScriptMethod* addMethod(const std::string& methodName, const Executor& executor);
     22
     23  const std::string& name(unsigned int methodNumber) const { return methods[methodNumber].name; };
     24  const Executor* executor(unsigned int methodNumber) const { return methods[methodNumber].executor; };
    2225
    2326
  • branches/script_engine/src/world_entities/space_ships/helicopter.cc

    r8389 r8393  
    3636CREATE_FACTORY(Helicopter, CL_HELICOPTER);
    3737#include "script_class.h"
    38 //CREATE_SCRIPTABLE_CLASS(Helicopter, CL_HELICOPTER);
     38//CREATE_SCRIPTABLE_CLASS(Helicopter, CL_HELICOPTER, NULL);
    3939
    4040
Note: See TracChangeset for help on using the changeset viewer.