1
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
1
|
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 |
1315
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
1
|
20 |
|
21 */ |
|
22 |
383
|
23 #if !defined (octave_variables_h) |
|
24 #define octave_variables_h 1 |
1
|
25 |
2892
|
26 class octave_symbol; |
1
|
27 class symbol_record; |
|
28 class symbol_table; |
1738
|
29 |
2390
|
30 class tree_identifier; |
|
31 class tree_indirect_ref; |
2086
|
32 class octave_value; |
|
33 class octave_value_list; |
2892
|
34 class octave_builtin; |
|
35 class octave_mapper; |
1755
|
36 class string_vector; |
|
37 |
|
38 #include <string> |
1
|
39 |
2390
|
40 #include "ov.h" |
|
41 |
529
|
42 typedef int (*sv_Function)(void); |
195
|
43 |
529
|
44 struct builtin_variable |
|
45 { |
2856
|
46 builtin_variable (const string& n, const octave_value& v, bool iaf, |
|
47 bool p, bool e, sv_Function svf, const string& h) |
1755
|
48 : name (n), value (v), install_as_function (iaf), protect (p), |
|
49 eternal (e), sv_function (svf), help_string (h) { } |
|
50 |
|
51 string name; |
2390
|
52 octave_value value; |
2856
|
53 bool install_as_function; |
|
54 bool protect; |
|
55 bool eternal; |
529
|
56 sv_Function sv_function; |
1755
|
57 string help_string; |
529
|
58 }; |
|
59 |
2390
|
60 class |
|
61 octave_variable_reference |
|
62 { |
|
63 public: |
|
64 |
|
65 octave_variable_reference (tree_identifier *i) : id (i), indir (0) { } |
|
66 |
|
67 octave_variable_reference (tree_indirect_ref *i); |
|
68 |
|
69 ~octave_variable_reference (void) { } |
|
70 |
2878
|
71 void assign (octave_value::assign_op, const octave_value&); |
2390
|
72 |
2878
|
73 void assign (octave_value::assign_op, const octave_value_list&, |
|
74 const octave_value&); |
2390
|
75 |
|
76 octave_value value (void); |
|
77 |
|
78 private: |
|
79 |
|
80 tree_identifier *id; |
|
81 |
|
82 tree_indirect_ref *indir; |
|
83 |
|
84 // No copying! |
|
85 |
|
86 octave_variable_reference (const octave_variable_reference&); |
|
87 |
|
88 octave_variable_reference& operator = (const octave_variable_reference&); |
|
89 }; |
|
90 |
2086
|
91 typedef octave_value_list (*Octave_builtin_fcn)(const octave_value_list&, int); |
529
|
92 |
195
|
93 extern void initialize_symbol_tables (void); |
|
94 |
2856
|
95 extern bool lookup (symbol_record *s, bool exec_script = true); |
581
|
96 |
2856
|
97 extern symbol_record *lookup_by_name (const string& nm, |
|
98 bool exec_script = true); |
581
|
99 |
2849
|
100 extern octave_value get_global_value (const string& nm); |
|
101 |
|
102 extern void set_global_value (const string& nm, const octave_value& val); |
|
103 |
1755
|
104 extern string get_help_from_file (const string& f); |
991
|
105 |
1755
|
106 extern string builtin_string_variable (const string&); |
|
107 extern int builtin_real_scalar_variable (const string&, double&); |
2086
|
108 extern octave_value builtin_any_variable (const string&); |
593
|
109 |
|
110 extern void link_to_global_variable (symbol_record *sr); |
|
111 extern void link_to_builtin_variable (symbol_record *sr); |
|
112 extern void link_to_builtin_or_function (symbol_record *sr); |
|
113 |
1755
|
114 extern void force_link_to_function (const string&); |
593
|
115 |
1827
|
116 extern bool is_builtin_variable (const string&); |
|
117 extern bool is_text_function_name (const string&); |
2293
|
118 extern bool is_mapper_function_name (const string&); |
|
119 extern bool is_builtin_function_name (const string&); |
1827
|
120 extern bool is_globally_visible (const string&); |
593
|
121 |
2892
|
122 extern octave_symbol * |
|
123 is_valid_function (const octave_value&, const string&, bool warn = false); |
593
|
124 |
2921
|
125 extern octave_symbol * |
2892
|
126 extract_function (const octave_value& arg, const string& warn_for, |
|
127 const string& fname, const string& header, |
|
128 const string& trailer); |
2796
|
129 |
2921
|
130 extern string_vector |
|
131 get_struct_elts (const string& text); |
|
132 |
|
133 extern bool |
|
134 looks_like_struct (const string& text); |
|
135 |
|
136 extern string_vector |
|
137 generate_struct_completions (const string& text, string& prefix, |
|
138 string& hint); |
|
139 |
1755
|
140 extern string_vector make_name_list (void); |
195
|
141 |
2892
|
142 extern void |
|
143 install_builtin_mapper (octave_mapper *mf); |
195
|
144 |
2892
|
145 extern void |
|
146 install_builtin_function (octave_builtin *f, bool is_text_fcn = false); |
195
|
147 |
2892
|
148 extern void |
|
149 install_builtin_variable (const builtin_variable& v); |
195
|
150 |
1755
|
151 extern void |
2390
|
152 install_builtin_variable_as_function (const string& name, |
|
153 const octave_value& val, |
2856
|
154 bool protect = false, |
|
155 bool eternal = false, |
2390
|
156 const string& help = string ()); |
1755
|
157 |
|
158 extern void alias_builtin (const string& alias, const string& name); |
548
|
159 |
2856
|
160 extern void bind_ans (const octave_value& val, bool print); |
1162
|
161 |
1489
|
162 extern void bind_global_error_variable (void); |
|
163 |
|
164 extern void clear_global_error_variable (void *); |
|
165 |
2892
|
166 extern void |
|
167 bind_builtin_variable (const string&, const octave_value&, |
|
168 bool protect = false, bool eternal = false, |
|
169 sv_Function f = (sv_Function) 0, |
|
170 const string& help = string ()); |
1406
|
171 |
1
|
172 // Symbol table for symbols at the top level. |
|
173 extern symbol_table *top_level_sym_tab; |
|
174 |
|
175 // Symbol table for the current scope. |
|
176 extern symbol_table *curr_sym_tab; |
|
177 |
|
178 // Symbol table for global symbols. |
|
179 extern symbol_table *global_sym_tab; |
|
180 |
2204
|
181 enum echo_state |
|
182 { |
|
183 ECHO_OFF = 0, |
|
184 ECHO_SCRIPTS = 1, |
|
185 ECHO_FUNCTIONS = 2, |
|
186 ECHO_CMD_LINE = 4 |
|
187 }; |
|
188 |
|
189 extern int Vecho_executing_commands; |
|
190 |
1
|
191 #endif |
|
192 |
|
193 /* |
|
194 ;;; Local Variables: *** |
|
195 ;;; mode: C++ *** |
|
196 ;;; End: *** |
|
197 */ |