From: Jonathan S. <jjs...@us...> - 2010-02-03 16:10:45
|
Update of /cvsroot/octaviz/octaviz/Wrapping In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv22427/Wrapping Modified Files: lex.yy.c vtkParse.l vtkParse.tab.c vtkParse.y vtkWrapOctave.c Added Files: y.tab.c Log Message: attempt to get octaviz working with vtk-5.2, courtesy of Andreas Potschka Index: vtkParse.y =================================================================== RCS file: /cvsroot/octaviz/octaviz/Wrapping/vtkParse.y,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- vtkParse.y 1 Mar 2005 02:13:29 -0000 1.2 +++ vtkParse.y 3 Feb 2010 16:10:37 -0000 1.3 @@ -196,6 +196,7 @@ %token ViewportCoordinateMacro %token WorldCoordinateMacro %token TypeMacro +%token ExportedTypeRevisionMacro %% /* @@ -310,7 +311,7 @@ static_mod: STATIC {postSig("static ");}; -any_id: VTK_ID {postSig($<str>1);} | ID {postSig($<str>1);}; +any_id: VTK_ID { postSig($<str>1);} | ID {postSig($<str>1);}; func_body: ';' | '{' maybe_other '}' ';' @@ -319,7 +320,7 @@ args_list: | more_args; -more_args: arg { currentFunction->NumberOfArguments++;} +more_args: arg { currentFunction->NumberOfArguments++; } | arg { currentFunction->NumberOfArguments++; postSig(", ");} ',' more_args; arg: type @@ -409,8 +410,7 @@ /* store the string into the return value just in case we need it */ /* this is a parsing hack because the first "type" parser will */ /* possibly be ht ereturn type of the first argument */ - if ((!currentFunction->ReturnClass) && - (!currentFunction->NumberOfArguments)) + if ((!currentFunction->ReturnClass) && (!currentFunction->NumberOfArguments)) { currentFunction->ReturnClass = vtkstrdup($1); } @@ -419,12 +419,12 @@ optional_scope: | ':' scope_list; scope_list: scope_type VTK_ID - { + { data.SuperClasses[data.NumberOfSuperClasses] = vtkstrdup($2); data.NumberOfSuperClasses++; } | scope_type VTK_ID - { + { data.SuperClasses[data.NumberOfSuperClasses] = vtkstrdup($2); data.NumberOfSuperClasses++; } ',' scope_list; @@ -485,6 +485,8 @@ {postSig(");"); openSig = 0;} ',' maybe_other_no_semi ')' { char *local = vtkstrdup(currentFunction->Signature); + char *savedReturnClass = NULL; + if (currentFunction->ReturnClass) savedReturnClass = vtkstrdup(currentFunction->ReturnClass); sscanf (currentFunction->Signature, "%*s %*s (%s);", local); sprintf(temps,"Set%s",$<str>3); currentFunction->Name = vtkstrdup(temps); @@ -501,6 +503,7 @@ currentFunction->Name = vtkstrdup(temps); currentFunction->NumberOfArguments = 0; currentFunction->ReturnType = $<integer>6; + currentFunction->ReturnClass = savedReturnClass; output_function(); currentFunction->Signature = (char *)malloc(2048); @@ -510,6 +513,7 @@ currentFunction->Name = vtkstrdup(temps); currentFunction->NumberOfArguments = 0; currentFunction->ReturnType = $<integer>6; + currentFunction->ReturnClass = savedReturnClass; output_function(); } | SetObjectMacro '(' any_id ',' @@ -946,6 +950,57 @@ output_function(); } } +| ExportedTypeRevisionMacro '(' any_id ',' any_id ',' ')' + { + currentFunction->Signature = (char *)malloc(2048); + sigAllocatedLength = 2048; + sprintf(currentFunction->Signature, "const char *GetClassName ();"); + sprintf(temps,"GetClassName"); + currentFunction->Name = vtkstrdup(temps); + currentFunction->NumberOfArguments = 0; + currentFunction->ReturnType = 1303; + output_function(); + + currentFunction->Signature = (char *)malloc(2048); + sigAllocatedLength = 2048; + sprintf(currentFunction->Signature, + "int IsA (const char *name);"); + sprintf(temps,"IsA"); + currentFunction->Name = vtkstrdup(temps); + currentFunction->NumberOfArguments = 1; + currentFunction->ArgTypes[0] = 1303; + currentFunction->ArgCounts[0] = 0; + currentFunction->ReturnType = 4; + output_function(); + + currentFunction->Signature = (char *)malloc(2048); + sigAllocatedLength = 2048; + sprintf(currentFunction->Signature, "%s *NewInstance ();", + $<str>3); + sprintf(temps,"NewInstance"); + currentFunction->Name = vtkstrdup(temps); + currentFunction->NumberOfArguments = 0; + currentFunction->ReturnType = 309; + currentFunction->ReturnClass = vtkstrdup($<str>3); + output_function(); + + if ( data.IsConcrete ) + { + currentFunction->Signature = (char *)malloc(2048); + sigAllocatedLength = 2048; + sprintf(currentFunction->Signature, "%s *SafeDownCast (vtkObject* o);", + $<str>3); + sprintf(temps,"SafeDownCast"); + currentFunction->Name = vtkstrdup(temps); + currentFunction->NumberOfArguments = 1; + currentFunction->ArgTypes[0] = 309; + currentFunction->ArgCounts[0] = 1; + currentFunction->ArgClasses[0] = vtkstrdup("vtkObject"); + currentFunction->ReturnType = 2309; + currentFunction->ReturnClass = vtkstrdup($<str>3); + output_function(); + } + } ; /* @@ -1151,8 +1206,8 @@ if (ret) { fprintf(stdout, - "*** SYNTAX ERROR found in parsing the header file %s before line %d ***\n", - argv[1], yylineno); + "*** SYNTAX ERROR found in parsing the header file %s before line %d: '%s\' ***\n", + argv[1], yylineno, yytext); return ret; } Index: vtkWrapOctave.c =================================================================== RCS file: /cvsroot/octaviz/octaviz/Wrapping/vtkWrapOctave.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- vtkWrapOctave.c 23 Oct 2006 01:01:33 -0000 1.5 +++ vtkWrapOctave.c 3 Feb 2010 16:10:37 -0000 1.6 @@ -175,6 +175,9 @@ } fprintf(fp," retval = tempResult;\n"); break; + default: + fprintf(stderr, "Warning (use_hints): unknown return type %d.\n", currentFunction->ReturnType); + break; } } @@ -358,17 +361,30 @@ break; case 109: case 309: - fprintf(fp," if ( args(%i).type_id() != vtk_object::static_type_id() ) error_flag = 1;\n",start_arg); + if ( currentFunction->ArgCounts[i] <= 1 ) + { + fprintf(fp," if ( args(%i).type_id() != vtk_object::static_type_id() ) error_flag = 1;\n",start_arg); # if __WORDSIZE == 64 - fprintf(fp," else temp%i = reinterpret_cast<%s*>( args(%i).uint64_scalar_value().value() );\n",i,currentFunction->ArgClasses[i],start_arg); + fprintf(fp," else temp%i = reinterpret_cast<%s*>( args(%i).uint64_scalar_value().value() );\n",i,currentFunction->ArgClasses[i],start_arg); # else - fprintf(fp," else temp%i = reinterpret_cast<%s*>( args(%i).uint32_scalar_value().value() );\n",i,currentFunction->ArgClasses[i],start_arg); + fprintf(fp," else temp%i = reinterpret_cast<%s*>( args(%i).uint32_scalar_value().value() );\n",i,currentFunction->ArgClasses[i],start_arg); # endif - /* FIXME - fprintf(fp," retval = octave_value( new vtk_object(temp%i) );\n",MAX_ARGS); - fprintf(fp," 309temp%i = (%s *)(vtkTclGetPointerFromObject(argv[%i],(char *) \"%s\",interp,error_flag));\n",i,currentFunction->ArgClasses[i],start_arg, - currentFunction->ArgClasses[i]); - */ + /* FIXME + fprintf(fp," retval = octave_value( new vtk_object(temp%i) );\n",MAX_ARGS); + fprintf(fp," 309temp%i = (%s *)(vtkTclGetPointerFromObject(argv[%i],(char *) \"%s\",interp,error_flag));\n",i,currentFunction->ArgClasses[i],start_arg, + currentFunction->ArgClasses[i]); + */ + } + else + { + fprintf(fp," if ( ( args(%i).rows()*args(%i).columns() != %i ) ) error_flag = 1;\n",start_arg,start_arg,currentFunction->ArgCounts[i]); + /* now allocate the array and copy octave vector */ + fprintf(fp," else \n {\n"); + fprintf(fp," Array<double> vect = args(%i).vector_value();\n",start_arg); + fprintf(fp," int length = args(%i).length();\n",start_arg); + fprintf(fp," if ( length != %d ) error_flag = 1;\n",currentFunction->ArgCounts[i]); + fprintf(fp," else for ( int k = 0; k < length; k++ ) temp%i[k] = (%s)vect(k);\n }\n",i,currentFunction->ArgClasses[i]); + } break; case 2: case 9: @@ -643,6 +659,7 @@ while ( data->Description[i] != 0 ) { if ( data->Description[i] == '"' ) fprintf(fp,"\\"); + if ( data->Description[i] == '\\' ) fprintf(fp,"\\"); /* Curly braces are special characters in Texinfo. Quote them. */ if ( data->Description[i] == '{' || data->Description[i] == '}' ) --- NEW FILE: y.tab.c --- /* A Bison parser, made by GNU Bison 2.4.1. */ /* Skeleton implementation for Bison's Yacc-like parsers in C Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License [...3605 lines suppressed...] } else { fout = fopen(argv[3],"w"); data.OutputFileName = argv[3]; } if (!fout) { fprintf(stderr,"Error opening output file %s\n",argv[3]); exit(1); } vtkParseOutput(fout,&data); fclose (fout); return 0; } Index: vtkParse.tab.c =================================================================== RCS file: /cvsroot/octaviz/octaviz/Wrapping/vtkParse.tab.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- vtkParse.tab.c 1 Mar 2005 02:53:06 -0000 1.3 +++ vtkParse.tab.c 3 Feb 2010 16:10:37 -0000 1.4 @@ -1,30 +1,39 @@ -/* A Bison parser, made by GNU Bison 1.875d. */ -/* Skeleton parser for Yacc-like parsing with Bison, - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +/* A Bison parser, made by GNU Bison 2.4.1. */ - This program is free software; you can redistribute it and/or modify +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. [...4232 lines suppressed...] +#line 1022 "vtkParse.y" #include <string.h> #include "lex.yy.c" @@ -3054,8 +3632,8 @@ if (ret) { fprintf(stdout, - "*** SYNTAX ERROR found in parsing the header file %s before line %d ***\n", - argv[1], yylineno); + "*** SYNTAX ERROR found in parsing the header file %s before line %d: '%s\' ***\n", + argv[1], yylineno, yytext); return ret; } @@ -3083,4 +3661,3 @@ - Index: vtkParse.l =================================================================== RCS file: /cvsroot/octaviz/octaviz/Wrapping/vtkParse.l,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- vtkParse.l 1 Mar 2005 02:53:06 -0000 1.3 +++ vtkParse.l 3 Feb 2010 16:10:37 -0000 1.4 @@ -176,7 +176,6 @@ "static" return(STATIC); "vtkFloatingPointType" return(DOUBLE); -"vtkIdType" return(INT); "vtkSetMacro" return(SetMacro); "vtkGetMacro" return(GetMacro); "vtkSetStringMacro" return(SetStringMacro); @@ -200,6 +199,7 @@ "vtkWorldCoordinateMacro" return(WorldCoordinateMacro); "vtkTypeMacro" return(TypeMacro); "vtkTypeRevisionMacro" return(TypeMacro); +"vtkExportedTypeRevisionMacro" return(ExportedTypeRevisionMacro); "VTK_LEGACY" return(VTK_LEGACY); [0-9]+ { sscanf(yytext,"%d",&yylval.integer); return(NUM);} Index: lex.yy.c =================================================================== RCS file: /cvsroot/octaviz/octaviz/Wrapping/lex.yy.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- lex.yy.c 1 Mar 2005 02:53:06 -0000 1.3 +++ lex.yy.c 3 Feb 2010 16:10:37 -0000 1.4 @@ -8,7 +8,7 @@ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 31 +#define YY_FLEX_SUBMINOR_VERSION 35 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif @@ -30,7 +30,15 @@ /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */ [...1332 lines suppressed...] return n; @@ -2628,18 +2739,6 @@ #define YYTABLES_NAME "yytables" -#undef YY_NEW_FILE -#undef YY_FLUSH_BUFFER -#undef yy_set_bol -#undef yy_new_buffer -#undef yy_set_interactive -#undef yytext_ptr -#undef YY_DO_BEFORE_ACTION - -#ifdef YY_DECL_IS_OURS -#undef YY_DECL_IS_OURS -#undef YY_DECL -#endif #line 238 "vtkParse.l" |