Forum: Ruby-Gnome 2 Sizable changes in SVN

Posted by Nikolai Weibull (Guest)
on 2011-09-12 17:15
(Received via mailing list)
Hi!

I pushed some rather sizable changes to SVN, primarily in gtk2.  I
removed all methods that implement methods already implemented as
properties.  I also removed unnecessary/superfluous/frivolous calls to
G_DEF_SETTERS(), as G_DEF_SETTERS() isn’t exactly fast.

I noticed something while doing this, however.  If HAVE_NODE_ATTRASGN
is set, rbgobj_define_property_accessors uses alias for properties, so
all rb_undef_method() in gtk2 for methods that redefine properties may
need rb_undef_method() for the #attribute= method as well (followed by
a matching G_DEF_SETTER()).   HAVE_NODE_ATTRASGN only seems to be set
for Ruby 1.7, however, so this shouldn’t really be a problem.
Posted by Nikolai Weibull (Guest)
on 2011-09-15 15:32
(Received via mailing list)
On Mon, Sep 12, 2011 at 17:15, Nikolai Weibull <now@bitwi.se> wrote:

> I noticed something while doing this, however.  If HAVE_NODE_ATTRASGN
> is set, rbgobj_define_property_accessors uses alias for properties, so
> all rb_undef_method() in gtk2 for methods that redefine properties may
> need rb_undef_method() for the #attribute= method as well (followed by
> a matching G_DEF_SETTER()).   HAVE_NODE_ATTRASGN only seems to be set
> for Ruby 1.7, however, so this shouldn’t really be a problem.

As I suspected, this is causing problems.  I don’t understand how this
has worked in the past, but  I’m adding a new pair of macros
G_REPLACE_PROPERTY() and G_REPLACE_PROPERTY_AND_SETTER() that we can
use:

#define G_REPLACE_PROPERTY(klass, name, function, args) \
    rb_undef_method(klass, "set_" name); \
    rb_define_method(klass, "set_" name, function, args)

#define G_REPLACE_PROPERTY_AND_SETTER(klass, name, function, args) \
    G_REPLACE_PROPERTY(klass, name, function, args); \
    rb_undef_method(klass, name "="); \
    G_DEF_SETTER(klass, name)

I will apply this patch later today once I get everything in place.
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.