[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Pushing a UserData pointer?
- From: Chris Marrin <chris@...>
- Date: Mon, 16 May 2005 20:43:06 -0700
Rici Lake wrote:
...
If you don't want to go hacking the Lua core, I have another solution...
You say you're reffing the new userdata anyway; this is going to store a
reference in the registry. There's no magic to luaL_ref other than that.
So why not kill two birds with one stone?
Instead of using luaL_ref to store a reference in the registry, store
your own reference in the registry using a lightuserdata of the this
pointer as a key. Then you can push the lua object onto the stack using
the this pointer, without breaking the API and without incurring much
overhead (since the hash of a lud is essentially the address).
The problem with that is now I would always have a pointer to the
userdata and it would never GC, right? When I used my own table to store
the lightuserdata key/userdata value pair, I made the values in that
table weak so they would get collected properly.
Is there another way to avoid the GC problem?
--
chris marrin ,""$,
cmarrin@arch.sel.sony.com b` $ ,,.
(408) 955-3049 mP b' , 1$'
Sony ,.` ,b` ,` :$$'
,|` mP ,` ,mm
,b" b" ,` ,mm m$$ ,m ,`P$$
m$` ,b` .` ,mm ,'|$P ,|"1$` ,b$P ,` :$1
b$` ,$: :,`` |$$ ,` $$` ,|` ,$$,,`"$$ .` :$|
b$| _m$`,:` :$1 ,` ,$Pm|` ` :$$,..;"' |$:
P$b, _;b$$b$1" |$$ ,` ,$$" ``' $$
```"```'" `"` `""` ""` ,P`
"As a general rule,don't solve puzzles that open portals to Hell"'