2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-31 05:55:28 +00:00

[1924] Comments and cleanups in the generator scripts

This commit is contained in:
Michal 'vorner' Vaner
2013-02-08 12:27:46 +01:00
parent 89c5952722
commit 57c90f7a92
2 changed files with 28 additions and 10 deletions

View File

@@ -13,15 +13,24 @@
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
'''
This script takes a C++ file with constants and converts it to a python
module. However, the syntax it parses is very limited (it doesn't understand
C++ at all, it just looks for lines containing the equal sign and strips
what it thinks might be type).
The purpose is to keep the same values of constants in C++ and python. This
saves the work of keeping the constants in sync manually and is less error
prone.
'''
import sys
import re
def die(message):
sys.stderr.write(message + "\n")
sys.exit(1)
if len(sys.argv) != 3:
die("Usage: python3 ./pythonize_constants.py input.cpp output.py")
sys.stderr.write("Usage: python3 ./pythonize_constants.py input.cpp output.py\n")
sys.exit(1)
die(
[filename_in, filename_out] = sys.argv[1:3]

View File

@@ -13,15 +13,24 @@
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
'''
The script takes a C++ file with constant definitions and creates a
header file for the constants. It, however, does not understand C++
syntax, it only does some heuristics to guess what looks like
a constant and strips the values.
The purpose is just to save some work with keeping both the source and
header. The source syntax must be limited already, because it's used to
generate the python module (by the
lib/python/isc/util/pythonize_constants.py script).
'''
import sys
import re
def die(message):
sys.stderr.write(message + "\n")
sys.exit(1)
if len(sys.argv) != 3:
die("Usage: python3 ./const2hdr.py input.cpp output.h")
sys.stderr.write("Usage: python3 ./const2hdr.py input.cc output.h\n")
sys.exit(1)
[filename_in, filename_out] = sys.argv[1:3]