- Type_privateData type(pool, ivar_getTypeEncoding(ivar));
- CYPoolFFI(&pool, context, type.type_, type.GetFFI(), reinterpret_cast<uint8_t *>(self) + ivar_getOffset(ivar), value);
- return true;
+ ptrdiff_t offset(ivar_getOffset(ivar));
+ void *data(reinterpret_cast<uint8_t *>(self) + offset);
+
+ const char *encoding(ivar_getTypeEncoding(ivar));
+ if (encoding[0] == 'b') {
+ unsigned length, shift;
+ CYBitField(length, shift, self, ivar, encoding, offset);
+ _assert(shift + length <= sizeof(uintptr_t) * 8);
+ uintptr_t &field(*reinterpret_cast<uintptr_t *>(data));
+ uintptr_t mask((1 << length) - 1);
+ field = field & ~(mask << shift) | (uintptr_t(CYCastDouble(context, value)) & mask) << shift;
+ } else {
+ Type_privateData type(pool, ivar_getTypeEncoding(ivar));
+ CYPoolFFI(&pool, context, type.type_, type.GetFFI(), reinterpret_cast<uint8_t *>(self) + ivar_getOffset(ivar), value);
+ return true;
+ }