# HG changeset patch # User John W. Eaton # Date 1560534747 18000 # Node ID b15b71bcd679d4ce6bb82239f4007c2425491f17 # Parent 04889e45f54ee00797fe3b5de4bf396c63756adc properties function: omit hidden properties (bug #55766) * ov-classdef.cc (Fproperties): Also skip hidden properties. * test/classdef/class_bug55766.m: New file. * classdef.tst: New test. * test/classdef/module.mk: Update. diff -r 04889e45f54e -r b15b71bcd679 libinterp/octave-value/ov-classdef.cc --- a/libinterp/octave-value/ov-classdef.cc Fri Jun 14 11:14:01 2019 -0500 +++ b/libinterp/octave-value/ov-classdef.cc Fri Jun 14 12:52:27 2019 -0500 @@ -524,13 +524,14 @@ @deftypefn {} {} properties (@var{class_name}) @deftypefnx {} {} properties (@var{obj}) @deftypefnx {} {@var{plist} =} properties (@dots{}) -Return or display the public properties for the named class @var{class_name} or -classdef object @var{obj}. +Return or display the public properties for the named class +@var{class_name} or classdef object @var{obj}. -If an output value is requested, return the list of property names in a cell -array. +If an output value is requested, return the list of property names in a +cell array. -Programming Note: Property names are returned if the @code{GetAccess} attribute is public and if the @code{Hidden} attribute is false. +Programming Note: Property names are returned if the @code{GetAccess} +attribute is public and if the @code{Hidden} attribute is false. @seealso{methods} @end deftypefn */) { @@ -561,13 +562,20 @@ for (const auto& pname_prop : property_map) { - std::string nm = pname_prop.second.get_name (); + const octave::cdef_property& prop = pname_prop.second; - octave_value acc = pname_prop.second.get ("GetAccess"); + std::string nm = prop.get_name (); + + octave_value acc = prop.get ("GetAccess"); if (! acc.is_string () || acc.string_value () != "public") continue; + octave_value hid = prop.get ("Hidden"); + + if (hid.bool_value ()) + continue; + property_names.push_back (nm); } diff -r 04889e45f54e -r b15b71bcd679 test/classdef/class_bug55766.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/classdef/class_bug55766.m Fri Jun 14 12:52:27 2019 -0500 @@ -0,0 +1,27 @@ +classdef class_bug55766 + + properties + testprop = 0; + end + + properties (Access = public) + publictestprop = 0; + end + + properties (Access = protected) + protectedtestprop = 0; + end + + properties (Hidden) + hiddentestprop = 0; + end + + properties (Hidden = true) + anotherhiddentestprop = 0; + end + + properties (Hidden = false) + notahiddentestprop = 0; + end + +end diff -r 04889e45f54e -r b15b71bcd679 test/classdef/classdef.tst --- a/test/classdef/classdef.tst Fri Jun 14 11:14:01 2019 -0500 +++ b/test/classdef/classdef.tst Fri Jun 14 12:52:27 2019 -0500 @@ -193,3 +193,8 @@ %! B = class_bug52614B (); %! assert (B.a, 1); %! assert (B.b, 2); + +%!test <*55766> +%! x = class_bug55766 (); +%! props = {"notahiddentestprop"; "publictestprop"; "testprop"}; +%! assert (properties (x), props); diff -r 04889e45f54e -r b15b71bcd679 test/classdef/module.mk --- a/test/classdef/module.mk Fri Jun 14 11:14:01 2019 -0500 +++ b/test/classdef/module.mk Fri Jun 14 12:52:27 2019 -0500 @@ -1,6 +1,7 @@ classdef_TEST_FILES = \ %reldir%/class_bug52614A.m \ %reldir%/class_bug52614B.m \ + %reldir%/class_bug55766.m \ %reldir%/classdef.tst \ %reldir%/foo_method_changes_property_size.m \ %reldir%/foo_static_method_constant_property.m \