@@ -42,9 +42,10 @@ std::shared_ptr<Location> StructOrUnion::getLocation() const {
4242}
4343
4444Struct::Struct (std::string name, std::vector<std::shared_ptr<Field>> fields,
45- uint64_t typeSize, std::shared_ptr<Location> location)
45+ uint64_t typeSize, std::shared_ptr<Location> location,
46+ bool isPacked)
4647 : StructOrUnion(std::move(name), std::move(fields), std::move(location)),
47- typeSize(typeSize) {}
48+ typeSize(typeSize), isPacked(isPacked) {}
4849
4950std::shared_ptr<TypeDef> Struct::generateTypeDef () {
5051 if (fields.size () < SCALA_NATIVE_MAX_STRUCT_FIELDS) {
@@ -89,7 +90,10 @@ std::string Struct::generateHelperClass() const {
8990}
9091
9192bool Struct::hasHelperMethods () const {
92- return !fields.empty () && fields.size () < SCALA_NATIVE_MAX_STRUCT_FIELDS;
93+ if (!isRepresentedAsStruct ()) {
94+ return false ;
95+ }
96+ return !isPacked && !fields.empty ();
9397}
9498
9599std::string Struct::getTypeAlias () const { return " struct_" + name; }
@@ -160,6 +164,10 @@ std::string Struct::generateGetter(unsigned fieldIndex) const {
160164 return s.str ();
161165}
162166
167+ bool Struct::isRepresentedAsStruct () const {
168+ return fields.size () <= SCALA_NATIVE_MAX_STRUCT_FIELDS;
169+ }
170+
163171Union::Union (std::string name, std::vector<std::shared_ptr<Field>> fields,
164172 uint64_t maxSize, std::shared_ptr<Location> location)
165173 : StructOrUnion(std::move(name), std::move(fields), std::move(location)),
0 commit comments