lua-users home
lua-l archive

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


In my port of Lua 4 based application I just create full user data with
a "__gc" for my C++ pointers. It's all done in a tag emulation layer.
What else is there to do? Ideas?

I have just finished implemlementation for coroutines; have not tested
them yet. Basically I ended up creating a user data with every coroutine
because Lua threads/coroutines don't support "__gc" (nor any other
events for that matter). For coroutines, I wanted to have an aility to
kill them at will and so ended up doing an ID based API instead of
original lua_State* based one. In addition I needed to deallocate some
C++ objects associated with coroutines whenever they are killed. As a
consequence coroutines now have to kill themselves or be killed by
somone else explicitly now or they will persist until lua_close is
called otherwise. But this can be reprogrammed at Lua level.

Michael Naunton wrote:

>I'd like enlightenment too. I currently just punted and wrote a C++
>wrapper template to push userdata as a T*, classTag pair. That way I can
>at least allocate my real data in mempools, etc, and vector GC stuff to
>the real class. Ugly as hell, but at least the ugliness is contained.
>
I don't quite understand how you can save on full user data allocations
using <class*, tag> pairs. You would still need to have a full user data
per pair, wouldn't you? You could wire it to a single "__gc" handler,
but allocations... Hmm.

AB

>
>- mike
>
>paul@theV.net wrote:
>
>  
>
>>I guess the "light-weight" userdata is to ease the burden on Lua's
>>internals whenever necessasry, i.e., no meta table bookkeeping
>>stuff.
>>
>>However, my biggest complaint of lua5 is now there seems no way to
>>define a "heavy-weight" userdata without using Lua's memory allocation
>>method. I can no longer define a GC method for pure C pointers. 
>>When it occurred to me almost impossible to convert my program to
>>Lua5, I'd still stick with Lua4 for now.
>>
>>Or I could be wrong on this, can somebody enlighten me please?
>>
>>Regards,
>>.paul.
>>
>> 
>>
>>    
>>
>
>
>
>
>  
>