4343
|
1 /* |
|
2 |
|
3 Copyright (C) 2003 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_fcn_handle_h) |
|
24 #define octave_fcn_handle_h 1 |
|
25 |
|
26 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) |
|
27 #pragma interface |
|
28 #endif |
|
29 |
|
30 #include <iostream> |
|
31 #include <string> |
|
32 |
|
33 #include "oct-alloc.h" |
|
34 |
|
35 #include "ov-base.h" |
4654
|
36 #include "ov-base-mat.h" |
4343
|
37 #include "ov-fcn.h" |
4654
|
38 #include "ov-typeinfo.h" |
4343
|
39 #include "symtab.h" |
|
40 |
|
41 // Function handles. |
|
42 |
4925
|
43 class |
|
44 octave_fcn_handle : public octave_base_value |
4654
|
45 { |
|
46 public: |
|
47 |
4925
|
48 octave_fcn_handle (void) : fcn (0), nm () { } |
4654
|
49 |
|
50 octave_fcn_handle (octave_function *f, const std::string& n) |
4925
|
51 : fcn (f), nm (n) { } |
4654
|
52 |
|
53 ~octave_fcn_handle (void) { } |
|
54 |
4924
|
55 octave_value subsref (const std::string&, |
|
56 const std::list<octave_value_list>&) |
|
57 { |
|
58 panic_impossible (); |
|
59 return octave_value (); |
|
60 } |
|
61 |
|
62 octave_value_list subsref (const std::string& type, |
|
63 const std::list<octave_value_list>& idx, |
|
64 int nargout); |
|
65 |
4925
|
66 bool is_defined (void) const { return true; } |
4654
|
67 |
|
68 bool is_function_handle (void) const { return true; } |
|
69 |
4925
|
70 octave_function *function_value (bool = false) { return fcn; } |
4654
|
71 |
4925
|
72 std::string name (void) const { return nm; } |
4654
|
73 |
|
74 octave_fcn_handle *fcn_handle_value (bool = false) { return this; } |
|
75 |
|
76 void print (std::ostream& os, bool pr_as_read_syntax = false) const; |
|
77 |
|
78 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; |
|
79 |
|
80 private: |
4343
|
81 |
4925
|
82 // No copying! |
|
83 |
|
84 octave_fcn_handle (const octave_fcn_handle& fh); |
|
85 |
|
86 octave_fcn_handle& operator = (const octave_fcn_handle& fh); |
|
87 |
4612
|
88 DECLARE_OCTAVE_ALLOCATOR |
4343
|
89 |
4612
|
90 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
4925
|
91 |
|
92 // The function we are handling. |
|
93 octave_function *fcn; |
|
94 |
|
95 // The name of the handle, including the "@". |
|
96 std::string nm; |
4343
|
97 }; |
|
98 |
|
99 extern octave_value make_fcn_handle (const std::string& nm); |
|
100 |
|
101 #endif |
|
102 |
|
103 /* |
|
104 ;;; Local Variables: *** |
|
105 ;;; mode: C++ *** |
|
106 ;;; End: *** |
|
107 */ |