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 |
2882
|
58 static bool register_assign_op (octave_value::assign_op, int, int, |
|
59 assign_op_fcn); |
2376
|
60 |
3196
|
61 static bool register_assignany_op (octave_value::assign_op, int, |
|
62 assign_op_fcn); |
|
63 |
2376
|
64 static bool register_pref_assign_conv (int, int, int); |
|
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 |
2427
|
92 static assign_op_fcn |
2882
|
93 lookup_assign_op (octave_value::assign_op op, int t_lhs, int t_rhs) |
2376
|
94 { |
2882
|
95 return instance->do_lookup_assign_op (op, t_lhs, t_rhs); |
2376
|
96 } |
|
97 |
3196
|
98 static assign_op_fcn |
|
99 lookup_assignany_op (octave_value::assign_op op, int t_lhs) |
|
100 { |
|
101 return instance->do_lookup_assignany_op (op, t_lhs); |
|
102 } |
|
103 |
2376
|
104 static int |
|
105 lookup_pref_assign_conv (int t_lhs, int t_rhs) |
|
106 { |
|
107 return instance->do_lookup_pref_assign_conv (t_lhs, t_rhs); |
|
108 } |
|
109 |
2427
|
110 static type_conv_fcn |
2376
|
111 lookup_widening_op (int t, int t_result) |
|
112 { |
|
113 return instance->do_lookup_widening_op (t, t_result); |
|
114 } |
|
115 |
|
116 static string_vector installed_type_names (void) |
|
117 { |
|
118 return instance->do_installed_type_names (); |
|
119 } |
|
120 |
|
121 protected: |
|
122 |
|
123 octave_value_typeinfo (void) |
3523
|
124 : num_types (0), types (init_tab_sz, std::string ()), |
3203
|
125 unary_ops (octave_value::num_unary_ops, init_tab_sz, |
|
126 (unary_op_fcn) 0), |
|
127 non_const_unary_ops (octave_value::num_unary_ops, init_tab_sz, |
|
128 (non_const_unary_op_fcn) 0), |
2479
|
129 binary_ops (octave_value::num_binary_ops, init_tab_sz, |
|
130 init_tab_sz, (binary_op_fcn) 0), |
2882
|
131 assign_ops (octave_value::num_assign_ops, init_tab_sz, |
|
132 init_tab_sz, (assign_op_fcn) 0), |
3196
|
133 assignany_ops (octave_value::num_assign_ops, init_tab_sz, |
|
134 (assign_op_fcn) 0), |
2479
|
135 pref_assign_conv (init_tab_sz, init_tab_sz, -1), |
|
136 widening_ops (init_tab_sz, init_tab_sz, (type_conv_fcn) 0) { } |
2376
|
137 |
|
138 private: |
|
139 |
2479
|
140 static const int init_tab_sz; |
|
141 |
2376
|
142 static octave_value_typeinfo *instance; |
|
143 |
|
144 int num_types; |
|
145 |
3523
|
146 Array<std::string> types; |
2376
|
147 |
4640
|
148 Array<octave_value> vals; |
|
149 |
3203
|
150 Array2<unary_op_fcn> unary_ops; |
|
151 |
|
152 Array2<non_const_unary_op_fcn> non_const_unary_ops; |
|
153 |
2427
|
154 Array3<binary_op_fcn> binary_ops; |
2376
|
155 |
2882
|
156 Array3<assign_op_fcn> assign_ops; |
2376
|
157 |
3196
|
158 Array2<assign_op_fcn> assignany_ops; |
|
159 |
2376
|
160 Array2<int> pref_assign_conv; |
|
161 |
2427
|
162 Array2<type_conv_fcn> widening_ops; |
2376
|
163 |
4640
|
164 int do_register_type (const std::string&, const std::string&, |
|
165 const octave_value&); |
2376
|
166 |
3203
|
167 bool do_register_unary_op (octave_value::unary_op, int, unary_op_fcn); |
|
168 |
|
169 bool do_register_non_const_unary_op (octave_value::unary_op, int, |
|
170 non_const_unary_op_fcn); |
|
171 |
2376
|
172 bool do_register_binary_op (octave_value::binary_op, int, int, |
2427
|
173 binary_op_fcn); |
2376
|
174 |
2882
|
175 bool do_register_assign_op (octave_value::assign_op, int, int, |
|
176 assign_op_fcn); |
2376
|
177 |
3196
|
178 bool do_register_assignany_op (octave_value::assign_op, int, |
|
179 assign_op_fcn); |
|
180 |
2376
|
181 bool do_register_pref_assign_conv (int, int, int); |
|
182 |
2427
|
183 bool do_register_widening_op (int, int, type_conv_fcn); |
2376
|
184 |
4640
|
185 octave_value do_lookup_type (const std::string& nm); |
|
186 |
3203
|
187 unary_op_fcn do_lookup_unary_op (octave_value::unary_op, int); |
|
188 |
|
189 non_const_unary_op_fcn do_lookup_non_const_unary_op |
|
190 (octave_value::unary_op, int); |
2376
|
191 |
3203
|
192 binary_op_fcn do_lookup_binary_op (octave_value::binary_op, int, int); |
2376
|
193 |
3203
|
194 assign_op_fcn do_lookup_assign_op (octave_value::assign_op, int, int); |
|
195 |
|
196 assign_op_fcn do_lookup_assignany_op (octave_value::assign_op, int); |
3196
|
197 |
2376
|
198 int do_lookup_pref_assign_conv (int, int); |
|
199 |
2427
|
200 type_conv_fcn do_lookup_widening_op (int, int); |
2376
|
201 |
|
202 string_vector do_installed_type_names (void); |
|
203 |
|
204 // No copying! |
|
205 |
|
206 octave_value_typeinfo (const octave_value_typeinfo&); |
|
207 |
|
208 octave_value_typeinfo& operator = (const octave_value_typeinfo&); |
|
209 }; |
|
210 |
|
211 #endif |
|
212 |
|
213 /* |
|
214 ;; Local Variables: *** |
|
215 ;; mode: C++ *** |
|
216 ;; End: *** |
|
217 */ |