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 |
5307
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
2376
|
21 |
|
22 */ |
|
23 |
|
24 #if !defined (octave_value_typeinfo_h) |
|
25 #define octave_value_typeinfo_h 1 |
|
26 |
|
27 #include <string> |
|
28 |
|
29 #include "Array.h" |
|
30 #include "Array2.h" |
|
31 #include "Array3.h" |
|
32 |
|
33 #include "ov.h" |
|
34 |
|
35 class string_vector; |
|
36 |
|
37 class |
|
38 octave_value_typeinfo |
|
39 { |
|
40 public: |
|
41 |
2926
|
42 static bool instance_ok (void); |
|
43 |
4640
|
44 static int register_type (const std::string&, const std::string&, |
|
45 const octave_value&); |
2376
|
46 |
3203
|
47 static bool register_unary_op (octave_value::unary_op, int, unary_op_fcn); |
|
48 |
|
49 static bool register_non_const_unary_op (octave_value::unary_op, int, |
|
50 non_const_unary_op_fcn); |
|
51 |
2376
|
52 static bool register_binary_op (octave_value::binary_op, int, int, |
2427
|
53 binary_op_fcn); |
2376
|
54 |
4915
|
55 static bool register_cat_op (int, int, cat_op_fcn); |
|
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 |
4901
|
65 static bool register_type_conv_op (int, int, type_conv_fcn); |
|
66 |
2427
|
67 static bool register_widening_op (int, int, type_conv_fcn); |
2376
|
68 |
4640
|
69 static octave_value |
|
70 lookup_type (const std::string& nm) |
|
71 { |
|
72 return instance->do_lookup_type (nm); |
|
73 } |
|
74 |
3203
|
75 static unary_op_fcn |
|
76 lookup_unary_op (octave_value::unary_op op, int t) |
|
77 { |
|
78 return instance->do_lookup_unary_op (op, t); |
|
79 } |
|
80 |
|
81 static non_const_unary_op_fcn |
|
82 lookup_non_const_unary_op (octave_value::unary_op op, int t) |
|
83 { |
|
84 return instance->do_lookup_non_const_unary_op (op, t); |
|
85 } |
|
86 |
2427
|
87 static binary_op_fcn |
2376
|
88 lookup_binary_op (octave_value::binary_op op, int t1, int t2) |
|
89 { |
|
90 return instance->do_lookup_binary_op (op, t1, t2); |
|
91 } |
|
92 |
4915
|
93 static cat_op_fcn |
|
94 lookup_cat_op (int t1, int t2) |
|
95 { |
|
96 return instance->do_lookup_cat_op (t1, t2); |
|
97 } |
|
98 |
2427
|
99 static assign_op_fcn |
2882
|
100 lookup_assign_op (octave_value::assign_op op, int t_lhs, int t_rhs) |
2376
|
101 { |
2882
|
102 return instance->do_lookup_assign_op (op, t_lhs, t_rhs); |
2376
|
103 } |
|
104 |
3196
|
105 static assign_op_fcn |
|
106 lookup_assignany_op (octave_value::assign_op op, int t_lhs) |
|
107 { |
|
108 return instance->do_lookup_assignany_op (op, t_lhs); |
|
109 } |
|
110 |
2376
|
111 static int |
|
112 lookup_pref_assign_conv (int t_lhs, int t_rhs) |
|
113 { |
|
114 return instance->do_lookup_pref_assign_conv (t_lhs, t_rhs); |
|
115 } |
|
116 |
2427
|
117 static type_conv_fcn |
4901
|
118 lookup_type_conv_op (int t, int t_result) |
|
119 { |
|
120 return instance->do_lookup_type_conv_op (t, t_result); |
|
121 } |
|
122 |
|
123 static type_conv_fcn |
2376
|
124 lookup_widening_op (int t, int t_result) |
|
125 { |
|
126 return instance->do_lookup_widening_op (t, t_result); |
|
127 } |
|
128 |
|
129 static string_vector installed_type_names (void) |
|
130 { |
|
131 return instance->do_installed_type_names (); |
|
132 } |
|
133 |
|
134 protected: |
|
135 |
|
136 octave_value_typeinfo (void) |
3523
|
137 : num_types (0), types (init_tab_sz, std::string ()), |
4645
|
138 vals (init_tab_sz), |
3203
|
139 unary_ops (octave_value::num_unary_ops, init_tab_sz, |
|
140 (unary_op_fcn) 0), |
|
141 non_const_unary_ops (octave_value::num_unary_ops, init_tab_sz, |
|
142 (non_const_unary_op_fcn) 0), |
2479
|
143 binary_ops (octave_value::num_binary_ops, init_tab_sz, |
|
144 init_tab_sz, (binary_op_fcn) 0), |
4915
|
145 cat_ops (init_tab_sz, init_tab_sz, (cat_op_fcn) 0), |
2882
|
146 assign_ops (octave_value::num_assign_ops, init_tab_sz, |
|
147 init_tab_sz, (assign_op_fcn) 0), |
3196
|
148 assignany_ops (octave_value::num_assign_ops, init_tab_sz, |
|
149 (assign_op_fcn) 0), |
2479
|
150 pref_assign_conv (init_tab_sz, init_tab_sz, -1), |
4901
|
151 type_conv_ops (init_tab_sz, init_tab_sz, (type_conv_fcn) 0), |
2479
|
152 widening_ops (init_tab_sz, init_tab_sz, (type_conv_fcn) 0) { } |
2376
|
153 |
|
154 private: |
|
155 |
2479
|
156 static const int init_tab_sz; |
|
157 |
2376
|
158 static octave_value_typeinfo *instance; |
|
159 |
|
160 int num_types; |
|
161 |
3523
|
162 Array<std::string> types; |
2376
|
163 |
4640
|
164 Array<octave_value> vals; |
|
165 |
3203
|
166 Array2<unary_op_fcn> unary_ops; |
|
167 |
|
168 Array2<non_const_unary_op_fcn> non_const_unary_ops; |
|
169 |
2427
|
170 Array3<binary_op_fcn> binary_ops; |
2376
|
171 |
4915
|
172 Array2<cat_op_fcn> cat_ops; |
|
173 |
2882
|
174 Array3<assign_op_fcn> assign_ops; |
2376
|
175 |
3196
|
176 Array2<assign_op_fcn> assignany_ops; |
|
177 |
2376
|
178 Array2<int> pref_assign_conv; |
|
179 |
4901
|
180 Array2<type_conv_fcn> type_conv_ops; |
|
181 |
2427
|
182 Array2<type_conv_fcn> widening_ops; |
2376
|
183 |
4640
|
184 int do_register_type (const std::string&, const std::string&, |
|
185 const octave_value&); |
2376
|
186 |
3203
|
187 bool do_register_unary_op (octave_value::unary_op, int, unary_op_fcn); |
|
188 |
|
189 bool do_register_non_const_unary_op (octave_value::unary_op, int, |
|
190 non_const_unary_op_fcn); |
|
191 |
2376
|
192 bool do_register_binary_op (octave_value::binary_op, int, int, |
2427
|
193 binary_op_fcn); |
2376
|
194 |
4915
|
195 bool do_register_cat_op (int, int, cat_op_fcn); |
|
196 |
2882
|
197 bool do_register_assign_op (octave_value::assign_op, int, int, |
|
198 assign_op_fcn); |
2376
|
199 |
3196
|
200 bool do_register_assignany_op (octave_value::assign_op, int, |
|
201 assign_op_fcn); |
|
202 |
2376
|
203 bool do_register_pref_assign_conv (int, int, int); |
|
204 |
4901
|
205 bool do_register_type_conv_op (int, int, type_conv_fcn); |
|
206 |
2427
|
207 bool do_register_widening_op (int, int, type_conv_fcn); |
2376
|
208 |
4640
|
209 octave_value do_lookup_type (const std::string& nm); |
|
210 |
3203
|
211 unary_op_fcn do_lookup_unary_op (octave_value::unary_op, int); |
|
212 |
|
213 non_const_unary_op_fcn do_lookup_non_const_unary_op |
|
214 (octave_value::unary_op, int); |
2376
|
215 |
3203
|
216 binary_op_fcn do_lookup_binary_op (octave_value::binary_op, int, int); |
2376
|
217 |
4915
|
218 cat_op_fcn do_lookup_cat_op (int, int); |
|
219 |
3203
|
220 assign_op_fcn do_lookup_assign_op (octave_value::assign_op, int, int); |
|
221 |
|
222 assign_op_fcn do_lookup_assignany_op (octave_value::assign_op, int); |
3196
|
223 |
2376
|
224 int do_lookup_pref_assign_conv (int, int); |
|
225 |
4901
|
226 type_conv_fcn do_lookup_type_conv_op (int, int); |
|
227 |
2427
|
228 type_conv_fcn do_lookup_widening_op (int, int); |
2376
|
229 |
|
230 string_vector do_installed_type_names (void); |
|
231 |
|
232 // No copying! |
|
233 |
|
234 octave_value_typeinfo (const octave_value_typeinfo&); |
|
235 |
|
236 octave_value_typeinfo& operator = (const octave_value_typeinfo&); |
|
237 }; |
|
238 |
|
239 #endif |
|
240 |
|
241 /* |
|
242 ;; Local Variables: *** |
|
243 ;; mode: C++ *** |
|
244 ;; End: *** |
|
245 */ |