summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Heller <theller@ctypes.org>2006-06-13 08:56:14 (GMT)
committerThomas Heller <theller@ctypes.org>2006-06-13 08:56:14 (GMT)
commita7e823fd2c0d40c1d792cf5a1e5ad103de30f5bd (patch)
tree1261a7a2c73c87b02379d954fbbfa9f7cd019cac
parent6d3d339d21aa303f3cb4df13d466a9db36656f49 (diff)
downloadcpython-a7e823fd2c0d40c1d792cf5a1e5ad103de30f5bd.zip
cpython-a7e823fd2c0d40c1d792cf5a1e5ad103de30f5bd.tar.gz
cpython-a7e823fd2c0d40c1d792cf5a1e5ad103de30f5bd.tar.bz2
Add some windows datatypes that were missing from this file, and add
the aliases defined in windows header files for the structures.
-rw-r--r--Lib/ctypes/wintypes.py94
1 files changed, 70 insertions, 24 deletions
diff --git a/Lib/ctypes/wintypes.py b/Lib/ctypes/wintypes.py
index 870d917..693d16d 100644
--- a/Lib/ctypes/wintypes.py
+++ b/Lib/ctypes/wintypes.py
@@ -1,63 +1,107 @@
######################################################################
# This file should be kept compatible with Python 2.3, see PEP 291. #
######################################################################
-# XXX This module needs cleanup.
+# The most useful windows datatypes
from ctypes import *
-DWORD = c_ulong
-WORD = c_ushort
BYTE = c_byte
+WORD = c_ushort
+DWORD = c_ulong
+
+BOOLEAN = BYTE
+BOOL = c_long
+VARIANT_BOOL = c_short
ULONG = c_ulong
LONG = c_long
+# in the windows header files, these are structures.
LARGE_INTEGER = c_longlong
ULARGE_INTEGER = c_ulonglong
+LPCOLESTR = LPOLESTR = OLESTR = c_wchar_p
+LPCWSTR = LPWSTR = c_wchar_p
+LPCSTR = LPSTR = c_char_p
+
+WPARAM = c_uint
+LPARAM = c_long
+
+ATOM = WORD
+LANGID = WORD
+
+COLORREF = DWORD
+LGRPID = DWORD
+LCTYPE = DWORD
+
+LCID = DWORD
+################################################################
+# HANDLE types
HANDLE = c_ulong # in the header files: void *
-HWND = HANDLE
+HACCEL = HANDLE
+HBITMAP = HANDLE
+HBRUSH = HANDLE
+HCOLORSPACE = HANDLE
HDC = HANDLE
-HMODULE = HANDLE
+HDESK = HANDLE
+HDWP = HANDLE
+HENHMETAFILE = HANDLE
+HFONT = HANDLE
+HGDIOBJ = HANDLE
+HGLOBAL = HANDLE
+HHOOK = HANDLE
+HICON = HANDLE
HINSTANCE = HANDLE
-HRGN = HANDLE
-HTASK = HANDLE
HKEY = HANDLE
-HPEN = HANDLE
-HGDIOBJ = HANDLE
+HKL = HANDLE
+HLOCAL = HANDLE
HMENU = HANDLE
+HMETAFILE = HANDLE
+HMODULE = HANDLE
+HMONITOR = HANDLE
+HPALETTE = HANDLE
+HPEN = HANDLE
+HRGN = HANDLE
+HRSRC = HANDLE
+HSTR = HANDLE
+HTASK = HANDLE
+HWINSTA = HANDLE
+HWND = HANDLE
+SC_HANDLE = HANDLE
+SERVICE_STATUS_HANDLE = HANDLE
-LCID = DWORD
-
-WPARAM = c_uint
-LPARAM = c_long
-
-BOOL = c_long
-VARIANT_BOOL = c_short
-
-LPCOLESTR = LPOLESTR = OLESTR = c_wchar_p
-LPCWSTR = LPWSTR = c_wchar_p
-
-LPCSTR = LPSTR = c_char_p
+################################################################
+# Some important structure definitions
class RECT(Structure):
_fields_ = [("left", c_long),
("top", c_long),
("right", c_long),
("bottom", c_long)]
-RECTL = RECT
+tagRECT = _RECTL = RECTL = RECT
+
+class _SMALL_RECT(Structure):
+ _fields_ = [('Left', c_short),
+ ('Top', c_short),
+ ('Right', c_short),
+ ('Bottom', c_short)]
+SMALL_RECT = _SMALL_RECT
+
+class _COORD(Structure):
+ _fields_ = [('X', c_short),
+ ('Y', c_short)]
class POINT(Structure):
_fields_ = [("x", c_long),
("y", c_long)]
-POINTL = POINT
+tagPOINT = _POINTL = POINTL = POINT
class SIZE(Structure):
_fields_ = [("cx", c_long),
("cy", c_long)]
-SIZEL = SIZE
+tagSIZE = SIZEL = SIZE
def RGB(red, green, blue):
return red + (green << 8) + (blue << 16)
@@ -65,6 +109,7 @@ def RGB(red, green, blue):
class FILETIME(Structure):
_fields_ = [("dwLowDateTime", DWORD),
("dwHighDateTime", DWORD)]
+_FILETIME = FILETIME
class MSG(Structure):
_fields_ = [("hWnd", HWND),
@@ -73,6 +118,7 @@ class MSG(Structure):
("lParam", LPARAM),
("time", DWORD),
("pt", POINT)]
+tagMSG = MSG
MAX_PATH = 260
class WIN32_FIND_DATAA(Structure):