lua-users home
lua-l archive

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


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);
       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


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: (3214Kb)

If you previously downloaded above file, you can get updates: (301Kb)

Hakki Dogusan