From e9a184546b18cf3b796bd560561f312934004c54 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Thu, 9 Sep 2010 01:48:52 +0200 Subject: Upgrading to CD 5.4 - and cleaning up. --- cd/src/lua5/cdlua5.c | 20 ++++++++---- cd/src/lua5/cdlua5.def | 1 - cd/src/lua5/cdlua5_canvas.c | 45 ++++++++++++++------------ cd/src/lua5/cdlua5ctx.c | 67 ++++++++++++++++++++++++++++++++++++--- cd/src/lua5/cdluacontextplus5.c | 5 --- cd/src/lua5/cdluacontextplus5.def | 1 - cd/src/lua5/cdluaim5.c | 5 --- cd/src/lua5/cdluaim5.def | 1 - cd/src/lua5/cdluapdf5.c | 8 ++--- cd/src/lua5/cdluapdf5.def | 1 - cd/src/lua5/cdvoid5.c | 6 ++-- 11 files changed, 109 insertions(+), 51 deletions(-) (limited to 'cd/src/lua5') diff --git a/cd/src/lua5/cdlua5.c b/cd/src/lua5/cdlua5.c index cd7554f..9c981c3 100755 --- a/cd/src/lua5/cdlua5.c +++ b/cd/src/lua5/cdlua5.c @@ -87,7 +87,7 @@ static cdluaPalette* cdlua_rawcheckpalette(lua_State *L, int param) } } } - luaL_typerror(L, param, "cdPalette"); /* else error */ + luaL_typeerror(L, param, "cdPalette"); /* else error */ return NULL; /* to avoid warnings */ } @@ -1428,8 +1428,21 @@ static const struct cdlua5_constant cdlibconstant[] = { {"CLIP" , CD_CLIP}, {"BEZIER" , CD_BEZIER}, {"REGION" , CD_REGION}, + {"PATH" , CD_PATH}, {"POLYCUSTOM" , CD_POLYCUSTOM}, + /* path actions */ + {"PATH_NEW", CD_PATH_NEW}, + {"PATH_MOVETO", CD_PATH_MOVETO}, + {"PATH_LINETO", CD_PATH_LINETO}, + {"PATH_ARC", CD_PATH_ARC}, + {"PATH_CURVETO", CD_PATH_CURVETO}, + {"PATH_CLOSE", CD_PATH_CLOSE}, + {"PATH_FILL", CD_PATH_FILL}, + {"PATH_STROKE", CD_PATH_STROKE}, + {"PATH_FILLSTROKE", CD_PATH_FILLSTROKE}, + {"PATH_CLIP", CD_PATH_CLIP}, + /* fill mode */ {"EVENODD", CD_EVENODD}, {"WINDING", CD_WINDING}, @@ -1841,8 +1854,3 @@ int luaopen_cdlua(lua_State* L) { return cdlua_open(L); } - -int luaopen_cdlua51(lua_State* L) -{ - return cdlua_open(L); -} diff --git a/cd/src/lua5/cdlua5.def b/cd/src/lua5/cdlua5.def index b4811b2..2a14843 100755 --- a/cd/src/lua5/cdlua5.def +++ b/cd/src/lua5/cdlua5.def @@ -8,6 +8,5 @@ EXPORTS cdlua_checkcanvas cdlua_pushcanvas luaopen_cdlua - luaopen_cdlua51 cdlua_pushbitmap cdlua_checkbitmap \ No newline at end of file diff --git a/cd/src/lua5/cdlua5_canvas.c b/cd/src/lua5/cdlua5_canvas.c index f3b929d..c2f6008 100755 --- a/cd/src/lua5/cdlua5_canvas.c +++ b/cd/src/lua5/cdlua5_canvas.c @@ -1494,7 +1494,7 @@ static int wdlua5_gettextbox(lua_State *L) } /***************************************************************************************************************\ -* cd.GetTextBounds(x, y: number, text: string) -> (rect0, rect1, rect2, rect3, rect4, rect5, rect6, rect7: number) * +* cd.GetTextBounds(x, y: number, text: string) -> (rect: table) * \***************************************************************************************************************/ static int cdlua5_gettextbounds(lua_State *L) { @@ -1502,21 +1502,20 @@ static int cdlua5_gettextbounds(lua_State *L) int x = luaL_checkint(L, 2); int y = luaL_checkint(L, 3); const char* s = luaL_checkstring(L, 4); + int i; cdCanvasGetTextBounds(cdlua_checkcanvas(L, 1), x, y, s, rect); - lua_pushnumber(L, rect[0]); - lua_pushnumber(L, rect[1]); - lua_pushnumber(L, rect[2]); - lua_pushnumber(L, rect[3]); - lua_pushnumber(L, rect[4]); - lua_pushnumber(L, rect[5]); - lua_pushnumber(L, rect[6]); - lua_pushnumber(L, rect[7]); - return 4; + lua_newtable(L); + for (i=0; i < 8; i++) + { + lua_pushnumber(L, rect[i]); + lua_rawseti(L, -2, i+1); + } + return 1; } /****************************************************************************************************************\ -* cd.wGetTextBounds(x, y: number, text: string) -> (rect0, rect1, rect2, rect3, rect4, rect5, rect6, rect7: number) * +* cd.wGetTextBounds(x, y: number, text: string) -> (rect: table) * \****************************************************************************************************************/ static int wdlua5_gettextbounds(lua_State *L) { @@ -1524,17 +1523,16 @@ static int wdlua5_gettextbounds(lua_State *L) double x = luaL_checknumber(L, 2); double y = luaL_checknumber(L, 3); const char* s = luaL_checkstring(L, 4); + int i; wdCanvasGetTextBounds(cdlua_checkcanvas(L, 1), x, y, s, rect); - lua_pushnumber(L, rect[0]); - lua_pushnumber(L, rect[1]); - lua_pushnumber(L, rect[2]); - lua_pushnumber(L, rect[3]); - lua_pushnumber(L, rect[4]); - lua_pushnumber(L, rect[5]); - lua_pushnumber(L, rect[6]); - lua_pushnumber(L, rect[7]); - return 4; + lua_newtable(L); + for (i=0; i < 8; i++) + { + lua_pushnumber(L, rect[i]); + lua_rawseti(L, -2, i+1); + } + return 1; } @@ -2205,6 +2203,12 @@ static int cdlua5_vertex(lua_State *L) return 0; } +static int cdlua5_pathset(lua_State *L) +{ + cdCanvasPathSet(cdlua_checkcanvas(L, 1), luaL_checkint(L, 2)); + return 0; +} + static int wdlua5_vertex(lua_State *L) { wdCanvasVertex(cdlua_checkcanvas(L, 1), luaL_checknumber(L, 2), luaL_checknumber(L, 3)); @@ -2429,6 +2433,7 @@ static const struct luaL_reg cdlib_canvas_meta[] = { /* Polygon */ {"Begin" , cdlua5_begin}, + {"PathSet" , cdlua5_pathset}, {"Vertex" , cdlua5_vertex}, {"wVertex" , wdlua5_vertex}, {"fVertex" , cdlua5_fvertex}, diff --git a/cd/src/lua5/cdlua5ctx.c b/cd/src/lua5/cdlua5ctx.c index 4d97f3b..71f090d 100755 --- a/cd/src/lua5/cdlua5ctx.c +++ b/cd/src/lua5/cdlua5ctx.c @@ -1,5 +1,5 @@ /***************************************************************************\ -* $Id: cdlua5ctx.c,v 1.2 2009/12/02 20:31:02 scuri Exp $ +* $Id: cdlua5ctx.c,v 1.4 2010/06/11 17:28:56 scuri Exp $ * * \***************************************************************************/ @@ -25,7 +25,9 @@ #include "cdps.h" #include "cdsvg.h" #include "cddbuf.h" -#include "cdgdiplus.h" +#include "cddebug.h" +#include "cdpicture.h" + #include #include @@ -320,6 +322,24 @@ static cdluaContext cdluadbufctx = 0 }; +/***************************************************************************\ +* CD_DBUFFERRGB. * +\***************************************************************************/ +static void *cddbufrgb_checkdata(lua_State * L, int param) +{ + return cdlua_checkcanvas(L, param); +} + +static cdluaContext cdluadbufrgbctx = +{ + 0, + "DBUFFERRGB", + cdContextDBufferRGB, + cddbufrgb_checkdata, + NULL, + 0 +}; + /***************************************************************************\ * CD_IMAGE. * \***************************************************************************/ @@ -377,7 +397,7 @@ static void *cdimagergb_checkdata(lua_State* L, int param) int ret = cdlua_rawchecktype(L, param, "cdBitmap"); if (ret == 0) - luaL_typerror(L, param, "cdBitmap"); /* not a user data and not a metatable */ + luaL_typeerror(L, param, "cdBitmap"); /* not a user data and not a metatable */ if (ret == 1) { @@ -467,7 +487,7 @@ static void *cdimagergb_checkdata(lua_State* L, int param) return data_s; } - luaL_typerror(L, param, "cdBitmap"); /* is a metatable but it is not one of the accepted */ + luaL_typeerror(L, param, "cdBitmap"); /* is a metatable but it is not one of the accepted */ } return data_s; @@ -619,6 +639,42 @@ static int emf_sizecb(cdCanvas *canvas, int w, int h, double mm_w, double mm_h) return luaL_checkint(L,-1); } +/***************************************************************************\ +* CD_PICTURE. * +\***************************************************************************/ +static void *cdpicture_checkdata(lua_State *L,int param) +{ + return (void *)luaL_checkstring(L,param); +} + +static cdluaContext cdluapicturectx = +{ + 0, + "PICTURE", + cdContextPicture, + cdpicture_checkdata, + NULL, + 0 +}; + +/***************************************************************************\ +* CD_DEBUG. * +\***************************************************************************/ +static void *cddebug_checkdata(lua_State *L,int param) +{ + return (void *)luaL_checkstring(L,param); +} + +static cdluaContext cdluadebugctx = +{ + 0, + "DEBUG", + cdContextDebug, + cddebug_checkdata, + NULL, + 0 +}; + /***************************************************************************\ * CD_METAFILE. * \***************************************************************************/ @@ -811,6 +867,8 @@ void cdlua_initdrivers(lua_State * L, cdluaLuaState* cdL) cdlua_addcontext(L, cdL, &cdluadgnctx); cdlua_addcontext(L, cdL, &cdluacgmctx); cdlua_addcontext(L, cdL, &cdluamfctx); + cdlua_addcontext(L, cdL, &cdluadebugctx); + cdlua_addcontext(L, cdL, &cdluapicturectx); cdlua_addcontext(L, cdL, &cdluapsctx); cdlua_addcontext(L, cdL, &cdluasvgctx); cdlua_addcontext(L, cdL, &cdluaclipboardctx); @@ -819,4 +877,5 @@ void cdlua_initdrivers(lua_State * L, cdluaLuaState* cdL) cdlua_addcontext(L, cdL, &cdluawmfctx); cdlua_addcontext(L, cdL, &cdluaemfctx); cdlua_addcontext(L, cdL, &cdluadbufctx); + cdlua_addcontext(L, cdL, &cdluadbufrgbctx); } diff --git a/cd/src/lua5/cdluacontextplus5.c b/cd/src/lua5/cdluacontextplus5.c index de69167..aa19633 100755 --- a/cd/src/lua5/cdluacontextplus5.c +++ b/cd/src/lua5/cdluacontextplus5.c @@ -37,8 +37,3 @@ int luaopen_cdluacontextplus(lua_State* L) { return cdluacontextplus_open(L); } - -int luaopen_cdluacontextplus51(lua_State* L) -{ - return cdluacontextplus_open(L); -} diff --git a/cd/src/lua5/cdluacontextplus5.def b/cd/src/lua5/cdluacontextplus5.def index 55e478b..69bdb2c 100755 --- a/cd/src/lua5/cdluacontextplus5.def +++ b/cd/src/lua5/cdluacontextplus5.def @@ -1,4 +1,3 @@ EXPORTS luaopen_cdluacontextplus - luaopen_cdluacontextplus51 \ No newline at end of file diff --git a/cd/src/lua5/cdluaim5.c b/cd/src/lua5/cdluaim5.c index 815cd0f..579c2c9 100755 --- a/cd/src/lua5/cdluaim5.c +++ b/cd/src/lua5/cdluaim5.c @@ -285,8 +285,3 @@ int luaopen_cdluaim(lua_State *L) { return cdluaim_open(L); } - -int luaopen_cdluaim51(lua_State *L) -{ - return cdluaim_open(L); -} diff --git a/cd/src/lua5/cdluaim5.def b/cd/src/lua5/cdluaim5.def index 0b26928..df8d982 100755 --- a/cd/src/lua5/cdluaim5.def +++ b/cd/src/lua5/cdluaim5.def @@ -1,4 +1,3 @@ EXPORTS cdluaim_open luaopen_cdluaim - luaopen_cdluaim51 diff --git a/cd/src/lua5/cdluapdf5.c b/cd/src/lua5/cdluapdf5.c index eb3f221..7fd2ece 100755 --- a/cd/src/lua5/cdluapdf5.c +++ b/cd/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; } @@ -47,7 +51,3 @@ int luaopen_cdluapdf(lua_State* L) return cdluapdf_open(L); } -int luaopen_cdluapdf51(lua_State* L) -{ - return cdluapdf_open(L); -} diff --git a/cd/src/lua5/cdluapdf5.def b/cd/src/lua5/cdluapdf5.def index bfbc889..8555b36 100755 --- a/cd/src/lua5/cdluapdf5.def +++ b/cd/src/lua5/cdluapdf5.def @@ -1,4 +1,3 @@ EXPORTS cdluapdf_open luaopen_cdluapdf - luaopen_cdluapdf51 \ No newline at end of file diff --git a/cd/src/lua5/cdvoid5.c b/cd/src/lua5/cdvoid5.c index 2424e1d..67c2c99 100755 --- a/cd/src/lua5/cdvoid5.c +++ b/cd/src/lua5/cdvoid5.c @@ -80,9 +80,9 @@ void cdinittable(cdCanvas* canvas) canvas->cxArc = (void ( *)(cdCtxCanvas*, int ,int ,int ,int ,double ,double ))cdvoid_error; canvas->cxSector = (void ( *)(cdCtxCanvas*, int ,int ,int ,int ,double ,double ))cdvoid_error; canvas->cxChord = (void ( *)(cdCtxCanvas*, int ,int ,int ,int ,double ,double ))cdvoid_error; - canvas->cxText = (void (*)(cdCtxCanvas*, int ,int ,const char *))cdvoid_error; + canvas->cxText = (void (*)(cdCtxCanvas*, int ,int ,const char *, int))cdvoid_error; canvas->cxGetFontDim = (void (*)(cdCtxCanvas*, int *,int *,int *,int *))cdvoid_error; - canvas->cxGetTextSize = (void (*)(cdCtxCanvas*, const char *,int *,int *))cdvoid_error; + canvas->cxGetTextSize = (void (*)(cdCtxCanvas*, const char *,int,int *,int *))cdvoid_error; canvas->cxPutImageRectRGB = (void (*)(cdCtxCanvas*, int ,int ,const unsigned char *,const unsigned char *,const unsigned char *,int ,int ,int ,int ,int ,int ,int ,int ))cdvoid_error; canvas->cxPutImageRectRGBA = (void (*)(cdCtxCanvas*, int ,int ,const unsigned char *,const unsigned char *,const unsigned char *,const unsigned char *,int ,int ,int ,int ,int ,int ,int ,int ))cdvoid_error; canvas->cxPutImageRectMap = (void (*)(cdCtxCanvas*, int ,int ,const unsigned char *,const long *,int ,int ,int ,int ,int ,int ,int ,int ))cdvoid_error; @@ -93,7 +93,7 @@ void cdinittable(cdCanvas* canvas) canvas->cxFBox = (void (*)(cdCtxCanvas*, double ,double ,double ,double ))cdvoid_error; canvas->cxFArc = (void (*)(cdCtxCanvas*, double ,double ,double ,double ,double ,double ))cdvoid_error; canvas->cxFSector = (void (*)(cdCtxCanvas*, double ,double ,double ,double ,double ,double ))cdvoid_error; - canvas->cxFText = (void (*)(cdCtxCanvas*, double ,double ,const char *))cdvoid_error; + canvas->cxFText = (void (*)(cdCtxCanvas*, double ,double ,const char *,int))cdvoid_error; canvas->cxStipple = (void (*)(cdCtxCanvas*, int ,int ,const unsigned char *))cdvoid_error; canvas->cxPattern = (void (*)(cdCtxCanvas*, int ,int , const long *))cdvoid_error; canvas->cxNativeFont = (int (*)(cdCtxCanvas*, const char*))cdvoid_error; -- cgit v1.2.3