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