]> khamidou — GitHub mirrors - te.git/commitdiff
rewriting the painting code
authorkhamidou <karim@lambda-expr.org>
Wed, 10 Jun 2009 21:08:58 +0000 (23:08 +0200)
committerkhamidou <karim@lambda-expr.org>
Wed, 10 Jun 2009 21:08:58 +0000 (23:08 +0200)
py2c.py [new file with mode: 0755]
util.h [new file with mode: 0644]

diff --git a/py2c.py b/py2c.py
new file mode 100755 (executable)
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 <Python.h>"
+
+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 (file)
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