Re: [Pharo-users] [UFFI] Getting an array of opaque structures filled

2016-07-04 Thread Julien Delplanque
Ok, the problem is resolved thanks to Esteban. There was a mistake in the code given in preceding mails so, I am rewriting the 3 steps here: === 1) Declare your class that subclasses FFIOpaqueObject: FFIOpaqueObject subclass: USBDevice etc... 2) Get a pointer to the array: arrayPtr :=

Re: [Pharo-users] [UFFI] Getting an array of opaque structures filled

2016-07-04 Thread Julien Delplanque
On 04/07/16 12:18, Ben Coman wrote: On Mon, Jul 4, 2016 at 4:24 PM, Julien Delplanque wrote: Hello again Esteban, all others, I am still experiencing strange behaviors with the objects in the external array. I get a lot of NULL pointers and some strange addresses (I guess, I am not a C expe

Re: [Pharo-users] [UFFI] Getting an array of opaque structures filled

2016-07-04 Thread Esteban Lorenzano
> On 04 Jul 2016, at 12:15, Ben Coman wrote: > > How does it compare with the result you get in pure C? > e.g. using this code... > http://libusb.org/browser/libusb/examples/lsusb.c?rev=efc29733ad31f81883a7ac51a6cc6cda9ad4feb9&order=name > >

Re: [Pharo-users] [UFFI] Getting an array of opaque structures filled

2016-07-04 Thread Ben Coman
> On Mon, Jul 4, 2016 at 4:24 PM, Julien Delplanque wrote: >> Hello again Esteban, all others, >> >> I am still experiencing strange behaviors with the objects in the external >> array. >> >> I get a lot of NULL pointers and some strange addresses (I guess, I am not a >> C expert) that are close t

Re: [Pharo-users] [UFFI] Getting an array of opaque structures filled

2016-07-04 Thread Ben Coman
How does it compare with the result you get in pure C? e.g. using this code... http://libusb.org/browser/libusb/examples/lsusb.c?rev=efc29733ad31f81883a7ac51a6cc6cda9ad4feb9&order=name On Mon, Jul 4, 2016 at 4:24 PM, Julien Delplanque wrote: > Hello again Esteban, all others, > > I am still exper

Re: [Pharo-users] [UFFI] Getting an array of opaque structures filled

2016-07-04 Thread Julien Delplanque
Hello again Esteban, all others, I am still experiencing strange behaviors with the objects in the external array. I get a lot of NULL pointers and some strange addresses (I guess, I am not a C expert) that are close to NULL (see the screenshot attached). These objects make the VM crash (seg

Re: [Pharo-users] [UFFI] Getting an array of opaque structures filled

2016-07-01 Thread Julien Delplanque
And it works! Thanks a lot! Yes I should join slack, do I need an invitation or something? Julien On 01/07/16 14:03, Esteban Lorenzano wrote: ok, can you reload development version and try again? ps: this is easier on slack ;) On 01 Jul 2016, at 14:00, Esteban Lorenzano wrote: yes, I ma

Re: [Pharo-users] [UFFI] Getting an array of opaque structures filled

2016-07-01 Thread Julien Delplanque
No problem, give me as much version(s) to test as you want. :p Julien On 01/07/16 14:00, Esteban Lorenzano wrote: yes, I made a mistake… the problem of not being capable of test here :( 1 minute. Esteban On 01 Jul 2016, at 13:56, Julien Delplanque wrote: Ok, now I get a different excepti

Re: [Pharo-users] [UFFI] Getting an array of opaque structures filled

2016-07-01 Thread Esteban Lorenzano
ok, can you reload development version and try again? ps: this is easier on slack ;) > On 01 Jul 2016, at 14:00, Esteban Lorenzano wrote: > > yes, I made a mistake… the problem of not being capable of test here :( > > 1 minute. > > Esteban > >> On 01 Jul 2016, at 13:56, Julien Delplanque wr

Re: [Pharo-users] [UFFI] Getting an array of opaque structures filled

2016-07-01 Thread Esteban Lorenzano
yes, I made a mistake… the problem of not being capable of test here :( 1 minute. Esteban > On 01 Jul 2016, at 13:56, Julien Delplanque wrote: > > Ok, now I get a different exception! :-) > > "MessageNotUnderstood: LUDevice class>>fromHandle:" > > when executing: "array first." > > Where LU

Re: [Pharo-users] [UFFI] Getting an array of opaque structures filled

2016-07-01 Thread Julien Delplanque
Ok, now I get a different exception! :-) "MessageNotUnderstood: LUDevice class>>fromHandle:" when executing: "array first." Where LUDevice is defined like this: FFIOpaqueObject subclass: #LUDevice instanceVariableNames: '' classVariableNames: '' package: 'LibUsb-Kernel' Julien O

Re: [Pharo-users] [UFFI] Getting an array of opaque structures filled

2016-07-01 Thread Esteban Lorenzano
I need you to test :) can you execute this: (ConfigurationOfUnifiedFFI project version: #development) load. and then retry your example? thanks, Esteban ps: this became pharo-dev, but well… still here :) > On 01 Jul 2016, at 13:48, Julien Delplanque wrote: > > Oh, ok :p > > Can you notif

Re: [Pharo-users] [UFFI] Getting an array of opaque structures filled

2016-07-01 Thread Julien Delplanque
Oh, ok :p Can you notify me know when the bug will be resolved? Thanks, Julien On 01/07/16 13:36, Esteban Lorenzano wrote: … and now you hit a bug. bah, an “non implemented feature” :P I never tested arrays with complex types. it should not be hard… I will provide a fix. Esteban On 01 J

Re: [Pharo-users] [UFFI] Getting an array of opaque structures filled

2016-07-01 Thread Esteban Lorenzano
… and now you hit a bug. bah, an “non implemented feature” :P I never tested arrays with complex types. it should not be hard… I will provide a fix. Esteban > On 01 Jul 2016, at 13:30, Julien Delplanque wrote: > > Ok, the ffi call is done without problem with your method thanks. :) > > But

Re: [Pharo-users] [UFFI] Getting an array of opaque structures filled

2016-07-01 Thread Julien Delplanque
Ok, the ffi call is done without problem with your method thanks. :) But now that I have the array, when I try to access the first element using: array first. I get a exception saying I need to override a method: "SubclassResponsibility: FFIOpaqueObjectType had the subclass responsibility to

Re: [Pharo-users] [UFFI] Getting an array of opaque structures filled

2016-07-01 Thread Esteban Lorenzano
> On 01 Jul 2016, at 12:27, Esteban Lorenzano wrote: > > hi, > > this is because you want to get an array with opaque objects. Do not let the > *** confuses you… cwhat you actually want, conceptually is something like > this: > > *((FFIOpaqueObject*)[]) > > means: you pass the address of

Re: [Pharo-users] [UFFI] Getting an array of opaque structures filled

2016-07-01 Thread Esteban Lorenzano
hi, this is because you want to get an array with opaque objects. Do not let the *** confuses you… cwhat you actually want, conceptually is something like this: *((FFIOpaqueObject*)[]) means: you pass the address of an array of opaque types (who are always pointers). So, what you need to pa

Re: [Pharo-users] [UFFI] Getting an array of opaque structures filled

2016-07-01 Thread Julien Delplanque
Thanks, it works I get an instance of FFIOpaqueObject. But how do I get a specific libusb_device object from the list? Thanks again for you quick answer :-). Julien On 01/07/16 11:44, Esteban Lorenzano wrote: Hi, an opaque structure is not an FFIExternalObject but an FFIOpaqueObject. in tha

Re: [Pharo-users] [UFFI] Getting an array of opaque structures filled

2016-07-01 Thread Esteban Lorenzano
Hi, an opaque structure is not an FFIExternalObject but an FFIOpaqueObject. in that case, something like (simplified): ctx := (your context). list := FFIOpaqueObject new. size := self getDevice: ctx list: list. getDevice: ctx list: list ^ self ffiCall: #(size_t libusb_get_device_list

[Pharo-users] [UFFI] Getting an array of opaque structures filled

2016-07-01 Thread Julien Delplanque
Hello everyone, I have a question about the UFFI API. I have the following function: ssize_t libusb_get_device_list (libusb_context *ctx, libusb_device ***list) where libusb_device is an opaque structure. I made a type mapping "ssize_t" -> "int" and an object inheriting from FFIExternalObject