[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Getting the address of Lua variables in C
- From: Daniel Silverstone <dsilvers@...>
- Date: Fri, 07 May 2004 16:04:28 +0100
On Fri, 2004-05-07 at 15:48, Jose Marin wrote:
> It's possible to get the address of Lua variable to be
> used in C?
> int *p_time;
> p_time = (int*)LuaGetVarAddress("time");
> and, for every game frame:
> *p_time = GetTime();
Yuck
> It's that possible?
It would rely on the lua object never changing its address (which while
I think it is true under the current GC scheme, isn't necessarily true
overall) and would also require the system to implement a write-barrier
because of hashing requirements...
It makes more sense for you to create a C function which when called
gets the time, and has a frame-by-frame barrier so that it only calls
the expensive GetTime() call once per frame (assuming that it is really
that expensive after all)
D.
--
Daniel Silverstone http://www.digital-scurf.org/
Hostmaster, Webmaster, and Chief Code Wibbler: Digital-Scurf Unlimited
GPG Public key available from keyring.debian.org KeyId: 20687895