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