Commit 348265e0 authored by David Gobbi's avatar David Gobbi Committed by Kitware Robot

Merge topic 'wrapper-using-declarations'

df0ebf0b Apply using declarations that hadn't been "used".
88693d29 Allow wrappers to properly support "using" methods.
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !65
parents 9a5b182e df0ebf0b
......@@ -58,47 +58,11 @@ public:
int GetNumberOfCellsPerBucket()
{ return this->NumberOfCellsPerNode; }
//BTX
/*
if the borland compiler is ever removed, we can use these declarations
instead of reimplementaing the calls in this subclass
// Re-use any superclass signatures that we don't override.
using vtkAbstractCellLocator::IntersectWithLine;
using vtkAbstractCellLocator::FindCell;
using vtkAbstractCellLocator::FindClosestPoint;
using vtkAbstractCellLocator::FindClosestPointWithinRadius;
*/
//ETX
// Description:
// reimplemented from vtkAbstractCellLocator to support bad compilers
virtual int IntersectWithLine(
double a0[3], double a1[3], double tol,
double& t, double x[3], double pcoords[3],
int &subId)
{
return Superclass::
IntersectWithLine(a0, a1, tol,t, x, pcoords, subId);
}
// Description:
// reimplemented from vtkAbstractCellLocator to support bad compilers
virtual int IntersectWithLine(
double a0[3], double a1[3], double tol,
double& t, double x[3], double pcoords[3],
int &subId, vtkIdType &cellId)
{
return Superclass::
IntersectWithLine(a0, a1, tol,t, x, pcoords, subId, cellId);
}
// Description:
// reimplemented from vtkAbstractCellLocator to support bad compilers
virtual int IntersectWithLine(
const double a0[3], const double a1[3],
vtkPoints *points, vtkIdList *cellIds)
{
return Superclass::
IntersectWithLine(a0, a1, points, cellIds);
}
// Description:
// Return intersection point (if any) AND the cell which was intersected by
......@@ -109,16 +73,6 @@ public:
int &subId, vtkIdType &cellId,
vtkGenericCell *cell);
// Description:
// reimplemented from vtkAbstractCellLocator to support bad compilers
virtual void FindClosestPoint(
double x[3], double closestPoint[3],
vtkIdType &cellId, int &subId, double& dist2)
{
Superclass::
FindClosestPoint(x, closestPoint, cellId, subId, dist2);
}
// Description:
// Return the closest point and the cell which is closest to the point x.
// The closest point is somewhere on a cell, it need not be one of the
......@@ -134,29 +88,6 @@ public:
vtkGenericCell *cell, vtkIdType &cellId,
int &subId, double& dist2);
// Description:
// reimplemented from vtkAbstractCellLocator to support bad compilers
virtual vtkIdType FindClosestPointWithinRadius(
double x[3], double radius,
double closestPoint[3], vtkIdType &cellId,
int &subId, double& dist2)
{
return Superclass::FindClosestPointWithinRadius
(x, radius, closestPoint, cellId, subId, dist2);
}
// Description:
// reimplemented from vtkAbstractCellLocator to support bad compilers
virtual vtkIdType FindClosestPointWithinRadius(
double x[3], double radius,
double closestPoint[3],
vtkGenericCell *cell, vtkIdType &cellId,
int &subId, double& dist2)
{
return Superclass::FindClosestPointWithinRadius
(x, radius, closestPoint, cell, cellId, subId, dist2);
}
// Description:
// Return the closest point within a specified radius and the cell which is
// closest to the point x. The closest point is somewhere on a cell, it
......@@ -187,12 +118,6 @@ public:
// built before attempting to access buckets (octants).
virtual int GetNumberOfBuckets(void);
// Description:
// Returns the Id of the cell containing the point,
// returns -1 if no cell found. This interface uses a tolerance of zero
virtual vtkIdType FindCell(double x[3])
{ return this->Superclass::FindCell(x); }
// Description:
// Find the cell containing a given point. returns -1 if no cell found
// the cell parameters are copied into the supplied variables, a cell must
......
......@@ -163,11 +163,9 @@ class VTKFILTERSFLOWPATHS_EXPORT vtkModifiedBSPTree : public vtkAbstractCellLoca
// Construct with maximum 32 cells per node. (average 16->31)
static vtkModifiedBSPTree *New();
//BTX
// Re-use any superclass signatures that we don't override.
using vtkAbstractCellLocator::IntersectWithLine;
using vtkAbstractCellLocator::FindClosestPoint;
using vtkAbstractCellLocator::FindClosestPointWithinRadius;
//ETX
using vtkAbstractCellLocator::FindCell;
// Description:
// Free tree memory
......@@ -186,14 +184,6 @@ class VTKFILTERSFLOWPATHS_EXPORT vtkModifiedBSPTree : public vtkAbstractCellLoca
// Generate BBox representation of all leaf nodes
virtual void GenerateRepresentationLeafs(vtkPolyData *pd);
// Description:
// Return intersection point (if any) of finite line with cells contained
// in cell locator.
virtual int IntersectWithLine(
double p1[3], double p2[3], double tol, double& t, double x[3],
double pcoords[3], int &subId)
{ return this->Superclass::IntersectWithLine(p1, p2, tol, t, x, pcoords, subId); }
// Description:
// Return intersection point (if any) AND the cell which was intersected by
// the finite line. Uses fast tree-search BBox rejection tests.
......@@ -208,22 +198,6 @@ class VTKFILTERSFLOWPATHS_EXPORT vtkModifiedBSPTree : public vtkAbstractCellLoca
double p1[3], double p2[3], double tol, double &t, double x[3],
double pcoords[3], int &subId, vtkIdType &cellId, vtkGenericCell *cell);
// Description:
// Take the passed line segment and intersect it with the data set.
// This method assumes that the data set is a vtkPolyData that describes
// a closed surface, and the intersection points that are returned in
// 'points' alternate between entrance points and exit points.
// The return value of the function is 0 if no intersections were found,
// -1 if point 'a0' lies inside the closed surface, or +1 if point 'a0'
// lies outside the closed surface.
// Either 'points' or 'cellIds' can be set to NULL if you don't want
// to receive that information. This method is currently only implemented
// in vtkOBBTree
virtual int IntersectWithLine(
const double p1[3], const double p2[3],
vtkPoints *points, vtkIdList *cellIds)
{ return this->Superclass::IntersectWithLine(p1, p2, points, cellIds); }
// Description:
// Take the passed line segment and intersect it with the data set.
// The return value of the function is 0 if no intersections were found.
......@@ -235,12 +209,6 @@ class VTKFILTERSFLOWPATHS_EXPORT vtkModifiedBSPTree : public vtkAbstractCellLoca
const double p1[3], const double p2[3], const double tol,
vtkPoints *points, vtkIdList *cellIds);
// Description:
// Returns the Id of the cell containing the point,
// returns -1 if no cell found. This interface uses a tolerance of zero
virtual vtkIdType FindCell(double x[3])
{ return this->Superclass::FindCell(x); }
// Description:
// Test a point to find if it is inside a cell. Returns the cellId if inside
// or -1 if not.
......
......@@ -89,37 +89,8 @@ public:
// 25 cells per octant.
static vtkOBBTree *New();
//BTX
/*
if the borland compiler is ever removed, we can use these declarations
instead of reimplementaing the calls in this subclass
// Re-use any superclass signatures that we don't override.
using vtkAbstractCellLocator::IntersectWithLine;
using vtkAbstractCellLocator::FindClosestPoint;
using vtkAbstractCellLocator::FindClosestPointWithinRadius;
*/
//ETX
// Description:
// reimplemented from vtkAbstractCellLocator to support bad compilers
virtual int IntersectWithLine(
double a0[3], double a1[3], double tol,
double& t, double x[3], double pcoords[3],
int &subId)
{
return Superclass::
IntersectWithLine(a0, a1, tol,t, x, pcoords, subId);
}
// Description:
// reimplemented from vtkAbstractCellLocator to support bad compilers
virtual int IntersectWithLine(
double a0[3], double a1[3], double tol,
double& t, double x[3], double pcoords[3],
int &subId, vtkIdType &cellId)
{
return Superclass::
IntersectWithLine(a0, a1, tol,t, x, pcoords, subId, cellId);
}
// Description:
// Take the passed line segment and intersect it with the data set.
......@@ -142,69 +113,6 @@ public:
double& t, double x[3], double pcoords[3],
int &subId, vtkIdType &cellId, vtkGenericCell *cell);
// Description:
// Return the closest point and the cell which is closest to the point x.
// The closest point is somewhere on a cell, it need not be one of the
// vertices of the cell. This version takes in a vtkGenericCell
// to avoid allocating and deallocating the cell. This is much faster than
// the version which does not take a *cell, especially when this function is
// called many times in a row such as by a for loop, where the allocation and
// deallocation can be done only once outside the for loop. If a cell is
// found, "cell" contains the points and ptIds for the cell "cellId" upon
// exit.
virtual void FindClosestPoint(
double x[3], double closestPoint[3],
vtkIdType &cellId, int &subId, double& dist2)
{
Superclass::
FindClosestPoint(x, closestPoint, cellId, subId, dist2);
}
// Description:
// reimplemented from vtkAbstractCellLocator to support bad compilers
virtual void FindClosestPoint(
double x[3], double closestPoint[3],
vtkGenericCell *cell, vtkIdType &cellId,
int &subId, double& dist2)
{
Superclass::
FindClosestPoint(x, closestPoint, cell, cellId, subId, dist2);
}
// Description:
// reimplemented from vtkAbstractCellLocator to support bad compilers
virtual vtkIdType FindClosestPointWithinRadius(
double x[3], double radius,
double closestPoint[3], vtkIdType &cellId,
int &subId, double& dist2)
{
return Superclass::FindClosestPointWithinRadius
(x, radius, closestPoint, cellId, subId, dist2);
}
// Description:
// reimplemented from vtkAbstractCellLocator to support bad compilers
virtual vtkIdType FindClosestPointWithinRadius(
double x[3], double radius,
double closestPoint[3],
vtkGenericCell *cell, vtkIdType &cellId,
int &subId, double& dist2)
{
return Superclass::FindClosestPointWithinRadius
(x, radius, closestPoint, cell, cellId, subId, dist2);
}
// Description:
// reimplemented from vtkAbstractCellLocator to support bad compilers
virtual vtkIdType FindClosestPointWithinRadius(
double x[3], double radius, double closestPoint[3],
vtkGenericCell *cell, vtkIdType &cellId,
int &subId, double& dist2, int &inside)
{
return Superclass::FindClosestPointWithinRadius
(x, radius, closestPoint, cell, cellId, subId, dist2, inside);
}
// Description:
// Compute an OBB from the list of points given. Return the corner point
// and the three axes defining the orientation of the OBB. Also return
......
......@@ -17,6 +17,7 @@ set(VTK_PARSE_SOURCES
vtkParseMain.c
vtkParseExtras.c
vtkParseMangle.c
vtkParseMerge.c
vtkParseString.c
vtkParseHierarchy.c
vtkParsePreprocess.c
......
This diff is collapsed.
......@@ -29,6 +29,16 @@
#include "vtkParseData.h"
#include <stddef.h>
/* Flags for selecting what info to print for declarations */
#define VTK_PARSE_NAMES 0x00000010
#define VTK_PARSE_VALUES 0x00000020
#define VTK_PARSE_RETURN_VALUE 0x00000040
#define VTK_PARSE_PARAMETER_LIST 0x00000080
#define VTK_PARSE_SPECIFIERS 0x00FF0000
#define VTK_PARSE_TRAILERS 0x0F000000
#define VTK_PARSE_TEMPLATES 0xF0000000
#define VTK_PARSE_EVERYTHING 0xFFFFFFFF
#ifdef __cplusplus
extern "C" {
#endif
......@@ -83,12 +93,55 @@ size_t vtkParse_ValueInfoFromString(
ValueInfo *val, StringCache *cache, const char *text);
/**
* Generate a declaration string from a ValueInfo struct. If the
* "nf" arg is set, the returned string must be freed.
* Only simple text strings are supported, e.g. "const T **".
* The variable or typedef name, if present, is ignored.
* Generate a C++ declaration string from a ValueInfo struct.
*
* The resulting string can represent a parameter declaration, a variable
* or type declaration, or a function return value. To use this function,
* you should call it twice: first, call it with "text" set to NULL, and
* it will return a lower bound on the length of the string that will be
* produced. Next, allocate at least length+1 bytes for the string, and
* and call it again with "text" set to the allocated string. The number
* of bytes written to the string (not including the terminating null) will
* be returned.
*
* The flags provide a mask that controls what information will be included,
* for example VTK_PARSE_CONST|VTK_PARSE_VOLATILE is needed to include the
* 'const' or 'volatile' qualifiers. Use VTK_PARSE_EVERYTHING to generate
* the entire declaration for a variable or parameter.
*/
size_t vtkParse_ValueInfoToString(
ValueInfo *data, char *text, unsigned int flags);
/**
* Generate a C++ function signature from a FunctionInfo struct.
*
* See vtkParse_ValueInfoToString() for basic usage. The flags can be set
* to VTK_PARSE_RETURN_VALUE to print only the return value for the function,
* or VTK_PARSE_PARAMETER_LIST to print only the parameter list.
*/
size_t vtkParse_FunctionInfoToString(
FunctionInfo *func, char *text, unsigned int flags);
/**
* Generate a C++ template declaration from a TemplateInfo struct.
*
* See vtkParse_ValueInfoToString() for basic usage.
*/
size_t vtkParse_TemplateInfoToString(
TemplateInfo *func, char *text, unsigned int flags);
/**
* Compare two C++ functions to see if they have the same signature.
*
* The following are the possible return values. Any non-zero return value
* means that the parameters match. If the 2nd bit is also set, then the
* function return value also matches. If the 3rd bit is set, then the
* parameters match and both methods are members of the same class, and
* the constness of the functions match. This means that the signatures
* are not identical unless the return value is 7 or higher (.
*/
const char *vtkParse_ValueInfoToString(ValueInfo *val, int *nf);
int vtkParse_CompareFunctionSignature(
const FunctionInfo *func1, const FunctionInfo *func2);
/**
* Expand a typedef within a variable, parameter, or typedef declaration.
......
......@@ -19,6 +19,7 @@
#include "vtkParse.h"
#include "vtkParseMain.h"
#include "vtkParseHierarchy.h"
#include "vtkWrap.h"
HierarchyInfo *hierarchyInfo = NULL;
StringCache *stringCache = NULL;
......@@ -861,6 +862,11 @@ int main(int argc, char *argv[])
if (options->HierarchyFileName)
{
hierarchyInfo = vtkParseHierarchy_ReadFile(options->HierarchyFileName);
if (hierarchyInfo)
{
/* resolve using declarations within the header files */
vtkWrap_ApplyUsingDeclarations(data, file_info, hierarchyInfo);
}
}
fprintf(fp,"// java wrapper for %s object\n//\n",data->Name);
......
This diff is collapsed.
/*=========================================================================
Program: Visualization Toolkit
Module: vtkParseMerge.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/*-------------------------------------------------------------------------
Copyright (c) 2010,2015 David Gobbi
Contributed to the VisualizationToolkit by the author in March 2015
under the terms of the Visualization Toolkit 2015 copyright.
-------------------------------------------------------------------------*/
/**
This file contains utility functions for merging together the
methods for a class with those inherited from all superclasses.
*/
#ifndef VTK_PARSE_MERGE_H
#define VTK_PARSE_MERGE_H
#include "vtkParseData.h"
#include "vtkParseHierarchy.h"
/**
* This struct is meant to supplement ClassInfo, it gives information
* about which class (or classes) each method was inherited from
*/
typedef struct _MergeInfo
{
int NumberOfClasses; /* number of classes in geneology */
const char **ClassNames; /* class name */
int NumberOfFunctions; /* must match FunctionInfo */
int *NumberOfOverrides; /* n classes that define this function */
int **OverrideClasses; /* class for the override */
} MergeInfo;
#ifdef __cplusplus
extern "C" {
#endif
/**
* Merge all inherited methods into the ClassInfo.
* This will find and parse the header files for all the superclasses,
* and recursively add all inherited superclass methods into one ClassInfo.
* The returned MergeInfo object provides information about which class
* each inherited method was inherited from.
*/
MergeInfo *vtkParseMerge_MergeSuperClasses(
FileInfo *finfo, NamespaceInfo *data, ClassInfo *classInfo);
/**
* Free the MergeInfo object.
*/
void vtkParseMerge_FreeMergeInfo(MergeInfo *info);
/**
* Recursive suproutine to inherit methods from "classname".
* The class named by "classname" should be a superclass of the ClassInfo.
* If the MergeInfo is not provided (if it is NULL), then the only methods
* that are brought into the class are ones that are explicitly named
* by using declarations. The hintfile can also be NULL, if there is
* no hints file.
*/
void vtkParseMerge_MergeHelper(
FileInfo *finfo, const NamespaceInfo *data, const HierarchyInfo *hinfo,
const char *classname, FILE *hintfile, MergeInfo *info, ClassInfo *merge);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif
......@@ -16,6 +16,7 @@
#include "vtkWrap.h"
#include "vtkParseData.h"
#include "vtkParseExtras.h"
#include "vtkParseMerge.h"
#include "vtkParseString.h"
#include <stdlib.h>
#include <string.h>
......@@ -844,6 +845,34 @@ void vtkWrap_ExpandTypedefs(
}
}
/* -------------------------------------------------------------------- */
/* Merge superclass methods according to using declarations */
void vtkWrap_ApplyUsingDeclarations(
ClassInfo *data, FileInfo *finfo, HierarchyInfo *hinfo)
{
int i, n;
/* first, check if there are any declarations to apply */
n = data->NumberOfUsings;
for (i = 0; i < n; i++)
{
if (data->Usings[i] && data->Usings[i]->Name)
{
break;
}
}
/* if using declarations found, read superclass headers */
if (i < n)
{
n = data->NumberOfSuperClasses;
for (i = 0; i < n; i++)
{
vtkParseMerge_MergeHelper(
finfo, finfo->Contents, hinfo, data->SuperClasses[i],
NULL, NULL, data);
}
}
}
/* -------------------------------------------------------------------- */
/* get the type name */
......
......@@ -163,6 +163,15 @@ int vtkWrap_HasPublicCopyConstructor(ClassInfo *data);
void vtkWrap_ExpandTypedefs(
ClassInfo *data, FileInfo *finfo, HierarchyInfo *hinfo);
/**
* Apply any using declarations that appear in the class.
* If any using declarations appear in the class that refer to superclass
* methods, the superclass header file will be parsed and the used methods
* will be brought into the class.
*/
void vtkWrap_ApplyUsingDeclarations(
ClassInfo *data, FileInfo *finfo, HierarchyInfo *hinfo);
/**
* Apply any hints about array sizes, e.g. hint that the
* GetNumberOfComponents() method gives the tuple size.
......
......@@ -1282,6 +1282,11 @@ int main(int argc, char *argv[])
if (options->HierarchyFileName)
{
hierarchyInfo = vtkParseHierarchy_ReadFile(options->HierarchyFileName);
if (hierarchyInfo)
{
/* resolve using declarations within the header files */
vtkWrap_ApplyUsingDeclarations(data, file_info, hierarchyInfo);
}
}
fprintf(fp,"// java wrapper for %s object\n//\n",data->Name);
......
......@@ -471,6 +471,10 @@ int main(int argc, char *argv[])
/* use the hierarchy file to expand typedefs */
if (hinfo)
{
for (i = 0; i < contents->NumberOfClasses; i++)
{
vtkWrap_ApplyUsingDeclarations(contents->Classes[i], file_info, hinfo);
}
for (i = 0; i < contents->NumberOfClasses; i++)
{
vtkWrap_ExpandTypedefs(contents->Classes[i], file_info, hinfo);
......
......@@ -1127,6 +1127,11 @@ int main(int argc, char *argv[])
if (options->HierarchyFileName)
{
hierarchyInfo = vtkParseHierarchy_ReadFile(options->HierarchyFileName);
if (hierarchyInfo)
{
/* resolve using declarations within the header files */
vtkWrap_ApplyUsingDeclarations(data, file_info, hierarchyInfo);
}
}
fprintf(fp,"// tcl wrapper for %s object\n//\n",data->Name);
......
Markdown is supported
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