From: <sm...@us...> - 2009-01-20 08:05:28
|
Revision: 9353 http://plplot.svn.sourceforge.net/plplot/?rev=9353&view=rev Author: smekal Date: 2009-01-20 08:05:23 +0000 (Tue, 20 Jan 2009) Log Message: ----------- Added new typemaps. pl.parseopt() is now fully supported. All commands are now in the "pl" namespace by default and the "pl" is ripped off from the default function names, so e.g. pllab() in Lua is pl.lab(), except end, which is still called via pl.plend(). Modified Paths: -------------- trunk/bindings/lua/plplotluac.i Modified: trunk/bindings/lua/plplotluac.i =================================================================== --- trunk/bindings/lua/plplotluac.i 2009-01-20 08:00:54 UTC (rev 9352) +++ trunk/bindings/lua/plplotluac.i 2009-01-20 08:05:23 UTC (rev 9353) @@ -148,15 +148,17 @@ /* with preceding count */ %typemap(in) (PLINT n, PLFLT *Array) { - $2 = (PLFLT*)SWIG_get_double_num_array_var(L, $input, &$1); + int temp; + $2 = (PLFLT*)SWIG_get_double_num_array_var(L, $input, &temp); if(!$2) SWIG_fail; - Alen = $1; + $1 = Alen = temp; } %typemap(freearg) (PLINT n, PLFLT *Array) { SWIG_FREE_ARRAY($2); } /* Trailing count and check consistency with previous */ -%typemap(in) (PLFLT *ArrayCk, PLINT n) (int temp) { +%typemap(in) (PLFLT *ArrayCk, PLINT n) { + int temp; $1 = (PLFLT*)SWIG_get_double_num_array_var(L, $input, &temp); if(!$1) SWIG_fail; if(temp != Alen) { @@ -181,7 +183,8 @@ /* No length but remember size to check others */ -%typemap(in) PLFLT *Array (int temp) { +%typemap(in) PLFLT *Array { + int temp; $1 = (PLFLT*)SWIG_get_double_num_array_var(L, $input, &temp); if(!$1) SWIG_fail; Alen = temp; @@ -189,7 +192,139 @@ %typemap(freearg) (PLFLT *Array) { SWIG_FREE_ARRAY($1); } +/* with trailing count */ +%typemap(in) (PLFLT *Array, PLINT n) { + int temp; + $1 = (PLFLT*)SWIG_get_double_num_array_var(L, $input, &temp); + if(!$1) SWIG_fail; + $2 = Alen = temp; +} +%typemap(freearg) (PLFLT *Array, PLINT n) { SWIG_FREE_ARRAY($1); } + + +/* check consistency with X dimension of previous */ +%typemap(in) PLFLT *ArrayCkX { + int temp; + $1 = (PLFLT*)SWIG_get_double_num_array_var(L, $input, &temp); + if(!$1) SWIG_fail; + if(temp != Xlen) { + lua_pushfstring(L, "Tables must be of same length."); + SWIG_fail; + } +} +%typemap(freearg) PLFLT *ArrayCkX { SWIG_FREE_ARRAY($1); } + + +/* check consistency with Y dimension of previous */ +%typemap(in) PLFLT *ArrayCkY { + int temp; + $1 = (PLFLT*)SWIG_get_double_num_array_var(L, $input, &temp); + if(!$1) SWIG_fail; + if(temp != Ylen) { + lua_pushfstring(L, "Tables must be of same length."); + SWIG_fail; + } +} +%typemap(freearg) PLFLT *ArrayCkY { SWIG_FREE_ARRAY($1); } + + +/* set X length for later consistency checking, with trailing count */ +%typemap(in) (PLFLT *ArrayX, PLINT nx) { + int temp; + $1 = (PLFLT*)SWIG_get_double_num_array_var(L, $input, &temp); + if(!$1) SWIG_fail; + $2 = Xlen = temp; +} +%typemap(freearg) (PLFLT *ArrayX, PLINT nx) { SWIG_FREE_ARRAY($1); } + + +/* set X length for later consistency checking */ +%typemap(in) PLFLT *ArrayX { + int temp; + $1 = (PLFLT*)SWIG_get_double_num_array_var(L, $input, &temp); + if(!$1) SWIG_fail; + Xlen = temp; +} +%typemap(freearg) PLFLT *ArrayX { SWIG_FREE_ARRAY($1); } + + +/* Set Y length for later consistency checking, with trailing count */ +%typemap(in) (PLFLT *ArrayY, PLINT ny) { + int temp; + $1 = (PLFLT*)SWIG_get_double_num_array_var(L, $input, &temp); + if(!$1) SWIG_fail; + $2 = Ylen = temp; +} +%typemap(freearg) (PLFLT *ArrayY, PLINT ny) { SWIG_FREE_ARRAY($1); } + + +/* set Y length for later consistency checking */ +%typemap(in) PLFLT *ArrayY { + int temp; + $1 = (PLFLT*)SWIG_get_double_num_array_var(L, $input, &temp); + if(!$1) SWIG_fail; + Ylen = temp; +} +%typemap(freearg) (PLFLT *ArrayY) { SWIG_FREE_ARRAY($1); } + + +/* 2D array with trailing dimensions, check consistency with previous */ +%typemap(in) (PLFLT **MatrixCk, PLINT nx, PLINT ny) { +} +%typemap(freearg) (PLFLT **MatrixCk, PLINT nx, PLINT ny) { +} + + +/* 2D array with trailing dimensions, set the X, Y size for later checking */ +%typemap(in) (PLFLT **Matrix, PLINT nx, PLINT ny) { +} +%typemap(freearg) (PLFLT **Matrix, PLINT nx, PLINT ny) { +} + + +/* 2D array with no dimensions, set the X, Y size for later checking */ +%typemap(in) PLFLT **Matrix { +} +%typemap(freearg) PLFLT **Matrix { +} + + +/* for plshade1, note the difference in the type for the first arg */ +%typemap(in) (PLFLT *Matrix, PLINT nx, PLINT ny) { +} +%typemap(freearg) (PLFLT *Matrix, PLINT nx, PLINT ny) { +} + +/* 2D array, check for consistency */ +%typemap(in) PLFLT **MatrixCk { +} +%typemap(freearg) PLFLT **MatrixCk { +} + +/* 2D array, check for consistency input / output version */ +%typemap(in) PLFLT **OutMatrixCk { +} +%typemap(freearg) PLFLT **OutMatrixCk { +} + + /****************************************************************************** + String returning functions +******************************************************************************/ + +/* This currently just used for plgdev, plgfnam, and plgver which apparently + * have a limit of 80 bytes. But to (hopefully) be safe for any future use + * have a 1000 byte limit here. */ +%typemap(in, numinputs=0) char *OUTPUT ( char buff[1000] ) { + $1 = buff; +} +/*%typemap(argout,fragment="t_output_helper") char *OUTPUT { + PyObject *o = PyString_FromString($1); + $result = t_output_helper($result,o); +}*/ + + +/****************************************************************************** Function calls ******************************************************************************/ @@ -230,14 +365,9 @@ } /* Process options list using current options info. */ -%typemap(in) (int *p_argc, const char **argv) { +%typemap(in, checkfn="lua_istable") (int *p_argc, const char **argv) { int i, n; - if(!lua_istable(L, $input)) { - lua_pushstring(L,"expected a table"); - SWIG_fail; - } - lua_pushstring(L, "n"); lua_gettable(L, $input); if(!lua_isnumber(L, -1)) { @@ -247,16 +377,14 @@ n = (int)lua_tonumber(L, -1); lua_pop(L, 1); /* remove number */ n=n+1; /* since lua only counts the options */ - printf("n=%d\n", n); $1 = &n; - $2 = SWIG_ALLOC_ARRAY(char*, n+1); + $2 = SWIG_ALLOC_ARRAY(char*, (n+1)); for(i = 0; i < n; i++) { lua_rawgeti(L, $input, i); if(lua_isstring(L, -1)) { $2[i] = (char*)lua_tostring(L, -1); - printf("argv[%d]=%s\n", i, $2[i]); } else { lua_pop(L,1); lua_pushfstring(L, "List items must be strings"); @@ -265,15 +393,11 @@ } lua_pop(L,1); } - puts("here"); $2[n] = NULL; } %typemap(freearg) (int *p_argc, const char **argv) { SWIG_FREE_ARRAY($2); } -%typemap(in,checkfn="lua_isnumber") PLINT mode { - $1 = ((int)lua_tonumber(L,$input)) | PL_PARSE_NODELETE; -} %ignore plshades; @@ -289,6 +413,158 @@ Renames ******************************************************************************/ %rename(parseopts) plparseopts; +%rename(adv) pladv; +%rename(axes) plaxes; +%rename(bin) plbin; +%rename(bop) plbop; +%rename(box) plbox; +%rename(box3) plbox3; +%rename(calworld) plcalworld; +%rename(clear) plclear; +%rename(col0) plcol0; +%rename(col1) plcol1; +%rename(cont) plcont; +%rename(cpstrm) plcpstrm; +%rename(plend) plend; +%rename(end1) plend1; +%rename(env) plenv; +%rename(env0) plenv0; +%rename(eop) pleop; +%rename(errx) plerrx; +%rename(erry) plerry; +%rename(famadv) plfamadv; +%rename(fill) plfill; +%rename(fill3) plfill3; +%rename(flush) plflush; +%rename(font) plfont; +%rename(fontld) plfontld; +%rename(gchr) plgchr; +%rename(gcol0) plgcol0; +%rename(gcolbg) plgcolbg; +%rename(gcol0a) plgcol0a; +%rename(gcolbga) plgcolbga; +%rename(gcompression) plgcompression; +%rename(gdev) plgdev; +%rename(gdidev) plgdidev; +%rename(gdiori) plgdiori; +%rename(gdiplt) plgdiplt; +%rename(gfam) plgfam; +%rename(gfci) plgfci; +%rename(gfnam) plgfnam; +%rename(gfont) plgfont; +%rename(glevel) plglevel; +%rename(gpage) plgpage; +%rename(gra) plgra; +%rename(griddata) plgriddata; +%rename(gspa) plgspa; +%rename(gstrm) plgstrm; +%rename(gver) plgver; +%rename(gvpd) plgvpd; +%rename(gvpw) plgvpw; +%rename(gxax) plgxax; +%rename(gyax) plgyax; +%rename(gzax) plgzax; +%rename(hist) plhist; +%rename(hls) plhls; +%rename(hlsrgb) plhlsrgb; +%rename(image) plimage; +%rename(imagefr) plimagefr; +%rename(init) plinit; +%rename(join) pljoin; +%rename(lab) pllab; +%rename(lightsource) pllightsource; +%rename(line) plline; +%rename(line3) plline3; +%rename(lsty) pllsty; +%rename(map) plmap; +%rename(meridians) plmeridians; +%rename(mesh) plmesh; +%rename(meshc) plmeshc; +%rename(mkstrm) plmkstrm; +%rename(mtex) plmtex; +%rename(mtex3) plmtex3; +%rename(ot3d) plot3d; +%rename(ot3dc) plot3dc; +%rename(ot3dcl) plot3dcl; +%rename(parseopts) plparseopts; +%rename(pat) plpat; +%rename(poin) plpoin; +%rename(poin3) plpoin3; +%rename(poly3) plpoly3; +%rename(prec) plprec; +%rename(psty) plpsty; +%rename(ptex) plptex; +%rename(ptex3) plptex3; +%rename(randd) plrandd; +%rename(replot) plreplot; +%rename(rgb) plrgb; +%rename(rgb1) plrgb1; +%rename(rgbhls) plrgbhls; +%rename(schr) plschr; +%rename(scmap0) plscmap0; +%rename(scmap0a) plscmap0a; +%rename(scmap0n) plscmap0n; +%rename(scmap1) plscmap1; +%rename(scmap1a) plscmap1a; +%rename(scmap1l) plscmap1l; +%rename(scmap1la) plscmap1la; +%rename(scmap1n) plscmap1n; +%rename(scol0) plscol0; +%rename(scol0a) plscol0a; +%rename(scolbg) plscolbg; +%rename(scolbga) plscolbga; +%rename(scolor) plscolor; +%rename(scompression) plscompression; +%rename(sdev) plsdev; +%rename(sdidev) plsdidev; +%rename(sdimap) plsdimap; +%rename(sdiori) plsdiori; +%rename(sdiplt) plsdiplt; +%rename(sdiplz) plsdiplz; +%rename(seed) plseed; +%rename(sesc) plsesc; +%rename(setopt) plsetopt; +%rename(sfam) plsfam; +%rename(sfci) plsfci; +%rename(sfnam) plsfnam; +%rename(sfont) plsfont; +%rename(shade) plshade; +%rename(shade1) plshade1; +%rename(shades) plshades; +%rename(smaj) plsmaj; +%rename(smem) plsmem; +%rename(smin) plsmin; +%rename(sori) plsori; +%rename(spage) plspage; +%rename(spause) plspause; +%rename(sstrm) plsstrm; +%rename(ssub) plssub; +%rename(ssym) plssym; +%rename(star) plstar; +%rename(start) plstart; +%rename(stripa) plstripa; +%rename(stripc) plstripc; +%rename(stripd) plstripd; +%rename(styl) plstyl; +%rename(surf3d) plsurf3d; +%rename(surf3dl) plsurf3dl; +%rename(svect) plsvect; +%rename(svpa) plsvpa; +%rename(sxax) plsxax; +%rename(syax) plsyax; +%rename(sym) plsym; +%rename(szax) plszax; +%rename(text) pltext; +%rename(timefmt) pltimefmt; +%rename(vasp) plvasp; +%rename(vect) plvect; +%rename(vpas) plvpas; +%rename(vpor) plvpor; +%rename(vsta) plvsta; +%rename(w3d) plw3d; +%rename(wid) plwid; +%rename(wind) plwind; +%rename(xormod) plxormod; /* swig compatible PLplot API definitions from here on. */ %include plplotcapi.i This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |