From: Dragan T. <dr...@us...> - 2005-03-01 02:13:49
|
Update of /cvsroot/octaviz/octaviz/Wrapping In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5805 Modified Files: hints lex.yy.c vtkParse.h vtkParse.l vtkParse.tab.c vtkParse.y vtkWrapOctave.c Log Message: Fixed problems related to preprocessor directives within class declarations (CVS VTK). Index: vtkParse.h =================================================================== RCS file: /cvsroot/octaviz/octaviz/Wrapping/vtkParse.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- vtkParse.h 21 Sep 2004 22:50:39 -0000 1.1.1.1 +++ vtkParse.h 1 Mar 2005 02:13:29 -0000 1.2 @@ -33,6 +33,7 @@ char *ReturnClass; char *Comment; char *Signature; + int IsLegacy; } FunctionInfo; typedef struct _FileInfo Index: vtkParse.y =================================================================== RCS file: /cvsroot/octaviz/octaviz/Wrapping/vtkParse.y,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- vtkParse.y 21 Sep 2004 22:50:39 -0000 1.1.1.1 +++ vtkParse.y 1 Mar 2005 02:13:29 -0000 1.2 @@ -12,14 +12,42 @@ PURPOSE. See the above copyright notice for more information. =========================================================================*/ - %{ + +/* + +This file must be translated to C and modified to build everywhere. + +Run yacc like this: + + yacc -b vtkParse vtkParse.y + +Modify vtkParse.tab.c: + - remove TABs + - comment out yyerrorlab stuff + +*/ + #include <stdio.h> #include <stdlib.h> #include <string.h> #define yyerror(a) fprintf(stderr,"%s\n",a) #define yywrap() 1 +static void vtkParseDebug(const char* s1, const char* s2); + +/* MSVC Does not define __STDC__ properly. */ +#if defined(_MSC_VER) && _MSC_VER >= 1200 && !defined(__STDC__) +# define __STDC__ 1 +#endif + +/* Disable warnings in generated code. */ +#if defined(_MSC_VER) +# pragma warning (disable: 4127) /* conditional expression is constant */ +# pragma warning (disable: 4244) /* conversion to smaller integer type */ +#endif + +int yylex(void); void output_function(); /* vtkstrdup is not part of POSIX so we create our own */ @@ -44,7 +72,7 @@ int CommentState; int openSig; int invertSig; - int sigAllocatedLength; + unsigned int sigAllocatedLength; #define YYMAXDEPTH 1000 @@ -107,6 +135,10 @@ currentFunction->Signature = NULL; } } + void legacySig(void) + { + currentFunction->IsLegacy = 1; + } %} %union{ @@ -139,6 +171,7 @@ %token STATIC %token VAR_FUNCTION %token ARRAY_NUM +%token VTK_LEGACY /* macro tokens */ %token SetMacro @@ -179,55 +212,99 @@ class_def_body: class_def_item | class_def_item class_def_body; class_def_item: scope_type ':' | var - | function | FRIEND function | macro ';' | macro; + | operator + | FRIEND operator + | function func_body { output_function(); } + | FRIEND function func_body { output_function(); } + | legacy_function func_body { legacySig(); output_function(); } + | macro ';' + | macro; -function: '~' func { preSig("~"); output_function(); } - | VIRTUAL '~' func { preSig("virtual ~"); output_function(); } - | func +legacy_function: VTK_LEGACY '(' function ')' + +function: '~' func { preSig("~"); } + | VIRTUAL '~' func { preSig("virtual ~"); } + | func + | type func + { + currentFunction->ReturnType = $<integer>1; + } + | type CONST func + { + currentFunction->ReturnType = $<integer>1; + } + | VIRTUAL type CONST func + { + preSig("virtual "); + currentFunction->ReturnType = $<integer>2; + } + | VIRTUAL type func + { + preSig("virtual "); + currentFunction->ReturnType = $<integer>2; + } + | VIRTUAL func + { + preSig("virtual "); + }; + +operator: + operator_sig { output_function(); } - | type func + | type operator_sig { currentFunction->ReturnType = $<integer>1; output_function(); - } - | VIRTUAL type func + } + | type CONST operator_sig + { + currentFunction->ReturnType = $<integer>1; + output_function(); + } + | VIRTUAL type CONST operator_sig { preSig("virtual "); currentFunction->ReturnType = $<integer>2; output_function(); } - | VIRTUAL func + | VIRTUAL type operator_sig + { + preSig("virtual "); + currentFunction->ReturnType = $<integer>2; + output_function(); + } + | VIRTUAL operator_sig { preSig("virtual "); output_function(); }; -func: func_beg { postSig(")"); } maybe_const { postSig(";"); openSig = 0; } - func_end +operator_sig: OPERATOR maybe_other_no_semi ';' + { + currentFunction->IsOperator = 1; + vtkParseDebug("Converted operator", 0); + } + +func: func_sig { postSig(")"); } maybe_const { postSig(";"); openSig = 0; } { openSig = 1; currentFunction->Name = $<str>1; - fprintf(stderr," Parsed func %s\n",$<str>1); - } - | OPERATOR maybe_other_no_semi ';' - { - currentFunction->IsOperator = 1; - fprintf(stderr," Converted operator\n"); + vtkParseDebug("Parsed func", $<str>1); } - | func_beg '=' NUM ';' + | func_sig '=' NUM { postSig(") = 0;"); currentFunction->Name = $<str>1; - fprintf(stderr," Parsed func %s\n",$<str>1); + vtkParseDebug("Parsed func", $<str>1); currentFunction->IsPureVirtual = 1; data.IsAbstract = 1; }; maybe_const: | CONST {postSig(" const");}; -func_beg: any_id '(' {postSig(" ("); } args_list ')'; +func_sig: any_id '(' {postSig(" ("); } args_list ')'; const_mod: CONST {postSig("const ");}; @@ -235,7 +312,7 @@ any_id: VTK_ID {postSig($<str>1);} | ID {postSig($<str>1);}; -func_end: ';' +func_body: ';' | '{' maybe_other '}' ';' | '{' maybe_other '}' | ':' maybe_other_no_semi ';'; @@ -284,8 +361,8 @@ { postSig("[]"); $<integer>$ = 300 + $<integer>4 % 1000; }; type: const_mod type_red1 {$<integer>$ = 1000 + $<integer>2;} - | type_red1 {$<integer>$ = $<integer>1;}; - | static_mod type_red1 {$<integer>$ = 2000 + $<integer>2;}; + | type_red1 {$<integer>$ = $<integer>1;} + | static_mod type_red1 {$<integer>$ = 2000 + $<integer>2;} | static_mod const_mod type_red1 {$<integer>$ = 3000 + $<integer>3;}; type_red1: type_red2 {$<integer>$ = $<integer>1;} @@ -859,6 +936,7 @@ 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; @@ -890,6 +968,19 @@ #include <string.h> #include "lex.yy.c" +static void vtkParseDebug(const char* s1, const char* s2) +{ + if ( getenv("DEBUG") ) + { + fprintf(stderr, " %s", s1); + if ( s2 ) + { + fprintf(stderr, " %s", s2); + } + fprintf(stderr, "\n"); + } +} + /* initialize the structure */ void InitFunction(FunctionInfo *func) { @@ -905,6 +996,7 @@ func->ReturnClass = NULL; func->Comment = NULL; func->Signature = NULL; + func->IsLegacy = 0; sigAllocatedLength = 0; openSig = 1; invertSig = 0; Index: vtkParse.l =================================================================== RCS file: /cvsroot/octaviz/octaviz/Wrapping/vtkParse.l,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- vtkParse.l 21 Sep 2004 22:50:39 -0000 1.1.1.1 +++ vtkParse.l 1 Mar 2005 02:13:29 -0000 1.2 @@ -1,9 +1,30 @@ %option yylineno %{ + +/* + +This file must be translated to C and modified to build everywhere. + +Run flex like this: + + flex vtkParse.l + +Modify lex.yy.c: + - remove yyunput function + - remove TABs + +*/ + /* We do not care of interactive mode */ #define YY_NEVER_INTERACTIVE 1 #define YY_NO_UNPUT 1 +/* Do not include unistd.h in generated source. */ +#define YY_NO_UNISTD_H + +/* Skip declaring this function. It is a macro. */ +#define YY_SKIP_YYWRAP + #ifdef _WIN32 #pragma warning ( disable : 4127 ) #pragma warning ( disable : 4131 ) @@ -179,6 +200,7 @@ "vtkWorldCoordinateMacro" return(WorldCoordinateMacro); "vtkTypeMacro" return(TypeMacro); "vtkTypeRevisionMacro" return(TypeMacro); +"VTK_LEGACY" return(VTK_LEGACY); [0-9]+ { sscanf(yytext,"%d",&yylval.integer); return(NUM);} Index: vtkWrapOctave.c =================================================================== RCS file: /cvsroot/octaviz/octaviz/Wrapping/vtkWrapOctave.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- vtkWrapOctave.c 21 Sep 2004 22:50:41 -0000 1.1.1.1 +++ vtkWrapOctave.c 1 Mar 2005 02:13:29 -0000 1.2 @@ -348,7 +348,7 @@ case 109: case 309: fprintf(fp," if ( args(%i).type_id() != vtk_object::static_type_id() ) error_flag = 1;\n",start_arg); - fprintf(fp," else temp%i = reinterpret_cast<%s*>( args(%i).uint_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); /* 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, @@ -685,7 +685,7 @@ fprintf(fp," octave_stdout << help_map[args(0).string_value()] << std::endl;\n"); fprintf(fp," return retval;\n }\n\n"); - fprintf(fp," %s *vtk_pointer = reinterpret_cast<%s*>( args(0).uint_value() );\n",data->ClassName,data->ClassName); + fprintf(fp," %s *vtk_pointer = reinterpret_cast<%s*>( args(0).uint32_scalar_value().value() );\n",data->ClassName,data->ClassName); fprintf(fp," std::string method_name = args(1).string_value();\n"); fprintf(fp," int error_flag;\n"); fprintf(fp," error_flag = 0; error_flag = error_flag;\n\n"); @@ -710,7 +710,7 @@ fprintf(fp," error_flag = 0;\n"); fprintf(fp," vtkOctaveCommand* comm = vtkOctaveCommand::New();\n"); fprintf(fp," comm->SetFunctionName(args(3).string_value().c_str());\n"); - fprintf(fp," vtk_object *vtk_obj = reinterpret_cast<vtk_object*>( args(0).uint_value() );\n"); + fprintf(fp," vtk_object *vtk_obj = reinterpret_cast<vtk_object*>( args(0).uint32_scalar_value().value() );\n"); fprintf(fp," comm->SetObject( vtk_obj );\n"); fprintf(fp," vtk_pointer->AddObserver(args(2).string_value().c_str(),comm);\n"); fprintf(fp," comm->Delete();\n"); Index: lex.yy.c =================================================================== RCS file: /cvsroot/octaviz/octaviz/Wrapping/lex.yy.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- lex.yy.c 21 Sep 2004 22:50:41 -0000 1.1.1.1 +++ lex.yy.c 1 Mar 2005 02:13:29 -0000 1.2 @@ -1,55 +1,96 @@ -/* A lexical scanner generated by flex */ -/* Scanner skeleton version: - * $Header$ - */ +#line 3 "lex.yy.c" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ [...4243 lines suppressed...] - yylex(); - return 0; - } -#endif -#line 224 "vtkParse.l" +#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" Index: vtkParse.tab.c =================================================================== RCS file: /cvsroot/octaviz/octaviz/Wrapping/vtkParse.tab.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- vtkParse.tab.c 21 Sep 2004 22:50:40 -0000 1.1.1.1 +++ vtkParse.tab.c 1 Mar 2005 02:13:29 -0000 1.2 @@ -1,22 +1,198 @@ -#define YYBYACC 1 -#define YYMAJOR 1 -#define YYMINOR 9 -#define YYLEX yylex() -#define YYEMPTY -1 -#define yyclearin (yychar=(YYEMPTY)) -#define yyerrok (yyerrflag=0) -#define YYRECOVERING() (yyerrflag!=0) -static int yygrowstack(); -#define YYPREFIX "yy" -#line 44 "vtkParse.y" [...4102 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: hints =================================================================== RCS file: /cvsroot/octaviz/octaviz/Wrapping/hints,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- hints 21 Sep 2004 22:50:39 -0000 1.1.1.1 +++ hints 1 Mar 2005 02:13:29 -0000 1.2 @@ -23,6 +23,9 @@ vtkCoordinate GetComputedViewportValue 304 2 vtkCoordinate GetComputedWorldValue 307 3 vtkCubeAxesActor2D GetBounds 307 6 +vtkCubeAxesActor2D GetRanges 307 6 +vtkDataObject GetWholeExtent 304 6 +vtkDataObject GetUpdateExtent 304 6 vtkDataArray GetRange 307 2 vtkDataArray GetTuple2 307 2 vtkDataArray GetTuple3 307 3 @@ -53,6 +56,7 @@ vtkImageConvolve GetKernel5x5 301 25 vtkImageConvolve GetKernel3x3x3 301 27 vtkImageData GetDimensions 304 3 +vtkImageData GetExtent 304 6 vtkImageData GetIncrements 304 3 vtkImageData GetPoint 307 3 vtkImageEllipsoidSource GetWholeExtent 304 6 @@ -70,6 +74,8 @@ vtkImageReslice GetResliceAxesDirectionCosines 307 9 vtkImageReslice GetResliceAxesOrigin 307 3 vtkImageSource GetExecuteExtent 304 6 +vtkImageSpatialAlgorithm GetKernelMiddle 304 3 +vtkImageSpatialAlgorithm GetKernelSize 304 3 vtkImageSpatialFilter GetKernelMiddle 304 3 vtkImageSpatialFilter GetKernelSize 304 3 vtkImageTracerWidget GetHandlePosition 307 3 @@ -139,6 +145,7 @@ vtkQuadricClustering GetNumberOfDivisions 304 3 vtkRayCaster GetParallelIncrements 301 2 vtkRayCaster GetParallelStartPosition 301 3 +vtkRectilinearGrid GetExtent 304 6 vtkRectilinearGrid GetPoint 307 3 vtkRecursiveSphereDirectionEncoder GetDecodedGradient 301 3 vtkRenderer ComputeVisiblePropBounds 307 6 @@ -146,6 +153,7 @@ vtkSplineWidget GetHandlePosition 307 3 vtkStreamer GetStartPosition 307 3 vtkStructuredGrid GetDimensions 304 3 +vtkStructuredGrid GetExtent 304 6 vtkStructuredGrid GetPoint 307 3 vtkStructuredGrid GetScalarRange 307 2 vtkStructuredPointsGeometryFilter GetExtent 304 6 |