Skip to content

Commit b6b1b8b

Browse files
SGSSGenemr-c
andauthored
basic C++ code generation (#553)
* tox/make: fix PYTEST_EXTRA Co-authored-by: Michael R. Crusoe <[email protected]>
1 parent 818ee72 commit b6b1b8b

12 files changed

+682
-22
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ diff_pylint_report: pylint_report.txt
124124
diff-quality --compare-branch=main --violations=pylint pylint_report.txt
125125

126126
.coverage:
127-
python setup.py test --addopts "--cov --cov-config=.coveragerc --cov-report= -n auto"
127+
python setup.py test --addopts "--cov --cov-config=.coveragerc --cov-report= ${PYTEST_EXTRA}"
128128
$(COVBASE) -m schema_salad.main \
129129
--print-jsonld-context schema_salad/metaschema/metaschema.yml \
130130
> /dev/null

schema_salad/codegen.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
from . import schema
1717
from .codegen_base import CodeGenBase
18+
from .cpp_codegen import CppCodeGen
1819
from .dotnet_codegen import DotNetCodeGen
1920
from .exceptions import SchemaSaladException
2021
from .java_codegen import JavaCodeGen
@@ -58,15 +59,26 @@ def codegen(
5859
)
5960
)
6061
info = parser_info or pkg
61-
if lang == "python":
62+
if lang == "python" or lang == "cpp":
6263
if target:
6364
dest: Union[TextIOWrapper, TextIO] = open(
6465
target, mode="w", encoding="utf-8"
6566
)
6667
else:
6768
dest = sys.stdout
69+
if lang == "cpp":
70+
gen = CppCodeGen(
71+
base,
72+
dest,
73+
examples,
74+
pkg,
75+
copyright,
76+
)
77+
gen.parse(j)
78+
return
79+
else:
80+
gen = PythonCodeGen(dest, copyright=copyright, parser_info=info)
6881

69-
gen = PythonCodeGen(dest, copyright=copyright, parser_info=info)
7082
elif lang == "java":
7183
gen = JavaCodeGen(
7284
base,

0 commit comments

Comments
 (0)