Mercurial > octave-libgccjit
annotate src/defun.cc @ 8575:f134925a1cfa
m-file implementation of help system
author | Soren Hauberg <soren@hauberg.org> |
---|---|
date | Thu, 22 Jan 2009 18:22:52 -0500 |
parents | c3d21b9b94b6 |
children | 5dd06f19e9be |
rev | line source |
---|---|
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 #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, |
4234 | 83 const std::string& doc, bool is_text_fcn, |
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 if (is_text_fcn) | |
7336 | 91 mark_as_command (name); |
2974 | 92 } |
93 | |
3258 | 94 void |
3523 | 95 install_dld_function (octave_dld_function::fcn f, const std::string& name, |
3325 | 96 const octave_shlib& shl, |
6323 | 97 const std::string& doc, bool is_text_fcn, |
98 bool relative) | |
3325 | 99 { |
7336 | 100 octave_dld_function *fcn = new octave_dld_function (f, shl, name, doc); |
6323 | 101 |
102 if (relative) | |
7336 | 103 fcn->mark_relative (); |
6323 | 104 |
7336 | 105 octave_value fval (fcn); |
5397 | 106 |
7336 | 107 symbol_table::install_built_in_function (name, fval); |
5397 | 108 |
7336 | 109 if (is_text_fcn) |
110 mark_as_command (name); | |
3325 | 111 } |
112 | |
113 void | |
5864 | 114 install_mex_function (void *fptr, bool fmex, const std::string& name, |
6323 | 115 const octave_shlib& shl, bool is_text_fcn, |
116 bool relative) | |
5864 | 117 { |
7336 | 118 octave_mex_function *fcn = new octave_mex_function (fptr, fmex, shl, name); |
6323 | 119 |
120 if (relative) | |
7336 | 121 fcn->mark_relative (); |
6323 | 122 |
7336 | 123 octave_value fval (fcn); |
5864 | 124 |
7336 | 125 symbol_table::install_built_in_function (name, fval); |
5864 | 126 |
7336 | 127 if (is_text_fcn) |
128 mark_as_command (name); | |
5864 | 129 } |
130 | |
131 void | |
3523 | 132 alias_builtin (const std::string& alias, const std::string& name) |
2974 | 133 { |
7336 | 134 symbol_table::alias_built_in_function (alias, name); |
2974 | 135 } |
136 | |
137 /* | |
138 ;;; Local Variables: *** | |
139 ;;; mode: C++ *** | |
140 ;;; End: *** | |
141 */ |