Skip to content

Commit 0e7b6ac

Browse files
committed
x
1 parent 4c2345e commit 0e7b6ac

5 files changed

Lines changed: 7 additions & 10 deletions

File tree

alt_core_api/tools/protoc_gen_arduinoif/core.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ def _iter_generated_files(
2828
continue
2929

3030
if proto_file.enum_type and not proto_file.service:
31-
yield from EnumRenderer(
32-
proto_file.name,
33-
list(proto_file.enum_type),
34-
).iter_headers()
31+
yield from EnumRenderer(proto_file.name, list(proto_file.enum_type))
3532

3633
for service in proto_file.service:
3734
service_model = ServiceModelBuilder.build(
@@ -40,7 +37,7 @@ def _iter_generated_files(
4037
list(proto_file.enum_type),
4138
context,
4239
)
43-
yield from ServiceRenderer(service_model).iter_headers()
40+
yield from ServiceRenderer(service_model)
4441

4542

4643
def main() -> int:

alt_core_api/tools/protoc_gen_arduinoif/enum_renderer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def __init__(self, proto_name: str, enums: List[EnumDescriptorProto]) -> None:
1717
self._proto_name = proto_name
1818
self._enums = enums
1919

20-
def iter_headers(self) -> Iterator[Tuple[str, str]]:
20+
def __iter__(self) -> Iterator[Tuple[str, str]]:
2121
yield self._header_name(), self.render_header_content()
2222

2323
def _header_name(self) -> str:

alt_core_api/tools/protoc_gen_arduinoif/service_renderer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class ServiceRenderer:
4545
def __init__(self, model: ServiceModel) -> None:
4646
self._model = model
4747

48-
def iter_headers(self) -> Iterator[Tuple[str, str]]:
48+
def __iter__(self) -> Iterator[Tuple[str, str]]:
4949
for header_attr, surface, gate_attr in _HEADER_ORDER:
5050
if gate_attr and not getattr(self._model, gate_attr):
5151
continue

alt_core_api/tools/protoc_gen_arduinoif/tests/test_renderer_templates.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def _sample_model() -> ServiceModel:
8989
def test_renderer_templates_emit_expected_fragments() -> None:
9090
model = _sample_model()
9191
renderer = ServiceRenderer(model)
92-
rendered = dict(renderer.iter_headers())
92+
rendered = dict(renderer)
9393

9494
ifc_content = rendered["example_interface.hpp"]
9595
assert "class ExampleInterface" in ifc_content
@@ -117,7 +117,7 @@ def test_renderer_template_iter_order_is_stable() -> None:
117117
model = _sample_model()
118118
renderer = ServiceRenderer(model)
119119

120-
names = [name for name, _ in renderer.iter_headers()]
120+
names = [name for name, _ in renderer]
121121
assert names == [
122122
"example_interface.hpp",
123123
"example_api.hpp",

alt_core_api/tools/protoc_gen_arduinoif/tests/test_service_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def test_build_service_model_has_expected_headers_and_groups(tmp_path: Path) ->
9494

9595
def test_render_service_headers_uses_stable_order(tmp_path: Path) -> None:
9696
model = _hardware_serial_model(tmp_path)
97-
rendered_names = [name for name, _ in ServiceRenderer(model).iter_headers()]
97+
rendered_names = [name for name, _ in ServiceRenderer(model)]
9898
assert rendered_names == [
9999
"hardware_serial_interface.hpp",
100100
"hardware_serial_api.hpp",

0 commit comments

Comments
 (0)