Mercurial > octave
diff libinterp/octave-value/ov-builtin.h @ 23518:8744d4ed8fb4
provide DEFMETHOD macros
Allow a reference to the interpreter object to be passed to built-in
interpreter functions.
* find-defun-files.sh: Adjust regexp pattern for finding built-in
functions.
* mk-builtins.pl: Handle DEFMETHOD variants of built-in function macros.
* defun-int.h, defun.cc (install_builtin_function):
New overloads for methods.
* defun-int.h (FORWARD_DECLARE_METHODX, FORWARD_DECLARE_METHOD,
DECLARE_METHODX, DECLARE_METHOD, DECLARE_STATIC_METHODX,
DECLARE_STATIC_METHOD): New macros.
* defun.h (DEFMETHOD, DEFMETHODX, DEFCONSTMETHOD): New macros.
* libinterp/gendoc.pl: Likewise.
* ov-builtin.h, ov-builtin.cc (octave_builtin::meth): New typedef.
(octave_builtin::m): New data member.
(octave_builtin::method): New function.
(octave_builtin::octave_builtin, octave_builtin::call):
Handle methods.
* ov-dld-fcn.h, ov-dld-fcn.cc (octave_dld_function::create,
octave_dld_function::octave_dld_function): Handle methods.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 19 May 2017 16:01:18 -0400 |
parents | c6714ae1c06c |
children | 9f925aed7d1b |
line wrap: on
line diff
--- a/libinterp/octave-value/ov-builtin.h Fri May 19 15:53:32 2017 -0400 +++ b/libinterp/octave-value/ov-builtin.h Fri May 19 16:01:18 2017 -0400 @@ -36,6 +36,11 @@ class octave_value_list; class jit_type; +namespace octave +{ + class interpreter; +} + // Builtin functions. class @@ -46,15 +51,26 @@ octave_builtin (void) : octave_function (), f (0), file (), jtype (0) { } + typedef octave_value_list (*meth) (octave::interpreter&, + const octave_value_list&, int); + typedef octave_value_list (*fcn) (const octave_value_list&, int); octave_builtin (fcn ff, const std::string& nm = "", const std::string& ds = "") - : octave_function (nm, ds), f (ff), file (), jtype (0) { } + : octave_function (nm, ds), f (ff), m (0), file (), jtype (0) { } + + octave_builtin (meth mm, const std::string& nm = "", + const std::string& ds = "") + : octave_function (nm, ds), f (0), m (mm), file (), jtype (0) { } octave_builtin (fcn ff, const std::string& nm, const std::string& fnm, const std::string& ds) - : octave_function (nm, ds), f (ff), file (fnm), jtype (0) { } + : octave_function (nm, ds), f (ff), m (0), file (fnm), jtype (0) { } + + octave_builtin (meth mm, const std::string& nm, const std::string& fnm, + const std::string& ds) + : octave_function (nm, ds), f (0), m (mm), file (fnm), jtype (0) { } // No copying! @@ -89,6 +105,8 @@ fcn function (void) const; + meth method (void) const; + void push_dispatch_class (const std::string& dispatch_type); bool handles_dispatch_class (const std::string& dispatch_type) const; @@ -97,6 +115,7 @@ // A pointer to the actual function. fcn f; + meth m; // The name of the file where this function was defined. std::string file;