2376
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
2376
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (octave_value_typeinfo_h) |
|
24 #define octave_value_typeinfo_h 1 |
|
25 |
4192
|
26 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) |
2376
|
27 #pragma interface |
|
28 #endif |
|
29 |
|
30 #include <string> |
|
31 |
|
32 #include "Array.h" |
|
33 #include "Array2.h" |
|
34 #include "Array3.h" |
|
35 |
|
36 #include "ov.h" |
|
37 |
|
38 class string_vector; |
|
39 |
|
40 class |
|
41 octave_value_typeinfo |
|
42 { |
|
43 public: |
|
44 |
2926
|
45 static bool instance_ok (void); |
|
46 |
3523
|
47 static int register_type (const std::string&); |
2376
|
48 |
3203
|
49 static bool register_unary_op (octave_value::unary_op, int, unary_op_fcn); |
|
50 |
|
51 static bool register_non_const_unary_op (octave_value::unary_op, int, |
|
52 non_const_unary_op_fcn); |
|
53 |
2376
|
54 static bool register_binary_op (octave_value::binary_op, int, int, |
2427
|
55 binary_op_fcn); |
2376
|
56 |
2882
|
57 static bool register_assign_op (octave_value::assign_op, int, int, |
|
58 assign_op_fcn); |
2376
|
59 |
3196
|
60 static bool register_assignany_op (octave_value::assign_op, int, |
|
61 assign_op_fcn); |
|
62 |
2376
|
63 static bool register_pref_assign_conv (int, int, int); |
|
64 |
2427
|
65 static bool register_widening_op (int, int, type_conv_fcn); |
2376
|
66 |
3203
|
67 static unary_op_fcn |
|
68 lookup_unary_op (octave_value::unary_op op, int t) |
|
69 { |
|
70 return instance->do_lookup_unary_op (op, t); |
|
71 } |
|
72 |
|
73 static non_const_unary_op_fcn |
|
74 lookup_non_const_unary_op (octave_value::unary_op op, int t) |
|
75 { |
|
76 return instance->do_lookup_non_const_unary_op (op, t); |
|
77 } |
|
78 |
2427
|
79 static binary_op_fcn |
2376
|
80 lookup_binary_op (octave_value::binary_op op, int t1, int t2) |
|
81 { |
|
82 return instance->do_lookup_binary_op (op, t1, t2); |
|
83 } |
|
84 |
2427
|
85 static assign_op_fcn |
2882
|
86 lookup_assign_op (octave_value::assign_op op, int t_lhs, int t_rhs) |
2376
|
87 { |
2882
|
88 return instance->do_lookup_assign_op (op, t_lhs, t_rhs); |
2376
|
89 } |
|
90 |
3196
|
91 static assign_op_fcn |
|
92 lookup_assignany_op (octave_value::assign_op op, int t_lhs) |
|
93 { |
|
94 return instance->do_lookup_assignany_op (op, t_lhs); |
|
95 } |
|
96 |
2376
|
97 static int |
|
98 lookup_pref_assign_conv (int t_lhs, int t_rhs) |
|
99 { |
|
100 return instance->do_lookup_pref_assign_conv (t_lhs, t_rhs); |
|
101 } |
|
102 |
2427
|
103 static type_conv_fcn |
2376
|
104 lookup_widening_op (int t, int t_result) |
|
105 { |
|
106 return instance->do_lookup_widening_op (t, t_result); |
|
107 } |
|
108 |
|
109 static string_vector installed_type_names (void) |
|
110 { |
|
111 return instance->do_installed_type_names (); |
|
112 } |
|
113 |
|
114 protected: |
|
115 |
|
116 octave_value_typeinfo (void) |
3523
|
117 : num_types (0), types (init_tab_sz, std::string ()), |
3203
|
118 unary_ops (octave_value::num_unary_ops, init_tab_sz, |
|
119 (unary_op_fcn) 0), |
|
120 non_const_unary_ops (octave_value::num_unary_ops, init_tab_sz, |
|
121 (non_const_unary_op_fcn) 0), |
2479
|
122 binary_ops (octave_value::num_binary_ops, init_tab_sz, |
|
123 init_tab_sz, (binary_op_fcn) 0), |
2882
|
124 assign_ops (octave_value::num_assign_ops, init_tab_sz, |
|
125 init_tab_sz, (assign_op_fcn) 0), |
3196
|
126 assignany_ops (octave_value::num_assign_ops, init_tab_sz, |
|
127 (assign_op_fcn) 0), |
2479
|
128 pref_assign_conv (init_tab_sz, init_tab_sz, -1), |
|
129 widening_ops (init_tab_sz, init_tab_sz, (type_conv_fcn) 0) { } |
2376
|
130 |
|
131 private: |
|
132 |
2479
|
133 static const int init_tab_sz; |
|
134 |
2376
|
135 static octave_value_typeinfo *instance; |
|
136 |
|
137 int num_types; |
|
138 |
3523
|
139 Array<std::string> types; |
2376
|
140 |
3203
|
141 Array2<unary_op_fcn> unary_ops; |
|
142 |
|
143 Array2<non_const_unary_op_fcn> non_const_unary_ops; |
|
144 |
2427
|
145 Array3<binary_op_fcn> binary_ops; |
2376
|
146 |
2882
|
147 Array3<assign_op_fcn> assign_ops; |
2376
|
148 |
3196
|
149 Array2<assign_op_fcn> assignany_ops; |
|
150 |
2376
|
151 Array2<int> pref_assign_conv; |
|
152 |
2427
|
153 Array2<type_conv_fcn> widening_ops; |
2376
|
154 |
3523
|
155 int do_register_type (const std::string&); |
2376
|
156 |
3203
|
157 bool do_register_unary_op (octave_value::unary_op, int, unary_op_fcn); |
|
158 |
|
159 bool do_register_non_const_unary_op (octave_value::unary_op, int, |
|
160 non_const_unary_op_fcn); |
|
161 |
2376
|
162 bool do_register_binary_op (octave_value::binary_op, int, int, |
2427
|
163 binary_op_fcn); |
2376
|
164 |
2882
|
165 bool do_register_assign_op (octave_value::assign_op, int, int, |
|
166 assign_op_fcn); |
2376
|
167 |
3196
|
168 bool do_register_assignany_op (octave_value::assign_op, int, |
|
169 assign_op_fcn); |
|
170 |
2376
|
171 bool do_register_pref_assign_conv (int, int, int); |
|
172 |
2427
|
173 bool do_register_widening_op (int, int, type_conv_fcn); |
2376
|
174 |
3203
|
175 unary_op_fcn do_lookup_unary_op (octave_value::unary_op, int); |
|
176 |
|
177 non_const_unary_op_fcn do_lookup_non_const_unary_op |
|
178 (octave_value::unary_op, int); |
2376
|
179 |
3203
|
180 binary_op_fcn do_lookup_binary_op (octave_value::binary_op, int, int); |
2376
|
181 |
3203
|
182 assign_op_fcn do_lookup_assign_op (octave_value::assign_op, int, int); |
|
183 |
|
184 assign_op_fcn do_lookup_assignany_op (octave_value::assign_op, int); |
3196
|
185 |
2376
|
186 int do_lookup_pref_assign_conv (int, int); |
|
187 |
2427
|
188 type_conv_fcn do_lookup_widening_op (int, int); |
2376
|
189 |
|
190 string_vector do_installed_type_names (void); |
|
191 |
|
192 // No copying! |
|
193 |
|
194 octave_value_typeinfo (const octave_value_typeinfo&); |
|
195 |
|
196 octave_value_typeinfo& operator = (const octave_value_typeinfo&); |
|
197 }; |
|
198 |
|
199 #endif |
|
200 |
|
201 /* |
|
202 ;; Local Variables: *** |
|
203 ;; mode: C++ *** |
|
204 ;; End: *** |
|
205 */ |