Mercurial > hg > octave-nkf
diff libinterp/octave-value/ov-classdef.h @ 19376:e0a7718ac085
Implement calling "struct" on classdef objects.
* ov-classdef.h (cdef_object::map_value, octave_classdef::map_value):
New methods.
(cdef_class::get_properties,
cdef_class::cdef_class_rep::get_properties,
cdef_class::cdef_class_rep::find_properties): Change signature to include
an int argument "mode".
(cdef_class::get_property_map,
cdef_class::cdef_class_rep::get_property_map): New methods.
(class cdef_class): New enum to hold possible values of mode argument
for method get_properties/get_property_map.
(cdef_object_rep::map_keys): Code style.
* ov-classdef.cc (cdef_class::cdef_class_rep::find_properties): Change
signature to include an int argument "mode".
(cdef_class::cdef_class_rep::get_properties): Likewise. Use
get_property_map instead of find_properties.
(cdef_class::cdef_class_rep::get_property_map): New method.
(cdef_object::map_value): Likewise.
author | Michael Goffioul <michael.goffioul@gmail.com> |
---|---|
date | Sun, 28 Sep 2014 21:43:51 -0400 |
parents | fa48651fbb8a |
children | db92e7e28e1f |
line wrap: on
line diff
--- a/libinterp/octave-value/ov-classdef.h +++ b/libinterp/octave-value/ov-classdef.h @@ -122,7 +122,7 @@ return octave_value (); } - virtual string_vector map_keys(void) const; + virtual string_vector map_keys (void) const; virtual bool is_valid (void) const { return false; } @@ -270,6 +270,8 @@ string_vector map_keys (void) const { return rep->map_keys (); } + octave_map map_value (void) const; + const cdef_object_rep* get_rep (void) const { return rep; } bool ok (void) const { return rep->is_valid (); } @@ -646,7 +648,9 @@ void install_property (const cdef_property& prop); - Cell get_properties (void); + Cell get_properties (int mode); + + std::map<std::string, cdef_property> get_property_map (int mode); string_vector get_names (void); @@ -708,7 +712,7 @@ void find_names (std::set<std::string>& names, bool all); void find_properties (std::map<std::string,cdef_property>& props, - bool only_inherited); + int mode = 0); void find_methods (std::map<std::string, cdef_method>& meths, bool only_inherited); @@ -804,7 +808,12 @@ void install_property (const cdef_property& prop) { get_rep ()->install_property (prop); } - Cell get_properties (void) { return get_rep ()->get_properties (); } + Cell get_properties (int mode = property_normal) + { return get_rep ()->get_properties (mode); } + + std::map<std::string, cdef_property> + get_property_map (int mode = property_normal) + { return get_rep ()->get_property_map (mode); } string_vector get_names (void) { return get_rep ()->get_names (); } @@ -866,6 +875,14 @@ void unregister_object (void) { get_rep ()->unregister_object (); } +public: + enum + { + property_normal, + property_inherited, + property_all + }; + private: cdef_class_rep* get_rep (void) { return dynamic_cast<cdef_class_rep *> (cdef_object::get_rep ()); } @@ -1452,6 +1469,8 @@ string_vector map_keys (void) const { return object.map_keys (); } + octave_map map_value (void) const { return object.map_value (); } + dim_vector dims (void) const { return object.dims (); } private: