Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7815 in orxonox.OLD for branches/script_engine/src


Ignore:
Timestamp:
May 24, 2006, 4:49:35 PM (19 years ago)
Author:
snellen
Message:

object pointer is now found

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

Legend:

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

    r7808 r7815  
    2222  int deposit(lua_State* L)
    2323  {
     24    std::cout<<"deposit called"<<std::endl;
    2425    m_balance += lua_tonumber(L, -1);
    2526    lua_pop(L, 1);
  • branches/script_engine/src/lib/script_engine/account.lua

    r7808 r7815  
    55print("testoutput from lua")
    66local a = Account{balance=100}
     7a:withdraw(25.00)
    78a:deposit(50.00)
    8 a:withdraw(25.00)
    99print("Account balance = $"..a:balance())
    1010
  • branches/script_engine/src/lib/script_engine/luna.h

    r7808 r7815  
    4343      /* stack = closure(-1), [args...], 'self' table(1) */
    4444      //int i = static_cast<int>(lua_tonumber(L,-1));
    45       int i = lua_upvalueindex (1);
     45 
     46       int i = lua_upvalueindex (1);
     47
    4648      //lua_pushnumber(L, 0); /* userdata object at index 0 */
    4749      //lua_gettable(L, 1);
    4850      lua_rawgeti (L, 1, 0);
    4951      T* obj = (T*)(lua_touserdata(L,-1));
    50       lua_pop(L, 2); /* pop closure value and obj */
     52      lua_pop(L, 1); /* pop closure value and obj */
    5153
    5254        printf("FUNCTION:: %d\n", i );
     
    8890
    8991 private:
     92
    9093   static int registerObject(T* obj, lua_State* L)
    9194    {
    9295      lua_newtable(L); /* new table object */
    93       int  objRef = luaL_ref (L, LUA_REGISTRYINDEX);
     96      //int  objRef = luaL_ref (L, LUA_REGISTRYINDEX);
    9497
    9598      //lua_pushnumber(L, 0); /* userdata obj at index 0 */
    96       lua_rawgeti(L, LUA_REGISTRYINDEX, objRef);
     99      //lua_rawgeti(L, LUA_REGISTRYINDEX, objRef);
    97100      lua_pushlightuserdata(L, obj);
    98101      lua_rawseti(L,-2,0);
     
    101104      //std::cout<<"test"<<std::endl;
    102105
    103     /* Set up garbage collection */
     106    /* Set up garbage collection
    104107      if(lua_getmetatable(L, objRef) != 0)
    105108       {
     
    109112        lua_settable(L,-3);
    110113       }
    111    
    112       lua_rawgeti (L, LUA_REGISTRYINDEX, objRef);
     114    */
     115      //lua_rawgeti (L, LUA_REGISTRYINDEX, objRef);
    113116      /* register the member functions */
    114       for (int i=0; T::Register[i].name; i++) {
    115          
     117      for (int i=0; T::Register[i].name; i++)
     118      {
    116119         lua_pushstring(L, T::Register[i].name);
    117120         lua_pushnumber(L, i);
Note: See TracChangeset for help on using the changeset viewer.