// PARAVIS : ParaView wrapper SALOME module
//
-// Copyright (C) 2010-2012 CEA/DEN, EDF R&D
+// Copyright (C) 2010-2013 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
+#include "vtkConfigure.h"
#include "vtkParse.h"
#include "vtkParseType.h"
+#include "vtkParseMain.h"
#include "vtkWrapIDL.h"
#include "vtkWrap.h"
#define bs 12288
+HierarchyInfo *hierarchyInfo = NULL;
int numberOfWrappedFunctions = 0;
FunctionInfo *wrappedFunctions[1000];
extern FunctionInfo *currentFunction;
+char *EmptyString = "";
static void add_to_sig(char *sig, const char *add, int *i)
AddAtomArg(I,Type,"char","Char",Result,CurrPos);
}
+void AddCharArrayArg(int I, ValueInfo* Type, char *Result, int *CurrPos) {
+ AddArrayArg(I,Type,"char",Result,CurrPos);
+}
+
void AddStringArg(int I, char *Result, int *CurrPos) {
#if defined(IDL_I_HH) || defined(IDL_I_CC)
add_to_sig(Result,"char ",CurrPos);
int IsShort(ValueInfo* theType) {
//return ((Type % 0x10) == 0x4 || (Type % 0x10) == 0x5 || (Type % 0x10) == 0xA);
int aVal = theType->Type & VTK_PARSE_BASE_TYPE;
- return (aVal == VTK_PARSE_SHORT) || (aVal == VTK_PARSE_INT) ||
- (aVal == VTK_PARSE_ID_TYPE) || (aVal == VTK_PARSE_UNSIGNED_INT) || (aVal == VTK_PARSE_UNSIGNED_SHORT) ||
+ return (aVal == VTK_PARSE_SHORT) || (aVal == VTK_PARSE_UNSIGNED_SHORT);
+}
+
+int IsInt(ValueInfo* theType) {
+ //return ((Type % 0x10) == 0x4 || (Type % 0x10) == 0x5 || (Type % 0x10) == 0xA);
+ int aVal = theType->Type & VTK_PARSE_BASE_TYPE;
+ return (aVal == VTK_PARSE_INT) ||
+ (aVal == VTK_PARSE_ID_TYPE) || (aVal == VTK_PARSE_UNSIGNED_INT) ||
(aVal == VTK_PARSE_SSIZE_T) || (aVal == VTK_PARSE_SIZE_T);
}
+int IsShortInt(ValueInfo* theType) {
+ //return ((Type % 0x10) == 0x4 || (Type % 0x10) == 0x5 || (Type % 0x10) == 0xA);
+ return (IsShort(theType) || IsInt(theType));
+}
+
void AddShortAtomArg(int I, ValueInfo* Type, char *Result, int *CurrPos) {
AddAtomArg(I,Type,"short","Short",Result,CurrPos);
}
return (IsShort(Type) && IsArray(Type));
}
+int IsIntArray(ValueInfo* Type) {
+ return (IsInt(Type) && IsArray(Type));
+}
+
void AddShortArrayArg(int I, ValueInfo* Type, char *Result, int *CurrPos) {
AddArrayArg(I,Type,"short",Result,CurrPos);
}
}
void AddTypeArray(ValueInfo* Type, char *Result, int *CurrPos) {
- if(IsShort(Type))
+ if(IsShortInt(Type))
add_to_sig(Result,"short",CurrPos);
if(IsLong(Type))
add_to_sig(Result,"long",CurrPos);
}
}
- if(IsShort(aType)) {
+ if(IsShortInt(aType)) {
if(IsArray(aType)) {
if (IsUnsigned(aType))
add_to_sig(result,"unsigned ",currPos);
}
}
- if(IsChar(aType)) {
- if(IsString(aType)) {
- if(IsReturnArg(i))
- add_to_sig(result,"const ",currPos);
+ if(IsString(aType)) {
+ if(IsReturnArg(i))
+ add_to_sig(result,"const ",currPos);
+ if(strcmp(aType->Class, "vtkStdString") == 0) {
+ add_to_sig(result,"vtkStdString",currPos);
+ } else {
+ add_to_sig(result,"char",currPos);
+ }
+ } else if(IsChar(aType)) {
+ if(IsArray(aType)) {
+ if (IsUnsigned(aType))
+ add_to_sig(result,"unsigned ",currPos);
add_to_sig(result,"char",currPos);
} else {
add_to_sig(result,"CORBA::Char",currPos);
}
if(IsArray(aType) || IsPtr(aType) || IsClass(aType) || IsString(aType)) {
- add_to_sig(result,"*",currPos);
+ if(strcmp(aType->Class, "vtkStdString") != 0) {
+ add_to_sig(result,"*",currPos);
+ }
}
}
}
}
- if(IsShort(aType)) {
- if(IsShortArray(aType)) {
+ if(IsShortInt(aType)) {
+ if(IsArray(aType)) {
AddShortArrayArg(i,aType,result,currPos);
} else {
AddShortAtomArg(i,aType,result,currPos);
if(IsString(aType)) {
AddStringArg(i,result,currPos);
} else {
- AddCharAtomArg(i,aType,result,currPos);
+ if(IsCharArray(aType)) {
+ AddCharArrayArg(i,aType,result,currPos);
+ } else {
+ AddCharAtomArg(i,aType,result,currPos);
+ }
}
} else if (IsString(aType)) //!!! VSV
AddStringArg(i,result,currPos);
ret = 1;
}
- for (j = 0; j < currentFunction->NumberOfArguments; j++) {
- aArgVal = currentFunction->Arguments[j];
+ for (j = 0; j < vtkWrap_CountWrappedParameters(currentFunction); j++) {
+ aArgVal = currentFunction->Parameters[j];
if(IsFunction(aArgVal))
ret == 1;
if(IsClass(aArgVal) && ret == 0) {
ret = 1;
}
+
if(ret) {
add_to_sig(result,"//\n",&currPos);
/*currentFunction->Signature = (const char*)realloc((void*)currentFunction->Signature,
add_to_sig(result,"* TObj;\n",&currPos);
add_to_sig(result," TObj myObj;\n",&currPos);
- for (i = 0; i < currentFunction->NumberOfArguments; i++) {
- aArgVal = currentFunction->Arguments[i];
+ for (i = 0; i < vtkWrap_CountWrappedParameters(currentFunction); i++) {
+ aArgVal = currentFunction->Parameters[i];
//output_typedef(result, &currPos, i, currentFunction->ArgTypes[i],
// currentFunction->ArgClasses[i]);
output_typedef(result, &currPos, i, aArgVal, currentFunction->ArgClasses[i]);
}
add_to_sig(result,")",&currPos);
add_to_sig(result,"(TObj theObj",&currPos);
- for (i = 0; i < currentFunction->NumberOfArguments; i++) {
+ for (i = 0; i < vtkWrap_CountWrappedParameters(currentFunction); i++) {
sprintf(buf,", TParam%d theParam%d",i,i);
add_to_sig(result,buf,&currPos);
}
add_to_sig(result,"):\n",&currPos);
add_to_sig(result," myObj(theObj)",&currPos);
- for (i = 0; i < currentFunction->NumberOfArguments; i++) {
+ for (i = 0; i < vtkWrap_CountWrappedParameters(currentFunction); i++) {
sprintf(buf,", myParam%d(theParam%d)",i,i);
add_to_sig(result,buf,&currPos);
}
add_to_sig(result,"myObj->",&currPos);
add_to_sig(result,currentFunction->Name,&currPos);
add_to_sig(result,"(",&currPos);
- for (i = 0; i < currentFunction->NumberOfArguments; i++) {
- aArgVal = currentFunction->Arguments[i];
+ for (i = 0; i < vtkWrap_CountWrappedParameters(currentFunction); i++) {
+ aArgVal = currentFunction->Parameters[i];
if(i!=0)
add_to_sig(result,", ",&currPos);
if(IsClass(aArgVal) && IsPtr(aArgVal)) {
add_to_sig(result,"*",&currPos);
}
- if (IsString(aArgVal) && IsConst(aArgVal))
+ if (IsString(aArgVal) && IsConst(aArgVal) && strcmp(aArgVal->Class, "vtkStdString") != 0)
sprintf(buf,"checkNullStr(myParam%d)",i);
else
sprintf(buf,"myParam%d",i);
/* print the arg list */
add_to_sig(result,"(",&currPos);
- for (i = 0; i < currentFunction->NumberOfArguments; i++) {
- aArgVal = currentFunction->Arguments[i];
+ for (i = 0; i < vtkWrap_CountWrappedParameters(currentFunction); i++) {
+ aArgVal = currentFunction->Parameters[i];
if( i != 0 ) {
add_to_sig(result,", ",&currPos);
}
/* output_temp(result, &currPos, i, currentFunction->ArgTypes[i],
(char*)currentFunction->ArgClasses[i],
currentFunction->ArgCounts[i]);*/
- output_temp(result, &currPos, i, aArgVal, aArgVal->Class, currentFunction->NumberOfArguments);
+ output_temp(result, &currPos, i, aArgVal, aArgVal->Class, vtkWrap_CountWrappedParameters(currentFunction));
}
add_to_sig(result,")",&currPos);
#if defined(IDL_I_CC)
add_to_sig(result," {\n",&currPos);
add_to_sig(result," try {\n",&currPos);
- for (i = 0; i < currentFunction->NumberOfArguments; i++) {
- aArgVal = currentFunction->Arguments[i];
+ for (i = 0; i < vtkWrap_CountWrappedParameters(currentFunction); i++) {
+ aArgVal = currentFunction->Parameters[i];
if(IsClass(aArgVal)) {
sprintf(buf," PARAVIS_Base_i* i_temp%d = GET_SERVANT(temp%d);\n",i,i);
add_to_sig(result,buf,&currPos);
if(IsDouble(aArgVal))
add_to_sig(result,"double",&currPos);
+ if(IsChar(aArgVal)) {
+ if (IsUnsigned(aArgVal))
+ add_to_sig(result,"unsigned ",&currPos);
+ add_to_sig(result,"char",&currPos);
+ }
+
if(IsvtkIdType(aArgVal)) {
if (IsUnsigned(aArgVal))
add_to_sig(result,"unsigned ",&currPos);
add_to_sig(result,"vtkIdType",&currPos);
} else {
- if(IsShort(aArgVal)) {
+ if(IsShortInt(aArgVal)) {
if (IsUnsigned(aArgVal))
add_to_sig(result,"unsigned ",&currPos);
add_to_sig(result,"int",&currPos);
if(IsDouble(aArgVal))
add_to_sig(result,"double",&currPos);
+ if(IsChar(aArgVal)) {
+ if (IsUnsigned(aArgVal))
+ add_to_sig(result,"unsigned ",&currPos);
+ add_to_sig(result,"char",&currPos);
+ }
+
if(IsvtkIdType(aArgVal)) {
if (IsUnsigned(aArgVal))
add_to_sig(result,"unsigned ",&currPos);
add_to_sig(result,"vtkIdType",&currPos);
} else {
- if(IsShort(aArgVal)) {
+ if(IsShortInt(aArgVal)) {
if (IsUnsigned(aArgVal))
add_to_sig(result,"unsigned ",&currPos);
add_to_sig(result,"int",&currPos);
add_to_sig(result,buf,&currPos);
add_to_sig(result," ",&currPos);
}
+
+ if(IsArray(aRetVal) && IsUnsigned(aRetVal)) {
+ add_to_sig(result,"unsigned ",&currPos);
+ }
if(IsFloat(aRetVal)) {
if(IsArray(aRetVal)) {
}
}
- if(IsShort(aRetVal)) {
+ if(IsShortInt(aRetVal)) {
if(IsArray(aRetVal)) {
if(IsvtkIdType(aRetVal)) {
add_to_sig(result,"vtkIdType",&currPos);
} else {
- add_to_sig(result,"int",&currPos);
+ if(IsShort(aRetVal)) {
+ add_to_sig(result,"short",&currPos);
+ } else {
+ add_to_sig(result,"int",&currPos);
+ }
}
add_to_sig(result,"* a_ret = ",&currPos);
} else {
add_to_sig(result,"*)",&currPos);
add_to_sig(result,"getVTKObject()\n",&currPos);
- for (i = 0; i < currentFunction->NumberOfArguments; i++) {
- aArgVal = currentFunction->Arguments[i];
+ for (i = 0; i < vtkWrap_CountWrappedParameters(currentFunction); i++) {
+ aArgVal = currentFunction->Parameters[i];
add_to_sig(result," , ",&currPos);
//if(IsClass(currentFunction->ArgTypes[i]) && IsPtr(currentFunction->ArgTypes[i])) {
add_to_sig(result,");\n",&currPos);
}
- for (i = 0; i < currentFunction->NumberOfArguments; i++) {
- aArgVal = currentFunction->Arguments[i];
+ for (i = 0; i < vtkWrap_CountWrappedParameters(currentFunction); i++) {
+ aArgVal = currentFunction->Parameters[i];
if(IsArray(aArgVal) && !IsVoid(aArgVal) && !IsString(aArgVal) && !IsClass(aArgVal)) {
if (!IsIn(aArgVal)) {
sprintf(buf," for(j_temp%d=0;j_temp%d<l_temp%d;j_temp%d++) {\n",i,i,i,i);
buf[j]=0;
buf1[j]=0;
if(strcmp(buf,buf1) == 0) {
- ((char*)currentFunction->Signature)[0]='\0';
+ //((char*)currentFunction->Signature)[0]='\0';
+ currentFunction->Signature = EmptyString;
return;
}
}
fprintf(fp,"#include \"PARAVIS_Gen_%s_i.hh\"\n",data->SuperClasses[i]);
}
+ //RNV: to avoid link error on windows via Visual Studio
+ //undef GetObject macro.
+ if( strcmp(data->Name, "vtkWebGLExporter") == 0 ) {
+ fprintf(fp,"#ifdef WIN32\n");
+ fprintf(fp," #ifdef GetObject\n");
+ fprintf(fp," #undef GetObject\n");
+ fprintf(fp," #endif\n");
+ fprintf(fp,"#endif\n");
+ }
+
fprintf(fp,"\nclass %s;\n",data->Name);
fprintf(fp,"\nnamespace PARAVIS\n{\n\n");
#elif defined(IDL_I_CC)
{
sprintf(num,"_%d",j);
}
-
get_signature(num,data);
}
/* create external type declarations for all object
theName = NULL;
theType = 0;
- for (i = theFunc->NumberOfArguments; i >= 0; i--)
+ for (i = vtkWrap_CountWrappedParameters(theFunc); i >= 0; i--)
{
if (i==0)/* return type */
{
}
else /* arg type */
{
- aArgVal = theFunc->Arguments[i-1];
+ aArgVal = theFunc->Parameters[i-1];
//theType = theFunc->ArgTypes[i-1];
//theName = (char*)theFunc->ArgClasses[i-1];
}
k = i+1;
else
k = 0;
- for (j = backFunc->NumberOfArguments; j >= k; j--)
+ for (j = vtkWrap_CountWrappedParameters(backFunc); j >= k; j--)
{
if (j==0) /* return type */
{
}
else /* arg type */
{
- aBackArgVal = backFunc->Arguments[j-1];
+ aBackArgVal = backFunc->Parameters[j-1];
//backType = backFunc->ArgTypes[j-1];
//backName = (char*)backFunc->ArgClasses[j-1];
}
//printf("#### Check %s\n", currentFunction->Name);
/* check to see if we can handle the args */
- for (i = 0; i < currentFunction->NumberOfArguments; i++)
+ for (i = 0; i < vtkWrap_CountWrappedParameters(currentFunction); i++)
{
- aArgVal = currentFunction->Arguments[i];
+ aArgVal = currentFunction->Parameters[i];
/*printf(" Argument: %s ", vtkWrap_GetTypeName(aArgVal));
if (vtkWrap_IsArray(aArgVal)) {
printf("!!!! Argument %i is array\n", i);
if (aRetVal % VTK_PARSE_BASE_TYPE == 0x316) args_ok = 0;
- if (currentFunction->NumberOfArguments &&
+ if (vtkWrap_CountWrappedParameters(currentFunction) &&
(currentFunction->ArgTypes[0] == 0x5000)
- &&(currentFunction->NumberOfArguments != 0x1)) args_ok = 0;*/
+ &&(vtkWrap_CountWrappedParameters(currentFunction) != 0x1)) args_ok = 0;*/
/* make sure we have all the info we need for array arguments in */
- /*for (i = 0; i < currentFunction->NumberOfArguments; i++)
+ /*for (i = 0; i < vtkWrap_CountWrappedParameters(currentFunction); i++)
{
if (((currentFunction->ArgTypes[i] % VTK_PARSE_BASE_TYPE)/0x100 == 0x3)&&
(currentFunction->ArgCounts[i] <= 0)&&
}
/* check for New() function */
- if (!strcmp("New",currentFunction->Name) && currentFunction->NumberOfArguments == 0)
+ if (!strcmp("New",currentFunction->Name) && vtkWrap_CountWrappedParameters(currentFunction) == 0)
{
class_has_new = 1;
}
}
/* print the parsed structures */
-void vtkParseOutput(FILE *fp, FileInfo *file_info)
+int main(int argc, char *argv[])
{
- int i;
+ OptionInfo *options;
+ FileInfo *file_info;
ClassInfo *data;
+ FILE *fp;
+ int i;
+
+ /* get command-line args and parse the header file */
+ file_info = vtkParse_Main(argc, argv);
+
+ /* get the command-line options */
+ options = vtkParse_GetCommandLineOptions();
+
+ /* get the output file */
+ fp = fopen(options->OutputFileName, "w");
+
+ if (!fp)
+ {
+ fprintf(stderr, "Error opening output file %s\n", options->OutputFileName);
+ exit(1);
+ }
/* get the main class */
- data = file_info->MainClass;
+ if ((data = file_info->MainClass) == NULL)
+ {
+ fclose(fp);
+ exit(0);
+ }
- // Do not wrap this class
- // if (strcmp(data->Name, "vtkVariant") == 0)
- // return;
+ /* get the hierarchy info for accurate typing */
+ if (options->HierarchyFileName)
+ {
+ hierarchyInfo = vtkParseHierarchy_ReadFile(options->HierarchyFileName);
+ }
#if defined(IDL_I_HH)
fprintf(fp, "// idl wrapper interface for %s object implementation\n//\n", data->Name);
for (i = 0; i < data->NumberOfFunctions; i++)
{
currentFunction = data->Functions[i];
+#ifdef VTK_LEGACY_REMOVE
+ if(currentFunction->IsLegacy)
+ continue;
+#endif
outputFunction(fp, data);
}
//printf("#### NbFunctions %i\n", numberOfWrappedFunctions);
#else
fprintf(fp,"\n#endif\n");
#endif
- return;
+
+ vtkParse_Free(file_info);
+
+ return 0;
}