From 88e5bb15f2688c99549f4b7077383f0497f0c767 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Mon, 29 Apr 2024 22:44:02 +0300 Subject: [PATCH] d --- v3/cpp.includes | 5 +++++ v3/memory.cpp | 1 + v3/memory_test.cpp | 1 + v3/tPythonC++/translate | 16 ++++++++++++---- v3/translate-py-cxx | 4 ++-- 5 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 v3/cpp.includes diff --git a/v3/cpp.includes b/v3/cpp.includes new file mode 100644 index 0000000..f055234 --- /dev/null +++ b/v3/cpp.includes @@ -0,0 +1,5 @@ +#include +#include +#include +#include "memory.h" +#include "memory_Context.h" diff --git a/v3/memory.cpp b/v3/memory.cpp index 0b3cb62..0ad95fd 100644 --- a/v3/memory.cpp +++ b/v3/memory.cpp @@ -1,3 +1,4 @@ +OPT_HEADER/OPT_INCLUDES: 'None'/'None' #include #include #include diff --git a/v3/memory_test.cpp b/v3/memory_test.cpp index 390675a..09f0b18 100644 --- a/v3/memory_test.cpp +++ b/v3/memory_test.cpp @@ -1,3 +1,4 @@ +OPT_HEADER/OPT_INCLUDES: 'None'/'None' #include #include #include diff --git a/v3/tPythonC++/translate b/v3/tPythonC++/translate index 525e884..d202e44 100755 --- a/v3/tPythonC++/translate +++ b/v3/tPythonC++/translate @@ -5,13 +5,21 @@ from process import * DIR = os.path.dirname(os.path.realpath(sys.argv[0])) -# Demand file as input if len(sys.argv) < 2: - print("Usage: /path/to/translate PYTHON_FILE") + print("Usage: /path/to/translate [OPTIONS] PYTHON_FILE") sys.exit(1) -FILE_IN = sys.argv[1] +FILE_IN = sys.argv[-1] + +# Parse options +# TODO Use options +OPT_HEADER = "--header" in sys.argv +OPT_INCLUDES = None +OPT_PREFIX_INCLUDES = "--includes=" +for arg in sys.argv: + if arg.startswith(OPT_PREFIX_INCLUDES): + OPT_INCLUDES = arg[len(OPT_PREFIX_INCLUDES):] # Translate file. -out = process(FILE_IN) +out = process(FILE_IN, OPT_HEADER, OPT_INCLUDES) print(out) diff --git a/v3/translate-py-cxx b/v3/translate-py-cxx index 01901fc..ec2f219 100755 --- a/v3/translate-py-cxx +++ b/v3/translate-py-cxx @@ -3,5 +3,5 @@ DIR=$(cd "$(dirname "$0")" ; pwd -P) TR=$DIR/tPythonC++/translate -$TR $DIR/memory.py > $DIR/memory.cpp -$TR $DIR/memory_test.py > $DIR/memory_test.cpp +$TR --header $DIR/memory.py #> $DIR/memory.cpp +$TR --includes=/path/to/file $DIR/memory_test.py #> $DIR/memory_test.cpp