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