summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorThomas Heller <theller@ctypes.org>2007-01-11 21:18:56 (GMT)
committerThomas Heller <theller@ctypes.org>2007-01-11 21:18:56 (GMT)
commit8138c26a8306a423ab0ae2c45976a37a2c000de6 (patch)
treef1bca12ced26b54897e90c9f1d1959bee94d4f9f /Lib
parent9fdfadb06ee3c6d182af084afaa97bc6bf4652bc (diff)
downloadcpython-8138c26a8306a423ab0ae2c45976a37a2c000de6.zip
cpython-8138c26a8306a423ab0ae2c45976a37a2c000de6.tar.gz
cpython-8138c26a8306a423ab0ae2c45976a37a2c000de6.tar.bz2
Fixes for 64-bit Windows: In ctypes.wintypes, correct the definitions
of HANDLE, WPARAM, LPARAM data types. Make parameterless foreign function calls work.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/ctypes/test/test_win32.py23
-rw-r--r--Lib/ctypes/wintypes.py12
2 files changed, 30 insertions, 5 deletions
diff --git a/Lib/ctypes/test/test_win32.py b/Lib/ctypes/test/test_win32.py
index 10deaca..d6f018b 100644
--- a/Lib/ctypes/test/test_win32.py
+++ b/Lib/ctypes/test/test_win32.py
@@ -3,6 +3,7 @@
from ctypes import *
from ctypes.test import is_resource_enabled
import unittest, sys
+from ctypes import wintypes
import _ctypes_test
@@ -32,12 +33,30 @@ if sys.platform == "win32" and sizeof(c_void_p) == sizeof(c_int):
# or wrong calling convention
self.assertRaises(ValueError, IsWindow, None)
+if sys.platform == "win32":
+ class FunctionCallTestCase(unittest.TestCase):
+
if is_resource_enabled("SEH"):
def test_SEH(self):
- # Call functions with invalid arguments, and make sure that access violations
- # are trapped and raise an exception.
+ # Call functions with invalid arguments, and make sure
+ # that access violations are trapped and raise an
+ # exception.
self.assertRaises(WindowsError, windll.kernel32.GetModuleHandleA, 32)
+ def test_noargs(self):
+ # This is a special case on win32 x64
+ windll.user32.GetDesktopWindow()
+
+ class TestWintypes(unittest.TestCase):
+ def test_HWND(self):
+ self.failUnlessEqual(sizeof(wintypes.HWND), sizeof(c_void_p))
+
+ def test_PARAM(self):
+ self.failUnlessEqual(sizeof(wintypes.WPARAM),
+ sizeof(c_void_p))
+ self.failUnlessEqual(sizeof(wintypes.LPARAM),
+ sizeof(c_void_p))
+
class Structures(unittest.TestCase):
def test_struct_by_value(self):
diff --git a/Lib/ctypes/wintypes.py b/Lib/ctypes/wintypes.py
index 9768233..d2c1e38 100644
--- a/Lib/ctypes/wintypes.py
+++ b/Lib/ctypes/wintypes.py
@@ -34,8 +34,14 @@ LPCOLESTR = LPOLESTR = OLESTR = c_wchar_p
LPCWSTR = LPWSTR = c_wchar_p
LPCSTR = LPSTR = c_char_p
-WPARAM = c_uint
-LPARAM = c_long
+# WPARAM is defined as UINT_PTR (which is signed)
+# LPARAM is defined as LONG_PTR (which is unsigned)
+if sizeof(c_long) == sizeof(c_void_p):
+ WPARAM = c_ulong
+ LPARAM = c_long
+elif sizeof(c_longlong) == sizeof(c_void_p):
+ WPARAM = c_ulonglong
+ LPARAM = c_longlong
ATOM = WORD
LANGID = WORD
@@ -48,7 +54,7 @@ LCID = DWORD
################################################################
# HANDLE types
-HANDLE = c_ulong # in the header files: void *
+HANDLE = c_void_p # in the header files: void *
HACCEL = HANDLE
HBITMAP = HANDLE