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 #if defined (__GNUG__) |
|
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 |
2376
|
47 static int register_type (const string&); |
|
48 |
|
49 static bool register_binary_op (octave_value::binary_op, int, int, |
2427
|
50 binary_op_fcn); |
2376
|
51 |
2882
|
52 static bool register_assign_op (octave_value::assign_op, int, int, |
|
53 assign_op_fcn); |
2376
|
54 |
3196
|
55 static bool register_assignany_op (octave_value::assign_op, int, |
|
56 assign_op_fcn); |
|
57 |
2376
|
58 static bool register_pref_assign_conv (int, int, int); |
|
59 |
2427
|
60 static bool register_widening_op (int, int, type_conv_fcn); |
2376
|
61 |
2427
|
62 static binary_op_fcn |
2376
|
63 lookup_binary_op (octave_value::binary_op op, int t1, int t2) |
|
64 { |
|
65 return instance->do_lookup_binary_op (op, t1, t2); |
|
66 } |
|
67 |
2427
|
68 static assign_op_fcn |
2882
|
69 lookup_assign_op (octave_value::assign_op op, int t_lhs, int t_rhs) |
2376
|
70 { |
2882
|
71 return instance->do_lookup_assign_op (op, t_lhs, t_rhs); |
2376
|
72 } |
|
73 |
3196
|
74 static assign_op_fcn |
|
75 lookup_assignany_op (octave_value::assign_op op, int t_lhs) |
|
76 { |
|
77 return instance->do_lookup_assignany_op (op, t_lhs); |
|
78 } |
|
79 |
2376
|
80 static int |
|
81 lookup_pref_assign_conv (int t_lhs, int t_rhs) |
|
82 { |
|
83 return instance->do_lookup_pref_assign_conv (t_lhs, t_rhs); |
|
84 } |
|
85 |
2427
|
86 static type_conv_fcn |
2376
|
87 lookup_widening_op (int t, int t_result) |
|
88 { |
|
89 return instance->do_lookup_widening_op (t, t_result); |
|
90 } |
|
91 |
|
92 static string_vector installed_type_names (void) |
|
93 { |
|
94 return instance->do_installed_type_names (); |
|
95 } |
|
96 |
|
97 protected: |
|
98 |
|
99 octave_value_typeinfo (void) |
2479
|
100 : num_types (0), types (init_tab_sz, string ()), |
|
101 binary_ops (octave_value::num_binary_ops, init_tab_sz, |
|
102 init_tab_sz, (binary_op_fcn) 0), |
2882
|
103 assign_ops (octave_value::num_assign_ops, init_tab_sz, |
|
104 init_tab_sz, (assign_op_fcn) 0), |
3196
|
105 assignany_ops (octave_value::num_assign_ops, init_tab_sz, |
|
106 (assign_op_fcn) 0), |
2479
|
107 pref_assign_conv (init_tab_sz, init_tab_sz, -1), |
|
108 widening_ops (init_tab_sz, init_tab_sz, (type_conv_fcn) 0) { } |
2376
|
109 |
|
110 private: |
|
111 |
2479
|
112 static const int init_tab_sz; |
|
113 |
2376
|
114 static octave_value_typeinfo *instance; |
|
115 |
|
116 int num_types; |
|
117 |
|
118 Array<string> types; |
|
119 |
2427
|
120 Array3<binary_op_fcn> binary_ops; |
2376
|
121 |
2882
|
122 Array3<assign_op_fcn> assign_ops; |
2376
|
123 |
3196
|
124 Array2<assign_op_fcn> assignany_ops; |
|
125 |
2376
|
126 Array2<int> pref_assign_conv; |
|
127 |
2427
|
128 Array2<type_conv_fcn> widening_ops; |
2376
|
129 |
|
130 int do_register_type (const string&); |
|
131 |
|
132 bool do_register_binary_op (octave_value::binary_op, int, int, |
2427
|
133 binary_op_fcn); |
2376
|
134 |
2882
|
135 bool do_register_assign_op (octave_value::assign_op, int, int, |
|
136 assign_op_fcn); |
2376
|
137 |
3196
|
138 bool do_register_assignany_op (octave_value::assign_op, int, |
|
139 assign_op_fcn); |
|
140 |
2376
|
141 bool do_register_pref_assign_conv (int, int, int); |
|
142 |
2427
|
143 bool do_register_widening_op (int, int, type_conv_fcn); |
2376
|
144 |
2427
|
145 binary_op_fcn |
2376
|
146 do_lookup_binary_op (octave_value::binary_op, int, int); |
|
147 |
2882
|
148 assign_op_fcn |
|
149 do_lookup_assign_op (octave_value::assign_op, int, int); |
2376
|
150 |
3196
|
151 assign_op_fcn |
|
152 do_lookup_assignany_op (octave_value::assign_op, int); |
|
153 |
2376
|
154 int do_lookup_pref_assign_conv (int, int); |
|
155 |
2427
|
156 type_conv_fcn do_lookup_widening_op (int, int); |
2376
|
157 |
|
158 string_vector do_installed_type_names (void); |
|
159 |
|
160 // No copying! |
|
161 |
|
162 octave_value_typeinfo (const octave_value_typeinfo&); |
|
163 |
|
164 octave_value_typeinfo& operator = (const octave_value_typeinfo&); |
|
165 }; |
|
166 |
|
167 #endif |
|
168 |
|
169 /* |
|
170 ;; Local Variables: *** |
|
171 ;; mode: C++ *** |
|
172 ;; End: *** |
|
173 */ |