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