VTK/Wrapper Update 2012: Difference between revisions
(Created page with "The VTK wrappers received a major overhaul in 2010 prior to the release of VTK 5.8. Work on improving the wrappers has continued (though at a slower pace) and this document aims...") |
|||
Line 35: | Line 35: | ||
Along with the code cleanup, the grammar rules in vtkParse.y have been rewritten. This started with trial-and-error modifications to enable the parser to wrap header files that contained ITK class declarations, and culminated in the renaming and rewriting the rules to approximate the grammar for the 1998 ISO C++ standard. With these changes, it is hoped that only truly pathological code will be able to break the parser without also breaking at least one of the supported VTK compilers. | Along with the code cleanup, the grammar rules in vtkParse.y have been rewritten. This started with trial-and-error modifications to enable the parser to wrap header files that contained ITK class declarations, and culminated in the renaming and rewriting the rules to approximate the grammar for the 1998 ISO C++ standard. With these changes, it is hoped that only truly pathological code will be able to break the parser without also breaking at least one of the supported VTK compilers. | ||
===Integrating the Wrapper Tools with the Modular Macros=== | |||
===Making a WrapperTools Module=== | |||
In order to build vtkWrapCientServer, the ParaView cmake files must grab certain wrapper source files from the VTK source code and compile them. This means that any cleanup or reorganization of the VTK wrapper tool code necessitates manual adjustments to the build scripts for vtkWrapClientServer. If the VTK wrapper tools existed as a library module, then it would be much easier to create and maintain external wrapper tools like vtkWrapClientServer. |
Revision as of 21:07, 14 August 2012
The VTK wrappers received a major overhaul in 2010 prior to the release of VTK 5.8. Work on improving the wrappers has continued (though at a slower pace) and this document aims to describe the wrapper goals for VTK 6.0.
Overview
The "Wrapper Overhaul 2010" project (Source article) had four primary goals, three of which were completed:
- Cleaning up the wrapper code (always more to do, though...)
- Wrapping vtkStdString (and vtkUnicodeString)
- Wrapping vtkVariant (and other non-vtkObject types)
- Eliminating BTX/ETX from the VTK header files
Item 3 was eventually extended to cover templated classes like vtkVector, which is a good demonstration of the power of the VTK wrapping tools. Items 3 and 4 necessitated the adoption of the vtkWrapHierarchy tool, which is only now (Aug 2012) being adopted into VTK-based projects like ParaView. As a result, Item 4 was not completed... it is possible to build VTK with all the BTX/ETX markers removed, but this will cause external wrappers like those in ParaView to fail.
The new goals, which are targeted for the VTK 6.0 release, are:
- More wrapper code cleanup (always more to do here)
- Integrate wrapping with the new modular VTK cmake scripts (Kitware has mostly finished this)
- Make the wrapping tools themselves into a VTK module
- Finish the work on removing BTX/ETX
Detailed Descriptions
Code Cleanup and Enhancement
Nearly all the parsing code for the wrappers was contained in one huge file, vtkParse.y. In 2010 the code in this file was cleaned up, but the file itself was still huge. Now, the parser code has been reorganized into several smaller "vtkParse..." files such as:
- vtkParseMain.c - argument parsing and other useful things for wrapper tool executables
- vtkParseHierarchy.c - allow wrapper tools to introspect the class hierarchy (created in 2010)
- vtkParseData.c - data structures for describing C++ classes, constants, functions, templates, and types
- vtkParseString.c - an efficient replacement for the dreaded "strdup()" that allows memory reclamation
- vtkParseMangle.c - provide symbol mangling utilities
- vtkParseExtras.c - a catch-all for utilities that don't fit elsewhere (created in 2010)
The tokenizer file, vtkParse.l, was much smaller than vtkParse.y but it has also been reorganized and supplemented:
- vtkParsePreprocess.c - preprocess C++ files, keep a table of macro definitions
The fact that the wrapper tools can expand macros and follow preprocessor directives makes them much more robust, though in order for the full power of the preprocessor to be realized the wrapper tools must be supplied with a list of include directories given on the command line as "-I" arguments.
Along with the code cleanup, the grammar rules in vtkParse.y have been rewritten. This started with trial-and-error modifications to enable the parser to wrap header files that contained ITK class declarations, and culminated in the renaming and rewriting the rules to approximate the grammar for the 1998 ISO C++ standard. With these changes, it is hoped that only truly pathological code will be able to break the parser without also breaking at least one of the supported VTK compilers.
Integrating the Wrapper Tools with the Modular Macros
Making a WrapperTools Module
In order to build vtkWrapCientServer, the ParaView cmake files must grab certain wrapper source files from the VTK source code and compile them. This means that any cleanup or reorganization of the VTK wrapper tool code necessitates manual adjustments to the build scripts for vtkWrapClientServer. If the VTK wrapper tools existed as a library module, then it would be much easier to create and maintain external wrapper tools like vtkWrapClientServer.