[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Sharing objects between states
- From: HyperHacker <hyperhacker@...>
- Date: Wed, 3 Aug 2011 05:53:41 -0600
On Wed, Aug 3, 2011 at 03:51, Marc Balmer <email@example.com> wrote:
> Am 03.08.11 09:08, schrieb STPeters:
>> *NOTE: this is being asked on behalf of a Lua forum user. I thought this
>> came up before on the list, but can't seem to find it, and I am stumped.
>> I can pass along the info, or you can reply directly at
>> http://forum.luahub.com/index.php?topic=3138.msg7072 - thanks for your
>> Can an object be created in one Lua state, passed to C++, and then
>> passed to a script running in a different Lua state?
>> The reason I ask is that I'd like scripts responsible for object
>> creation to have a different set of available APIs than the scripts
>> which later control the object, as well as run on a different thread
>> (native thread - each of these interpreters in turn contains many Lua
>> threads). They will never be accessing the object at the same time.
>> Does the use of Luabind, as opposed to native C wrappers, affect the
>> answer to this question?
>> They are derived from a C++ base class, with virtual functions
>> reimplemented in Lua (and called from C++ with Luabind glue), and
>> instantiated from Lua. So I guess that makes them Lua objects used by C++.
> We have created a 'proxy' module which allows you to manipulate objects
> in a different state hence the name.
> We use it in our own templating system "Lua templates" to separate a
> data processing state from a web-GUI rendering state.
> I will probably present this system during the Lua Workshop 2011.
It's possible to provide a different API to the object creation
scripts than to the scripts that use them even if they run in the same
state, via function environments.
Sent from my toaster.