Skip to content

Commit

Permalink
fix(metadata-generator): skip empty bitfields (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
rigor789 authored Jul 26, 2022
1 parent 6ee354c commit 3720b2b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions metadata-generator/src/TypeScript/DefinitionWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,11 @@ std::string DefinitionWriter::writeProperty(PropertyMeta* meta, BaseClassMeta* o
return std::string();
}

// prevent writing out empty property names
if (meta->jsName.length() == 0) {
return std::string();
}

output << meta->jsName;
if (owner->is(MetaType::Protocol) && clang::dyn_cast<clang::ObjCPropertyDecl>(meta->declaration)->getPropertyImplementation() == clang::ObjCPropertyDecl::PropertyControl::Optional) {
output << "?";
Expand Down Expand Up @@ -751,6 +756,13 @@ void DefinitionWriter::writeMembers(const std::vector<RecordField>& fields, std:
if (i < fieldsComments.size()) {
_buffer << fieldsComments[i].toString("\t");
}

// prevent writing empty field names,
// fixes issue with structs containing emtpy bitfields (ie. __darwin_fp_control)
if(fields[i].name.length() == 0) {
continue;
}

_buffer << "\t" << fields[i].name << ": " << tsifyType(*fields[i].encoding) << ";" << std::endl;
}
}
Expand Down

0 comments on commit 3720b2b

Please sign in to comment.