Mercurial > hg > octave-lyh
annotate src/ov-builtin.h @ 9151:d8f9588c6ba1
object exemplars
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 23 Apr 2009 16:05:52 -0400 |
parents | eb63fbe60fab |
children | 84b0725f4b09 |
rev | line source |
---|---|
2974 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, |
8920 | 4 2007, 2008 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_builtin_h) | |
25 #define octave_builtin_h 1 | |
26 | |
27 #include <string> | |
28 | |
29 #include "ov-fcn.h" | |
30 #include "ov-typeinfo.h" | |
31 | |
32 class octave_value; | |
33 class octave_value_list; | |
34 | |
35 // Builtin functions. | |
36 | |
37 class | |
7349 | 38 OCTINTERP_API |
2974 | 39 octave_builtin : public octave_function |
40 { | |
41 public: | |
42 | |
4645 | 43 octave_builtin (void) { } |
4642 | 44 |
2974 | 45 typedef octave_value_list (*fcn) (const octave_value_list&, int); |
46 | |
3523 | 47 octave_builtin (fcn ff, const std::string& nm = std::string (), |
48 const std::string& ds = std::string ()) | |
2974 | 49 : octave_function (nm, ds), f (ff) { } |
50 | |
51 ~octave_builtin (void) { } | |
52 | |
7651
443a8f5a50fd
require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents:
7349
diff
changeset
|
53 octave_value subsref (const std::string& type, |
443a8f5a50fd
require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents:
7349
diff
changeset
|
54 const std::list<octave_value_list>& idx) |
4271 | 55 { |
7651
443a8f5a50fd
require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents:
7349
diff
changeset
|
56 octave_value_list tmp = subsref (type, idx, 1); |
443a8f5a50fd
require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents:
7349
diff
changeset
|
57 return tmp.length () > 0 ? tmp(0) : octave_value (); |
4271 | 58 } |
59 | |
4247 | 60 octave_value_list subsref (const std::string& type, |
4219 | 61 const std::list<octave_value_list>& idx, |
3933 | 62 int nargout); |
63 | |
4654 | 64 octave_function *function_value (bool = false) { return this; } |
2974 | 65 |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
66 const octave_function *function_value (bool = false) const { return this; } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
67 |
3325 | 68 bool is_builtin_function (void) const { return true; } |
69 | |
3544 | 70 octave_value_list |
71 do_multi_index_op (int nargout, const octave_value_list& args); | |
2974 | 72 |
3325 | 73 protected: |
74 | |
75 // A pointer to the actual function. | |
76 fcn f; | |
77 | |
2974 | 78 private: |
79 | |
4645 | 80 // No copying! |
81 | |
82 octave_builtin (const octave_builtin& ob); | |
83 | |
84 octave_builtin& operator = (const octave_builtin& ob); | |
2974 | 85 |
4612 | 86 DECLARE_OCTAVE_ALLOCATOR |
2974 | 87 |
4612 | 88 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
2974 | 89 }; |
90 | |
91 #endif | |
92 | |
93 /* | |
94 ;;; Local Variables: *** | |
95 ;;; mode: C++ *** | |
96 ;;; End: *** | |
97 */ |