Skip to content

Commit

Permalink
[sourcegen] Debugging ... (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl committed Dec 31, 2024
1 parent 78e5333 commit 49c963b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion interfaces/sourcegen/sourcegen/_HeaderFileParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _parse_yaml(self) -> HeaderFile:
func.get("implements", ""),
uses,
func.get("what", "")))
return HeaderFile(self._path, [], recipes)
return HeaderFile(self._path, [], recipes, base)

@classmethod
def headers_from_h(cls, ignore_files, ignore_funcs) -> list[HeaderFile]:
Expand Down
1 change: 1 addition & 0 deletions interfaces/sourcegen/sourcegen/_dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ class HeaderFile:
path: Path
funcs: list[Func]
recipes: list[Recipe] = None
cabinet: str = ""

def output_name(self, auto="3", suffix=""):
"""Return updated path."""
Expand Down
8 changes: 4 additions & 4 deletions interfaces/sourcegen/sourcegen/clib/_CLibSourceGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ def _reverse_crosswalk(c_func: CFunc, base: str) -> tuple[dict[str, str], set[st
# retrieve object from cabinet
obj_base = cxx_type.split("<")[-1].split(">")[0]
args.append(f"{base}Cabinet::at({c_name})")
bases |= {obj_base}
if obj_base != base:
bases |= {obj_base}
else:
# regular parameter
args.append(c_name)
Expand Down Expand Up @@ -419,20 +420,19 @@ def _scaffold_source(self, header: HeaderFile) -> None:

template = loader.from_string(self._templates["clib-implementation"])
implementations = []
cabinet = None
other = set()
for c_func, recipe in zip(header.funcs, header.recipes):
body, bases = self._scaffold_body(c_func, recipe)
implementations.append(
template.render(declaration=c_func.declaration(),body=body))
cabinet = recipe.base
other |= bases

filename = header.output_name(suffix=".cpp", auto="3")
template = loader.from_string(self._templates["clib-source-file"])
print(header.cabinet)
output = template.render(
name=filename.stem, source_entries=implementations,
base=cabinet, other=other)
base=header.cabinet, other=other)

if self._out_dir:
out = Path(self._out_dir) / "src" / filename.name
Expand Down

0 comments on commit 49c963b

Please sign in to comment.