[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Fast set and get a value in a table
- From: Jose Marin <jose_marin2@...>
- Date: Wed, 7 Jul 2004 15:57:46 -0300 (ART)
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/