[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #30419] set/get vs setappdata/getappdata for c

From: David Bateman
Subject: [Octave-bug-tracker] [bug #30419] set/get vs setappdata/getappdata for custom properties
Date: Mon, 12 Jul 2010 19:34:55 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/2009091010 Iceweasel/3.0.14 (Debian-3.0.14-1)

Follow-up Comment #1, bug #30419 (project octave):

Why can't we have Octave style properties added to the base properties and
setappdata/getappdata properties as well. For example with the functions

function setappdata (h, name, val)
   addproperty (name, h, "any", val);

function x = isappdata (h, name)
  x = any (strcmp (name, fieldnames (getappdata (h))));

function rmappdata (h, name)
   ## FIXME Need to write this function in graphics.cc
   delproperty (h, name);

and then add the code

DEFUN (getappdata, args, , "there's no help for the wicked")
  int nargin = args.length ();
  octave_value retval;

  if (nargin != 1 || nargin != 2)
    print_usage ();
      double h = args(0).double_value ();

      if (! error_state)
          graphics_handle gh = gh_manager::lookup (h);

          if (gh.ok ())
              graphics_object go = gh_manager::get_object (gh);

              if (nargin == 1)
                retval = go.get_properties ().get_dynamic ();
                  std::string name = args(1).string_value ();

                  if (! error_state)
                    retval = go.get_properties ().get_dynamic (name);

to src/graphics.cc. In this manner you could keep the old behavior and be
compatible with matlab. If you want to get fancy you could do it all in
graphics.cc, or at least the isappdata function as this could be more
efficient as a DEFUN in graphics.cc.

For the fact the the appdata of the axes holds the data for the matlab line
color, style and the hold style, this is undocumented and we shouldn't rely on
it and don't need to implement it in the same fashion. Unless you're telling
me its common knowledge and many people in the matlab world rely on this

As for the COM versions of addproperty, I say tough luck.



Reply to this item at:


  Message sent via/by Savannah

reply via email to

[Prev in Thread] Current Thread [Next in Thread]