Skip to content

Commit 06e98d0

Browse files
author
David C. Lonie
committed
Replace vtkDataArrayTemplate with vtkAoSDataArrayTemplate.
1 parent d76ab44 commit 06e98d0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+166
-1932
lines changed

Common/Core/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,6 @@ SET(Module_SRCS
222222
vtkWeakPointerBase.cxx
223223
vtkWindow.cxx
224224
vtkXMLFileOutputWindow.cxx
225-
vtkDataArrayTemplate.txx
226-
vtkDataArrayTemplateHelper.cxx
227225
vtkDenseArray.txx
228226
vtkSparseArray.txx
229227
vtkTypedArray.txx
@@ -254,7 +252,6 @@ set(${vtk-module}_HDRS
254252
vtkAtomicTypes.h
255253
vtkAutoInit.h
256254
vtkDataArrayIteratorMacro.h
257-
vtkDataArrayTemplateImplicit.txx
258255
vtkGenericDataArray.h
259256
vtkGenericDataArrayLookupHelper.h
260257
vtkGenericDataArrayMacros.h
@@ -583,7 +580,6 @@ set_source_files_properties(
583580
vtkAutoInit.h
584581
vtkDataArrayTemplateHelper.cxx
585582
vtkDataArrayTemplateImplicit.txx
586-
vtkDataArrayTemplate.txx
587583
vtkDenseArray.txx
588584
vtkGenericDataArrayHelpers.h
589585
vtkIOStream.h

Common/Core/vtkAoSDataArrayTemplate.h

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,78 @@ class vtkAoSDataArrayTemplate :
171171
};
172172

173173
#include "vtkAoSDataArrayTemplate.txx"
174+
175+
// Ported over from vtkDataArrayTemplate:
176+
177+
#if !defined(VTK_NO_EXPLICIT_TEMPLATE_INSTANTIATION)
178+
# define VTK_AOS_DATA_ARRAY_TEMPLATE_INSTANTIATE(T) \
179+
template class VTKCOMMONCORE_EXPORT vtkAoSDataArrayTemplate< T >
180+
#else
181+
// TODO Not sure what this does, need to dig some:
182+
//# include "vtkDataArrayTemplateImplicit.txx"
183+
//# define VTK_DATA_ARRAY_TEMPLATE_INSTANTIATE(T)
174184
#endif
185+
186+
#endif // header guard
187+
188+
// TODO clean this up, more or less copy/pasted from vtkDataArrayTemplate.h:
189+
190+
// This portion must be OUTSIDE the include blockers. Each
191+
// vtkDataArray subclass uses this to give its instantiation of this
192+
// template a DLL interface.
193+
#if defined(VTK_DATA_ARRAY_TEMPLATE_TYPE) && !defined(VTK_NO_EXPLICIT_TEMPLATE_INSTANTIATION)
194+
# if defined(VTK_BUILD_SHARED_LIBS) && defined(_MSC_VER)
195+
# pragma warning (push)
196+
# pragma warning (disable: 4091) // warning C4091: 'extern ' :
197+
// ignored on left of 'int' when no variable is declared
198+
# pragma warning (disable: 4231) // Compiler-specific extension warning.
199+
200+
// We need to disable warning 4910 and do an extern dllexport
201+
// anyway. When deriving vtkCharArray and other types from an
202+
// instantiation of this template the compiler does an explicit
203+
// instantiation of the base class. From outside the vtkCommon
204+
// library we block this using an extern dllimport instantiation.
205+
// For classes inside vtkCommon we should be able to just do an
206+
// extern instantiation, but VS 2008 complains about missing
207+
// definitions. We cannot do an extern dllimport inside vtkCommon
208+
// since the symbols are local to the dll. An extern dllexport
209+
// seems to be the only way to convince VS 2008 to do the right
210+
// thing, so we just disable the warning.
211+
# pragma warning (disable: 4910) // extern and dllexport incompatible
212+
213+
// Use an "extern explicit instantiation" to give the class a DLL
214+
// interface. This is a compiler-specific extension.
215+
extern VTK_AOS_DATA_ARRAY_TEMPLATE_INSTANTIATE(VTK_DATA_ARRAY_TEMPLATE_TYPE);
216+
# pragma warning (pop)
217+
# endif
218+
# undef VTK_DATA_ARRAY_TEMPLATE_TYPE
219+
#endif
220+
221+
// This macro is used by the subclasses to create dummy
222+
// declarations for these functions such that the wrapper
223+
// can see them. The wrappers ignore vtkDataArrayTemplate.
224+
#define vtkCreateWrappedArrayInterface(T) \
225+
int GetDataType(); \
226+
void GetTupleValue(vtkIdType i, T* tuple); \
227+
void SetTupleValue(vtkIdType i, const T* tuple); \
228+
void InsertTupleValue(vtkIdType i, const T* tuple); \
229+
vtkIdType InsertNextTupleValue(const T* tuple); \
230+
T GetValue(vtkIdType id); \
231+
void SetValue(vtkIdType id, T value); \
232+
void SetNumberOfValues(vtkIdType number); \
233+
void InsertValue(vtkIdType id, T f); \
234+
vtkIdType InsertNextValue(T f); \
235+
T *GetValueRange(int comp); \
236+
T *GetValueRange(); \
237+
T* WritePointer(vtkIdType id, vtkIdType number); \
238+
T* GetPointer(vtkIdType id)/*; \
239+
240+
* These methods are not wrapped to avoid wrappers exposing these
241+
* easy-to-get-wrong methods because passing in the wrong value for 'save' is
242+
* guaranteed to cause a memory issue down the line. Either the wrappers
243+
* didn't use malloc to allocate the memory or the memory isn't actually
244+
* persisted because a temporary array is used that doesn't persist like this
245+
* method expects.
246+
247+
void SetArray(T* array, vtkIdType size, int save); \
248+
void SetArray(T* array, vtkIdType size, int save, int deleteMethod) */

Common/Core/vtkCharArray.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
1414
=========================================================================*/
1515
// Instantiate superclass first to give the template a DLL interface.
16-
#include "vtkDataArrayTemplate.txx"
17-
VTK_DATA_ARRAY_TEMPLATE_INSTANTIATE(char);
16+
#include "vtkAoSDataArrayTemplate.h"
17+
VTK_AOS_DATA_ARRAY_TEMPLATE_INSTANTIATE(char);
1818

1919
#include "vtkArrayIteratorTemplate.txx"
2020
VTK_ARRAY_ITERATOR_TEMPLATE_INSTANTIATE(char);

Common/Core/vtkCharArray.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@
2828

2929
#include "vtkCommonCoreModule.h" // For export macro
3030
#include "vtkDataArray.h"
31-
#include "vtkDataArrayTemplate.h" // Real Superclass
31+
#include "vtkAoSDataArrayTemplate.h" // Real Superclass
3232

3333
// Fake the superclass for the wrappers.
3434
#ifndef __WRAP__
35-
#define vtkDataArray vtkDataArrayTemplate<char>
35+
#define vtkDataArray vtkAoSDataArrayTemplate<char>
3636
#endif
3737
class VTKCOMMONCORE_EXPORT vtkCharArray : public vtkDataArray
3838
{
@@ -65,7 +65,7 @@ class VTKCOMMONCORE_EXPORT vtkCharArray : public vtkDataArray
6565

6666
private:
6767
//BTX
68-
typedef vtkDataArrayTemplate<char> RealSuperclass;
68+
typedef vtkAoSDataArrayTemplate<char> RealSuperclass;
6969
//ETX
7070
vtkCharArray(const vtkCharArray&); // Not implemented.
7171
void operator=(const vtkCharArray&); // Not implemented.

0 commit comments

Comments
 (0)