Commit a597c63b authored by Ken Martin's avatar Ken Martin
Browse files

ENH: modified the TCL wrappers to no longer take in a function pointer for...

ENH: modified the TCL wrappers to no longer take in a function pointer for vtkTclGetObjectFromPointer instead a string name for the return class type is passed. This allows methods to be wrapped that return vtk classes that have not been wrapped without a link error. The run time behaviour should be the same.
parent 33d4babb
......@@ -242,8 +242,9 @@ vtkTclUpdateCommand(Tcl_Interp *interp, char *name, vtkObject *temp)
VTKTCL_EXPORT void
vtkTclGetObjectFromPointer(Tcl_Interp *interp, void *temp1,
int (*command)(ClientData, Tcl_Interp *,int, char *[]))
const char *targetType)
{
int (*command)(ClientData, Tcl_Interp *,int, char *[]) = 0;
int is_new;
vtkObject *temp = (vtkObject *)temp1;
char temps[80];
......@@ -301,6 +302,40 @@ vtkTclGetObjectFromPointer(Tcl_Interp *interp, void *temp1,
command = cs->CommandFunction;
}
}
// if the class command wasn;t found try the target return type command
if (!command && targetType)
{
if (tstr)
{
free(tstr);
}
tstr = strdup(targetType);
if (Tcl_GetCommandInfo(interp,tstr,&cinf))
{
if (cinf.clientData)
{
vtkTclCommandStruct *cs = (vtkTclCommandStruct *)cinf.clientData;
command = cs->CommandFunction;
}
}
}
// if we still do not havbe a match then try vtkObject
if (!command)
{
if (tstr)
{
free(tstr);
}
tstr = strdup("vtkObject");
if (Tcl_GetCommandInfo(interp,tstr,&cinf))
{
if (cinf.clientData)
{
vtkTclCommandStruct *cs = (vtkTclCommandStruct *)cinf.clientData;
command = cs->CommandFunction;
}
}
}
if (tstr)
{
free(tstr);
......
......@@ -37,8 +37,7 @@ extern VTKTCL_EXPORT void vtkTclGenericDeleteObject(ClientData cd);
extern VTKTCL_EXPORT void
vtkTclGetObjectFromPointer(Tcl_Interp *interp, void *temp,
int (*command)(ClientData,
Tcl_Interp *,int, char *[]));
const char *targetType);
extern VTKTCL_EXPORT void *
vtkTclGetPointerFromObject(const char *name, const char *result_type,
......
......@@ -567,7 +567,7 @@ static int vtkTkImageViewerWidget_MakeImageViewer(struct vtkTkImageViewerWidget
self->ImageViewer = imgViewer = vtkImageViewer::New();
#ifndef VTK_PYTHON_BUILD
vtkTclGetObjectFromPointer(self->Interp, self->ImageViewer,
vtkImageViewerCommand);
"vtkImageViewer");
#endif
ckfree (self->IV);
self->IV = strdup(self->Interp->result);
......
......@@ -854,7 +854,7 @@ static int vtkTkRenderWidget_MakeRenderWindow(struct vtkTkRenderWidget *self)
renderWindow = (vtkWin32OpenGLRenderWindow *)(self->RenderWindow);
#ifndef VTK_PYTHON_BUILD
vtkTclGetObjectFromPointer(self->Interp, self->RenderWindow,
vtkRenderWindowCommand);
"vtkRenderWindow");
#endif
self->RW = strdup(self->Interp->result);
self->Interp->result[0] = '\0';
......
......@@ -211,7 +211,7 @@ void return_result(FILE *fp)
break;
case 109:
case 309:
fprintf(fp," vtkTclGetObjectFromPointer(interp,(void *)temp%i,%sCommand);\n",MAX_ARGS,currentFunction->ReturnClass);
fprintf(fp," vtkTclGetObjectFromPointer(interp,(void *)temp%i,\"%s\");\n",MAX_ARGS,currentFunction->ReturnClass);
break;
/* handle functions returning vectors */
......@@ -227,17 +227,6 @@ void return_result(FILE *fp)
}
}
void handle_return_prototype(FILE *fp)
{
switch (currentFunction->ReturnType%1000)
{
case 109:
case 309:
fprintf(fp," int %sCommand(ClientData, Tcl_Interp *, int, char *[]);\n",currentFunction->ReturnClass);
break;
}
}
void get_args(FILE *fp, int i)
{
int j;
......@@ -451,7 +440,7 @@ void outputFunction(FILE *fp, FileInfo *data)
}
output_temp(fp, MAX_ARGS,currentFunction->ReturnType,
currentFunction->ReturnClass, 0);
handle_return_prototype(fp);
/* only use the error variable if we have arguments to parse */
if (currentFunction->NumberOfArguments)
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment