r4694 - trunk/src/host/pye17/codegen

marek at docs.openmoko.org marek at docs.openmoko.org
Mon Oct 6 13:04:19 CEST 2008


Author: marek
Date: 2008-10-06 13:04:19 +0200 (Mon, 06 Oct 2008)
New Revision: 4694

Modified:
   trunk/src/host/pye17/codegen/argtypes.py
   trunk/src/host/pye17/codegen/codegen.py
Log:
[pye17] fix casts to pythonize the bindings

Modified: trunk/src/host/pye17/codegen/argtypes.py
===================================================================
--- trunk/src/host/pye17/codegen/argtypes.py	2008-10-06 08:25:56 UTC (rev 4693)
+++ trunk/src/host/pye17/codegen/argtypes.py	2008-10-06 11:04:19 UTC (rev 4694)
@@ -493,19 +493,19 @@
     nulldflt = ('    if ((PyObject *)py_%(name)s == Py_None)\n'
                 '        %(name)s = NULL;\n'
                 '    else if (py_%(name)s && pygobject_check(py_%(name)s, &Py%(type)s_Type))\n'
-                '        %(name)s = %(cast)s(py_%(name)s->obj);\n'
+                '        %(name)s = (%(cast)s *)(py_%(name)s->obj);\n'
                 '    else if (py_%(name)s) {\n'
                 '        PyErr_SetString(PyExc_TypeError, "%(name)s should be a %(type)s or None");\n'
                 '        return NULL;\n'
                 '    }\n')
     null = ('    if (py_%(name)s && pygobject_check(py_%(name)s, &Py%(type)s_Type))\n'
-            '        %(name)s = %(cast)s(py_%(name)s->obj);\n'
+            '        %(name)s = (%(cast)s *)(py_%(name)s->obj);\n'
             '    else if ((PyObject *)py_%(name)s != Py_None) {\n'
             '        PyErr_SetString(PyExc_TypeError, "%(name)s should be a %(type)s or None");\n'
             '        return NULL;\n'
             '    }\n')
     dflt = '    if (py_%(name)s)\n' \
-           '        %(name)s = %(cast)s(py_%(name)s->obj);\n'
+           '        %(name)s = (%(cast)s *)(py_%(name)s->obj);\n'
     def __init__(self, objname, parent, typecode):
         self.objname = objname
         self.cast = string.replace(typecode, '_TYPE_', '_', 1)

Modified: trunk/src/host/pye17/codegen/codegen.py
===================================================================
--- trunk/src/host/pye17/codegen/codegen.py	2008-10-06 08:25:56 UTC (rev 4693)
+++ trunk/src/host/pye17/codegen/codegen.py	2008-10-06 11:04:19 UTC (rev 4694)
@@ -321,7 +321,7 @@
             raise argtypes.ArgTypeNotFoundError("varargs functions not supported")
 
 	#fd = open("/tmp/codegen.log","a+")
-	#fd.write(">>> write_function_wrapper() >>>\n")
+	#fd.write(">>> write_function_wrapper() " + function_obj.c_name + " >>>\n")
 	#fd.write("arglist 1: " + str(info.get_arglist()) + "\n")
 
         for param in function_obj.params:
@@ -363,7 +363,7 @@
 
         if self.objinfo:
             substdict['typename'] = self.objinfo.c_name
-        substdict.setdefault('cname',  function_obj.c_name)
+        substdict.setdefault('cname', function_obj.c_name)
         substdict['varlist'] = info.get_varlist()
         substdict['typecodes'] = info.parsestr
         substdict['parselist'] = info.get_parselist()
@@ -391,7 +391,7 @@
 
 	#fd.write("arglist: " + str(info.get_arglist()) + "\n")
 	#for key,item in substdict.iteritems():
-		#fd.write("key: " + str(key) + ", item: " + str(item) + "\n")
+	#	fd.write("key: " + str(key) + ", item: " + str(item) + "\n")
         #fd.close()
 
         return template % substdict, flags
@@ -952,7 +952,7 @@
         '%(parseargs)s'
         '%(codebefore)s'
         '    %(begin_allow_threads)s\n'
-        '    %(setreturn)s%(cname)s(%(cast)s(self->obj)%(arglist)s);\n'
+        '    %(setreturn)s%(cname)s((%(cast)s *)(self->obj)%(arglist)s);\n'
         '    %(end_allow_threads)s\n'
         '%(codeafter)s\n'
         '}\n\n'




More information about the commitlog mailing list