bugGNU Octave - Bugs: bug #41629, "set (h)" should not...

 
 

bug #41629: "set (h)" should not return read only properties

Submitter:  Pantxo Diribarne <pantxo>
Submitted:  Mon 17 Feb 2014 11:37:01 PM UTC
   
 
Category:  Plotting Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 18 Mar 2014 03:35:29 PM UTC, comment #5: 

I applied your changesets (http://hg.savannah.gnu.org/hgweb/octave/rev/8d5cb159fbc7, http://hg.savannah.gnu.org/hgweb/octave/rev/5264b0ec9f97).  With this in place, I think I we can return back to bug #35511 and getting "reset (h)" to work.

Rik <rik5>
Group administrator
Mon 17 Mar 2014 09:57:52 PM UTC, comment #4: 

AFAICS there is no equivalent of base_graphics_object/graphics_object for proeprties, so that there is no way other than explicitly calling static function to call e.g axes::properties::... mehtods.
The two attached patches (to be applied one after the other) avoid static calls by implementing has_readonly_property for all graphics objects.


(file #30932, file #30933)

Pantxo Diribarne <pantxo>
Group Member
Mon 17 Mar 2014 01:27:14 AM UTC, comment #3: 

I applied the two patches together and they appear to work.  I'm uploading the consolidated changeset so you can see the final result.

One thing I wondered about was the dispatch table in the is_readonly function.  Is there any way to get C++ to do this for us?  Below is a small portion of the dispatch table.


static bool
is_readonly (const graphics_object obj, const std::string& pname)
{
  bool retval = false;

  if (obj.isa ("root_figure"))
      retval = root_figure::properties::has_readonly_property (pname);
  else if (obj.isa ("figure"))
      retval = figure::properties::has_readonly_property (pname)


It seems like there ought to be a way to call something like the following


retval = obj.has_readonly_property (pname);


because the object already knows what it is and has an overloaded instance of the has_readonly_property method depending on what kind of object it is.  The syntax above doesn't work though.


(file #30923)

Rik <rik5>
Group administrator
Wed 19 Feb 2014 12:18:47 PM UTC, comment #2: 

Attached is a second patch (to be applied after the first one) that makes the original example work as expected.

(file #30606)

Pantxo Diribarne <pantxo>
Group Member
Tue 18 Feb 2014 04:12:56 PM UTC, comment #1: 

I went ahead to propose a method to determine whether a variable is readonly.

In the attached changeset I modified genprops.awk to generate readonly_property_names/has_readonly_property methods. They are basically identical to core_property_names/has_core_property methods except they list read-only properties.

I also modified set methods in order to let them report if a property is read only:


octave:2> set (gcf, "type", "toto")
error: set: "type" is read-only


If the approach is approved, I may address this bug.


(file #30596)

Pantxo Diribarne <pantxo>
Group Member
Mon 17 Feb 2014 11:37:01 PM UTC, original submission:  

In octave the following returns true:


ax = axes ();
isfield (set (ax), "tightinset")  ## returns true


As in Matlab, "tightinset" is read only and the test should return false.

I could not find a way (but try/catch) to determine programmatically whether a property is read only, neither in octave language, nor on the c++ side.

Pantxo Diribarne <pantxo>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #30923:  ro_props.cset added by rik5 (8KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Updated the item)
  • -email is unavailable- added by pantxo (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-03-18 rik5 StatusNone Fixed
        Open/ClosedOpen Closed
    2014-03-17 pantxo Attached File- Added readonly_part1_bug41629.patch, #30932
        Attached File- Added readonly_part2_bug41629.patch, #30933
    2014-03-17 rik5 Attached File- Added ro_props.cset, #30923
    2014-02-19 pantxo Attached File- Added report_readonly_2_bug41629.patch, #30606
    2014-02-18 pantxo Attached File- Added report_readonly_bug41629.patch, #30596

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code