-
Notifications
You must be signed in to change notification settings - Fork 2
/
uxsdcxx.py
executable file
·29 lines (25 loc) · 1.06 KB
/
uxsdcxx.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env python3
import os
import sys
import xmlschema # type: ignore
from uxsdcxx.cpp import render_interface_header_file, render_header_file, render_impl_file
from uxsdcxx.schema import UxsdSchema
def main() -> None:
input_file = os.path.abspath(sys.argv[1])
base = os.path.splitext(os.path.basename(input_file))[0]
interface_header_file_name = base + "_uxsdcxx_interface.h"
header_file_name = base + "_uxsdcxx.h"
impl_file_name = base + "_uxsdcxx.cpp"
cmdline = " ".join(sys.argv)
schema = UxsdSchema(xmlschema.validators.XMLSchema10(input_file))
interface_header_file = open(interface_header_file_name, "w")
interface_header_file.write(render_interface_header_file(schema, cmdline, input_file))
interface_header_file.close()
header_file = open(header_file_name, "w")
header_file.write(render_header_file(schema, cmdline, input_file, interface_header_file_name))
header_file.close()
impl_file= open(impl_file_name, "w")
impl_file.write(render_impl_file(schema, cmdline, input_file, header_file_name))
impl_file.close()
if __name__ == "__main__":
main()