Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8408 in orxonox.OLD for trunk/src/lib/script_engine/object.cc


Ignore:
Timestamp:
Jun 14, 2006, 5:50:18 PM (18 years ago)
Author:
bensch
Message:

trunk: merged the script_engine branche back here
merged with command
svn merge https://svn.orxonox.net/orxonox/branches/script_engine . -r8284:HEAD
no conflicts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/script_engine/object.cc

    r8271 r8408  
    88
    99
    10 class Object : public BaseObject {
    11    public:
    12      static const char className[];
    13      static Lunar<Object>::RegType methods[];
     10class Object : public BaseObject
     11{
     12public:
     13  Object(lua_State* L) {callCount = 0; }
     14  Object(){callCount = 0;this->setClassID(CL_TEST_OBJECT, "Object");};
     15  ~Object() { printf("deleted Object (%p)\n", this); }
    1416
    15      Object(lua_State* L) {callCount = 0; }
    16      Object(){callCount = 0;};
    17      ~Object() { printf("deleted Object (%p)\n", this); }
     17  //meber functions
     18  void takeParam(int i)
     19  {
     20    printf("Lua passed %i to c++\n",i);
     21  }
    1822
    19         //meber functions
    20      void takeParam(int i)
    21      {
    22        printf("Lua passed %i to c++\n",i);
    23      }
     23  int printName(lua_State* L)
     24  {
     25    this->printName();
     26    return 0;
     27  }
    2428
    25      int printName(lua_State* L)
    26      {
    27        this->printName();
    28        return 0;
    29      }
     29  void printName()
     30  {
     31    callCount ++;
     32    printf("Hi i'm object %p ! This is the %i. call.\n",this,callCount);
     33  }
    3034
    31      void printName()
    32      {
    33        callCount ++;
    34        printf("Hi i'm object %p ! This is the %i. call.\n",this,callCount);
    35      }
     35  int getCallCount(){ return callCount; }
    3636
    37      int getCallCount(){ return callCount; }
     37private:
     38  int callCount;
    3839
    39    private:
    40      int callCount;
     40};
    4141
    42  };
    4342
    44  const char Object::className[] = "Object";
    45 
    46  Lunar<Object>::RegType Object::methods[] = {
    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  };
    52 
    53  CREATE_SCRIPTABLE_CLASS(Object, CL_TEST_OBJECT);
     43CREATE_SCRIPTABLE_CLASS(Object, CL_TEST_OBJECT,
     44                        addMethod("printName", ExecutorLua0<Object>(&Object::printName))
     45                        ->addMethod("getCallCount", ExecutorLua0ret<Object, int>(&Object::getCallCount))
     46                        ->addMethod("takeParam", ExecutorLua1<Object, int>(&Object::takeParam)));
Note: See TracChangeset for help on using the changeset viewer.