diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-01-02 09:30:43 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-01-02 09:43:28 -0800 |
commit | 6b06553049d438a52127fa722cbd8717d2a13680 (patch) | |
tree | 756fec86b34bfc56234301a2808e60240338df62 /socket.h | |
parent | 77340129486f06498bca2d536ec0406e02ca6d76 (diff) | |
download | txr-6b06553049d438a52127fa722cbd8717d2a13680.tar.gz txr-6b06553049d438a52127fa722cbd8717d2a13680.tar.bz2 txr-6b06553049d438a52127fa722cbd8717d2a13680.zip |
ffi: allow enumed bitfield.
* ffi.c (ffi_type_copy): Function moved earlier in file
without change.
(ffi_type_copy_new_ops): New stati function.
(make_ffi_type_enum): Do not create a new type object using
cobj; copy the existing base_type, and then tweak its
properties, just like what is done with bool. Thus if
base_type is a bitfield, the enum will be a bitfield.
Add check against doign this to anything but an FFI_KIND_NUM,
with the awareness that this does include floating-point types.
Since tft is now a copy, we no longer have to copy a number of
things from btft. We do set he kind field to FFI_KIND_ENUM.
(ffi_type_compile): In the two bitfield cases, we now
calculate the mask field for the bitfield type (leaving the
shift at zero). The struct or union type into which the
bitfield is embedded will still re-calculate this.
The reason is that when an (enumed (bit ...) ...) type is
defined, it constructs hash tables for converting between the
symbolic and numeric values. It calls the put function of the
underlying type to test whether each enumeration value can be
converted (i.e. is in range). So the bitfield type must have a
valid mask at that time, or else it will reject every nonzero
value as being out of range for the bitfield. I'm also
replacing the max_int variable with bits_int. Since bitfields
are restricted to no wider than int, why pretend?
* tests/017/ffi-misc.tl: New test cases.
* txr.1: Documented.
Diffstat (limited to 'socket.h')
0 files changed, 0 insertions, 0 deletions