26#if defined (HAVE_CONFIG_H)
73 const std::list<octave_value_list>& idx,
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;
137 retval = meth.
execute (args, 1,
true,
"subsref");
145 if (type.length () > skip && idx.size () > skip)
146 retval = retval(0).next_subsref (1, type, idx, skip);
153 const std::list<octave_value_list>& idx,
176 retlist = meth.
execute (args, 1,
true,
"subsasgn");
178 if (retlist.
empty ())
179 error (
"overloaded method 'subsasgn' did not return any value");
193 const std::list<octave_value_list>& idx,
196 if (type.length () == 1 && type[0] ==
'(')
227 return lv(0).matrix_value ();
258 octave::tree_evaluator& tw = interp.get_evaluator();
262 tw.set_lvalue_list (lvl);
263 }, tw.lvalue_list ());
264 tw.set_lvalue_list (
nullptr);
268 error (
"@%s/numel: invalid return value", cls.
get_name ().c_str ());
270 retval = lv(0).idx_type_value (
true);
302 os <<
" with properties:";
309 std::map<std::string, octave::cdef_property> property_map
312 std::size_t max_len = 0;
313 for (
const auto& pname_prop : property_map)
320 const std::string nm = prop.
get_name ();
332 std::size_t sz = nm.
size ();
338 for (
auto& pname_prop : property_map)
342 const std::string nm = prop.
get_name ();
363 os << std::setw (max_len+2) << nm <<
": ";
393 const std::string& cls)
449 if (meth_name.empty ())
480 std::string meth_name;
487 error (
"superclass calls can only occur in methods or constructors");
500 error (
"'%s' is not a direct superclass of '%s'",
501 cname.c_str (), ctx.
get_name ().c_str ());
504 error (
"cannot call superclass constructor with variable '%s'",
515 std::size_t pos = mname.find (
'.');
519 if (pos != std::string::npos)
524 mname = mname.substr (pos + 1);
547 if (mname != meth_name)
548 error (
"method name mismatch ('%s' != '%s')",
549 mname.c_str (), meth_name.c_str ());
552 error (
"'%s' is not a superclass of '%s'",
553 cname.c_str (), ctx.
get_name ().c_str ());
569 error (
"no method '%s' found in superclass '%s'",
570 meth_name.c_str (), cname.c_str ());
573 ? meth.
execute (obj, idx, nargout,
true, meth_name)
574 : meth.
execute (idx, nargout,
true, meth_name));
581 const std::string& nm)
593 if (ret_list && ret_list->
length () == 1)
594 return (ret_list->
front ()->
name () == nm);
601OCTAVE_NAMESPACE_BEGIN
603DEFUN (__meta_get_package__, args, ,
609 if (args.length () != 1)
612 std::string cname = args(0).xstring_value (
"PACKAGE_NAME must be a string");
617DEFUN (metaclass, args, ,
623 if (args.length () != 1)
628 return to_ov (obj.get_class ());
652 if (args.length () != 1)
657 std::string class_name;
671 error (
"invalid class: %s", class_name.c_str ());
673 std::map<std::string, cdef_property> property_map =
674 cls.get_property_map ();
676 std::list<std::string> property_names;
678 for (
const auto& pname_prop : property_map)
683 const cdef_property& prop = pname_prop.second;
685 std::string nm = prop.get_name ();
697 property_names.push_back (nm);
703 octave_stdout <<
"properties for class " << class_name <<
":\n\n";
705 for (
const auto& nm : property_names)
735 std::string class_name;
750 std::map<std::string, cdef_method> method_map
751 = cls.get_method_map (
false,
true);
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)
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="")
std::size_t length(void) const
std::map< std::string, cdef_property > get_property_map(int mode=property_normal)
void doc_string(const std::string &txt)
OCTINTERP_API cdef_method find_method(const std::string &nm, bool local=false)
void file_name(const std::string &nm)
std::string get_name(void) const
void run_constructor(cdef_object &obj, const octave_value_list &args)
bool is_defined_in_class(const std::string &cname) const
octave_value_list execute(const octave_value_list &args, int nargout, bool do_check_access=true, const std::string &who="")
std::string get_doc_string(void)
cdef_object make_array(void) const
octave_value_list subsref(const std::string &type, const std::list< octave_value_list > &idx, int nargout, std::size_t &skip, const cdef_class &context, bool auto_add=false)
OCTINTERP_API cdef_class get_class(void) const
octave_value subsasgn(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs, int ignore_copies=0)
octave_value get(const std::string &pname) const
bool is_array(void) const
octave_value get_value(const cdef_object &obj, bool do_check_access=true, const std::string &who="") const
std::string get_name(void) const
std::string name(void) const
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
OCTINTERP_API octave_classdef * classdef_object_value(bool silent=false) const
std::string string_value(bool force=false) const
bool isobject(void) const
bool islogical(void) const
dim_vector dims(void) const
string_vector & append(const std::string &s)
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)
T::properties & properties(graphics_object obj)
octave_value to_ov(const cdef_object &obj)
bool is_superclass(const cdef_class &clsa, const cdef_class &clsb, bool allow_equal, int max_depth)
cdef_class get_class_context(std::string &name, bool &in_constructor)
class OCTINTERP_API cdef_class
class OCTINTERP_API cdef_object
cdef_object & to_cdef_ref(const octave_value &val)
cdef_object to_cdef(const octave_value &val)
cdef_class lookup_class(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)
interpreter & __get_interpreter__(const std::string &who)
bool is_strict_superclass(const cdef_class &clsa, const cdef_class &clsb)
cdef_package lookup_package(const std::string &name, bool error_if_not_found, bool load_if_not_found)
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.