Track parsed_timezone presence and escape host TZ codegen

This commit is contained in:
J. Nick Koston
2026-08-14 14:18:20 -05:00
parent dffe9863d1
commit c8380daf85
8 changed files with 46 additions and 8 deletions
+20
View File
@@ -937,9 +937,29 @@ class MessageType(TypeInfo):
# runtime polymorphism through virtual function calls.
return None
@property
def public_content(self) -> list[str]:
content = [self.class_member]
if self._track_presence:
content.append(f"bool has_{self.name}{{false}};")
return content
@property
def _track_presence(self) -> bool:
# Use getattr to handle older versions of api_options_pb2
opt = getattr(pb, "track_presence", None)
return opt is not None and get_field_opt(self._field, opt, False)
@property
def decode_length_content(self) -> str:
# Custom decode that doesn't use templates
if self._track_presence:
return (
f"case {self.number}:\n"
f" this->has_{self.name} = true;\n"
f" value.decode_to_message(this->{self.field_name});\n"
f" break;"
)
return f"case {self.number}: value.decode_to_message(this->{self.field_name}); break;"
def dump(self, name: str) -> str: