lua-users home
lua-l archive

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


I'm not too sure how to use the index/newindex metamethods for what I'm
trying to do.  Are there examples of this somewhere?

-----Original Message-----
From: lua-bounces@bazar2.conectiva.com.br
[mailto:lua-bounces@bazar2.conectiva.com.br] On Behalf Of Jerome Vuarand
Sent: Thursday, July 23, 2009 8:44 AM
To: Lua list
Subject: Re: Direct Memory Access to Lua variables?

2009/7/22 b's spam <spam@inlandstudios.com>:
> I'm writing a C++ wrapper class that allows me to manipulate variables in
a
> loaded lua script. It works fine, but is very slow because I'm performing
> these operations many times (in real-time). Is there a way to write
directly
> to the memory location without having to search and push the variable onto
> the stack by name?

If you're doing a lot more C access than Lua access, you can store the
variable data in a userdata, that will never be moved (just store its
address in your C code). Then you can use index/newindex metamethods
to read or write that data from Lua.
No virus found in this incoming message.
Checked by AVG - www.avg.com 
Version: 8.5.392 / Virus Database: 270.13.23/2254 - Release Date: 07/23/09
06:02:00