-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from vkottler/dev/struct-sizes
Initial type-system integration
- Loading branch information
Showing
15 changed files
with
159 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
""" | ||
A module implementing unit-testing related generation utilities. | ||
""" | ||
|
||
# built-in | ||
from contextlib import contextmanager | ||
from typing import Iterator, List | ||
|
||
# third-party | ||
from vcorelib.io import IndentedFileWriter | ||
|
||
# internal | ||
from ifgen.generation.interface import GenerateTask | ||
|
||
|
||
@contextmanager | ||
def unit_test_boilerplate( | ||
task: GenerateTask, includes: List[str] = None | ||
) -> Iterator[IndentedFileWriter]: | ||
"""Handle standard unit-test boilerplate.""" | ||
|
||
include = task.env.rel_include(task.name, task.generator) | ||
|
||
if includes is None: | ||
includes = [] | ||
|
||
with task.boilerplate( | ||
includes=["<cassert>", "<cstring>", "<iostream>", f'"{include}"'] | ||
+ includes, | ||
is_test=True, | ||
use_namespace=False, | ||
description=f"A unit test for {task.generator} {task.name}.", | ||
) as writer: | ||
writer.write("int main(void)") | ||
with writer.scope(): | ||
writer.write(f"using namespace {task.namespace()};") | ||
writer.empty() | ||
yield writer | ||
writer.write("return 0;") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
vcorelib>=2.5.2 | ||
runtimepy>=2.1.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
""" | ||
A module implementing a unit-test output generator for structs. | ||
""" | ||
|
||
# third-party | ||
from vcorelib.io import IndentedFileWriter | ||
|
||
# internal | ||
from ifgen.generation.interface import GenerateTask | ||
from ifgen.generation.test import unit_test_boilerplate | ||
|
||
|
||
def unit_test_body(task: GenerateTask, writer: IndentedFileWriter) -> None: | ||
"""Implement a unit test for a struct.""" | ||
|
||
del task | ||
|
||
writer.cpp_comment("TODO.") | ||
writer.empty() | ||
|
||
|
||
def create_struct_test(task: GenerateTask) -> None: | ||
"""Create a unit test for the enum string-conversion methods.""" | ||
|
||
with unit_test_boilerplate(task) as writer: | ||
unit_test_body(task, writer) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
major: 1 | ||
minor: 0 | ||
minor: 1 | ||
patch: 0 | ||
entry: ig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ structs: | |
Test3: | ||
fields: | ||
- name: field1 | ||
type: int | ||
type: int32_t | ||
|
||
- name: field2 | ||
type: C::Test1 | ||
|