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