diff options
author | scuri <scuri> | 2010-06-10 20:17:50 +0000 |
---|---|---|
committer | scuri <scuri> | 2010-06-10 20:17:50 +0000 |
commit | 2fb345fc972465ade03cc1d527ad3c8db3438ac5 (patch) | |
tree | 3fd9b1f7e2b12fd79c2000c0f305e8ef7763364a /src/lua5 | |
parent | c5f7b4e29afdd70a0f05d8785619585a45916b27 (diff) |
*** empty log message ***
Diffstat (limited to 'src/lua5')
-rw-r--r-- | src/lua5/cdluacairo5.c | 108 | ||||
-rw-r--r-- | src/lua5/cdluacairo5.def | 4 | ||||
-rw-r--r-- | src/lua5/cdluapdf5.c | 4 |
3 files changed, 116 insertions, 0 deletions
diff --git a/src/lua5/cdluacairo5.c b/src/lua5/cdluacairo5.c new file mode 100644 index 0000000..0e99b3c --- /dev/null +++ b/src/lua5/cdluacairo5.c @@ -0,0 +1,108 @@ +/** \file + * \brief Cairo Lua 5 Binding + * + * See Copyright Notice in cd.h + */ + +#include <stdlib.h> +#include <stdio.h> + +#include "cd.h" +#include "cdcairo.h" + +#include <lua.h> +#include <lauxlib.h> + +#include "cdlua.h" +#include "cdlua5_private.h" + + +static void *cdimagergb_checkdata(lua_State* L, int param) +{ + return (void *)luaL_checkstring(L, param); +} + +static cdluaContext cdluaimagergbctx = +{ + 0, + "CAIRO_IMAGERGB", + cdContextCairoImageRGB, + cdimagergb_checkdata, + NULL, + 0 +}; + +static void *cdps_checkdata( lua_State *L, int param) +{ + return (void *)luaL_checkstring(L, param); +} + +static cdluaContext cdluapsctx = +{ + 0, + "CAIRO_PS", + cdContextCairoPS, + cdps_checkdata, + NULL, + 0 +}; + +static void *cdsvg_checkdata( lua_State *L, int param) +{ + return (void *)luaL_checkstring(L, param); +} + +static cdluaContext cdluasvgctx = +{ + 0, + "CAIRO_SVG", + cdContextCairoSVG, + cdsvg_checkdata, + NULL, + 0 +}; + +static void *cdpdf_checkdata(lua_State *L, int param) +{ + return (void *)luaL_checkstring(L, param); +} + +static cdluaContext cdluapdfctx = +{ + 0, + "CAIRO_PDF", + cdContextCairoPDF, + cdpdf_checkdata, + NULL, + 0 +}; + +static int cdlua5_initcairo(lua_State *L) +{ + (void)L; + cdInitContextPlus(); + return 0; +} + +static const struct luaL_reg cdlib[] = { + {"InitContextPlus", cdlua5_initcairo}, + {NULL, NULL}, +}; + + +static int cdluacairo_open (lua_State *L) +{ + cdluaLuaState* cdL = cdlua_getstate(L); + cdInitContextPlus(); + luaL_register(L, "cd", cdlib); /* leave "cd" table at the top of the stack */ + cdlua_addcontext(L, cdL, &cdluapdfctx); + cdlua_addcontext(L, cdL, &cdluapsctx); + cdlua_addcontext(L, cdL, &cdluasvgctx); + cdlua_addcontext(L, cdL, &cdluaimagergbctx); + return 1; +} + +int luaopen_cdluacairo(lua_State* L) +{ + return cdluacairo_open(L); +} diff --git a/src/lua5/cdluacairo5.def b/src/lua5/cdluacairo5.def new file mode 100644 index 0000000..aa12034 --- /dev/null +++ b/src/lua5/cdluacairo5.def @@ -0,0 +1,4 @@ +EXPORTS + luaopen_cdluacairo + +
\ No newline at end of file diff --git a/src/lua5/cdluapdf5.c b/src/lua5/cdluapdf5.c index 40877ad..7fd2ece 100644 --- a/src/lua5/cdluapdf5.c +++ b/src/lua5/cdluapdf5.c @@ -37,7 +37,11 @@ int cdluapdf_open (lua_State *L) { cdluaLuaState* cdL = cdlua_getstate(L); lua_pushliteral(L, "cd"); +#if LUA_VERSION_NUM > 501 + lua_pushglobaltable(L); +#else lua_gettable(L, LUA_GLOBALSINDEX); /* leave "cd" table at the top of the stack */ +#endif cdlua_addcontext(L, cdL, &cdluapdfctx); return 1; } |