lua-users home
lua-l archive

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


Thank you, this worked. Also, GetLuaState() is inlined so declaring it at
the top would make no difference.

I'm not very good with Lua's C interface so perhaps you could help me
understand this. The first line you gave me is pretty self explanatory, but
what is pushliteral doing? And then why do we get and remove the 2nd item on
stack?

-----Original Message-----
From: lua-bounces@bazar2.conectiva.com.br
[mailto:lua-bounces@bazar2.conectiva.com.br] On Behalf Of Daniel Silverstone
Sent: Tuesday, December 18, 2007 1:39 AM
To: lua@bazar2.conectiva.com.br
Subject: Re: Call module function from C

On Tue, 2007-12-18 at 01:31 -0800, Tony Paloma wrote:

First up, instead of:

> lua_getglobal(GetLuaState(), "hook.Call");

Try:

lua_getglobal(GetLuaState(), "hook");
lua_pushliteral(GetLuaState(), "Call");
lua_gettable(GetLuaState(), -2);
lua_remove(GetLuaState(), -2);

Also, I'd be tempted to stuff a lua_State *L = GetLuaState() at the top,
unless GetLuaState is a correctly consted function such that the
compiler can optimise away calls to it.

D.

-- 
Daniel Silverstone                         http://www.digital-scurf.org/
PGP mail accepted and encouraged.            Key Id: 2BC8 4016 2068 7895