Skip to content

Commit cc271d6

Browse files
committed
Codegen: ignore synth properties in cppgen
1 parent b09386a commit cc271d6

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

misc/codegen/generators/cppgen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def _get_class(self, name: str) -> cpp.Class:
7676
bases=[self._get_class(b) for b in cls.bases],
7777
fields=[
7878
_get_field(cls, p, self._add_or_none_except)
79-
for p in cls.properties if "cpp_skip" not in p.pragmas
79+
for p in cls.properties if "cpp_skip" not in p.pragmas and not p.synth
8080
],
8181
final=not cls.derived,
8282
trap_name=trap_name,

misc/codegen/test/test_cppgen.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,5 +203,27 @@ def test_ipa_classes_ignored(generate):
203203
]
204204

205205

206+
def test_synth_properties_ignored(generate):
207+
assert generate([
208+
schema.Class(
209+
name="X",
210+
properties=[
211+
schema.SingleProperty("x", "a"),
212+
schema.SingleProperty("y", "b", synth=True),
213+
schema.SingleProperty("z", "c"),
214+
schema.OptionalProperty("foo", "bar", synth=True),
215+
schema.RepeatedProperty("baz", "bazz", synth=True),
216+
schema.RepeatedOptionalProperty("bazzz", "bazzzz", synth=True),
217+
schema.RepeatedUnorderedProperty("bazzzzz", "bazzzzzz", synth=True),
218+
],
219+
),
220+
]) == [
221+
cpp.Class(name="X", final=True, trap_name="Xes", fields=[
222+
cpp.Field("x", "a"),
223+
cpp.Field("z", "c"),
224+
]),
225+
]
226+
227+
206228
if __name__ == '__main__':
207229
sys.exit(pytest.main([__file__] + sys.argv[1:]))

0 commit comments

Comments
 (0)