void do_return(FILE *fp) { /* ignore void */ if (((currentFunction->ReturnType % 0x10) == 0x2)&&(!((currentFunction->ReturnType % 0x1000)/0x100))) { return; } switch (currentFunction->ReturnType % 0x1000) { case 0x303: { fprintf(fp," return vtkJavaMakeJavaString(env,temp%i);\n", MAX_ARGS); } break; case 0x109: case 0x309: { fprintf(fp," return (jlong)(size_t)temp%i;", MAX_ARGS); break; } /* handle functions returning vectors */ /* this is done by looking them up in a hint file */ case 0x301: case 0x307: case 0x313: case 0x304: case 0x305: case 0x306: case 0x30A: case 0x30B: case 0x30C: case 0x30D: case 0x30E: use_hints(fp); break; default: fprintf(fp," return temp%i;\n", MAX_ARGS); break; } }
void do_return(FILE *fp) { unsigned int rType = (currentFunction->ReturnType & VTK_PARSE_UNQUALIFIED_TYPE); /* ignore void */ if (rType == VTK_PARSE_VOID) { return; } switch (rType) { case VTK_PARSE_CHAR_PTR: { fprintf(fp," return vtkJavaMakeJavaString(env,temp%i);\n", MAX_ARGS); break; } case VTK_PARSE_STRING: { fprintf(fp," return vtkJavaMakeJavaString(env,temp%i.c_str());\n", MAX_ARGS); break; } case VTK_PARSE_STRING_REF: { fprintf(fp," return vtkJavaMakeJavaString(env,temp%i->c_str());\n", MAX_ARGS); break; } case VTK_PARSE_OBJECT_PTR: { fprintf(fp," return (jlong)(size_t)temp%i;", MAX_ARGS); break; } /* handle functions returning vectors */ /* this is done by looking them up in a hint file */ case VTK_PARSE_FLOAT_PTR: case VTK_PARSE_DOUBLE_PTR: case VTK_PARSE_UNSIGNED_CHAR_PTR: case VTK_PARSE_INT_PTR: case VTK_PARSE_SHORT_PTR: case VTK_PARSE_LONG_PTR: case VTK_PARSE_ID_TYPE_PTR: case VTK_PARSE_LONG_LONG_PTR: case VTK_PARSE___INT64_PTR: case VTK_PARSE_SIGNED_CHAR_PTR: case VTK_PARSE_BOOL_PTR: use_hints(fp); break; default: fprintf(fp," return temp%i;\n", MAX_ARGS); break; } }
void return_result(FILE *fp) { unsigned int rType = currentFunction->ReturnType; const char *rClass = currentFunction->ReturnClass; switch (rType & VTK_PARSE_BASE_TYPE) { case VTK_PARSE_VOID: if ((rType & VTK_PARSE_INDIRECT) == 0) { return; } break; case VTK_PARSE_FLOAT: case VTK_PARSE_CHAR: case VTK_PARSE_INT: case VTK_PARSE_SHORT: case VTK_PARSE_LONG: case VTK_PARSE_DOUBLE: case VTK_PARSE_ID_TYPE: case VTK_PARSE_LONG_LONG: case VTK_PARSE___INT64: case VTK_PARSE_SIGNED_CHAR: case VTK_PARSE_BOOL: case VTK_PARSE_UNSIGNED_CHAR: case VTK_PARSE_UNSIGNED_INT: case VTK_PARSE_UNSIGNED_SHORT: case VTK_PARSE_UNSIGNED_LONG: case VTK_PARSE_UNSIGNED_ID_TYPE: case VTK_PARSE_UNSIGNED_LONG_LONG: case VTK_PARSE_UNSIGNED___INT64: case VTK_PARSE_STRING: if ((rType & VTK_PARSE_INDIRECT) == 0 || (((rType & VTK_PARSE_BASE_TYPE) == VTK_PARSE_CHAR) && ((rType & VTK_PARSE_INDIRECT) == VTK_PARSE_POINTER))) { fprintf(fp, " resultStream.Reset();\n" " resultStream << vtkClientServerStream::Reply << temp%i << vtkClientServerStream::End;\n", MAX_ARGS); return; } else if ((rType & VTK_PARSE_INDIRECT) == VTK_PARSE_REF) { fprintf(fp, " resultStream.Reset();\n" " resultStream << vtkClientServerStream::Reply << *temp%i << vtkClientServerStream::End;\n", MAX_ARGS); return; } else if ((rType & VTK_PARSE_INDIRECT) == VTK_PARSE_POINTER) { /* handle functions returning vectors */ /* this is done by looking them up in a hint file */ use_hints(fp); return; } break; case VTK_PARSE_VTK_OBJECT: /* Handle some objects of known type. */ if(strcmp(rClass, "vtkClientServerStream") == 0) { fprintf(fp, " resultStream.Reset();\n" " resultStream << vtkClientServerStream::Reply << *temp%i << vtkClientServerStream::End;\n", MAX_ARGS); return; } else if ((rType & VTK_PARSE_INDIRECT) == VTK_PARSE_POINTER) { fprintf(fp, " resultStream.Reset();\n" " resultStream << vtkClientServerStream::Reply << (vtkObjectBase *)temp%i << vtkClientServerStream::End;\n",MAX_ARGS); return; } break; } /* if we get to here, then the type was not recognized */ fprintf(fp, " resultStream.Reset();\n" " resultStream << vtkClientServerStream::Reply\n" " << \"unable to return result of type(%#x).\"\n" " << vtkClientServerStream::End;\n", (rType & VTK_PARSE_UNQUALIFIED_TYPE)); }
void return_result(FILE *fp) { switch (currentFunction->ReturnType & VTK_PARSE_UNQUALIFIED_TYPE) { case VTK_PARSE_VOID: fprintf(fp," Tcl_ResetResult(interp);\n"); break; case VTK_PARSE_FLOAT: case VTK_PARSE_DOUBLE: fprintf(fp," char tempResult[1024];\n"); /* * use tcl's print double function to support variable * precision at runtime */ fprintf(fp," Tcl_PrintDouble(interp,temp%i,tempResult);\n", MAX_ARGS); fprintf(fp," Tcl_SetResult(interp, tempResult, TCL_VOLATILE);\n"); break; case VTK_PARSE_INT: #ifndef VTK_USE_64BIT_IDS case VTK_PARSE_ID_TYPE: #endif case VTK_PARSE_SIGNED_CHAR: /* rely on promotion to integer, since "%hhi" is non-standard */ fprintf(fp," char tempResult[1024];\n"); fprintf(fp," sprintf(tempResult,\"%%i\",temp%i);\n", MAX_ARGS); fprintf(fp," Tcl_SetResult(interp, tempResult, TCL_VOLATILE);\n"); break; case VTK_PARSE_BOOL: fprintf(fp," char tempResult[1024];\n"); fprintf(fp," sprintf(tempResult,\"%%i\",(int)temp%i);\n", MAX_ARGS); fprintf(fp," Tcl_SetResult(interp, tempResult, TCL_VOLATILE);\n"); break; case VTK_PARSE_SHORT: fprintf(fp," char tempResult[1024];\n"); fprintf(fp," sprintf(tempResult,\"%%hi\",temp%i);\n", MAX_ARGS); fprintf(fp," Tcl_SetResult(interp, tempResult, TCL_VOLATILE);\n"); break; case VTK_PARSE_LONG: fprintf(fp," char tempResult[1024];\n"); fprintf(fp," sprintf(tempResult,\"%%li\",temp%i);\n", MAX_ARGS); fprintf(fp," Tcl_SetResult(interp, tempResult, TCL_VOLATILE);\n"); break; #ifdef VTK_USE_64BIT_IDS case VTK_PARSE_ID_TYPE: fprintf(fp," char tempResult[1024];\n"); # if defined(_MSC_VER) fprintf(fp," sprintf(tempResult,\"%%I64i\",temp%i);\n", MAX_ARGS); # else fprintf(fp," sprintf(tempResult,\"%%lli\",temp%i);\n", MAX_ARGS); # endif fprintf(fp," Tcl_SetResult(interp, tempResult, TCL_VOLATILE);\n"); break; #endif case VTK_PARSE_LONG_LONG: fprintf(fp," char tempResult[1024];\n"); fprintf(fp," sprintf(tempResult,\"%%lli\",temp%i);\n", MAX_ARGS); fprintf(fp," Tcl_SetResult(interp, tempResult, TCL_VOLATILE);\n"); break; case VTK_PARSE___INT64: fprintf(fp," char tempResult[1024];\n"); fprintf(fp," sprintf(tempResult,\"%%I64i\",temp%i);\n", MAX_ARGS); fprintf(fp," Tcl_SetResult(interp, tempResult, TCL_VOLATILE);\n"); break; case VTK_PARSE_UNSIGNED_INT: #ifndef VTK_USE_64BIT_IDS case VTK_PARSE_UNSIGNED_ID_TYPE: #endif fprintf(fp," char tempResult[1024];\n"); fprintf(fp," sprintf(tempResult,\"%%u\",temp%i);\n", MAX_ARGS); fprintf(fp," Tcl_SetResult(interp, tempResult, TCL_VOLATILE);\n"); break; case VTK_PARSE_UNSIGNED_SHORT: fprintf(fp," char tempResult[1024];\n"); fprintf(fp," sprintf(tempResult,\"%%hu\",temp%i);\n", MAX_ARGS); fprintf(fp," Tcl_SetResult(interp, tempResult, TCL_VOLATILE);\n"); break; case VTK_PARSE_UNSIGNED_LONG: fprintf(fp," char tempResult[1024];\n"); fprintf(fp," sprintf(tempResult,\"%%lu\",temp%i);\n", MAX_ARGS); fprintf(fp," Tcl_SetResult(interp, tempResult, TCL_VOLATILE);\n"); break; case VTK_PARSE_UNSIGNED_CHAR: /* rely on promotion to integer, since "%hhu" is non-standard */ fprintf(fp," char tempResult[1024];\n"); fprintf(fp," sprintf(tempResult,\"%%i\",temp%i);\n", MAX_ARGS); fprintf(fp," Tcl_SetResult(interp, tempResult, TCL_VOLATILE);\n"); break; #ifdef VTK_USE_64BIT_IDS case VTK_PARSE_UNSIGNED_ID_TYPE: fprintf(fp," char tempResult[1024];\n"); # if defined(_MSC_VER) fprintf(fp," sprintf(tempResult,\"%%I64u\",temp%i);\n", MAX_ARGS); # else fprintf(fp," sprintf(tempResult,\"%%llu\",temp%i);\n", MAX_ARGS); # endif fprintf(fp," Tcl_SetResult(interp, tempResult, TCL_VOLATILE);\n"); break; #endif case VTK_PARSE_UNSIGNED_LONG_LONG: fprintf(fp," char tempResult[1024];\n"); fprintf(fp," sprintf(tempResult,\"%%llu\",temp%i);\n", MAX_ARGS); fprintf(fp," Tcl_SetResult(interp, tempResult, TCL_VOLATILE);\n"); break; case VTK_PARSE_UNSIGNED___INT64: fprintf(fp," char tempResult[1024];\n"); fprintf(fp," sprintf(tempResult,\"%%I64u\",temp%i);\n", MAX_ARGS); fprintf(fp," Tcl_SetResult(interp, tempResult, TCL_VOLATILE);\n"); break; case VTK_PARSE_STRING: fprintf(fp," Tcl_SetResult(interp, const_cast<char *>(temp%i.c_str()), TCL_VOLATILE);\n",MAX_ARGS); break; case VTK_PARSE_STRING_REF: fprintf(fp," Tcl_SetResult(interp, const_cast<char *>(temp%i->c_str()), TCL_VOLATILE);\n",MAX_ARGS); break; case VTK_PARSE_CHAR_PTR: fprintf(fp," if (temp%i)\n {\n Tcl_SetResult(interp, const_cast<char *>(temp%i), TCL_VOLATILE);\n",MAX_ARGS,MAX_ARGS); fprintf(fp," }\n else\n {\n"); fprintf(fp," Tcl_ResetResult(interp);\n }\n"); break; case VTK_PARSE_CHAR: fprintf(fp," char tempResult[1024];\n"); fprintf(fp," sprintf(tempResult,\"%%c\",temp%i);\n", MAX_ARGS); fprintf(fp," Tcl_SetResult(interp, tempResult, TCL_VOLATILE);\n"); break; case VTK_PARSE_OBJECT_PTR: fprintf(fp," vtkTclGetObjectFromPointer(interp,(void *)(temp%i),\"%s\");\n",MAX_ARGS,currentFunction->ReturnClass); break; /* handle functions returning vectors */ /* this is done by looking them up in a hint file */ case VTK_PARSE_FLOAT_PTR: case VTK_PARSE_DOUBLE_PTR: case VTK_PARSE_INT_PTR: case VTK_PARSE_SHORT_PTR: case VTK_PARSE_LONG_PTR: case VTK_PARSE_ID_TYPE_PTR: case VTK_PARSE_LONG_LONG_PTR: case VTK_PARSE___INT64_PTR: case VTK_PARSE_SIGNED_CHAR_PTR: case VTK_PARSE_BOOL_PTR: case VTK_PARSE_UNSIGNED_CHAR_PTR: case VTK_PARSE_UNSIGNED_INT_PTR: case VTK_PARSE_UNSIGNED_SHORT_PTR: case VTK_PARSE_UNSIGNED_LONG_PTR: case VTK_PARSE_UNSIGNED_ID_TYPE_PTR: case VTK_PARSE_UNSIGNED_LONG_LONG_PTR: case VTK_PARSE_UNSIGNED___INT64_PTR: use_hints(fp); break; default: fprintf(fp," Tcl_SetResult(interp, const_cast<char *>(\"unable to return result.\"), TCL_VOLATILE);\n"); break; } }
void do_return(FILE *fp) { /* ignore void */ if (((currentFunction->ReturnType % 0x10) == 0x2)&& (!((currentFunction->ReturnType % 0x1000)/0x100))) { fprintf(fp," Py_INCREF(Py_None);\n"); fprintf(fp," return Py_None;\n"); return; } switch (currentFunction->ReturnType % 0x1000) { case 0x303: fprintf(fp," if (temp%i == NULL) {\n",MAX_ARGS); fprintf(fp," Py_INCREF(Py_None);\n"); fprintf(fp," return Py_None;\n }\n"); fprintf(fp," else {\n"); fprintf(fp," return PyString_FromString(temp%i);\n }\n",MAX_ARGS); break; case 0x109: case 0x309: { fprintf(fp," return vtkPythonGetObjectFromPointer((vtkObjectBase *)temp%i);\n", MAX_ARGS); break; } /* handle functions returning vectors */ /* this is done by looking them up in a hint file */ case 0x301: case 0x307: case 0x30A: case 0x30B: case 0x30C: case 0x30D: case 0x304: case 0x305: case 0x306: case 0x30E: use_hints(fp); break; case 0x302: { fprintf(fp," if (temp%i == NULL)\n {\n",MAX_ARGS); fprintf(fp," Py_INCREF(Py_None);\n"); fprintf(fp," return Py_None;\n }\n"); fprintf(fp," else\n {\n"); fprintf(fp," return PyString_FromString(vtkPythonManglePointer(temp%i,\"void_p\"));\n }\n", MAX_ARGS); break; } case 0x1: case 0x7: { fprintf(fp," return PyFloat_FromDouble(temp%i);\n", MAX_ARGS); break; } case 0x13: case 0x14: case 0x15: case 0x4: case 0x5: case 0x6: case 0xD: { fprintf(fp," return PyInt_FromLong(temp%i);\n", MAX_ARGS); break; } case 0xE: { /* PyBool_FromLong was introduced in Python 2.3. Use PyInt_FromLong as a bool substitute in earlier versions of python... */ fprintf(fp,"#if PY_VERSION_HEX >= 0x02030000\n"); fprintf(fp," return PyBool_FromLong(temp%i);\n", MAX_ARGS); fprintf(fp,"#else\n"); fprintf(fp," return PyInt_FromLong((long)temp%i);\n", MAX_ARGS); fprintf(fp,"#endif\n"); break; } case 0x16: { #if (PY_VERSION_HEX >= 0x02020000) fprintf(fp," return PyLong_FromUnsignedLong(temp%i);\n", MAX_ARGS); #else fprintf(fp," return PyInt_FromLong((long)temp%i);\n", MAX_ARGS); #endif break; } #if defined(VTK_USE_64BIT_IDS) && defined(PY_LONG_LONG) && (VTK_SIZEOF_LONG != VTK_SIZEOF_ID_TYPE) case 0xA: { fprintf(fp," return PyLong_FromLongLong(temp%i);\n", MAX_ARGS); break; } case 0x1A: { fprintf(fp," return PyLong_FromUnsignedLongLong(temp%i);\n", MAX_ARGS); break; } #else case 0xA: { fprintf(fp," return PyInt_FromLong((long)temp%i);\n", MAX_ARGS); break; } case 0x1A: { #if (PY_VERSION_HEX >= 0x02020000) fprintf(fp," return PyLong_FromUnsignedLong((unsigned long)temp%i);\n", MAX_ARGS); #else fprintf(fp," return PyInt_FromLong((long)temp%i);\n", MAX_ARGS); #endif break; } #endif #if defined(VTK_SIZEOF_LONG_LONG) # if defined(PY_LONG_LONG) && (VTK_SIZEOF_LONG != VTK_SIZEOF_LONG_LONG) case 0xB: { fprintf(fp," return PyLong_FromLongLong(temp%i);\n", MAX_ARGS); break; } case 0x1B: { fprintf(fp," return PyLong_FromUnsignedLongLong(temp%i);\n", MAX_ARGS); break; } # else case 0xB: { fprintf(fp," return PyLong_FromLong(temp%i);\n", MAX_ARGS); break; } case 0x1B: { fprintf(fp," return PyLong_FromUnsignedLong(temp%i);\n", MAX_ARGS); break; } # endif #endif #if defined(VTK_SIZEOF___INT64) # if defined(PY_LONG_LONG) && (VTK_SIZEOF_LONG != VTK_SIZEOF___INT64) case 0xC: { fprintf(fp," return PyLong_FromLongLong(temp%i);\n", MAX_ARGS); break; } case 0x1C: { fprintf(fp," return PyLong_FromUnsignedLongLong(temp%i);\n", MAX_ARGS); break; } # else case 0xC: { fprintf(fp," return PyLong_FromLong(temp%i);\n", MAX_ARGS); break; } case 0x1C: { fprintf(fp," return PyLong_FromUnsignedLong(temp%i);\n", MAX_ARGS); break; } # endif #endif case 0x3: { fprintf(fp," char temp%iString[2];\n" " temp%iString[0] = temp%i;\n" " temp%iString[1] = \'\\0\';\n" " return PyString_FromStringAndSize(temp%iString,1);\n", MAX_ARGS, MAX_ARGS, MAX_ARGS, MAX_ARGS, MAX_ARGS); break; } } }
void return_result(FILE *fp) { switch (currentFunction->ReturnType % 0x1000) { case 0x2: break; case 0x1: case 0x3: case 0x4: case 0x5: case 0x6: case 0x7: case 0xA: case 0xB: case 0xC: case 0xD: case 0xE: case 0x13: case 0x14: case 0x15: case 0x16: case 0x1A: case 0x1B: case 0x1C: case 0x303: fprintf(fp, " resultStream.Reset();\n" " resultStream << vtkClientServerStream::Reply << temp%i << vtkClientServerStream::End;\n", MAX_ARGS); break; case 0x109: case 0x309: /* Handle some objects of known type. */ if(strcmp(currentFunction->ReturnClass, "vtkClientServerStream") == 0) { fprintf(fp, " resultStream.Reset();\n" " resultStream << vtkClientServerStream::Reply << *temp%i << vtkClientServerStream::End;\n", MAX_ARGS); } else { fprintf(fp, " resultStream.Reset();\n" " resultStream << vtkClientServerStream::Reply << (vtkObjectBase *)temp%i << vtkClientServerStream::End;\n",MAX_ARGS); } break; /* handle functions returning vectors */ /* this is done by looking them up in a hint file */ case 0x301: case 0x307: case 0x304: case 0x305: case 0x306: case 0x30A: case 0x30B: case 0x30C: case 0x30D: case 0x313: case 0x314: case 0x315: case 0x316: case 0x31A: case 0x31B: case 0x31C: use_hints(fp); break; case 0x9: { /* Handle some objects of known type. */ if(strcmp(currentFunction->ReturnClass, "vtkClientServerStream") == 0) { fprintf(fp, " resultStream.Reset();\n" " resultStream << vtkClientServerStream::Reply << temp%i << vtkClientServerStream::End;\n", MAX_ARGS); break; } } default: fprintf(fp, " resultStream.Reset();\n" " resultStream << vtkClientServerStream::Reply\n" " << \"unable to return result of type(%d %% 0x1000 = %d).\"\n" " << vtkClientServerStream::End;\n", currentFunction->ReturnType, currentFunction->ReturnType % 0x1000); break; } }