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 |
|
26 class symbol_record; |
|
27 class symbol_table; |
1738
|
28 |
490
|
29 class tree_fvc; |
2390
|
30 class tree_identifier; |
|
31 class tree_indirect_ref; |
2086
|
32 class octave_value; |
|
33 class octave_value_list; |
1755
|
34 class string_vector; |
|
35 |
|
36 #include <string> |
1
|
37 |
2390
|
38 #include "ov.h" |
|
39 |
529
|
40 struct builtin_mapper_function; |
|
41 |
|
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 |
|
93 struct builtin_function |
|
94 { |
2856
|
95 builtin_function (const string& n, bool itf, Octave_builtin_fcn f, |
1755
|
96 const string& h) |
|
97 : name (n), is_text_fcn (itf), fcn (f), help_string (h) { } |
|
98 |
|
99 string name; |
2856
|
100 bool is_text_fcn; |
529
|
101 Octave_builtin_fcn fcn; |
1755
|
102 string help_string; |
529
|
103 }; |
195
|
104 |
|
105 extern void initialize_symbol_tables (void); |
|
106 |
2856
|
107 extern bool lookup (symbol_record *s, bool exec_script = true); |
581
|
108 |
2856
|
109 extern symbol_record *lookup_by_name (const string& nm, |
|
110 bool exec_script = true); |
581
|
111 |
2849
|
112 extern octave_value get_global_value (const string& nm); |
|
113 |
|
114 extern void set_global_value (const string& nm, const octave_value& val); |
|
115 |
1755
|
116 extern string get_help_from_file (const string& f); |
991
|
117 |
1755
|
118 extern string builtin_string_variable (const string&); |
|
119 extern int builtin_real_scalar_variable (const string&, double&); |
2086
|
120 extern octave_value builtin_any_variable (const string&); |
593
|
121 |
|
122 extern void link_to_global_variable (symbol_record *sr); |
|
123 extern void link_to_builtin_variable (symbol_record *sr); |
|
124 extern void link_to_builtin_or_function (symbol_record *sr); |
|
125 |
1755
|
126 extern void force_link_to_function (const string&); |
593
|
127 |
1827
|
128 extern bool is_builtin_variable (const string&); |
|
129 extern bool is_text_function_name (const string&); |
2293
|
130 extern bool is_mapper_function_name (const string&); |
|
131 extern bool is_builtin_function_name (const string&); |
1827
|
132 extern bool is_globally_visible (const string&); |
593
|
133 |
2086
|
134 extern tree_fvc *is_valid_function (const octave_value&, const string&, |
2856
|
135 bool warn = false); |
593
|
136 |
2796
|
137 tree_fvc *extract_function (const octave_value& arg, const string& warn_for, |
|
138 const string& fname, const string& header, |
|
139 const string& trailer); |
|
140 |
1755
|
141 extern string_vector make_name_list (void); |
195
|
142 |
1755
|
143 extern void install_builtin_mapper (const builtin_mapper_function& mf); |
195
|
144 |
1755
|
145 extern void install_builtin_function (const builtin_function& gf); |
195
|
146 |
1755
|
147 extern void install_builtin_variable (const builtin_variable& v); |
195
|
148 |
1755
|
149 extern void |
2390
|
150 install_builtin_variable_as_function (const string& name, |
|
151 const octave_value& val, |
2856
|
152 bool protect = false, |
|
153 bool eternal = false, |
2390
|
154 const string& help = string ()); |
1755
|
155 |
|
156 extern void alias_builtin (const string& alias, const string& name); |
548
|
157 |
2856
|
158 extern void bind_ans (const octave_value& val, bool print); |
1162
|
159 |
1489
|
160 extern void bind_global_error_variable (void); |
|
161 |
|
162 extern void clear_global_error_variable (void *); |
|
163 |
2086
|
164 extern void bind_builtin_variable (const string&, const octave_value&, |
2856
|
165 bool protect = false, |
|
166 bool eternal = false, |
1406
|
167 sv_Function f = (sv_Function) 0, |
1755
|
168 const string& help = string ()); |
1406
|
169 |
529
|
170 extern void install_builtin_variables (void); |
|
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 */ |