Author: Matti Picus <[email protected]>
Branch: win_ffi
Changeset: r55252:ba7be50b404e
Date: 2012-05-31 22:31 +0300
http://bitbucket.org/pypy/pypy/changeset/ba7be50b404e/
Log: add test for __stdcall, add fix for non-jit
diff --git a/pypy/rlib/libffi.py b/pypy/rlib/libffi.py
--- a/pypy/rlib/libffi.py
+++ b/pypy/rlib/libffi.py
@@ -1,11 +1,11 @@
from __future__ import with_statement
from pypy.rpython.lltypesystem import rffi, lltype
-from pypy.rlib.objectmodel import specialize, enforceargs, we_are_translated
+from pypy.rlib.objectmodel import specialize, enforceargs
from pypy.rlib.rarithmetic import intmask, r_uint, r_singlefloat, r_longlong
from pypy.rlib import jit
from pypy.rlib import clibffi
-from pypy.rlib.clibffi import get_libc_name, FUNCFLAG_CDECL, AbstractFuncPtr, \
+from pypy.rlib.clibffi import FUNCFLAG_CDECL, AbstractFuncPtr, \
push_arg_as_ffiptr, c_ffi_call, FFI_TYPE_STRUCT
from pypy.rlib.rdynload import dlopen, dlclose, dlsym, dlsym_byordinal
from pypy.rlib.rdynload import DLLHANDLE
@@ -374,7 +374,7 @@
else:
res = None
self._free_buffers(ll_result, ll_args)
- #check_fficall_result(ffires, self.flags)
+ clibffi.check_fficall_result(ffires, self.flags)
return res
def _free_buffers(self, ll_result, ll_args):
diff --git a/pypy/rlib/test/test_libffi.py b/pypy/rlib/test/test_libffi.py
--- a/pypy/rlib/test/test_libffi.py
+++ b/pypy/rlib/test/test_libffi.py
@@ -1,12 +1,12 @@
-import sys
+import os
import py
from pypy.rlib.rarithmetic import r_singlefloat, r_longlong, r_ulonglong
-from pypy.rlib.test.test_clibffi import BaseFfiTest, get_libm_name,
make_struct_ffitype_e
+from pypy.rlib.test.test_clibffi import BaseFfiTest, make_struct_ffitype_e
from pypy.rpython.lltypesystem import rffi, lltype
from pypy.rpython.lltypesystem.ll2ctypes import ALLOCATED
-from pypy.rlib.libffi import (CDLL, Func, get_libc_name, ArgChain, types,
+from pypy.rlib.libffi import (CDLL, ArgChain, types,
IS_32_BIT, array_getitem, array_setitem)
from pypy.rlib.libffi import (struct_getfield_int, struct_setfield_int,
struct_getfield_longlong,
struct_setfield_longlong,
@@ -261,7 +261,6 @@
func = (libfoo, 'diff_xy', [types.sint, types.signed], types.sint)
res = self.call(func, [50, 8], lltype.Signed)
assert res == 42
-
def test_simple(self):
"""
int sum_xy(int x, double y)
@@ -536,4 +535,24 @@
assert p[1] == 34
lltype.free(p, flavor='raw')
lltype.free(ffi_point_struct, flavor='raw')
+
+ if os.name == 'nt':
+ def test_stdcall_simple(self):
+ """
+ int __stdcall std_diff_xy(int x, Signed y)
+ {
+ return x - y;
+ }
+ """
+ libfoo = self.get_libfoo()
+ func = (libfoo, 'std_diff_xy', [types.sint, types.signed],
types.sint)
+ try:
+ self.call(func, [50, 8], lltype.Signed)
+ except ValueError, e:
+ assert e.message == 'Procedure called with not enough ' + \
+ 'arguments (8 bytes missing) or wrong calling convention'
+ else:
+ assert 0, 'wrong calling convention should have raised'
+
+
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit