26 #if defined (HAVE_CONFIG_H)
73 const std::list<octave_value_list>& idx,
83 octave::cdef_method meth = cls.find_method (
"subsref");
94 retval = meth.execute (args, nargout,
true,
"subsref");
104 if (type.length () > skip && idx.size () > skip)
105 retval = retval(0).next_subsref (nargout, type, idx, skip);
112 const std::list<octave_value_list>& idx,
115 std::size_t skip = 0;
126 octave::cdef_method meth = cls.find_method (
"subsref");
137 retval = meth.execute (args, 1,
true,
"subsref");
143 retval =
m_object.subsref (type, idx, 1, skip,
146 if (type.length () > skip && idx.size () > skip)
147 retval = retval(0).next_subsref (1, type, idx, skip);
154 const std::list<octave_value_list>& idx,
163 octave::cdef_method meth = cls.find_method (
"subsasgn");
177 retlist = meth.execute (args, 1,
true,
"subsasgn");
179 if (retlist.
empty ())
180 error (
"overloaded method 'subsasgn' did not return any value");
187 retval =
m_object.subsasgn (type, idx, rhs);
194 const std::list<octave_value_list>& idx,
197 if (type.length () == 1 && type[0] ==
'(')
216 octave::cdef_method meth = cls.find_method (
"size");
228 return lv(0).matrix_value ();
244 octave::cdef_method meth = cls.find_method (
"numel");
259 octave::tree_evaluator& tw = interp.get_evaluator();
261 octave::unwind_action act ([&tw] (
const std::list<octave::octave_lvalue> *lvl)
263 tw.set_lvalue_list (lvl);
264 }, tw.lvalue_list ());
265 tw.set_lvalue_list (
nullptr);
269 error (
"@%s/numel: invalid return value", cls.get_name ().c_str ());
271 retval = lv(0).idx_type_value (
true);
295 bool is_array =
m_object.is_array ();
303 os <<
" with properties:";
310 std::map<std::string, octave::cdef_property> property_map
311 = cls.get_property_map ();
313 std::size_t max_len = 0;
314 for (
const auto& pname_prop : property_map)
319 const octave::cdef_property& prop = pname_prop.second;
321 const std::string nm = prop.get_name ();
333 std::size_t sz = nm.
size ();
339 for (
auto& pname_prop : property_map)
341 const octave::cdef_property& prop = pname_prop.second;
343 const std::string nm = prop.get_name ();
364 os << std::setw (max_len+2) << nm <<
": ";
394 const std::string& cls)
415 octave::cdef_method meth (
m_object);
417 return meth.is_defined_in_class (cname);
436 if (cls.get_name () == cname)
450 if (meth_name.empty ())
451 return cls.doc_string ();
453 octave::cdef_method cdef_meth = cls.find_method (meth_name);
456 return cdef_meth.get_doc_string ();
468 return cls.file_name ();
481 std::string meth_name;
488 error (
"superclass calls can only occur in methods or constructors");
501 error (
"'%s' is not a direct superclass of '%s'",
502 cname.c_str (), ctx.get_name ().c_str ());
505 error (
"cannot call superclass constructor with variable '%s'",
516 std::size_t pos = mname.find (
'.');
520 if (pos != std::string::npos)
525 mname = mname.substr (pos + 1);
548 if (mname != meth_name)
549 error (
"method name mismatch ('%s' != '%s')",
550 mname.c_str (), meth_name.c_str ());
553 error (
"'%s' is not a superclass of '%s'",
554 cname.c_str (), ctx.get_name ().c_str ());
567 octave::cdef_method meth = cls.find_method (meth_name,
false);
570 error (
"no method '%s' found in superclass '%s'",
571 meth_name.c_str (), cname.c_str ());
574 ? meth.execute (obj, idx, nargout,
true, meth_name)
575 : meth.execute (idx, nargout,
true, meth_name));
582 const std::string& nm)
592 octave::tree_parameter_list *ret_list = uf->
return_list ();
594 if (ret_list && ret_list->length () == 1)
595 return (ret_list->front ()->name () == nm);
604 DEFUN (__meta_get_package__, args, ,
610 if (args.length () != 1)
613 std::string cname = args(0).xstring_value (
"PKG_NAME must be a string");
618 DEFUN (metaclass, args, ,
624 if (args.length () != 1)
653 if (args.length () != 1)
658 std::string class_name;
672 error (
"invalid class: %s", class_name.c_str ());
674 std::map<std::string, cdef_property> property_map =
677 std::list<std::string> property_names;
679 for (
const auto& pname_prop : property_map)
698 property_names.push_back (nm);
704 octave_stdout <<
"properties for class " << class_name <<
":\n\n";
706 for (
const auto& nm : property_names)
734 std::string class_name;
750 std::map<std::string, cdef_method> method_map
753 std::list<std::string> method_names;
755 for (
const auto& nm_mthd : method_map)
757 std::string nm = nm_mthd.first;
759 method_names.push_back (nm);
bool isvector(const dim_vector &dim)
class OCTINTERP_API cdef_object
class OCTINTERP_API cdef_class
bool is_superclass(const cdef_class &clsa, const cdef_class &clsb, bool allow_equal, int max_depth)
bool is_strict_superclass(const cdef_class &clsa, const cdef_class &clsb)
cdef_object to_cdef(const octave_value &val)
cdef_object & to_cdef_ref(const octave_value &val)
cdef_class get_class_context(std::string &name, bool &in_constructor)
cdef_class lookup_class(const std::string &name, bool error_if_not_found, bool load_if_not_found)
octave_value to_ov(const cdef_object &obj)
cdef_package lookup_package(const std::string &name, bool error_if_not_found, bool load_if_not_found)
bool is_direct_superclass(const cdef_class &clsa, const cdef_class &clsb)
std::map< std::string, cdef_property > get_property_map(int mode=property_normal)
std::map< std::string, cdef_method > get_method_map(bool only_inherited=false, bool include_ctor=false)
OCTINTERP_API cdef_class get_class(void) const
octave_value get(const std::string &pname) const
std::string get_name(void) const
Vector representing the dimensions (size) of an Array.
OCTAVE_API std::string str(char sep='x') const
std::list< std::string > methods(const std::string &class_name, const std::string &pack_name="")
octave::refcount< octave_idx_type > count
void decrement_indent_level(void) const
void increment_indent_level(void) const
OCTINTERP_API void indent(std::ostream &os) const
OCTINTERP_API void newline(std::ostream &os) const
virtual Matrix size(void)
virtual bool is_matrix_type(void) const
virtual bool is_scalar_type(void) const
virtual octave_idx_type xnumel(const octave_value_list &)
virtual octave_user_function * user_function_value(bool silent=false)
virtual octave_value undef_subsasgn(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
static void register_type(void)
friend class octave_value
std::string m_method_name
OCTINTERP_API bool is_constructed_object(octave::tree_evaluator &tw, const std::string &nm)
OCTINTERP_API octave_value_list execute(octave::tree_evaluator &tw, int nargout, const octave_value_list &idx)
OCTINTERP_API void print(std::ostream &os, bool pr_as_read_syntax=false)
OCTINTERP_API octave_value subsasgn(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
dim_vector dims(void) const
OCTINTERP_API octave_value_list subsref(const std::string &type, const std::list< octave_value_list > &idx, int nargout)
OCTINTERP_API Matrix size(void)
static const std::string t_name
octave::cdef_object get_object(void) const
OCTINTERP_API bool is_instance_of(const std::string &cls_name) const
OCTINTERP_API octave_value undef_subsasgn(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
octave::cdef_object m_object
static OCTINTERP_API octave_value metaclass_query(const std::string &cls)
OCTINTERP_API octave_idx_type xnumel(const octave_value_list &)
static OCTINTERP_API octave_value superclass_ref(const std::string &meth, const std::string &cls)
OCTINTERP_API void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
std::string class_name(void) const
virtual bool is_classdef_constructor(const std::string &="") const
octave::tree_parameter_list * return_list(void)
octave_idx_type length(void) const
bool is_classdef_object(void) const
bool bool_value(bool warn=false) const
bool is_string(void) const
bool is_defined(void) const
std::string class_name(void) const
std::string string_value(bool force=false) const
bool isobject(void) const
bool islogical(void) const
dim_vector dims(void) const
OCTINTERP_API octave_classdef * classdef_object_value(bool silent=false) const
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
OCTINTERP_API void print_usage(void)
#define DEFMETHOD(name, interp_name, args_name, nargout_name, doc)
Macro to define a builtin method.
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
void error(const char *fmt,...)
void err_wrong_type_arg(const char *name, const char *s)
interpreter & __get_interpreter__(void)
T::properties & properties(graphics_object obj)
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
octave_value make_idx_args(const std::string &type, const std::list< octave_value_list > &idx, const std::string &who)
bool called_from_builtin(void)
static bool in_class_method(const octave::cdef_class &cls)
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.