After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 621318 - GDK_NONE not bound in gdk-2.0.vapi
GDK_NONE not bound in gdk-2.0.vapi
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Bindings
0.9.x
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2010-06-11 20:07 UTC by Jim Nelson
Modified: 2010-06-16 20:05 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Binds GDK_NONE to Gdk.Atom. (3.84 KB, patch)
2010-06-11 20:09 UTC, Jim Nelson
none Details | Review

Description Jim Nelson 2010-06-11 20:07:52 UTC
GDK_NONE (the null value for GdkAtom) is not bound in gdk-2.0.vapi.  I will attach a patch that binds it as a static field of Gdk.Atom.

However, my implementation is problematic because GDK_NONE isn't actually a const, but a macro that calls _GDK_MAKE_ATOM(0).  That means that testing for equality fails with an error:

    if (Gdk.NONE == Gdk.NONE)

test.vala: In function ‘_vala_main’:
test.vala:23: error: lvalue required as unary ‘&’ operand
test.vala:23: error: lvalue required as unary ‘&’ operand

The problem is that, because Gdk.Atom is bound as a struct, valac is generating an internal test-equality function that accepts the address of the two structs.  (I have a separate ticket about this issue.)  Taking the address of the macro fails.

Note that this works:

    Gdk.Atom a = Gdk.NONE;
    if (a == a)

Also, for some reason my patch modifies several GDK methods that take Gdk.Atom as parameters from normal to out parameters.  I'm not sure what I'm going wrong here that causes this.
Comment 1 Jim Nelson 2010-06-11 20:09:24 UTC
Created attachment 163425 [details] [review]
Binds GDK_NONE to Gdk.Atom.

For some reason, other methods are affected in gdk-2.0.vapi, changing their Atom parameters to "out" parameters.
Comment 2 Jürg Billeter 2010-06-16 20:05:21 UTC
(In reply to comment #0)
> GDK_NONE (the null value for GdkAtom) is not bound in gdk-2.0.vapi.  I will
> attach a patch that binds it as a static field of Gdk.Atom.
> 
> However, my implementation is problematic because GDK_NONE isn't actually a
> const, but a macro that calls _GDK_MAKE_ATOM(0).  That means that testing for
> equality fails with an error:
> 
>     if (Gdk.NONE == Gdk.NONE)
> 
> test.vala: In function ‘_vala_main’:
> test.vala:23: error: lvalue required as unary ‘&’ operand
> test.vala:23: error: lvalue required as unary ‘&’ operand
> 
> The problem is that, because Gdk.Atom is bound as a struct, valac is generating
> an internal test-equality function that accepts the address of the two structs.
>  (I have a separate ticket about this issue.)  Taking the address of the macro
> fails.

We need to investigate what options we have here, however, I think it still makes sense to already merge this.

> Also, for some reason my patch modifies several GDK methods that take Gdk.Atom
> as parameters from normal to out parameters.  I'm not sure what I'm going wrong
> here that causes this.

The changes are due to imperfect GIDL handling, however, they actually make sense to me - according to the documentation they really are out parameters.
Comment 3 Jürg Billeter 2010-06-16 20:05:39 UTC
commit 9120dbc8836e7e80f0a5b5c686f6405cf1889135
Author: Jim Nelson <jim@yorba.org>
Date:   Wed Jun 16 22:02:41 2010 +0200

    gdk-2.0: Add GDK_NONE binding
    
    Fixes bug 621318.