Mercurial > hg > octave-nkf
changeset 15398:2e5ba861898f
default arg values for DEFUN functions
* defun-int.h (DECLARE_FUNXX, DECLARE_FUNX_NO_DEFAULTS,
DECLARE_FUN_NO_DEFAULTS): New macros.
(DECLARE_FUNX): Define using DECLARE_FUNXX. Provide default argument
values.
* defun-dld.h (DEFUN_DLD, DEFUNX_DLD): Use DECLARE_FUNX_NO_DEFAULTS
instead of DECLARE_FUNX.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 17 Sep 2012 22:35:38 -0400 |
parents | 231d8d3b8225 |
children | 66e17621f99a |
files | libinterp/interp-core/defun-dld.h libinterp/interp-core/defun-int.h |
diffstat | 2 files changed, 16 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/interp-core/defun-dld.h +++ b/libinterp/interp-core/defun-dld.h @@ -57,14 +57,14 @@ #else #define DEFUN_DLD(name, args_name, nargout_name, doc) \ - DECLARE_FUN (name, args_name, nargout_name); \ + DECLARE_FUN_NO_DEFAULTS (name, args_name, nargout_name); \ DEFINE_FUN_INSTALLER_FUN (name, doc) \ - DECLARE_FUN (name, args_name, nargout_name) + DECLARE_FUN_NO_DEFAULTS (name, args_name, nargout_name) #define DEFUNX_DLD(name, fname, gname, args_name, nargout_name, doc) \ - DECLARE_FUNX (fname, args_name, nargout_name); \ + DECLARE_FUNX_NO_DEFAULTS (fname, args_name, nargout_name); \ DEFINE_FUNX_INSTALLER_FUN (name, fname, gname, doc) \ - DECLARE_FUNX (fname, args_name, nargout_name) + DECLARE_FUNX_NO_DEFAULTS (fname, args_name, nargout_name) #endif
--- a/libinterp/interp-core/defun-int.h +++ b/libinterp/interp-core/defun-int.h @@ -77,13 +77,23 @@ extern OCTINTERP_API void defun_isargout (int, int, bool *); +#define DECLARE_FUNXX(name, args_decl, nargout_decl) \ + OCTAVE_EXPORT octave_value_list name (args_decl, nargout_decl) + #define DECLARE_FUNX(name, args_name, nargout_name) \ - OCTAVE_EXPORT octave_value_list \ - name (const octave_value_list& args_name, int nargout_name) + DECLARE_FUNXX (name, \ + const octave_value_list& args_name = octave_value_list (), \ + int nargout_name = 0) + +#define DECLARE_FUNX_NO_DEFAULTS(name, args_name, nargout_name) \ + DECLARE_FUNXX (name, const octave_value_list& args_name, int nargout_name) #define DECLARE_FUN(name, args_name, nargout_name) \ DECLARE_FUNX (F ## name, args_name, nargout_name) +#define DECLARE_FUN_NO_DEFAULTS(name, args_name, nargout_name) \ + DECLARE_FUNX_NO_DEFAULTS (F ## name, args_name, nargout_name) + // Define the code that will be used to insert the new function into // the symbol table. We look for this name instead of the actual // function so that we can easily install the doc std::string too.