* a foreign struct: a shameless request
@ 2017-06-16 16:04 Catonano
2017-06-16 19:02 ` Taylan Ulrich Bayırlı/Kammer
0 siblings, 1 reply; 5+ messages in thread
From: Catonano @ 2017-06-16 16:04 UTC (permalink / raw)
To: guile-user
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
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: a foreign struct: a shameless request
2017-06-16 16:04 a foreign struct: a shameless request Catonano
@ 2017-06-16 19:02 ` Taylan Ulrich Bayırlı/Kammer
2017-06-18 6:22 ` Catonano
0 siblings, 1 reply; 5+ messages in thread
From: Taylan Ulrich Bayırlı/Kammer @ 2017-06-16 19:02 UTC (permalink / raw)
To: Catonano; +Cc: guile-user
Catonano <catonano@gmail.com> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: a foreign struct: a shameless request
2017-06-16 19:02 ` Taylan Ulrich Bayırlı/Kammer
@ 2017-06-18 6:22 ` Catonano
2017-06-18 12:28 ` Amirouche
0 siblings, 1 reply; 5+ messages in thread
From: Catonano @ 2017-06-18 6:22 UTC (permalink / raw)
To: Taylan Ulrich Bayırlı/Kammer; +Cc: guile-user
Taylan,
2017-06-16 21:02 GMT+02:00 Taylan Ulrich Bayırlı/Kammer <
taylanbayirli@gmail.com>:
>
>
> 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/
>
>
Than you for your offer !
I am impressed that Bytestructures works on so many different scheme
implementations
I am a bit concerned that it as no proper packaging so it'd be hard to port
it in Guix. That's an issue for me
I took a look at the code, though
I think I understand now
The size of the union'ed field has to be the maximum of the sizes of the
types of the things the field could be populated with
That's all I need, I think, to use make-c-struct
Then I can pass the thing to Ffreexl functions and they will populate it
Then, depending on the contents of the type field, I can parse the thing
accordingly, to get back scheme things
This is the master plan
I can't do it today, though. I'll be busy
I'll get back to you, with this
Thanks for showing me scheme-bytestructures !
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: a foreign struct: a shameless request
2017-06-18 6:22 ` Catonano
@ 2017-06-18 12:28 ` Amirouche
2017-06-18 14:41 ` Catonano
0 siblings, 1 reply; 5+ messages in thread
From: Amirouche @ 2017-06-18 12:28 UTC (permalink / raw)
To: guile-user
Le 18/06/2017 à 08:22, Catonano a écrit :
> Taylan,
>
> 2017-06-16 21:02 GMT+02:00 Taylan Ulrich Bayırlı/Kammer <
> taylanbayirli@gmail.com>:
>
>>
>> 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/
>>
>>
> Than you for your offer !
>
> I am impressed that Bytestructures works on so many different scheme
> implementations
>
> I am a bit concerned that it as no proper packaging so it'd be hard to port
> it in Guix. That's an issue for me
It's packaged in guix under the name guile-bytestructures
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: a foreign struct: a shameless request
2017-06-18 12:28 ` Amirouche
@ 2017-06-18 14:41 ` Catonano
0 siblings, 0 replies; 5+ messages in thread
From: Catonano @ 2017-06-18 14:41 UTC (permalink / raw)
To: Amirouche; +Cc: guile-user
2017-06-18 14:28 GMT+02:00 Amirouche <amirouche@hypermove.net>:
>
>
> Le 18/06/2017 à 08:22, Catonano a écrit :
>
>> Taylan,
>>
>> 2017-06-16 21:02 GMT+02:00 Taylan Ulrich Bayırlı/Kammer <
>> taylanbayirli@gmail.com>:
>>
>>
>>> 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/
>>>
>>>
>>> Than you for your offer !
>>
>> I am impressed that Bytestructures works on so many different scheme
>> implementations
>>
>> I am a bit concerned that it as no proper packaging so it'd be hard to
>> port
>> it in Guix. That's an issue for me
>>
> It's packaged in guix under the name guile-bytestructure
oh wow !
Then I'll surely take a look !
Thank you Amirrouche !
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-06-18 14:41 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-16 16:04 a foreign struct: a shameless request Catonano
2017-06-16 19:02 ` Taylan Ulrich Bayırlı/Kammer
2017-06-18 6:22 ` Catonano
2017-06-18 12:28 ` Amirouche
2017-06-18 14:41 ` Catonano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).