[pypy-svn] r28984 - in pypy/dist/pypy: doc rpython/rctypes rpython/rctypes/test

ac at codespeak.net ac at codespeak.net
Tue Jun 20 12:22:53 CEST 2006


Author: ac
Date: Tue Jun 20 12:22:52 2006
New Revision: 28984

Modified:
   pypy/dist/pypy/doc/rctypes.txt
   pypy/dist/pypy/rpython/rctypes/aprimitive.py
   pypy/dist/pypy/rpython/rctypes/test/test_rpointer.py
   pypy/dist/pypy/rpython/rctypes/test/test_rprimitive.py
Log:
Remove the use of c_float and c_wchar as they are not propery supported yet.

Modified: pypy/dist/pypy/doc/rctypes.txt
==============================================================================
--- pypy/dist/pypy/doc/rctypes.txt	(original)
+++ pypy/dist/pypy/doc/rctypes.txt	Tue Jun 20 12:22:52 2006
@@ -49,8 +49,9 @@
 anyway.
 
 Apart from this, you can use many ctypes constructs freely: all
-primitive types, pointers, structures, arrays, external functions.  The
-following ctypes functions are supported at run-time:
+primitive types except c_float and c_wchar and c_wchar_p (they will be
+added at a later time), pointers, structures, arrays, external functions.
+  The following ctypes functions are supported at run-time:
 create_string_buffer(), pointer(), POINTER(), sizeof(), cast().  (Adding
 support for more is easy.)  Free union are *not* supported.  There is
 some support for callbacks and a few more obscure ctypes features, but

Modified: pypy/dist/pypy/rpython/rctypes/aprimitive.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/aprimitive.py	(original)
+++ pypy/dist/pypy/rpython/rctypes/aprimitive.py	Tue Jun 20 12:22:52 2006
@@ -8,7 +8,7 @@
 
 ctypes_annotation_list = {
     c_char:          lltype.Char,
-    c_wchar:         lltype.UniChar,
+    #c_wchar:         lltype.UniChar,
     c_byte:          rcarith.CByte,
     c_ubyte:         rcarith.CUByte,
     c_short:         rcarith.CShort,
@@ -19,7 +19,7 @@
     c_ulong:         rcarith.CULong,
     c_longlong:      rcarith.CLonglong,
     c_ulonglong:     rcarith.CULonglong,
-    c_float:         lltype.Float,
+    #c_float:         lltype.Float,
     c_double:        lltype.Float,
 }   # nb. platform-dependent duplicate ctypes are removed
 

Modified: pypy/dist/pypy/rpython/rctypes/test/test_rpointer.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/test/test_rpointer.py	(original)
+++ pypy/dist/pypy/rpython/rctypes/test/test_rpointer.py	Tue Jun 20 12:22:52 2006
@@ -10,7 +10,7 @@
 from pypy.translator.c.test.test_genc import compile
 from pypy.annotation.model import SomeCTypesObject
 
-from ctypes import c_int, c_float, POINTER, pointer, Structure
+from ctypes import c_int, c_double, POINTER, pointer, Structure
 
 class Test_annotation:
     def test_simple(self):
@@ -34,10 +34,10 @@
 
         assert s.knowntype == int
 
-    def test_annotate_c_float_ptr(self):
-        ptrtype = POINTER(c_float)
+    def test_annotate_c_double(self):
+        ptrtype = POINTER(c_double)
         def func():
-            res = c_float(4.2)
+            res = c_double(4.2)
             ptrres  = ptrtype(res)
             return ptrres.contents.value
         
@@ -118,14 +118,14 @@
 
     def test_annotate_POINTER(self):
         def fn():
-            p = POINTER(c_float)()
-            p.contents = c_float(6.1)
+            p = POINTER(c_double)()
+            p.contents = c_double(6.1)
             return p
 
         t = TranslationContext()
         a = t.buildannotator()
         s = a.build_types(fn, [])
-        assert s.knowntype == POINTER(c_float)
+        assert s.knowntype == POINTER(c_double)
 
         if conftest.option.view:
             t.view()
@@ -261,8 +261,8 @@
 
     def test_specialize_POINTER(self):
         def fn():
-            p = POINTER(c_float)()
-            p.contents = c_float(6.25)
+            p = POINTER(c_double)()
+            p.contents = c_double(6.25)
             return p
 
         res = interpret(fn, [])

Modified: pypy/dist/pypy/rpython/rctypes/test/test_rprimitive.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/test/test_rprimitive.py	(original)
+++ pypy/dist/pypy/rpython/rctypes/test/test_rprimitive.py	Tue Jun 20 12:22:52 2006
@@ -69,9 +69,9 @@
         if conftest.option.view:
             t.view()
     
-    def test_annotate_c_float(self):
+    def test_annotate_c_double(self):
         def func():
-            res = c_float(4.2)
+            res = c_double(4.2)
 
             return res.value
 
@@ -84,8 +84,8 @@
         if conftest.option.view:
             t.view()
 
-    def test_annotate_prebuilt_c_float(self):
-        res = c_float(4.2)
+    def test_annotate_prebuilt_c_double(self):
+        res = c_double(4.2)
 
         def func():
             return res.value
@@ -99,9 +99,9 @@
         if conftest.option.view:
             t.view()
 
-    def test_annotate_set_c_float_value(self):
+    def test_annotate_set_c_double_value(self):
         def func():
-            res = c_float(4.2)
+            res = c_double(4.2)
             res.value = 5.2
 
             return res.value
@@ -268,41 +268,41 @@
         res = interpret(access_cint, [])
         assert res == 42
 
-    def test_specialize_c_float(self):
-        def create_c_float():
-            return c_float(4.2)
-        res = interpret(create_c_float, [])
+    def test_specialize_c_double(self):
+        def create_c_double():
+            return c_double(4.2)
+        res = interpret(create_c_double, [])
         c_data = res.c_data
         assert c_data[0] == 4.2
 
-    def test_specialize_c_float_default_value(self):
-        def create_c_float():
-            return c_float()
-        res = interpret(create_c_float, [])
+    def test_specialize_c_double_default_value(self):
+        def create_c_double():
+            return c_double()
+        res = interpret(create_c_double, [])
         c_data = res.c_data
         assert c_data[0] == 0.0
 
-    def test_specialize_c_float_access_value(self):
-        def create_c_float():
-            return c_float(4.2).value
-        res = interpret(create_c_float, [])
+    def test_specialize_c_double_access_value(self):
+        def create_c_double():
+            return c_double(4.2).value
+        res = interpret(create_c_double, [])
         assert res == 4.2
 
-    def test_specialize_c_float_set_value(self):
-        def set_c_float_value():
-            cf = c_float(4.2)
+    def test_specialize_c_double_set_value(self):
+        def set_c_double_value():
+            cf = c_double(4.2)
             cf.value = 5.2
             return cf.value
 
-        res = interpret(set_c_float_value, [])
+        res = interpret(set_c_double_value, [])
         assert res == 5.2
 
-    def test_specialize_access_prebuilt_c_float_value(self):
-        cf = c_float(4.3)
-        def access_c_float():
+    def test_specialize_access_prebuilt_c_double_value(self):
+        cf = c_double(4.3)
+        def access_c_double():
             return cf.value
 
-        res = interpret(access_c_float, [])
+        res = interpret(access_c_double, [])
         
         # XXX: goden: Not sure if this is an indication of some sort of
         #             problem, but the precision appears to be broken when
@@ -325,19 +325,19 @@
             x = c_ulonglong(5)
             x.value += 1
             assert x.value == r_ulonglong(6)
-            x = c_float(2.5)
-            x.value += 0.25
-            assert x.value == 2.75
-            x.value -= 1
-            assert x.value == 1.75
+            # x = c_float(2.5)
+            # x.value += 0.25
+            # assert x.value == 2.75
+            # x.value -= 1
+            # assert x.value == 1.75
             x = c_double(2.5)
             x.value += 0.25
             assert x.value == 2.75
             x.value -= 1
             assert x.value == 1.75
-            x = c_wchar(u'A')
-            x.value = unichr(ord(x.value) + 1)
-            assert x.value == u'B'
+            # x = c_wchar(u'A')
+            # x.value = unichr(ord(x.value) + 1)
+            # assert x.value == u'B'
         interpret(func, [])
 
     def test_convert_from_llvalue(self):
@@ -354,19 +354,19 @@
             x = c_ulonglong(5)
             pointer(x)[0] += 1
             assert x.value == r_ulonglong(6)
-            x = c_float(2.5)
-            pointer(x)[0] += 0.25
-            assert x.value == 2.75
-            pointer(x)[0] -= 1
-            assert x.value == 1.75
+            # x = c_float(2.5)
+            # pointer(x)[0] += 0.25
+            # assert x.value == 2.75
+            # pointer(x)[0] -= 1
+            # assert x.value == 1.75
             x = c_double(2.5)
             pointer(x)[0] += 0.25
             assert x.value == 2.75
             pointer(x)[0] -= 1
             assert x.value == 1.75
-            x = c_wchar(u'A')
-            pointer(x)[0] = unichr(ord(pointer(x)[0]) + 1)
-            assert x.value == u'B'
+            # x = c_wchar(u'A')
+            # pointer(x)[0] = unichr(ord(pointer(x)[0]) + 1)
+            # assert x.value == u'B'
         interpret(func, [])
 
     def test_truth_value(self):
@@ -378,7 +378,7 @@
             assert c_int(-1)
             assert not c_byte(z)
             assert not c_char(chr(z))
-            assert not c_float(z)
+            # assert not c_float(z)
             assert not c_double(z)
             assert not c_ulonglong(bigzero)
             assert c_ulonglong(big)
@@ -489,18 +489,18 @@
         fn = compile(access_cint, [])
         assert fn() == 52
     
-    def test_compile_c_float(self):
-        def create_c_float():
-            return c_float(4.2).value
-        fn = compile(create_c_float, [])
+    def test_compile_c_double(self):
+        def create_c_double():
+            return c_double(4.2).value
+        fn = compile(create_c_double, [])
         assert fn() == 4.2
 
-    def test_compile_prebuilt_c_float(self):
-        cf = c_float(4.2)
-        def access_c_float():
+    def test_compile_prebuilt_c_double(self):
+        cf = c_double(4.2)
+        def access_c_double():
             return cf.value
 
-        fn = compile(access_c_float, [])
+        fn = compile(access_c_double, [])
         # XXX: goden: Not sure if this is an indication of some sort of
         #             problem, but the precision appears to be broken when
         #             returning a float from the interpreted function when its
@@ -508,13 +508,13 @@
         #             the precision to compare.
         assert ("%.2f" % (fn(),)) == ("%.2f" % (4.2,))
 
-    def test_compile_set_prebuilt_c_float_value(self):
-        cf = c_float(4.2)
-        def access_c_float():
+    def test_compile_set_prebuilt_c_double_value(self):
+        cf = c_double(4.2)
+        def access_c_double():
             cf.value = 5.2
             return cf.value
 
-        fn = compile(access_c_float, [])
+        fn = compile(access_c_double, [])
         assert fn() == 5.2
 
     def test_compile_c_integers(self):



More information about the Pypy-commit mailing list