[squeak-dev] Fun with spock (NativeBoost FFI)

Lawson English lenglish5 at cox.net
Tue May 15 03:06:26 UTC 2012


On 5/14/12 8:02 PM, Lawson English wrote:
> OK, getting closer. However I'm still not quite getting what I expect:
>
>
> f1 := GMPfWrapper new.
> f2 := GMPfWrapper new.
> f3 := GMPfWrapper new.
> f1 set_ui: 50.
> f2 set_ui: 50.
> f3 set_ui:50.
> (f3 +f2) asString ==> '1
>
>
hmm apparently my source code was deleted. Something to do with the '>>"


relevant code:

GMPfWrapper>>asString



     |exp aString|
     exp := ByteArray new:4.
     aString := ByteString new: 12.   "for 10 digits"
     self prim___gmpf_get_str: aString WithExp:exp.
     ^aString

GMPfWrapper>>prim___gmpf_get_str: aString WithExp:exp

"Function: char * mpf_get_str (char *str, mp_exp_t *expptr, int base, 
size_t n_digits, mpf_t op)"
<primitive: #primitiveNativeCall module: #NativeBoostPlugin error: 
errorCode>

     ^ self nbCall: #( void __gmpf_get_str ( char *aString,  
NBSignedLong * exp, 10,  10, mpf_t gmpf))

-- 
Squeak from the very start (introduction to Squeak and Pharo Smalltalk for the (almost) complete and compleate beginner).
https://www.youtube.com/playlist?list=PL6601A198DF14788D&feature=view_all



More information about the Squeak-dev mailing list