Author: Armin Rigo <[email protected]>
Branch: win32-stdcall
Changeset: r2306:91c068cc1270
Date: 2015-10-05 20:10 +0200
http://bitbucket.org/cffi/cffi/changeset/91c068cc1270/
Log: non-windows fixes
diff --git a/cffi/cparser.py b/cffi/cparser.py
--- a/cffi/cparser.py
+++ b/cffi/cparser.py
@@ -167,7 +167,7 @@
if calling_conv is None or calling_conv == "cdecl":
abi = None
elif calling_conv == "stdcall":
- abi = "stdcall"
+ abi = "__stdcall"
else:
raise api.CDefError("calling_conv must be 'cdecl' or 'stdcall';"
" got %r" % (calling_conv,))
diff --git a/cffi/model.py b/cffi/model.py
--- a/cffi/model.py
+++ b/cffi/model.py
@@ -1,4 +1,4 @@
-import types
+import types, sys
import weakref
from .lock import allocate_lock
@@ -238,15 +238,17 @@
args.append(tp.get_cached_btype(ffi, finishlist))
if self.abi is None:
abi_args = ()
- elif self.abi == "stdcall":
+ elif self.abi == "__stdcall":
try:
abi_args = (ffi._backend.FFI_STDCALL,)
except AttributeError:
if sys.platform == "win32":
- raise NotImplementedError("%r: stdcall with ctypes
backend")
+ raise NotImplementedError("%r: stdcall with ctypes backend"
+ % (self,))
else:
from . import api
- raise api.CDefError("%r: '__stdcall' only for Windows")
+ raise api.CDefError("%r: '__stdcall' only for Windows"
+ % (self,))
import pdb;pdb.set_trace()
else:
raise NotImplementedError("abi=%r" % (self.abi,))
diff --git a/testing/cffi0/test_function.py b/testing/cffi0/test_function.py
--- a/testing/cffi0/test_function.py
+++ b/testing/cffi0/test_function.py
@@ -1,5 +1,5 @@
import py
-from cffi import FFI
+from cffi import FFI, CDefError
import math, os, sys
import ctypes.util
from cffi.backend_ctypes import CTypesBackend
@@ -471,8 +471,10 @@
if sys.platform == 'win32':
py.test.skip("not-Windows-only test")
ffi = FFI(backend=self.Backend())
- e = py.test.raises(CDefError, ffi.cdef, """
- BOOL QueryPerformanceFrequency(LONGLONG *lpFrequency);
+ ffi.cdef("""
+ int QueryPerformanceFrequency(long long *lpFrequency);
""", calling_conv="stdcall")
+ m = ffi.dlopen(None)
+ e = py.test.raises(CDefError, getattr, m, 'QueryPerformanceFrequency')
assert str(e.value) == (
- "<int(__stdcall *)(int)>: '__stdcall' only for Windows")
+ "<int(__stdcall *)(long long *)>: '__stdcall' only for Windows")
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit