Yes, I did. I found it difficult to understand. It would be nice to have some
clear examples in the documentation, for example, really simple and common
situations such as a C function returning an integer in a
passed-by-reference argument.

Speaking of documentation, in "Pharo by Example 50," I found this statement:

> (Recall that you should set halosEnabled in the Preferences
browser.)

However, nowhere else in the book is there any reference to halosEnabled or
Preferences browser. Did you guys forget and leave out a chunk of the book?



Stephane Ducasse-3 wrote
> Did you read the UFFI chapter?
> 
> https://ci.inria.fr/pharo-contribution/view/Books/job/PharoBookWorkInProgress/174/artifact/book-result/UnifiedFFI/UnifiedFFI.pdf
> 
> https://ci.inria.fr/pharo-contribution/view/Books/job/PharoBookWorkInProgress/174/artifact/book-result/UnifiedFFI/
> 
> 
> I'm  turning it into a booklet but I will not write it because I'm bad in
> FFI
> Now if you have corrections, suggestions, please do some pull requests
> 
> https://github.com/SquareBracketAssociates/Booklet-uFFI
> 
> Stef
> 
> On Mon, May 22, 2017 at 10:42 PM, horrido <

> horrido.hobbies@

> > wrote:
> 
>> There is shockingly very little documentation on how to use uFFI. In
>> particular, I have the following situation...
>>
>> A shared C lib has the following function:
>>
>> void get_machine(char *machine) {
>>         uname(&uname_s);
>>         strcpy(machine, uname_s.machine);
>> }
>>
>> It copies the content of a string value into the buffer passed to it
>> (char
>> *machine).
>>
>> I want to call this function from Pharo, thus:
>>
>> buffer := String new: 64.
>> self ffiCall: #( void get_machine(String buffer) ).
>>
>> The buffer never receives the string value (it just contains the 64
>> initiialized spaces).
>>
>> Clearly, I'm misunderstanding the proper mechanism for doing this.
>>
>> [There are other functions in the shared C lib that work fine, such as:
>>
>> uint get_uptime() {
>>         sysinfo(&info);
>>         return info.uptime;
>> }
>>
>> Returning integers or floats is no problem. But passing arguments by
>> reference seems to be verboten.]
>>
>>
>>
>> --
>> View this message in context: http://forum.world.st/How-to-
>> use-uFFI-with-String-tp4947890.html
>> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>>
>>





--
View this message in context: 
http://forum.world.st/How-to-use-uFFI-with-String-tp4947890p4948427.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.

Reply via email to