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 { |
2390
|
46 builtin_variable (const string& n, const octave_value& v, int iaf, int p, |
1755
|
47 int e, sv_Function svf, const string& h) |
|
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; |
529
|
53 int install_as_function; |
|
54 int protect; |
|
55 int eternal; |
|
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 |
|
71 void assign (const octave_value&); |
|
72 |
|
73 void assign (const octave_value_list&, const octave_value&); |
|
74 |
|
75 octave_value value (void); |
|
76 |
|
77 private: |
|
78 |
|
79 tree_identifier *id; |
|
80 |
|
81 tree_indirect_ref *indir; |
|
82 |
|
83 // No copying! |
|
84 |
|
85 octave_variable_reference (const octave_variable_reference&); |
|
86 |
|
87 octave_variable_reference& operator = (const octave_variable_reference&); |
|
88 }; |
|
89 |
2086
|
90 typedef octave_value_list (*Octave_builtin_fcn)(const octave_value_list&, int); |
529
|
91 |
|
92 struct builtin_function |
|
93 { |
1755
|
94 builtin_function (const string& n, int itf, Octave_builtin_fcn f, |
|
95 const string& h) |
|
96 : name (n), is_text_fcn (itf), fcn (f), help_string (h) { } |
|
97 |
|
98 string name; |
529
|
99 int is_text_fcn; |
|
100 Octave_builtin_fcn fcn; |
1755
|
101 string help_string; |
529
|
102 }; |
195
|
103 |
|
104 extern void initialize_symbol_tables (void); |
|
105 |
1827
|
106 extern bool lookup (symbol_record *s, int exec_script = 1); |
581
|
107 |
1755
|
108 extern symbol_record *lookup_by_name (const string& nm, int exec_script = 1); |
581
|
109 |
2849
|
110 extern octave_value get_global_value (const string& nm); |
|
111 |
|
112 extern void set_global_value (const string& nm, const octave_value& val); |
|
113 |
1755
|
114 extern string get_help_from_file (const string& f); |
991
|
115 |
1755
|
116 extern string builtin_string_variable (const string&); |
|
117 extern int builtin_real_scalar_variable (const string&, double&); |
2086
|
118 extern octave_value builtin_any_variable (const string&); |
593
|
119 |
|
120 extern void link_to_global_variable (symbol_record *sr); |
|
121 extern void link_to_builtin_variable (symbol_record *sr); |
|
122 extern void link_to_builtin_or_function (symbol_record *sr); |
|
123 |
1755
|
124 extern void force_link_to_function (const string&); |
593
|
125 |
1827
|
126 extern bool is_builtin_variable (const string&); |
|
127 extern bool is_text_function_name (const string&); |
2293
|
128 extern bool is_mapper_function_name (const string&); |
|
129 extern bool is_builtin_function_name (const string&); |
1827
|
130 extern bool is_globally_visible (const string&); |
593
|
131 |
2086
|
132 extern tree_fvc *is_valid_function (const octave_value&, const string&, |
593
|
133 int warn = 0); |
|
134 |
2796
|
135 tree_fvc *extract_function (const octave_value& arg, const string& warn_for, |
|
136 const string& fname, const string& header, |
|
137 const string& trailer); |
|
138 |
1755
|
139 extern string_vector make_name_list (void); |
195
|
140 |
1755
|
141 extern void install_builtin_mapper (const builtin_mapper_function& mf); |
195
|
142 |
1755
|
143 extern void install_builtin_function (const builtin_function& gf); |
195
|
144 |
1755
|
145 extern void install_builtin_variable (const builtin_variable& v); |
195
|
146 |
1755
|
147 extern void |
2390
|
148 install_builtin_variable_as_function (const string& name, |
|
149 const octave_value& val, |
|
150 int protect = 0, int eternal = 0, |
|
151 const string& help = string ()); |
1755
|
152 |
|
153 extern void alias_builtin (const string& alias, const string& name); |
548
|
154 |
2086
|
155 extern void bind_ans (const octave_value& val, int print); |
1162
|
156 |
1489
|
157 extern void bind_global_error_variable (void); |
|
158 |
|
159 extern void clear_global_error_variable (void *); |
|
160 |
2086
|
161 extern void bind_builtin_variable (const string&, const octave_value&, |
1406
|
162 int protect = 0, int eternal = 0, |
|
163 sv_Function f = (sv_Function) 0, |
1755
|
164 const string& help = string ()); |
1406
|
165 |
529
|
166 extern void install_builtin_variables (void); |
|
167 |
1
|
168 // Symbol table for symbols at the top level. |
|
169 extern symbol_table *top_level_sym_tab; |
|
170 |
|
171 // Symbol table for the current scope. |
|
172 extern symbol_table *curr_sym_tab; |
|
173 |
|
174 // Symbol table for global symbols. |
|
175 extern symbol_table *global_sym_tab; |
|
176 |
2204
|
177 enum echo_state |
|
178 { |
|
179 ECHO_OFF = 0, |
|
180 ECHO_SCRIPTS = 1, |
|
181 ECHO_FUNCTIONS = 2, |
|
182 ECHO_CMD_LINE = 4 |
|
183 }; |
|
184 |
|
185 extern int Vecho_executing_commands; |
|
186 |
1
|
187 #endif |
|
188 |
|
189 /* |
|
190 ;;; Local Variables: *** |
|
191 ;;; mode: C++ *** |
|
192 ;;; End: *** |
|
193 */ |