23 #if ! defined (octave_classdef_h) 24 #define octave_classdef_h 1 26 #include "octave-config.h" 72 { err_invalid_object (
"set_class"); }
76 err_invalid_object (
"clone");
81 err_invalid_object (
"empty_clone");
86 err_invalid_object (
"copy");
91 err_invalid_object (
"make_array");
94 virtual bool is_array (
void)
const {
return false; }
104 err_invalid_object (
"array_value");
108 { err_invalid_object (
"put"); }
112 err_invalid_object (
"get");
118 err_invalid_object (
"set_property");
123 err_invalid_object (
"get_property");
130 err_invalid_object (
"subsref");
137 err_invalid_object (
"subsasgn");
142 virtual bool is_valid (
void)
const {
return false; }
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");
200 {
error (
"%s: invalid object", who); }
283 bool auto_add =
false)
363 void register_object (
void);
365 void unregister_object (
void);
451 if (
val.numel () < 1)
452 error (
"get: unknown slot: %s",
pname.c_str ());
461 error (
"invalid index");
470 error (
"invalid index");
587 virtual bool is_class (
void)
const {
return false; }
597 const std::list<octave_value_list>& ,
600 error (
"subsref: invalid meta object");
647 const std::list<octave_value_list>& idx,
int nargout)
653 {
return get_rep ()->meta_accepts_postfix_index (
type); }
674 object_count (0), meta (
false)
684 {
return get (
"Name").string_value (); }
688 bool is_abstract (
void)
const {
return get (
"Abstract").bool_value (); }
690 bool is_sealed (
void)
const {
return get (
"Sealed").bool_value (); }
696 Cell get_methods (
void);
704 std::map<std::string, cdef_property> get_property_map (
int mode);
716 const std::list<octave_value_list>& idx,
int nargout);
718 void meta_release (
void);
721 {
return (
type ==
'(' ||
type ==
'.'); }
750 property_map.clear ();
762 void load_all_methods (
void);
764 void find_names (std::set<std::string>& names,
bool all);
766 void find_properties (std::map<std::string,cdef_property>& props,
769 void find_methods (std::map<std::string, cdef_method>& meths,
770 bool only_inherited);
814 method_map (
c.method_map), property_map (
c.property_map),
815 member_count (
c.member_count), handle_class (
c.handle_class),
816 implicit_ctor_list (
c.implicit_ctor_list),
817 object_count (
c.object_count), meta (
c.meta) { }
837 error (
"internal error: invalid assignment from %s to meta.class object",
851 {
get_rep ()->install_method (meth); }
858 {
get_rep ()->install_property (prop); }
863 std::map<std::string, cdef_property>
874 {
get_rep ()->set_directory (dir); }
877 {
return get_rep ()->get_directory (); }
880 {
return get_rep ()->get_name (); }
883 {
return get_directory ().empty (); }
886 {
get_rep ()->delete_object (obj); }
910 bool is_at_folder =
false);
915 {
return get_method_function (get_name ()); }
918 {
return get_rep ()->construct (args); }
921 {
return get_rep ()->construct_object (args); }
924 {
get_rep ()->initialize_object (obj); }
927 {
get_rep ()->run_constructor (obj, args); }
930 {
get_rep ()->mark_as_handle_class (); }
933 {
return get_rep ()->is_handle_class (); }
972 {
return ! (clsa == clsb); }
1001 bool is_constant (
void)
const {
return get(
"Constant").bool_value (); }
1007 bool do_check_access =
true,
1011 bool do_check_access =
true,
1014 bool check_get_access (
void)
const;
1016 bool check_set_access (
void)
const;
1022 bool is_recursive_set (
const cdef_object& obj)
const;
1046 error (
"internal error: invalid assignment from %s to meta.property object",
1059 {
return get_rep ()->get_value (obj, do_check_access, who); }
1063 {
return get_rep ()->get_value (do_check_access, who); }
1066 bool do_check_access =
true,
1068 {
get_rep ()->set_value (obj,
val, do_check_access, who); }
1071 {
return get_rep ()->check_get_access (); }
1074 {
return get_rep ()->check_set_access (); }
1111 bool is_static (
void)
const {
return get(
"Static").bool_value (); }
1122 { dispatch_type = dtype; }
1125 bool do_check_access =
true,
1130 bool do_check_access =
true,
1133 bool is_constructor (
void)
const;
1137 const std::list<octave_value_list>& idx,
int nargout);
1140 {
return (
type ==
'(' ||
type ==
'.'); }
1145 dispatch_type (m.dispatch_type)
1148 void check_method (
void);
1178 error (
"internal error: invalid assignment from %s to meta.method object",
1191 bool do_check_access =
true,
1193 {
return get_rep ()->execute (args,
nargout, do_check_access, who); }
1198 bool do_check_access =
true,
1200 {
return get_rep ()->execute (obj, args,
nargout, do_check_access, who); }
1212 {
return get_rep ()->get_function (); }
1215 {
return get_rep ()->is_constructor (); }
1220 {
get_rep ()->mark_as_external (dtype); }
1333 Cell get_classes (
void)
const;
1335 Cell get_functions (
void)
const;
1337 Cell get_packages (
void)
const;
1350 package_map.clear ();
1358 const std::list<octave_value_list>& idx,
int nargout);
1363 {
return (
type ==
'.'); }
1386 class_map (
p.class_map), function_map (
p.function_map),
1387 package_map (
p.package_map), member_count (
p.member_count)
1412 error (
"internal error: invalid assignment from %s to meta.package object",
1424 {
get_rep ()->install_class (cls,
nm); }
1430 {
get_rep ()->install_package (pack,
nm); }
1433 {
return get_rep ()->get_classes (); }
1436 {
return get_rep ()->get_functions (); }
1439 {
return get_rep ()->get_packages (); }
1488 void print (std::ostream&
os,
bool pr_as_read_syntax =
false);
1490 void print_raw (std::ostream&
os,
bool pr_as_read_syntax =
false)
const;
1495 bool print_padding =
true);
1497 bool is_instance_of (
const std::string& cls_name)
const;
1500 const std::list<octave_value_list>& idx,
1504 const std::list<octave_value_list>& idx)
1511 const std::list<octave_value_list>& idx,
1515 const std::list<octave_value_list>& idx,
1520 const std::list<octave_value_list>& idx,
1534 object.set_property (idx,
name, pval);
1540 return object.get_property (idx,
name);
1578 if (
val.type_name () !=
"object")
1579 error (
"cannot convert `%s' into `object'",
val.type_name().c_str ());
1587 if (
val.type_name () !=
"object")
1588 error (
"cannot convert `%s' into `object'",
val.type_name().c_str ());
1615 bool load_if_not_found =
true);
1621 bool error_if_not_found =
true,
1622 bool load_if_not_found =
true);
1628 m_all_classes[cls.
get_name ()] = cls;
1633 m_all_classes.erase(cls.
get_name ());
1638 m_all_packages[pkg.
get_name ()] = pkg;
1643 m_all_packages.erase (pkg.
get_name ());
1655 const std::list<cdef_class>& super_list = std::list<cdef_class> ());
1677 bool is_static =
false);
1683 bool is_static =
false);
1689 bool is_static =
false);
void unregister_class(const cdef_class &cls)
cdef_object get_object(void) const
cdef_object_rep * copy(void) const
virtual bool is_meta_object(void) const
std::map< std::string, cdef_package > package_map
cdef_package(const std::string &nm)
octave_value get_property(octave_idx_type idx, const std::string &pname) const
string_vector map_keys(void) const
void unregister_object(void)
bool check_get_access(void) const
bool is_meta_class(void) const
octave::interpreter & m_interpreter
bool is_sealed(void) const
void unregister_object(void)
void unregister_object(void)
virtual cdef_class get_class(void) const
bool is_array(void) const
bool is_property(void) const
octave_value find(const std::string &nm)
octave_value get_property(octave_idx_type idx, const std::string &pname) const
octave::refcount< octave_idx_type > object_count
void set_property(octave_idx_type idx, const std::string &pname, const octave_value &pval)
const cdef_class & meta_method(void) const
OCTAVE_NORETURN void err_invalid_object(const char *who) const
Cell get_properties(int mode=property_normal)
cdef_object make_array(void) const
static 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=false)
std::string type_name(void) const
octave_value_list execute(const cdef_object &obj, const octave_value_list &args, int nargout, bool do_check_access=true, const std::string &who="")
static cdef_class make_meta_class(octave::interpreter &interp, octave::tree_classdef *t, bool is_at_folder=false)
Analyze the tree_classdef tree and transform it to a cdef_class.
void register_object(void)
void install_method(const cdef_method &meth)
virtual cdef_object_rep * make_array(void) const
std::string get_name(void) const
void assign(const std::string &k, const Cell &val)
cdef_method_rep(const cdef_method_rep &m)
octave_value_list subsref(const std::string &type, const std::list< octave_value_list > &idx, int nargout, size_t &skip, const cdef_class &context, bool auto_add=false)
octave_idx_type member_count
bool is_abstract(void) const
cdef_object_rep * clone(void) const
cdef_object empty_clone(void) const
std::map< std::string, octave_value >::const_iterator function_const_iterator
bool is_value_object(void) const
virtual bool is_constructed_for(const cdef_class &) const
void set_value(cdef_object &obj, const octave_value &val, bool do_check_access=true, const std::string &who="")
dim_vector dims(void) const
identity matrix If supplied two scalar respectively For allows like xample val
cdef_object & operator=(const cdef_object &obj)
bool is_external(void) const
cdef_object clone(void) const
bool is_partially_constructed_for(const cdef_class &cls) const
bool meta_accepts_postfix_index(char type) const
void set_name(const std::string &nm)
Return the CPU time used by your Octave session The first output is the total time spent executing your process and is equal to the sum of second and third which are the number of CPU seconds spent executing in user mode and the number of CPU seconds spent executing in system mode
cdef_method(const cdef_method &meth)
idx subsref(val, idx) esult
cdef_object_rep * copy(void) const
Cell get_functions(void) const
std::string get_name(void) const
void register_object(void)
virtual bool is_valid(void) const
void mark_for_construction(const cdef_class &cls)
cdef_property(const std::string &nm)
const cdef_property_rep * get_rep(void) const
void put(const std::string &pname, const octave_value &val)
bool is_external(void) const
bool is_sealed(void) const
const cdef_class_rep * get_rep(void) const
Array< cdef_object > array
octave_value_list(* fcn)(const octave_value_list &, int)
void install_package(const cdef_package &pack, const std::string &nm)
std::map< std::string, cdef_class > m_all_classes
void mark_as_constructed(const cdef_class &cls)
void error(const char *fmt,...)
bool is_handle_class(void) const
bool is_handle_object(void) const
void release(const cdef_object &obj)
cdef_object_array(const Array< cdef_object > &a)
cdef_object & to_cdef_ref(const octave_value &val)
void register_object(void)
std::map< cdef_class, std::list< cdef_class > > ctor_list
void register_class(const cdef_class &cls)
bool is_valid(void) const
virtual Array< cdef_object > array_value(void) const
bool is_method(void) const
bool isobject(void) const
static llvm::LLVMContext & context
const cdef_class & meta_package(void) const
virtual bool is_partially_constructed_for(const cdef_class &) const
Cell get_classes(void) const
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function t
cdef_object_rep * copy(void) const
bool is_value_object(void) const
virtual octave_idx_type static_count(void) const
void register_package(const cdef_package &pkg)
nd example oindent opens the file binary numeric values will be read assuming they are stored in IEEE format with the least significant bit and then converted to the native representation Opening a file that is already open simply opens it again and returns a separate file id It is not an error to open a file several though writing to the same file through several different file ids may produce unexpected results The possible values of text mode reading and writing automatically converts linefeeds to the appropriate line end character for the you may append a you must also open the file in binary mode The parameter conversions are currently only supported for and permissions will be set to and then everything is written in a single operation This is very efficient and improves performance c
void set_property(octave_idx_type idx, const std::string &name, const octave_value &pval)
bool is_package(void) const
bool check_access(void) const
void set_name(const std::string &nm)
std::string get_name(void) const
std::map< std::string, cdef_class >::iterator class_iterator
void fill_empty_values(void)
handle_cdef_object(const handle_cdef_object &obj)
virtual bool is_handle_object(void) const
virtual bool is_value_object(void) const
std::string get_name(void) const
const cdef_package_rep * get_rep(void) const
std::map< std::string, cdef_property >::iterator property_iterator
Array< cdef_object > array_value(void) const
virtual string_vector map_keys(void) const
cdef_property_rep(const cdef_property_rep &p)
void set_name(const std::string &nm)
virtual void mark_as_constructed(void)
void initialize_object(cdef_object &obj)
std::map< std::string, cdef_property >::const_iterator property_const_iterator
octave_idx_type static_count(void) const
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
cdef_class & operator=(const cdef_class &cls)
bool is_classdef_object(void) const
bool is_abstract(void) const
bool is_handle_object(void) const
then the function must return scalars which will be concatenated into the return array(s). If code
cdef_object_rep * make_array(void) const
std::string class_name(void) const
bool is_static(void) const
virtual octave_value get(const std::string &) const
void set_property(octave_idx_type idx, const std::string &pname, const octave_value &pval)
nd deftypefn *std::string name
void install_class(const cdef_class &cls, const std::string &nm)
cdef_package_rep * get_rep(void)
OCTAVE_EXPORT octave_value_list isdir nd deftypefn *std::string nm
std::map< std::string, cdef_package >::const_iterator package_const_iterator
virtual bool is_constructed(void) const
void set_directory(const std::string &dir)
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function xample nargout(@histc)
cdef_object copy(void) const
bool is_valid(void) const
cdef_method find_method(const std::string &nm, bool local=false)
Array< cdef_object > array_value(void) const
cdef_object_rep * empty_clone(void) const
OCTINTERP_API void install_classdef(octave::interpreter &interp)
octave_function * get_constructor_function(void)
const cdef_object_rep * get_rep(void) const
create a structure array and initialize its values The dimensions of each cell array of values must match Singleton cells and non cell values are repeated so that they fill the entire array If the cells are create an empty structure array with the specified field names If the argument is an object
virtual octave_value get_property(octave_idx_type, const std::string &) const
cdef_object_base(const cdef_object_base &obj)
void set_property(octave_idx_type idx, const std::string &pname, const octave_value &pval)
octave_value get_value(bool do_check_access=true, const std::string &who="")
cdef_object_rep * get_rep(void)
virtual octave_value subsasgn(const std::string &, const std::list< octave_value_list > &, const octave_value &)
bool is_meta_object(void) const
virtual void put(const std::string &, const octave_value &)
void mark_as_external(const std::string &dtype)
void put(const std::string &pname, const octave_value &val)
cdef_object_rep * copy(void) const
bool operator<(const cdef_class &clsa, const cdef_class &clsb)
virtual void mark_for_construction(const cdef_class &)
void mark_as_handle_class(void)
std::string dispatch_type
bool is_defined(void) const
bool meta_accepts_postfix_index(char type) const
octave_value_list execute(const octave_value_list &args, int nargout, bool do_check_access=true, const std::string &who="")
bool is_array(void) const
bool is_constructed_for(const cdef_class &cls) const
std::list< cdef_class > implicit_ctor_list
octave_value to_ov(const cdef_object &obj)
void set_name(const std::string &nm)
cdef_property(const cdef_property &prop)
cdef_method(const std::string &nm)
std::string get_name(void) const
virtual void set_property(octave_idx_type, const std::string &, const octave_value &)
virtual void mark_as_constructed(const cdef_class &)
const cdef_package & meta(void) const
octave_value get_function(void) const
static int static_type_id(void)
virtual ~cdef_object(void)
octave_value_list(* meth)(octave::interpreter &, const octave_value_list &, int)
const Cell & contents(const_iterator p) const
bool is_handle_class(void) const
cdef_package(const cdef_package &pack)
cdef_object_rep(const cdef_object_rep &)
octave_classdef(const cdef_object &obj)
Cell get_packages(void) const
std::string get_directory(void) const
cdef_method_rep * get_rep(void)
void mark_as_meta_class(void)
cdef_class get_class(void) const
std::string release(void)
virtual cdef_object_rep * copy(void) const
std::map< std::string, cdef_package >::iterator package_iterator
virtual cdef_object_rep * clone(void) const
virtual void destroy(void)
dim_vector dims(void) const
octave_value construct(const octave_value_list &args)
void install_function(const octave_value &fcn, const std::string &nm)
cdef_object_rep * clone(void) const
cdef_object_scalar(const cdef_object_scalar &obj)
bool is_constructed(void) const
cdef_property find_property(const std::string &nm)
bool isstruct(void) const
cdef_object(const cdef_object &obj)
cdef_object_rep * copy(void) const
cdef_object & get_object_ref(void)
cdef_class(const cdef_class &cls)
static octave_idx_type find(octave_idx_type i, octave_idx_type *pp)
octave_map map_value(void) const
cdef_property find_property(const std::string &nm)
octave_base_value * clone(void) const
virtual void set_class(const cdef_class &)
octave_value get_property(octave_idx_type idx, const std::string &pname) const
bool is_static(void) const
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
virtual octave_value_list subsref(const std::string &, const std::list< octave_value_list > &, int, size_t &, const cdef_class &, bool)
cdef_class m_meta_package
bool operator!=(const cdef_class &clsa, const cdef_class &clsb)
void make_unique(int ignore_copies)
std::map< std::string, octave_value > function_map
octave_value subsref(const std::string &type, const std::list< octave_value_list > &idx)
bool is_valid(void) const
T::size_type numel(const T &str)
bool check_set_access(void) const
string_vector map_keys(void) const
octave_value get_property(octave_idx_type idx, const std::string &name) const
bool is_constant(void) const
octave::refcount< octave_idx_type > refcount
cdef_object to_cdef(const octave_value &val)
bool is_constructed(void) const
void mark_as_meta_class(void)
std::map< std::string, cdef_package > m_all_packages
bool is_meta_class(void) const
std::string get_name(void) const
void mark_as_handle_class(void)
static const std::string t_name
std::map< std::string, cdef_class >::const_iterator class_const_iterator
std::map< std::string, cdef_property > property_map
void set_class(const cdef_class &cls)
void run_constructor(cdef_object &obj, const octave_value_list &args)
static std::string static_class_name(void)
cdef_object construct_object(const octave_value_list &args)
dim_vector dims(void) const
std::map< std::string, cdef_method > method_map
std::map< std::string, cdef_property > get_property_map(int mode=property_normal)
octave_classdef(const octave_classdef &obj)
int register_type(const std::string &t_name, const std::string &c_name, const octave_value &val)
void mark_as_external(const std::string &dtype)
cdef_class_rep(const cdef_class_rep &c)
cdef_object(cdef_object_rep *r)
const cdef_method_rep * get_rep(void) const
void mark_as_constructed(void)
virtual dim_vector dims(void) const
bool is(const cdef_object &obj) const
idx subsasgn(val, idx, 0) esult
cdef_class_rep * get_rep(void)
std::string get_name(void) const
cdef_class m_meta_property
std::string get_name(void) const
const cdef_class & meta_property(void) const
std::string class_name(void) const
std::map< std::string, octave_value >::iterator function_iterator
cdef_class(const cdef_object &obj)
std::map< std::string, cdef_method >::const_iterator method_const_iterator
const cdef_class & meta_class(void) const
std::map< std::string, cdef_method >::iterator method_iterator
cdef_property_rep * get_rep(void)
void mark_as_constructed(void)
cdef_class(const std::string &nm, const std::list< cdef_class > &superclasses)
value_cdef_object(const value_cdef_object &obj)
cdef_object_array(const cdef_object_array &obj)
cdef_method find_method(const std::string &nm, bool local=false)
octave_value get_value(const cdef_object &obj, bool do_check_access=true, const std::string &who="")
bool operator==(const cdef_class &clsa, const cdef_class &clsb)
virtual bool is_array(void) const
cdef_property(const cdef_object &obj)
static std::string static_type_name(void)
bool is_constructor(void) const
void set_function(const octave_value &fcn)
octave_idx_type member_count
octave_classdef * classdef_object_value(bool=false)
cdef_object_rep * copy(void) const
octave_idx_type length(void) const
bool is_constant(void) const
void set_directory(const std::string &dir)
cdef_method(const cdef_object &obj)
void unregister_package(const cdef_package &pkg)
Vector representing the dimensions (size) of an Array.
cdef_object_rep * clone(void) const
void set_class(const cdef_class &cls)
void install_property(const cdef_property &prop)
bool meta_accepts_postfix_index(char type) const
octave_map map_value(void) const
string_vector get_names(void)
octave_value get_function(void) const
cdef_package(const cdef_object &obj)
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
bool is_builtin(void) const
bool is_class(void) const
virtual cdef_object_rep * empty_clone(void) const
std::string get_directory(void) const
cdef_package_rep(const cdef_package_rep &p)
dim_vector dims(void) const
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)
void delete_object(const cdef_object &obj)
void set_function(const octave_value &fcn)
octave_base_value * empty_clone(void) const
std::map< std::string, cdef_class > class_map
octave_idx_type static_count(void) const
std::string class_name(void) const
OCTAVE_EXPORT octave_value_list directory