|
15 | 15 | * Macro definitions |
16 | 16 | * ------------------------------------------------------------------------- */ |
17 | 17 |
|
18 | | -%define %flc_extend_vector_pod(CTYPE) |
| 18 | +%define %flc_std_vector_extend_pod(CTYPE) |
| 19 | +%extend { |
19 | 20 | %apply (const SWIGTYPE *DATA, ::size_t SIZE) |
20 | 21 | { (const CTYPE* DATA, size_type SIZE) }; |
21 | 22 |
|
|
40 | 41 | vector<CTYPE>& view() { |
41 | 42 | return *$self; |
42 | 43 | } |
| 44 | +} |
43 | 45 | %enddef |
44 | 46 |
|
45 | 47 | /* ------------------------------------------------------------------------- */ |
46 | | -/*! \def %specialize_std_vector_pod |
| 48 | +/*! \def %flc_template_std_vector_pod |
47 | 49 | * |
48 | | - * Inject member functions and typemaps for POD classes. |
| 50 | + * Inject member functions and typemaps for POD classes, and instantiate. |
49 | 51 | * |
50 | | - * These provide an efficient constructor from a Fortan array view. It also |
51 | | - * offers a "view" functionality for getting an array pointer to the |
| 52 | + * The added methods provide an efficient constructor from a Fortan array view. |
| 53 | + * It also offers a "view" functionality for getting an array pointer to the |
52 | 54 | * vector-owned data. |
53 | 55 | * |
54 | 56 | * This definition is considered part of the \em public API so that downstream |
55 | 57 | * apps that generate FLC-based bindings can instantiate their own POD vectors. |
56 | 58 | */ |
57 | | -%define %specialize_std_vector_pod(T) |
| 59 | +%define %flc_template_std_vector_pod(NAME, T) |
58 | 60 |
|
59 | 61 | // Automatically free temporary vectors as appropriate |
60 | 62 | %fortran_autofree_rvalue(std::vector<T>); |
61 | 63 |
|
62 | 64 | namespace std { |
63 | 65 | template<> class vector<T> { |
64 | 66 |
|
65 | | - SWIG_STD_VECTOR_COMMON(T, const T&) |
66 | | - SWIG_STD_VECTOR_REF(T) |
67 | | - %extend { |
68 | | - %flc_extend_vector_pod(T) |
69 | | - } |
| 67 | + %swig_std_vector(T, const T&) |
| 68 | + %swig_std_vector_extend_ref(T) |
| 69 | + %flc_std_vector_extend_pod(T) |
70 | 70 | }; |
71 | 71 | } |
| 72 | + |
| 73 | +// Instantiate the template |
| 74 | +%template(NAME) std::vector<T>; |
| 75 | + |
72 | 76 | %enddef |
73 | 77 |
|
74 | 78 | /* ------------------------------------------------------------------------- |
75 | 79 | * Numeric vectors |
76 | 80 | * ------------------------------------------------------------------------- */ |
77 | 81 |
|
78 | | -%specialize_std_vector_pod(int32_t) |
79 | | -%specialize_std_vector_pod(int64_t) |
80 | | -%specialize_std_vector_pod(double) |
81 | | - |
82 | | -%template(VectorInt4) std::vector<int32_t>; |
83 | | -%template(VectorInt8) std::vector<int64_t>; |
84 | | -%template(VectorReal8) std::vector<double>; |
| 82 | +%flc_template_std_vector_pod(VectorInt4, int32_t) |
| 83 | +%flc_template_std_vector_pod(VectorInt8, int64_t) |
| 84 | +%flc_template_std_vector_pod(VectorReal8, double) |
85 | 85 |
|
86 | 86 | /* ------------------------------------------------------------------------- |
87 | 87 | * String vectors |
|
0 commit comments