Mercurial > hg > octave-nkf
annotate src/defun-int.h @ 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 |
---|---|
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, |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
43 const std::string& doc, |
4234 | 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, |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
48 const octave_shlib& shl, const std::string& doc, |
6323 | 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, |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
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 |
3743 | 58 #define DECLARE_FUNX(name, args_name, nargout_name) \ |
6109 | 59 OCTAVE_EXPORT octave_value_list \ |
3743 | 60 name (const octave_value_list& args_name, int nargout_name) |
61 | |
62 #define DECLARE_FUN(name, args_name, nargout_name) \ | |
63 DECLARE_FUNX (F ## name, args_name, nargout_name) | |
2968 | 64 |
3325 | 65 // Define the code that will be used to insert the new function into |
66 // the symbol table. We look for this name instead of the actual | |
3523 | 67 // function so that we can easily install the doc std::string too. |
3325 | 68 |
6323 | 69 typedef bool (*octave_dld_fcn_installer) (const octave_shlib&, bool relative); |
3325 | 70 |
7336 | 71 typedef octave_function * (*octave_dld_fcn_getter) (const octave_shlib&, bool relative); |
72 | |
3325 | 73 #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
|
74 DEFINE_FUNX_INSTALLER_FUN(#name, F ## name, G ## name, doc) |
5796 | 75 |
7996
6a7db240b3a3
configure.in: eliminate CXX_ABI and OCTAVE_CXX_PREPEND_UNDERSCORE
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
76 #define DEFINE_FUNX_INSTALLER_FUN(name, fname, gname, doc) \ |
7336 | 77 extern "C" \ |
78 OCTAVE_EXPORT \ | |
79 octave_function * \ | |
7996
6a7db240b3a3
configure.in: eliminate CXX_ABI and OCTAVE_CXX_PREPEND_UNDERSCORE
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
80 gname (const octave_shlib& shl, bool relative) \ |
7336 | 81 { \ |
82 octave_function *retval = 0; \ | |
83 \ | |
84 check_version (OCTAVE_API_VERSION, name); \ | |
85 \ | |
86 if (! error_state) \ | |
87 { \ | |
7349 | 88 octave_dld_function *fcn = octave_dld_function::create (fname, shl, name, doc); \ |
7336 | 89 \ |
90 if (relative) \ | |
91 fcn->mark_relative (); \ | |
92 \ | |
93 retval = fcn; \ | |
94 } \ | |
95 \ | |
96 return retval; \ | |
3325 | 97 } |
98 | |
3295 | 99 // MAKE_BUILTINS is defined to extract function names and related |
100 // information and create the *.df files that are eventually used to | |
101 // create the builtins.cc file. | |
102 | |
103 #if defined (MAKE_BUILTINS) | |
104 | |
105 // Generate code to install name in the symbol table. The script | |
106 // mkdefs will create a .def file for every .cc file that uses DEFUN, | |
4208 | 107 // or DEFCMD. |
3295 | 108 |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
109 #define DEFUN_INTERNAL(name, args_name, nargout_name, doc) \ |
3295 | 110 BEGIN_INSTALL_BUILTIN \ |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
111 XDEFUN_INTERNAL (name, args_name, nargout_name, doc) \ |
3295 | 112 END_INSTALL_BUILTIN |
113 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
114 #define DEFCONSTFUN_INTERNAL(name, args_name, nargout_name, doc) \ |
4234 | 115 BEGIN_INSTALL_BUILTIN \ |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
116 XDEFCONSTFUN_INTERNAL (name, args_name, nargout_name, doc) \ |
4234 | 117 END_INSTALL_BUILTIN |
118 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
119 #define DEFUNX_INTERNAL(name, fname, args_name, nargout_name, doc) \ |
3743 | 120 BEGIN_INSTALL_BUILTIN \ |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
121 XDEFUNX_INTERNAL (name, fname, args_name, nargout_name, doc) \ |
3743 | 122 END_INSTALL_BUILTIN |
123 | |
3364 | 124 // Generate code to install name in the symbol table. The script |
125 // mkdefs will create a .def file for every .cc file that uses | |
126 // DEFUN_DLD. | |
127 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
128 #define DEFUN_DLD_INTERNAL(name, args_name, nargout_name, doc) \ |
3364 | 129 BEGIN_INSTALL_BUILTIN \ |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
130 XDEFUN_DLD_INTERNAL (name, args_name, nargout_name, doc) \ |
3364 | 131 END_INSTALL_BUILTIN |
132 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
133 #define DEFUNX_DLD_INTERNAL(name, fname, args_name, nargout_name, doc) \ |
5796 | 134 BEGIN_INSTALL_BUILTIN \ |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
135 XDEFUNX_DLD_INTERNAL (name, fname, args_name, nargout_name, doc) \ |
5796 | 136 END_INSTALL_BUILTIN |
137 | |
3295 | 138 // Generate code for making another name for an existing function. |
139 | |
140 #define DEFALIAS_INTERNAL(alias, name) \ | |
141 BEGIN_INSTALL_BUILTIN \ | |
142 XDEFALIAS_INTERNAL(alias, name) \ | |
143 END_INSTALL_BUILTIN | |
144 | |
145 #else /* ! MAKE_BUILTINS */ | |
146 | |
147 // Generate the first line of the function definition. This ensures | |
148 // that the internal functions all have the same signature. | |
149 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
150 #define DEFUN_INTERNAL(name, args_name, nargout_name, doc) \ |
3295 | 151 DECLARE_FUN (name, args_name, nargout_name) |
152 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
153 #define DEFCONSTFUN_INTERNAL(name, args_name, nargout_name, doc) \ |
4234 | 154 DECLARE_FUN (name, args_name, nargout_name) |
155 | |
8746
5dd06f19e9be
handle commands in the lexer
John W. Eaton <jwe@octave.org>
parents:
8575
diff
changeset
|
156 #define DEFUNX_INTERNAL(name, fname, args_name, nargout_name, doc) \ |
3743 | 157 DECLARE_FUNX (fname, args_name, nargout_name) |
158 | |
3295 | 159 // No definition is required for an alias. |
160 | |
4699 | 161 #define DEFALIAS_INTERNAL(alias, name) |
3295 | 162 |
163 #endif /* ! MAKE_BUILTINS */ | |
164 | |
525 | 165 #endif |
166 | |
167 /* | |
168 ;;; Local Variables: *** | |
169 ;;; mode: C++ *** | |
170 ;;; End: *** | |
171 */ |