[pypy-svn] r47547 - in pypy/dist/pypy/module/_ffi: . test
fijal at codespeak.net
fijal at codespeak.net
Thu Oct 18 15:04:48 CEST 2007
Author: fijal
Date: Thu Oct 18 15:04:47 2007
New Revision: 47547
Modified:
pypy/dist/pypy/module/_ffi/__init__.py
pypy/dist/pypy/module/_ffi/interp_ffi.py
pypy/dist/pypy/module/_ffi/test/test__ffi.py
Log:
More rpythonism
Modified: pypy/dist/pypy/module/_ffi/__init__.py
==============================================================================
--- pypy/dist/pypy/module/_ffi/__init__.py (original)
+++ pypy/dist/pypy/module/_ffi/__init__.py Thu Oct 18 15:04:47 2007
@@ -14,7 +14,7 @@
'FuncPtr' : 'interp_ffi.W_FuncPtr',
'StructureInstance' : 'structure.W_StructureInstance',
'ArrayInstance' : 'array.W_ArrayInstance',
- '_get_type' : 'interp_ffi._get_type',
+ '_get_type' : 'interp_ffi._w_get_type',
}
appleveldefs = {
Modified: pypy/dist/pypy/module/_ffi/interp_ffi.py
==============================================================================
--- pypy/dist/pypy/module/_ffi/interp_ffi.py (original)
+++ pypy/dist/pypy/module/_ffi/interp_ffi.py Thu Oct 18 15:04:47 2007
@@ -59,8 +59,13 @@
return TYPEMAP[key]
except KeyError:
raise OperationError(space.w_ValueError, space.wrap(
- "Uknown type letter %s" % key))
-_get_type.unwrap_spec = [ObjSpace, str]
+ "Uknown type letter %s" % (key,)))
+ return lltype.nullptr(FFI_TYPE_P.TO)
+
+def _w_get_type(space, key):
+ _get_type(space, key)
+ return space.w_None
+_w_get_type.unwrap_spec = [ObjSpace, str]
class W_CDLL(Wrappable):
def __init__(self, space, name):
@@ -198,12 +203,20 @@
raise OperationError(space.w_TypeError, w(
"Expected structure, array or simple type"))
else:
+ # XXX not sure how this will look like at the end regarding
+ # val annotation
if tp == "c" or tp == "b" or tp == "B":
s = space.str_w(w_arg)
if len(s) != 1:
raise OperationError(space.w_ValueError, w(
"Expected string of length one as character"))
val = ord(s[0])
+ elif tp == 'I':
+ val = space.uint_w(w_arg)
+ elif tp == 'q':
+ val = space.r_longlong_w(w_arg)
+ elif tp == 'Q':
+ val = space.r_ulonglong_w(w_arg)
else:
val = space.int_w(w_arg)
for c, checker in unroll_size_checkers:
Modified: pypy/dist/pypy/module/_ffi/test/test__ffi.py
==============================================================================
--- pypy/dist/pypy/module/_ffi/test/test__ffi.py (original)
+++ pypy/dist/pypy/module/_ffi/test/test__ffi.py Thu Oct 18 15:04:47 2007
@@ -83,6 +83,11 @@
{
return 1LL<<42;
}
+
+ long long pass_ll(long long x)
+ {
+ return x;
+ }
'''))
compile_c_module([c_file], 'x')
return str(udir.join('x.so'))
@@ -281,3 +286,6 @@
assert some_huge_uvalue() == 1<<42
x = lib.ptr('some_huge_value', ['Q'], None)
raises(ValueError, "x(-1)")
+ pass_ll = lib.ptr('pass_ll', ['q'], 'q')
+ assert pass_ll(1<<42) == 1<<42
+
More information about the Pypy-commit
mailing list