[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Store reference to a function to be called later
- From: Jose Marin <jose_marin2@...>
- Date: Fri, 12 Aug 2011 06:10:19 -0700 (PDT)
I´ve just read the manual section about luaL_ref and _unref, and seems the way to go.
--- Em sex, 12/8/11, Rob Kendrick <firstname.lastname@example.org> escreveu:
> De: Rob Kendrick <email@example.com>
> Assunto: Re: Store reference to a function to be called later
> Para: "Lua mailing list" <firstname.lastname@example.org>
> Data: Sexta-feira, 12 de Agosto de 2011, 9:43
> On Fri, Aug 12, 2011 at 04:57:08AM
> -0700, Jose Marin wrote:
> > I wouldn´t like to store the string "OnPlay", and
> make a search on the register for the function, would like
> to store the reference to the fucntion itself, to be
> directly called when the button is pressed.
> > Any suggestions?
> You can't take the actual reference to the function, as
> this would
> defeat the garbage collector, as Lua won't know when your C
> code is done
> with it.
> Look at luaL_ref and _unref. These will give you an
> integer "handle" to
> a Lua value that you can then store and easily lookup when
> you need to.