[pypy-svn] r47623 - in pypy/dist/pypy/rpython/lltypesystem: . test
fijal at codespeak.net
fijal at codespeak.net
Sat Oct 20 12:05:46 CEST 2007
Author: fijal
Date: Sat Oct 20 12:05:45 2007
New Revision: 47623
Modified:
pypy/dist/pypy/rpython/lltypesystem/ll2ctypes.py
pypy/dist/pypy/rpython/lltypesystem/rffi.py
pypy/dist/pypy/rpython/lltypesystem/test/test_ll2ctypes.py
pypy/dist/pypy/rpython/lltypesystem/test/test_rffi.py
Log:
Adapt rffi to new interface of rffi_platform.
Modified: pypy/dist/pypy/rpython/lltypesystem/ll2ctypes.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/ll2ctypes.py (original)
+++ pypy/dist/pypy/rpython/lltypesystem/ll2ctypes.py Sat Oct 20 12:05:45 2007
@@ -172,7 +172,7 @@
elif isinstance(T, lltype.OpaqueType):
if T.hints.get('external', None) != 'C':
raise TypeError("%s is not external" % T)
- return ctypes.c_char * T.hints['getsize']()
+ return ctypes.c_char * T.hints['size']
else:
_setup_ctypes_cache()
if T in _ctypes_cache:
@@ -410,7 +410,7 @@
elif isinstance(T.TO, lltype.Array):
convert_array(container)
elif isinstance(T.TO, lltype.OpaqueType):
- cbuf = ctypes.create_string_buffer(T.TO.hints['getsize']())
+ cbuf = ctypes.create_string_buffer(T.TO.hints['size'])
add_storage(container, _parentable_mixin, cbuf)
else:
raise NotImplementedError(T)
Modified: pypy/dist/pypy/rpython/lltypesystem/rffi.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/rffi.py (original)
+++ pypy/dist/pypy/rpython/lltypesystem/rffi.py Sat Oct 20 12:05:45 2007
@@ -222,20 +222,14 @@
return lltype.Ptr(CArray(tp))
CArray._annspecialcase_ = 'specialize:memo'
-def COpaque(name, hints=None, **kwds):
+def COpaque(name, size, hints=None, **kwds):
if hints is None:
hints = {}
else:
hints = hints.copy()
hints['external'] = 'C'
hints['c_name'] = name
- def lazy_getsize(result=[]):
- if not result:
- from pypy.rpython.tool import rffi_platform
- size = rffi_platform.sizeof(name, "", **kwds)
- result.append(size)
- return result[0]
- hints['getsize'] = lazy_getsize
+ hints['size'] = size
return lltype.OpaqueType(name, hints)
def COpaquePtr(*args, **kwds):
Modified: pypy/dist/pypy/rpython/lltypesystem/test/test_ll2ctypes.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/test/test_ll2ctypes.py (original)
+++ pypy/dist/pypy/rpython/lltypesystem/test/test_ll2ctypes.py Sat Oct 20 12:05:45 2007
@@ -2,6 +2,7 @@
import sys, struct
import ctypes
from pypy.rpython.lltypesystem import lltype, rffi, llmemory
+from pypy.rpython.tool import rffi_platform
from pypy.rpython.lltypesystem.ll2ctypes import lltype2ctypes, ctypes2lltype
from pypy.rpython.lltypesystem.ll2ctypes import standard_c_lib
from pypy.rpython.lltypesystem.ll2ctypes import uninitialized2ctypes
@@ -274,8 +275,8 @@
def test_opaque_obj(self):
includes = ['sys/time.h', 'time.h']
- TIMEVALP = rffi.COpaquePtr('struct timeval', includes=includes)
- TIMEZONEP = rffi.COpaquePtr('struct timezone', includes=includes)
+ TIMEVALP = rffi_platform.copaque('struct timeval', '', _includes_=includes)
+ TIMEZONEP = rffi_platform.copaque('struct timezone', '', _includes_=includes)
gettimeofday = rffi.llexternal('gettimeofday', [TIMEVALP, TIMEZONEP],
rffi.INT, includes=includes)
ll_timevalp = lltype.malloc(TIMEVALP.TO, flavor='raw')
Modified: pypy/dist/pypy/rpython/lltypesystem/test/test_rffi.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/test/test_rffi.py (original)
+++ pypy/dist/pypy/rpython/lltypesystem/test/test_rffi.py Sat Oct 20 12:05:45 2007
@@ -223,8 +223,9 @@
h_file = udir.join("opaque.h")
h_file.write(h_source)
- STUFFP = COpaquePtr('struct stuff', includes=['opaque.h'],
- include_dirs=[str(udir)])
+ from pypy.rpython.tool import rffi_platform
+ STUFFP = rffi_platform.copaque('struct stuff', '', _includes_=['opaque.h'],
+ _include_dirs_=[str(udir)])
ll_get = llexternal('get', [STUFFP], lltype.Char, includes=['opaque.h'],
include_dirs=[str(udir)])
More information about the Pypy-commit
mailing list