# HG changeset patch # User Markus Mützel # Date 1667672113 -3600 # Sat Nov 05 19:15:13 2022 +0100 # Node ID 3f487a2612f26c1571c83a55b4eb53c1d86d376b # Parent 4f86d56c090d26efdb8759b9b5aa58213106a263 Template visibility diff -r 4f86d56c090d -r 3f487a2612f2 libinterp/template-inst/Array-tc.cc --- a/libinterp/template-inst/Array-tc.cc Sat Nov 05 18:35:09 2022 -0400 +++ b/libinterp/template-inst/Array-tc.cc Sat Nov 05 19:15:13 2022 +0100 @@ -29,7 +29,6 @@ # include "config.h" #endif -#include "Array.h" #include "Array-oct.cc" #include "ov.h" @@ -45,13 +44,13 @@ #endif NO_INSTANTIATE_ARRAY_SORT_API (octave_value, OCTINTERP_API); -INSTANTIATE_ARRAY (octave_value, OCTINTERP_API); +INSTANTIATE_ARRAY (octave_value, OCTINTERP_CLASS_TEMPLATE_INSTANTIATION_API); NO_INSTANTIATE_ARRAY_SORT_API (octave_value *, OCTINTERP_API); -INSTANTIATE_ARRAY (octave_value *, OCTINTERP_API); +INSTANTIATE_ARRAY (octave_value *, OCTINTERP_CLASS_TEMPLATE_INSTANTIATION_API); NO_INSTANTIATE_ARRAY_SORT_API (octave::cdef_object, OCTINTERP_API); -INSTANTIATE_ARRAY (octave::cdef_object, OCTINTERP_API); +INSTANTIATE_ARRAY (octave::cdef_object, OCTINTERP_CLASS_TEMPLATE_INSTANTIATION_API); #if defined (HAVE_PRAGMA_GCC_VISIBILITY) # pragma GCC visibility pop diff -r 4f86d56c090d -r 3f487a2612f2 libinterp/template-inst/Array.cc --- a/libinterp/template-inst/Array.cc Sat Nov 05 18:35:09 2022 -0400 +++ b/libinterp/template-inst/Array.cc Sat Nov 05 19:15:13 2022 +0100 @@ -33,6 +33,6 @@ // being implicitly instantiated in compilation units including this file. // instantiated in Array-tc.cc -extern template class Array; -extern template class Array; -extern template class Array; +extern template class OCTINTERP_EXTERN_TEMPLATE_API Array; +extern template class OCTINTERP_EXTERN_TEMPLATE_API Array; +extern template class OCTINTERP_EXTERN_TEMPLATE_API Array; diff -r 4f86d56c090d -r 3f487a2612f2 liboctave/array/Array-C.cc --- a/liboctave/array/Array-C.cc Sat Nov 05 18:35:09 2022 -0400 +++ b/liboctave/array/Array-C.cc Sat Nov 05 19:15:13 2022 +0100 @@ -33,15 +33,16 @@ #include "lo-mappers.h" #include "Array.h" -#include "Array-base.cc" -#include "oct-sort.cc" // Prevent implicit instantiations on some systems (Windows, others?) // that can lead to duplicate definitions of static data members. -extern template class Array; +extern template class OCTAVE_EXTERN_TEMPLATE_API Array; extern template class Array; +#include "Array-base.cc" +#include "oct-sort.cc" + template <> inline bool sort_isnan (const Complex& x) @@ -94,7 +95,7 @@ template class octave_sort; -INSTANTIATE_ARRAY (Complex, OCTAVE_API); +INSTANTIATE_ARRAY (Complex, OCTAVE_CLASS_TEMPLATE_INSTANTIATION_API); template OCTAVE_API std::ostream& operator << (std::ostream&, const Array&); diff -r 4f86d56c090d -r 3f487a2612f2 liboctave/array/Array-b.cc --- a/liboctave/array/Array-b.cc Sat Nov 05 18:35:09 2022 -0400 +++ b/liboctave/array/Array-b.cc Sat Nov 05 19:15:13 2022 +0100 @@ -30,18 +30,19 @@ // Instantiate Arrays of bool values. #include "Array.h" + +// Prevent implicit instantiations on some systems (Windows, others?) +// that can lead to duplicate definitions of static data members. + +extern template class OCTAVE_EXTERN_TEMPLATE_API Array; +extern template class Array; + #include "Array-base.cc" #define INLINE_ASCENDING_SORT 1 #define INLINE_DESCENDING_SORT 1 #include "oct-sort.cc" -// Prevent implicit instantiations on some systems (Windows, others?) -// that can lead to duplicate definitions of static data members. - -extern template class Array; -extern template class Array; - // Specialize bool sorting (aka stable partitioning). template @@ -120,7 +121,7 @@ template class octave_sort; -INSTANTIATE_ARRAY (bool, OCTAVE_API); +INSTANTIATE_ARRAY (bool, OCTAVE_CLASS_TEMPLATE_INSTANTIATION_API); template OCTAVE_API std::ostream& operator << (std::ostream&, const Array&); diff -r 4f86d56c090d -r 3f487a2612f2 liboctave/array/Array-base.cc --- a/liboctave/array/Array-base.cc Sat Nov 05 18:35:09 2022 -0400 +++ b/liboctave/array/Array-base.cc Sat Nov 05 19:15:13 2022 +0100 @@ -2792,19 +2792,11 @@ T::__xXxXx__ (); } -#if defined (__clang__) -# define INSTANTIATE_ARRAY(T, API) \ +#define INSTANTIATE_ARRAY(T, API) \ template <> API void \ Array::instantiation_guard () { } \ \ template class API Array -#else -# define INSTANTIATE_ARRAY(T, API) \ - template <> API void \ - Array::instantiation_guard () { } \ - \ - template class Array -#endif // FIXME: is this used? diff -r 4f86d56c090d -r 3f487a2612f2 liboctave/array/Array-ch.cc --- a/liboctave/array/Array-ch.cc Sat Nov 05 18:35:09 2022 -0400 +++ b/liboctave/array/Array-ch.cc Sat Nov 05 19:15:13 2022 +0100 @@ -30,21 +30,22 @@ // Instantiate Arrays of char values. #include "Array.h" + +// Prevent implicit instantiations on some systems (Windows, others?) +// that can lead to duplicate definitions of static data members. + +extern template class OCTAVE_EXTERN_TEMPLATE_API Array; +extern template class Array; + #include "Array-base.cc" #define INLINE_ASCENDING_SORT 1 #define INLINE_DESCENDING_SORT 1 #include "oct-sort.cc" -// Prevent implicit instantiations on some systems (Windows, others?) -// that can lead to duplicate definitions of static data members. - -extern template class Array; -extern template class Array; - template class octave_sort; -INSTANTIATE_ARRAY (char, OCTAVE_API); +INSTANTIATE_ARRAY (char, OCTAVE_CLASS_TEMPLATE_INSTANTIATION_API); template OCTAVE_API std::ostream& operator << (std::ostream&, const Array&); diff -r 4f86d56c090d -r 3f487a2612f2 liboctave/array/Array-d.cc --- a/liboctave/array/Array-d.cc Sat Nov 05 18:35:09 2022 -0400 +++ b/liboctave/array/Array-d.cc Sat Nov 05 19:15:13 2022 +0100 @@ -31,6 +31,13 @@ #include "lo-mappers.h" #include "Array.h" + +// Prevent implicit instantiations on some systems (Windows, others?) +// that can lead to duplicate definitions of static data members. + +extern template class OCTAVE_EXTERN_TEMPLATE_API Array; +extern template class Array; + #include "Array-base.cc" #include "oct-locbuf.h" @@ -38,12 +45,6 @@ #define INLINE_DESCENDING_SORT 1 #include "oct-sort.cc" -// Prevent implicit instantiations on some systems (Windows, others?) -// that can lead to duplicate definitions of static data members. - -extern template class Array; -extern template class Array; - template <> inline bool sort_isnan (double x) @@ -165,7 +166,7 @@ template class octave_sort; -INSTANTIATE_ARRAY (double, OCTAVE_API); +INSTANTIATE_ARRAY (double, OCTAVE_CLASS_TEMPLATE_INSTANTIATION_API); template OCTAVE_API std::ostream& operator << (std::ostream&, const Array&); diff -r 4f86d56c090d -r 3f487a2612f2 liboctave/array/Array-f.cc --- a/liboctave/array/Array-f.cc Sat Nov 05 18:35:09 2022 -0400 +++ b/liboctave/array/Array-f.cc Sat Nov 05 19:15:13 2022 +0100 @@ -31,6 +31,13 @@ #include "lo-mappers.h" #include "Array.h" + +// Prevent implicit instantiations on some systems (Windows, others?) +// that can lead to duplicate definitions of static data members. + +extern template class OCTAVE_EXTERN_TEMPLATE_API Array; +extern template class Array; + #include "Array-base.cc" #include "oct-locbuf.h" @@ -38,12 +45,6 @@ #define INLINE_DESCENDING_SORT 1 #include "oct-sort.cc" -// Prevent implicit instantiations on some systems (Windows, others?) -// that can lead to duplicate definitions of static data members. - -extern template class Array; -extern template class Array; - template <> inline bool sort_isnan (float x) @@ -165,7 +166,7 @@ template class octave_sort; -INSTANTIATE_ARRAY (float, OCTAVE_API); +INSTANTIATE_ARRAY (float, OCTAVE_CLASS_TEMPLATE_INSTANTIATION_API); template OCTAVE_API std::ostream& operator << (std::ostream&, const Array&); diff -r 4f86d56c090d -r 3f487a2612f2 liboctave/array/Array-fC.cc --- a/liboctave/array/Array-fC.cc Sat Nov 05 18:35:09 2022 -0400 +++ b/liboctave/array/Array-fC.cc Sat Nov 05 19:15:13 2022 +0100 @@ -33,15 +33,16 @@ #include "lo-mappers.h" #include "Array.h" -#include "Array-base.cc" -#include "oct-sort.cc" // Prevent implicit instantiations on some systems (Windows, others?) // that can lead to duplicate definitions of static data members. -extern template class Array; +extern template class OCTAVE_EXTERN_TEMPLATE_API Array; extern template class Array; +#include "Array-base.cc" +#include "oct-sort.cc" + template <> inline bool sort_isnan (const FloatComplex& x) @@ -94,7 +95,7 @@ template class octave_sort; -INSTANTIATE_ARRAY (FloatComplex, OCTAVE_API); +INSTANTIATE_ARRAY (FloatComplex, OCTAVE_CLASS_TEMPLATE_INSTANTIATION_API); template OCTAVE_API std::ostream& operator << (std::ostream&, const Array&); diff -r 4f86d56c090d -r 3f487a2612f2 liboctave/array/Array-fwd.h --- a/liboctave/array/Array-fwd.h Sat Nov 05 18:35:09 2022 -0400 +++ b/liboctave/array/Array-fwd.h Sat Nov 05 19:15:13 2022 +0100 @@ -32,13 +32,13 @@ # include template > -class OCTARRAY_API Array; +class OCTAVE_TEMPLATE_API Array; #else # include template > -class OCTARRAY_API Array; +class OCTAVE_TEMPLATE_API Array; #endif diff -r 4f86d56c090d -r 3f487a2612f2 liboctave/array/Array-i.cc --- a/liboctave/array/Array-i.cc Sat Nov 05 18:35:09 2022 -0400 +++ b/liboctave/array/Array-i.cc Sat Nov 05 19:15:13 2022 +0100 @@ -32,17 +32,18 @@ // Instantiate Arrays of integer values. #include "Array.h" + +// Prevent implicit instantiations on some systems (Windows, others?) +// that can lead to duplicate definitions of static data members. + +extern template class OCTAVE_EXTERN_TEMPLATE_API Array; + #include "Array-base.cc" #define INLINE_ASCENDING_SORT 1 #define INLINE_DESCENDING_SORT 1 #include "oct-sort.cc" -// Prevent implicit instantiations on some systems (Windows, others?) -// that can lead to duplicate definitions of static data members. - -extern template class Array; - template class octave_sort; //template class octave_sort; template class octave_sort; @@ -51,12 +52,12 @@ template class octave_sort; #endif -INSTANTIATE_ARRAY (signed char, OCTAVE_API); -//INSTANTIATE_ARRAY (short, OCTAVE_API); -INSTANTIATE_ARRAY (int, OCTAVE_API); -INSTANTIATE_ARRAY (long, OCTAVE_API); +INSTANTIATE_ARRAY (signed char, OCTAVE_CLASS_TEMPLATE_INSTANTIATION_API); +//INSTANTIATE_ARRAY (short, OCTAVE_CLASS_TEMPLATE_INSTANTIATION_API); +INSTANTIATE_ARRAY (int, OCTAVE_CLASS_TEMPLATE_INSTANTIATION_API); +INSTANTIATE_ARRAY (long, OCTAVE_CLASS_TEMPLATE_INSTANTIATION_API); #if defined (OCTAVE_HAVE_LONG_LONG_INT) -INSTANTIATE_ARRAY (long long, OCTAVE_API); +INSTANTIATE_ARRAY (long long, OCTAVE_CLASS_TEMPLATE_INSTANTIATION_API); #endif template class octave_sort; @@ -67,12 +68,12 @@ template class octave_sort; #endif -INSTANTIATE_ARRAY (unsigned char, OCTAVE_API); -INSTANTIATE_ARRAY (unsigned short, OCTAVE_API); -INSTANTIATE_ARRAY (unsigned int, OCTAVE_API); -INSTANTIATE_ARRAY (unsigned long, OCTAVE_API); +INSTANTIATE_ARRAY (unsigned char, OCTAVE_CLASS_TEMPLATE_INSTANTIATION_API); +INSTANTIATE_ARRAY (unsigned short, OCTAVE_CLASS_TEMPLATE_INSTANTIATION_API); +INSTANTIATE_ARRAY (unsigned int, OCTAVE_CLASS_TEMPLATE_INSTANTIATION_API); +INSTANTIATE_ARRAY (unsigned long, OCTAVE_CLASS_TEMPLATE_INSTANTIATION_API); #if defined (OCTAVE_HAVE_UNSIGNED_LONG_LONG_INT) -INSTANTIATE_ARRAY (unsigned long long, OCTAVE_API); +INSTANTIATE_ARRAY (unsigned long long, OCTAVE_CLASS_TEMPLATE_INSTANTIATION_API); #endif template class octave_sort; @@ -80,20 +81,20 @@ template class octave_sort; template class octave_sort; -INSTANTIATE_ARRAY (octave_int8, OCTAVE_API); -INSTANTIATE_ARRAY (octave_int16, OCTAVE_API); -INSTANTIATE_ARRAY (octave_int32, OCTAVE_API); -INSTANTIATE_ARRAY (octave_int64, OCTAVE_API); +INSTANTIATE_ARRAY (octave_int8, OCTAVE_CLASS_TEMPLATE_INSTANTIATION_API); +INSTANTIATE_ARRAY (octave_int16, OCTAVE_CLASS_TEMPLATE_INSTANTIATION_API); +INSTANTIATE_ARRAY (octave_int32, OCTAVE_CLASS_TEMPLATE_INSTANTIATION_API); +INSTANTIATE_ARRAY (octave_int64, OCTAVE_CLASS_TEMPLATE_INSTANTIATION_API); template class octave_sort; template class octave_sort; template class octave_sort; template class octave_sort; -INSTANTIATE_ARRAY (octave_uint8, OCTAVE_API); -INSTANTIATE_ARRAY (octave_uint16, OCTAVE_API); -INSTANTIATE_ARRAY (octave_uint32, OCTAVE_API); -INSTANTIATE_ARRAY (octave_uint64, OCTAVE_API); +INSTANTIATE_ARRAY (octave_uint8, OCTAVE_CLASS_TEMPLATE_INSTANTIATION_API); +INSTANTIATE_ARRAY (octave_uint16, OCTAVE_CLASS_TEMPLATE_INSTANTIATION_API); +INSTANTIATE_ARRAY (octave_uint32, OCTAVE_CLASS_TEMPLATE_INSTANTIATION_API); +INSTANTIATE_ARRAY (octave_uint64, OCTAVE_CLASS_TEMPLATE_INSTANTIATION_API); #include "DiagArray2.h" #include "DiagArray2.cc" diff -r 4f86d56c090d -r 3f487a2612f2 liboctave/array/Array-idx-vec.cc --- a/liboctave/array/Array-idx-vec.cc Sat Nov 05 18:35:09 2022 -0400 +++ b/liboctave/array/Array-idx-vec.cc Sat Nov 05 19:15:13 2022 +0100 @@ -32,13 +32,14 @@ #include "idx-vector.h" #include "Array.h" -#include "Array-base.cc" // Prevent implicit instantiations on some systems (Windows, others?) // that can lead to duplicate definitions of static data members. extern template class Array; +#include "Array-base.cc" + NO_INSTANTIATE_ARRAY_SORT_API (octave::idx_vector, OCTAVE_API); -INSTANTIATE_ARRAY (octave::idx_vector, OCTAVE_API); +INSTANTIATE_ARRAY (octave::idx_vector, OCTAVE_CLASS_TEMPLATE_INSTANTIATION_API); diff -r 4f86d56c090d -r 3f487a2612f2 liboctave/array/Array-oct.cc --- a/liboctave/array/Array-oct.cc Sat Nov 05 18:35:09 2022 -0400 +++ b/liboctave/array/Array-oct.cc Sat Nov 05 19:15:13 2022 +0100 @@ -27,49 +27,57 @@ // Include this file when instantiating the Array class with new types in // projects linking to "liboctave" but not to "liboctinterp". -#include "Array-base.cc" +#include "Array.h" + +// FIXME: Including "Array.h" will have implicitly instantiated +// Array. Could that be an issue? -// "Protect" Array instantiations that are exported by liboctave from being -// implicitly instantiated in compilation units including this file. +// "Protect" Array instantiations that are exported by liboctave from +// being implicitly instantiated in compilation units including this file. + +// Declare extern templates before including "Array-base.cc" to avoid +// implicitly instantiating Array. // instantiated in Array-C.cc -extern template class Array; +extern template class OCTAVE_EXTERN_TEMPLATE_API Array; // instantiated in Array-b.cc -extern template class Array; +extern template class OCTAVE_EXTERN_TEMPLATE_API Array; // instantiated in Array-ch.cc -extern template class Array; +extern template class OCTAVE_EXTERN_TEMPLATE_API Array; // instantiated in Array-d.cc -extern template class Array; +extern template class OCTAVE_EXTERN_TEMPLATE_API Array; // instantiated in Array-f.cc -extern template class Array; +extern template class OCTAVE_EXTERN_TEMPLATE_API Array; // instantiated in Array-fC.cc -extern template class Array; +extern template class OCTAVE_EXTERN_TEMPLATE_API Array; // instantiated in Array-i.cc -extern template class Array; +extern template class OCTAVE_EXTERN_TEMPLATE_API Array; // extern template class Array; -extern template class Array; -extern template class Array; +extern template class OCTAVE_EXTERN_TEMPLATE_API Array; +extern template class OCTAVE_EXTERN_TEMPLATE_API Array; #if defined (OCTAVE_HAVE_LONG_LONG_INT) -extern template class Array; +extern template class OCTAVE_EXTERN_TEMPLATE_API Array; #endif -extern template class Array; -extern template class Array; -extern template class Array; -extern template class Array; +extern template class OCTAVE_EXTERN_TEMPLATE_API Array; +extern template class OCTAVE_EXTERN_TEMPLATE_API Array; +extern template class OCTAVE_EXTERN_TEMPLATE_API Array; +extern template class OCTAVE_EXTERN_TEMPLATE_API Array; #if defined (OCTAVE_HAVE_UNSIGNED_LONG_LONG_INT) -extern template class Array; +extern template class OCTAVE_EXTERN_TEMPLATE_API Array; #endif -extern template class Array; -extern template class Array; -extern template class Array; -extern template class Array; -extern template class Array; -extern template class Array; -extern template class Array; -extern template class Array; +extern template class OCTAVE_EXTERN_TEMPLATE_API Array; +extern template class OCTAVE_EXTERN_TEMPLATE_API Array; +extern template class OCTAVE_EXTERN_TEMPLATE_API Array; +extern template class OCTAVE_EXTERN_TEMPLATE_API Array; +extern template class OCTAVE_EXTERN_TEMPLATE_API Array; +extern template class OCTAVE_EXTERN_TEMPLATE_API Array; +extern template class OCTAVE_EXTERN_TEMPLATE_API Array; +extern template class OCTAVE_EXTERN_TEMPLATE_API Array; // instantiated in Array-idx-vec.cc -extern template class Array; +extern template class OCTAVE_EXTERN_TEMPLATE_API Array; // instantiated in Array-s.cc -extern template class Array; +extern template class OCTAVE_EXTERN_TEMPLATE_API Array; // instantiated in Array-str.cc -extern template class Array; +extern template class OCTAVE_EXTERN_TEMPLATE_API Array; + +#include "Array-base.cc" diff -r 4f86d56c090d -r 3f487a2612f2 liboctave/array/Array-s.cc --- a/liboctave/array/Array-s.cc Sat Nov 05 18:35:09 2022 -0400 +++ b/liboctave/array/Array-s.cc Sat Nov 05 19:15:13 2022 +0100 @@ -30,21 +30,22 @@ // Instantiate Arrays of short int values. #include "Array.h" + +// Prevent implicit instantiations on some systems (Windows, others?) +// that can lead to duplicate definitions of static data members. + +extern template class OCTAVE_EXTERN_TEMPLATE_API Array; +extern template class Array; + #include "Array-base.cc" #define INLINE_ASCENDING_SORT 1 #define INLINE_DESCENDING_SORT 1 #include "oct-sort.cc" -// Prevent implicit instantiations on some systems (Windows, others?) -// that can lead to duplicate definitions of static data members. - -extern template class Array; -extern template class Array; - template class octave_sort; -INSTANTIATE_ARRAY (short, OCTAVE_API); +INSTANTIATE_ARRAY (short, OCTAVE_CLASS_TEMPLATE_INSTANTIATION_API); #include "DiagArray2.h" #include "DiagArray2.cc" diff -r 4f86d56c090d -r 3f487a2612f2 liboctave/array/Array-str.cc --- a/liboctave/array/Array-str.cc Sat Nov 05 18:35:09 2022 -0400 +++ b/liboctave/array/Array-str.cc Sat Nov 05 19:15:13 2022 +0100 @@ -32,16 +32,17 @@ // Instantiate Arrays of strings. #include "Array.h" -#include "Array-base.cc" - -#include "oct-sort.cc" // Prevent implicit instantiations on some systems (Windows, others?) // that can lead to duplicate definitions of static data members. -extern template class Array; +extern template class OCTAVE_EXTERN_TEMPLATE_API Array; extern template class Array; +#include "Array-base.cc" + +#include "oct-sort.cc" + template class octave_sort; -INSTANTIATE_ARRAY (std::string, OCTAVE_API); +INSTANTIATE_ARRAY (std::string, OCTAVE_CLASS_TEMPLATE_INSTANTIATION_API); diff -r 4f86d56c090d -r 3f487a2612f2 liboctave/array/Array-voidp.cc --- a/liboctave/array/Array-voidp.cc Sat Nov 05 18:35:09 2022 -0400 +++ b/liboctave/array/Array-voidp.cc Sat Nov 05 19:15:13 2022 +0100 @@ -32,14 +32,15 @@ // Instantiate Arrays of void *. #include "Array.h" -#include "Array-base.cc" // Prevent implicit instantiations on some systems (Windows, others?) // that can lead to duplicate definitions of static data members. -extern template class Array; +extern template class OCTAVE_EXTERN_TEMPLATE_API Array; extern template class Array; +#include "Array-base.cc" + NO_INSTANTIATE_ARRAY_SORT_API (void *, OCTAVE_API); -INSTANTIATE_ARRAY (void *, OCTAVE_API); +INSTANTIATE_ARRAY (void *, OCTAVE_CLASS_TEMPLATE_INSTANTIATION_API); diff -r 4f86d56c090d -r 3f487a2612f2 liboctave/array/Array.h --- a/liboctave/array/Array.h Sat Nov 05 18:35:09 2022 -0400 +++ b/liboctave/array/Array.h Sat Nov 05 19:15:13 2022 +0100 @@ -125,6 +125,7 @@ template class +OCTARRAY_TEMPLATE_API Array { protected: @@ -212,7 +213,7 @@ public: - void make_unique (void) + OCTARRAY_OVERRIDABLE_FUNC_API void make_unique (void) { if (m_rep->m_count > 1) { @@ -403,11 +404,14 @@ { clear (dim_vector (r, c)); } //! Number of elements in the array. - octave_idx_type numel (void) const { return m_slice_len; } + OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type + numel (void) const + { return m_slice_len; } //@} //! Return the array as a column vector. - Array as_column (void) const + OCTARRAY_OVERRIDABLE_FUNC_API Array + as_column (void) const { Array retval (*this); if (m_dimensions.ndims () != 2 || m_dimensions(1) != 1) @@ -417,7 +421,8 @@ } //! Return the array as a row vector. - Array as_row (void) const + OCTARRAY_OVERRIDABLE_FUNC_API Array + as_row (void) const { Array retval (*this); if (m_dimensions.ndims () != 2 || m_dimensions(0) != 1) @@ -427,7 +432,8 @@ } //! Return the array as a matrix. - Array as_matrix (void) const + OCTARRAY_OVERRIDABLE_FUNC_API Array + as_matrix (void) const { Array retval (*this); if (m_dimensions.ndims () != 2) @@ -440,25 +446,34 @@ //! //! Get the first dimension of the array (number of rows) //@{ - octave_idx_type dim1 (void) const { return m_dimensions(0); } - octave_idx_type rows (void) const { return dim1 (); } + OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type + dim1 (void) const + { return m_dimensions(0); } + OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type + rows (void) const + { return dim1 (); } //@} //! @name Second dimension //! //! Get the second dimension of the array (number of columns) //@{ - octave_idx_type dim2 (void) const { return m_dimensions(1); } - octave_idx_type cols (void) const { return dim2 (); } - octave_idx_type columns (void) const { return dim2 (); } + OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type dim2 (void) const + { return m_dimensions(1); } + OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type cols (void) const + { return dim2 (); } + OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type columns (void) const + { return dim2 (); } //@} //! @name Third dimension //! //! Get the third dimension of the array (number of pages) //@{ - octave_idx_type dim3 (void) const { return m_dimensions(2); } - octave_idx_type pages (void) const { return dim3 (); } + OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type dim3 (void) const + { return m_dimensions(2); } + OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type pages (void) const + { return dim3 (); } //@} //! Size of the specified dimension. @@ -468,51 +483,63 @@ //! //! Equivalent to Octave's 'size (A, DIM)' - size_type size (const size_type d) const + OCTARRAY_OVERRIDABLE_FUNC_API size_type size (const size_type d) const { // Should we throw for negative values? // Should >= ndims () be handled by dim_vector operator() instead ? return d >= ndims () ? 1 : m_dimensions(d); } - std::size_t byte_size (void) const + OCTARRAY_OVERRIDABLE_FUNC_API std::size_t byte_size (void) const { return static_cast (numel ()) * sizeof (T); } //! Return a const-reference so that dims ()(i) works efficiently. - const dim_vector& dims (void) const { return m_dimensions; } + OCTARRAY_OVERRIDABLE_FUNC_API const dim_vector& dims (void) const + { return m_dimensions; } //! Chop off leading singleton dimensions OCTARRAY_API Array squeeze (void) const; - OCTARRAY_API octave_idx_type compute_index (octave_idx_type i, octave_idx_type j) const; - OCTARRAY_API octave_idx_type compute_index (octave_idx_type i, octave_idx_type j, - octave_idx_type k) const; - OCTARRAY_API octave_idx_type compute_index (const Array& ra_idx) const; + OCTARRAY_API octave_idx_type + compute_index (octave_idx_type i, octave_idx_type j) const; + OCTARRAY_API octave_idx_type + compute_index (octave_idx_type i, octave_idx_type j, octave_idx_type k) const; + OCTARRAY_API octave_idx_type + compute_index (const Array& ra_idx) const; - octave_idx_type compute_index_unchecked (const Array& ra_idx) const + OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type + compute_index_unchecked (const Array& ra_idx) const { return m_dimensions.compute_index (ra_idx.data (), ra_idx.numel ()); } // No checking, even for multiple references, ever. - T& xelem (octave_idx_type n) { return m_slice_data[n]; } - crefT xelem (octave_idx_type n) const { return m_slice_data[n]; } + OCTARRAY_OVERRIDABLE_FUNC_API T& xelem (octave_idx_type n) + { return m_slice_data[n]; } + OCTARRAY_OVERRIDABLE_FUNC_API crefT xelem (octave_idx_type n) const + { return m_slice_data[n]; } - T& xelem (octave_idx_type i, octave_idx_type j) + OCTARRAY_OVERRIDABLE_FUNC_API T& + xelem (octave_idx_type i, octave_idx_type j) { return xelem (dim1 ()*j+i); } - crefT xelem (octave_idx_type i, octave_idx_type j) const + OCTARRAY_OVERRIDABLE_FUNC_API crefT + xelem (octave_idx_type i, octave_idx_type j) const { return xelem (dim1 ()*j+i); } - T& xelem (octave_idx_type i, octave_idx_type j, octave_idx_type k) + OCTARRAY_OVERRIDABLE_FUNC_API T& + xelem (octave_idx_type i, octave_idx_type j, octave_idx_type k) { return xelem (i, dim2 ()*k+j); } - crefT xelem (octave_idx_type i, octave_idx_type j, octave_idx_type k) const + OCTARRAY_OVERRIDABLE_FUNC_API crefT + xelem (octave_idx_type i, octave_idx_type j, octave_idx_type k) const { return xelem (i, dim2 ()*k+j); } - T& xelem (const Array& ra_idx) + OCTARRAY_OVERRIDABLE_FUNC_API T& + xelem (const Array& ra_idx) { return xelem (compute_index_unchecked (ra_idx)); } - crefT xelem (const Array& ra_idx) const + OCTARRAY_OVERRIDABLE_FUNC_API crefT + xelem (const Array& ra_idx) const { return xelem (compute_index_unchecked (ra_idx)); } // FIXME: would be nice to fix this so that we don't unnecessarily force @@ -526,25 +553,28 @@ OCTARRAY_API T& checkelem (const Array& ra_idx); - T& elem (octave_idx_type n) + OCTARRAY_OVERRIDABLE_FUNC_API T& elem (octave_idx_type n) { make_unique (); return xelem (n); } - T& elem (octave_idx_type i, octave_idx_type j) { return elem (dim1 ()*j+i); } + OCTARRAY_OVERRIDABLE_FUNC_API T& elem (octave_idx_type i, octave_idx_type j) + { return elem (dim1 ()*j+i); } - T& elem (octave_idx_type i, octave_idx_type j, octave_idx_type k) + OCTARRAY_OVERRIDABLE_FUNC_API T& elem (octave_idx_type i, octave_idx_type j, octave_idx_type k) { return elem (i, dim2 ()*k+j); } - T& elem (const Array& ra_idx) + OCTARRAY_OVERRIDABLE_FUNC_API T& elem (const Array& ra_idx) { return Array::elem (compute_index_unchecked (ra_idx)); } - T& operator () (octave_idx_type n) { return elem (n); } - T& operator () (octave_idx_type i, octave_idx_type j) { return elem (i, j); } - T& operator () (octave_idx_type i, octave_idx_type j, octave_idx_type k) + OCTARRAY_OVERRIDABLE_FUNC_API T& operator () (octave_idx_type n) + { return elem (n); } + OCTARRAY_OVERRIDABLE_FUNC_API T& operator () (octave_idx_type i, octave_idx_type j) + { return elem (i, j); } + OCTARRAY_OVERRIDABLE_FUNC_API T& operator () (octave_idx_type i, octave_idx_type j, octave_idx_type k) { return elem (i, j, k); } - T& operator () (const Array& ra_idx) + OCTARRAY_OVERRIDABLE_FUNC_API T& operator () (const Array& ra_idx) { return elem (ra_idx); } OCTARRAY_API crefT checkelem (octave_idx_type n) const; @@ -556,24 +586,31 @@ OCTARRAY_API crefT checkelem (const Array& ra_idx) const; - crefT elem (octave_idx_type n) const { return xelem (n); } + OCTARRAY_OVERRIDABLE_FUNC_API crefT elem (octave_idx_type n) const + { return xelem (n); } - crefT elem (octave_idx_type i, octave_idx_type j) const + OCTARRAY_OVERRIDABLE_FUNC_API crefT + elem (octave_idx_type i, octave_idx_type j) const { return xelem (i, j); } - crefT elem (octave_idx_type i, octave_idx_type j, octave_idx_type k) const + OCTARRAY_OVERRIDABLE_FUNC_API crefT + elem (octave_idx_type i, octave_idx_type j, octave_idx_type k) const { return xelem (i, j, k); } - crefT elem (const Array& ra_idx) const + OCTARRAY_OVERRIDABLE_FUNC_API crefT + elem (const Array& ra_idx) const { return Array::xelem (compute_index_unchecked (ra_idx)); } - crefT operator () (octave_idx_type n) const { return elem (n); } - crefT operator () (octave_idx_type i, octave_idx_type j) const + OCTARRAY_OVERRIDABLE_FUNC_API crefT + operator () (octave_idx_type n) const { return elem (n); } + OCTARRAY_OVERRIDABLE_FUNC_API crefT + operator () (octave_idx_type i, octave_idx_type j) const { return elem (i, j); } - crefT operator () (octave_idx_type i, octave_idx_type j, - octave_idx_type k) const + OCTARRAY_OVERRIDABLE_FUNC_API crefT + operator () (octave_idx_type i, octave_idx_type j, octave_idx_type k) const { return elem (i, j, k); } - crefT operator () (const Array& ra_idx) const + OCTARRAY_OVERRIDABLE_FUNC_API crefT + operator () (const Array& ra_idx) const { return elem (ra_idx); } // Fast extractors. All of these produce shallow copies. @@ -585,41 +622,54 @@ //! Extract a slice from this array as a column vector: A(:)(lo+1:up). //! Must be 0 <= lo && up <= numel. May be up < lo. - OCTARRAY_API Array linear_slice (octave_idx_type lo, octave_idx_type up) const; + OCTARRAY_API Array + linear_slice (octave_idx_type lo, octave_idx_type up) const; - Array reshape (octave_idx_type nr, octave_idx_type nc) const + OCTARRAY_OVERRIDABLE_FUNC_API Array + reshape (octave_idx_type nr, octave_idx_type nc) const { return Array (*this, dim_vector (nr, nc)); } - Array reshape (const dim_vector& new_dims) const + OCTARRAY_OVERRIDABLE_FUNC_API Array + reshape (const dim_vector& new_dims) const { return Array (*this, new_dims); } - OCTARRAY_API Array permute (const Array& vec, bool inv = false) const; - Array ipermute (const Array& vec) const + OCTARRAY_API Array + permute (const Array& vec, bool inv = false) const; + OCTARRAY_OVERRIDABLE_FUNC_API Array + ipermute (const Array& vec) const { return permute (vec, true); } - bool issquare (void) const { return (dim1 () == dim2 ()); } + OCTARRAY_OVERRIDABLE_FUNC_API bool issquare (void) const + { return (dim1 () == dim2 ()); } - bool isempty (void) const { return numel () == 0; } + OCTARRAY_OVERRIDABLE_FUNC_API bool isempty (void) const + { return numel () == 0; } - bool isvector (void) const { return m_dimensions.isvector (); } + OCTARRAY_OVERRIDABLE_FUNC_API bool isvector (void) const + { return m_dimensions.isvector (); } - bool is_nd_vector (void) const { return m_dimensions.is_nd_vector (); } + OCTARRAY_OVERRIDABLE_FUNC_API bool is_nd_vector (void) const + { return m_dimensions.is_nd_vector (); } OCTARRAY_API Array transpose (void) const; OCTARRAY_API Array hermitian (T (*fcn) (const T&) = nullptr) const; - const T * data (void) const { return m_slice_data; } + OCTARRAY_OVERRIDABLE_FUNC_API const T * data (void) const + { return m_slice_data; } #if defined (OCTAVE_PROVIDE_DEPRECATED_SYMBOLS) OCTAVE_DEPRECATED (7, "for read-only access, use 'data' method instead") - const T * fortran_vec (void) const { return data (); } + OCTARRAY_OVERRIDABLE_FUNC_API const T * fortran_vec (void) const + { return data (); } #endif OCTARRAY_API T * fortran_vec (void); - bool is_shared (void) { return m_rep->m_count > 1; } + OCTARRAY_OVERRIDABLE_FUNC_API bool is_shared (void) + { return m_rep->m_count > 1; } - int ndims (void) const { return m_dimensions.ndims (); } + OCTARRAY_OVERRIDABLE_FUNC_API int ndims (void) const + { return m_dimensions.ndims (); } //@{ //! Indexing without resizing. @@ -635,16 +685,18 @@ //@{ //! Resizing (with fill). OCTARRAY_API void resize2 (octave_idx_type nr, octave_idx_type nc, const T& rfv); - void resize2 (octave_idx_type nr, octave_idx_type nc) + OCTARRAY_OVERRIDABLE_FUNC_API void resize2 (octave_idx_type nr, octave_idx_type nc) { resize2 (nr, nc, resize_fill_value ()); } OCTARRAY_API void resize1 (octave_idx_type n, const T& rfv); - void resize1 (octave_idx_type n) { resize1 (n, resize_fill_value ()); } + OCTARRAY_OVERRIDABLE_FUNC_API void resize1 (octave_idx_type n) + { resize1 (n, resize_fill_value ()); } OCTARRAY_API void resize (const dim_vector& dv, const T& rfv); - void resize (const dim_vector& dv) { resize (dv, resize_fill_value ()); } + OCTARRAY_OVERRIDABLE_FUNC_API void resize (const dim_vector& dv) + { resize (dv, resize_fill_value ()); } //@} //@{ @@ -653,24 +705,29 @@ // FIXME: this is really a corner case, that should better be // handled directly in liboctinterp. - OCTARRAY_API Array index (const octave::idx_vector& i, bool resize_ok, const T& rfv) const; - Array index (const octave::idx_vector& i, bool resize_ok) const + OCTARRAY_API Array + index (const octave::idx_vector& i, bool resize_ok, const T& rfv) const; + OCTARRAY_OVERRIDABLE_FUNC_API Array + index (const octave::idx_vector& i, bool resize_ok) const { return index (i, resize_ok, resize_fill_value ()); } - OCTARRAY_API Array index (const octave::idx_vector& i, const octave::idx_vector& j, - bool resize_ok, - const T& rfv) const; - Array index (const octave::idx_vector& i, const octave::idx_vector& j, - bool resize_ok) const + OCTARRAY_API Array + index (const octave::idx_vector& i, const octave::idx_vector& j, + bool resize_ok, const T& rfv) const; + OCTARRAY_OVERRIDABLE_FUNC_API Array + index (const octave::idx_vector& i, const octave::idx_vector& j, + bool resize_ok) const { return index (i, j, resize_ok, resize_fill_value ()); } - OCTARRAY_API Array index (const Array& ia, bool resize_ok, - const T& rfv) const; - Array index (const Array& ia, bool resize_ok) const + OCTARRAY_API Array + index (const Array& ia, bool resize_ok, + const T& rfv) const; + OCTARRAY_OVERRIDABLE_FUNC_API Array + index (const Array& ia, bool resize_ok) const { return index (ia, resize_ok, resize_fill_value ()); } @@ -678,22 +735,28 @@ //@{ //! Indexed assignment (always with resize & fill). - OCTARRAY_API void assign (const octave::idx_vector& i, const Array& rhs, const T& rfv); - void assign (const octave::idx_vector& i, const Array& rhs) + OCTARRAY_API void + assign (const octave::idx_vector& i, const Array& rhs, const T& rfv); + OCTARRAY_OVERRIDABLE_FUNC_API void + assign (const octave::idx_vector& i, const Array& rhs) { assign (i, rhs, resize_fill_value ()); } - OCTARRAY_API void assign (const octave::idx_vector& i, const octave::idx_vector& j, - const Array& rhs, - const T& rfv); - void assign (const octave::idx_vector& i, const octave::idx_vector& j, const Array& rhs) + OCTARRAY_API void + assign (const octave::idx_vector& i, const octave::idx_vector& j, + const Array& rhs, const T& rfv); + OCTARRAY_OVERRIDABLE_FUNC_API void + assign (const octave::idx_vector& i, const octave::idx_vector& j, + const Array& rhs) { assign (i, j, rhs, resize_fill_value ()); } - OCTARRAY_API void assign (const Array& ia, const Array& rhs, const T& rfv); - void assign (const Array& ia, const Array& rhs) + OCTARRAY_API void + assign (const Array& ia, const Array& rhs, const T& rfv); + OCTARRAY_OVERRIDABLE_FUNC_API void + assign (const Array& ia, const Array& rhs) { assign (ia, rhs, resize_fill_value ()); } @@ -716,12 +779,14 @@ //! size (a) is [d1 d2 ... dN] and idx is [i1 i2 ... iN], this //! method is equivalent to x(i1:i1+d1-1, i2:i2+d2-1, ... , //! iN:iN+dN-1) = a. - OCTARRAY_API Array& insert (const Array& a, const Array& idx); + OCTARRAY_API Array& + insert (const Array& a, const Array& idx); //! This is just a special case for idx = [r c 0 ...] - OCTARRAY_API Array& insert (const Array& a, octave_idx_type r, octave_idx_type c); + OCTARRAY_API Array& + insert (const Array& a, octave_idx_type r, octave_idx_type c); - void maybe_economize (void) + OCTARRAY_OVERRIDABLE_FUNC_API void maybe_economize (void) { if (m_rep->m_count == 1 && m_slice_len != m_rep->m_len) { @@ -754,7 +819,7 @@ //! Ditto, but for an array of values, specializing on the case when values //! are sorted. NaNs get the value N. OCTARRAY_API Array lookup (const Array& values, - sortmode mode = UNSORTED) const; + sortmode mode = UNSORTED) const; //! Count nonzero elements. OCTARRAY_API octave_idx_type nnz (void) const; @@ -762,7 +827,7 @@ //! Find indices of (at most n) nonzero elements. If n is specified, //! backward specifies search from backward. OCTARRAY_API Array find (octave_idx_type n = -1, - bool backward = false) const; + bool backward = false) const; //! Returns the n-th element in increasing order, using the same //! ordering as used for sort. n can either be a scalar index or a diff -r 4f86d56c090d -r 3f487a2612f2 liboctave/array/MArray-C.cc --- a/liboctave/array/MArray-C.cc Sat Nov 05 18:35:09 2022 -0400 +++ b/liboctave/array/MArray-C.cc Sat Nov 05 19:15:13 2022 +0100 @@ -34,7 +34,7 @@ #include "MArray.h" #include "MArray.cc" -INSTANTIATE_MARRAY (Complex, OCTAVE_API); +INSTANTIATE_MARRAY (Complex, OCTARRAY_CLASS_TEMPLATE_INSTANTIATION_API); INSTANTIATE_MARRAY_FRIENDS (Complex, OCTAVE_API) diff -r 4f86d56c090d -r 3f487a2612f2 liboctave/array/MArray-d.cc --- a/liboctave/array/MArray-d.cc Sat Nov 05 18:35:09 2022 -0400 +++ b/liboctave/array/MArray-d.cc Sat Nov 05 19:15:13 2022 +0100 @@ -32,7 +32,7 @@ #include "MArray.h" #include "MArray.cc" -INSTANTIATE_MARRAY (double, OCTAVE_API); +INSTANTIATE_MARRAY (double, OCTARRAY_CLASS_TEMPLATE_INSTANTIATION_API); INSTANTIATE_MARRAY_FRIENDS (double, OCTAVE_API) diff -r 4f86d56c090d -r 3f487a2612f2 liboctave/array/MArray-f.cc --- a/liboctave/array/MArray-f.cc Sat Nov 05 18:35:09 2022 -0400 +++ b/liboctave/array/MArray-f.cc Sat Nov 05 19:15:13 2022 +0100 @@ -32,7 +32,7 @@ #include "MArray.h" #include "MArray.cc" -INSTANTIATE_MARRAY (float, OCTAVE_API); +INSTANTIATE_MARRAY (float, OCTARRAY_CLASS_TEMPLATE_INSTANTIATION_API); INSTANTIATE_MARRAY_FRIENDS (float, OCTAVE_API) diff -r 4f86d56c090d -r 3f487a2612f2 liboctave/array/MArray-fC.cc --- a/liboctave/array/MArray-fC.cc Sat Nov 05 18:35:09 2022 -0400 +++ b/liboctave/array/MArray-fC.cc Sat Nov 05 19:15:13 2022 +0100 @@ -34,7 +34,7 @@ #include "MArray.h" #include "MArray.cc" -INSTANTIATE_MARRAY (FloatComplex, OCTAVE_API); +INSTANTIATE_MARRAY (FloatComplex, OCTARRAY_CLASS_TEMPLATE_INSTANTIATION_API); INSTANTIATE_MARRAY_FRIENDS (FloatComplex, OCTAVE_API) diff -r 4f86d56c090d -r 3f487a2612f2 liboctave/array/MArray-fwd.h --- a/liboctave/array/MArray-fwd.h Sat Nov 05 18:35:09 2022 -0400 +++ b/liboctave/array/MArray-fwd.h Sat Nov 05 19:15:13 2022 +0100 @@ -28,6 +28,6 @@ #include "octave-config.h" -template class OCTARRAY_API MArray; +template class OCTAVE_TEMPLATE_API MArray; #endif diff -r 4f86d56c090d -r 3f487a2612f2 liboctave/array/MArray-i.cc --- a/liboctave/array/MArray-i.cc Sat Nov 05 18:35:09 2022 -0400 +++ b/liboctave/array/MArray-i.cc Sat Nov 05 19:15:13 2022 +0100 @@ -34,9 +34,9 @@ #include "MArray.h" #include "MArray.cc" -INSTANTIATE_MARRAY (int, OCTAVE_API); +INSTANTIATE_MARRAY (int, OCTARRAY_CLASS_TEMPLATE_INSTANTIATION_API); #if defined (OCTAVE_ENABLE_64) -INSTANTIATE_MARRAY (int64_t, OCTAVE_API); +INSTANTIATE_MARRAY (int64_t, OCTARRAY_CLASS_TEMPLATE_INSTANTIATION_API); #endif INSTANTIATE_MARRAY_FRIENDS (int, OCTAVE_API) @@ -44,20 +44,20 @@ INSTANTIATE_MARRAY_FRIENDS (int64_t, OCTAVE_API) #endif -INSTANTIATE_MARRAY (octave_int8, OCTAVE_API); -INSTANTIATE_MARRAY (octave_int16, OCTAVE_API); -INSTANTIATE_MARRAY (octave_int32, OCTAVE_API); -INSTANTIATE_MARRAY (octave_int64, OCTAVE_API); +INSTANTIATE_MARRAY (octave_int8, OCTARRAY_CLASS_TEMPLATE_INSTANTIATION_API); +INSTANTIATE_MARRAY (octave_int16, OCTARRAY_CLASS_TEMPLATE_INSTANTIATION_API); +INSTANTIATE_MARRAY (octave_int32, OCTARRAY_CLASS_TEMPLATE_INSTANTIATION_API); +INSTANTIATE_MARRAY (octave_int64, OCTARRAY_CLASS_TEMPLATE_INSTANTIATION_API); INSTANTIATE_MARRAY_FRIENDS (octave_int8, OCTAVE_API) INSTANTIATE_MARRAY_FRIENDS (octave_int16, OCTAVE_API) INSTANTIATE_MARRAY_FRIENDS (octave_int32, OCTAVE_API) INSTANTIATE_MARRAY_FRIENDS (octave_int64, OCTAVE_API) -INSTANTIATE_MARRAY (octave_uint8, OCTAVE_API); -INSTANTIATE_MARRAY (octave_uint16, OCTAVE_API); -INSTANTIATE_MARRAY (octave_uint32, OCTAVE_API); -INSTANTIATE_MARRAY (octave_uint64, OCTAVE_API); +INSTANTIATE_MARRAY (octave_uint8, OCTARRAY_CLASS_TEMPLATE_INSTANTIATION_API); +INSTANTIATE_MARRAY (octave_uint16, OCTARRAY_CLASS_TEMPLATE_INSTANTIATION_API); +INSTANTIATE_MARRAY (octave_uint32, OCTARRAY_CLASS_TEMPLATE_INSTANTIATION_API); +INSTANTIATE_MARRAY (octave_uint64, OCTARRAY_CLASS_TEMPLATE_INSTANTIATION_API); INSTANTIATE_MARRAY_FRIENDS (octave_uint8, OCTAVE_API) INSTANTIATE_MARRAY_FRIENDS (octave_uint16, OCTAVE_API) diff -r 4f86d56c090d -r 3f487a2612f2 liboctave/array/MArray-s.cc --- a/liboctave/array/MArray-s.cc Sat Nov 05 18:35:09 2022 -0400 +++ b/liboctave/array/MArray-s.cc Sat Nov 05 19:15:13 2022 +0100 @@ -32,7 +32,7 @@ #include "MArray.h" #include "MArray.cc" -INSTANTIATE_MARRAY (short, OCTAVE_API); +INSTANTIATE_MARRAY (short, OCTARRAY_CLASS_TEMPLATE_INSTANTIATION_API); INSTANTIATE_MARRAY_FRIENDS (short, OCTAVE_API) diff -r 4f86d56c090d -r 3f487a2612f2 liboctave/array/MArray.cc --- a/liboctave/array/MArray.cc Sat Nov 05 18:35:09 2022 -0400 +++ b/liboctave/array/MArray.cc Sat Nov 05 19:15:13 2022 +0100 @@ -380,16 +380,8 @@ T::__xXxXx__ (); } -#if defined (__clang__) -# define INSTANTIATE_MARRAY(T, API) \ +#define INSTANTIATE_MARRAY(T, API) \ template <> API void \ MArray::instantiation_guard () { } \ \ template class API MArray -#else -# define INSTANTIATE_MARRAY(T, API) \ - template <> API void \ - MArray::instantiation_guard () { } \ - \ - template class MArray -#endif diff -r 4f86d56c090d -r 3f487a2612f2 liboctave/array/Sparse-fwd.h --- a/liboctave/array/Sparse-fwd.h Sat Nov 05 18:35:09 2022 -0400 +++ b/liboctave/array/Sparse-fwd.h Sat Nov 05 19:15:13 2022 +0100 @@ -32,12 +32,12 @@ # include template > -class OCTAVE_API Sparse; +class OCTAVE_TEMPLATE_API Sparse; #else template > -class OCTARRAY_API Sparse; +class OCTAVE_TEMPLATE_API Sparse; #endif diff -r 4f86d56c090d -r 3f487a2612f2 liboctave/numeric/sparse-qr.h --- a/liboctave/numeric/sparse-qr.h Sat Nov 05 18:35:09 2022 -0400 +++ b/liboctave/numeric/sparse-qr.h Sat Nov 05 19:15:13 2022 +0100 @@ -111,13 +111,11 @@ std::shared_ptr m_rep; }; -#if defined (__clang__) || defined (_WIN32) // extern instantiations with set visibility/export/import attribute - extern template class OCTAVE_API sparse_qr; + extern template class OCTAVE_EXTERN_TEMPLATE_API sparse_qr; - extern template class OCTAVE_API sparse_qr; -#endif + extern template class OCTAVE_EXTERN_TEMPLATE_API sparse_qr; // Provide qrsolve for backward compatibility. diff -r 4f86d56c090d -r 3f487a2612f2 liboctave/util/oct-cmplx.h --- a/liboctave/util/oct-cmplx.h Sat Nov 05 18:35:09 2022 -0400 +++ b/liboctave/util/oct-cmplx.h Sat Nov 05 19:15:13 2022 +0100 @@ -47,11 +47,11 @@ // extern template instantiations # define EXT_INST_COMPLEXR_COMP(OP, T) \ - extern template OCTAVE_API \ + extern template OCTAVE_EXTERN_TEMPLATE_API \ bool operator OP (const std::complex& a, const std::complex& b); \ - extern template OCTAVE_API \ + extern template OCTAVE_EXTERN_TEMPLATE_API \ bool operator OP (const std::complex& a, T b); \ - extern template OCTAVE_API \ + extern template OCTAVE_EXTERN_TEMPLATE_API \ bool operator OP (T a, const std::complex& b); EXT_INST_COMPLEXR_COMP(>, double) diff -r 4f86d56c090d -r 3f487a2612f2 liboctave/util/oct-inttypes-fwd.h --- a/liboctave/util/oct-inttypes-fwd.h Sat Nov 05 18:35:09 2022 -0400 +++ b/liboctave/util/oct-inttypes-fwd.h Sat Nov 05 19:15:13 2022 +0100 @@ -28,7 +28,7 @@ #include "octave-config.h" -template class OCTAVE_API octave_int; +template class OCTAVE_TEMPLATE_API octave_int; typedef octave_int octave_int8; typedef octave_int octave_int16; diff -r 4f86d56c090d -r 3f487a2612f2 liboctave/util/oct-inttypes.cc --- a/liboctave/util/oct-inttypes.cc Sat Nov 05 18:35:09 2022 -0400 +++ b/liboctave/util/oct-inttypes.cc Sat Nov 05 19:15:13 2022 +0100 @@ -819,7 +819,7 @@ } #define INSTANTIATE_INTTYPE(T) \ - template class octave_int; \ + template class OCTAVE_CLASS_TEMPLATE_INSTANTIATION_API octave_int; \ \ template OCTAVE_API octave_int \ pow (const octave_int&, const octave_int&); \ diff -r 4f86d56c090d -r 3f487a2612f2 liboctave/util/oct-inttypes.h --- a/liboctave/util/oct-inttypes.h Sat Nov 05 18:35:09 2022 -0400 +++ b/liboctave/util/oct-inttypes.h Sat Nov 05 19:15:13 2022 +0100 @@ -779,7 +779,9 @@ { }; template -class octave_int : public octave_int_base +class +OCTAVE_TEMPLATE_API +octave_int : public octave_int_base { public: diff -r 4f86d56c090d -r 3f487a2612f2 liboctave/util/oct-sort.h --- a/liboctave/util/oct-sort.h Sat Nov 05 18:35:09 2022 -0400 +++ b/liboctave/util/oct-sort.h Sat Nov 05 19:15:13 2022 +0100 @@ -98,7 +98,7 @@ template class -OCTARRAY_API +OCTAVE_TEMPLATE_API octave_sort { public: @@ -348,7 +348,7 @@ template class -OCTARRAY_API +OCTAVE_TEMPLATE_API vec_index { public: diff -r 4f86d56c090d -r 3f487a2612f2 oct-conf-post-public.in.h --- a/oct-conf-post-public.in.h Sat Nov 05 18:35:09 2022 -0400 +++ b/oct-conf-post-public.in.h Sat Nov 05 19:15:13 2022 +0100 @@ -134,39 +134,139 @@ # define OCTAVE_IMPORT #endif -/* API macro for liboctave */ +/* API macros for liboctave */ #if defined (OCTAVE_DLL) # define OCTAVE_API OCTAVE_EXPORT +# if defined (_WIN32) || defined (__CYGWIN__) +# define OCTAVE_TEMPLATE_API +# if defined(__MINGW32__) +# define OCTAVE_EXTERN_TEMPLATE_API OCTAVE_EXPORT +# define OCTAVE_CLASS_TEMPLATE_INSTANTIATION_API +# else +# define OCTAVE_EXTERN_TEMPLATE_API +# define OCTAVE_CLASS_TEMPLATE_INSTANTIATION_API OCTAVE_EXPORT +# endif +# define OCTAVE_OVERRIDABLE_FUNC_API OCTAVE_EXPORT +# else +# define OCTAVE_TEMPLATE_API OCTAVE_EXPORT +# define OCTAVE_EXTERN_TEMPLATE_API OCTAVE_EXPORT +# define OCTAVE_CLASS_TEMPLATE_INSTANTIATION_API +# define OCTAVE_OVERRIDABLE_FUNC_API +# endif #else # define OCTAVE_API OCTAVE_IMPORT +# define OCTAVE_TEMPLATE_API +# define OCTAVE_EXTERN_TEMPLATE_API OCTAVE_IMPORT +# define OCTAVE_CLASS_TEMPLATE_INSTANTIATION_API +# define OCTAVE_OVERRIDABLE_FUNC_API #endif -/* API macro for liboctinterp */ +/* API macros for liboctinterp */ #if defined (OCTINTERP_DLL) # define OCTINTERP_API OCTAVE_EXPORT +# if defined (_WIN32) || defined (__CYGWIN__) +# define OCTINTERP_TEMPLATE_API +# if defined(__MINGW32__) +# define OCTINTERP_EXTERN_TEMPLATE_API OCTAVE_EXPORT +# define OCTINTERP_CLASS_TEMPLATE_INSTANTIATION_API +# else +# define OCTINTERP_EXTERN_TEMPLATE_API +# define OCTINTERP_CLASS_TEMPLATE_INSTANTIATION_API OCTAVE_EXPORT +# endif +# define OCTINTERP_OVERRIDABLE_FUNC_API OCTAVE_EXPORT +# else +# define OCTINTERP_TEMPLATE_API OCTAVE_EXPORT +# define OCTINTERP_EXTERN_TEMPLATE_API OCTAVE_EXPORT +# define OCTINTERP_CLASS_TEMPLATE_INSTANTIATION_API +# define OCTINTERP_OVERRIDABLE_FUNC_API +# endif #else # define OCTINTERP_API OCTAVE_IMPORT +# define OCTINTERP_TEMPLATE_API +# define OCTINTERP_EXTERN_TEMPLATE_API OCTAVE_IMPORT +# define OCTINTERP_CLASS_TEMPLATE_INSTANTIATION_API +# define OCTINTERP_OVERRIDABLE_FUNC_API #endif -/* API macro for the Array class in liboctave and liboctinterp */ +/* API macros for the Array class in liboctave and liboctinterp */ #if (defined (OCTAVE_DLL) || defined (OCTINTERP_DLL)) # define OCTARRAY_API OCTAVE_EXPORT +# if defined (_WIN32) || defined (__CYGWIN__) +# define OCTARRAY_TEMPLATE_API +# if defined(__MINGW32__) +# define OCTARRAY_EXTERN_TEMPLATE_API OCTAVE_EXPORT +# define OCTARRAY_CLASS_TEMPLATE_INSTANTIATION_API +# else +# define OCTARRAY_EXTERN_TEMPLATE_API +# define OCTARRAY_CLASS_TEMPLATE_INSTANTIATION_API OCTAVE_EXPORT +# endif +# define OCTARRAY_OVERRIDABLE_FUNC_API OCTAVE_EXPORT +# else +# define OCTARRAY_TEMPLATE_API OCTAVE_EXPORT +# define OCTARRAY_EXTERN_TEMPLATE_API OCTAVE_EXPORT +# define OCTARRAY_CLASS_TEMPLATE_INSTANTIATION_API +# define OCTARRAY_OVERRIDABLE_FUNC_API +# endif #else # define OCTARRAY_API OCTAVE_IMPORT +# define OCTARRAY_TEMPLATE_API +# define OCTARRAY_EXTERN_TEMPLATE_API OCTAVE_IMPORT +# define OCTARRAY_CLASS_TEMPLATE_INSTANTIATION_API +# define OCTARRAY_OVERRIDABLE_FUNC_API #endif -/* API macro for libinterp/graphics */ +/* API macros for libinterp/graphics */ #if defined (OCTGRAPHICS_DLL) # define OCTGRAPHICS_API OCTAVE_EXPORT +# if defined (_WIN32) || defined (__CYGWIN__) +# define OCTGRAPHICS_TEMPLATE_API +# if defined(__MINGW32__) +# define OCTGRAPHICS_EXTERN_TEMPLATE_API OCTAVE_EXPORT +# define OCTGRAPHICS_CLASS_TEMPLATE_INSTANTIATION_API +# else +# define OCTGRAPHICS_EXTERN_TEMPLATE_API +# define OCTGRAPHICS_CLASS_TEMPLATE_INSTANTIATION_API OCTAVE_EXPORT +# endif +# define OCTGRAPHICS_OVERRIDABLE_FUNC_API OCTAVE_EXPORT +# else +# define OCTGRAPHICS_TEMPLATE_API OCTAVE_EXPORT +# define OCTGRAPHICS_EXTERN_TEMPLATE_API OCTAVE_EXPORT +# define OCTGRAPHICS_CLASS_TEMPLATE_INSTANTIATION_API +# define OCTGRAPHICS_OVERRIDABLE_FUNC_API +# endif #else # define OCTGRAPHICS_API OCTAVE_IMPORT +# define OCTGRAPHICS_TEMPLATE_API +# define OCTGRAPHICS_EXTERN_TEMPLATE_API OCTAVE_IMPORT +# define OCTGRAPHICS_CLASS_TEMPLATE_INSTANTIATION_API +# define OCTGRAPHICS_OVERRIDABLE_FUNC_API #endif -/* API macro for libgui */ +/* API macros for libgui */ #if defined (OCTGUI_DLL) # define OCTGUI_API OCTAVE_EXPORT +# if defined (_WIN32) || defined (__CYGWIN__) +# define OCTGUI_TEMPLATE_API +# if defined(__MINGW32__) +# define OCTGUI_EXTERN_TEMPLATE_API OCTAVE_EXPORT +# define OCTGUI_CLASS_TEMPLATE_INSTANTIATION_API +# else +# define OCTGUI_EXTERN_TEMPLATE_API +# define OCTGUI_CLASS_TEMPLATE_INSTANTIATION_API OCTAVE_EXPORT +# endif +# define OCTGUI_OVERRIDABLE_FUNC_API OCTAVE_EXPORT +# else +# define OCTGUI_TEMPLATE_API OCTAVE_EXPORT +# define OCTGUI_EXTERN_TEMPLATE_API OCTAVE_EXPORT +# define OCTGUI_CLASS_TEMPLATE_INSTANTIATION_API +# define OCTGUI_OVERRIDABLE_FUNC_API +# endif #else # define OCTGUI_API OCTAVE_IMPORT +# define OCTGUI_TEMPLATE_API +# define OCTGUI_EXTERN_TEMPLATE_API OCTAVE_IMPORT +# define OCTGUI_CLASS_TEMPLATE_INSTANTIATION_API +# define OCTGUI_OVERRIDABLE_FUNC_API #endif #if defined (OCTAVE_ENABLE_64)