FFI on Linux again

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

FFI on Linux again

Annick
Hi,

I Have tried the following code on Linux , but the call breaks. Is it because of the X11Window structure missing or else ?

Annick
====
testGetOurWindowLocation
   "self new testGetOurWindowLocation"

   | display ourWindow aParent anX anY aWidth aHeight aBorderWidth aDepth |
   display := X11Display XOpenDisplay: nil.
   ourWindow := display ourWindow.
   (Alien lookup: 'XGetGeometry' inLibrary: 'X11')
       primFFICallResult: nil
       withArguments:
           {display.
           ourWindow.
           (aParent := Alien new: 4).
           (anX := Alien new: 4).
           (anY := Alien new: 4).
           (aWidth := Alien new: 4).
           (aHeight := Alien new: 4).
           (aBorderWidth := Alien new: 4).
           (aDepth := Alien new: 4)}.
   (anX unsignedLongAt: 1) inspect
Reply | Threaded
Open this post in threaded view
|

Re: FFI on Linux again

Nicolai Hess


Am 25.09.2014 17:25 schrieb "Annick Fron" <[hidden email]>:
>
> Hi,
>
> I Have tried the following code on Linux , but the call breaks. Is it because of the X11Window structure missing or else ?
>
> Annick
> ====
> testGetOurWindowLocation
>    "self new testGetOurWindowLocation"
>
>    | display ourWindow aParent anX anY aWidth aHeight aBorderWidth aDepth |
>    display := X11Display XOpenDisplay: nil.
>    ourWindow := display ourWindow.
>    (Alien lookup: 'XGetGeometry' inLibrary: 'X11')
>        primFFICallResult: nil
>        withArguments:
>            {display.
>            ourWindow.
>            (aParent := Alien new: 4).
>            (anX := Alien new: 4).
>            (anY := Alien new: 4).
>            (aWidth := Alien new: 4).
>            (aHeight := Alien new: 4).
>            (aBorderWidth := Alien new: 4).
>            (aDepth := Alien new: 4)}.
>    (anX unsignedLongAt: 1) inspect

withArguments ...
ourWindow xid
...
?

Reply | Threaded
Open this post in threaded view
|

Re: FFI on Linux again

Annick
I have the same problem with myWindow xid.

« bad argument ».

Yet I have used all the other methods which also use myWindow xid and display as arguments. I think the problem is from the other arguments passed by reference, not by value.
I have seen a new version of Alien from Sept 30, but I don’t know if it works in pharo.
Annick

Le 25 sept. 2014 à 18:56, Nicolai Hess <[hidden email]> a écrit :


Am 25.09.2014 17:25 schrieb "Annick Fron" <[hidden email]>:
>
> Hi,
>
> I Have tried the following code on Linux , but the call breaks. Is it because of the X11Window structure missing or else ?
>
> Annick
> ====
> testGetOurWindowLocation
>    "self new testGetOurWindowLocation"
>
>    | display ourWindow aParent anX anY aWidth aHeight aBorderWidth aDepth |
>    display := X11Display XOpenDisplay: nil.
>    ourWindow := display ourWindow.
>    (Alien lookup: 'XGetGeometry' inLibrary: 'X11')
>        primFFICallResult: nil
>        withArguments:
>            {display.
>            ourWindow.
>            (aParent := Alien new: 4).
>            (anX := Alien new: 4).
>            (anY := Alien new: 4).
>            (aWidth := Alien new: 4).
>            (aHeight := Alien new: 4).
>            (aBorderWidth := Alien new: 4).
>            (aDepth := Alien new: 4)}.
>    (anX unsignedLongAt: 1) inspect

withArguments ...
ourWindow xid
...
?