Re: [Pharo-users] Unified FFI: pointer of String as function parameter

2016-05-30 Thread Julien Delplanque
On 30/05/16 11:44, Esteban Lorenzano wrote: On 30 May 2016, at 11:39, Julien Delplanque wrote: I just did it, it works directly except for 2 little mistakes (for people who are interested): The class method to override in StringValueHolder is #typeDecl and not #typeDesc. To get the actual

Re: [Pharo-users] Unified FFI: pointer of String as function parameter

2016-05-30 Thread Esteban Lorenzano
> On 30 May 2016, at 11:39, Julien Delplanque wrote: > > I just did it, it works directly except for 2 little mistakes (for people who > are interested): > > The class method to override in StringValueHolder is #typeDecl and not > #typeDesc. > > To get the actual String from the StringValueH

Re: [Pharo-users] Unified FFI: pointer of String as function parameter

2016-05-30 Thread Julien Delplanque
I just did it, it works directly except for 2 little mistakes (for people who are interested): The class method to override in StringValueHolder is #typeDecl and not #typeDesc. To get the actual String from the StringValueHolder, no need to call #readString on the result of #value, it causes

Re: [Pharo-users] Unified FFI: pointer of String as function parameter

2016-05-30 Thread Julien Delplanque
Thanks for the fast answer. :-) On 30/05/16 11:14, Esteban Lorenzano wrote: this is not the easiest part of FFI :) this is the simplest way: str := ExternalAddress new. “This will point to NULL” self callToMyFunction: str. pharoString := (str pointerAt: 1) readString. callToMyFunction: str

Re: [Pharo-users] Unified FFI: pointer of String as function parameter

2016-05-30 Thread Esteban Lorenzano
this is not the easiest part of FFI :) this is the simplest way: str := ExternalAddress new. “This will point to NULL” self callToMyFunction: str. pharoString := (str pointerAt: 1) readString. callToMyFunction: str self ffiCall: #( void function ( char ** str ) ) now, another way is

[Pharo-users] Unified FFI: pointer of String as function parameter

2016-05-30 Thread Julien Delplanque
Hello everyone, I have a C function to call from Pharo that looks like this: int my_function(char ** parameter); This function fill the pointer on the String given as parameter. How can I use this from pharo Unified FFI? I mean, how to get a pharo String filled by this function? Thanks in a