[pypy-svn] r22600 - in pypy/dist/pypy: rpython/rctypes rpython/rctypes/test translator/c

stephan at codespeak.net stephan at codespeak.net
Tue Jan 24 16:32:11 CET 2006


Author: stephan
Date: Tue Jan 24 16:32:08 2006
New Revision: 22600

Modified:
   pypy/dist/pypy/rpython/rctypes/implementation.py
   pypy/dist/pypy/rpython/rctypes/test/test_rctypes.py
   pypy/dist/pypy/translator/c/external.py
Log:
intermediate checkin for rpython/rctypes

Modified: pypy/dist/pypy/rpython/rctypes/implementation.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/implementation.py	(original)
+++ pypy/dist/pypy/rpython/rctypes/implementation.py	Tue Jan 24 16:32:08 2006
@@ -24,8 +24,12 @@
             return id(self)
 
         def specialize(self, hop):
-            return hop.llops.gencapicall(self.__name__, hop.args_v[1:],
-                         resulttype=self.restype.ll_type, _callable=None) 
+            return hop.llops.gencapicall(self.__name__, hop.args_v,
+                         resulttype=self.restype.ll_type, _callable=None,
+                         convert_params=self.convert_params) 
+
+        def convert_params(self, backend, param_info_list):
+            raise NotImplementedError
 
 
 class RCDLL(CDLL):

Modified: pypy/dist/pypy/rpython/rctypes/test/test_rctypes.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/test/test_rctypes.py	(original)
+++ pypy/dist/pypy/rpython/rctypes/test/test_rctypes.py	Tue Jan 24 16:32:08 2006
@@ -1,4 +1,8 @@
 import py.test
+from pypy.annotation.annrpython import RPythonAnnotator
+from pypy.translator.translator import TranslationContext
+from pypy.translator.c.test.test_genc import compile
+    
 
 def setup_module(mod):
     try:
@@ -27,9 +31,6 @@
 
 class Test_rctypes:
 
-    from pypy.annotation.annrpython import RPythonAnnotator
-    from pypy.translator.translator import TranslationContext
-    
     def test_simple(self):
 
 
@@ -37,16 +38,22 @@
         assert res == 42 
 
     def test_annotate_simple(self):
-        a = self.RPythonAnnotator()
+        a = RPythonAnnotator()
         s = a.build_types(o_atoi, [str])
         # result should be an integer
         assert s.knowntype == int
 
     def test_specialize_simple(self):
-        t = self.TranslationContext()
+        t = TranslationContext()
         a = t.buildannotator()
         s = a.build_types(o_atoi, [str])
         # result should be an integer
         assert s.knowntype == int
         t.buildrtyper().specialize()
         #d#t.view()
+
+    def x_test_compile_simple(self):
+        fn = compile(o_atoi, [str])
+        res = fn("42")
+        assert res == 42
+

Modified: pypy/dist/pypy/translator/c/external.py
==============================================================================
--- pypy/dist/pypy/translator/c/external.py	(original)
+++ pypy/dist/pypy/translator/c/external.py	Tue Jan 24 16:32:08 2006
@@ -31,7 +31,11 @@
             yield '%s;' % cdecl(self.resulttypename, 'result')
 
     def cfunction_body(self):
-        call = '%s(%s)' % (self.fnptr._name, ', '.join(self.argnames()))
+        try:
+            convert_params = self.fnptr.convert_params
+        except AttributeError:
+            convert_params = lambda backend, args: [arg for _,arg in args]
+        call = '%s(%s)' % (self.fnptr._name, ', '.join(convert_params("c", zip(self.FUNCTYPE.ARGS, self.argnames()))))
         if self.FUNCTYPE.RESULT is not Void:
             yield 'result = %s;' % call
             yield 'if (PyErr_Occurred()) RPyConvertExceptionFromCPython();'



More information about the Pypy-commit mailing list