Lisaac external C struct pointer and Enum
Mildred Ki'Lya
ml.mildred593 at gmail.com
Sun Apr 11 14:39:59 UTC 2010
On 04/11/2010 04:09 PM, Xavier Oswald wrote:
> Hi there,
>
> Im working a lot on lisaac libs since 2 weeks.
>
> Im wondering how you handle C struct pointers...
>
> As an example, I have "My_struct* s;"
> and have some C functions handling this struct.
>
Probably, you could create a prototype MY_STRUCT with:
Section Header
+ name := MY_STRUCT;
- type := `My_Struct*`;
Then, you can directly put MY_STRUCT as a type for C externals:
Section Public
- create <-
(
`malloc(sizeof(My_Struct))`:MY_STRUCT
);
- operation_on_my_struct <-
(
`operation_on_mt_struct(@Self)`
);
Be careful not to put any + slot on MY_STRUCT, that could be dangerous.
> Im wondering what's the best way to have My_Struct as a Prototype or something
> else...
>
> What do you think ?
> BTW, what's your opinion about how to handle C enum ?
>
>
What about C enums ?
These are just integer and integer constants ...
Section Header
- name := Expanded C_ENUM;
- type := `C_Enum`; // that's really an integer
Section Public
- enum_1 <- `C_ENUM_ENUM_1`:C_ENUM;
- enum_2 <- `C_ENUM_ENUM_2`:C_ENUM;
- enum_3 <- `C_ENUM_ENUM_3`:C_ENUM;
Then, I suppose you simply have to compare with the strict equality
operator if your variable of type C_ENUM is equal to C_ENUM.enum_1 or
any other constant.
But you might want to test if it works better, still, I'm quite sure.
Mildred
--
Mildred Ki'Lya
╭───────── mildred593@online.fr ──────────
│ Jabber, GoogleTalk: <mildred at jabber.fr>
│ Website: <http://ki.lya.online.fr> GPG ID: 9A7D 2E2B
│ Fingerprint: 197C A7E6 645B 4299 6D37 684B 6F9D A8D6 9A7D 2E2B
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: OpenPGP digital signature
URL: <http://lists.alioth.debian.org/pipermail/lisaac-devel/attachments/20100411/0c715624/attachment.pgp>
More information about the Lisaac-devel
mailing list