octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: def const in .oct file


From: John Swensen
Subject: Re: def const in .oct file
Date: Mon, 08 May 2006 12:48:04 -0600
User-agent: Thunderbird 1.5.0.2 (Windows/20060308)

I have just been using the bind_builtin_variable() function.  Is there a
reason to use the macros rather than this function?

John Swensen

John W. Eaton wrote:
> On  8-May-2006, Tom Holroyd (NIH/NIMH) [E] wrote:
>
> | Can you give me a hint?
>
> Try the following patch.  It required touching a few more files than I
> thought it would...
>
> Use the new macro like this:
>
>   DEFUNX_DLD ("AF_UNIX", FAF_UNIX, FSAF_UNIX, args, nargin, nargout,
>     "doc string")
>   {
>     // Your function here.
>   }
>
> The F and FS prefixes for the second and third args are used by
> convention.
>
> jwe
>
>
> src/ChangeLog:
>
> 2006-05-08  John W. Eaton  <address@hidden>
>
>       * Makefile.in (DEFUN_PATTERN): Match DEFUNX_DLD.
>       * mkbuiltins: Handle XDEFUNX_DLD_INTERNAL.
>       * mkgendoc: Likewise.
>       * mk-pkg-add: Likewise.  Do all the matching with sed.
>       * defun-int.h   (DEFINE_FUNX_INSTALLER_FUN, DEFINE_FUNX_INSTALLER_FUN2,
>       DEFINE_FUNX_INSTALLER_FUN3): New macros.
>       (DEFINE_FUN_INSTALLER_FUN3): Define using DEFINE_FUNX_INSTALLER_FUN3.
>       (DEFUNX_DLD_INTERNAL): New macro.
>       * defun-dld.h (DEFUNX_DLD): New macro.
>
>
> Index: src/Makefile.in
> ===================================================================
> RCS file: /cvs/octave/src/Makefile.in,v
> retrieving revision 1.401
> diff -u -r1.401 Makefile.in
> --- src/Makefile.in   4 May 2006 18:33:11 -0000       1.401
> +++ src/Makefile.in   8 May 2006 17:51:55 -0000
> @@ -212,7 +212,7 @@
>  # so we have to repeat ourselves because some stupid egreps don't like
>  # empty elements in alternation patterns.
>  
> -DEFUN_PATTERN = "^[ \t]*DEF(CONSTFUN|CMD|UN|UN_DLD|UN_TEXT|UN_MAPPER)[ 
> \t]*\\("
> +DEFUN_PATTERN = "^[ 
> \t]*DEF(CONSTFUN|CMD|UN|UN_DLD|UNX_DLD|UN_TEXT|UN_MAPPER)[ \t]*\\("
>  
>  DLD_DEF_FILES_1 := $(patsubst %.l, %.df, $(DLD_XSRC))
>  DLD_DEF_FILES := $(patsubst %.cc, %.df, $(DLD_DEF_FILES_1))
> Index: src/defun-dld.h
> ===================================================================
> RCS file: /cvs/octave/src/defun-dld.h,v
> retrieving revision 1.21
> diff -u -r1.21 defun-dld.h
> --- src/defun-dld.h   26 Apr 2005 19:24:32 -0000      1.21
> +++ src/defun-dld.h   8 May 2006 17:51:55 -0000
> @@ -43,7 +43,15 @@
>  #if defined (MAKE_BUILTINS)
>  
>  #define DEFUN_DLD(name, args_name, nargout_name, doc) \
> -  DEFUN_DLD_INTERNAL (name, args_name, nargout_name, 0, doc)
> +  DEFUN_DLD_INTERNAL (name, args_name, nargout_name, false, doc)
> +
> +// This one can be used when `name' cannot be used directly (if it is
> +// already defined as a macro).  In that case, name is already a
> +// quoted string, and the internal name of the function must be passed
> +// too (the convention is to use a prefix of "F", so "foo" becomes "Ffoo").
> +
> +#define DEFUNX_DLD(name, fname, fsname, args_name, nargout_name, doc) \
> +  DEFUNX_DLD_INTERNAL (name, fname, args_name, nargout_name, false, doc)
>  
>  #else
>  
> @@ -52,6 +60,11 @@
>    DEFINE_FUN_INSTALLER_FUN (name, doc) \
>    DECLARE_FUN (name, args_name, nargout_name)
>  
> +#define DEFUNX_DLD(name, fname, fsname, args_name, nargout_name, doc) \
> +  DECLARE_FUNX (fname, args_name, nargout_name); \
> +  DEFINE_FUNX_INSTALLER_FUN (name, fname, fsname, doc) \
> +  DECLARE_FUNX (fname, args_name, nargout_name)
> +
>  #endif
>  
>  #endif
> Index: src/defun-int.h
> ===================================================================
> RCS file: /cvs/octave/src/defun-int.h,v
> retrieving revision 1.51
> diff -u -r1.51 defun-int.h
> --- src/defun-int.h   27 Apr 2006 20:02:31 -0000      1.51
> +++ src/defun-int.h   8 May 2006 17:51:55 -0000
> @@ -81,12 +81,21 @@
>    DEFINE_FUN_INSTALLER_FUN3(name, doc, cxx_abi)
>  
>  #define DEFINE_FUN_INSTALLER_FUN3(name, doc, cxx_abi) \
> +  DEFINE_FUNX_INSTALLER_FUN3(#name, F ## name, FS ## name, doc, cxx_abi)
> +
> +#define DEFINE_FUNX_INSTALLER_FUN(name, fname, fsname, doc) \
> +  DEFINE_FUNX_INSTALLER_FUN2(name, fname, fsname, doc, CXX_ABI)
> +
> +#define DEFINE_FUNX_INSTALLER_FUN2(name, fname, fsname, doc, cxx_abi) \
> +  DEFINE_FUNX_INSTALLER_FUN3(name, fname, fsname, doc, cxx_abi)
> +
> +#define DEFINE_FUNX_INSTALLER_FUN3(name, fname, fsname, doc, cxx_abi) \
>    extern "C" \
>    bool \
> -  FS ## name ## _ ## cxx_abi (const octave_shlib& shl) \
> +  fsname ## _ ## cxx_abi (const octave_shlib& shl) \
>    { \
> -    check_version (OCTAVE_API_VERSION, #name); \
> -    install_dld_function (F ## name, #name, shl, doc); \
> +    check_version (OCTAVE_API_VERSION, name); \
> +    install_dld_function (fname, name, shl, doc); \
>      return error_state ? false : true; \
>    }
>  
> @@ -147,6 +156,12 @@
>      XDEFUN_DLD_INTERNAL (name, args_name, nargout_name, is_text_fcn, doc) \
>    END_INSTALL_BUILTIN
>  
> +#define DEFUNX_DLD_INTERNAL(name, fname, args_name, nargout_name, \
> +                         is_text_fcn, doc) \
> +  BEGIN_INSTALL_BUILTIN \
> +    XDEFUNX_DLD_INTERNAL (name, fname, args_name, nargout_name, is_text_fcn, 
> doc) \
> +  END_INSTALL_BUILTIN
> +
>  // Generate code for making another name for an existing function.
>  
>  #define DEFALIAS_INTERNAL(alias, name) \
> Index: src/mk-pkg-add
> ===================================================================
> RCS file: /cvs/octave/src/mk-pkg-add,v
> retrieving revision 1.3
> diff -u -r1.3 mk-pkg-add
> --- src/mk-pkg-add    5 Apr 2006 06:56:25 -0000       1.3
> +++ src/mk-pkg-add    8 May 2006 17:51:56 -0000
> @@ -8,8 +8,7 @@
>      ## Compute and print the autoloads.
>    
>      base=`basename $f | $SED 's/\.df$//'`
> -    fcns=`grep '^ *XDEFUN_DLD_INTERNAL' $f |\
> -       $SED -e 's/XDEFUN_DLD_INTERNAL *( *//' -e 's/ *,.*$//' |\
> +    fcns=`$SED -n -e 's/XDEFUN\(X\|\)_DLD_INTERNAL *( *\("\|\)\([^", ]*\)[", 
> ].*$/\3/p' $f | \
>         sort -u`
>      if [ -n "$fcns" ]; then
>        for n in $fcns; do
> Index: src/mkbuiltins
> ===================================================================
> RCS file: /cvs/octave/src/mkbuiltins,v
> retrieving revision 1.20
> diff -u -r1.20 mkbuiltins
> --- src/mkbuiltins    26 Apr 2005 19:24:47 -0000      1.20
> +++ src/mkbuiltins    8 May 2006 17:51:56 -0000
> @@ -36,10 +36,21 @@
>  #endif
>  
>  #if defined (ENABLE_DYNAMIC_LINKING)
> +
>  #define XDEFUN_DLD_INTERNAL(name, args_name, nargout_name, is_text_fcn, doc)
> +
> +#define XDEFUNX_DLD_INTERNAL(name, fname, args_name, nargout_name, \
> +                             is_text_fcn, doc)
> +
>  #else
> +
>  #define XDEFUN_DLD_INTERNAL(name, args_name, nargout_name, is_text_fcn, doc) 
> \
>    XDEFUN_INTERNAL(name, args_name, nargout_name, is_text_fcn, doc)
> +
> +#define XDEFUNX_DLD_INTERNAL(name, fname, args_name, nargout_name, \
> +                             is_text_fcn, doc) \
> +  XDEFUNX_INTERNAL(name, fname, args_name, nargout_name, is_text_fcn, doc)
> +
>  #endif
>  
>  #define XDEFUN_INTERNAL(name, args_name, nargout_name, is_text_fcn, doc) \
> Index: src/mkgendoc
> ===================================================================
> RCS file: /cvs/octave/src/mkgendoc,v
> retrieving revision 1.12
> diff -u -r1.12 mkgendoc
> --- src/mkgendoc      2 May 2005 18:15:21 -0000       1.12
> +++ src/mkgendoc      8 May 2006 17:51:56 -0000
> @@ -27,6 +27,10 @@
>  #define XDEFUN_DLD_INTERNAL(name, args_name, nargout_name, is_text_fcn, doc) 
> \
>    print_doc_string (#name, doc);
>  
> +#define XDEFUNX_DLD_INTERNAL(name, fname, args_name, nargout_name, \
> +                             is_text_fcn, doc) \
> +  print_doc_string (name, doc);
> +
>  #define XDEFUN_INTERNAL(name, args_name, nargout_name, is_text_fcn, doc) \
>    print_doc_string (#name, doc);
>  
>
>
>   




reply via email to

[Prev in Thread] Current Thread [Next in Thread]