[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-smalltalk] CStruct ABI and packed structs
From: |
Paolo Bonzini |
Subject: |
Re: [Help-smalltalk] CStruct ABI and packed structs |
Date: |
Mon, 07 Jun 2010 09:26:48 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100430 Fedora/3.0.4-3.fc13 Lightning/1.0b2pre Thunderbird/3.0.4 |
On 06/07/2010 03:30 AM, Holger Hans Peter Freyther wrote:
- Add stdint.h types to cint.h enum and code
> - Add these to CObject.st
It shouldn't be necessary to add all of stdint.h. You just need to add
long long (i.e. hardcoded 64-bit) values. Then, all values except
#long/#ulong trivially map to one intXX_t/uintXX_t and you just need to
cut/paste classes and CDATA_* values.
You can even do this last, since it would only take some
search-and-replace to change your header file parser
- Attempt to add bitfields
This is not hard if you do it entirely in CStruct. It may require some
small refactoring, but nothing incredibly difficult. For the syntax I
suggest:
#( ....
((#bitfield1 3)
(#bitfield2 4)
(#bitfield3 1)) #uint)
since in non-packed structs the type will give you the alignment.
Feel free to add methods like
Integer extend [
truncateToBits: n [
"Keep the lowest N bits of the receiver."
^self bitAnd: (1 bitShift: n) - 1
]
signExtendToBits: n [
"Keep the lowest N bits of the receiver and sign extend them
using two's complement."
| mask |
mask := 1 bitShift: n - 1.
^(self bitAnd: mask - 1) - (self bitAnd: mask)
]
]
- Maybe start on the CPP/C Parser and see if what is missing to
parse our header files.
The C parser is a bit hard mostly because there is no documentation on
its state (I found none in 1.1.5). I think it's simpler to try to whip
out a simple converter in Perl or awk, like it was done for the GTK+
bindings.
Paolo