[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [ANN] LuaCairo and CairoPad updated
- From: Asko Kauppi <askok@...>
- Date: Mon, 17 Nov 2008 22:04:17 +0200
I think with the OO approach one should go strictly with the official
Anything else would mean one needs to do and maintain heavy
documentation. Also, it will be easier to sell an implementation if
it does not deviate from an existing well designed API.
Hakki Dogusan kirjoitti 17.11.2008 kello 18:52:
Asko Kauppi wrote:
Thanks for the heads up.
Thanks. I was resisted to adapt 2.8.x (all new Cairo functions got
"not implemented!" status). But at least we can have fixes for old
Would you consider adopting an object-like interface, instead of
the C-like you currently use? This is the #1 issue keeping me away
from LuaCairo and using others (oocairo).
The Cairo C++ API (cairomm) could be used as a reference API. It is
as official as the C API is.
Your current sample (now and "then"):
[oo example snipped]
I tried to hack my code to add an oo style. It seems work. But
before to work for complete implementation, I need your advice: Do
you see any logic error in the following solution?
cr = cairo.create(cs) -- creates a cairo_t* lightuserdata
-- Current style
-- OO style
ctx = cairo.Context(cr) -- creates a Context userdata
They are implemented as:
static int l_cairo_save(lua_State* L)
cairo_t *cr = (cairo_t *) check_lightuserdata(L, 1);
static int ool_cairo_save(lua_State* L)
static void replace_context_with_cairo_t (lua_State *L)
Context *o = check_contextud(L, 1); // o ...
lua_pushlightuserdata(L, o->cr_); // o ... cr
lua_replace(L, 1); // cr ...
Ie. if a Cairo API function has cairo_t* as first parameter then;
-- put it in Context userdata's API
-- when called, forward it to existing l_xxx() brother.
Is it logical or am I hallucinating :)