lua-users home
lua-l archive

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


Hi,

Jerome Vuarand wrote:
Hakki Dogusan wrote:
- lcario creates two -namespace- tables:
       cairo - for functions
       CAIRO - for constants, enums

    this simplifies translating C code to Lua, ie:
       cairo_set_operator (cr, CAIRO_OPERATOR_ADD);
    becomes:
       cairo.set_operator (cr, CAIRO.OPERATOR_ADD)

Users can achieve the same result pretty easily:

local cairo = require 'lcario'
local CAIRO = cairo

and then the same code ported from C:

cairo.set_operator (cr, CAIRO.OPERATOR_ADD)

That way you don't have to pollute the global namespace with several
symbols (you could even have no global symbol and only use require
return value). You can also put all constants in a sub-table to more
clearly distinguish them:

local cairo = require 'lcario'
local CAIRO = cairo.constants



Ok. I changed code as your first suggestion, ie:
local cairo = require 'lcario'
local CAIRO = cairo

Thanks.


If you don't mind, I'll make ANN here..

- All snippets are working (libsvg snippet is commented)
- PDF, PNG saving is working
- Much of the "not implemented!" messages gone

You can get full library:
http://www.dogusan.net/dogusanh/download/luacairo.zip (3214Kb)

If you previously downloaded above file, you can get updates:
http://www.dogusan.net/dogusanh/download/luacairo-update.zip (301Kb)



--
Regards,
Hakki Dogusan