Mercurial > hg > octave-lyh
annotate src/defun-int.h @ 10687:a8ce6bdecce5
Improve documentation strings.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Tue, 08 Jun 2010 20:22:38 -0700 |
parents | ed6969880316 |
children | f10d0bc8f9cc |
rev | line source |
---|---|
525 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, |
8920 | 4 2003, 2004, 2005, 2006, 2007, 2008, 2009 John W. Eaton |
525 | 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. | |
525 | 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/>. | |
525 | 21 |
22 */ | |
23 | |
24 #if !defined (octave_defun_int_h) | |
25 #define octave_defun_int_h 1 | |
26 | |
2968 | 27 #include <string> |
28 | |
3145 | 29 #include "ov-builtin.h" |
3325 | 30 #include "ov-dld-fcn.h" |
3145 | 31 #include "symtab.h" |
3015 | 32 #include "version.h" |
33 | |
2968 | 34 class octave_value; |
35 | |
6109 | 36 extern OCTINTERP_API void print_usage (void); |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
7996
diff
changeset
|
37 extern OCTINTERP_API void print_usage (const std::string&); |
3014 | 38 |
6109 | 39 extern OCTINTERP_API void check_version (const std::string& version, const std::string& fcn); |
3015 | 40 |
6109 | 41 extern OCTINTERP_API void |
3523 | 42 install_builtin_function (octave_builtin::fcn f, const std::string& name, |
10313 | 43 const std::string& doc, |
44 bool can_hide_function = true); | |
2968 | 45 |
6109 | 46 extern OCTINTERP_API void |
3523 | 47 install_dld_function (octave_dld_function::fcn f, const std::string& name, |
10313 | 48 const octave_shlib& shl, const std::string& doc, |
49 bool relative = false); | |
703 | 50 |
6109 | 51 extern OCTINTERP_API void |
5864 | 52 install_mex_function (void *fptr, bool fmex, const std::string& name, |
10313 | 53 const octave_shlib& shl, bool relative = false); |
5864 | 54 |
6109 | 55 extern OCTINTERP_API void |
3523 | 56 alias_builtin (const std::string& alias, const std::string& name); |
703 | 57 |
9960
5f3c10ecb150
implement get_current_shlib and octave_auto_shlib
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
58 // Gets the shlib of the currently executing DLD function, if any. |
5f3c10ecb150
implement get_current_shlib and octave_auto_shlib
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
59 extern OCTINTERP_API octave_shlib |
5f3c10ecb150
implement get_current_shlib and octave_auto_shlib
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
60 get_current_shlib (void); |
5f3c10ecb150
implement get_current_shlib and octave_auto_shlib
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
61 |
5f3c10ecb150
implement get_current_shlib and octave_auto_shlib
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
62 // This is a convenience class that calls the above function automatically at |
5f3c10ecb150
implement get_current_shlib and octave_auto_shlib
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
63 // construction time. When deriving new classes, you can either use it as a field |
5f3c10ecb150
implement get_current_shlib and octave_auto_shlib
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
64 // or as a parent (with multiple inheritance). |
5f3c10ecb150
implement get_current_shlib and octave_auto_shlib
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
65 |
5f3c10ecb150
implement get_current_shlib and octave_auto_shlib
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
66 class octave_auto_shlib : public octave_shlib |
5f3c10ecb150
implement get_current_shlib and octave_auto_shlib
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
67 { |
10641
ed6969880316
preliminary onCleanup support
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
68 public: |
9960
5f3c10ecb150
implement get_current_shlib and octave_auto_shlib
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
69 octave_auto_shlib (void) |
5f3c10ecb150
implement get_current_shlib and octave_auto_shlib
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
70 : octave_shlib (get_current_shlib ()) { } |
5f3c10ecb150
implement get_current_shlib and octave_auto_shlib
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
71 octave_auto_shlib (const octave_shlib& shl) |
5f3c10ecb150
implement get_current_shlib and octave_auto_shlib
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
72 : octave_shlib (shl) { } |
5f3c10ecb150
implement get_current_shlib and octave_auto_shlib
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
73 }; |
5f3c10ecb150
implement get_current_shlib and octave_auto_shlib
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
74 |
3743 | 75 #define DECLARE_FUNX(name, args_name, nargout_name) \ |
6109 | 76 OCTAVE_EXPORT octave_value_list \ |
3743 | 77 name (const octave_value_list& args_name, int nargout_name) |
78 | |
79 #define DECLARE_FUN(name, args_name, nargout_name) \ | |
80 DECLARE_FUNX (F ## name, args_name, nargout_name) | |
2968 | 81 |
3325 | 82 // Define the code that will be used to insert the new function into |
83 // the symbol table. We look for this name instead of the actual | |
3523 | 84 // function so that we can easily install the doc std::string too. |
3325 | 85 |
6323 | 86 typedef bool (*octave_dld_fcn_installer) (const octave_shlib&, bool relative); |
3325 | 87 |
7336 | 88 typedef octave_function * (*octave_dld_fcn_getter) (const octave_shlib&, bool relative); |
89 | |
3325 | 90 #define DEFINE_FUN_INSTALLER_FUN(name, doc) \ |
7996
6a7db240b3a3
configure.in: eliminate CXX_ABI and OCTAVE_CXX_PREPEND_UNDERSCORE
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
91 DEFINE_FUNX_INSTALLER_FUN(#name, F ## name, G ## name, doc) |
5796 | 92 |
7996
6a7db240b3a3
configure.in: eliminate CXX_ABI and OCTAVE_CXX_PREPEND_UNDERSCORE
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
93 #define DEFINE_FUNX_INSTALLER_FUN(name, fname, gname, doc) \ |
7336 | 94 extern "C" \ |
95 OCTAVE_EXPORT \ | |
96 octave_function * \ | |
7996
6a7db240b3a3
configure.in: eliminate CXX_ABI and OCTAVE_CXX_PREPEND_UNDERSCORE
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
97 gname (const octave_shlib& shl, bool relative) \ |
7336 | 98 { \ |
99 octave_function *retval = 0; \ | |
100 \ | |
101 check_version (OCTAVE_API_VERSION, name); \ | |
102 \ | |
103 if (! error_state) \ | |
104 { \ | |
10313 | 105 octave_dld_function *fcn = octave_dld_function::create (fname, shl, name, doc); \ |
7336 | 106 \ |
107 if (relative) \ | |
108 fcn->mark_relative (); \ | |
109 \ | |
110 retval = fcn; \ | |
111 } \ | |
112 \ | |
113 return retval; \ | |
3325 | 114 } |
115 | |
3295 | 116 // MAKE_BUILTINS is defined to extract function names and related |
117 // information and create the *.df files that are eventually used to | |
118 // create the builtins.cc file. | |
119 | |
120 #if defined (MAKE_BUILTINS) | |
121 | |
122 // Generate code to install name in the symbol table. The script | |
123 // mkdefs will create a .def file for every .cc file that uses DEFUN, | |
4208 | 124 // or DEFCMD. |
3295 | 125 |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
126 #define DEFUN_INTERNAL(name, args_name, nargout_name, doc) \ |
3295 | 127 BEGIN_INSTALL_BUILTIN \ |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
128 XDEFUN_INTERNAL (name, args_name, nargout_name, doc) \ |
3295 | 129 END_INSTALL_BUILTIN |
130 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
131 #define DEFCONSTFUN_INTERNAL(name, args_name, nargout_name, doc) \ |
4234 | 132 BEGIN_INSTALL_BUILTIN \ |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
133 XDEFCONSTFUN_INTERNAL (name, args_name, nargout_name, doc) \ |
4234 | 134 END_INSTALL_BUILTIN |
135 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
136 #define DEFUNX_INTERNAL(name, fname, args_name, nargout_name, doc) \ |
3743 | 137 BEGIN_INSTALL_BUILTIN \ |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
138 XDEFUNX_INTERNAL (name, fname, args_name, nargout_name, doc) \ |
3743 | 139 END_INSTALL_BUILTIN |
140 | |
3364 | 141 // Generate code to install name in the symbol table. The script |
142 // mkdefs will create a .def file for every .cc file that uses | |
143 // DEFUN_DLD. | |
144 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
145 #define DEFUN_DLD_INTERNAL(name, args_name, nargout_name, doc) \ |
3364 | 146 BEGIN_INSTALL_BUILTIN \ |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
147 XDEFUN_DLD_INTERNAL (name, args_name, nargout_name, doc) \ |
3364 | 148 END_INSTALL_BUILTIN |
149 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
150 #define DEFUNX_DLD_INTERNAL(name, fname, args_name, nargout_name, doc) \ |
5796 | 151 BEGIN_INSTALL_BUILTIN \ |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
152 XDEFUNX_DLD_INTERNAL (name, fname, args_name, nargout_name, doc) \ |
5796 | 153 END_INSTALL_BUILTIN |
154 | |
3295 | 155 // Generate code for making another name for an existing function. |
156 | |
157 #define DEFALIAS_INTERNAL(alias, name) \ | |
158 BEGIN_INSTALL_BUILTIN \ | |
159 XDEFALIAS_INTERNAL(alias, name) \ | |
160 END_INSTALL_BUILTIN | |
161 | |
162 #else /* ! MAKE_BUILTINS */ | |
163 | |
164 // Generate the first line of the function definition. This ensures | |
165 // that the internal functions all have the same signature. | |
166 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
167 #define DEFUN_INTERNAL(name, args_name, nargout_name, doc) \ |
3295 | 168 DECLARE_FUN (name, args_name, nargout_name) |
169 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
170 #define DEFCONSTFUN_INTERNAL(name, args_name, nargout_name, doc) \ |
4234 | 171 DECLARE_FUN (name, args_name, nargout_name) |
172 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
173 #define DEFUNX_INTERNAL(name, fname, args_name, nargout_name, doc) \ |
3743 | 174 DECLARE_FUNX (fname, args_name, nargout_name) |
175 | |
3295 | 176 // No definition is required for an alias. |
177 | |
4699 | 178 #define DEFALIAS_INTERNAL(alias, name) |
3295 | 179 |
180 #endif /* ! MAKE_BUILTINS */ | |
181 | |
525 | 182 #endif |