RFC on plans to implement a c2ffi->cffi generator
Attila Lendvai
attila at lendvai.name
Fri Dec 11 18:50:43 UTC 2015
> the c2ffi output contains offset for each field in a struct, which
> enables us to generate partial bindings where not all struct fields
> need to have a defined type.
and on this note, where can i find info/examples on bitfield support
in cffi? (as in { int bar : 3}, not DEFBITFIELD) IIRC it does support
bitfields, but i couldn't find it in the code.
the OFFSET slot in FOREIGN-STRUCT-SLOT doesn't say anything about the
unit it's assuming, but the way it's used in MEM-REF suggests it's in
bytes (as opposed to bits), right?
as an example, this is what c2ffi emits:
struct {
unsigned int f1 : 1;
int f2 : 3;
} teststruct;
=>
{
"type": {
"fields": [
{
"type": {
"type": {
"tag": ":unsigned-int"
},
"width": 1,
"tag": ":bitfield"
},
"bit-alignment": 32,
"bit-size": 32,
"bit-offset": 0,
"name": "f1",
"tag": "field"
},
{
"type": {
"type": {
"tag": ":int"
},
"width": 3,
"tag": ":bitfield"
},
"bit-alignment": 32,
"bit-size": 32,
"bit-offset": 1,
"name": "f2",
"tag": "field"
}
],
"bit-alignment": 32,
"bit-size": 32,
"location": "[...]\/autospec\/bluez.h:1:1",
"id": 1,
"name": "",
"ns": 0,
"tag": "struct"
},
"location": "[...]\/autospec\/bluez.h:4:3",
"name": "teststruct",
"tag": "const"
},
--
• attila lendvai
• PGP: 963F 5D5F 45C7 DFCD 0A39
--
A costume doesn't change morality. If you kick in doors to threaten
peaceful strangers in their own home, or if you kidnap peaceful
individuals to lock them up in your basement, then *you* are the
criminal, even if you do this wearing a blue clown suit.
More information about the cffi-devel
mailing list