mirror of
https://github.com/corda/corda.git
synced 2025-01-23 21:08:48 +00:00
fix member offset calculation inconsistencies in type-generator.cpp
This commit is contained in:
parent
6df0b2cfd9
commit
9c603c6525
@ -44,7 +44,7 @@ inline unsigned
|
|||||||
pad(unsigned size, unsigned alignment)
|
pad(unsigned size, unsigned alignment)
|
||||||
{
|
{
|
||||||
unsigned n = alignment;
|
unsigned n = alignment;
|
||||||
while (size and n % size and n % BytesPerWord) ++ n;
|
while (size and n % size) ++ n;
|
||||||
return n - alignment;
|
return n - alignment;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -886,11 +886,11 @@ class MemberIterator {
|
|||||||
offset_(type->type == Object::Pod ? 0 : BytesPerWord),
|
offset_(type->type == Object::Pod ? 0 : BytesPerWord),
|
||||||
size_(0),
|
size_(0),
|
||||||
padding_(0),
|
padding_(0),
|
||||||
alignment_(0)
|
alignment_(BytesPerWord)
|
||||||
{
|
{
|
||||||
while (skipSupers and hasMore() and this->type != type) next();
|
while (skipSupers and hasMore() and this->type != type) next();
|
||||||
padding_ = 0;
|
padding_ = 0;
|
||||||
alignment_ = 0;
|
alignment_ = BytesPerWord;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasMore() {
|
bool hasMore() {
|
||||||
@ -924,7 +924,7 @@ class MemberIterator {
|
|||||||
case Object::Scalar: {
|
case Object::Scalar: {
|
||||||
size_ = memberSize(member);
|
size_ = memberSize(member);
|
||||||
padding_ = pad(size_, alignment_);
|
padding_ = pad(size_, alignment_);
|
||||||
alignment_ = (alignment_ + size_ + padding_) % BytesPerWord;
|
alignment_ = (alignment_ + size_ + padding_) % 8;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case Object::Array: {
|
case Object::Array: {
|
||||||
@ -938,11 +938,11 @@ class MemberIterator {
|
|||||||
|
|
||||||
offset_ += padding_;
|
offset_ += padding_;
|
||||||
|
|
||||||
// fprintf(stderr,
|
// fprintf(stderr,
|
||||||
// "type: %s; member: %s; size: %d; padding: %d; alignment: %d;"
|
// "type: %s; member: %s; size: %d; padding: %d; alignment: %d;"
|
||||||
// " offset: %d;\n",
|
// " offset: %d;\n",
|
||||||
// typeName(type), memberName(member), size_, padding_, alignment_,
|
// typeName(type), memberName(member), size_, padding_, alignment_,
|
||||||
// offset_);
|
// offset_);
|
||||||
|
|
||||||
return member;
|
return member;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user