Mercurial > hg > octave-nkf
annotate src/defun-int.h @ 12541:dd2c70b30f28
Add tests for ifftshift.m
author | Robert T. Short <octave@phaselockedsystems.com.com> |
---|---|
date | Sat, 26 Mar 2011 06:50:12 -0700 |
parents | 12df7854fa7c |
children | 72c96de7a403 |
rev | line source |
---|---|
525 | 1 /* |
2 | |
11523 | 3 Copyright (C) 1994-2011 John W. Eaton |
525 | 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 | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
525 | 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 | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
525 | 20 |
21 */ | |
22 | |
23 #if !defined (octave_defun_int_h) | |
24 #define octave_defun_int_h 1 | |
25 | |
2968 | 26 #include <string> |
27 | |
3145 | 28 #include "ov-builtin.h" |
3325 | 29 #include "ov-dld-fcn.h" |
3145 | 30 #include "symtab.h" |
3015 | 31 #include "version.h" |
32 | |
2968 | 33 class octave_value; |
34 | |
6109 | 35 extern OCTINTERP_API void print_usage (void); |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
7996
diff
changeset
|
36 extern OCTINTERP_API void print_usage (const std::string&); |
3014 | 37 |
6109 | 38 extern OCTINTERP_API void check_version (const std::string& version, const std::string& fcn); |
3015 | 39 |
6109 | 40 extern OCTINTERP_API void |
3523 | 41 install_builtin_function (octave_builtin::fcn f, const std::string& name, |
10313 | 42 const std::string& doc, |
43 bool can_hide_function = true); | |
2968 | 44 |
6109 | 45 extern OCTINTERP_API void |
3523 | 46 install_dld_function (octave_dld_function::fcn f, const std::string& name, |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
47 const octave_shlib& shl, const std::string& doc, |
10313 | 48 bool relative = false); |
703 | 49 |
6109 | 50 extern OCTINTERP_API void |
5864 | 51 install_mex_function (void *fptr, bool fmex, const std::string& name, |
10313 | 52 const octave_shlib& shl, bool relative = false); |
5864 | 53 |
6109 | 54 extern OCTINTERP_API void |
3523 | 55 alias_builtin (const std::string& alias, const std::string& name); |
703 | 56 |
9960
5f3c10ecb150
implement get_current_shlib and octave_auto_shlib
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
57 // 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
|
58 extern OCTINTERP_API octave_shlib |
5f3c10ecb150
implement get_current_shlib and octave_auto_shlib
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
59 get_current_shlib (void); |
5f3c10ecb150
implement get_current_shlib and octave_auto_shlib
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
60 |
5f3c10ecb150
implement get_current_shlib and octave_auto_shlib
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
61 // 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
|
62 // 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
|
63 // 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
|
64 |
5f3c10ecb150
implement get_current_shlib and octave_auto_shlib
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
65 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
|
66 { |
10641
ed6969880316
preliminary onCleanup support
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
67 public: |
9960
5f3c10ecb150
implement get_current_shlib and octave_auto_shlib
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
68 octave_auto_shlib (void) |
5f3c10ecb150
implement get_current_shlib and octave_auto_shlib
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
69 : octave_shlib (get_current_shlib ()) { } |
5f3c10ecb150
implement get_current_shlib and octave_auto_shlib
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
70 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
|
71 : octave_shlib (shl) { } |
5f3c10ecb150
implement get_current_shlib and octave_auto_shlib
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
72 }; |
5f3c10ecb150
implement get_current_shlib and octave_auto_shlib
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
73 |
10887
f10d0bc8f9cc
make isargout available to DEFUNs
Jaroslav Hajek <highegg@gmail.com>
parents:
10641
diff
changeset
|
74 extern OCTINTERP_API bool |
f10d0bc8f9cc
make isargout available to DEFUNs
Jaroslav Hajek <highegg@gmail.com>
parents:
10641
diff
changeset
|
75 defun_isargout (int, int); |
f10d0bc8f9cc
make isargout available to DEFUNs
Jaroslav Hajek <highegg@gmail.com>
parents:
10641
diff
changeset
|
76 |
f10d0bc8f9cc
make isargout available to DEFUNs
Jaroslav Hajek <highegg@gmail.com>
parents:
10641
diff
changeset
|
77 extern OCTINTERP_API void |
f10d0bc8f9cc
make isargout available to DEFUNs
Jaroslav Hajek <highegg@gmail.com>
parents:
10641
diff
changeset
|
78 defun_isargout (int, int, bool *); |
f10d0bc8f9cc
make isargout available to DEFUNs
Jaroslav Hajek <highegg@gmail.com>
parents:
10641
diff
changeset
|
79 |
3743 | 80 #define DECLARE_FUNX(name, args_name, nargout_name) \ |
6109 | 81 OCTAVE_EXPORT octave_value_list \ |
3743 | 82 name (const octave_value_list& args_name, int nargout_name) |
83 | |
84 #define DECLARE_FUN(name, args_name, nargout_name) \ | |
85 DECLARE_FUNX (F ## name, args_name, nargout_name) | |
2968 | 86 |
3325 | 87 // Define the code that will be used to insert the new function into |
88 // the symbol table. We look for this name instead of the actual | |
3523 | 89 // function so that we can easily install the doc std::string too. |
3325 | 90 |
6323 | 91 typedef bool (*octave_dld_fcn_installer) (const octave_shlib&, bool relative); |
3325 | 92 |
7336 | 93 typedef octave_function * (*octave_dld_fcn_getter) (const octave_shlib&, bool relative); |
94 | |
3325 | 95 #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
|
96 DEFINE_FUNX_INSTALLER_FUN(#name, F ## name, G ## name, doc) |
5796 | 97 |
7996
6a7db240b3a3
configure.in: eliminate CXX_ABI and OCTAVE_CXX_PREPEND_UNDERSCORE
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
98 #define DEFINE_FUNX_INSTALLER_FUN(name, fname, gname, doc) \ |
7336 | 99 extern "C" \ |
100 OCTAVE_EXPORT \ | |
101 octave_function * \ | |
7996
6a7db240b3a3
configure.in: eliminate CXX_ABI and OCTAVE_CXX_PREPEND_UNDERSCORE
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
102 gname (const octave_shlib& shl, bool relative) \ |
7336 | 103 { \ |
104 octave_function *retval = 0; \ | |
105 \ | |
106 check_version (OCTAVE_API_VERSION, name); \ | |
107 \ | |
108 if (! error_state) \ | |
109 { \ | |
10313 | 110 octave_dld_function *fcn = octave_dld_function::create (fname, shl, name, doc); \ |
7336 | 111 \ |
112 if (relative) \ | |
113 fcn->mark_relative (); \ | |
114 \ | |
115 retval = fcn; \ | |
116 } \ | |
117 \ | |
118 return retval; \ | |
3325 | 119 } |
120 | |
3295 | 121 // MAKE_BUILTINS is defined to extract function names and related |
122 // information and create the *.df files that are eventually used to | |
123 // create the builtins.cc file. | |
124 | |
125 #if defined (MAKE_BUILTINS) | |
126 | |
127 // Generate code to install name in the symbol table. The script | |
128 // mkdefs will create a .def file for every .cc file that uses DEFUN, | |
4208 | 129 // or DEFCMD. |
3295 | 130 |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
131 #define DEFUN_INTERNAL(name, args_name, nargout_name, doc) \ |
3295 | 132 BEGIN_INSTALL_BUILTIN \ |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
133 XDEFUN_INTERNAL (name, args_name, nargout_name, doc) \ |
3295 | 134 END_INSTALL_BUILTIN |
135 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
136 #define DEFCONSTFUN_INTERNAL(name, args_name, nargout_name, doc) \ |
4234 | 137 BEGIN_INSTALL_BUILTIN \ |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
138 XDEFCONSTFUN_INTERNAL (name, args_name, nargout_name, doc) \ |
4234 | 139 END_INSTALL_BUILTIN |
140 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
141 #define DEFUNX_INTERNAL(name, fname, args_name, nargout_name, doc) \ |
3743 | 142 BEGIN_INSTALL_BUILTIN \ |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
143 XDEFUNX_INTERNAL (name, fname, args_name, nargout_name, doc) \ |
3743 | 144 END_INSTALL_BUILTIN |
145 | |
3364 | 146 // Generate code to install name in the symbol table. The script |
147 // mkdefs will create a .def file for every .cc file that uses | |
148 // DEFUN_DLD. | |
149 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
150 #define DEFUN_DLD_INTERNAL(name, args_name, nargout_name, doc) \ |
3364 | 151 BEGIN_INSTALL_BUILTIN \ |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
152 XDEFUN_DLD_INTERNAL (name, args_name, nargout_name, doc) \ |
3364 | 153 END_INSTALL_BUILTIN |
154 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
155 #define DEFUNX_DLD_INTERNAL(name, fname, args_name, nargout_name, doc) \ |
5796 | 156 BEGIN_INSTALL_BUILTIN \ |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
157 XDEFUNX_DLD_INTERNAL (name, fname, args_name, nargout_name, doc) \ |
5796 | 158 END_INSTALL_BUILTIN |
159 | |
3295 | 160 // Generate code for making another name for an existing function. |
161 | |
162 #define DEFALIAS_INTERNAL(alias, name) \ | |
163 BEGIN_INSTALL_BUILTIN \ | |
164 XDEFALIAS_INTERNAL(alias, name) \ | |
165 END_INSTALL_BUILTIN | |
166 | |
167 #else /* ! MAKE_BUILTINS */ | |
168 | |
169 // Generate the first line of the function definition. This ensures | |
170 // that the internal functions all have the same signature. | |
171 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
172 #define DEFUN_INTERNAL(name, args_name, nargout_name, doc) \ |
3295 | 173 DECLARE_FUN (name, args_name, nargout_name) |
174 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
175 #define DEFCONSTFUN_INTERNAL(name, args_name, nargout_name, doc) \ |
4234 | 176 DECLARE_FUN (name, args_name, nargout_name) |
177 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
178 #define DEFUNX_INTERNAL(name, fname, args_name, nargout_name, doc) \ |
3743 | 179 DECLARE_FUNX (fname, args_name, nargout_name) |
180 | |
3295 | 181 // No definition is required for an alias. |
182 | |
4699 | 183 #define DEFALIAS_INTERNAL(alias, name) |
3295 | 184 |
185 #endif /* ! MAKE_BUILTINS */ | |
186 | |
525 | 187 #endif |