Skip to content

Commit

Permalink
remove from ctypes import * (enthought#488)
Browse files Browse the repository at this point in the history
  • Loading branch information
junkmd authored Jun 16, 2023
1 parent 6532d32 commit 65e3c10
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions comtypes/typeinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# generated by 'xml2py'
# flags '..\tools\windows.xml -m comtypes -m comtypes.automation -w -r .*TypeLibEx -r .*TypeLib -o typeinfo.py'
# then hacked manually
from ctypes import _Pointer
import os
import sys
from typing import (
Expand All @@ -20,7 +19,8 @@
)
import weakref

from ctypes import *
import ctypes
from ctypes import HRESULT, POINTER, _Pointer, byref, c_int, c_void_p, c_wchar_p
from ctypes.wintypes import DWORD, LONG, UINT, ULONG, WCHAR, WORD
from comtypes import (
BSTR,
Expand Down Expand Up @@ -56,11 +56,11 @@
MEMBERID = DISPID
OLECHAR = WCHAR
PVOID = c_void_p
SHORT = c_short
SHORT = ctypes.c_short
# See https://msdn.microsoft.com/en-us/library/windows/desktop/aa383751(v=vs.85).aspx#ULONG_PTR # noqa
ULONG_PTR = c_uint64 if is_64_bit else c_ulong
ULONG_PTR = ctypes.c_uint64 if is_64_bit else ctypes.c_ulong

USHORT = c_ushort
USHORT = ctypes.c_ushort
LPOLESTR = POINTER(OLECHAR)

################################################################
Expand Down Expand Up @@ -276,7 +276,7 @@ def FindName(
) -> Optional[Tuple[int, "ITypeInfo"]]:
# Hm...
# Could search for more than one name - should we support this?
found = c_ushort(1)
found = ctypes.c_ushort(1)
tinfo = POINTER(ITypeInfo)()
memid = MEMBERID()
self.__com_FindName( # type: ignore
Expand Down Expand Up @@ -389,7 +389,7 @@ def GetVarDesc(self, index):
def GetNames(self, memid: int, count: int = 1) -> List[str]:
"""Return names for memid"""
names = (BSTR * count)()
cnames = c_uint()
cnames = ctypes.c_uint()
self.__com_GetNames(memid, names, count, byref(cnames)) # type: ignore
return names[: cnames.value]

Expand Down Expand Up @@ -478,7 +478,7 @@ class ICreateTypeLib2(ICreateTypeLib):
class ICreateTypeInfo(IUnknown):
_iid_ = GUID("{00020405-0000-0000-C000-000000000046}")
# C:/Programme/gccxml/bin/Vc71/PlatformSDK/oaidl.h 915
_SetFuncAndParamNames: Callable[[int, "Array[c_wchar_p]", int], int]
_SetFuncAndParamNames: Callable[[int, "ctypes.Array[c_wchar_p]", int], int]

def SetFuncAndParamNames(self, index: int, *names: str) -> int:
rgszNames = (c_wchar_p * len(names))()
Expand All @@ -492,7 +492,7 @@ class IRecordInfo(IUnknown):
_iid_ = GUID("{0000002F-0000-0000-C000-000000000046}")

def GetFieldNames(self, *args: Any) -> List[Optional[str]]:
count = c_ulong()
count = ctypes.c_ulong()
self.__com_GetFieldNames(count, None) # type: ignore
array = (BSTR * count.value)()
self.__com_GetFieldNames(count, array) # type: ignore
Expand All @@ -513,7 +513,7 @@ def GetFieldNames(self, *args: Any) -> List[Optional[str]]:
),
COMMETHOD([], HRESULT, "GetGuid", (["out"], POINTER(GUID), "pguid")),
COMMETHOD([], HRESULT, "GetName", (["out"], POINTER(BSTR), "pbstrName")),
COMMETHOD([], HRESULT, "GetSize", (["out"], POINTER(c_ulong), "pcbSize")),
COMMETHOD([], HRESULT, "GetSize", (["out"], POINTER(ctypes.c_ulong), "pcbSize")),
COMMETHOD(
[], HRESULT, "GetTypeInfo", (["out"], POINTER(POINTER(ITypeInfo)), "ppTypeInfo")
),
Expand All @@ -538,7 +538,7 @@ def GetFieldNames(self, *args: Any) -> List[Optional[str]]:
[],
HRESULT,
"PutField",
(["in"], c_ulong, "wFlags"),
(["in"], ctypes.c_ulong, "wFlags"),
(["in"], c_void_p, "pvData"),
(["in"], c_wchar_p, "szFieldName"),
(["in"], POINTER(VARIANT), "pvarField"),
Expand All @@ -547,7 +547,7 @@ def GetFieldNames(self, *args: Any) -> List[Optional[str]]:
[],
HRESULT,
"PutFieldNoCopy",
(["in"], c_ulong, "wFlags"),
(["in"], ctypes.c_ulong, "wFlags"),
(["in"], c_void_p, "pvData"),
(["in"], c_wchar_p, "szFieldName"),
(["in"], POINTER(VARIANT), "pvarField"),
Expand All @@ -556,7 +556,7 @@ def GetFieldNames(self, *args: Any) -> List[Optional[str]]:
[],
HRESULT,
"GetFieldNames",
(["in", "out"], POINTER(c_ulong), "pcNames"),
(["in", "out"], POINTER(ctypes.c_ulong), "pcNames"),
(["in"], POINTER(BSTR), "rgBstrNames"),
),
COMMETHOD([], BOOL, "IsMatchingType", (["in"], POINTER(IRecordInfo))),
Expand All @@ -574,7 +574,7 @@ def GetFieldNames(self, *args: Any) -> List[Optional[str]]:

################################################################
# functions
_oleaut32 = oledll.oleaut32
_oleaut32 = ctypes.oledll.oleaut32


def GetRecordInfoFromTypeInfo(tinfo: ITypeInfo) -> IRecordInfo:
Expand Down Expand Up @@ -672,7 +672,7 @@ def QueryPathOfRegTypeLib(
# Structures


class tagTLIBATTR(Structure):
class tagTLIBATTR(ctypes.Structure):
# C:/Programme/gccxml/bin/Vc71/PlatformSDK/oaidl.h 4437
if TYPE_CHECKING:
guid: GUID
Expand All @@ -695,7 +695,7 @@ def __repr__(self):
TLIBATTR = tagTLIBATTR


class tagTYPEATTR(Structure):
class tagTYPEATTR(ctypes.Structure):
# C:/Programme/gccxml/bin/Vc71/PlatformSDK/oaidl.h 672
if TYPE_CHECKING:
guid: GUID
Expand Down Expand Up @@ -730,7 +730,7 @@ def __repr__(self):
TYPEATTR = tagTYPEATTR


class tagFUNCDESC(Structure):
class tagFUNCDESC(ctypes.Structure):
# C:/Programme/gccxml/bin/Vc71/PlatformSDK/oaidl.h 769
if TYPE_CHECKING:
memid: int
Expand Down Expand Up @@ -762,7 +762,7 @@ def __repr__(self):
FUNCDESC = tagFUNCDESC


class tagVARDESC(Structure):
class tagVARDESC(ctypes.Structure):
# C:/Programme/gccxml/bin/Vc71/PlatformSDK/oaidl.h 803
if TYPE_CHECKING:
memid: int
Expand All @@ -776,7 +776,7 @@ class tagVARDESC(Structure):
VARDESC = tagVARDESC


class tagBINDPTR(Union):
class tagBINDPTR(ctypes.Union):
# C:/Programme/gccxml/bin/Vc71/PlatformSDK/oaidl.h 3075
if TYPE_CHECKING:
lpfuncdesc: _Pointer["FUNCDESC"]
Expand All @@ -787,7 +787,7 @@ class tagBINDPTR(Union):
BINDPTR = tagBINDPTR


class tagTYPEDESC(Structure):
class tagTYPEDESC(ctypes.Structure):
# C:/Programme/gccxml/bin/Vc71/PlatformSDK/oaidl.h 582
if TYPE_CHECKING:
_: "N11tagTYPEDESC5DOLLAR_203E"
Expand All @@ -797,7 +797,7 @@ class tagTYPEDESC(Structure):
TYPEDESC = tagTYPEDESC


class tagIDLDESC(Structure):
class tagIDLDESC(ctypes.Structure):
# C:/Programme/gccxml/bin/Vc71/PlatformSDK/oaidl.h 633
if TYPE_CHECKING:
dwReserved: int
Expand All @@ -807,7 +807,7 @@ class tagIDLDESC(Structure):
IDLDESC = tagIDLDESC


class tagARRAYDESC(Structure):
class tagARRAYDESC(ctypes.Structure):
# C:/Programme/gccxml/bin/Vc71/PlatformSDK/oaidl.h 594
if TYPE_CHECKING:
tdescElem: TYPEDESC
Expand Down Expand Up @@ -1121,7 +1121,7 @@ def GetGUID(self, dwGuidKind: int) -> GUID:
]


class N11tagTYPEDESC5DOLLAR_203E(Union):
class N11tagTYPEDESC5DOLLAR_203E(ctypes.Union):
# C:/Programme/gccxml/bin/Vc71/PlatformSDK/oaidl.h 584
if TYPE_CHECKING:
lptdesc: TYPEDESC
Expand Down Expand Up @@ -1170,7 +1170,7 @@ class N11tagTYPEDESC5DOLLAR_203E(Union):
]


class N10tagVARDESC5DOLLAR_205E(Union):
class N10tagVARDESC5DOLLAR_205E(ctypes.Union):
# C:/Programme/gccxml/bin/Vc71/PlatformSDK/oaidl.h 807
if TYPE_CHECKING:
oInst: int
Expand All @@ -1184,28 +1184,28 @@ class N10tagVARDESC5DOLLAR_205E(Union):
]


class tagELEMDESC(Structure):
class tagELEMDESC(ctypes.Structure):
# C:/Programme/gccxml/bin/Vc71/PlatformSDK/oaidl.h 661
if TYPE_CHECKING:
tdesc: TYPEDESC
_: "N11tagELEMDESC5DOLLAR_204E"


class N11tagELEMDESC5DOLLAR_204E(Union):
class N11tagELEMDESC5DOLLAR_204E(ctypes.Union):
# C:/Programme/gccxml/bin/Vc71/PlatformSDK/oaidl.h 663
if TYPE_CHECKING:
idldesc: IDLDESC
paramdesc: "PARAMDESC"


class tagPARAMDESC(Structure):
class tagPARAMDESC(ctypes.Structure):
# C:/Programme/gccxml/bin/Vc71/PlatformSDK/oaidl.h 609
if TYPE_CHECKING:
pparamdescex: "tagPARAMDESCEX"
wParamFlags: int


class tagPARAMDESCEX(Structure):
class tagPARAMDESCEX(ctypes.Structure):
# C:/Programme/gccxml/bin/Vc71/PlatformSDK/oaidl.h 601
if TYPE_CHECKING:
cBytes: int
Expand Down Expand Up @@ -1274,7 +1274,7 @@ class tagPARAMDESCEX(Structure):
]


class tagSAFEARRAYBOUND(Structure):
class tagSAFEARRAYBOUND(ctypes.Structure):
# C:/Programme/gccxml/bin/Vc71/PlatformSDK/oaidl.h 226
if TYPE_CHECKING:
cElements: int
Expand Down

0 comments on commit 65e3c10

Please sign in to comment.