Subject:
Re: [ruby-ffi] Pointer to a struct - how to cast?
From:
DA
Date:
5/20/10 2:04 PM
To:
ruby-ffi@googlegroups.com

On Thu, May 20, 2010 at 2:48 PM, Chuck Remes <cremes.devlist@mac.com> wrote:

> That looks kind of funky to me. In the F_TextItemsT C struct, it shows *val which is just a single pointer. There is no array of pointers to read from at that location. I believe the syntax for arrays of pointers are more like:
>
> struct {
>  int len;
>  item_t **list;
> }
>
> Note the double-asterisk.
>
> Have you written this in C to see how to get each F_TextItemT?

Hi Chuck, you're right, that pointer is for an array of F_TextItemT,
*not* an array of pointers to F_TextItemT.

The c code looks like this:

tis = F_ApiGetText(docId, flowId, FTI_String | FTI_LineEnd);
/* Traverse text items and print strings and line ends. */
for (i=0; i<tis.len; i++)
{
ip = &tis.val[i];
if (ip->dataType == FTI_String)
F_Printf(NULL,"%s", ip->u.sdata);
else F_Printf(NULL,"\n");
}

So I guess I need the equivalent of "get_array_of_struct"?  I can't
find an example for this case (array of struct) on the wiki.  Any
ideas?

Thanks,
Drew