26 #if defined (HAVE_CONFIG_H)
50 if (args.
length () == 1 && args(0).type_name () ==
"object")
65 if (args.
length () == 1 && args(0).type_name () ==
"object")
80 if (args.
length () == 1 && args(0).type_name () ==
"object"
81 && args(0).class_name () ==
"meta.class")
98 if (args.
length () == 1 && args(0).type_name () ==
"object"
99 && args(0).class_name () ==
"meta.class")
117 error (
"fromName: invalid number of parameters");
119 std::string name = args(0).xstring_value (
"fromName: CLASS_NAME must be a string");
129 if (args.
length () <= 1 || args(0).type_name () !=
"object")
130 error (
"fevalStatic: first argument must be a meta.class object");
134 std::string meth_name = args(1).xstring_value (
"fevalStatic: method name must be a string");
139 error (
"fevalStatic: method not found: %s", meth_name.c_str ());
142 error (
"fevalStatic: method '%s' is not static", meth_name.c_str ());
144 return meth.
execute (args.
splice (0, 2), nargout,
true,
"fevalStatic");
152 if (args.
length () != 2 || args(0).type_name () !=
"object"
153 || args(0).class_name () !=
"meta.class")
154 error (
"getConstant: first argument must be a meta.class object");
158 std::string prop_name = args(1).xstring_value (
"getConstant: property name must be a string");
163 error (
"getConstant: property not found: %s",
167 error (
"getConstant: property '%s' is not constant",
170 retval(0) = prop.
get_value (
true,
"getConstant");
175 #define META_CLASS_CMP(OP, CLSA, CLSB, FCN) \
176 static octave_value_list \
177 class_ ## OP (const octave_value_list& args, int ) \
179 octave_value_list retval; \
181 if (args.length () != 2 \
182 || args(0).type_name () != "object" \
183 || args(1).type_name () != "object" \
184 || args(0).class_name () != "meta.class" \
185 || args(1).class_name () != "meta.class") \
186 error (#OP ": invalid arguments"); \
188 cdef_class clsa = to_cdef (args(0)); \
190 cdef_class clsb = to_cdef (args(1)); \
192 retval(0) = FCN (CLSA, CLSB); \
209 if (args.length () == 1 && args(0).type_name () ==
"object")
213 retval(0) = prop.
get (
"DefaultValue");
215 if (! retval(0).is_defined ())
217 "no default value for property '%s'",
239 if (args.
length () == 1 && args(0).type_name () ==
"object"
240 && args(0).class_name () ==
"meta.package")
255 if (args.
length () == 0 && args(0).type_name () ==
"object"
256 && args(0).class_name () ==
"meta.package")
271 if (args.
length () == 0 && args(0).type_name () ==
"object"
272 && args(0).class_name () ==
"meta.package")
287 std::map<std::string, cdef_package> toplevel_packages;
295 toplevel_packages[
"meta"] = cdm.
find_package (
"meta",
false,
false);
297 for (
const auto& nm : names)
298 toplevel_packages[nm] = cdm.
find_package (nm,
false,
true);
300 Cell c (toplevel_packages.size (), 1);
304 for (
const auto& nm_pkg : toplevel_packages)
305 c(i++, 0) =
to_ov (nm_pkg.second);
316 error (
"fromName: invalid number of parameters");
318 std::string name = args(0).xstring_value (
"fromName: PACKAGE_NAME must be a string");
326 : m_interpreter (interp), m_all_classes (), m_all_packages (),
327 m_meta_class (), m_meta_property (), m_meta_method (),
328 m_meta_package (), m_meta ()
383 "meta.class>get.InferiorClasses"),
384 "public",
Matrix (),
"private"));
389 "meta.class>get.Methods"),
390 "public",
Matrix (),
"private"));
395 "meta.class>get.MethodList"),
396 "public",
Matrix (),
"private"));
403 "meta.class>get.Properties"),
404 "public",
Matrix (),
"private"));
409 "meta.class>get.PropertyList"),
410 "public",
Matrix (),
"private"));
417 "meta.class>get.SuperClasses"),
418 "public",
Matrix (),
"private"));
423 "meta.class>get.SuperclassList"),
424 "public",
Matrix (),
"private"));
432 "meta.class>get.SuperclassList"),
433 "public",
Matrix (),
"private"));
531 "meta.property>get.DefaultValue"),
532 "public",
Matrix (),
"private"));
556 "meta.package>get.ClassList"),
557 "public",
Matrix (),
"private"));
562 "meta.package>get.Classes"),
563 "public",
Matrix (),
"private"));
568 "meta.package>get.FunctionList"),
569 "public",
Matrix (),
"private"));
574 "meta.package>get.Functions"),
575 "public",
Matrix (),
"private"));
580 "meta.package>get.PackageList"),
581 "public",
Matrix (),
"private"));
586 "meta.package>get.Packages"),
587 "public",
Matrix (),
"private"));
607 package_meta.
install_class (tmp_meta_dynproperty,
"dynproperty");
636 bool load_if_not_found)
642 if (load_if_not_found)
646 std::size_t pos = name.rfind (
'.');
648 if (pos == std::string::npos)
652 std::string pack_name = name.substr (0, pos);
657 ov_cls = pack.
find (name.substr (pos+1));
667 if (error_if_not_found)
668 error (
"class not found: %s", name.c_str ());
688 const std::string& class_name)
705 bool load_if_not_found)
709 std::map<std::string, cdef_package>::const_iterator it
717 error (
"invalid package '%s'", name.c_str ());
725 std::size_t pos = name.rfind (
'.');
727 if (pos == std::string::npos)
731 std::string parent_name = name.substr (0, pos);
736 else if (error_if_not_found)
737 error (
"unknown package '%s'", name.c_str ());
756 const std::list<cdef_class>& super_list)
762 cls.
put (
"Abstract",
false);
763 cls.
put (
"ConstructOnLoad",
false);
764 cls.
put (
"ContainingPackage",
Matrix ());
765 cls.
put (
"Description",
"");
766 cls.
put (
"DetailedDescription",
"");
768 cls.
put (
"Hidden",
false);
769 cls.
put (
"InferiorClasses",
Cell ());
771 cls.
put (
"Properties",
Cell ());
772 cls.
put (
"Sealed",
false);
774 if (name ==
"handle")
776 cls.
put (
"HandleCompatible",
true);
779 else if (super_list.empty ())
781 cls.
put (
"HandleCompatible",
false);
785 bool all_handle_compatible =
true;
786 bool has_handle_class =
false;
788 for (
const auto& cl : super_list)
790 all_handle_compatible = all_handle_compatible
791 && cl.get (
"HandleCompatible").bool_value ();
793 has_handle_class = has_handle_class || cl.is_handle_class ();
796 if (has_handle_class && ! all_handle_compatible)
797 error (
"%s: cannot mix handle and non-HandleCompatible classes",
800 cls.
put (
"HandleCompatible", all_handle_compatible);
801 if (has_handle_class)
815 return make_class (name, std::list<cdef_class> (1, super));
824 cls.
put (
"Sealed",
true);
833 const std::string& get_access,
835 const std::string& set_access)
841 prop.
put (
"Description",
"");
842 prop.
put (
"DetailedDescription",
"");
843 prop.
put (
"Abstract",
false);
844 prop.
put (
"Constant",
false);
845 prop.
put (
"GetAccess", get_access);
846 prop.
put (
"SetAccess", set_access);
847 prop.
put (
"Dependent",
false);
848 prop.
put (
"Transient",
false);
849 prop.
put (
"Hidden",
false);
850 prop.
put (
"GetObservable",
false);
851 prop.
put (
"SetObservable",
false);
852 prop.
put (
"GetMethod", get_method);
853 prop.
put (
"SetMethod", set_method);
854 prop.
put (
"DefiningClass",
to_ov (cls));
856 prop.
put (
"HasDefault",
false);
858 std::string class_name = cls.
get_name ();
877 const std::string& m_access,
bool is_static)
883 meth.
put (
"Abstract",
false);
884 meth.
put (
"Access", m_access);
885 meth.
put (
"DefiningClass",
to_ov (cls));
886 meth.
put (
"Description",
"");
887 meth.
put (
"DetailedDescription",
"");
888 meth.
put (
"Hidden",
false);
889 meth.
put (
"Sealed",
true);
890 meth.
put (
"Static", is_static);
906 const std::string& m_access,
bool is_static)
910 return make_method (cls, name, fcn, m_access, is_static);
916 const std::string& m_access,
bool is_static)
920 return make_method (cls, name, fcn, m_access, is_static);
931 pack.
put (
"ContainingPackage",
Matrix ());
943 const std::string& name)
const
class OCTINTERP_API cdef_class
static octave_value_list class_lt(const octave_value_list &args, int)
static octave_value_list class_gt(const octave_value_list &args, int)
static octave_value make_fcn_handle(octave_builtin::fcn ff, const std::string &nm)
static octave_value_list property_get_defaultvalue(const octave_value_list &args, int)
static octave_value_list class_fromName(const octave_value_list &args, int)
static octave_value_list class_ne(const octave_value_list &args, int)
static octave_value_list class_get_methods(const octave_value_list &args, int)
static octave_value_list class_eq(const octave_value_list &args, int)
#define META_CLASS_CMP(OP, CLSA, CLSB, FCN)
static octave_value_list class_get_superclasses(const octave_value_list &args, int)
static octave_value_list package_getAllPackages(interpreter &interp, const octave_value_list &, int)
static octave_value_list package_get_classes(const octave_value_list &args, int)
static octave_value_list package_get_functions(const octave_value_list &args, int)
static octave_value_list class_get_properties(const octave_value_list &args, int)
static octave_value_list class_le(const octave_value_list &args, int)
static octave_value_list handle_delete(const octave_value_list &, int)
static octave_value_list class_get_inferiorclasses(const octave_value_list &args, int)
static octave_value_list class_ge(const octave_value_list &args, int)
static octave_value_list package_fromName(const octave_value_list &args, int)
static octave_value_list class_getConstant(const octave_value_list &args, int)
static octave_value_list package_get_packages(const octave_value_list &args, int)
static octave_value_list class_fevalStatic(const octave_value_list &args, int nargout)
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)
bool is_dummy_method(const octave_value &fcn)
cdef_object to_cdef(const octave_value &val)
std::list< cdef_class > lookup_classes(const Cell &cls_list)
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)
void make_function_of_class(const std::string &class_name, const octave_value &fcn)
OCTINTERP_API cdef_method find_method(const std::string &nm, bool local=false)
void install_property(const cdef_property &prop)
std::string get_name(void) const
void install_method(const cdef_method &meth)
octave_value get_method(const std::string &nm) const
octave_value get_constructor_function(void)
void mark_as_meta_class(void)
bool is_builtin(void) const
OCTINTERP_API cdef_property find_property(const std::string &nm)
Cell get_properties(int mode=property_normal)
Cell get_methods(bool include_ctor=false)
void mark_as_handle_class(void)
OCTINTERP_API cdef_class make_class(const std::string &name, const std::list< cdef_class > &super_list=std::list< cdef_class >())
OCTINTERP_API cdef_property make_property(const cdef_class &cls, const std::string &name, const octave_value &get_method=Matrix(), const std::string &get_access="public", const octave_value &set_method=Matrix(), const std::string &set_access="public")
OCTINTERP_API octave_value find_method(const std::string &class_name, const std::string &name) const
const cdef_class & meta_method(void) const
const cdef_class & meta_property(void) const
OCTINTERP_API cdef_package make_package(const std::string &nm, const std::string &parent="")
OCTINTERP_API octave_value find_method_symbol(const std::string &method_name, const std::string &class_name)
OCTINTERP_API cdef_package find_package(const std::string &name, bool error_if_not_found=true, bool load_if_not_found=true)
cdef_class m_meta_property
OCTINTERP_API octave_value find_package_symbol(const std::string &pack_name)
void register_package(const cdef_package &pkg)
cdef_class m_meta_package
const cdef_class & meta_package(void) const
std::map< std::string, cdef_package > m_all_packages
interpreter & m_interpreter
OCTINTERP_API cdef_class find_class(const std::string &name, bool error_if_not_found=true, bool load_if_not_found=true)
const cdef_class & meta_class(void) const
std::map< std::string, cdef_class > m_all_classes
OCTINTERP_API cdef_manager(interpreter &interp)
void register_class(const cdef_class &cls)
OCTINTERP_API cdef_class make_meta_class(const std::string &name, const cdef_class &super)
OCTINTERP_API cdef_method make_method(const cdef_class &cls, const std::string &name, const octave_value &fcn, const std::string &m_access="public", bool is_static=false)
OCTINTERP_API cdef_property make_attribute(const cdef_class &cls, const std::string &name)
octave_value_list execute(const octave_value_list &args, int nargout, bool do_check_access=true, const std::string &who="")
bool is_static(void) const
void set_function(const octave_value &fcn)
void mark_as_external(const std::string &dtype)
void put(const std::string &pname, const octave_value &val)
void set_class(const cdef_class &cls)
octave_value get(const std::string &pname) const
Cell get_classes(void) const
Cell get_packages(void) const
Cell get_functions(void) const
void install_class(const cdef_class &cls, const std::string &nm)
octave_value find(const std::string &nm)
std::string get_name(void) const
bool is_constant(void) const
octave_value get_value(const cdef_object &obj, bool do_check_access=true, const std::string &who="") const
type_info & get_type_info(void)
octave_value find(const std::string &name)
symbol_table & get_symbol_table(void)
cdef_manager & get_cdef_manager(void)
load_path & get_load_path(void)
bool find_package(const std::string &package_name) const
std::list< std::string > get_all_package_names(bool only_top_level=true) const
static void register_type(void)
octave_value_list(* fcn)(const octave_value_list &, int)
octave_value_list(* meth)(octave::interpreter &, const octave_value_list &, int)
octave_idx_type length(void) const
octave_value_list splice(octave_idx_type offset, octave_idx_type len, const octave_value_list &lst=octave_value_list()) const
bool is_defined(void) const
Cell cell_value(void) const
void install_built_in_function(const std::string &name, const octave_value &fcn)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
void error_with_id(const char *id, const char *fmt,...)
void error(const char *fmt,...)
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))