Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8404 in orxonox.OLD for branches


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

all functions added

Location:
branches/script_engine/src/lib/script_engine
Files:
2 edited

Legend:

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

    r8401 r8404  
    1111
    1212
    13  class Account : public BaseObject {
    14       lua_Number m_balance;
    15    public:
    16     // static const char className[];
    17      static Lunar<Account>::RegType methods[];
     13class Account : public BaseObject
     14{
     15  lua_Number m_balance;
     16public:
     17  // static const char className[];
     18  static Lunar<Account>::RegType methods[];
    1819
    19      Account(lua_State *L)      { m_balance = luaL_checknumber(L, 1); }
    20      Account(double balance=0)    : m_balance(balance) { this->setClassID(CL_ACCOUNT, "Account"); }
     20  Account(lua_State *L)      { m_balance = luaL_checknumber(L, 1); }
     21  Account(double balance=0)    : m_balance(balance) { this->setClassID(CL_ACCOUNT, "Account"); }
    2122
    22      void deposit (float value) { m_balance += value; };
    23      void withdraw(float value) { m_balance -= value; };
    24      float balance() { return m_balance; };
     23  void deposit (float value) { m_balance += value; };
     24  void withdraw(float value) { m_balance -= value; };
     25  float balance() { return m_balance; };
    2526
    26      int deposit (lua_State *L) { m_balance += luaL_checknumber(L, 1); return 0; }
    27      int withdraw(lua_State *L) { m_balance -= luaL_checknumber(L, 1); return 0; }
    28      int balance (lua_State *L) { lua_pushnumber(L, m_balance); return 1; }
    29      ~Account() { printf("deleted Account (%p)\n", this); }
    30  };
     27  int deposit (lua_State *L) { m_balance += luaL_checknumber(L, 1); return 0; }
     28  int withdraw(lua_State *L) { m_balance -= luaL_checknumber(L, 1); return 0; }
     29  int balance (lua_State *L) { lua_pushnumber(L, m_balance); return 1; }
     30  ~Account() { printf("deleted Account (%p)\n", this); }
     31};
    3132
    32  //const char Account::className[] = "Account";
     33//const char Account::className[] = "Account";
    3334
    34  Lunar<Account>::RegType Account::methods[] = {
    35    {"deposit", new ExecutorLua1<Account, float>(&Account::deposit)},
    36    {"withdraw", new ExecutorLua1<Account, float>(&Account::withdraw)},
    37    {"balance", new ExecutorLua0ret<Account, float>(&Account::balance)},
    38    {0,NULL}
    39  };
     35Lunar<Account>::RegType Account::methods[] = {
     36      {"deposit", new ExecutorLua1<Account, float>(&Account::deposit)},
     37      {"withdraw", new ExecutorLua1<Account, float>(&Account::withdraw)},
     38      {"balance", new ExecutorLua0ret<Account, float>(&Account::balance)},
     39      {0,NULL}
     40    };
    4041
    41  tScriptClass<Account> global_ACCOUNT_ScriptableClass("Account", CL_ACCOUNT, (new ScriptMethod())->addMethod("deposit", ExecutorLua1<Account, float>(&Account::deposit)));
     42tScriptClass<Account> global_ACCOUNT_ScriptableClass("Account", CL_ACCOUNT, (new ScriptMethod())->addMethod("deposit", ExecutorLua1<Account, float>(&Account::deposit)));
    4243
    43 
    44 //CREATE_SCRIPTABLE_CLASS(Account, CL_ACCOUNT, NULL);
     44CREATE_SCRIPTABLE_CLASS(Account, CL_ACCOUNT,
     45                        addMethod("deposit", ExecutorLua1<Account, float>(&Account::deposit))
     46                        ->addMethod("withdraw", ExecutorLua1<Account, float>(&Account::withdraw))
     47                        ->addMethod("balance", ExecutorLua0ret<Account, float>(&Account::balance)));
  • branches/script_engine/src/lib/script_engine/object.cc

    r8401 r8404  
    4343};
    4444
    45 const char Object::className[] = "Object";
    46 
    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     };
    5345
    5446CREATE_SCRIPTABLE_CLASS(Object, CL_TEST_OBJECT,
Note: See TracChangeset for help on using the changeset viewer.