2974
|
1 /* |
|
2 |
7017
|
3 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, |
|
4 2006, 2007 John W. Eaton |
2974
|
5 |
|
6 This file is part of Octave. |
|
7 |
|
8 Octave is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published by the |
7016
|
10 Free Software Foundation; either version 3 of the License, or (at your |
|
11 option) any later version. |
2974
|
12 |
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
7016
|
19 along with Octave; see the file COPYING. If not, see |
|
20 <http://www.gnu.org/licenses/>. |
2974
|
21 |
|
22 */ |
|
23 |
|
24 #if !defined (octave_function_h) |
|
25 #define octave_function_h 1 |
|
26 |
|
27 #include <string> |
|
28 |
3258
|
29 #include "oct-time.h" |
3325
|
30 #include "str-vec.h" |
3258
|
31 |
2974
|
32 #include "oct-alloc.h" |
4748
|
33 #include "oct-obj.h" |
2974
|
34 #include "ov-base.h" |
|
35 #include "ov-typeinfo.h" |
7336
|
36 #include "symtab.h" |
2974
|
37 |
2976
|
38 class tree_walker; |
|
39 |
2974
|
40 // Functions. |
|
41 |
|
42 class |
6109
|
43 OCTINTERP_API |
2974
|
44 octave_function : public octave_base_value |
|
45 { |
|
46 public: |
|
47 |
4645
|
48 octave_function (void) { } |
2974
|
49 |
|
50 ~octave_function (void) { } |
|
51 |
5759
|
52 octave_base_value *clone (void) const; |
|
53 octave_base_value *empty_clone (void) const; |
2974
|
54 |
|
55 bool is_defined (void) const { return true; } |
|
56 |
|
57 bool is_function (void) const { return true; } |
|
58 |
3325
|
59 virtual bool is_dynamically_loaded_function (void) const { return false; } |
|
60 |
3544
|
61 virtual bool is_system_fcn_file (void) const { return false; } |
2974
|
62 |
3523
|
63 virtual std::string fcn_file_name (void) const { return std::string (); } |
2974
|
64 |
6323
|
65 virtual std::string parent_fcn_name (void) const { return std::string (); } |
|
66 |
3255
|
67 virtual void mark_fcn_file_up_to_date (const octave_time&) { } |
3166
|
68 |
7336
|
69 virtual symbol_table::scope_id scope (void) { return -1; } |
|
70 |
3255
|
71 virtual octave_time time_parsed (void) const |
|
72 { return octave_time (static_cast<time_t> (0)); } |
2974
|
73 |
3255
|
74 virtual octave_time time_checked (void) const |
|
75 { return octave_time (static_cast<time_t> (0)); } |
3166
|
76 |
4343
|
77 virtual bool is_nested_function (void) const { return false; } |
|
78 |
7336
|
79 virtual bool is_class_constructor (void) const { return false; } |
5744
|
80 |
7336
|
81 virtual bool is_class_method (void) const { return false; } |
|
82 |
|
83 virtual std::string dispatch_class (void) const { return std::string (); } |
4748
|
84 |
|
85 virtual bool takes_varargs (void) const { return false; } |
|
86 |
|
87 virtual bool takes_var_return (void) const { return false; } |
|
88 |
7336
|
89 std::string dir_name (void) const { return my_dir_name; } |
|
90 |
|
91 void stash_dir_name (const std::string& dir) { my_dir_name = dir; } |
|
92 |
|
93 void lock (void) { locked = true; } |
|
94 |
|
95 void unlock (void) { locked = false; } |
|
96 |
|
97 bool islocked (void) { return locked; } |
|
98 |
6323
|
99 void mark_relative (void) { relative = true; } |
|
100 |
|
101 bool is_relative (void) const { return relative; } |
|
102 |
3523
|
103 std::string name (void) const { return my_name; } |
2974
|
104 |
5823
|
105 void document (const std::string& ds) { doc = ds; } |
|
106 |
3523
|
107 std::string doc_string (void) const { return doc; } |
2974
|
108 |
3325
|
109 virtual void unload (void) { } |
|
110 |
2976
|
111 virtual void accept (tree_walker&) { } |
|
112 |
2974
|
113 protected: |
|
114 |
5864
|
115 octave_function (const std::string& nm, |
|
116 const std::string& ds = std::string ()) |
6323
|
117 : relative (false), my_name (nm), doc (ds) { } |
|
118 |
|
119 // TRUE if this function was found from a relative path element. |
|
120 bool relative; |
2974
|
121 |
7336
|
122 // TRUE if this function is tagged so that it can't be cleared. |
|
123 bool locked; |
|
124 |
2974
|
125 // The name of this function. |
3523
|
126 std::string my_name; |
2974
|
127 |
7336
|
128 // The name of the directory in the path where we found this |
|
129 // function. May be relative. |
|
130 std::string my_dir_name; |
|
131 |
2974
|
132 // The help text for this function. |
3523
|
133 std::string doc; |
2974
|
134 |
3325
|
135 private: |
|
136 |
4645
|
137 // No copying! |
|
138 |
|
139 octave_function (const octave_function& f); |
|
140 |
|
141 octave_function& operator = (const octave_function& f); |
|
142 |
3219
|
143 DECLARE_OCTAVE_ALLOCATOR |
2974
|
144 }; |
|
145 |
|
146 #endif |
|
147 |
|
148 /* |
6705
|
149 ;;; Local Variables: *** |
|
150 ;;; mode: C++ *** |
|
151 ;;; End: *** |
2974
|
152 */ |