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",
175 #define META_CLASS_CMP(OP, CLSA, CLSB, FUN) \
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) = FUN (CLSA, CLSB); \
209 if (args.length () == 1 && args(0).type_name () ==
"object")
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")
286 std::map<std::string, cdef_package> toplevel_packages;
294 toplevel_packages[
"meta"] = cdm.
find_package (
"meta",
false,
false);
296 for (
const auto& nm : names)
297 toplevel_packages[nm] = cdm.
find_package (nm,
false,
true);
299 Cell c (toplevel_packages.size (), 1);
303 for (
const auto& nm_pkg : toplevel_packages)
304 c(i++,0) =
to_ov (nm_pkg.second);
315 error (
"fromName: invalid number of parameters");
317 std::string
name = args(0).xstring_value (
"fromName: PACKAGE_NAME must be a string");
325 : m_interpreter (interp), m_all_classes (), m_all_packages (),
326 m_meta_class (), m_meta_property (), m_meta_method (),
327 m_meta_package (), m_meta ()
382 "meta.class>get.InferiorClasses"),
383 "public",
Matrix (),
"private"));
388 "meta.class>get.Methods"),
389 "public",
Matrix (),
"private"));
394 "meta.class>get.MethodList"),
395 "public",
Matrix (),
"private"));
402 "meta.class>get.Properties"),
403 "public",
Matrix (),
"private"));
408 "meta.class>get.PropertyList"),
409 "public",
Matrix (),
"private"));
416 "meta.class>get.SuperClasses"),
417 "public",
Matrix (),
"private"));
422 "meta.class>get.SuperclassList"),
423 "public",
Matrix (),
"private"));
431 "meta.class>get.SuperclassList"),
432 "public",
Matrix (),
"private"));
530 "meta.property>get.DefaultValue"),
531 "public",
Matrix (),
"private"));
555 "meta.package>get.ClassList"),
556 "public",
Matrix (),
"private"));
561 "meta.package>get.Classes"),
562 "public",
Matrix (),
"private"));
567 "meta.package>get.FunctionList"),
568 "public",
Matrix (),
"private"));
573 "meta.package>get.Functions"),
574 "public",
Matrix (),
"private"));
579 "meta.package>get.PackageList"),
580 "public",
Matrix (),
"private"));
585 "meta.package>get.Packages"),
586 "public",
Matrix (),
"private"));
606 package_meta.
install_class (tmp_meta_dynproperty,
"dynproperty");
635 bool load_if_not_found)
641 if (load_if_not_found)
645 size_t pos =
name.rfind (
'.');
647 if (pos == std::string::npos)
651 std::string pack_name =
name.substr (0, pos);
656 ov_cls = pack.
find (
name.substr (pos+1));
666 if (error_if_not_found)
667 error (
"class not found: %s",
name.c_str ());
687 const std::string& class_name)
704 bool load_if_not_found)
708 std::map<std::string, cdef_package>::const_iterator it
716 error (
"invalid package '%s'",
name.c_str ());
724 size_t pos =
name.rfind (
'.');
726 if (pos == std::string::npos)
730 std::string parent_name =
name.substr (0, pos);
735 else if (error_if_not_found)
736 error (
"unknown package '%s'",
name.c_str ());
755 const std::list<cdef_class>& super_list)
761 cls.
put (
"Abstract",
false);
762 cls.
put (
"ConstructOnLoad",
false);
763 cls.
put (
"ContainingPackage",
Matrix ());
764 cls.
put (
"Description",
"");
765 cls.
put (
"DetailedDescription",
"");
767 cls.
put (
"Hidden",
false);
768 cls.
put (
"InferiorClasses",
Cell ());
770 cls.
put (
"Properties",
Cell ());
771 cls.
put (
"Sealed",
false);
773 if (
name ==
"handle")
775 cls.
put (
"HandleCompatible",
true);
778 else if (super_list.empty ())
780 cls.
put (
"HandleCompatible",
false);
784 bool all_handle_compatible =
true;
785 bool has_handle_class =
false;
787 for (
const auto& cl : super_list)
789 all_handle_compatible = all_handle_compatible
790 && cl.get (
"HandleCompatible").bool_value ();
792 has_handle_class = has_handle_class || cl.is_handle_class ();
795 if (has_handle_class && ! all_handle_compatible)
796 error (
"%s: cannot mix handle and non-HandleCompatible classes",
799 cls.
put (
"HandleCompatible", all_handle_compatible);
800 if (has_handle_class)
823 cls.
put (
"Sealed",
true);
832 const std::string& get_access,
834 const std::string& set_access)
840 prop.
put (
"Description",
"");
841 prop.
put (
"DetailedDescription",
"");
842 prop.
put (
"Abstract",
false);
843 prop.
put (
"Constant",
false);
844 prop.
put (
"GetAccess", get_access);
845 prop.
put (
"SetAccess", set_access);
846 prop.
put (
"Dependent",
false);
847 prop.
put (
"Transient",
false);
848 prop.
put (
"Hidden",
false);
849 prop.
put (
"GetObservable",
false);
850 prop.
put (
"SetObservable",
false);
851 prop.
put (
"GetMethod", get_method);
852 prop.
put (
"SetMethod", set_method);
853 prop.
put (
"DefiningClass",
to_ov (cls));
855 prop.
put (
"HasDefault",
false);
857 std::string class_name = cls.
get_name ();
876 const std::string& m_access,
bool is_static)
882 meth.
put (
"Abstract",
false);
883 meth.
put (
"Access", m_access);
884 meth.
put (
"DefiningClass",
to_ov (cls));
885 meth.
put (
"Description",
"");
886 meth.
put (
"DetailedDescription",
"");
887 meth.
put (
"Hidden",
false);
888 meth.
put (
"Sealed",
true);
889 meth.
put (
"Static", is_static);
905 const std::string& m_access,
bool is_static)
915 const std::string& m_access,
bool is_static)
930 pack.
put (
"ContainingPackage",
Matrix ());
942 const std::string&
name)
const
#define META_CLASS_CMP(OP, CLSA, CLSB, FUN)
Cell get_methods(bool include_ctor=false)
void install_property(const cdef_property &prop)
bool is_builtin(void) const
void install_method(const cdef_method &meth)
cdef_method find_method(const std::string &nm, bool local=false)
cdef_property find_property(const std::string &nm)
octave_value get_method(const std::string &nm) const
Cell get_properties(int mode=property_normal)
void mark_as_handle_class(void)
std::string get_name(void) const
void mark_as_meta_class(void)
octave_value get_constructor_function(void)
octave_value find_method_symbol(const std::string &method_name, const std::string &class_name)
std::map< std::string, cdef_package > m_all_packages
cdef_class find_class(const std::string &name, bool error_if_not_found=true, bool load_if_not_found=true)
interpreter & m_interpreter
std::map< std::string, cdef_class > m_all_classes
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")
const cdef_class & meta_package(void) const
void register_package(const cdef_package &pkg)
cdef_class make_meta_class(const std::string &name, const cdef_class &super)
cdef_package make_package(const std::string &nm, const std::string &parent="")
cdef_class m_meta_package
cdef_manager(interpreter &interp)
void register_class(const cdef_class &cls)
octave_value find_package_symbol(const std::string &pack_name)
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)
const cdef_class & meta_property(void) const
cdef_class m_meta_property
const cdef_class & meta_method(void) const
cdef_class make_class(const std::string &name, const std::list< cdef_class > &super_list=std::list< cdef_class >())
cdef_package find_package(const std::string &name, bool error_if_not_found=true, bool load_if_not_found=true)
cdef_property make_attribute(const cdef_class &cls, const std::string &name)
const cdef_class & meta_class(void) const
octave_value find_method(const std::string &class_name, const std::string &name) const
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 mark_as_external(const std::string &dtype)
void set_function(const octave_value &fcn)
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
octave_value find(const std::string &nm)
Cell get_functions(void) const
Cell get_classes(void) const
Cell get_packages(void) const
void install_class(const cdef_class &cls, const std::string &nm)
octave_value get_value(const cdef_object &obj, bool do_check_access=true, const std::string &who="") const
bool is_constant(void) const
std::string get_name(void) const
load_path & get_load_path(void)
cdef_manager & get_cdef_manager(void)
type_info & get_type_info(void)
symbol_table & get_symbol_table(void)
octave_value find(const std::string &name)
std::list< std::string > get_all_package_names(bool only_top_level=true) const
bool find_package(const std::string &package_name) const
void install_built_in_function(const std::string &name, const octave_value &fcn)
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 error_with_id(const char *id, const char *fmt,...)
void error(const char *fmt,...)
static octave_value_list class_le(const octave_value_list &args, int)
bool is_superclass(const cdef_class &clsa, const cdef_class &clsb, bool allow_equal, int max_depth)
static octave_value_list class_gt(const octave_value_list &args, int)
static octave_value_list class_get_methods(const octave_value_list &args, int)
std::list< cdef_class > lookup_classes(const Cell &cls_list)
static octave_value_list handle_delete(const octave_value_list &, int)
void make_function_of_class(const std::string &class_name, const octave_value &fcn)
bool is_dummy_method(const octave_value &fcn)
octave_value to_ov(const cdef_object &obj)
static octave_value_list class_fromName(const octave_value_list &args, int)
static octave_value_list package_get_packages(const octave_value_list &args, int)
cdef_object to_cdef(const octave_value &val)
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 class_get_properties(const octave_value_list &args, int)
static octave_value_list property_get_defaultvalue(const octave_value_list &args, 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)
cdef_package lookup_package(const std::string &name, bool error_if_not_found, bool load_if_not_found)
static octave_value_list class_eq(const octave_value_list &args, int)
cdef_class lookup_class(const std::string &name, bool error_if_not_found, bool load_if_not_found)
static octave_value_list class_lt(const octave_value_list &args, int)
static octave_value_list class_fevalStatic(const octave_value_list &args, int nargout)
static octave_value_list class_getConstant(const octave_value_list &args, int)
static octave_value_list package_get_functions(const octave_value_list &args, int)
static octave_value_list class_ne(const octave_value_list &args, int)
static octave_value_list package_get_classes(const octave_value_list &args, int)
static octave_value_list package_fromName(const octave_value_list &args, int)
bool is_strict_superclass(const cdef_class &clsa, const cdef_class &clsb)
static octave_value make_fcn_handle(const octave_value &fcn, const std::string &meth_name, const std::string &class_name)
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
octave_value::octave_value(const Array< char > &chm, char type) return retval