View mode: basic / threaded / horizontal-split · Log in · Help
April 02, 2009
X11 binding, XGetWindowProperty, and different behaviour for similar code between D and C++ (D fails)
As a personal learning D/learn X11 project, I thought it would be  
interesting to try to port dwm over to D. Building it up nice and slowly,  
right now I'm trying to collect a list of windows and their states a-la  
dwm.c code.

The D code, which is translated from C code, does not work, it returns:
X Error of failed request:  BadValue (integer parameter out of range for  
operation)
  Major opcode of failed request:  20 (X_GetProperty)
  Value in failed request:  0x2
  Serial number of failed request:  29
  Current serial number in output stream:  29

The C++ code, which is the D code translated back, does work. The code  
fails on a call to XGetWindowProperty. Debugging each shows that both the  
C++ and D code pass the same atom, display, and window. Setting  
WM_STATE_ELEMENTS < 2 causes the D code to start to segfault while the C++  
code still seems to work.

The std.c.linux.X11.X and std.c.linux.X11.Xlib modules I grabbed off of  
http://www.dsource.org/projects/bindings/browser/trunk/X11?order=date. The  
rest are hand translated (but unconsequential, XGetWindowProperty is  
contained in Xlib). X.d and Xlib.d look correct enough.

I've spent a full day looking at this code, and I can't seem to determine  
why the D code fails. Anyone have any ideas? Thanks in advance.

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
April 02, 2009
Re: X11 binding, XGetWindowProperty, and different behaviour for similar code between D and C++ (D fails)
On Fri, 03 Apr 2009 04:09:25 -0400, Simon Gomizelj <simongmzlj@gmail.com>  
wrote:

> As a personal learning D/learn X11 project, I thought it would be  
> interesting to try to port dwm over to D. Building it up nice and  
> slowly, right now I'm trying to collect a list of windows and their  
> states a-la dwm.c code.
>
> The D code, which is translated from C code, does not work, it returns:
> X Error of failed request:  BadValue (integer parameter out of range for  
> operation)
>    Major opcode of failed request:  20 (X_GetProperty)
>    Value in failed request:  0x2
>    Serial number of failed request:  29
>    Current serial number in output stream:  29
>
> The C++ code, which is the D code translated back, does work. The code  
> fails on a call to XGetWindowProperty. Debugging each shows that both  
> the C++ and D code pass the same atom, display, and window. Setting  
> WM_STATE_ELEMENTS < 2 causes the D code to start to segfault while the  
> C++ code still seems to work.
>
> The std.c.linux.X11.X and std.c.linux.X11.Xlib modules I grabbed off of  
> http://www.dsource.org/projects/bindings/browser/trunk/X11?order=date.  
> The rest are hand translated (but unconsequential, XGetWindowProperty is  
> contained in Xlib). X.d and Xlib.d look correct enough.
>
> I've spent a full day looking at this code, and I can't seem to  
> determine why the D code fails. Anyone have any ideas? Thanks in advance.
>

C++ code:
long getstate(Window window)
{
    static const long WM_STATE_ELEMENTS = 2L;

    unsigned long nitems;
    unsigned long leftover;
    Atom xa_WM_STATE, actual_type;
    int actual_format;
    int status;
    unsigned char* p = NULL;

    xa_WM_STATE = XInternAtom(display, "WM_STATE", false);
    cout << "debug: atom " << xa_WM_STATE << endl;

    cout << "debug: XGetWindowProperty on window " << window << endl;
    status = XGetWindowProperty(display, window,
                  xa_WM_STATE, 0L, WM_STATE_ELEMENTS,
                  false, xa_WM_STATE, &actual_type, &actual_format,
                  &nitems, &leftover, &p);

    if(status == 0)
    {
        cout << "RETURN:" << ((p != NULL) ? (long)*p : -1) << " leftover:"  
<< leftover << " nitems:" << nitems << endl;
        XFree(p);
        return (p != NULL) ? (long)*p : -1;
    }
    return -1;
}

D code:
long getstate(Window window)
{
    static const long WM_STATE_ELEMENTS = 2L;

    uint nitems;
    uint leftover;
    Atom xa_WM_STATE, actual_type;
    int actual_format;
    int status;

    ubyte* p = null;
    scope(exit) XFree(p);

    byte[] name = cast(byte[])"WM_STATE\0";
    xa_WM_STATE = XInternAtom(display, name.ptr, Bool.False);
    debug output(color.green, "debug: atom {}", xa_WM_STATE);

    debug output(color.cyan, "debug: XGetWindowProperty on window {}",  
window);
    status = XGetWindowProperty(display, window,
                  xa_WM_STATE, 0L, WM_STATE_ELEMENTS,
                  Bool.False, xa_WM_STATE, &actual_type, &actual_format,
                  &nitems, &leftover, &p);
    debug output(color.cyan, "debug: XGetWindowProperty, result:{}",  
status);

    if(status == 0)
        return (p != null) ? cast(long)*p : -1;
    return -1;
}

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
April 02, 2009
Re: X11 binding, XGetWindowProperty, and different behaviour for
Simon Gomizelj:

I don't like this:
cast(long)*p : -1;
In C you may need to use an union to perform that cast safely.

Bye,
bearophile
April 02, 2009
Re: X11 binding, XGetWindowProperty, and different behaviour for
On Thu, 02 Apr 2009 05:08:33 -0400, bearophile <bearophileHUGS@lycos.com>  
wrote:

> Simon Gomizelj:
>
> I don't like this:
> cast(long)*p : -1;
> In C you may need to use an union to perform that cast safely.
>
> Bye,
> bearophile

I agree it's ugly, but I'm starting with a straight port. It will get  
cleaned up. The D code never manages to get to that point so I have no  
idea if it even works. (The running C++ code makes me think it should).

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
April 02, 2009
Re: X11 binding, XGetWindowProperty, and different behaviour for
bearophile Wrote:

> Simon Gomizelj:
> 
> I don't like this:
> cast(long)*p : -1;
> In C you may need to use an union to perform that cast safely.
> 
> Bye,
> bearophile

Yeah, C long is D intptr_t
April 02, 2009
Re: X11 binding, XGetWindowProperty, and different behaviour for
What type is Window? D will pass it differently based on type. Also, did you use the proper extern statement when declaring external API functions?

Simon Gomizelj Wrote:

> On Fri, 03 Apr 2009 04:09:25 -0400, Simon Gomizelj <simongmzlj@gmail.com>  
> wrote:
> 
> > As a personal learning D/learn X11 project, I thought it would be  
> > interesting to try to port dwm over to D. Building it up nice and  
> > slowly, right now I'm trying to collect a list of windows and their  
> > states a-la dwm.c code.
> >
> > The D code, which is translated from C code, does not work, it returns:
> > X Error of failed request:  BadValue (integer parameter out of range for  
> > operation)
> >    Major opcode of failed request:  20 (X_GetProperty)
> >    Value in failed request:  0x2
> >    Serial number of failed request:  29
> >    Current serial number in output stream:  29
> >
> > The C++ code, which is the D code translated back, does work. The code  
> > fails on a call to XGetWindowProperty. Debugging each shows that both  
> > the C++ and D code pass the same atom, display, and window. Setting  
> > WM_STATE_ELEMENTS < 2 causes the D code to start to segfault while the  
> > C++ code still seems to work.
> >
> > The std.c.linux.X11.X and std.c.linux.X11.Xlib modules I grabbed off of  
> > http://www.dsource.org/projects/bindings/browser/trunk/X11?order=date.  
> > The rest are hand translated (but unconsequential, XGetWindowProperty is  
> > contained in Xlib). X.d and Xlib.d look correct enough.
> >
> > I've spent a full day looking at this code, and I can't seem to  
> > determine why the D code fails. Anyone have any ideas? Thanks in advance.
> >
> 
> C++ code:
> long getstate(Window window)
> {
>      static const long WM_STATE_ELEMENTS = 2L;
> 
>      unsigned long nitems;
>      unsigned long leftover;
>      Atom xa_WM_STATE, actual_type;
>      int actual_format;
>      int status;
>      unsigned char* p = NULL;
> 
>      xa_WM_STATE = XInternAtom(display, "WM_STATE", false);
>      cout << "debug: atom " << xa_WM_STATE << endl;
> 
>      cout << "debug: XGetWindowProperty on window " << window << endl;
>      status = XGetWindowProperty(display, window,
>                    xa_WM_STATE, 0L, WM_STATE_ELEMENTS,
>                    false, xa_WM_STATE, &actual_type, &actual_format,
>                    &nitems, &leftover, &p);
> 
>      if(status == 0)
>      {
>          cout << "RETURN:" << ((p != NULL) ? (long)*p : -1) << " leftover:"  
> << leftover << " nitems:" << nitems << endl;
>          XFree(p);
>          return (p != NULL) ? (long)*p : -1;
>      }
>      return -1;
> }
> 
> D code:
> long getstate(Window window)
> {
>      static const long WM_STATE_ELEMENTS = 2L;
> 
>      uint nitems;
>      uint leftover;
>      Atom xa_WM_STATE, actual_type;
>      int actual_format;
>      int status;
> 
>      ubyte* p = null;
>      scope(exit) XFree(p);
> 
>      byte[] name = cast(byte[])"WM_STATE\0";
>      xa_WM_STATE = XInternAtom(display, name.ptr, Bool.False);
>      debug output(color.green, "debug: atom {}", xa_WM_STATE);
> 
>      debug output(color.cyan, "debug: XGetWindowProperty on window {}",  
> window);
>      status = XGetWindowProperty(display, window,
>                    xa_WM_STATE, 0L, WM_STATE_ELEMENTS,
>                    Bool.False, xa_WM_STATE, &actual_type, &actual_format,
>                    &nitems, &leftover, &p);
>      debug output(color.cyan, "debug: XGetWindowProperty, result:{}",  
> status);
> 
>      if(status == 0)
>          return (p != null) ? cast(long)*p : -1;
>      return -1;
> }
> 
> -- 
> Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
April 02, 2009
Re: X11 binding, XGetWindowProperty, and different behaviour for similar code between D and C++ (D fails)
On Fri, Apr 3, 2009 at 4:40 AM, Simon Gomizelj <simongmzlj@gmail.com> wrote:
> On Fri, 03 Apr 2009 04:09:25 -0400, Simon Gomizelj <simongmzlj@gmail.com>
> wrote:
>
>> As a personal learning D/learn X11 project, I thought it would be
>> interesting to try to port dwm over to D. Building it up nice and slowly,
>> right now I'm trying to collect a list of windows and their states a-la
>> dwm.c code.
>>
>> The D code, which is translated from C code, does not work, it returns:
>> X Error of failed request:  BadValue (integer parameter out of range for
>> operation)
>>   Major opcode of failed request:  20 (X_GetProperty)
>>   Value in failed request:  0x2
>>   Serial number of failed request:  29
>>   Current serial number in output stream:  29
>>
>> The C++ code, which is the D code translated back, does work. The code
>> fails on a call to XGetWindowProperty. Debugging each shows that both the
>> C++ and D code pass the same atom, display, and window. Setting
>> WM_STATE_ELEMENTS < 2 causes the D code to start to segfault while the C++
>> code still seems to work.
>>
>> The std.c.linux.X11.X and std.c.linux.X11.Xlib modules I grabbed off of
>> http://www.dsource.org/projects/bindings/browser/trunk/X11?order=date. The
>> rest are hand translated (but unconsequential, XGetWindowProperty is
>> contained in Xlib). X.d and Xlib.d look correct enough.
>>
>> I've spent a full day looking at this code, and I can't seem to determine
>> why the D code fails. Anyone have any ideas? Thanks in advance.
>>
>
> C++ code:
> long getstate(Window window)
> {
>    static const long WM_STATE_ELEMENTS = 2L;
>
>    unsigned long nitems;
>    unsigned long leftover;
>    Atom xa_WM_STATE, actual_type;
>    int actual_format;
>    int status;
>    unsigned char* p = NULL;
>
>    xa_WM_STATE = XInternAtom(display, "WM_STATE", false);
>    cout << "debug: atom " << xa_WM_STATE << endl;
>
>    cout << "debug: XGetWindowProperty on window " << window << endl;
>    status = XGetWindowProperty(display, window,
>                  xa_WM_STATE, 0L, WM_STATE_ELEMENTS,
>                  false, xa_WM_STATE, &actual_type, &actual_format,
>                  &nitems, &leftover, &p);
>
>    if(status == 0)
>    {
>        cout << "RETURN:" << ((p != NULL) ? (long)*p : -1) << " leftover:" <<
> leftover << " nitems:" << nitems << endl;
>        XFree(p);
>        return (p != NULL) ? (long)*p : -1;
>    }
>    return -1;
> }
>
> D code:
> long getstate(Window window)
> {
>    static const long WM_STATE_ELEMENTS = 2L;
>
>    uint nitems;
>    uint leftover;
>    Atom xa_WM_STATE, actual_type;
>    int actual_format;
>    int status;
>
>    ubyte* p = null;
>    scope(exit) XFree(p);
>
>    byte[] name = cast(byte[])"WM_STATE\0";
>    xa_WM_STATE = XInternAtom(display, name.ptr, Bool.False);
>    debug output(color.green, "debug: atom {}", xa_WM_STATE);
>
>    debug output(color.cyan, "debug: XGetWindowProperty on window {}",
> window);
>    status = XGetWindowProperty(display, window,
>                  xa_WM_STATE, 0L, WM_STATE_ELEMENTS,
>                  Bool.False, xa_WM_STATE, &actual_type, &actual_format,
>                  &nitems, &leftover, &p);
>    debug output(color.cyan, "debug: XGetWindowProperty, result:{}", status);
>
>    if(status == 0)
>        return (p != null) ? cast(long)*p : -1;
>    return -1;
> }

My best guess is that you've translated those X11 function headers
incorrectly.  Perhaps you've used a D long where you shouldn't have.
A D long is 64 bits, while a C long is 32, at least on 32-bit
platforms.  If you were to pass a 64-bit value where it was expecting
a 32-bit one, the params would be in all the wrong places.  But this
is just speculation, since I don't know what your bindings look like.
April 02, 2009
Re: X11 binding, XGetWindowProperty, and different behaviour for similar code between D and C++ (D fails)
On Thu, 02 Apr 2009 09:59:55 -0400, Jarrett Billingsley  
<jarrett.billingsley@gmail.com> wrote:

> On Fri, Apr 3, 2009 at 4:40 AM, Simon Gomizelj <simongmzlj@gmail.com>  
> wrote:
>> On Fri, 03 Apr 2009 04:09:25 -0400, Simon Gomizelj  
>> <simongmzlj@gmail.com>
>> wrote:
>>
>>> As a personal learning D/learn X11 project, I thought it would be
>>> interesting to try to port dwm over to D. Building it up nice and  
>>> slowly,
>>> right now I'm trying to collect a list of windows and their states a-la
>>> dwm.c code.
>>>
>>> The D code, which is translated from C code, does not work, it returns:
>>> X Error of failed request:  BadValue (integer parameter out of range  
>>> for
>>> operation)
>>>   Major opcode of failed request:  20 (X_GetProperty)
>>>   Value in failed request:  0x2
>>>   Serial number of failed request:  29
>>>   Current serial number in output stream:  29
>>>
>>> The C++ code, which is the D code translated back, does work. The code
>>> fails on a call to XGetWindowProperty. Debugging each shows that both  
>>> the
>>> C++ and D code pass the same atom, display, and window. Setting
>>> WM_STATE_ELEMENTS < 2 causes the D code to start to segfault while the  
>>> C++
>>> code still seems to work.
>>>
>>> The std.c.linux.X11.X and std.c.linux.X11.Xlib modules I grabbed off of
>>> http://www.dsource.org/projects/bindings/browser/trunk/X11?order=date.  
>>> The
>>> rest are hand translated (but unconsequential, XGetWindowProperty is
>>> contained in Xlib). X.d and Xlib.d look correct enough.
>>>
>>> I've spent a full day looking at this code, and I can't seem to  
>>> determine
>>> why the D code fails. Anyone have any ideas? Thanks in advance.
>>>
>>
>> C++ code:
>> long getstate(Window window)
>> {
>>    static const long WM_STATE_ELEMENTS = 2L;
>>
>>    unsigned long nitems;
>>    unsigned long leftover;
>>    Atom xa_WM_STATE, actual_type;
>>    int actual_format;
>>    int status;
>>    unsigned char* p = NULL;
>>
>>    xa_WM_STATE = XInternAtom(display, "WM_STATE", false);
>>    cout << "debug: atom " << xa_WM_STATE << endl;
>>
>>    cout << "debug: XGetWindowProperty on window " << window << endl;
>>    status = XGetWindowProperty(display, window,
>>                  xa_WM_STATE, 0L, WM_STATE_ELEMENTS,
>>                  false, xa_WM_STATE, &actual_type, &actual_format,
>>                  &nitems, &leftover, &p);
>>
>>    if(status == 0)
>>    {
>>        cout << "RETURN:" << ((p != NULL) ? (long)*p : -1) << "  
>> leftover:" <<
>> leftover << " nitems:" << nitems << endl;
>>        XFree(p);
>>        return (p != NULL) ? (long)*p : -1;
>>    }
>>    return -1;
>> }
>>
>> D code:
>> long getstate(Window window)
>> {
>>    static const long WM_STATE_ELEMENTS = 2L;
>>
>>    uint nitems;
>>    uint leftover;
>>    Atom xa_WM_STATE, actual_type;
>>    int actual_format;
>>    int status;
>>
>>    ubyte* p = null;
>>    scope(exit) XFree(p);
>>
>>    byte[] name = cast(byte[])"WM_STATE\0";
>>    xa_WM_STATE = XInternAtom(display, name.ptr, Bool.False);
>>    debug output(color.green, "debug: atom {}", xa_WM_STATE);
>>
>>    debug output(color.cyan, "debug: XGetWindowProperty on window {}",
>> window);
>>    status = XGetWindowProperty(display, window,
>>                  xa_WM_STATE, 0L, WM_STATE_ELEMENTS,
>>                  Bool.False, xa_WM_STATE, &actual_type, &actual_format,
>>                  &nitems, &leftover, &p);
>>    debug output(color.cyan, "debug: XGetWindowProperty, result:{}",  
>> status);
>>
>>    if(status == 0)
>>        return (p != null) ? cast(long)*p : -1;
>>    return -1;
>> }
>
> My best guess is that you've translated those X11 function headers
> incorrectly.  Perhaps you've used a D long where you shouldn't have.
> A D long is 64 bits, while a C long is 32, at least on 32-bit
> platforms.  If you were to pass a 64-bit value where it was expecting
> a 32-bit one, the params would be in all the wrong places.  But this
> is just speculation, since I don't know what your bindings look like.

Yeah, thats it exactly, which is annoying because since I downloaded this  
binding I just assumed it was done right 8-).

extern (C):
extern int XGetWindowProperty(
    Display*    /* display */,
    Window      /* w */,
    Atom        /* property */,
    long        /* long_offset */,  <-- should be int
    long        /* long_length */,  <-- should be int
    Bool        /* delete */,
    Atom        /* req_type */,
    Atom*       /* actual_type_return */,
    int*        /* actual_format_return */,
    uint*       /* nitems_return */,
    uint*       /* bytes_after_return */,
    ubyte**     /* prop_return */
);

Since their are no occurences of long longs I just did a search and  
replace across the whole file for longs to ints

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
April 02, 2009
Re: X11 binding, XGetWindowProperty, and different behaviour for similar code between D and C++ (D fails)
On Fri, 03 Apr 2009 13:33:21 -0400, Simon Gomizelj <simongmzlj@gmail.com>  
wrote:

> On Thu, 02 Apr 2009 09:59:55 -0400, Jarrett Billingsley  
> <jarrett.billingsley@gmail.com> wrote:
>
>> On Fri, Apr 3, 2009 at 4:40 AM, Simon Gomizelj <simongmzlj@gmail.com>  
>> wrote:
>>> On Fri, 03 Apr 2009 04:09:25 -0400, Simon Gomizelj  
>>> <simongmzlj@gmail.com>
>>> wrote:
>>>
>>>> As a personal learning D/learn X11 project, I thought it would be
>>>> interesting to try to port dwm over to D. Building it up nice and  
>>>> slowly,
>>>> right now I'm trying to collect a list of windows and their states  
>>>> a-la
>>>> dwm.c code.
>>>>
>>>> The D code, which is translated from C code, does not work, it  
>>>> returns:
>>>> X Error of failed request:  BadValue (integer parameter out of range  
>>>> for
>>>> operation)
>>>>   Major opcode of failed request:  20 (X_GetProperty)
>>>>   Value in failed request:  0x2
>>>>   Serial number of failed request:  29
>>>>   Current serial number in output stream:  29
>>>>
>>>> The C++ code, which is the D code translated back, does work. The code
>>>> fails on a call to XGetWindowProperty. Debugging each shows that both  
>>>> the
>>>> C++ and D code pass the same atom, display, and window. Setting
>>>> WM_STATE_ELEMENTS < 2 causes the D code to start to segfault while  
>>>> the C++
>>>> code still seems to work.
>>>>
>>>> The std.c.linux.X11.X and std.c.linux.X11.Xlib modules I grabbed off  
>>>> of
>>>> http://www.dsource.org/projects/bindings/browser/trunk/X11?order=date.  
>>>> The
>>>> rest are hand translated (but unconsequential, XGetWindowProperty is
>>>> contained in Xlib). X.d and Xlib.d look correct enough.
>>>>
>>>> I've spent a full day looking at this code, and I can't seem to  
>>>> determine
>>>> why the D code fails. Anyone have any ideas? Thanks in advance.
>>>>
>>>
>>> C++ code:
>>> long getstate(Window window)
>>> {
>>>    static const long WM_STATE_ELEMENTS = 2L;
>>>
>>>    unsigned long nitems;
>>>    unsigned long leftover;
>>>    Atom xa_WM_STATE, actual_type;
>>>    int actual_format;
>>>    int status;
>>>    unsigned char* p = NULL;
>>>
>>>    xa_WM_STATE = XInternAtom(display, "WM_STATE", false);
>>>    cout << "debug: atom " << xa_WM_STATE << endl;
>>>
>>>    cout << "debug: XGetWindowProperty on window " << window << endl;
>>>    status = XGetWindowProperty(display, window,
>>>                  xa_WM_STATE, 0L, WM_STATE_ELEMENTS,
>>>                  false, xa_WM_STATE, &actual_type, &actual_format,
>>>                  &nitems, &leftover, &p);
>>>
>>>    if(status == 0)
>>>    {
>>>        cout << "RETURN:" << ((p != NULL) ? (long)*p : -1) << "  
>>> leftover:" <<
>>> leftover << " nitems:" << nitems << endl;
>>>        XFree(p);
>>>        return (p != NULL) ? (long)*p : -1;
>>>    }
>>>    return -1;
>>> }
>>>
>>> D code:
>>> long getstate(Window window)
>>> {
>>>    static const long WM_STATE_ELEMENTS = 2L;
>>>
>>>    uint nitems;
>>>    uint leftover;
>>>    Atom xa_WM_STATE, actual_type;
>>>    int actual_format;
>>>    int status;
>>>
>>>    ubyte* p = null;
>>>    scope(exit) XFree(p);
>>>
>>>    byte[] name = cast(byte[])"WM_STATE\0";
>>>    xa_WM_STATE = XInternAtom(display, name.ptr, Bool.False);
>>>    debug output(color.green, "debug: atom {}", xa_WM_STATE);
>>>
>>>    debug output(color.cyan, "debug: XGetWindowProperty on window {}",
>>> window);
>>>    status = XGetWindowProperty(display, window,
>>>                  xa_WM_STATE, 0L, WM_STATE_ELEMENTS,
>>>                  Bool.False, xa_WM_STATE, &actual_type, &actual_format,
>>>                  &nitems, &leftover, &p);
>>>    debug output(color.cyan, "debug: XGetWindowProperty, result:{}",  
>>> status);
>>>
>>>    if(status == 0)
>>>        return (p != null) ? cast(long)*p : -1;
>>>    return -1;
>>> }
>>
>> My best guess is that you've translated those X11 function headers
>> incorrectly.  Perhaps you've used a D long where you shouldn't have.
>> A D long is 64 bits, while a C long is 32, at least on 32-bit
>> platforms.  If you were to pass a 64-bit value where it was expecting
>> a 32-bit one, the params would be in all the wrong places.  But this
>> is just speculation, since I don't know what your bindings look like.
>
> Yeah, thats it exactly, which is annoying because since I downloaded  
> this binding I just assumed it was done right 8-).
>
> extern (C):
> extern int XGetWindowProperty(
>      Display*    /* display */,
>      Window      /* w */,
>      Atom        /* property */,
>      long        /* long_offset */,  <-- should be int
>      long        /* long_length */,  <-- should be int
>      Bool        /* delete */,
>      Atom        /* req_type */,
>      Atom*       /* actual_type_return */,
>      int*        /* actual_format_return */,
>      uint*       /* nitems_return */,
>      uint*       /* bytes_after_return */,
>      ubyte**     /* prop_return */
> );
>
> Since their are no occurences of long longs I just did a search and  
> replace across the whole file for longs to ints
>

For curiousities sake, is there any interest to adding my bindings to any  
standard library? I know bindings for X.h and Xlib.h exist, but I created  
a more complete set: X.d, Xlib.d, Xatom.d, Xproto.d, Xregion.d Xutil.d and  
Xinerama.d and xf86vmode.h

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
April 02, 2009
Re: X11 binding, XGetWindowProperty, and different behaviour for similar code between D and C++ (D fails)
Fri, 03 Apr 2009 13:55:12 -0400, Simon Gomizelj wrote:

> For curiousities sake, is there any interest to adding my bindings to any  
> standard library? I know bindings for X.h and Xlib.h exist, but I created  
> a more complete set: X.d, Xlib.d, Xatom.d, Xproto.d, Xregion.d Xutil.d and  
> Xinerama.d and xf86vmode.h

If you have a dsource account, you automatically have write access to
the bindings project.  Simply update it if you think your version is
better.
« First   ‹ Prev
1 2
Top | Discussion index | About this forum | D home