comparison libinterp/operators/ops.h @ 21647:66cae7a6dc47

eliminate some macros for operator definitions * ops.h (CAST_UNOP_ARG, CAST_BINOP_ARGS, CAST_CONV_ARG, ASSIGNOPDECL, NULLASSIGNOPDECL, ASSIGNANYOPDECL, DEFASSIGNOP, DEFASSIGNOP_FN, UNOPDECL, BINOPDECL, CATOPDECL): Delete macros. * make_int.cc, ov-bool-mat.cc, ov-bool-sparse.cc, ov-bool.cc, ov-complex.cc, ov-cx-diag.cc, ov-cx-mat.cc, ov-flt-cx-diag.cc, ov-flt-re-diag.cc, ov-lazy-idx.cc, ov-null-mat.cc, ov-perm.cc, ov-range.cc, ov-re-diag.cc, ov-re-mat.cc, ov-scalar.cc, ov-str-mat.cc, op-b-b.cc, op-b-bm.cc, op-b-sbm.cc, op-bm-bm.cc, op-bm-sbm.cc, op-cdm-cdm.cc, op-cell.cc, op-chm.cc, op-cm-cm.cc, op-cm-cs.cc, op-cm-m.cc, op-cm-s.cc, op-cm-scm.cc, op-cm-sm.cc, op-cs-cm.cc, op-cs-cs.cc, op-cs-m.cc, op-cs-s.cc, op-cs-scm.cc, op-cs-sm.cc, op-dm-dm.cc, op-dm-scm.cc, op-dm-sm.cc, op-dm-template.cc, op-dms-template.cc, op-fcdm-fcdm.cc, op-fcm-fcm.cc, op-fcm-fcs.cc, op-fcm-fm.cc, op-fcm-fs.cc, op-fcn.cc, op-fcs-fcm.cc, op-fcs-fcs.cc, op-fcs-fm.cc, op-fcs-fs.cc, op-fdm-fdm.cc, op-fm-fcm.cc, op-fm-fcs.cc, op-fm-fm.cc, op-fm-fs.cc, op-fs-fcm.cc, op-fs-fcs.cc, op-fs-fm.cc, op-fs-fs.cc, op-int-conv.cc, op-int.h, op-m-cm.cc, op-m-cs.cc, op-m-m.cc, op-m-s.cc, op-m-scm.cc, op-m-sm.cc, op-pm-pm.cc, op-pm-scm.cc, op-pm-sm.cc, op-pm-template.cc, op-range.cc, op-s-cm.cc, op-s-cs.cc, op-s-m.cc, op-s-s.cc, op-s-scm.cc, op-s-sm.cc, op-sbm-b.cc, op-sbm-bm.cc, op-sbm-sbm.cc, op-scm-cm.cc, op-scm-cs.cc, op-scm-m.cc, op-scm-s.cc, op-scm-scm.cc, op-scm-sm.cc, op-sm-cm.cc, op-sm-cs.cc, op-sm-m.cc, op-sm-s.cc, op-sm-scm.cc, op-sm-sm.cc, op-str-m.cc, op-str-s.cc, op-str-str.cc, op-struct.cc, ops.h: Expand eliminated macros in place.
author John W. Eaton <jwe@octave.org>
date Wed, 27 Apr 2016 16:13:40 -0400
parents 1473547f50f5
children 1eabc3e24a53
comparison
equal deleted inserted replaced
21646:3cddf1e65ccf 21647:66cae7a6dc47
73 73
74 #define INSTALL_WIDENOP(t1, t2, f) \ 74 #define INSTALL_WIDENOP(t1, t2, f) \
75 octave_value_typeinfo::register_widening_op \ 75 octave_value_typeinfo::register_widening_op \
76 (t1::static_type_id (), t2::static_type_id (), CONCAT2(oct_conv_, f)); 76 (t1::static_type_id (), t2::static_type_id (), CONCAT2(oct_conv_, f));
77 77
78 #define CAST_UNOP_ARG(t) \ 78 #define DEFASSIGNOP(name, t1, t2) \
79 t v = dynamic_cast<t> (a) 79 static octave_value \
80 80 CONCAT2(oct_assignop_, name) (octave_base_value& a1, \
81 #define CAST_BINOP_ARGS(t1, t2) \ 81 const octave_value_list& idx, \
82 t1 v1 = dynamic_cast<t1> (a1); \ 82 const octave_base_value& a2)
83 t2 v2 = dynamic_cast<t2> (a2) 83
84 84 #define DEFASSIGNOP_FN(name, t1, t2, f) \
85 #define CAST_CONV_ARG(t) \ 85 static octave_value \
86 t v = dynamic_cast<t> (a) 86 CONCAT2(oct_assignop_, name) (octave_base_value& a1, \
87 87 const octave_value_list& idx, \
88 #define ASSIGNOPDECL(name) \ 88 const octave_base_value& a2) \
89 static octave_value \ 89 { \
90 CONCAT2(oct_assignop_, name) (octave_base_value& a1, \ 90 CONCAT2(octave_, t1)& v1 = dynamic_cast<CONCAT2(octave_, t1)&> (a1); \
91 const octave_value_list& idx, \ 91 const CONCAT2(octave_, t2)& v2 = dynamic_cast<const CONCAT2(octave_, t2)&> (a2); \
92 const octave_base_value& a2) 92 \
93 93 v1.f (idx, v2.CONCAT2(t1, _value) ()); \
94 #define NULLASSIGNOPDECL(name) \ 94 return octave_value (); \
95 }
96
97 #define DEFNULLASSIGNOP_FN(name, t, f) \
95 static octave_value \ 98 static octave_value \
96 CONCAT2(oct_assignop_, name) (octave_base_value& a, \ 99 CONCAT2(oct_assignop_, name) (octave_base_value& a, \
97 const octave_value_list& idx, \ 100 const octave_value_list& idx, \
98 const octave_base_value&) 101 const octave_base_value&) \
99 102 { \
100 #define ASSIGNANYOPDECL(name) \ 103 CONCAT2(octave_, t)& v = dynamic_cast<CONCAT2(octave_, t)&> (a); \
101 static octave_value \
102 CONCAT2(oct_assignop_, name) (octave_base_value& a1, \
103 const octave_value_list& idx, \
104 const octave_value& a2)
105
106 #define DEFASSIGNOP(name, t1, t2) \
107 ASSIGNOPDECL (name)
108
109 #define DEFASSIGNOP_FN(name, t1, t2, f) \
110 ASSIGNOPDECL (name) \
111 { \
112 CAST_BINOP_ARGS (CONCAT2(octave_, t1)&, const CONCAT2(octave_, t2)&); \
113 \
114 v1.f (idx, v2.CONCAT2(t1, _value) ()); \
115 return octave_value (); \
116 }
117
118 #define DEFNULLASSIGNOP_FN(name, t, f) \
119 NULLASSIGNOPDECL (name) \
120 { \
121 CAST_UNOP_ARG (CONCAT2(octave_, t)&); \
122 \ 104 \
123 v.f (idx); \ 105 v.f (idx); \
124 return octave_value (); \ 106 return octave_value (); \
125 } 107 }
126 108
127 #define DEFNDASSIGNOP_FN(name, t1, t2, e, f) \ 109 #define DEFNDASSIGNOP_FN(name, t1, t2, e, f) \
128 ASSIGNOPDECL (name) \ 110 static octave_value \
129 { \ 111 CONCAT2(oct_assignop_, name) (octave_base_value& a1, \
130 CAST_BINOP_ARGS (CONCAT2(octave_, t1)&, const CONCAT2(octave_, t2)&); \ 112 const octave_value_list& idx, \
113 const octave_base_value& a2) \
114 { \
115 CONCAT2(octave_, t1)& v1 = dynamic_cast<CONCAT2(octave_, t1)&> (a1); \
116 const CONCAT2(octave_, t2)& v2 = dynamic_cast<const CONCAT2(octave_, t2)&> (a2); \
131 \ 117 \
132 v1.f (idx, v2.CONCAT2(e, _value) ()); \ 118 v1.f (idx, v2.CONCAT2(e, _value) ()); \
133 return octave_value (); \ 119 return octave_value (); \
134 } 120 }
135 121
136 // FIXME: the following currently don't handle index. 122 // FIXME: the following currently don't handle index.
137 #define DEFNDASSIGNOP_OP(name, t1, t2, f, op) \ 123 #define DEFNDASSIGNOP_OP(name, t1, t2, f, op) \
138 ASSIGNOPDECL (name) \ 124 static octave_value \
139 { \ 125 CONCAT2(oct_assignop_, name) (octave_base_value& a1, \
140 CAST_BINOP_ARGS (CONCAT2(octave_, t1)&, const CONCAT2(octave_, t2)&); \ 126 const octave_value_list& idx, \
127 const octave_base_value& a2) \
128 { \
129 CONCAT2(octave_, t1)& v1 = dynamic_cast<CONCAT2(octave_, t1)&> (a1); \
130 const CONCAT2(octave_, t2)& v2 = dynamic_cast<const CONCAT2(octave_, t2)&> (a2); \
141 \ 131 \
142 assert (idx.empty ()); \ 132 assert (idx.empty ()); \
143 v1.matrix_ref () op v2.CONCAT2(f, _value) (); \ 133 v1.matrix_ref () op v2.CONCAT2(f, _value) (); \
144 \ 134 \
145 return octave_value (); \ 135 return octave_value (); \
146 } 136 }
147 137
148 #define DEFNDASSIGNOP_FNOP(name, t1, t2, f, fnop) \ 138 #define DEFNDASSIGNOP_FNOP(name, t1, t2, f, fnop) \
149 ASSIGNOPDECL (name) \ 139 static octave_value \
150 { \ 140 CONCAT2(oct_assignop_, name) (octave_base_value& a1, \
151 CAST_BINOP_ARGS (CONCAT2(octave_, t1)&, const CONCAT2(octave_, t2)&); \ 141 const octave_value_list& idx, \
142 const octave_base_value& a2) \
143 { \
144 CONCAT2(octave_, t1)& v1 = dynamic_cast<CONCAT2(octave_, t1)&> (a1); \
145 const CONCAT2(octave_, t2)& v2 = dynamic_cast<const CONCAT2(octave_, t2)&> (a2); \
152 \ 146 \
153 assert (idx.empty ()); \ 147 assert (idx.empty ()); \
154 fnop (v1.matrix_ref (), v2.CONCAT2(f, _value) ()); \ 148 fnop (v1.matrix_ref (), v2.CONCAT2(f, _value) ()); \
155 \ 149 \
156 return octave_value (); \ 150 return octave_value (); \
157 } 151 }
158 152
159 #define DEFASSIGNANYOP_FN(name, t1, f) \ 153 #define DEFASSIGNANYOP_FN(name, t1, f) \
160 ASSIGNANYOPDECL (name) \ 154 static octave_value \
155 CONCAT2(oct_assignop_, name) (octave_base_value& a1, \
156 const octave_value_list& idx, \
157 const octave_value& a2) \
161 { \ 158 { \
162 CONCAT2(octave_, t1)& v1 = dynamic_cast<CONCAT2(octave_, t1)&> (a1); \ 159 CONCAT2(octave_, t1)& v1 = dynamic_cast<CONCAT2(octave_, t1)&> (a1); \
163 \ 160 \
164 v1.f (idx, a2); \ 161 v1.f (idx, a2); \
165 return octave_value (); \ 162 return octave_value (); \
177 CONVDECL (name) 174 CONVDECL (name)
178 175
179 #define DEFCONVFNX(name, tfrom, ovtto, tto, e) \ 176 #define DEFCONVFNX(name, tfrom, ovtto, tto, e) \
180 CONVDECL (name) \ 177 CONVDECL (name) \
181 { \ 178 { \
182 CAST_CONV_ARG (const CONCAT2(octave_, tfrom)&); \ 179 const CONCAT2(octave_, tfrom)& v = dynamic_cast<const CONCAT2(octave_, tfrom)&> (a); \
183 \ 180 \
184 return new CONCAT2(octave_, ovtto) (CONCAT2(tto, NDArray) (v.CONCAT2(e, array_value) ())); \ 181 return new CONCAT2(octave_, ovtto) (CONCAT2(tto, NDArray) (v.CONCAT2(e, array_value) ())); \
185 } 182 }
186 183
187 #define DEFCONVFNX2(name, tfrom, ovtto, e) \ 184 #define DEFCONVFNX2(name, tfrom, ovtto, e) \
188 CONVDECL (name) \ 185 CONVDECL (name) \
189 { \ 186 { \
190 CAST_CONV_ARG (const CONCAT2(octave_, tfrom)&); \ 187 const CONCAT2(octave_, tfrom)& v = dynamic_cast<const CONCAT2(octave_, tfrom)&> (a); \
191 \ 188 \
192 return new CONCAT2(octave_, ovtto) (v.CONCAT2(e, array_value) ()); \ 189 return new CONCAT2(octave_, ovtto) (v.CONCAT2(e, array_value) ()); \
193 } 190 }
194 191
195 #define DEFDBLCONVFN(name, ovtfrom, e) \ 192 #define DEFDBLCONVFN(name, ovtfrom, e) \
196 CONVDECL (name) \ 193 CONVDECL (name) \
197 { \ 194 { \
198 CAST_CONV_ARG (const CONCAT2(octave_, ovtfrom)&); \ 195 const CONCAT2(octave_, ovtfrom)& v = dynamic_cast<const CONCAT2(octave_, ovtfrom)&> (a); \
199 \ 196 \
200 return new octave_matrix (NDArray (v.CONCAT2(e, _value) ())); \ 197 return new octave_matrix (NDArray (v.CONCAT2(e, _value) ())); \
201 } 198 }
202 199
203 #define DEFFLTCONVFN(name, ovtfrom, e) \ 200 #define DEFFLTCONVFN(name, ovtfrom, e) \
204 CONVDECL (name) \ 201 CONVDECL (name) \
205 { \ 202 { \
206 CAST_CONV_ARG (const CONCAT2(octave_, ovtfrom)&); \ 203 const CONCAT2(octave_, ovtfrom)& v = dynamic_cast<const CONCAT2(octave_, ovtfrom)&> (a); \
207 \ 204 \
208 return new octave_float_matrix (FloatNDArray (v.CONCAT2(e, _value) ())); \ 205 return new octave_float_matrix (FloatNDArray (v.CONCAT2(e, _value) ())); \
209 } 206 }
210 207
211 #define DEFSTRINTCONVFN(name, tto) \ 208 #define DEFSTRINTCONVFN(name, tto) \
221 DEFCONVFNX2 (name, tfrom, CONCAT2(tto, _matrix), CONCAT2(tto, _)) 218 DEFCONVFNX2 (name, tfrom, CONCAT2(tto, _matrix), CONCAT2(tto, _))
222 219
223 #define DEFCONVFN2(name, tfrom, sm, tto) \ 220 #define DEFCONVFN2(name, tfrom, sm, tto) \
224 DEFCONVFNX2 (name, CONCAT3(tfrom, _, sm), CONCAT2(tto, _matrix), CONCAT2(tto, _)) 221 DEFCONVFNX2 (name, CONCAT3(tfrom, _, sm), CONCAT2(tto, _matrix), CONCAT2(tto, _))
225 222
226 #define UNOPDECL(name, a) \ 223 #define DEFUNOPX(name, t) \
224 static octave_value \
225 CONCAT2(oct_unop_, name) (const octave_base_value&)
226
227 #define DEFUNOP(name, t) \
227 static octave_value \ 228 static octave_value \
228 CONCAT2(oct_unop_, name) (const octave_base_value& a) 229 CONCAT2(oct_unop_, name) (const octave_base_value& a)
229 230
230 #define DEFUNOPX(name, t) \
231 UNOPDECL (name, , )
232
233 #define DEFUNOP(name, t) \
234 UNOPDECL (name, a)
235
236 #define DEFUNOP_OP(name, t, op) \ 231 #define DEFUNOP_OP(name, t, op) \
237 UNOPDECL (name, a) \ 232 static octave_value \
238 { \ 233 CONCAT2(oct_unop_, name) (const octave_base_value& a) \
239 CAST_UNOP_ARG (const CONCAT2(octave_, t)&); \ 234 { \
235 const CONCAT2(octave_, t)& v = dynamic_cast<const CONCAT2(octave_, t)&> (a); \
240 return octave_value (op v.CONCAT2(t, _value) ()); \ 236 return octave_value (op v.CONCAT2(t, _value) ()); \
241 } 237 }
242 238
243 #define DEFNDUNOP_OP(name, t, e, op) \ 239 #define DEFNDUNOP_OP(name, t, e, op) \
244 UNOPDECL (name, a) \ 240 static octave_value \
245 { \ 241 CONCAT2(oct_unop_, name) (const octave_base_value& a) \
246 CAST_UNOP_ARG (const CONCAT2(octave_, t)&); \ 242 { \
243 const CONCAT2(octave_, t)& v = dynamic_cast<const CONCAT2(octave_, t)&> (a); \
247 return octave_value (op v.CONCAT2(e, _value) ()); \ 244 return octave_value (op v.CONCAT2(e, _value) ()); \
248 } 245 }
249 246
250 // FIXME: in some cases, the constructor isn't necessary. 247 // FIXME: in some cases, the constructor isn't necessary.
251 248
252 #define DEFUNOP_FN(name, t, f) \ 249 #define DEFUNOP_FN(name, t, f) \
253 UNOPDECL (name, a) \ 250 static octave_value \
254 { \ 251 CONCAT2(oct_unop_, name) (const octave_base_value& a) \
255 CAST_UNOP_ARG (const CONCAT2(octave_, t)&); \ 252 { \
253 const CONCAT2(octave_, t)& v = dynamic_cast<const CONCAT2(octave_, t)&> (a); \
256 return octave_value (f (v.CONCAT2(t, _value) ())); \ 254 return octave_value (f (v.CONCAT2(t, _value) ())); \
257 } 255 }
258 256
259 #define DEFNDUNOP_FN(name, t, e, f) \ 257 #define DEFNDUNOP_FN(name, t, e, f) \
260 UNOPDECL (name, a) \ 258 static octave_value \
261 { \ 259 CONCAT2(oct_unop_, name) (const octave_base_value& a) \
262 CAST_UNOP_ARG (const CONCAT2(octave_, t)&); \ 260 { \
261 const CONCAT2(octave_, t)& v = dynamic_cast<const CONCAT2(octave_, t)&> (a); \
263 return octave_value (f (v.CONCAT2(e, _value) ())); \ 262 return octave_value (f (v.CONCAT2(e, _value) ())); \
264 } 263 }
265 264
266 #define DEFNCUNOP_METHOD(name, t, method) \ 265 #define DEFNCUNOP_METHOD(name, t, method) \
267 static void \ 266 static void \
268 CONCAT2(oct_unop_, name) (octave_base_value& a) \ 267 CONCAT2(oct_unop_, name) (octave_base_value& a) \
269 { \ 268 { \
270 CAST_UNOP_ARG (CONCAT2(octave_, t)&); \ 269 CONCAT2(octave_, t)& v = dynamic_cast<CONCAT2(octave_, t)&> (a); \
271 v.method (); \ 270 v.method (); \
272 } 271 }
273 272
274 #define BINOPDECL(name, a1, a2) \ 273 #define DEFBINOPX(name, t1, t2) \
274 static octave_value \
275 CONCAT2(oct_binop_, name) (const octave_base_value&, const octave_base_value&)
276
277 #define DEFBINOP(name, t1, t2) \
275 static octave_value \ 278 static octave_value \
276 CONCAT2(oct_binop_, name) (const octave_base_value& a1, const octave_base_value& a2) 279 CONCAT2(oct_binop_, name) (const octave_base_value& a1, const octave_base_value& a2)
277 280
278 #define DEFBINOPX(name, t1, t2) \
279 BINOPDECL (name, , )
280
281 #define DEFBINOP(name, t1, t2) \
282 BINOPDECL (name, a1, a2)
283
284 #define DEFBINOP_OP(name, t1, t2, op) \ 281 #define DEFBINOP_OP(name, t1, t2, op) \
285 BINOPDECL (name, a1, a2) \ 282 static octave_value \
286 { \ 283 CONCAT2(oct_binop_, name) (const octave_base_value& a1, const octave_base_value& a2) \
287 CAST_BINOP_ARGS (const CONCAT2(octave_, t1)&, const CONCAT2(octave_, t2)&); \ 284 { \
285 const CONCAT2(octave_, t1)& v1 = dynamic_cast<const CONCAT2(octave_, t1)&> (a1); \
286 const CONCAT2(octave_, t2)& v2 = dynamic_cast<const CONCAT2(octave_, t2)&> (a2); \
288 return octave_value \ 287 return octave_value \
289 (v1.CONCAT2(t1, _value) () op v2.CONCAT2(t2, _value) ()); \ 288 (v1.CONCAT2(t1, _value) () op v2.CONCAT2(t2, _value) ()); \
290 } 289 }
291 290
292 #define DEFCMPLXCMPOP_OP(name, t1, t2, op) \ 291 #define DEFCMPLXCMPOP_OP(name, t1, t2, op) \
293 BINOPDECL (name, a1, a2) \ 292 static octave_value \
294 { \ 293 CONCAT2(oct_binop_, name) (const octave_base_value& a1, const octave_base_value& a2) \
295 CAST_BINOP_ARGS (const CONCAT2(octave_, t1)&, const CONCAT2(octave_, t2)&); \ 294 { \
295 const CONCAT2(octave_, t1)& v1 = dynamic_cast<const CONCAT2(octave_, t1)&> (a1); \
296 const CONCAT2(octave_, t2)& v2 = dynamic_cast<const CONCAT2(octave_, t2)&> (a2); \
296 warn_complex_cmp (); \ 297 warn_complex_cmp (); \
297 return octave_value \ 298 return octave_value \
298 (v1.CONCAT2(t1, _value) () op v2.CONCAT2(t2, _value) ()); \ 299 (v1.CONCAT2(t1, _value) () op v2.CONCAT2(t2, _value) ()); \
299 } 300 }
300 301
301 #define DEFSCALARBOOLOP_OP(name, t1, t2, op) \ 302 #define DEFSCALARBOOLOP_OP(name, t1, t2, op) \
302 BINOPDECL (name, a1, a2) \ 303 static octave_value \
303 { \ 304 CONCAT2(oct_binop_, name) (const octave_base_value& a1, const octave_base_value& a2) \
304 CAST_BINOP_ARGS (const CONCAT2(octave_, t1)&, const CONCAT2(octave_, t2)&); \ 305 { \
306 const CONCAT2(octave_, t1)& v1 = dynamic_cast<const CONCAT2(octave_, t1)&> (a1); \
307 const CONCAT2(octave_, t2)& v2 = dynamic_cast<const CONCAT2(octave_, t2)&> (a2); \
305 if (xisnan (v1.CONCAT2(t1, _value) ()) || xisnan (v2.CONCAT2(t2, _value) ())) \ 308 if (xisnan (v1.CONCAT2(t1, _value) ()) || xisnan (v2.CONCAT2(t2, _value) ())) \
306 err_nan_to_logical_conversion (); \ 309 err_nan_to_logical_conversion (); \
307 \ 310 \
308 return octave_value \ 311 return octave_value \
309 (v1.CONCAT2(t1, _value) () op v2.CONCAT2(t2, _value) ()); \ 312 (v1.CONCAT2(t1, _value) () op v2.CONCAT2(t2, _value) ()); \
310 } 313 }
311 314
312 #define DEFNDBINOP_OP(name, t1, t2, e1, e2, op) \ 315 #define DEFNDBINOP_OP(name, t1, t2, e1, e2, op) \
313 BINOPDECL (name, a1, a2) \ 316 static octave_value \
314 { \ 317 CONCAT2(oct_binop_, name) (const octave_base_value& a1, const octave_base_value& a2) \
315 CAST_BINOP_ARGS (const CONCAT2(octave_, t1)&, const CONCAT2(octave_, t2)&); \ 318 { \
319 const CONCAT2(octave_, t1)& v1 = dynamic_cast<const CONCAT2(octave_, t1)&> (a1); \
320 const CONCAT2(octave_, t2)& v2 = dynamic_cast<const CONCAT2(octave_, t2)&> (a2); \
316 return octave_value \ 321 return octave_value \
317 (v1.CONCAT2(e1, _value) () op v2.CONCAT2(e2, _value) ()); \ 322 (v1.CONCAT2(e1, _value) () op v2.CONCAT2(e2, _value) ()); \
318 } 323 }
319 324
320 // FIXME: in some cases, the constructor isn't necessary. 325 // FIXME: in some cases, the constructor isn't necessary.
321 326
322 #define DEFBINOP_FN(name, t1, t2, f) \ 327 #define DEFBINOP_FN(name, t1, t2, f) \
323 BINOPDECL (name, a1, a2) \ 328 static octave_value \
324 { \ 329 CONCAT2(oct_binop_, name) (const octave_base_value& a1, const octave_base_value& a2) \
325 CAST_BINOP_ARGS (const CONCAT2(octave_, t1)&, const CONCAT2(octave_, t2)&); \ 330 { \
331 const CONCAT2(octave_, t1)& v1 = dynamic_cast<const CONCAT2(octave_, t1)&> (a1); \
332 const CONCAT2(octave_, t2)& v2 = dynamic_cast<const CONCAT2(octave_, t2)&> (a2); \
326 return octave_value (f (v1.CONCAT2(t1, _value) (), v2.CONCAT2(t2, _value) ())); \ 333 return octave_value (f (v1.CONCAT2(t1, _value) (), v2.CONCAT2(t2, _value) ())); \
327 } 334 }
328 335
329 #define DEFNDBINOP_FN(name, t1, t2, e1, e2, f) \ 336 #define DEFNDBINOP_FN(name, t1, t2, e1, e2, f) \
330 BINOPDECL (name, a1, a2) \ 337 static octave_value \
331 { \ 338 CONCAT2(oct_binop_, name) (const octave_base_value& a1, const octave_base_value& a2) \
332 CAST_BINOP_ARGS (const CONCAT2(octave_, t1)&, const CONCAT2(octave_, t2)&); \ 339 { \
340 const CONCAT2(octave_, t1)& v1 = dynamic_cast<const CONCAT2(octave_, t1)&> (a1); \
341 const CONCAT2(octave_, t2)& v2 = dynamic_cast<const CONCAT2(octave_, t2)&> (a2); \
333 return octave_value (f (v1.CONCAT2(e1, _value) (), v2.CONCAT2(e2, _value) ())); \ 342 return octave_value (f (v1.CONCAT2(e1, _value) (), v2.CONCAT2(e2, _value) ())); \
334 } 343 }
335 344
336 #define DEFNDCMPLXCMPOP_FN(name, t1, t2, e1, e2, f) \ 345 #define DEFNDCMPLXCMPOP_FN(name, t1, t2, e1, e2, f) \
337 BINOPDECL (name, a1, a2) \ 346 static octave_value \
338 { \ 347 CONCAT2(oct_binop_, name) (const octave_base_value& a1, const octave_base_value& a2) \
339 CAST_BINOP_ARGS (const CONCAT2(octave_, t1)&, const CONCAT2(octave_, t2)&); \ 348 { \
349 const CONCAT2(octave_, t1)& v1 = dynamic_cast<const CONCAT2(octave_, t1)&> (a1); \
350 const CONCAT2(octave_, t2)& v2 = dynamic_cast<const CONCAT2(octave_, t2)&> (a2); \
340 return octave_value (f (v1.CONCAT2(e1, _value) (), v2.CONCAT2(e2, _value) ())); \ 351 return octave_value (f (v1.CONCAT2(e1, _value) (), v2.CONCAT2(e2, _value) ())); \
341 } 352 }
342 353
343 #define CATOPDECL(name, a1, a2) \ 354 #define DEFCATOPX(name, t1, t2) \
355 static octave_value \
356 CONCAT2(oct_catop_, name) (octave_base_value&, const octave_base_value&, \
357 const Array<octave_idx_type>& ra_idx)
358
359 #define DEFCATOP(name, t1, t2) \
344 static octave_value \ 360 static octave_value \
345 CONCAT2(oct_catop_, name) (octave_base_value& a1, const octave_base_value& a2, \ 361 CONCAT2(oct_catop_, name) (octave_base_value& a1, const octave_base_value& a2, \
346 const Array<octave_idx_type>& ra_idx) 362 const Array<octave_idx_type>& ra_idx)
347
348 #define DEFCATOPX(name, t1, t2) \
349 CATOPDECL (name, , )
350
351 #define DEFCATOP(name, t1, t2) \
352 CATOPDECL (name, a1, a2)
353 363
354 // FIXME: in some cases, the constructor isn't necessary. 364 // FIXME: in some cases, the constructor isn't necessary.
355 365
356 #define DEFCATOP_FN(name, t1, t2, f) \ 366 #define DEFCATOP_FN(name, t1, t2, f) \
357 CATOPDECL (name, a1, a2) \ 367 static octave_value \
358 { \ 368 CONCAT2(oct_catop_, name) (octave_base_value& a1, const octave_base_value& a2, \
359 CAST_BINOP_ARGS (CONCAT2(octave_, t1)&, const CONCAT2(octave_, t2)&); \ 369 const Array<octave_idx_type>& ra_idx) \
370 { \
371 CONCAT2(octave_, t1)& v1 = dynamic_cast<CONCAT2(octave_, t1)&> (a1); \
372 const CONCAT2(octave_, t2)& v2 = dynamic_cast<const CONCAT2(octave_, t2)&> (a2); \
360 return octave_value (v1.CONCAT2(t1, _value) () . f (v2.CONCAT2(t2, _value) (), ra_idx)); \ 373 return octave_value (v1.CONCAT2(t1, _value) () . f (v2.CONCAT2(t2, _value) (), ra_idx)); \
361 } 374 }
362 375
363 #define DEFNDCATOP_FN(name, t1, t2, e1, e2, f) \ 376 #define DEFNDCATOP_FN(name, t1, t2, e1, e2, f) \
364 CATOPDECL (name, a1, a2) \ 377 static octave_value \
365 { \ 378 CONCAT2(oct_catop_, name) (octave_base_value& a1, const octave_base_value& a2, \
366 CAST_BINOP_ARGS (CONCAT2(octave_, t1)&, const CONCAT2(octave_, t2)&); \ 379 const Array<octave_idx_type>& ra_idx) \
380 { \
381 CONCAT2(octave_, t1)& v1 = dynamic_cast<CONCAT2(octave_, t1)&> (a1); \
382 const CONCAT2(octave_, t2)& v2 = dynamic_cast<const CONCAT2(octave_, t2)&> (a2); \
367 return octave_value (v1.CONCAT2(e1, _value) () . f (v2.CONCAT2(e2, _value) (), ra_idx)); \ 383 return octave_value (v1.CONCAT2(e1, _value) () . f (v2.CONCAT2(e2, _value) (), ra_idx)); \
368 } 384 }
369 385
370 #define DEFNDCHARCATOP_FN(name, t1, t2, f) \ 386 #define DEFNDCHARCATOP_FN(name, t1, t2, f) \
371 CATOPDECL (name, a1, a2) \ 387 static octave_value \
372 { \ 388 CONCAT2(oct_catop_, name) (octave_base_value& a1, const octave_base_value& a2, \
373 CAST_BINOP_ARGS (CONCAT2(octave_, t1)&, const CONCAT2(octave_, t2)&); \ 389 const Array<octave_idx_type>& ra_idx) \
390 { \
391 CONCAT2(octave_, t1)& v1 = dynamic_cast<CONCAT2(octave_, t1)&> (a1); \
392 const CONCAT2(octave_, t2)& v2 = dynamic_cast<const CONCAT2(octave_, t2)&> (a2); \
374 \ 393 \
375 return octave_value (v1.char_array_value () . f (v2.char_array_value (), ra_idx), \ 394 return octave_value (v1.char_array_value () . f (v2.char_array_value (), ra_idx), \
376 ((a1.is_sq_string () || a2.is_sq_string ()) \ 395 ((a1.is_sq_string () || a2.is_sq_string ()) \
377 ? '\'' : '"')); \ 396 ? '\'' : '"')); \
378 } 397 }
379 398
380 // For compatibility, the second arg is always converted to the type 399 // For compatibility, the second arg is always converted to the type
381 // of the first. Hmm. 400 // of the first. Hmm.
382 401
383 #define DEFNDCATOP_FN2(name, t1, t2, tc1, tc2, e1, e2, f) \ 402 #define DEFNDCATOP_FN2(name, t1, t2, tc1, tc2, e1, e2, f) \
384 CATOPDECL (name, a1, a2) \ 403 static octave_value \
385 { \ 404 CONCAT2(oct_catop_, name) (octave_base_value& a1, const octave_base_value& a2, \
386 CAST_BINOP_ARGS (CONCAT2(octave_, t1)&, const CONCAT2(octave_, t2)&); \ 405 const Array<octave_idx_type>& ra_idx) \
406 { \
407 CONCAT2(octave_, t1)& v1 = dynamic_cast<CONCAT2(octave_, t1)&> (a1); \
408 const CONCAT2(octave_, t2)& v2 = dynamic_cast<const CONCAT2(octave_, t2)&> (a2); \
387 return octave_value (tc1 (v1.CONCAT2(e1, _value) ()) . f (tc2 (v2.CONCAT2(e2, _value) ()), ra_idx)); \ 409 return octave_value (tc1 (v1.CONCAT2(e1, _value) ()) . f (tc2 (v2.CONCAT2(e2, _value) ()), ra_idx)); \
388 } 410 }
389 411
390 #define CATOP_NONCONFORMANT(msg) \ 412 #define CATOP_NONCONFORMANT(msg) \
391 err_nonconformant (msg, \ 413 err_nonconformant (msg, \