26 #if defined (HAVE_CONFIG_H)
54 OCTAVE_NORETURN
static
56 err_method_access (
const std::string& from,
const cdef_method& meth)
64 acc_s =
"class-restricted";
66 error (
"%s: method '%s' has %s access and cannot be run in this context",
67 from.c_str (), meth.
get_name ().c_str (), acc_s.c_str ());
71 cdef_method::cdef_method_rep::check_method ()
79 std::string name = get_name ();
80 std::string cls_name = m_dispatch_type;
81 std::string pack_name;
83 std::size_t pos = cls_name.rfind (
'.');
85 if (pos != std::string::npos)
87 pack_name = cls_name.substr (0, pos);
88 cls_name = cls_name.substr (pos + 1);
92 std::string file_name = lp.
find_method (cls_name, name,
95 if (! file_name.empty ())
99 m_dispatch_type, pack_name);
115 error (
"no definition found for method '%s' of class '%s'",
116 get_name ().c_str (), m_dispatch_type.c_str ());
122 int nargout,
bool do_check_access,
123 const std::string& who)
128 err_method_access (who, wrap ());
130 if (get (
"Abstract").bool_value ())
131 error (
"%s: cannot execute abstract method",
132 get (
"Name").string_value ().c_str ());
136 if (m_function.is_defined ())
140 retval = interp.
feval (m_function, args, nargout);
147 cdef_method::cdef_method_rep::execute (
const cdef_object& obj,
149 int nargout,
bool do_check_access,
150 const std::string& who)
155 err_method_access (who, wrap ());
157 if (get (
"Abstract").bool_value ())
158 error (
"%s: cannot execute abstract method",
159 get (
"Name").string_value ().c_str ());
163 if (m_function.is_defined ())
169 new_args(0) =
to_ov (obj);
170 for (
int i = 0; i < args.
length (); i++)
171 new_args(i+1) = args(i);
175 retval = interp.
feval (m_function, new_args, nargout);
182 cdef_method::cdef_method_rep::is_constructor ()
const
184 if (m_function.is_function())
185 return m_function.function_value ()->is_classdef_constructor ();
191 cdef_method::cdef_method_rep::is_defined_in_class (
const std::string& cname)
const
193 return (m_function.is_function ()
194 ? m_function.function_value ()->dispatch_class () == cname
199 cdef_method::cdef_method_rep::get_doc_string ()
217 cdef_method::cdef_method_rep::meta_subsref
218 (
const std::string& type,
const std::list<octave_value_list>& idx,
226 retval = (execute (idx.front (),
227 type.length () > 1 ? 1 : nargout,
true));
231 error (
"invalid meta.method indexing");
235 if (type.length () > 1 && idx.size () > 1 && ! retval.
empty ())
236 retval = retval(0).next_subsref (nargout, type, idx, 1);
241 OCTAVE_END_NAMESPACE(
octave)
bool check_access(const cdef_class &cls, const octave_value &acc, const std::string &meth_name, const std::string &prop_name, bool is_prop_set)
bool is_dummy_method(const octave_value &fcn)
cdef_object to_cdef(const octave_value &val)
octave_value to_ov(const cdef_object &obj)
void make_function_of_class(const std::string &class_name, const octave_value &fcn)
std::string get_name() const
octave_value get(const std::string &pname) const
octave_value_list feval(const char *name, const octave_value_list &args=octave_value_list(), int nargout=0)
Evaluate an Octave function (built-in or interpreted) and return the list of result values.
std::string find_method(const std::string &class_name, const std::string &meth, std::string &dir_name, const std::string &pack_name="")
virtual octave_function * function_value(bool silent=false)
virtual std::string doc_string(const std::string &="") const
void resize(octave_idx_type n, const octave_value &rfv=octave_value())
octave_idx_type length() const
std::string string_value(bool force=false) const
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
void() error(const char *fmt,...)
interpreter & __get_interpreter__()
load_path & __get_load_path__()
octave_value load_fcn_from_file(const std::string &file_name, const std::string &dir_name="", const std::string &dispatch_type="", const std::string &package_name="", const std::string &fcn_name="", bool autoload=false)