guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: a foreign struct: a shameless request


From: Taylan Ulrich Bayırlı/Kammer
Subject: Re: a foreign struct: a shameless request
Date: Fri, 16 Jun 2017 21:02:08 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux)

Catonano <address@hidden> writes:

> I'd love to see a template of usage of a complex structure from scheme
> That is, I'm asking for someone to write that template for me :-/
>
> This is the foreign struct I have to deal with
>
> https://www.gaia-gis.it/gaia-sins/freexl-1.0.1-doxy-doc/html/structFreeXL__CellValue__str.html

With bytestructures[0], this would be:

    (define freexl-cell-value
      (bs:struct
        `((type ,uint8)
          (value ,(bs:union
                    `((int_value ,int)
                      (double_value ,double)
                      (text_value ,cstring-pointer)))))))

If you decide to use bytestructures, feel free to e-mail me privately or
use the GitHub issues system for questions.  I don't actively monitor
the Guile ML these days so I may miss your questions and feedback here.

[0] https://github.com/TaylanUB/scheme-bytestructures/

HTH,
Taylan

> Particulary, I don't know how to treat the "union" thing
>
> A different union field gets populated on the basis of the type of the
> content of the spreadsheet cell
>
> If the cell contains an integer number, then cell.int_value field gets
> populated
>
> If the cell contains a double float number, then the cell.double_value
> field gets populated
>
> And so on
>
> This is an excerpt from the example usage:
>
> switch (cell.type
> <https://www.gaia-gis.it/gaia-sins/freexl-1.0.1-doxy-doc/html/structFreeXL__CellValue__str.html#af2b1f157e4dc4508b1c4e303429c01d5>
> )
> {
>    case FREEXL_CELL_INT
> <https://www.gaia-gis.it/gaia-sins/freexl-1.0.1-doxy-doc/html/freexl_8h.html#a1a2260897b305108f008c924a7e56778>
> :
>    printf (", %d", cell.value
> <https://www.gaia-gis.it/gaia-sins/freexl-1.0.1-doxy-doc/html/structFreeXL__CellValue__str.html#acaf7ae03285c299b05f0e345eff3c6a1>
> .int_value
> <https://www.gaia-gis.it/gaia-sins/freexl-1.0.1-doxy-doc/html/structFreeXL__CellValue__str.html#a7dcd352478ee217f4a24e7fcff6170bb>
> );
>    break;
> ...
>
> How do I use "make-c-struct" and "parse-c-struct" with a structure like
> this ?
>
> Thanks in advance



reply via email to

[Prev in Thread] Current Thread [Next in Thread]