While class dumping YouTube Music, I ran into two problematic properties in a protobuf-generated class.
The property largestImageSource
had the type encoding
{YTImageSource=@@{YTClientResource=@@{optional<unsigned int>=B(?={dummy_type=[4{empty_struct=}]}I)}}{optional<unsigned int>=B(?={dummy_type=[4{empty_struct=}]}I)}{optional<unsigned int>=B(?={dummy_type=[4{empty_struct=}]}I)}}
which I reconstructed with
struct optional_unsigned_int {
BOOL optional;
union {
struct dummy_type {
struct empty_struct {
} empty[4];
} blank;
unsigned int type;
} either;
};
struct YTImageSource {
id objectAlpha;
id objectBeta;
struct YTClientResource {
id objectAlpha;
id objectBeta;
struct optional_unsigned_int ouiAlpha;
} resources;
struct optional_unsigned_int ouiAlpha;
struct optional_unsigned_int ouiBeta;
};
with the exception of the optional_unsigned_int
struct name, which according to the original encoding is optional<unsigned int>
, which can't be compiled in Objective-C. Looking over at C++17, there's a new class in the standard namespace called "optional", and allows std::optional<unsigned int>
.
The propery imageSources
had the type encoding
{vector<YTImageSource, std::__1::allocator<YTImageSource> >=^{YTImageSource}^{YTImageSource}{__compressed_pair<YTImageSource *, std::__1::allocator<YTImageSource> >=^{YTImageSource}}}
which is std::vector<struct YTImageSource>
in C++ (requires a .mm
file).