annotate libinterp/operators/ops.h @ 30723:08b08b7f05b2

Replace direct calls to C library assert() with Octave specialty functions in libinterp/ (bug #61753) Define 4 new inline functions in error.h (panic_if, panic_unless, error_if, error_unless) that call either assert() or Octave's own error() function. Replace calls to assert() in code that maintains state and for which no recovery on detection of a problem is possible with calls to panic_XXX. Replace calls to assert() in interpreter code which could simply return to the Octave prompt when a problem is detected with calls to error_XXX. * error.h (panic_if, panic_unless): New functions which eventually call can call assert(). panic_if (COND) calls assert if COND is true. panic_unless (COND) calls assert if COND is false. * error.h (error_if, error_unless): New functions which eventually call can call Octave's error() function. error_if (COND) calls assert if COND is true. error_unless (COND) calls assert if COND is false. * cellfun.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, dot.cc, error.cc, graphics.cc, kron.cc, mex.cc, oct-map.cc, oct-stream.cc, pr-output.cc, schur.cc, stack-frame.cc, typecast.cc, variables.cc, ov-base.cc, ov-class.cc, ov-fcn-handle.cc, ov-struct.cc, ov-usr-fcn.cc, ov.h, ovl.cc, ops.h, profiler.cc, pt-classdef.cc, pt-eval.cc, pt-idx.cc, pt-pr-code.cc, pt-tm-const.cc, token.cc: Replace direct calls to C library assert() with Octave specialty functions.
author Arun Giridhar <arungiridhar@gmail.com> and Rik <rik@octave.org>
date Mon, 07 Feb 2022 21:47:53 -0800
parents 796f54d4ddbf
children e88a07dec498
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 29989
diff changeset
3 // Copyright (C) 1996-2022 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
25
20791
f7084eae3318 maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents: 19697
diff changeset
26 #if ! defined (octave_ops_h)
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
27 #define octave_ops_h 1
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
28
21244
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 21129
diff changeset
29 #include "octave-config.h"
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 21129
diff changeset
30
4669
334a27c8f453 [project @ 2003-11-26 07:02:42 by jwe]
jwe
parents: 4550
diff changeset
31 #include "Array-util.h"
30723
08b08b7f05b2 Replace direct calls to C library assert() with Octave specialty functions in libinterp/ (bug #61753)
Arun Giridhar <arungiridhar@gmail.com> and Rik <rik@octave.org>
parents: 30564
diff changeset
32 #include "error.h"
4669
334a27c8f453 [project @ 2003-11-26 07:02:42 by jwe]
jwe
parents: 4550
diff changeset
33
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
34 namespace octave
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
35 {
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
36 class type_info;
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
37 }
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
38
8366
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 8150
diff changeset
39 // Concatenation macros that enforce argument prescan
21649
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
40 #define CONCAT2X(x, y) x ## y
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
41 #define CONCAT2(x, y) CONCAT2X (x, y)
8366
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 8150
diff changeset
42
21649
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
43 #define CONCAT3X(x, y, z) x ## y ## z
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
44 #define CONCAT3(x, y, z) CONCAT3X (x, y, z)
8366
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 8150
diff changeset
45
24540
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
46 #define INSTALL_UNOP_TI(ti, op, t, f) \
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
47 ti.install_unary_op \
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
48 (octave_value::op, t::static_type_id (), CONCAT2 (oct_unop_, f));
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
49
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
50 #define INSTALL_NCUNOP_TI(ti, op, t, f) \
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
51 ti.install_non_const_unary_op \
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
52 (octave_value::op, t::static_type_id (), CONCAT2 (oct_unop_, f));
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
53
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
54 #define INSTALL_BINOP_TI(ti, op, t1, t2, f) \
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
55 ti.install_binary_op \
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
56 (octave_value::op, t1::static_type_id (), t2::static_type_id (), \
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
57 CONCAT2 (oct_binop_, f));
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
58
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
59 #define INSTALL_CATOP_TI(ti, t1, t2, f) \
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
60 ti.install_cat_op \
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
61 (t1::static_type_id (), t2::static_type_id (), CONCAT2 (oct_catop_, f));
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
62
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
63 #define INSTALL_ASSIGNOP_TI(ti, op, t1, t2, f) \
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
64 ti.install_assign_op \
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
65 (octave_value::op, t1::static_type_id (), t2::static_type_id (), \
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
66 CONCAT2 (oct_assignop_, f));
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
67
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
68 #define INSTALL_ASSIGNANYOP_TI(ti, op, t1, f) \
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
69 ti.install_assignany_op \
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
70 (octave_value::op, t1::static_type_id (), CONCAT2 (oct_assignop_, f));
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
71
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
72 #define INSTALL_ASSIGNCONV_TI(ti, t1, t2, tr) \
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
73 ti.install_pref_assign_conv \
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
74 (t1::static_type_id (), t2::static_type_id (), tr::static_type_id ());
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
75
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
76 #define INSTALL_WIDENOP_TI(ti, t1, t2, f) \
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
77 ti.install_widening_op \
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
78 (t1::static_type_id (), t2::static_type_id (), CONCAT2 (oct_conv_, f));
46440078d73b don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
79
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
80 #define DEFASSIGNOP(name, t1, t2) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
81 static octave_value \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
82 CONCAT2 (oct_assignop_, name) (octave_base_value& a1, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
83 const octave_value_list& idx, \
21649
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
84 const octave_base_value& a2)
5759
ce79d238f142 [project @ 2006-04-13 13:04:32 by jwe]
jwe
parents: 5533
diff changeset
85
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
86 #define DEFASSIGNOP_FN(name, t1, t2, f) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
87 static octave_value \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
88 CONCAT2 (oct_assignop_, name) (octave_base_value& a1, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
89 const octave_value_list& idx, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
90 const octave_base_value& a2) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
91 { \
21649
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
92 CONCAT2 (octave_, t1)& v1 = dynamic_cast<CONCAT2 (octave_, t1)&> (a1); \
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
93 const CONCAT2 (octave_, t2)& v2 = dynamic_cast<const CONCAT2 (octave_, t2)&> (a2); \
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
94 \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
95 v1.f (idx, v2.CONCAT2 (t1, _value) ()); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
96 return octave_value (); \
2914
d6a3e3723736 [project @ 1997-04-30 20:43:31 by jwe]
jwe
parents: 2879
diff changeset
97 }
d6a3e3723736 [project @ 1997-04-30 20:43:31 by jwe]
jwe
parents: 2879
diff changeset
98
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
99 #define DEFNULLASSIGNOP_FN(name, t, f) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
100 static octave_value \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
101 CONCAT2 (oct_assignop_, name) (octave_base_value& a, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
102 const octave_value_list& idx, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
103 const octave_base_value&) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
104 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
105 CONCAT2 (octave_, t)& v = dynamic_cast<CONCAT2 (octave_, t)&> (a); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
106 \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
107 v.f (idx); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
108 return octave_value (); \
8150
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7997
diff changeset
109 }
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 7997
diff changeset
110
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
111 #define DEFNDASSIGNOP_FN(name, t1, t2, e, f) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
112 static octave_value \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
113 CONCAT2 (oct_assignop_, name) (octave_base_value& a1, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
114 const octave_value_list& idx, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
115 const octave_base_value& a2) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
116 { \
21649
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
117 CONCAT2 (octave_, t1)& v1 = dynamic_cast<CONCAT2 (octave_, t1)&> (a1); \
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
118 const CONCAT2 (octave_, t2)& v2 = dynamic_cast<const CONCAT2 (octave_, t2)&> (a2); \
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
119 \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
120 v1.f (idx, v2.CONCAT2 (e, _value) ()); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
121 return octave_value (); \
4686
c7ae43dfdea4 [project @ 2004-01-06 19:29:23 by jwe]
jwe
parents: 4669
diff changeset
122 }
c7ae43dfdea4 [project @ 2004-01-06 19:29:23 by jwe]
jwe
parents: 4669
diff changeset
123
9548
e5f7aee2ab8c optimize &=, |= operators
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
124 // FIXME: the following currently don't handle index.
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
125 #define DEFNDASSIGNOP_OP(name, t1, t2, f, op) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
126 static octave_value \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
127 CONCAT2 (oct_assignop_, name) (octave_base_value& a1, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
128 const octave_value_list& idx, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
129 const octave_base_value& a2) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
130 { \
21649
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
131 CONCAT2 (octave_, t1)& v1 = dynamic_cast<CONCAT2 (octave_, t1)&> (a1); \
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
132 const CONCAT2 (octave_, t2)& v2 = dynamic_cast<const CONCAT2 (octave_, t2)&> (a2); \
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
133 \
30723
08b08b7f05b2 Replace direct calls to C library assert() with Octave specialty functions in libinterp/ (bug #61753)
Arun Giridhar <arungiridhar@gmail.com> and Rik <rik@octave.org>
parents: 30564
diff changeset
134 error_unless (idx.empty ()); \
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
135 v1.matrix_ref () op v2.CONCAT2 (f, _value) (); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
136 \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
137 return octave_value (); \
9546
1beb23d2b892 optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
138 }
1beb23d2b892 optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
139
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
140 #define DEFNDASSIGNOP_FNOP(name, t1, t2, f, fnop) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
141 static octave_value \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
142 CONCAT2 (oct_assignop_, name) (octave_base_value& a1, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
143 const octave_value_list& idx, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
144 const octave_base_value& a2) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
145 { \
21649
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
146 CONCAT2 (octave_, t1)& v1 = dynamic_cast<CONCAT2 (octave_, t1)&> (a1); \
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
147 const CONCAT2 (octave_, t2)& v2 = dynamic_cast<const CONCAT2 (octave_, t2)&> (a2); \
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
148 \
30723
08b08b7f05b2 Replace direct calls to C library assert() with Octave specialty functions in libinterp/ (bug #61753)
Arun Giridhar <arungiridhar@gmail.com> and Rik <rik@octave.org>
parents: 30564
diff changeset
149 error_unless (idx.empty ()); \
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
150 fnop (v1.matrix_ref (), v2.CONCAT2 (f, _value) ()); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
151 \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
152 return octave_value (); \
9548
e5f7aee2ab8c optimize &=, |= operators
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
153 }
e5f7aee2ab8c optimize &=, |= operators
Jaroslav Hajek <highegg@gmail.com>
parents: 9546
diff changeset
154
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
155 #define DEFASSIGNANYOP_FN(name, t1, f) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
156 static octave_value \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
157 CONCAT2 (oct_assignop_, name) (octave_base_value& a1, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
158 const octave_value_list& idx, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
159 const octave_value& a2) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
160 { \
21649
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
161 CONCAT2 (octave_, t1)& v1 = dynamic_cast<CONCAT2 (octave_, t1)&> (a1); \
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
162 \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
163 v1.f (idx, a2); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
164 return octave_value (); \
3195
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 2914
diff changeset
165 }
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 2914
diff changeset
166
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
167 #define CONVDECL(name) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
168 static octave_base_value * \
21649
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
169 CONCAT2 (oct_conv_, name) (const octave_base_value& a)
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3195
diff changeset
170
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
171 #define DEFCONV(name, a_dummy, b_dummy) \
2914
d6a3e3723736 [project @ 1997-04-30 20:43:31 by jwe]
jwe
parents: 2879
diff changeset
172 CONVDECL (name)
d6a3e3723736 [project @ 1997-04-30 20:43:31 by jwe]
jwe
parents: 2879
diff changeset
173
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
174 #define DEFUNOPX(name, t) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
175 static octave_value \
21649
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
176 CONCAT2 (oct_unop_, name) (const octave_base_value&)
21647
66cae7a6dc47 eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
177
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
178 #define DEFUNOP(name, t) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
179 static octave_value \
21649
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
180 CONCAT2 (oct_unop_, name) (const octave_base_value& a)
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3195
diff changeset
181
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
182 #define DEFUNOP_OP(name, t, op) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
183 static octave_value \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
184 CONCAT2 (oct_unop_, name) (const octave_base_value& a) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
185 { \
21649
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
186 const CONCAT2 (octave_, t)& v = dynamic_cast<const CONCAT2 (octave_, t)&> (a); \
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
187 return octave_value (op v.CONCAT2 (t, _value) ()); \
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3195
diff changeset
188 }
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3195
diff changeset
189
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
190 #define DEFNDUNOP_OP(name, t, e, op) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
191 static octave_value \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
192 CONCAT2 (oct_unop_, name) (const octave_base_value& a) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
193 { \
21649
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
194 const CONCAT2 (octave_, t)& v = dynamic_cast<const CONCAT2 (octave_, t)&> (a); \
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
195 return octave_value (op v.CONCAT2 (e, _value) ()); \
4543
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 3203
diff changeset
196 }
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 3203
diff changeset
197
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
198 // FIXME: in some cases, the constructor isn't necessary.
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3195
diff changeset
199
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
200 #define DEFUNOP_FN(name, t, f) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
201 static octave_value \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
202 CONCAT2 (oct_unop_, name) (const octave_base_value& a) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
203 { \
21649
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
204 const CONCAT2 (octave_, t)& v = dynamic_cast<const CONCAT2 (octave_, t)&> (a); \
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
205 return octave_value (f (v.CONCAT2 (t, _value) ())); \
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3195
diff changeset
206 }
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3195
diff changeset
207
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
208 #define DEFNDUNOP_FN(name, t, e, f) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
209 static octave_value \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
210 CONCAT2 (oct_unop_, name) (const octave_base_value& a) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
211 { \
21649
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
212 const CONCAT2 (octave_, t)& v = dynamic_cast<const CONCAT2 (octave_, t)&> (a); \
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
213 return octave_value (f (v.CONCAT2 (e, _value) ())); \
4543
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 3203
diff changeset
214 }
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 3203
diff changeset
215
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
216 #define DEFNCUNOP_METHOD(name, t, method) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
217 static void \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
218 CONCAT2 (oct_unop_, name) (octave_base_value& a) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
219 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
220 CONCAT2 (octave_, t)& v = dynamic_cast<CONCAT2 (octave_, t)&> (a); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
221 v.method (); \
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3195
diff changeset
222 }
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 3195
diff changeset
223
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
224 #define DEFBINOPX(name, t1, t2) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
225 static octave_value \
21649
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
226 CONCAT2 (oct_binop_, name) (const octave_base_value&, \
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
227 const octave_base_value&)
21647
66cae7a6dc47 eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
228
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
229 #define DEFBINOP(name, t1, t2) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
230 static octave_value \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
231 CONCAT2 (oct_binop_, name) (const octave_base_value& a1, \
21649
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
232 const octave_base_value& a2)
2914
d6a3e3723736 [project @ 1997-04-30 20:43:31 by jwe]
jwe
parents: 2879
diff changeset
233
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
234 #define DEFBINOP_OP(name, t1, t2, op) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
235 static octave_value \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
236 CONCAT2 (oct_binop_, name) (const octave_base_value& a1, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
237 const octave_base_value& a2) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
238 { \
21649
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
239 const CONCAT2 (octave_, t1)& v1 = dynamic_cast<const CONCAT2 (octave_, t1)&> (a1); \
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
240 const CONCAT2 (octave_, t2)& v2 = dynamic_cast<const CONCAT2 (octave_, t2)&> (a2); \
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
241 \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
242 return octave_value \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
243 (v1.CONCAT2 (t1, _value) () op v2.CONCAT2 (t2, _value) ()); \
2914
d6a3e3723736 [project @ 1997-04-30 20:43:31 by jwe]
jwe
parents: 2879
diff changeset
244 }
d6a3e3723736 [project @ 1997-04-30 20:43:31 by jwe]
jwe
parents: 2879
diff changeset
245
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
246 #define DEFCMPLXCMPOP_OP(name, t1, t2, op) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
247 static octave_value \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
248 CONCAT2 (oct_binop_, name) (const octave_base_value& a1, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
249 const octave_base_value& a2) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
250 { \
21649
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
251 const CONCAT2 (octave_, t1)& v1 = dynamic_cast<const CONCAT2 (octave_, t1)&> (a1); \
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
252 const CONCAT2 (octave_, t2)& v2 = dynamic_cast<const CONCAT2 (octave_, t2)&> (a2); \
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
253 \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
254 warn_complex_cmp (); \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
255 \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
256 return octave_value \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
257 (v1.CONCAT2 (t1, _value) () op v2.CONCAT2 (t2, _value) ()); \
9588
319e2ab9b8ae warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9587
diff changeset
258 }
319e2ab9b8ae warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9587
diff changeset
259
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
260 #define DEFSCALARBOOLOP_OP(name, t1, t2, op) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
261 static octave_value \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
262 CONCAT2 (oct_binop_, name) (const octave_base_value& a1, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
263 const octave_base_value& a2) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
264 { \
21649
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
265 const CONCAT2 (octave_, t1)& v1 = dynamic_cast<const CONCAT2 (octave_, t1)&> (a1); \
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
266 const CONCAT2 (octave_, t2)& v2 = dynamic_cast<const CONCAT2 (octave_, t2)&> (a2); \
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
267 \
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21649
diff changeset
268 if (octave::math::isnan (v1.CONCAT2 (t1, _value) ()) || octave::math::isnan (v2.CONCAT2 (t2, _value) ())) \
22327
d0562b3159c7 move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
269 octave::err_nan_to_logical_conversion (); \
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
270 \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
271 return octave_value \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
272 (v1.CONCAT2 (t1, _value) () op v2.CONCAT2 (t2, _value) ()); \
7922
935be827eaf8 error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
273 }
935be827eaf8 error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
274
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
275 #define DEFNDBINOP_OP(name, t1, t2, e1, e2, op) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
276 static octave_value \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
277 CONCAT2 (oct_binop_, name) (const octave_base_value& a1, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
278 const octave_base_value& a2) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
279 { \
21649
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
280 const CONCAT2 (octave_, t1)& v1 = dynamic_cast<const CONCAT2 (octave_, t1)&> (a1); \
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
281 const CONCAT2 (octave_, t2)& v2 = dynamic_cast<const CONCAT2 (octave_, t2)&> (a2); \
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
282 \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
283 return octave_value \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
284 (v1.CONCAT2 (e1, _value) () op v2.CONCAT2 (e2, _value) ()); \
4543
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 3203
diff changeset
285 }
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 3203
diff changeset
286
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
287 // FIXME: in some cases, the constructor isn't necessary.
2914
d6a3e3723736 [project @ 1997-04-30 20:43:31 by jwe]
jwe
parents: 2879
diff changeset
288
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
289 #define DEFBINOP_FN(name, t1, t2, f) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
290 static octave_value \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
291 CONCAT2 (oct_binop_, name) (const octave_base_value& a1, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
292 const octave_base_value& a2) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
293 { \
21649
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
294 const CONCAT2 (octave_, t1)& v1 = dynamic_cast<const CONCAT2 (octave_, t1)&> (a1); \
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
295 const CONCAT2 (octave_, t2)& v2 = dynamic_cast<const CONCAT2 (octave_, t2)&> (a2); \
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
296 \
21649
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
297 return octave_value (f (v1.CONCAT2 (t1, _value) (), v2.CONCAT2 (t2, _value) ())); \
2914
d6a3e3723736 [project @ 1997-04-30 20:43:31 by jwe]
jwe
parents: 2879
diff changeset
298 }
d6a3e3723736 [project @ 1997-04-30 20:43:31 by jwe]
jwe
parents: 2879
diff changeset
299
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
300 #define DEFNDBINOP_FN(name, t1, t2, e1, e2, f) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
301 static octave_value \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
302 CONCAT2 (oct_binop_, name) (const octave_base_value& a1, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
303 const octave_base_value& a2) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
304 { \
21649
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
305 const CONCAT2 (octave_, t1)& v1 = dynamic_cast<const CONCAT2 (octave_, t1)&> (a1); \
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
306 const CONCAT2 (octave_, t2)& v2 = dynamic_cast<const CONCAT2 (octave_, t2)&> (a2); \
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
307 \
21649
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
308 return octave_value (f (v1.CONCAT2 (e1, _value) (), v2.CONCAT2 (e2, _value) ())); \
4543
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 3203
diff changeset
309 }
79df15d4470c [project @ 2003-10-18 03:53:52 by jwe]
jwe
parents: 3203
diff changeset
310
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
311 #define DEFNDCMPLXCMPOP_FN(name, t1, t2, e1, e2, f) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
312 static octave_value \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
313 CONCAT2 (oct_binop_, name) (const octave_base_value& a1, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
314 const octave_base_value& a2) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
315 { \
21649
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
316 const CONCAT2 (octave_, t1)& v1 = dynamic_cast<const CONCAT2 (octave_, t1)&> (a1); \
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
317 const CONCAT2 (octave_, t2)& v2 = dynamic_cast<const CONCAT2 (octave_, t2)&> (a2); \
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
318 \
21649
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
319 return octave_value (f (v1.CONCAT2 (e1, _value) (), v2.CONCAT2 (e2, _value) ())); \
9588
319e2ab9b8ae warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9587
diff changeset
320 }
319e2ab9b8ae warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9587
diff changeset
321
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
322 #define DEFCATOPX(name, t1, t2) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
323 static octave_value \
28630
35f974bab4c8 fix constness of cat op args
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
324 CONCAT2 (oct_catop_, name) (const octave_base_value&, \
35f974bab4c8 fix constness of cat op args
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
325 const octave_base_value&, \
21649
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
326 const Array<octave_idx_type>& ra_idx)
21647
66cae7a6dc47 eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
327
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
328 #define DEFCATOP(name, t1, t2) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
329 static octave_value \
28630
35f974bab4c8 fix constness of cat op args
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
330 CONCAT2 (oct_catop_, name) (const octave_base_value& a1, \
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
331 const octave_base_value& a2, \
21649
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
332 const Array<octave_idx_type>& ra_idx)
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4901
diff changeset
333
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
334 // FIXME: in some cases, the constructor isn't necessary.
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4901
diff changeset
335
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
336 #define DEFCATOP_FN(name, t1, t2, f) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
337 static octave_value \
28630
35f974bab4c8 fix constness of cat op args
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
338 CONCAT2 (oct_catop_, name) (const octave_base_value& a1, \
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
339 const octave_base_value& a2, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
340 const Array<octave_idx_type>& ra_idx) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
341 { \
28630
35f974bab4c8 fix constness of cat op args
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
342 const CONCAT2 (octave_, t1)& v1 = dynamic_cast<const CONCAT2 (octave_, t1)&> (a1); \
21649
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
343 const CONCAT2 (octave_, t2)& v2 = dynamic_cast<const CONCAT2 (octave_, t2)&> (a2); \
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
344 \
21649
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
345 return octave_value (v1.CONCAT2 (t1, _value) () . f (v2.CONCAT2 (t2, _value) (), ra_idx)); \
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4901
diff changeset
346 }
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4901
diff changeset
347
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
348 #define DEFNDCATOP_FN(name, t1, t2, e1, e2, f) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
349 static octave_value \
28630
35f974bab4c8 fix constness of cat op args
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
350 CONCAT2 (oct_catop_, name) (const octave_base_value& a1, \
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
351 const octave_base_value& a2, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
352 const Array<octave_idx_type>& ra_idx) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
353 { \
28630
35f974bab4c8 fix constness of cat op args
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
354 const CONCAT2 (octave_, t1)& v1 = dynamic_cast<const CONCAT2 (octave_, t1)&> (a1); \
21649
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
355 const CONCAT2 (octave_, t2)& v2 = dynamic_cast<const CONCAT2 (octave_, t2)&> (a2); \
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
356 \
21649
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
357 return octave_value (v1.CONCAT2 (e1, _value) () . f (v2.CONCAT2 (e2, _value) (), ra_idx)); \
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
358 }
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
359
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
360 #define DEFNDCHARCATOP_FN(name, t1, t2, f) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
361 static octave_value \
28630
35f974bab4c8 fix constness of cat op args
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
362 CONCAT2 (oct_catop_, name) (const octave_base_value& a1, \
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
363 const octave_base_value& a2, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
364 const Array<octave_idx_type>& ra_idx) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
365 { \
28630
35f974bab4c8 fix constness of cat op args
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
366 const CONCAT2 (octave_, t1)& v1 = dynamic_cast<const CONCAT2 (octave_, t1)&> (a1); \
21649
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
367 const CONCAT2 (octave_, t2)& v2 = dynamic_cast<const CONCAT2 (octave_, t2)&> (a2); \
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
368 \
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5307
diff changeset
369 return octave_value (v1.char_array_value () . f (v2.char_array_value (), ra_idx), \
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
370 ((a1.is_sq_string () || a2.is_sq_string ()) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
371 ? '\'' : '"')); \
4915
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4901
diff changeset
372 }
c638c144d4da [project @ 2004-07-23 19:01:22 by jwe]
jwe
parents: 4901
diff changeset
373
5075
b6a9f78f60e9 [project @ 2004-11-10 03:13:26 by jwe]
jwe
parents: 5073
diff changeset
374 // For compatibility, the second arg is always converted to the type
b6a9f78f60e9 [project @ 2004-11-10 03:13:26 by jwe]
jwe
parents: 5073
diff changeset
375 // of the first. Hmm.
b6a9f78f60e9 [project @ 2004-11-10 03:13:26 by jwe]
jwe
parents: 5073
diff changeset
376
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
377 #define DEFNDCATOP_FN2(name, t1, t2, tc1, tc2, e1, e2, f) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
378 static octave_value \
28630
35f974bab4c8 fix constness of cat op args
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
379 CONCAT2 (oct_catop_, name) (const octave_base_value& a1, \
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
380 const octave_base_value& a2, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
381 const Array<octave_idx_type>& ra_idx) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
382 { \
28630
35f974bab4c8 fix constness of cat op args
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
383 const CONCAT2 (octave_, t1)& v1 = dynamic_cast<const CONCAT2 (octave_, t1)&> (a1); \
21649
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
384 const CONCAT2 (octave_, t2)& v2 = dynamic_cast<const CONCAT2 (octave_, t2)&> (a2); \
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
385 \
21649
0822917dfcf5 * ops.h, op-int.h: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 21648
diff changeset
386 return octave_value (tc1 (v1.CONCAT2 (e1, _value) ()) . f (tc2 (v2.CONCAT2 (e2, _value) ()), ra_idx)); \
5075
b6a9f78f60e9 [project @ 2004-11-10 03:13:26 by jwe]
jwe
parents: 5073
diff changeset
387 }
b6a9f78f60e9 [project @ 2004-11-10 03:13:26 by jwe]
jwe
parents: 5073
diff changeset
388
2376
2142216bf85a [project @ 1996-10-12 01:39:07 by jwe]
jwe
parents:
diff changeset
389 #endif