Mercurial > hg > octave-nkf
changeset 9767:0df32e0b2074
fix base class field assignment
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Mon, 02 Nov 2009 10:28:57 +0100 |
parents | 82fe4db20dec |
children | 31900e17b5f5 |
files | src/ChangeLog src/ov-base.h src/ov-class.cc src/ov-class.h |
diffstat | 4 files changed, 50 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2009-11-02 Jaroslav Hajek <highegg@gmail.com> + + * ov-class.cc (octave_class::unique_parent_class): New method. + (octave_class::subsasgn): Use it here. + * ov-class.h: Declare it. + 2009-11-01 John W. Eaton <jwe@octave.org> * data.cc (get_sort_mode_option): New function.
--- a/src/ov-base.h +++ b/src/ov-base.h @@ -521,6 +521,9 @@ virtual octave_base_value *find_parent_class (const std::string&) { return 0; } + virtual octave_base_value *unique_parent_class (const std::string&) + { return 0; } + virtual octave_function *function_value (bool silent = false); virtual const octave_function *function_value (bool silent = false) const;
--- a/src/ov-class.cc +++ b/src/ov-class.cc @@ -794,7 +794,7 @@ std::string method_class = get_current_method_class (); - octave_base_value *obvp = find_parent_class (method_class); + octave_base_value *obvp = unique_parent_class (method_class); if (obvp) { @@ -930,6 +930,44 @@ return retval; } +octave_base_value * +octave_class::unique_parent_class (const std::string& parent_class_name) +{ + octave_base_value* retval = 0; + + if (parent_class_name == class_name ()) + retval = this; + else + { + for (std::list<std::string>::iterator pit = parent_list.begin (); + pit != parent_list.end (); + pit++) + { + Octave_map::iterator smap = map.seek (*pit); + + Cell& tmp = smap->second; + + octave_value& vtmp = tmp(0); + + octave_base_value *obvp = vtmp.internal_rep (); + + // Use find_parent_class first to avoid uniquifying if not necessary. + retval = obvp->find_parent_class (parent_class_name); + + if (retval) + { + vtmp.make_unique (); + obvp = vtmp.internal_rep (); + retval = obvp->unique_parent_class (parent_class_name); + + break; + } + } + } + + return retval; +} + void octave_class::print (std::ostream& os, bool) const {
--- a/src/ov-class.h +++ b/src/ov-class.h @@ -141,6 +141,8 @@ octave_base_value *find_parent_class (const std::string&); + octave_base_value *unique_parent_class (const std::string&); + void print (std::ostream& os, bool pr_as_read_syntax = false) const; void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;