# HG changeset patch # User John W. Eaton # Date 1629054955 14400 # Node ID 7aa4d8c049e5877ae1fef9d9920d205d068fd8b2 # Parent da1678140f7e676bdb0b5fbf99014103560a311c eliminate obsolete DEFCONSTFUN and DEFCONSTMETHOD macros For some time now, DEFCONSTFUN and DEFCONSTMETHOD have been equivalent to DEFUN and DEFMETHOD so we might as well eliminate them. For now we will eliminate all handling of them in Octave but leave them as aliases in defun.h. * macros.dox: Don't mention DEFCONSTFUN or DEFCONSTMETHOD. * defun.h (DEFCONSTFUN, DEFCONSTMETHOD): Define as direct aliases of DEFUN and DEFMETHOD but eliminate documentation for them. * mk-builtins.pl, mk-doc.pl: Don't handle DEFCONSTFUN or DEFCONSTMETHOD. * pt-eval.cc (Fend): Define with DEFMETHOD instead of DEFCONSTMETHOD. diff -r da1678140f7e -r 7aa4d8c049e5 doc/doxyhtml/pages/macros.dox --- a/doc/doxyhtml/pages/macros.dox Sun Aug 15 15:06:09 2021 -0400 +++ b/doc/doxyhtml/pages/macros.dox Sun Aug 15 15:15:55 2021 -0400 @@ -68,21 +68,15 @@ In addition to #DEFUN and #DEFMETHOD, there are two specialized versions of both macros, that should only be used with reason: -1. If the name `foo` cannot be used directly (for example if it is already - defined as a macro), one can use instead one of - ```{.cc} - DEFUNX ("foo", Ffoo, args_name, nargout_name, doc) - DEFMETHODX ("foo", Ffoo, interp_name, args_name, nargout_name, doc) - ``` - where `"foo"` is the name for the interpreter, protected by macro expansion - inside a string, and `Ffoo` is the actual builtin function or builtin method - name. -2. In case `foo` may not be hidden by a variable, defined in an Octave - interpreter session, one can use instead one of - ```{.cc} - DEFCONSTFUN (foo, args_name, nargout_name, doc) - DEFCONSTMETHOD (foo, interp_name, args_name, nargout_name, doc) - ``` +If the name `foo` cannot be used directly (for example if it is already +defined as a macro), one can use instead one of +```{.cc} +DEFUNX ("foo", Ffoo, args_name, nargout_name, doc) +DEFMETHODX ("foo", Ffoo, interp_name, args_name, nargout_name, doc) +``` +where `"foo"` is the name for the interpreter, protected by macro expansion +inside a string, and `Ffoo` is the actual builtin function or builtin method +name. Last but not least, there is #DEFALIAS. As the name suggests, this macro can be used to define an alias for an existing builtin function. diff -r da1678140f7e -r 7aa4d8c049e5 libinterp/corefcn/defun.h --- a/libinterp/corefcn/defun.h Sun Aug 15 15:06:09 2021 -0400 +++ b/libinterp/corefcn/defun.h Sun Aug 15 15:15:55 2021 -0400 @@ -51,7 +51,7 @@ //! omitted, the function cannot access this number. //! @param doc Texinfo help text (docstring) for the function. //! -//! @see DEFUNX, DEFCONSTFUN +//! @see DEFUNX #define DEFUN(name, args_name, nargout_name, doc) \ DECLARE_FUN (name, args_name, nargout_name) @@ -80,38 +80,11 @@ //! omitted, the function cannot access this number. //! @param doc Texinfo help text (docstring) for the function. //! -//! @see DEFUN, DEFCONSTFUN +//! @see DEFUN #define DEFUNX(name, fname, args_name, nargout_name, doc) \ DECLARE_FUNX (fname, args_name, nargout_name) -//! Macro to define a builtin function that cannot be hidden by a variable. -//! -//! @warning Consider to use #DEFUN, unless you have good reason. -//! -//! For detailed information, see \ref Macros. -//! -//! The function gets installed to the 'octave::symbol_table' in a way, such -//! that no variable is allowed to hide this function name. -//! -//! @param name The **unquoted** name of the function that should be installed -//! on the 'octave::symbol_table' and can be called by the -//! interpreter. Internally, the function name is prepended by an -//! 'F'. -//! @param args_name The name of the octave_value_list variable used to pass -//! the argument list to this function. If this value is -//! omitted, the function cannot access the argument list. -//! @param nargout_name The name of the 'int' variable used to pass the number -//! of output arguments this function is expected to -//! produce from the caller. If this value is -//! omitted, the function cannot access this number. -//! @param doc Texinfo help text (docstring) for the function. -//! -//! @see DEFUN, DEFUNX - -#define DEFCONSTFUN(name, args_name, nargout_name, doc) \ - DECLARE_FUN (name, args_name, nargout_name) - //! Macro to define a builtin method. //! //! For detailed information, see \ref Macros. @@ -133,7 +106,7 @@ //! omitted, the method cannot access this number. //! @param doc Texinfo help text (docstring) for the method. //! -//! @see DEFMETHODX, DEFCONSTMETHOD +//! @see DEFMETHODX #define DEFMETHOD(name, interp_name, args_name, nargout_name, doc) \ DECLARE_METHOD (name, interp_name, args_name, nargout_name) @@ -166,41 +139,14 @@ //! omitted, the method cannot access this number. //! @param doc Texinfo help text (docstring) for the method. //! -//! @see DEFMETHOD, DEFCONSTMETHOD +//! @see DEFMETHOD #define DEFMETHODX(name, fname, interp_name, args_name, nargout_name, doc) \ DECLARE_METHODX (fname, interp_name, args_name, nargout_name) -//! Macro to define a builtin method that cannot be hidden by a variable. -//! -//! @warning Consider to use #DEFMETHOD, unless you have good reason. -//! -//! For detailed information, see \ref Macros. -//! -//! The method gets installed to the 'octave::symbol_table' in a way, such -//! that no variable is allowed to hide this method name. -//! -//! @param name The **unquoted** name of the method that should be installed -//! on the 'octave::symbol_table' and can be called by the -//! interpreter. Internally, the method name is prepended by an -//! 'F'. -//! @param interp_name The name of the 'octave::interpreter' reference that can -//! be used by this method. If this value is omitted, -//! there is no access to the interpreter and one should -//! use #DEFCONSTFUN to define a function instead. -//! @param args_name The name of the octave_value_list variable used to pass -//! the argument list to this method. If this value is -//! omitted, the method cannot access the argument list. -//! @param nargout_name The name of the 'int' variable used to pass the number -//! of output arguments this method is expected to -//! produce from the caller. If this value is -//! omitted, the method cannot access this number. -//! @param doc Texinfo help text (docstring) for the method. -//! -//! @see DEFMETHOD, DEFMETHODX - -#define DEFCONSTMETHOD(name, interp_name, args_name, nargout_name, doc) \ - DECLARE_METHOD (name, interp_name, args_name, nargout_name) +// These macros are obsolete but provided for backward compatibility. +#define DEFCONSTFUN DEFUN +#define DEFCONSTMETHOD DEFMETHOD //! Macro to define an alias for another existing function name. //! diff -r da1678140f7e -r 7aa4d8c049e5 libinterp/mk-builtins.pl --- a/libinterp/mk-builtins.pl Sun Aug 15 15:06:09 2021 -0400 +++ b/libinterp/mk-builtins.pl Sun Aug 15 15:15:55 2021 -0400 @@ -79,10 +79,10 @@ while (<$fh>) { - if (/^[ \t]*DEF(CONSTFUN|CONSTMETHOD|METHOD|UN)[ \t]*\( *([^ ,]*).*$/) + if (/^[ \t]*DEF(METHOD|UN)[ \t]*\( *([^ ,]*).*$/) { $name = "F$2"; - $is_method = ($1 eq "METHOD" || $1 eq "CONSTMETHOD"); + $is_method = ($1 eq "METHOD"); } elsif (/^[ \t]*DEF(METHOD|UN)X[ \t]*\( *"[^"]*" *, *([^ ,]*).*$/) { @@ -247,13 +247,6 @@ $fname = "$3"; $name = "$2"; } - elsif ($line =~ /^ *DEFCONST(FUN|METHOD) *\( *([^ ,]*) *,.*$/) - { - $type = "fun"; - $fname = "F$2"; - $name = "$2"; - $const_param = ", true"; - } elsif ($line =~ /^ *DEFALIAS *\( *([^ ,]*) *, *([^ )]*) *\).*$/) { $type = "alias"; diff -r da1678140f7e -r 7aa4d8c049e5 libinterp/mk-doc.pl --- a/libinterp/mk-doc.pl Sun Aug 15 15:06:09 2021 -0400 +++ b/libinterp/mk-doc.pl Sun Aug 15 15:15:55 2021 -0400 @@ -55,7 +55,7 @@ LINE: while (my $line = ) { - if ($line =~ /^\s*DEF(?:CONSTFUN|CONSTMETHOD|METHOD|METHOD_(|STATIC_)DLD|METHODX|METHODX_(|STATIC_)DLD|UN|UN_(|STATIC_)DLD|UNX|UNX_(|STATIC_)DLD)\s*\(/) + if ($line =~ /^\s*DEF(?:METHOD|METHOD_(|STATIC_)DLD|METHODX|METHODX_(|STATIC_)DLD|UN|UN_(|STATIC_)DLD|UNX|UNX_(|STATIC_)DLD)\s*\(/) { ($func) = $line =~ /\("?(\w+)"?,/; unless ($func) { die "Unable to parse $src_fname at line $.\n" } diff -r da1678140f7e -r 7aa4d8c049e5 libinterp/parse-tree/pt-eval.cc --- a/libinterp/parse-tree/pt-eval.cc Sun Aug 15 15:06:09 2021 -0400 +++ b/libinterp/parse-tree/pt-eval.cc Sun Aug 15 15:15:55 2021 -0400 @@ -2234,8 +2234,8 @@ } // END is documented in op-kw-docs. -DEFCONSTMETHOD (end, interp, args, , - doc: /* -*- texinfo -*- +DEFMETHOD (end, interp, args, , + doc: /* -*- texinfo -*- @deftypefn {} {} end Last element of an array or the end of any @code{for}, @code{parfor}, @code{if}, @code{do}, @code{while}, @code{function}, @code{switch},