Mercurial > octave-nkf
comparison libinterp/octave-value/ov-classdef.cc @ 19137:56bc1464ec59
Implement "isa" for classdef objects.
* ov.h (octave_value::is_instance_of): New method.
* ov-base.h (octave_base_value::is_instance_of): Likewise.
* ov-class.h (octave_class::is_instance_of): New method declaration.
* ov-class.cc (octave_class::is_instance_of): Implement it with
find_parent_class.
* ov-classdef.h (octave_classdef::is_instance_of): New method
declaration.
* ov-classdef.cc (octave_classdef::is_instance_of): Implement it
with lookup_class and is_superclass.
author | Michael Goffioul <michael.goffioul@gmail.com> |
---|---|
date | Sat, 20 Sep 2014 12:43:25 -0400 |
parents | 1f36981ab323 |
children | e0a7718ac085 |
comparison
equal
deleted
inserted
replaced
19136:bb20384acf7b | 19137:56bc1464ec59 |
---|---|
1084 indent (os); | 1084 indent (os); |
1085 meth.execute (args, 0, true, "display"); | 1085 meth.execute (args, 0, true, "display"); |
1086 } | 1086 } |
1087 else | 1087 else |
1088 octave_base_value::print_with_name (os, name, print_padding); | 1088 octave_base_value::print_with_name (os, name, print_padding); |
1089 } | |
1090 | |
1091 bool | |
1092 octave_classdef::is_instance_of (const std::string& cls_name) const | |
1093 { | |
1094 cdef_class cls = lookup_class (cls_name, false, false); | |
1095 | |
1096 if (cls.ok ()) | |
1097 return is_superclass (cls, object.get_class ()); | |
1098 | |
1099 return false; | |
1089 } | 1100 } |
1090 | 1101 |
1091 //---------------------------------------------------------------------------- | 1102 //---------------------------------------------------------------------------- |
1092 | 1103 |
1093 class octave_classdef_meta : public octave_function | 1104 class octave_classdef_meta : public octave_function |