File: vtkCreateArrayDispatchImplicitList.cmake

package info (click to toggle)
paraview 5.11.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 497,236 kB
  • sloc: cpp: 3,171,290; ansic: 1,315,072; python: 134,290; xml: 103,324; sql: 65,887; sh: 5,286; javascript: 4,901; yacc: 4,383; java: 3,977; perl: 2,363; lex: 1,909; f90: 1,255; objc: 143; makefile: 119; tcl: 59; pascal: 50; fortran: 29
file content (215 lines) | stat: -rw-r--r-- 6,867 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# This file contains macros that are used by VTK to generate the list of
# implicit arrays used by the vtkArrayDispatch system.
#
# There are a number of CMake variables that control the final array list. At
# the high level, the following options enable/disable predefined categories of
# arrays:
#
# - VTK_DISPATCH_AFFINE_ARRAYS (default: OFF)
#   Include vtkAffineArray<ValueType> for the basic types supported
#   by VTK.
# - VTK_DISPATCH_CONSTANT_ARRAYS (default: OFF)
#   Include vtkConstantArray<ValueType> for the basic types supported
#   by VTK.
# - VTK_DISPATCH_STD_FUNCTION_ARRAYS (default: OFF)
#   Include vtkStdFunctionArray<ValueType> for the basic types supported
#   by VTK.
#
# At a lower level, specific arrays can be added to the list individually in
# two ways:
#
# For templated classes, set the following variables:
# - vtkArrayDispatchImplicit_containers:
#   List of template class names.
# - vtkArrayDispatchImplicit_[template class name]_types:
#   For the specified template class, add an entry to the array list that
#   instantiates the container for each type listed here.
# - vtkArrayDispatchImplicit_[template class name]_header
#   Specifies the header file to include for the specified template class.
#
# Both templated and non-templated arrays can be added using these variables:
# - vtkArrayDispatchImplicit_extra_arrays:
#   List of arrays to add to the list.
# - vtkArrayDispatchImplicit_extra_headers:
#   List of headers to include.
#
################################ Example #######################################
#
# The cmake call below instantiates the array list that follows:
#
# cmake [path to VTK source]
#   -DvtkArrayDispatchImplicit_containers="MyCustomArray1;MyCustomArray2"
#   -DvtkArrayDispatchImplicit_MyCustomArray1_header="MyCustomArray1.h"
#   -DvtkArrayDispatchImplicit_MyCustomArray1_types="float;double"
#   -DvtkArrayDispatchImplicit_MyCustomArray2_header="MyCustomArray2.h"
#   -DvtkArrayDispatchImplicit_MyCustomArray2_types="int;unsigned char"
#   -DvtkArrayDispatchImplicit_extra_headers="ExtraHeader1.h;ExtraHeader2.h"
#   -DvtkArrayDispatchImplicit_extra_arrays="ExtraArray1;ExtraArray2<float>;ExtraArray2<char>"
#
# Generated header:
#
# #ifndef vtkArrayDispatchImplicitArrayList_h
# #define vtkArrayDispatchImplicitArrayList_h
#
# #include "vtkTypeList.h"
# #include "MyCustomArray1.h"
# #include "MyCustomArray2.h"
# #include "ExtraHeader1.h"
# #include "ExtraHeader2.h"
# #include "vtkArrayDispatchArrayList.h"
#
# namespace vtkArrayDispatch {
#
# VTK_ABI_NAMESPACE_BEGIN
#
# typedef vtkTypeList::Unique<
#   vtkTypeListvtkTypeList::Create<
#     MyCustomArray1<float>,
#     MyCustomArray1<double>,
#     MyCustomArray2<int>,
#     MyCustomArray2<unsigned char>,
#     ExtraArray1,
#     ExtraArray2<float>,
#     ExtraArray2<char>
#   >
# >::Result ReadOnlyArrays;
# 
# typedef vtkTypeList::Unique< vtkTypeList::TypeList<Arrays, ReadOnlyArrays> >::Result AllArrays;
#
# VTK_ABI_NAMESPACE_END
#
# } // end namespace vtkArrayDispatch
#
# #endif // vtkArrayDispatchImplicitArrayList_h
#

# Populate the environment so that vtk_array_dispatch_generate_array_header will
# create the array TypeList with all known array types.
macro(vtkArrayDispatchImplicit_default_array_setup)

# The default set of scalar types:
set(vtkArrayDispatchImplicit_all_types
  "char"
  "double"
  "float"
  "int"
  "long"
  "long long"
  "short"
  "signed char"
  "unsigned char"
  "unsigned int"
  "unsigned long"
  "unsigned long long"
  "unsigned short"
  "vtkIdType"
)

if (VTK_DISPATCH_STD_FUNCTION_ARRAYS)
  list(APPEND vtkArrayDispatchImplicit_containers vtkStdFunctionArray)
  set(vtkArrayDispatchImplicit_vtkStdFunctionArray_header vtkStdFunctionArray.h)
  set(vtkArrayDispatchImplicit_vtkStdFunctionArray_types
    ${vtkArrayDispatchImplicit_all_types}
  )
endif()

if (VTK_DISPATCH_CONSTANT_ARRAYS)
  list(APPEND vtkArrayDispatchImplicit_containers vtkConstantArray)
  set(vtkArrayDispatchImplicit_vtkConstantArray_header vtkConstantArray.h)
  set(vtkArrayDispatchImplicit_vtkConstantArray_types
    ${vtkArrayDispatchImplicit_all_types}
  )
endif()

if (VTK_DISPATCH_AFFINE_ARRAYS)
  list(APPEND vtkArrayDispatchImplicit_containers vtkAffineArray)
  set(vtkArrayDispatchImplicit_vtkAffineArray_header vtkAffineArray.h)
  set(vtkArrayDispatchImplicit_vtkAffineArray_types
    ${vtkArrayDispatchImplicit_all_types}
  )
endif()

if (VTK_DISPATCH_COMPOSITE_ARRAYS)
  list(APPEND vtkArrayDispatchImplicit_containers vtkCompositeArray)
  set(vtkArrayDispatchImplicit_vtkCompositeArray_header vtkCompositeArray.h)
  set(vtkArrayDispatchImplicit_vtkCompositeArray_types
    ${vtkArrayDispatchImplicit_all_types}
  )
endif()

if (VTK_DISPATCH_INDEXED_ARRAYS)
  list(APPEND vtkArrayDispatchImplicit_containers vtkIndexedArray)
  set(vtkArrayDispatchImplicit_vtkIndexedArray_header vtkIndexedArray.h)
  set(vtkArrayDispatchImplicit_vtkIndexedArray_types
    ${vtkArrayDispatchImplicit_all_types}
  )
endif()

endmacro()

# Create a header that declares the vtkArrayDispatch::Arrays TypeList.
macro(vtkArrayDispatchImplicit_generate_array_header result)

set(vtkAD_headers vtkTypeList.h)
list(APPEND vtkAD_headers vtkArrayDispatchArrayList.h)
set(vtkAD_arrays)
foreach(container ${vtkArrayDispatchImplicit_containers})
  list(APPEND vtkAD_headers ${vtkArrayDispatchImplicit_${container}_header})
  foreach(value_type ${vtkArrayDispatchImplicit_${container}_types})
    list(APPEND vtkAD_arrays "${container}<${value_type}>")
  endforeach()
endforeach()

# Include externally specified headers/arrays:
list(APPEND vtkAD_headers ${vtkArrayDispatchImplicit_extra_headers})
list(APPEND vtkAD_arrays ${vtkArrayDispatchImplicit_extra_arrays})

set(temp
  "// This file is autogenerated by vtkCreateArrayDispatchImplicitArrayList.cmake.\n"
  "// Do not edit this file. Your changes will not be saved.\n"
  "// Funded by CEA, DAM, DIF, F-91297 Arpajon, France\n"
  "\n"
  "#ifndef vtkArrayDispatchImplicitArrayList_h\n"
  "#define vtkArrayDispatchImplicitArrayList_h\n"
  "\n"
)

foreach(header ${vtkAD_headers})
  list(APPEND temp "#include \"${header}\"\n")
endforeach()

list(APPEND temp
  "\n"
  "namespace vtkArrayDispatch {\n"
  "VTK_ABI_NAMESPACE_BEGIN\n"
  "\n"
  "typedef vtkTypeList::Unique<\n"
  "  vtkTypeList::Create<\n"
)

foreach(array ${vtkAD_arrays})
  list(APPEND temp "    ${array},\n")
endforeach()

# Remove the final comma from the array list:
string(CONCAT temp ${temp})
string(REGEX REPLACE ",\n$" "\n" temp "${temp}")

list(APPEND temp
  "  >\n"
  ">::Result ReadOnlyArrays\;\n"
  "\n"
  "typedef vtkTypeList::Unique<\n"
  "vtkTypeList::Append<Arrays,\n"
  "ReadOnlyArrays>::Result\n"
  ">::Result AllArrays\;\n"
  "\n"
  "VTK_ABI_NAMESPACE_END\n"
  "\n"
  "} // end namespace vtkArrayDispatch\n"
  "#endif // vtkArrayDispatchImplicitArrayList_h\n"
)

string(CONCAT ${result} ${temp})

endmacro()