[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Simple C++ wrapper
- From: Andre de Leiradella <aleirade@...>
- Date: Sat, 25 Apr 2009 14:58:38 -0300
I've done it once for a project but abandoned it during a major rewrite
of the application. The problem was that I was having to consult the
documentation (err..., the source code) much more that I used to consult
the Lua docs. I ended up with just a couple of functions, one being to
lua_pcall and get a nice stacktrace if things go wrong for example.
Your example is exactly like what I was trying to do, and every time I
had to call State.getTable I wondered what the default argument values
were and if the method would cause any side effects besides calling
lua_gettable.
So from my experience, stick to the Lua API if you're already familiar
with it, and write a couple of functions on top of the API to make your
life easier.
Cheers,
Andre
> Hello,
>
> I'd like to wrap the Lua API in a C++ class to take advantage of
> overloading and default arguments, etc. I looked at Paolo Capriotti's
> library but it seems to be oriented for using C++ objects on the stack.
> I don't need that so much as just a more convenient way to use Lua.
>
> I think something like this would be favorable:
>
> namespace luaxx
> {
> class State
> {
> void getTable(int index = -2)
> { lua_gettable(m_L, index); };
> void getTable(int index = -2, int key = -1)
> {
> if (index < 0 && index > LUA_REGISTRYINDEX)
> index -= 1;
> push(key);
> lua_gettable(m_L, index);
> };
> };
> }
>
> Does anyone have a library already made?
>
> -- tom
> telliamed@whoopdedo.org