Mercurial > hg > octave-nkf
annotate src/defun.cc @ 8920:eb63fbe60fab
update copyright notices
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 07 Mar 2009 10:41:27 -0500 |
parents | 5dd06f19e9be |
children | 5f3c10ecb150 |
rev | line source |
---|---|
2974 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, |
8920 | 4 2006, 2007, 2008, 2009 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 #ifdef HAVE_CONFIG_H | |
25 #include <config.h> | |
26 #endif | |
27 | |
5765 | 28 #include <sstream> |
3503 | 29 #include <iostream> |
3014 | 30 #include <string> |
31 | |
3606 | 32 #include "defun.h" |
3325 | 33 #include "dynamic-ld.h" |
3014 | 34 #include "error.h" |
35 #include "help.h" | |
2974 | 36 #include "ov.h" |
37 #include "ov-builtin.h" | |
3325 | 38 #include "ov-dld-fcn.h" |
5823 | 39 #include "ov-fcn.h" |
5864 | 40 #include "ov-mex-fcn.h" |
5823 | 41 #include "ov-usr-fcn.h" |
3606 | 42 #include "oct-obj.h" |
3014 | 43 #include "pager.h" |
2974 | 44 #include "symtab.h" |
5823 | 45 #include "toplev.h" |
2974 | 46 #include "variables.h" |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
7923
diff
changeset
|
47 #include "parse.h" |
2974 | 48 |
5823 | 49 // Print the usage part of the doc string of FCN (user-defined or DEFUN). |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
7923
diff
changeset
|
50 void |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
7923
diff
changeset
|
51 print_usage (void) |
3014 | 52 { |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
7923
diff
changeset
|
53 const octave_function *cur = octave_call_stack::current (); |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
7923
diff
changeset
|
54 if (cur) |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
7923
diff
changeset
|
55 print_usage (cur->name ()); |
3014 | 56 else |
5823 | 57 error ("print_usage: invalid function"); |
58 } | |
59 | |
60 void | |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
7923
diff
changeset
|
61 print_usage (const std::string& name) |
5823 | 62 { |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
7923
diff
changeset
|
63 feval ("print_usage", octave_value (name), 0); |
5800 | 64 } |
65 | |
3015 | 66 void |
3523 | 67 check_version (const std::string& version, const std::string& fcn) |
3015 | 68 { |
4448 | 69 if (version != OCTAVE_API_VERSION) |
3986 | 70 { |
4448 | 71 error ("API version %s found in .oct file function `%s'\n" |
72 " does not match the running Octave (API version %s)\n" | |
73 " this can lead to incorrect results or other failures\n" | |
74 " you can fix this problem by recompiling this .oct file", | |
75 version.c_str (), fcn.c_str (), OCTAVE_API_VERSION); | |
3986 | 76 } |
3015 | 77 } |
78 | |
2974 | 79 // Install variables and functions in the symbol tables. |
80 | |
81 void | |
3523 | 82 install_builtin_function (octave_builtin::fcn f, const std::string& name, |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
83 const std::string& doc, |
4234 | 84 bool /* can_hide_function -- not yet implemented */) |
2974 | 85 { |
7336 | 86 octave_value fcn (new octave_builtin (f, name, doc)); |
2974 | 87 |
7336 | 88 symbol_table::install_built_in_function (name, fcn); |
2974 | 89 } |
90 | |
3258 | 91 void |
3523 | 92 install_dld_function (octave_dld_function::fcn f, const std::string& name, |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
93 const octave_shlib& shl, const std::string& doc, |
6323 | 94 bool relative) |
3325 | 95 { |
7336 | 96 octave_dld_function *fcn = new octave_dld_function (f, shl, name, doc); |
6323 | 97 |
98 if (relative) | |
7336 | 99 fcn->mark_relative (); |
6323 | 100 |
7336 | 101 octave_value fval (fcn); |
5397 | 102 |
7336 | 103 symbol_table::install_built_in_function (name, fval); |
3325 | 104 } |
105 | |
106 void | |
5864 | 107 install_mex_function (void *fptr, bool fmex, const std::string& name, |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
108 const octave_shlib& shl, bool relative) |
5864 | 109 { |
7336 | 110 octave_mex_function *fcn = new octave_mex_function (fptr, fmex, shl, name); |
6323 | 111 |
112 if (relative) | |
7336 | 113 fcn->mark_relative (); |
6323 | 114 |
7336 | 115 octave_value fval (fcn); |
5864 | 116 |
7336 | 117 symbol_table::install_built_in_function (name, fval); |
5864 | 118 } |
119 | |
120 void | |
3523 | 121 alias_builtin (const std::string& alias, const std::string& name) |
2974 | 122 { |
7336 | 123 symbol_table::alias_built_in_function (alias, name); |
2974 | 124 } |
125 | |
126 /* | |
127 ;;; Local Variables: *** | |
128 ;;; mode: C++ *** | |
129 ;;; End: *** | |
130 */ |