lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi.

I'm looking for a fast way of store a value (int or
void*) in a table and retrieve it(fastly, again) when
calling some method of the table.

Like this:


In Lua:

obj = {}

StoreTheValueInTheTable(obj)

obj.func1 = func1
obj.func2 = func2



StoreTheValueInTheTable it's a C function.

In C:

int func1(lua_State *L) {
    // The table is the first parameter

    int value = GetTheValueFromTheTable(L, 1);
    Class* pClass;
    pClass = (Class*)value;
    pClass->func1();
    
    return 0;
  }

Same for func2

So, when I call in C:
obj:func1()

The C function 'func1' will receive a reference for
the table as the first parameters, so I can retrieve
the value stored in the table.

I found this would be a fast way of interface objects
between Lua and C.

Any comment?





	
	
		
_______________________________________________________
Yahoo! Mail agora com 100MB, anti-spam e antivírus grátis!
http://br.info.mail.yahoo.com/