[gambit-list] Converting uint32 to scheme object
Alex Silva
asandroq at gmail.com
Thu Jan 7 05:00:55 EST 2016
Hallo,
On 06/01/16 15:37, Marc Feeley wrote:
> Of course one way would be to return a double (which has 53 bits of precision) and use NaN to encode “missing tag”. I’m not kidding!
>
> If you don’t like this approach, and I can understand why you wouldn’t, then you have to do the conversion to ___SCMOBJ by directly calling the conversion macros. Something like this:
>
> (define uint32_tag
> (c-lambda
> (TIFF* ttag_t)
> scheme-object
> "
> ___U32 val;
> if (TIFFGetField(___arg1, ___arg2, &val) == 1) {
> if ((___err = ___U32_to_SCMOBJ (___PSTATE, val, &___result, ___RETURN_POS)) == ___FIX(___NO_ERR)) {
> ___release_scmobj (___result);
> }
> } else {
> ___result = ___FAL;
> }
> "))
>
Thanks, this looks promising. But I do not understand the call to
`___release_scmobj`, wouldn't that release the object that we are
returning? Or is it just decrementing some reference count?
Cheers,
--
-alex
http://unendli.ch/
More information about the Gambit-list
mailing list