From 3720b2b3c219fa17151f85ffe0ba227cdce0d692 Mon Sep 17 00:00:00 2001 From: Igor Randjelovic Date: Tue, 26 Jul 2022 20:13:27 +0200 Subject: [PATCH] fix(metadata-generator): skip empty bitfields (#178) --- .../src/TypeScript/DefinitionWriter.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/metadata-generator/src/TypeScript/DefinitionWriter.cpp b/metadata-generator/src/TypeScript/DefinitionWriter.cpp index d96ff830..6d20d891 100644 --- a/metadata-generator/src/TypeScript/DefinitionWriter.cpp +++ b/metadata-generator/src/TypeScript/DefinitionWriter.cpp @@ -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(meta->declaration)->getPropertyImplementation() == clang::ObjCPropertyDecl::PropertyControl::Optional) { output << "?"; @@ -751,6 +756,13 @@ void DefinitionWriter::writeMembers(const std::vector& 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; } }