Commit c3ee5eb0 authored by David Gobbi's avatar David Gobbi Committed by Kitware Robot

Merge topic 'wrapexclude'

d83bf827 Test VTK_WRAPEXCLUDE on a couple classes
5e84eb6d Generically handle GetSet macro wrapping
6104d8c8 Check for IsExcluded in the language wrappers
dcacb7a3 Store WRAPEXCLUDE attribute in the hierarchy files
fb5df905 Add VTK_WRAPEXCLUDE attribute
d7e47571 Store "override" for use by the wrappers
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: Ben Boeckel's avatarBen Boeckel <ben.boeckel@kitware.com>
Merge-request: !5147
parents 7e33366b d83bf827
......@@ -19,12 +19,11 @@
#ifndef vtkLargeInteger_h
#define vtkLargeInteger_h
#ifndef __VTK_WRAP__
#include "vtkCommonCoreModule.h" // For export macro
#include "vtkObject.h"
class VTKCOMMONCORE_EXPORT vtkLargeInteger
class VTKCOMMONCORE_EXPORT VTK_WRAPEXCLUDE vtkLargeInteger
{
public:
vtkLargeInteger(void);
......@@ -109,7 +108,6 @@ private:
};
#endif
#endif
// VTK-HeaderTest-Exclude: vtkLargeInteger.h
......@@ -26,7 +26,6 @@
#ifndef vtkOStreamWrapper_h
#define vtkOStreamWrapper_h
#ifndef __VTK_WRAP__
#include "vtkCommonCoreModule.h"
......@@ -40,7 +39,7 @@ class vtkLargeInteger;
class vtkSmartPointerBase;
class vtkStdString;
class VTKCOMMONCORE_EXPORT vtkOStreamWrapper
class VTKCOMMONCORE_EXPORT VTK_WRAPEXCLUDE vtkOStreamWrapper
{
class std_string;
public:
......@@ -156,6 +155,5 @@ private:
};
//@}
#endif
#endif
// VTK-HeaderTest-Exclude: vtkOStreamWrapper.h
......@@ -316,12 +316,14 @@ virtual type *Get##name () VTK_SIZEHINT(2) \
vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning " << #name " pointer " << this->name); \
return this->name; \
} \
VTK_WRAPEXCLUDE \
virtual void Get##name (type &_arg1, type &_arg2) \
{ \
_arg1 = this->name[0]; \
_arg2 = this->name[1]; \
vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning " << #name " = (" << _arg1 << "," << _arg2 << ")"); \
} \
VTK_WRAPEXCLUDE \
virtual void Get##name (type _arg[2]) \
{ \
this->Get##name (_arg[0], _arg[1]);\
......@@ -350,6 +352,7 @@ virtual type *Get##name () VTK_SIZEHINT(3) \
vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning " << #name " pointer " << this->name); \
return this->name; \
} \
VTK_WRAPEXCLUDE \
virtual void Get##name (type &_arg1, type &_arg2, type &_arg3) \
{ \
_arg1 = this->name[0]; \
......@@ -357,6 +360,7 @@ virtual void Get##name (type &_arg1, type &_arg2, type &_arg3) \
_arg3 = this->name[2]; \
vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning " << #name " = (" << _arg1 << "," << _arg2 << "," << _arg3 << ")"); \
} \
VTK_WRAPEXCLUDE \
virtual void Get##name (type _arg[3]) \
{ \
this->Get##name (_arg[0], _arg[1], _arg[2]);\
......@@ -387,6 +391,7 @@ virtual type *Get##name () VTK_SIZEHINT(4) \
vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning " << #name " pointer " << this->name); \
return this->name; \
} \
VTK_WRAPEXCLUDE \
virtual void Get##name (type &_arg1, type &_arg2, type &_arg3, type &_arg4) \
{ \
_arg1 = this->name[0]; \
......@@ -395,6 +400,7 @@ virtual void Get##name (type &_arg1, type &_arg2, type &_arg3, type &_arg4) \
_arg4 = this->name[3]; \
vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning " << #name " = (" << _arg1 << "," << _arg2 << "," << _arg3 << "," << _arg4 << ")"); \
} \
VTK_WRAPEXCLUDE \
virtual void Get##name (type _arg[4]) \
{ \
this->Get##name (_arg[0], _arg[1], _arg[2], _arg[3]);\
......@@ -426,6 +432,7 @@ virtual type *Get##name () VTK_SIZEHINT(6) \
vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning " << #name " pointer " << this->name); \
return this->name; \
} \
VTK_WRAPEXCLUDE \
virtual void Get##name (type &_arg1, type &_arg2, type &_arg3, type &_arg4, type &_arg5, type &_arg6) \
{ \
_arg1 = this->name[0]; \
......@@ -436,6 +443,7 @@ virtual void Get##name (type &_arg1, type &_arg2, type &_arg3, type &_arg4, type
_arg6 = this->name[5]; \
vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning " << #name " = (" << _arg1 << "," << _arg2 << "," << _arg3 << "," << _arg4 << "," << _arg5 <<"," << _arg6 << ")"); \
} \
VTK_WRAPEXCLUDE \
virtual void Get##name (type _arg[6]) \
{ \
this->Get##name (_arg[0], _arg[1], _arg[2], _arg[3], _arg[4], _arg[5]);\
......@@ -470,6 +478,7 @@ virtual type *Get##name () VTK_SIZEHINT(count)\
vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning " << #name " pointer " << this->name); \
return this->name; \
} \
VTK_WRAPEXCLUDE \
virtual void Get##name (type data[count]) \
{ \
for (int i=0; i<count; i++) { data[i] = this->name[i]; }\
......
......@@ -25,6 +25,8 @@
#ifdef __VTK_WRAP__
#define VTK_WRAP_HINTS_DEFINED
// Exclude a method or class from wrapping
#define VTK_WRAPEXCLUDE [[vtk::wrapexclude]]
// The return value points to a newly-created VTK object.
#define VTK_NEWINSTANCE [[vtk::newinstance]]
// The parameter is a pointer to a zerocopy buffer.
......@@ -36,6 +38,7 @@
#endif
#ifndef VTK_WRAP_HINTS_DEFINED
#define VTK_WRAPEXCLUDE
#define VTK_NEWINSTANCE
#define VTK_ZEROCOPY
#define VTK_EXPECTS(x)
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -249,21 +249,6 @@ ID [a-zA-Z_\x80-\xff][0-9a-zA-Z_\x80-\xff]*
"bitor" return('|');
"compl" return('~');
"vtkSetVector2Macro" return(SetVector2Macro);
"vtkSetVector3Macro" return(SetVector3Macro);
"vtkSetVector4Macro" return(SetVector4Macro);
"vtkSetVector6Macro" return(SetVector6Macro);
"vtkGetVector2Macro" return(GetVector2Macro);
"vtkGetVector3Macro" return(GetVector3Macro);
"vtkGetVector4Macro" return(GetVector4Macro);
"vtkGetVector6Macro" return(GetVector6Macro);
"vtkSetVectorMacro" return(SetVectorMacro);
"vtkGetVectorMacro" return(GetVectorMacro);
"vtkViewportCoordinateMacro" return(ViewportCoordinateMacro);
"vtkWorldCoordinateMacro" return(WorldCoordinateMacro);
"VTK_WRAP_EXTERN" ;
"VTK_BYTE_SWAP_DECL" return(VTK_BYTE_SWAP_DECL);
"("{PS}({ID}"::")*"&" {
size_t i = 1;
size_t j;
......
This diff is collapsed.
This diff is collapsed.
......@@ -152,8 +152,10 @@ void vtkParse_InitFunction(FunctionInfo *func)
func->IsConst = 0;
func->IsDeleted = 0;
func->IsFinal = 0;
func->IsOverride = 0;
func->IsExplicit = 0;
func->IsLegacy = 0;
func->IsExcluded = 0;
#ifndef VTK_PARSE_LEGACY_REMOVE
/* everything below here is legacy information, *
......@@ -235,8 +237,10 @@ void vtkParse_CopyFunction(FunctionInfo *func, const FunctionInfo *orig)
func->IsConst = orig->IsConst;
func->IsDeleted = orig->IsDeleted;
func->IsFinal = orig->IsFinal;
func->IsOverride = orig->IsOverride;
func->IsExplicit = orig->IsExplicit;
func->IsLegacy = orig->IsLegacy;
func->IsExcluded = orig->IsExcluded;
#ifndef VTK_PARSE_LEGACY_REMOVE
/* everything below here is legacy information, *
......@@ -453,6 +457,7 @@ void vtkParse_InitClass(ClassInfo *cls)
cls->IsAbstract = 0;
cls->IsFinal = 0;
cls->HasDelete = 0;
cls->IsExcluded = 0;
}
/* Copy a Class struct */
......@@ -606,6 +611,7 @@ void vtkParse_CopyClass(ClassInfo *cls, const ClassInfo *orig)
cls->IsAbstract = orig->IsAbstract;
cls->IsFinal = orig->IsFinal;
cls->HasDelete = orig->HasDelete;
cls->IsExcluded = orig->IsExcluded;
}
/* Free a Class struct */
......
......@@ -186,12 +186,14 @@ struct _FunctionInfo
int IsOperator;
int IsVariadic;
int IsLegacy; /* marked as a legacy method or function */
int IsExcluded; /* marked as excluded from wrapping */
int IsStatic; /* methods only */
int IsVirtual; /* methods only */
int IsPureVirtual; /* methods only */
int IsConst; /* methods only */
int IsDeleted; /* methods only */
int IsFinal; /* methods only */
int IsOverride; /* methods only */
int IsExplicit; /* constructors only */
#ifndef VTK_PARSE_LEGACY_REMOVE
int NumberOfArguments; /* legacy */
......@@ -255,6 +257,7 @@ typedef struct _ClassInfo
int IsAbstract;
int IsFinal;
int HasDelete;
int IsExcluded;
} ClassInfo;
/**
......
......@@ -965,6 +965,21 @@ const char *vtkParseHierarchy_GetProperty(
return NULL;
}
/* Check whether the header was named after the type */
int vtkParseHierarchy_IsPrimary(const HierarchyEntry *entry)
{
size_t n = strlen(entry->Name);
if (entry->HeaderFile &&
strncmp(entry->HeaderFile, entry->Name, n) == 0 &&
entry->HeaderFile[n] == '.')
{
return 1;
}
return 0;
}
/* Expand all unrecognized types in the template args of a type
* using the typedefs in the HierarchyInfo struct.
* Return a cached string (or the original string if no change). */
......
......@@ -111,11 +111,16 @@ HierarchyEntry *vtkParseHierarchy_FindEntryEx(
* Get properties for the class. Returns NULL if the property
* is not set, and returns either an empty string or a value string
* if the property is set. The properties supported are as follows:
* "WRAP_EXCLUDE_PYTHON"
* "WRAPEXCLUDE"
*/
const char *vtkParseHierarchy_GetProperty(
const HierarchyEntry *entry, const char *property);
/**
* Check whether item's name is the same as the header name.
*/
int vtkParseHierarchy_IsPrimary(const HierarchyEntry *entry);
/**
* Check whether class is derived from baseclass.
*/
......
......@@ -441,11 +441,14 @@ static int isClassWrapped(const char *classname)
entry = vtkParseHierarchy_FindEntry(hierarchyInfo, classname);
if (entry == 0 ||
vtkParseHierarchy_GetProperty(entry, "WRAP_EXCLUDE_PYTHON") ||
vtkParseHierarchy_GetProperty(entry, "WRAPEXCLUDE") ||
!vtkParseHierarchy_IsTypeOf(hierarchyInfo, entry, "vtkObjectBase"))
{
return 0;
}
/* Only the primary class in the header is wrapped in Java */
return vtkParseHierarchy_IsPrimary(entry);
}
return 1;
......@@ -475,6 +478,7 @@ int checkFunctionSignature(ClassInfo *data)
/* some functions will not get wrapped no matter what else */
if (currentFunction->IsOperator ||
currentFunction->ArrayFailure ||
currentFunction->IsExcluded ||
!currentFunction->IsPublic ||
!currentFunction->Name)
{
......@@ -714,7 +718,9 @@ void outputFunction(FILE *fp, ClassInfo *data)
numberOfWrappedFunctions++;
}
if (currentFunction->IsPublic && args_ok &&
if (!currentFunction->IsExcluded &&
currentFunction->IsPublic &&
args_ok &&
strcmp(data->Name,currentFunction->Name) &&
strcmp(data->Name, currentFunction->Name + 1))
{
......@@ -845,7 +851,8 @@ int main(int argc, char *argv[])
}
/* get the main class */
if ((data = file_info->MainClass) == NULL)
data = file_info->MainClass;
if (data == NULL || data->IsExcluded)
{
fclose(fp);
exit(0);
......
......@@ -278,11 +278,14 @@ static int isClassWrapped(const char *classname)
entry = vtkParseHierarchy_FindEntry(hierarchyInfo, classname);
if (entry == 0 ||
vtkParseHierarchy_GetProperty(entry, "WRAP_EXCLUDE_PYTHON") ||
vtkParseHierarchy_GetProperty(entry, "WRAPEXCLUDE") ||
!vtkParseHierarchy_IsTypeOf(hierarchyInfo, entry, "vtkObjectBase"))
{
return 0;
}
/* Only the primary class in the header is wrapped in Java */
return vtkParseHierarchy_IsPrimary(entry);
}
return 1;
......@@ -312,6 +315,7 @@ int checkFunctionSignature(ClassInfo *data)
/* some functions will not get wrapped no matter what else */
if (currentFunction->IsOperator ||
currentFunction->ArrayFailure ||
currentFunction->IsExcluded ||
!currentFunction->IsPublic ||
!currentFunction->Name)
{
......@@ -507,7 +511,9 @@ void outputFunction(FILE *fp, ClassInfo *data)
args_ok = checkFunctionSignature(data);
if (currentFunction->IsPublic && args_ok &&
if (!currentFunction->IsExcluded &&
currentFunction->IsPublic &&
args_ok &&
strcmp(data->Name,currentFunction->Name) &&
strcmp(data->Name, currentFunction->Name + 1))
{
......@@ -660,7 +666,9 @@ void vtkParseOutput(FILE *fp, FileInfo *file_info)
ClassInfo *data;
int i;
if ((data = file_info->MainClass) == NULL)
/* get the main class */
data = file_info->MainClass;
if (data == NULL || data->IsExcluded)
{
return;
}
......@@ -703,7 +711,10 @@ if (strcmp("vtkObject",data->Name))
for (i = 0; i < data->NumberOfFunctions; i++)
{
currentFunction = data->Functions[i];
outputFunction(fp, data);
if (!currentFunction->IsExcluded)
{
outputFunction(fp, data);
}
}
if (!data->NumberOfSuperClasses)
......
......@@ -76,9 +76,10 @@
/**
* Attributes (used for hints)
*/
#define VTK_PARSE_ATTRIBUTES 0x03000000
#define VTK_PARSE_ATTRIBUTES 0x07000000
#define VTK_PARSE_NEWINSTANCE 0x01000000
#define VTK_PARSE_ZEROCOPY 0x02000000
#define VTK_PARSE_WRAPEXCLUDE 0x04000000
/**
* Special
......
......@@ -376,7 +376,7 @@ static char **append_class_contents(
line = append_scope_to_line(line, &m, &maxlen, scope);
line = append_class_to_line(line, &m, &maxlen, class_info);
tmpflags = "WRAP_EXCLUDE_PYTHON";
tmpflags = "WRAPEXCLUDE";
}
else if (data->Items[i].Type == VTK_ENUM_INFO)
{
......@@ -429,9 +429,8 @@ static char **append_class_contents(
* Append all types in a namespace
*/
static char **append_namespace_contents(
char **lines, size_t *np, NamespaceInfo *data, ClassInfo *main_class,
const char *scope, const char *header_file, const char *module_name,
const char *flags)
char **lines, size_t *np, NamespaceInfo *data, const char *scope,
const char *header_file, const char *module_name, const char *flags)
{
int i;
const char *tmpflags;
......@@ -473,21 +472,17 @@ static char **append_namespace_contents(
/* add a line for each type that is found */
for (i = 0; i < data->NumberOfItems; i++)
{
tmpflags = 0;
tmpflags = flags;
m = 0;
line[m] = '\0';
if (data->Items[i].Type == VTK_CLASS_INFO ||
data->Items[i].Type == VTK_STRUCT_INFO)
{
ClassInfo *class_info =
data->Classes[data->Items[i].Index];
/* all but the main class in each file is excluded from wrapping */
tmpflags = "WRAP_EXCLUDE_PYTHON";
if (class_info == main_class)
ClassInfo *class_info = data->Classes[data->Items[i].Index];
if (class_info->IsExcluded)
{
tmpflags = flags;
tmpflags = "WRAPEXCLUDE";
}
line = append_scope_to_line(line, &m, &maxlen, scope);
......@@ -495,9 +490,14 @@ static char **append_namespace_contents(
}
else if (data->Items[i].Type == VTK_ENUM_INFO)
{
EnumInfo *enum_info = data->Enums[data->Items[i].Index];
if (enum_info->IsExcluded)
{
tmpflags = "WRAPEXCLUDE";
}
line = append_scope_to_line(line, &m, &maxlen, scope);
line = append_enum_to_line(line, &m, &maxlen,
data->Enums[data->Items[i].Index]);
line = append_enum_to_line(line, &m, &maxlen, enum_info);
}
else if (data->Items[i].Type == VTK_TYPEDEF_INFO)
{
......@@ -536,8 +536,8 @@ static char **append_namespace_contents(
data->Namespaces[data->Items[i].Index]->Name)
{
lines = append_namespace_contents(lines, np,
data->Namespaces[data->Items[i].Index], 0,
scope, header_file, module_name, "WRAP_EXCLUDE_PYTHON");
data->Namespaces[data->Items[i].Index],
scope, header_file, module_name, "WRAPEXCLUDE");
}
}
......@@ -597,7 +597,7 @@ static char **vtkWrapHierarchy_ParseHeaderFile(
/* append the file contents to the output */
lines = append_namespace_contents(
lines, &n, data->Contents, data->MainClass, 0,
lines, &n, data->Contents, 0,
header_file, module_name, flags);
vtkParse_Free(data);
......
......@@ -799,6 +799,7 @@ int checkFunctionSignature(ClassInfo *data)
/* some functions will not get wrapped no matter what else */
if (currentFunction->IsOperator ||
currentFunction->ArrayFailure ||
currentFunction->IsExcluded ||
!currentFunction->IsPublic ||
!currentFunction->Name)
{
......@@ -1053,7 +1054,9 @@ void outputFunction(FILE *fp, ClassInfo *data)
numberOfWrappedFunctions++;
}
if (currentFunction->IsPublic && args_ok &&
if (!currentFunction->IsExcluded &&
currentFunction->IsPublic &&
args_ok &&
strcmp(data->Name,currentFunction->Name) &&
strcmp(data->Name, currentFunction->Name + 1))
{
......@@ -1252,7 +1255,8 @@ int main(int argc, char *argv[])
}
/* get the main class */
if ((data = file_info->MainClass) == NULL)
data = file_info->MainClass;
if (data == NULL || data->IsExcluded)
{
fclose(fp);
exit(0);
......
......@@ -185,6 +185,7 @@ static void vtkWrapPython_GenerateSpecialHeaders(
{
currentFunction = data->Functions[i];
if (currentFunction->Access == VTK_ACCESS_PUBLIC &&
!currentFunction->IsExcluded &&
strcmp(currentFunction->Class, data->Name) == 0)
{
classname = "void";
......@@ -505,6 +506,11 @@ int main(int argc, char *argv[])
for (i = 0; i < contents->NumberOfClasses; i++)
{
data = contents->Classes[i];
if (data->IsExcluded)
{
continue;
}
is_vtkobject = wrapAsVTKObject[i];
/* if "hinfo" is present, wrap everything, else just the main class */
......
......@@ -649,6 +649,7 @@ int vtkWrapPython_WrapOneClass(
FunctionInfo *func = data->Functions[i];
if (func->Name &&
!func->IsExcluded &&
func->Access == VTK_ACCESS_PUBLIC &&
strcmp("New", func->Name) == 0 &&
func->NumberOfParameters == 0 &&
......@@ -661,7 +662,8 @@ int vtkWrapPython_WrapOneClass(
/* create any enum types defined in the class */
for (i = 0; i < data->NumberOfEnums; i++)
{
if (data->Enums[i]->Access == VTK_ACCESS_PUBLIC)
if (!data->Enums[i]->IsExcluded &&
data->Enums[i]->Access == VTK_ACCESS_PUBLIC)
{
vtkWrapPython_GenerateEnumType(
fp, module, classname, data->Enums[i]);
......
......@@ -61,7 +61,8 @@ void vtkWrapPython_MarkAllEnums(
for (i = 0; i < n; i++)
{
currentFunction = data->Functions[i];
if (currentFunction->Access == VTK_ACCESS_PUBLIC)
if (!currentFunction->IsExcluded &&
currentFunction->Access == VTK_ACCESS_PUBLIC)
{
/* we start with the return value */
val = currentFunction->ReturnValue;
......@@ -239,7 +240,8 @@ void vtkWrapPython_AddPublicEnumTypes(
for (i = 0; i < data->NumberOfEnums; i++)
{
if (data->Enums[i]->Access == VTK_ACCESS_PUBLIC)
if (!data->Enums[i]->IsExcluded &&
data->Enums[i]->Access == VTK_ACCESS_PUBLIC)
{
vtkWrapPython_AddEnumType(
fp, indent, dictvar, objvar, pythonname, data->Enums[i]);
......
......@@ -588,7 +588,8 @@ int vtkWrapPython_MethodCheck(
int i, n;
/* some functions will not get wrapped no matter what */
if (currentFunction->Access != VTK_ACCESS_PUBLIC ||
if (currentFunction->IsExcluded ||
currentFunction->Access != VTK_ACCESS_PUBLIC ||
vtkWrap_IsInheritedMethod(data, currentFunction))
{
return 0;
......
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