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