vtkWrapMacro

John Biddiscombe j.biddiscombe at rl.ac.uk
Mon Apr 3 10:08:22 EDT 2000


I have a suggestion regarding the tcl wrapping etc etc.

I've been working quite hard at generating an automatic means of wrapping
filters with tcl and combining this with my own wrapping process.

How about 

vtkWrapMacro(thisClass,ParentClass,Win32,Abstract/Concrete,Header/cxx,wrapTc
lYes,Wrap...)

it could expand to nothing in c++ but provide an easy hook for the parsing
process in pcmaker/GetClasses and in vtk\Wrap.

I'm sure it isn't necessary, but the code in getclasses looks dreadful.

The main reason is for those of us that have developed large numbers of our
own filters (60+ now) and don't want to put them in vtk\local, but do want
to automatically wrap them in tcl.

By providing a wrapMacro with some general information
Win32 Specific. X specific. Abstract ot concrete etc etc
The dependence on the makefile.in is reduced in common/graphics/imagine etc
etc 

(I've made a pcmaker type program which will scan directories for files
vtk*.h and if there was a vtkWrapMacro(...) in the header for each class,
it'd be trivial to include them in the tcl wrapping etc etc.) Users need
only supply the directory of their own classes and off they go. Currently,
I have to have the user manually click checkboxes for each vtk*.h file it
finds and enter
wrapTcl yes/No
Win32 only yes/no
Abstract/Concrete etc etc

I guess you could argue that each directory needs only a makefile.in file
to achieve the same goal, but the code in GetClasses.cxx proves this is
nonsense!

It seems to me that tcl wrapping should only take place for concrete
classes, but if a function is declared in an abstract base class, then it
needs to be pulled in and parsed. Using the above macro would give you the
superclass name (like vtkTypeMacro) and you could pull it in and parse it.
Only concrete classes would be scanned at all and the exports section of
vtktcl.dll might be better. (?)

John B

PS. Ive added my own Macro to vtkSetGet.h vtkTypeMacro

static int InheritsFrom(const char *Name) {
	if (!strcmp(typeid(thisClass).name(),Name)) return 1;
	else if(!strcmp(typeid(thisClass).name(),"vtkObject")) return 0;
	else return superclass::InheritsFrom(Name);
} 

this allows you to call

vtkCellLocator::InheritsFrom("vtkLocator");

and get a boolean answer. I find it very useful when you want to query
inheritance but have no pointers available.

Just a thought, any comments. I use it to pass pointers like

CanAcceptDragDrop(@vtkCellLocator::InheritsFrom,"classname");

a bit obscure I realize, but would anyone else use it?





More information about the vtk-developers mailing list