2974
|
1 /* |
|
2 |
|
3 Copyright (C) 1996, 1997 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_builtin_h) |
|
24 #define octave_builtin_h 1 |
|
25 |
|
26 #if defined (__GNUG__) |
|
27 #pragma interface |
|
28 #endif |
|
29 |
|
30 #include <string> |
|
31 |
|
32 #include "ov-fcn.h" |
|
33 #include "ov-typeinfo.h" |
|
34 |
|
35 class octave_value; |
|
36 class octave_value_list; |
|
37 |
|
38 // Builtin functions. |
|
39 |
|
40 class |
|
41 octave_builtin : public octave_function |
|
42 { |
|
43 public: |
|
44 |
|
45 typedef octave_value_list (*fcn) (const octave_value_list&, int); |
|
46 |
|
47 octave_builtin (fcn ff, const string& nm = string (), |
|
48 const string& ds = string ()) |
|
49 : octave_function (nm, ds), f (ff) { } |
|
50 |
|
51 ~octave_builtin (void) { } |
|
52 |
|
53 void *operator new (size_t size) |
|
54 { return allocator.alloc (size); } |
|
55 |
|
56 void operator delete (void *p, size_t size) |
|
57 { allocator.free (p, size); } |
|
58 |
|
59 octave_function *function_value (bool) { return this; } |
|
60 |
|
61 octave_value_list do_index_op (int nargout, const octave_value_list& args); |
|
62 |
|
63 int type_id (void) const { return t_id; } |
|
64 |
|
65 string type_name (void) const { return t_name; } |
|
66 |
|
67 static int static_type_id (void) { return t_id; } |
|
68 |
|
69 static void register_type (void) |
|
70 { t_id = octave_value_typeinfo::register_type (t_name); } |
|
71 |
|
72 private: |
|
73 |
|
74 octave_builtin (void); |
|
75 |
|
76 octave_builtin (const octave_builtin& m); |
|
77 |
|
78 // A pointer to the actual function. |
|
79 fcn f; |
|
80 |
|
81 // For custom memory management. |
|
82 static octave_allocator allocator; |
|
83 |
|
84 // Type id of list objects, set by register_type(). |
|
85 static int t_id; |
|
86 |
|
87 // Type name of list objects, defined in ov-list.cc. |
|
88 static const string t_name; |
|
89 }; |
|
90 |
|
91 #endif |
|
92 |
|
93 /* |
|
94 ;;; Local Variables: *** |
|
95 ;;; mode: C++ *** |
|
96 ;;; End: *** |
|
97 */ |