From ade29454c975d79d9dff3e825e11695b553c234a Mon Sep 17 00:00:00 2001 From: khamidou Date: Wed, 10 Jun 2009 23:08:58 +0200 Subject: [PATCH] rewriting the painting code --- py2c.py | 29 +++++++++++++++++++++++++++++ util.h | 6 ++++++ 2 files changed, 35 insertions(+) create mode 100755 py2c.py create mode 100644 util.h diff --git a/py2c.py b/py2c.py new file mode 100755 index 0000000..a813612 --- /dev/null +++ b/py2c.py @@ -0,0 +1,29 @@ +#! /usr/bin/env python +# +# py2c takes as parameters a list of python files and creates one big C file +# that contains strings that are fed to the python interpreter. + +import sys + +try: + ofile = open("py2cout.c", "w+") +except IOError: + print "Unable to open py2cout.c" + sys.exit(-1) + +skel = +"/* This code has been generated by py2c.py +#include " + +ofile.write(skel) + +for i in sys.argv[1:]: + try: + f = open(i, "r") + except IOError: + print "Unable to open " + i + sys.exit(-1) + + c = f.read() + + diff --git a/util.h b/util.h new file mode 100644 index 0000000..0142824 --- /dev/null +++ b/util.h @@ -0,0 +1,6 @@ +#ifndef __TE_UTIL_H__ +#define __TE_UTIL_H__ + +#define decrement_or_nullify(x) (x > 0) ? x-- : x = 0; + +#endif -- 2.43.0