[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lua-l
Subject:    Re: Change value of upvalue from within function
From:       Rob Hoelz <rob () hoelz ! ro>
Date:       2012-08-22 21:56:20
Message-ID: 20120822235620.7917ca72 () hoelz ! ro
[Download RAW message or body]


An upvalue index is just like a regular stack index, so you can use
lua_replace with it:

  lua_newtable(L);
  lua_replace(L, lua_upvalueindex(1));

-Rob

On Wed, 22 Aug 2012 15:52:12 -0600
Eric Tetz <erictetz@gmail.com> wrote:

> If I have a C function called by Lua. It has an upvalue and I'd like
> to change it's value. Possible?
> 
>    static int closure_that_has_upvalues( lua_State* L )
>    {
>        ...
>        // how can I change the value of, say, the upvalue at
> lua_upvalueindex(1)?
> 


["signature.asc" (application/pgp-signature)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic