Skip to content

Commit afd4d56

Browse files
author
Paolo Tranquilli
committed
Rust: first draft of canonical paths rework
1 parent dce29db commit afd4d56

File tree

151 files changed

+15496
-11031
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+15496
-11031
lines changed

misc/codegen/generators/rustgen.py

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -101,38 +101,27 @@ def _get_class(self, name: str) -> rust.Class:
101101
)
102102

103103
def get_classes(self):
104-
ret = {"": []}
104+
ret = []
105105
for k, cls in self._classmap.items():
106106
if not cls.imported and not cls.synth:
107-
ret.setdefault(cls.group, []).append(self._get_class(cls.name))
107+
ret.append(self._get_class(cls.name))
108108
elif cls.imported:
109-
ret[""].append(rust.Class(name=cls.name))
109+
ret.append(rust.Class(name=cls.name))
110110
return ret
111111

112112

113113
def generate(opts, renderer):
114114
assert opts.rust_output
115115
processor = Processor(schemaloader.load_file(opts.schema))
116116
out = opts.rust_output
117-
groups = set()
118117
with renderer.manage(generated=out.rglob("*.rs"),
119118
stubs=(),
120119
registry=out / ".generated.list",
121120
force=opts.force) as renderer:
122-
for group, classes in processor.get_classes().items():
123-
group = group or "top"
124-
groups.add(group)
125-
renderer.render(
126-
rust.ClassList(
127-
classes,
128-
opts.schema,
129-
),
130-
out / f"{group}.rs",
131-
)
132121
renderer.render(
133-
rust.ModuleList(
134-
groups,
135-
opts.schema,
122+
rust.ClassList(
123+
classes=processor.get_classes(),
124+
source=opts.schema,
136125
),
137126
out / f"mod.rs",
138127
)

misc/codegen/loaders/schemaloader.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,14 @@ def _fill_hideable_information(classes: typing.Dict[str, schema.Class]):
121121

122122

123123
def _check_test_with(classes: typing.Dict[str, schema.Class]):
124+
pragma = "qlest_test_with"
124125
for cls in classes.values():
125-
test_with = typing.cast(str, cls.pragmas.get("qltest_test_with"))
126-
transitive_test_with = test_with and classes[test_with].pragmas.get("qltest_test_with")
126+
if cls.name == cls.pragmas.get(pragma):
127+
# this is already implicit
128+
del cls.pragmas[pragma]
129+
for cls in classes.values():
130+
test_with = typing.cast(str, cls.pragmas.get(pragma))
131+
transitive_test_with = test_with and classes[test_with].pragmas.get(pragma)
127132
if test_with and transitive_test_with:
128133
raise schema.Error(f"{cls.name} has test_with {test_with} which in turn "
129134
f"has test_with {transitive_test_with}, use that directly")

rust/extractor/src/generated/.generated.list

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/extractor/src/generated/.gitattributes

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)