From: Jonathan S. <jjs...@us...> - 2006-10-23 01:01:38
|
Update of /cvsroot/octaviz/octaviz/Wrapping In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv31562/Wrapping Modified Files: vtkWrapOctave.c Log Message: patches for vtk 5 and gcc 4.1 Index: vtkWrapOctave.c =================================================================== RCS file: /cvsroot/octaviz/octaviz/Wrapping/vtkWrapOctave.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- vtkWrapOctave.c 7 Mar 2005 02:06:54 -0000 1.4 +++ vtkWrapOctave.c 23 Oct 2006 01:01:33 -0000 1.5 @@ -57,6 +57,16 @@ j++; } else { + // double escape everything that is escaped; + // gcc doesn't like things like \$, \frac, \sum, ... + // in strings; luckily, this happens only in + // the 'Descriptions:' field + if (wrappedFunctions[i]->Comment[j] == '\\') + { + fprintf(fp, "\\\\"); + j++; + } + fprintf(fp,"%c",wrappedFunctions[i]->Comment[j++]); } } @@ -576,6 +586,7 @@ void vtkParseOutput(FILE *fp, FileInfo *data) { int i,j; + int in_example; fprintf(fp,"// Octave wrapper for %s object\n//\n",data->ClassName); @@ -623,19 +634,62 @@ /* Make the function that is callable from octave */ /* Add class description into the function. */ /* This will displayed as help in octave */ - fprintf(fp,"\nDEFUN_DLD ( %s, args, nargout, \n \"%s \\n\\\n \\n\\\n ",data->ClassName,data->ClassName); + fprintf(fp,"\nDEFUN_DLD ( %s, args, nargout, \n", data->ClassName); + fprintf(fp," \"-*- texinfo -*-\\n\\\n"); + fprintf(fp,"@deftypefn {Built-in Function} {} %s\\n\\\n\\n\\\n", data->ClassName); i = 0; + in_example = 0; if ( data->Description != NULL ) while ( data->Description[i] != 0 ) { if ( data->Description[i] == '"' ) fprintf(fp,"\\"); - + + /* Curly braces are special characters in Texinfo. Quote them. */ + if ( data->Description[i] == '{' || data->Description[i] == '}' ) + fprintf(fp,"@"); + + /* Replace `\code [...] \endcode' constructs by the texinfo equivalent + @example [..] @end example' */ + if (strncmp (data->Description + i, "\\code", 5) == 0) { + fprintf(fp,"@example"); + in_example = 1; + i += 5; + } + if (strncmp (data->Description + i, "\\endcode", 8) == 0) { + fprintf(fp,"@end example"); + in_example = 0; + i += 8; + } + /* Skip emphasis markup. This could be replaced by @emph, + but it is trick because @emph needs a bracketed argument */ + if (strncmp (data->Description + i, "\\em", 3) == 0) { + i += 3; + } + /* Unscape \sum macro */ + if (strncmp (data->Description + i, "\\sum", 4) == 0) { + i += 1; + } + + /* Unscape \pre macro -- this will probably look like shit in the final .oct files */ + if (strncmp (data->Description + i, "\\pre", 4) == 0) { + i += 1; + } + + /* Unscape \post macro -- this will probably look like shit in the final .oct files */ + if (strncmp (data->Description + i, "\\post", 5) == 0) { + i += 1; + } + if ( data->Description[i] == '\n' ) { /* Don't want the last newline */ if ( i + 2 < strlen(data->Description) ) { - fprintf(fp,"\\n\\\n "); + fprintf(fp,"\\n\\\n"); + /* Eat spaces at beginning of lines */ + if (in_example != 1) + while (data->Description[i + 1] == ' ') + i++; } i++; } else @@ -643,7 +697,7 @@ fprintf(fp,"%c",data->Description[i++]); } } - fprintf(fp,"\")\n{\n" ); + fprintf(fp,"\\n\\\n@end deftypefn\")\n{\n" ); fprintf(fp," octave_value retval;\n" ); /* This associative map holds help for each method (if avaliable) */ |