1
1
/* !
2
2
* \file flc_vector.i
3
3
*
4
- * Copyright (c) 2019 Oak Ridge National Laboratory, UT-Battelle, LLC.
4
+ * Copyright (c) 2019-2020 Oak Ridge National Laboratory, UT-Battelle, LLC.
5
5
* Distributed under an MIT open source license: see LICENSE for details.
6
6
*/
7
7
8
8
%module " flc_vector"
9
9
%include " import_flc.i"
10
10
%flc_add_header
11
11
12
+ %include <complex .i>
12
13
%include <std_vector.i>
13
14
14
15
/* -------------------------------------------------------------------------
15
16
* Macro definitions
16
17
* ------------------------------------------------------------------------- */
17
18
18
- %define %flc_std_vector_extend_pod(CTYPE)
19
+ %define %flc_std_vector_extend_pod(CTYPE, IMTYPE )
19
20
%extend {
20
21
%apply (const SWIGTYPE *DATA, ::size_t SIZE)
21
22
{ (const CTYPE* DATA, size_type SIZE) };
31
32
}
32
33
33
34
// Get a mutable view to ourself
34
- %fortran_array_pointer (CTYPE , vector<CTYPE>& view);
35
+ %fortran_array_pointer (IMTYPE , vector<CTYPE>& view);
35
36
36
37
%typemap (out, noblock=1 ) vector<CTYPE>& view {
37
38
$result.data = ($1 ->empty () ? NULL : &(*$1 ->begin ()));
@@ -63,7 +64,7 @@ namespace std {
63
64
64
65
%swig_std_vector(T, const T&)
65
66
%swig_std_vector_extend_ref(T)
66
- %flc_std_vector_extend_pod(T)
67
+ %flc_std_vector_extend_pod(T, T )
67
68
};
68
69
}
69
70
@@ -72,6 +73,31 @@ namespace std {
72
73
73
74
%enddef
74
75
76
+
77
+ /* ------------------------------------------------------------------------- */
78
+ /* ! \def %flc_template_std_vector_complex
79
+ *
80
+ * Inject member functions and typemaps for std::complex instantiations.
81
+ *
82
+ * This definition is considered part of the \em public API so that downstream
83
+ * apps that generate FLC-based bindings can instantiate their own POD vectors.
84
+ */
85
+ %define %flc_template_std_vector_complex(NAME, T)
86
+
87
+ namespace std {
88
+ template <> class vector <std::complex <T> > {
89
+
90
+ %swig_std_vector(std::complex <T>, const std::complex <T>&)
91
+ %swig_std_vector_extend_ref(std::complex <T>)
92
+ %flc_std_vector_extend_pod(std::complex <T>, SwigComplex_ ## T)
93
+ };
94
+ }
95
+
96
+ // Instantiate the template
97
+ %template (NAME) std::vector<std::complex <T> >;
98
+
99
+ %enddef
100
+
75
101
/* -------------------------------------------------------------------------
76
102
* Numeric vectors
77
103
* ------------------------------------------------------------------------- */
@@ -80,6 +106,8 @@ namespace std {
80
106
%flc_template_std_vector_pod(VectorInt8, int64_t )
81
107
%flc_template_std_vector_pod(VectorReal8, double )
82
108
109
+ %flc_template_std_vector_complex(VectorComplex8, double )
110
+
83
111
/* -------------------------------------------------------------------------
84
112
* String vectors
85
113
* ------------------------------------------------------------------------- */
0 commit comments