26 #if ! defined (octave_cdef_object_h)
27 #define octave_cdef_object_h 1
29 #include "octave-config.h"
66 err_invalid_object (
"set_class");
71 err_invalid_object (
"clone");
76 err_invalid_object (
"empty_clone");
81 err_invalid_object (
"copy");
86 err_invalid_object (
"make_array");
89 virtual bool is_array ()
const {
return false; }
99 err_invalid_object (
"array_value");
103 { err_invalid_object (
"put"); }
107 err_invalid_object (
"get");
113 err_invalid_object (
"set_property");
118 err_invalid_object (
"get_property");
123 err_invalid_object (
"break_closure_cycles");
127 subsref (
const std::string&,
const std::list<octave_value_list>&,
130 err_invalid_object (
"subsref");
134 subsasgn (
const std::string&,
const std::list<octave_value_list>&,
137 err_invalid_object (
"subsasgn");
144 OCTINTERP_API std::string
class_name ()
const;
148 err_invalid_object (
"mark_for_construction");
153 err_invalid_object (
"is_constructed_for");
158 err_invalid_object (
"is_partially_constructed_for");
163 err_invalid_object (
"mark_as_constructed");
168 err_invalid_object (
"mark_as_constructed");
173 err_invalid_object (
"is_constructed");
195 OCTAVE_NORETURN
void err_invalid_object (
const char *who)
const
197 error (
"%s: invalid object", who);
211 { m_rep->m_count++; }
219 if (m_rep != obj.m_rep)
221 m_rep->release (*
this);
234 std::string
class_name ()
const {
return m_rep->class_name (); }
252 bool is_array ()
const {
return m_rep->is_array (); }
261 {
return m_rep->array_value (); }
265 m_rep->put (pname, val);
270 return m_rep->get (pname);
276 return m_rep->set_property (idx, pname, pval);
282 return m_rep->get_property (idx, pname);
287 m_rep->break_closure_cycles (frame);
291 subsref (
const std::string& type,
const std::list<octave_value_list>& idx,
292 int nargout, std::size_t& skip,
const cdef_class& context,
293 bool auto_add =
false)
295 return m_rep->subsref (type, idx, nargout, skip, context, auto_add);
299 subsasgn (
const std::string& type,
const std::list<octave_value_list>& idx,
303 return m_rep->subsasgn (type, idx, rhs);
312 bool ok ()
const {
return m_rep->is_valid (); }
316 m_rep->mark_for_construction (cls);
323 return m_rep->is_constructed_for (cls);
328 return m_rep->is_partially_constructed_for (cls);
334 { m_rep->mark_as_constructed (cls); }
344 if (m_rep->m_count > ignore_copies + 1)
421 subsref (
const std::string& type,
const std::list<octave_value_list>& idx,
422 int nargout, std::size_t& skip,
const cdef_class& context,
426 subsasgn (
const std::string& type,
const std::list<octave_value_list>& idx,
434 return tmp.
put (pname, pval);
442 return tmp.
get (pname);
449 void fill_empty_values () { fill_empty_values (m_array); }
477 m_map.assign (pname, val);
482 Cell val = m_map.contents (pname);
484 if (val.
numel () < 1)
485 error (
"get: unknown slot: %s", pname.c_str ());
494 error (
"invalid index");
503 error (
"invalid index");
509 subsref (
const std::string& type,
const std::list<octave_value_list>& idx,
510 int nargout, std::size_t& skip,
const cdef_class& context,
514 subsasgn (
const std::string& type,
const std::list<octave_value_list>& idx,
638 void doc_string (
const std::string& txt) { m_doc_string = txt; }
644 const std::list<octave_value_list>& ,
647 error (
"subsref: invalid meta object");
700 const std::list<octave_value_list>& idx,
int nargout)
702 return get_rep ()->meta_subsref (type, idx, nargout);
709 return get_rep ()->meta_accepts_postfix_index (type);
725 OCTAVE_END_NAMESPACE(
octave)
octave_idx_type numel() const
Number of elements in the array.
void set_property(octave_idx_type idx, const std::string &pname, const octave_value &pval)
~cdef_object_array()=default
cdef_object_rep * clone() const
Array< cdef_object > array_value() const
octave_value get_property(octave_idx_type idx, const std::string &pname) const
cdef_object_array(const Array< cdef_object > &a)
cdef_object_rep * empty_clone() const
cdef_object_base(const cdef_object_base &obj)
virtual void break_closure_cycles(const std::shared_ptr< stack_frame > &)
virtual octave_value_list subsref(const std::string &, const std::list< octave_value_list > &, int, std::size_t &, const cdef_class &, bool)
virtual bool is_array() const
virtual void mark_as_constructed(const cdef_class &)
virtual void mark_as_constructed()
virtual bool is_constructed_for(const cdef_class &) const
virtual void set_class(const cdef_class &)
virtual void set_property(octave_idx_type, const std::string &, const octave_value &)
virtual ~cdef_object_rep()=default
virtual octave_value get(const std::string &) const
virtual bool is_constructed() const
virtual bool is_meta_object() const
virtual cdef_object_rep * clone() const
virtual cdef_object_rep * make_array() const
virtual cdef_object_rep * empty_clone() const
virtual octave_value get_property(octave_idx_type, const std::string &) const
virtual Array< cdef_object > array_value() const
virtual bool is_partially_constructed_for(const cdef_class &) const
cdef_object_rep(const cdef_object_rep &)
virtual void put(const std::string &, const octave_value &)
virtual bool is_handle_object() const
virtual octave_idx_type static_count() const
virtual cdef_object_rep * copy() const
virtual bool is_valid() const
virtual void mark_for_construction(const cdef_class &)
virtual octave_value subsasgn(const std::string &, const std::list< octave_value_list > &, const octave_value &)
virtual dim_vector dims() const
virtual bool is_value_object() const
refcount< octave_idx_type > m_count
std::map< cdef_class, std::list< cdef_class > > m_ctor_list
bool is_constructed() const
octave_value get_property(octave_idx_type idx, const std::string &pname) const
void mark_as_constructed()
void put(const std::string &pname, const octave_value &val)
octave_value get(const std::string &pname) const
void set_property(octave_idx_type idx, const std::string &pname, const octave_value &pval)
cdef_object_scalar(const cdef_object_scalar &obj)
~cdef_object_scalar()=default
cdef_object clone() const
bool is_constructed() const
void break_closure_cycles(const std::shared_ptr< stack_frame > &frame)
void mark_as_constructed(const cdef_class &cls)
const cdef_object_rep * get_rep() const
cdef_class get_class() const
void mark_for_construction(const cdef_class &cls)
cdef_object & operator=(const cdef_object &obj)
octave_map map_value() const
bool is_partially_constructed_for(const cdef_class &cls) const
bool is_handle_object() const
void put(const std::string &pname, const octave_value &val)
void set_property(octave_idx_type idx, const std::string &pname, const octave_value &pval)
cdef_object(const cdef_object &obj)
string_vector map_keys() const
void mark_as_constructed()
void set_class(const cdef_class &cls)
std::string class_name() const
bool is_meta_object() const
cdef_object make_array() const
octave_value subsasgn(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs, int ignore_copies=0)
cdef_object empty_clone() const
bool is_value_object() const
cdef_object(cdef_object_rep *r)
Array< cdef_object > array_value() const
cdef_object_rep * get_rep()
bool is(const cdef_object &obj) const
void make_unique(int ignore_copies)
octave_value get(const std::string &pname) 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)
bool is_constructed_for(const cdef_class &cls) const
octave_value get_property(octave_idx_type idx, const std::string &pname) const
Vector representing the dimensions (size) of an Array.
handle_cdef_object(const handle_cdef_object &obj)
cdef_object_rep * copy() const
bool is_handle_object() const
cdef_object_rep * clone() const
bool is_value_object() const
cdef_object_rep * copy() const
cdef_object_rep * clone() const
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
void() error(const char *fmt,...)