From: <ai...@us...> - 2010-12-29 23:30:17
|
Revision: 11400 http://plplot.svn.sourceforge.net/plplot/?rev=11400&view=rev Author: airwin Date: 2010-12-29 23:30:10 +0000 (Wed, 29 Dec 2010) Log Message: ----------- Implement typemaps for the string-returning functions. These typemaps work, but the implementation uses a swig internal detail and doesn't follow the style of other functions that return data to octave so this implementation should be reviewed and improved. Also handle the plSetOpt versus plsetopt octave situation in a simpler way using the %rename directive. Modified Paths: -------------- trunk/bindings/octave/plplot_octave.i trunk/bindings/swig-support/plplotcapi.i Modified: trunk/bindings/octave/plplot_octave.i =================================================================== --- trunk/bindings/octave/plplot_octave.i 2010-12-29 23:24:04 UTC (rev 11399) +++ trunk/bindings/octave/plplot_octave.i 2010-12-29 23:30:10 UTC (rev 11400) @@ -365,20 +365,24 @@ %typemap(argout) (PLFLT *ArrayY, PLINT ny, PLFLT **OutMatrixCk) {} %typemap(freearg) (PLFLT *ArrayY, PLINT ny, PLFLT **OutMatrixCk) {} -/****************************************************************************** - String returning functions -******************************************************************************/ +//----------------------------------------------------------------------------- +// 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] ) {} -%typemap(argout) char *OUTPUT {} +// This currently just used for plgdev, plgfnam, and plgver which +// apparently have a limit of 80 bytes. N.B. This works, but it +// copies what was done by Rafael for matwrap with no deep knowledge +// of octave and uses swig internals (note the use of retval1 as the +// return value). Thus, it needs to be redone by somebody who knows +// what they are doing. +%typemap(in, numinputs=0) char *OUTPUT (octave_value_list retval){ + retval(0) = octave_value(charMatrix(80, 1), true); + $1 = (char *)retval(0).char_matrix_value().data(); +} +%typemap(argout) char *OUTPUT { + return retval1; + } -%typemap(in, checkfn="lua_isstring") const char *message {} - - - typedef PLINT (*defined_func)(PLFLT, PLFLT); typedef void (*fill_func)(PLINT, PLFLT*, PLFLT*); typedef void (*pltr_func)(PLFLT, PLFLT, PLFLT *, PLFLT*, PLPointer); @@ -394,7 +398,9 @@ typedef PLFLT (*f2eval_func)(PLINT, PLINT, PLPointer); typedef void (*label_func)(PLINT, PLFLT, char*, PLINT, PLPointer); %} +// For historical reasons our octave bindings use the name plSetOpt for +// the PLplot function, plsetopt, and use the plsetopt name for a different +// purpose (plsetopt.m). We implement that here using the rename directive. +%rename(plSetOpt) plsetopt; /* swig compatible PLplot API definitions from here on. */ %include plplotcapi.i -// Our Octave interfaces define plsetopt.m which relies on plSetOpt internally. -int plSetOpt( const char *opt, const char *optarg ); Modified: trunk/bindings/swig-support/plplotcapi.i =================================================================== --- trunk/bindings/swig-support/plplotcapi.i 2010-12-29 23:24:04 UTC (rev 11399) +++ trunk/bindings/swig-support/plplotcapi.i 2010-12-29 23:30:10 UTC (rev 11400) @@ -761,12 +761,9 @@ void plsesc( char esc ); -// Octave has its own definition of plsetopt(.m) -#if !defined ( SWIG_OCTAVE ) %feature( "autodoc", "Process input strings, treating them as an option and argument pair. The first is for the external API, the second the work routine declared here for backward compatibility." ) plsetopt; PLINT plsetopt( const char *opt, const char *optarg ); -#endif %feature( "autodoc", "Set family file parameters." ) plsfam; void This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |