Skip to content

Commit 93ed6e3

Browse files
authored
Merge pull request #85 from kornilova-l/fix-array-size-for-anonymous-struct
Convert bits to bytes
2 parents 2a19669 + eb63e57 commit 93ed6e3

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

bindgen/TypeTranslator.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,10 @@ std::shared_ptr<Type>
101101
TypeTranslator::translateStructOrUnion(const clang::QualType &qtpe) {
102102
if (qtpe->hasUnnamedOrLocalType()) {
103103
// TODO: Verify that the local part is not a problem
104-
uint64_t size = ctx->getTypeSize(qtpe);
104+
uint64_t sizeInBits = ctx->getTypeSize(qtpe);
105+
assert(sizeInBits % 8 == 0);
105106
return std::make_shared<ArrayType>(
106-
std::make_shared<PrimitiveType>("Byte"), size);
107+
std::make_shared<PrimitiveType>("Byte"), sizeInBits / 8);
107108
}
108109

109110
return translateStructOrUnionOrEnum(qtpe);

tests/samples/ReservedWords.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ object ReservedWordsHelpers {
4848
def instance_=(value: native.Ptr[`object`]): Unit = !p.cast[native.Ptr[native.Ptr[`object`]]] = value
4949
def `forSome`: native.Ptr[`match`] = p.cast[native.Ptr[`match`]]
5050
def `forSome_=`(value: `match`): Unit = !p.cast[native.Ptr[`match`]] = value
51-
def `implicit`: native.Ptr[native.CArray[Byte, native.Nat.Digit[native.Nat._1, native.Nat.Digit[native.Nat._2, native.Nat._8]]]] = p.cast[native.Ptr[native.CArray[Byte, native.Nat.Digit[native.Nat._1, native.Nat.Digit[native.Nat._2, native.Nat._8]]]]]
52-
def `implicit_=`(value: native.CArray[Byte, native.Nat.Digit[native.Nat._1, native.Nat.Digit[native.Nat._2, native.Nat._8]]]): Unit = !p.cast[native.Ptr[native.CArray[Byte, native.Nat.Digit[native.Nat._1, native.Nat.Digit[native.Nat._2, native.Nat._8]]]]] = value
51+
def `implicit`: native.Ptr[native.CArray[Byte, native.Nat.Digit[native.Nat._1, native.Nat._6]]] = p.cast[native.Ptr[native.CArray[Byte, native.Nat.Digit[native.Nat._1, native.Nat._6]]]]
52+
def `implicit_=`(value: native.CArray[Byte, native.Nat.Digit[native.Nat._1, native.Nat._6]]): Unit = !p.cast[native.Ptr[native.CArray[Byte, native.Nat.Digit[native.Nat._1, native.Nat._6]]]] = value
5353
}
5454
}

0 commit comments

Comments
 (0)