ctypes-commit Mailing List for ctypes (Page 43)
Brought to you by:
theller
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
(8) |
May
(90) |
Jun
(143) |
Jul
(106) |
Aug
(94) |
Sep
(84) |
Oct
(163) |
Nov
(60) |
Dec
(58) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(128) |
Feb
(79) |
Mar
(227) |
Apr
(192) |
May
(179) |
Jun
(41) |
Jul
(53) |
Aug
(103) |
Sep
(28) |
Oct
(38) |
Nov
(81) |
Dec
(17) |
2006 |
Jan
(184) |
Feb
(111) |
Mar
(188) |
Apr
(67) |
May
(58) |
Jun
(123) |
Jul
(73) |
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
From: Thomas H. <th...@us...> - 2005-08-10 13:18:01
|
Update of /cvsroot/ctypes/ctypes/comtypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1990 Added Files: Tag: branch_1_0 persist.py connectionpoints.py Log Message: Persist and connectionpoint related interfaces. --- NEW FILE: connectionpoints.py --- from ctypes import * from comtypes import IUnknown, COMMETHOD, GUID, HRESULT, dispid _GUID = GUID class tagCONNECTDATA(Structure): _fields_ = [ ('pUnk', POINTER(IUnknown)), ('dwCookie', c_ulong), ] CONNECTDATA = tagCONNECTDATA ################################################################ class IConnectionPointContainer(IUnknown): _iid_ = GUID('{B196B284-BAB4-101A-B69C-00AA00341D07}') _idlflags_ = [] class IConnectionPoint(IUnknown): _iid_ = GUID('{B196B286-BAB4-101A-B69C-00AA00341D07}') _idlflags_ = [] class IEnumConnections(IUnknown): _iid_ = GUID('{B196B287-BAB4-101A-B69C-00AA00341D07}') _idlflags_ = [] class IEnumConnectionPoints(IUnknown): _iid_ = GUID('{B196B285-BAB4-101A-B69C-00AA00341D07}') _idlflags_ = [] ################################################################ IConnectionPointContainer._methods_ = [ COMMETHOD([dispid(1610678272)], HRESULT, 'EnumConnectionPoints', ( ['out'], POINTER(POINTER(IEnumConnectionPoints)), 'ppEnum' )), COMMETHOD([dispid(1610678273)], HRESULT, 'FindConnectionPoint', ( ['in'], POINTER(_GUID), 'riid' ), ( ['out'], POINTER(POINTER(IConnectionPoint)), 'ppCP' )), ] IConnectionPoint._methods_ = [ COMMETHOD([dispid(1610678272)], HRESULT, 'GetConnectionInterface', ( ['out'], POINTER(_GUID), 'pIID' )), COMMETHOD([dispid(1610678273)], HRESULT, 'GetConnectionPointContainer', ( ['out'], POINTER(POINTER(IConnectionPointContainer)), 'ppCPC' )), COMMETHOD([dispid(1610678274)], HRESULT, 'Advise', ( ['in'], POINTER(IUnknown), 'pUnkSink' ), ( ['out'], POINTER(c_ulong), 'pdwCookie' )), COMMETHOD([dispid(1610678275)], HRESULT, 'Unadvise', ( ['in'], c_ulong, 'dwCookie' )), COMMETHOD([dispid(1610678276)], HRESULT, 'EnumConnections', ( ['out'], POINTER(POINTER(IEnumConnections)), 'ppEnum' )), ] IEnumConnections._methods_ = [ COMMETHOD([dispid(1610678272)], HRESULT, 'Next', ( ['in'], c_ulong, 'cConnections' ), ( ['out'], POINTER(tagCONNECTDATA), 'rgcd' ), ( ['out'], POINTER(c_ulong), 'pcFetched' )), COMMETHOD([dispid(1610678273)], HRESULT, 'Skip', ( ['in'], c_ulong, 'cConnections' )), COMMETHOD([dispid(1610678274)], HRESULT, 'Reset'), COMMETHOD([dispid(1610678275)], HRESULT, 'Clone', ( ['out'], POINTER(POINTER(IEnumConnections)), 'ppEnum' )), ] IEnumConnectionPoints._methods_ = [ COMMETHOD([dispid(1610678272)], HRESULT, 'Next', ( ['in'], c_ulong, 'cConnections' ), ( ['out'], POINTER(POINTER(IConnectionPoint)), 'ppCP' ), ( ['out'], POINTER(c_ulong), 'pcFetched' )), COMMETHOD([dispid(1610678273)], HRESULT, 'Skip', ( ['in'], c_ulong, 'cConnections' )), COMMETHOD([dispid(1610678274)], HRESULT, 'Reset'), COMMETHOD([dispid(1610678275)], HRESULT, 'Clone', ( ['out'], POINTER(POINTER(IEnumConnectionPoints)), 'ppEnum' )), ] --- NEW FILE: persist.py --- from ctypes import * from comtypes import GUID, IUnknown, COMMETHOD, HRESULT, dispid from comtypes.automation import VARIANT, tagEXCEPINFO class IErrorLog(IUnknown): _iid_ = GUID('{3127CA40-446E-11CE-8135-00AA004BB851}') _idlflags_ = [] _methods_ = [ COMMETHOD([dispid(1610678272)], HRESULT, 'AddError', ( ['in'], POINTER(c_wchar), 'pszPropName' ), ( ['in'], POINTER(tagEXCEPINFO), 'pExcepInfo' )), ] class IPersist(IUnknown): _iid_ = GUID('{0000010C-0000-0000-C000-000000000046}') _idlflags_ = [] _methods_ = [ COMMETHOD([dispid(1610678272)], HRESULT, 'GetClassID', ( ['out'], POINTER(GUID), 'pClassID' )), ] class IPropertyBag(IUnknown): _iid_ = GUID('{55272A00-42CB-11CE-8135-00AA004BB851}') _idlflags_ = [] _methods_ = [ COMMETHOD([dispid(1610678272)], HRESULT, 'RemoteRead', ( ['in'], POINTER(c_wchar), 'pszPropName' ), ( ['out'], POINTER(VARIANT), 'pVar' ), ( ['in'], POINTER(IErrorLog), 'pErrorLog' ), ( ['in'], c_ulong, 'varType' ), ( ['in'], POINTER(IUnknown), 'pUnkObj' )), COMMETHOD([dispid(1610678273)], HRESULT, 'Write', ( ['in'], POINTER(c_wchar), 'pszPropName' ), ( ['in'], POINTER(VARIANT), 'pVar' )), ] class IPersistPropertyBag(IPersist): _iid_ = GUID('{37D84F60-42CB-11CE-8135-00AA004BB851}') _idlflags_ = [] _methods_ = [ COMMETHOD([dispid(1610743808)], HRESULT, 'InitNew'), COMMETHOD([dispid(1610743809)], HRESULT, 'Load', ( ['in'], POINTER(IPropertyBag), 'pPropBag' ), ( ['in'], POINTER(IErrorLog), 'pErrorLog' )), COMMETHOD([dispid(1610743810)], HRESULT, 'Save', ( ['in'], POINTER(IPropertyBag), 'pPropBag' ), ( ['in'], c_int, 'fClearDirty' ), ( ['in'], c_int, 'fSaveAllProperties' )), ] CLIPFORMAT = c_ulong # Hm, is that correct? PROPBAG2_TYPE_UNDEFINED = 0 PROPBAG2_TYPE_DATA = 1 PROPBAG2_TYPE_URL = 2 PROPBAG2_TYPE_OBJECT = 3 PROPBAG2_TYPE_STREAM = 4 PROPBAG2_TYPE_STORAGE = 5 PROPBAG2_TYPE_MONIKER = 6 class tagPROPBAG2(Structure): _fields_ = [ ('dwType', c_ulong), ('vt', c_ushort), ('cfType', CLIPFORMAT), ('dwHint', c_ulong), ('pstrName', POINTER(c_wchar)), ('clsid', GUID), ] assert sizeof(tagPROPBAG2) == 36, sizeof(tagPROPBAG2) assert alignment(tagPROPBAG2) == 4, alignment(tagPROPBAG2) class IPropertyBag2(IUnknown): _iid_ = GUID('{22F55882-280B-11D0-A8A9-00A0C90C2004}') _idlflags_ = [] _methods_ = [ COMMETHOD([dispid(1610678272)], HRESULT, 'Read', ( ['in'], c_ulong, 'cProperties' ), ( ['in'], POINTER(tagPROPBAG2), 'pPropBag' ), ( ['in'], POINTER(IErrorLog), 'pErrLog' ), ( ['out'], POINTER(VARIANT), 'pvarValue' ), ( ['out'], POINTER(HRESULT), 'phrError' )), COMMETHOD([dispid(1610678273)], HRESULT, 'Write', ( ['in'], c_ulong, 'cProperties' ), ( ['in'], POINTER(tagPROPBAG2), 'pPropBag' ), ( ['in'], POINTER(VARIANT), 'pvarValue' )), COMMETHOD([dispid(1610678274)], HRESULT, 'CountProperties', ( ['out'], POINTER(c_ulong), 'pcProperties' )), COMMETHOD([dispid(1610678275)], HRESULT, 'GetPropertyInfo', ( ['in'], c_ulong, 'iProperty' ), ( ['in'], c_ulong, 'cProperties' ), ( ['out'], POINTER(tagPROPBAG2), 'pPropBag' ), ( ['out'], POINTER(c_ulong), 'pcProperties' )), COMMETHOD([dispid(1610678276)], HRESULT, 'LoadObject', ( ['in'], POINTER(c_wchar), 'pstrName' ), ( ['in'], c_ulong, 'dwHint' ), ( ['in'], POINTER(IUnknown), 'punkObject' ), ( ['in'], POINTER(IErrorLog), 'pErrLog' )), ] class IPersistPropertyBag2(IPersist): _iid_ = GUID('{22F55881-280B-11D0-A8A9-00A0C90C2004}') _idlflags_ = [] _methods_ = [ COMMETHOD([dispid(1610743808)], HRESULT, 'InitNew'), COMMETHOD([dispid(1610743809)], HRESULT, 'Load', ( ['in'], POINTER(IPropertyBag2), 'pPropBag' ), ( ['in'], POINTER(IErrorLog), 'pErrLog' )), COMMETHOD([dispid(1610743810)], HRESULT, 'Save', ( ['in'], POINTER(IPropertyBag2), 'pPropBag' ), ( ['in'], c_int, 'fClearDirty' ), ( ['in'], c_int, 'fSaveAllProperties' )), COMMETHOD([dispid(1610743811)], HRESULT, 'IsDirty'), ] |
From: Thomas H. <th...@us...> - 2005-08-10 13:14:24
|
Update of /cvsroot/ctypes/ctypes/comtypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1280 Modified Files: Tag: branch_1_0 test_DISPPARAMS.py Log Message: Sync with upstream version. Index: test_DISPPARAMS.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/unittests/Attic/test_DISPPARAMS.py,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** test_DISPPARAMS.py 28 Jul 2005 08:49:22 -0000 1.1.2.2 --- test_DISPPARAMS.py 10 Aug 2005 13:14:16 -0000 1.1.2.3 *************** *** 1,6 **** import unittest - # damn, there's still an old bug! - class TestCase(unittest.TestCase): def test(self): --- 1,4 ---- *************** *** 17,25 **** dp.rgvarg[2].value = "foo" self.failUnlessEqual(dp.rgvarg[0].value, 42) self.failUnlessEqual(dp.rgvarg[1].value, "spam") self.failUnlessEqual(dp.rgvarg[2].value, "foo") ! def test_2(self): from comtypes.automation import DISPPARAMS, VARIANT --- 15,26 ---- dp.rgvarg[2].value = "foo" + # damn, there's still this old bug! + self.failUnlessEqual(dp.rgvarg[0].value, 42) self.failUnlessEqual(dp.rgvarg[1].value, "spam") self.failUnlessEqual(dp.rgvarg[2].value, "foo") ! def X_test_2(self): ! # basically the same test as above from comtypes.automation import DISPPARAMS, VARIANT *************** *** 32,37 **** gc.collect() ! for i in range(3): ! print dp.rgvarg[i].value if __name__ == "__main__": --- 33,39 ---- gc.collect() ! self.failUnlessEqual(dp.rgvarg[0].value, 42) ! self.failUnlessEqual(dp.rgvarg[1].value, "spam") ! self.failUnlessEqual(dp.rgvarg[2].value, "foo") if __name__ == "__main__": |
From: Thomas H. <th...@us...> - 2005-08-10 13:14:18
|
Update of /cvsroot/ctypes/ctypes/comtypes/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1259 Modified Files: Tag: branch_1_0 tlbparser.py Log Message: Sync with upstream version. Index: tlbparser.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/tools/tlbparser.py,v retrieving revision 1.4.2.18 retrieving revision 1.4.2.19 diff -C2 -d -r1.4.2.18 -r1.4.2.19 *** tlbparser.py 5 Aug 2005 17:58:22 -0000 1.4.2.18 --- tlbparser.py 10 Aug 2005 13:14:10 -0000 1.4.2.19 *************** *** 618,623 **** def generate_module(tlib, ofi, make_module, name_module): known_symbols = {} ! for name in ("comtypes.typeinfo", "comtypes.automation", "comtypes", "ctypes"): ! mod = __import__(name) for submodule in name.split(".")[1:]: mod = getattr(mod, submodule) --- 618,629 ---- def generate_module(tlib, ofi, make_module, name_module): known_symbols = {} ! for name in ("comtypes.persist", "comtypes.typeinfo", ! "comtypes.automation", "comtypes._others", "comtypes", "ctypes"): ! try: ! mod = __import__(name) ! except ImportError: ! if name == "comtypes._others": ! continue ! raise for submodule in name.split(".")[1:]: mod = getattr(mod, submodule) |
From: Thomas H. <th...@us...> - 2005-08-10 13:14:13
|
Update of /cvsroot/ctypes/ctypes/comtypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1225 Modified Files: Tag: branch_1_0 typeinfo.py safearray.py client.py automation.py __init__.py GUID.py Log Message: Sync with upstream version. Index: GUID.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/GUID.py,v retrieving revision 1.6.2.1 retrieving revision 1.6.2.2 diff -C2 -d -r1.6.2.1 -r1.6.2.2 *** GUID.py 1 Jul 2005 13:26:56 -0000 1.6.2.1 --- GUID.py 10 Aug 2005 13:14:04 -0000 1.6.2.2 *************** *** 7,10 **** --- 7,18 ---- _ole32 = oledll.ole32 + _StringFromCLSID = _ole32.StringFromCLSID + _CoTaskMemFree = _ole32.CoTaskMemFree + _ProgIDFromCLSID = _ole32.ProgIDFromCLSID + _CLSIDFromString = _ole32.CLSIDFromString + _CLSIDFromProgID = _ole32.CLSIDFromProgID + _IsEqualGUID = _ole32.IsEqualGUID + _CoCreateGuid = _ole32.CoCreateGuid + class GUID(Structure): _fields_ = [("Data1", DWORD), *************** *** 15,42 **** def __init__(self, name=None): if name is not None: ! _ole32.CLSIDFromString(unicode(name), byref(self)) def __repr__(self): ! s = (c_wchar * 39)() ! _ole32.StringFromGUID2(byref(self), s, 39) ! return 'GUID("%s")' % s.value ! def __str__(self): ! s = (c_wchar * 39)() ! _ole32.StringFromGUID2(byref(self), s, 39) ! return s.value def __cmp__(self, other): if isinstance(other, GUID): ! return not _ole32.IsEqualGUID(byref(self), byref(other)) return -1 def __nonzero__(self): ! result = str(buffer(self)) != "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" ! return result def __eq__(self, other): return isinstance(other, GUID) and \ ! _ole32.IsEqualGUID(byref(self), byref(other)) ## def __hash__(self): --- 23,56 ---- def __init__(self, name=None): if name is not None: ! _CLSIDFromString(unicode(name), byref(self)) ! ! def hashcode(self): ! # hashcode returns a hashable object that uniquely identifies ! # the GUID. GUID instances itself are unhashable because they ! # are mutable. ! return unicode(self) def __repr__(self): ! return u'GUID("%s")' % unicode(self) ! def __unicode__(self): ! p = c_wchar_p() ! _StringFromCLSID(byref(self), byref(p)) ! result = p.value ! _CoTaskMemFree(p) ! return result ! __str__ = __unicode__ def __cmp__(self, other): if isinstance(other, GUID): ! return not _IsEqualGUID(byref(self), byref(other)) return -1 def __nonzero__(self): ! return str(buffer(self)) != "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" def __eq__(self, other): return isinstance(other, GUID) and \ ! _IsEqualGUID(byref(self), byref(other)) ## def __hash__(self): *************** *** 44,53 **** def copy(self): ! return GUID(str(self)) def from_progid(cls, progid): "Get guid from progid" inst = cls() ! _ole32.CLSIDFromProgID(unicode(progid), byref(inst)) return inst from_progid = classmethod(from_progid) --- 58,67 ---- def copy(self): ! return GUID(unicode(self)) def from_progid(cls, progid): "Get guid from progid" inst = cls() ! _CLSIDFromProgID(unicode(progid), byref(inst)) return inst from_progid = classmethod(from_progid) *************** *** 56,66 **** "Get progid from guid" progid = c_wchar_p() ! _ole32.ProgIDFromCLSID(byref(self), byref(progid)) ! return progid.value def create_new(cls): "Create a brand new guid" guid = cls() ! _ole32.CoCreateGuid(byref(guid)) return guid create_new = classmethod(create_new) --- 70,82 ---- "Get progid from guid" progid = c_wchar_p() ! _ProgIDFromCLSID(byref(self), byref(progid)) ! result = progid.value ! _CoTaskMemFree(progid) ! return result def create_new(cls): "Create a brand new guid" guid = cls() ! _CoCreateGuid(byref(guid)) return guid create_new = classmethod(create_new) Index: automation.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/automation.py,v retrieving revision 1.12.2.11 retrieving revision 1.12.2.12 diff -C2 -d -r1.12.2.11 -r1.12.2.12 *** automation.py 29 Jul 2005 19:45:01 -0000 1.12.2.11 --- automation.py 10 Aug 2005 13:14:04 -0000 1.12.2.12 *************** *** 4,7 **** --- 4,8 ---- from comtypes import IUnknown, GUID, IID, STDMETHOD, BSTR, COMMETHOD, dispid import datetime # for VT_DATE, standard in Python 2.3 and up + import array try: import decimal # standard in Python 2.4 and up *************** *** 146,149 **** --- 147,154 ---- self.value = args[0] + def __del__(self): + if not self._b_base_: + _VariantClear(byref(self)) + def __repr__(self): return "VARIANT(%r)" % self.value *************** *** 201,204 **** --- 206,217 ---- CopyComPointer(value, byref(self._)) self.vt = VT_UNKNOWN + elif isinstance(value, (list, tuple)): + from comtypes.safearray import SafeArray_FromSequence + self._.c_void_p = SafeArray_FromSequence(value) + self.vt = VT_ARRAY | VT_VARIANT + elif isinstance(value, array.array): + from comtypes.safearray import SafeArray_FromArray + typecode, self._.c_void_p = SafeArray_FromArray(value) + self.vt = VT_ARRAY | typecode else: raise "NYI", value *************** *** 256,259 **** --- 269,273 ---- val = self._.c_void_p if not val: + # See above. return None # XXX? ptr = cast(val, POINTER(IDispatch)).__ctypes_from_outparam__() *************** *** 261,271 **** ptr.AddRef() return ptr else: ! raise "NYI", vt ! ! """ ! VT_DISPATCH ! VT_UNKNOWN ! """ # these are missing: --- 275,286 ---- ptr.AddRef() return ptr + # see also c:/sf/pywin32/com/win32com/src/oleargs.cpp + elif vt == VT_BYREF|VT_VARIANT: + return self._.pvarVal[0].value + elif self.vt & VT_ARRAY: + from comtypes.safearray import UnpackSafeArray + return UnpackSafeArray(self._.c_void_p) else: ! raise NotImplementedError("typecode %d = 0x%x)" % (vt, vt)) # these are missing: *************** *** 403,406 **** --- 418,425 ---- ('cNamedArgs', UINT), ] + def __del__(self): + if not self._b_base_: + for i in range(self.cArgs): + self.rgvarg[i].value = None assert sizeof(tagDISPPARAMS) == 16, sizeof(tagDISPPARAMS) assert alignment(tagDISPPARAMS) == 4, alignment(tagDISPPARAMS) *************** *** 479,483 **** array[i].value = a - raise "DISPATCH_PROPERTYGET" dp = DISPPARAMS() dp.cArgs = len(args) --- 498,501 ---- *************** *** 486,490 **** elif _invkind == DISPATCH_PROPERTYPUT: # propput - raise "DISPATCH_PROPERTYPUT" assert len(args) == 1 dp = DISPPARAMS() --- 504,507 ---- *************** *** 508,511 **** --- 525,529 ---- return result.value + # Hm, maybe we should provide separate methods for _METHOD, _PROPERTYGET and _PROPERTYPUT # all the DISP_E_ values from windows.h Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/__init__.py,v retrieving revision 1.25.2.23 retrieving revision 1.25.2.24 diff -C2 -d -r1.25.2.23 -r1.25.2.24 *** __init__.py 5 Aug 2005 18:27:02 -0000 1.25.2.23 --- __init__.py 10 Aug 2005 13:14:04 -0000 1.25.2.24 *************** *** 1,6 **** # requires ctypes 0.9.3 or later import new ! import warnings import types try: set --- 1,7 ---- # requires ctypes 0.9.3 or later import new ! ##import warnings import types + import sys try: set *************** *** 54,59 **** class _Cleaner(object): def __del__(self, func=_ole32.CoUninitialize): ! # Sometimes, CoUnititialize, running at Python shutdown, raises an exception. ! # We suppress this when __debug__ is False. if __debug__: func() --- 55,61 ---- class _Cleaner(object): def __del__(self, func=_ole32.CoUninitialize): ! # Sometimes, CoUnititialize, running at Python shutdown, ! # raises an exception. We suppress this when __debug__ is ! # False. if __debug__: func() *************** *** 65,76 **** del _Cleaner ! def _clean_exc_info(): ! # the purpose of this function is to ensure that no com object ! # pointers are in sys.exc_info() ! try: 1//0 ! except: pass ! import atexit ! atexit.register(_clean_exc_info) ################################################################ --- 67,74 ---- del _Cleaner ! # Make sure no COM pointers stay in exception frames at first step of ! # shutdown. import atexit ! atexit.register(sys.exc_clear) ################################################################ *************** *** 90,96 **** cls = type.__new__(self, name, bases, namespace) if methods is not None: ! setattr(cls, "_methods_", methods) if dispmethods is not None: ! setattr(cls, "_disp_methods_", dispmethods) # If we sublass a COM interface, for example: --- 88,94 ---- cls = type.__new__(self, name, bases, namespace) if methods is not None: ! cls._methods_ = methods if dispmethods is not None: ! cls._disp_methods_ = dispmethods # If we sublass a COM interface, for example: *************** *** 106,113 **** else: _ptr_bases = (cls, POINTER(bases[0])) # The interface 'cls' is used as a mixin. p = type(_compointer_base)("POINTER(%s)" % cls.__name__, _ptr_bases, ! {"__ctypes_from_outparam__": lambda self: self}) from ctypes import _pointer_type_cache _pointer_type_cache[cls] = p --- 104,123 ---- else: _ptr_bases = (cls, POINTER(bases[0])) + + def from_param(klass, value): + if isinstance(value, klass): + return value + if value is None: + return None + if klass._iid_ == getattr(value, "_iid_", None): + return value + return value.QueryInterface(cls) + # The interface 'cls' is used as a mixin. p = type(_compointer_base)("POINTER(%s)" % cls.__name__, _ptr_bases, ! {"__ctypes_from_outparam__": lambda self: self, ! "from_param": classmethod(from_param), ! "__com_interface__": cls}) from ctypes import _pointer_type_cache _pointer_type_cache[cls] = p *************** *** 123,126 **** --- 133,137 ---- def _make_dispmethods(self, methods): # create dispinterface methods and properties on the interface 'self' + properties = {} for m in methods: what, name, idlflags, restype, argspec = m *************** *** 140,169 **** method = self._disp_method(memid, name, idlflags, restype, argspec) ## not in 2.3 method.__name__ = name ! if method is not None: setattr(self, name, method) def _disp_method(self, memid, name, idlflags, restype, argspec): if 'propget' in idlflags: ! ## if argspec: # has parameters ! ## print name, idlflags, restype, argspec ! ## raise NotImplementedError, 'propget %s' % name ! return ! if 'propput' in idlflags: ! ## if len(argspec) > 1: # has parameters ! ## print name, idlflags, restype, argspec ! ## raise NotImplementedError, 'propput %s' % name ! return ! args = [] ! for a in argspec: ! if len(a) == 4: ! args.append("%s=%r" % (a[2], a[3])) ! else: ! args.append(a[2]) ! ## print " def %s(self, %s):" % (name, ", ".join(args)) ! ## print " return self.Invoke(%s, %s)" % (memid, ", ".join([a[2] for a in argspec])) def func(obj, *args, **kw): ! result = self.Invoke(obj, memid, _invkind=1, *args, **kw) # DISPATCH_METHOD ! # Hm, seems we should call AddRef(). ! return cast(result, restype) return func --- 151,186 ---- method = self._disp_method(memid, name, idlflags, restype, argspec) ## not in 2.3 method.__name__ = name ! if 'propget' in idlflags: ! nargs = len(argspec) ! properties.setdefault((name, nargs), [None, None])[0] = method ! elif 'propput' in idlflags: ! nargs = len(argspec)-1 ! properties.setdefault((name, nargs), [None, None])[1] = method ! else: setattr(self, name, method) + for (name, nargs), methods in properties.items(): + if nargs: + setattr(self, name, named_property(*methods)) + else: + setattr(self, name, property(*methods)) def _disp_method(self, memid, name, idlflags, restype, argspec): if 'propget' in idlflags: ! def getfunc(obj, *args, **kw): ! return self.Invoke(obj, memid, _invkind=2, *args, **kw) # DISPATCH_PROPERTYGET ! return getfunc ! elif 'propput' in idlflags: ! def putfunc(obj, *args, **kw): ! return self.Invoke(obj, memid, _invkind=4, *args, **kw) # DISPATCH_PROPERTYPUT ! return putfunc ! # The following doesn't have the desired effect ! ## args = [] ! ## for a in argspec: ! ## if len(a) == 4: ! ## args.append("%s=%r" % (a[2], a[3])) ! ## else: ! ## args.append(a[2]) def func(obj, *args, **kw): ! return self.Invoke(obj, memid, _invkind=1, *args, **kw) # DISPATCH_METHOD return func *************** *** 195,212 **** else: iid = str(iid) ! if iid in com_interface_registry: ! # Warn when multiple interfaces are defined with identical iids. ! # This would also trigger if we reload() a module that contains ! # interface types, so suppress the warning in this case. ! other = com_interface_registry[iid] ! if self.__name__ != other.__name__ or self.__module__ != other.__module__: ! text = "Multiple interface defn: %s" % self.__name__ ! warnings.warn(text, UserWarning) com_interface_registry[iid] = self del iid vtbl_offset = self.__get_baseinterface_methodcount() ! getters = {} ! setters = {} # create private low level, and public high level methods --- 212,229 ---- else: iid = str(iid) ! ## if iid in com_interface_registry: ! ## # Warn when multiple interfaces are defined with identical iids. ! ## # This would also trigger if we reload() a module that contains ! ## # interface types, so suppress the warning in this case. ! ## other = com_interface_registry[iid] ! ## if self.__name__ != other.__name__ or self.__module__ != other.__module__: ! ## text = "Multiple interface defn: %s, %s" % \ ! ## (self, other) ! ## warnings.warn(text, UserWarning) com_interface_registry[iid] = self del iid vtbl_offset = self.__get_baseinterface_methodcount() ! properties = {} # create private low level, and public high level methods *************** *** 248,252 **** # if (flags[0] & 1) or (flags[0] == 0)]) propname = name[len("_get_"):] ! getters[propname, doc, nargs] = func is_prop = True elif "propput" in idlflags: --- 265,269 ---- # if (flags[0] & 1) or (flags[0] == 0)]) propname = name[len("_get_"):] ! properties.setdefault((propname, doc, nargs), [None, None])[0] = func is_prop = True elif "propput" in idlflags: *************** *** 255,259 **** if flags[0] & 7 in (0, 1)]) - 1 propname = name[len("_set_"):] ! setters[propname, doc, nargs] = func is_prop = True --- 272,276 ---- if flags[0] & 7 in (0, 1)]) - 1 propname = name[len("_set_"):] ! properties.setdefault((propname, doc, nargs), [None, None])[1] = func is_prop = True *************** *** 268,281 **** # create public properties / attribute accessors ! # XXX Das sieht mir aber komisch aus! ! for item in set(getters.keys()) | set(getters.keys()): ! name, doc, nargs = item if nargs == 0: ! prop = property(getters.get(item), setters.get(item), doc=doc) else: # Hm, must be a descriptor where the __get__ method # returns a bound object having __getitem__ and # __setitem__ methods. ! prop = named_property(getters.get(item), setters.get(item), doc=doc) # Again, we should not overwrite class attributes that are # already present. --- 285,296 ---- # create public properties / attribute accessors ! for (name, doc, nargs), methods in properties.items(): if nargs == 0: ! prop = property(*methods + [doc]) else: # Hm, must be a descriptor where the __get__ method # returns a bound object having __getitem__ and # __setitem__ methods. ! prop = named_property(*methods + [doc]) # Again, we should not overwrite class attributes that are # already present. *************** *** 300,303 **** --- 315,323 ---- return self.getter(self.im_inst, index) + def __call__(self, *args): + if self.getter is None: + raise TypeError("object is nor callable") + return self.getter(self.im_inst, *args) + def __setitem__(self, index, value): if self.setter is None: *************** *** 305,313 **** self.setter(self.im_inst, index, value) - def __call__(self, *args): - return self.getter(self.im_inst, *args) - class named_property(object): ! def __init__(self, getter, setter, doc): self.getter = getter self.setter = setter --- 325,330 ---- self.setter(self.im_inst, index, value) class named_property(object): ! def __init__(self, getter, setter, doc=None): self.getter = getter self.setter = setter *************** *** 541,549 **** raise TypeError, "len() of unsized object" # does this make sense? It seems that all standard typelibs I've ! # seen so far that support .Item aso support ._NewEnum ! # ! # And how can we know if the indexes are 1-based or 0-based? ! def __getitem__(self, index): """Forwards to self.Item(index), raises TypeError if no Item method.""" --- 558,571 ---- raise TypeError, "len() of unsized object" + # calling a COM pointer calls it's .Item property, if that is present. + def __call__(self, *args, **kw): + try: + mth = self.Item + except AttributeError: + raise TypeError, "object is not callable" + return self.Item(*args, **kw) + # does this make sense? It seems that all standard typelibs I've ! # seen so far that support .Item also support ._NewEnum def __getitem__(self, index): """Forwards to self.Item(index), raises TypeError if no Item method.""" *************** *** 557,560 **** --- 579,583 ---- except WindowsError: raise IndexError, "invalid index" + # Hm, this doesn't look correct... if not result: # we got a NULL com pointer raise IndexError, "invalid index" Index: safearray.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/Attic/safearray.py,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** safearray.py 1 Jul 2005 19:07:05 -0000 1.1.2.1 --- safearray.py 10 Aug 2005 13:14:04 -0000 1.1.2.2 *************** *** 2,6 **** from ctypes import * from comtypes.typeinfo import SAFEARRAYBOUND ! from comtypes.automation import VT_I4, VT_R8 class SAFEARRAY(Structure): --- 2,7 ---- from ctypes import * from comtypes.typeinfo import SAFEARRAYBOUND ! from comtypes.automation import VARIANT, VARTYPE ! from comtypes.automation import VT_VARIANT, VT_R4, VT_R8, VT_I1, VT_I2, VT_I4, VT_INT, VT_UI1, VT_UI2, VT_UI4, VT_UINT class SAFEARRAY(Structure): *************** *** 38,54 **** if __name__ == "__main__": ! rgsa = (SAFEARRAYBOUND * 2)() ! rgsa[0].lLBound = 0 ! rgsa[0].cElements = 8 ! rgsa[1].lLBound = 0 ! rgsa[1].cElements = 5 windll.oleaut32.SafeArrayCreate.restype = POINTER(SAFEARRAY) ! array = windll.oleaut32.SafeArrayCreate(VT_I4, len(rgsa), rgsa)[0] ! array.dump() ! for i, data in enumerate(array): ! print i, data ! ##print array[-1] ! print array[:] --- 39,172 ---- + def SafeArray_FromSequence(seq): + psa = oledll.oleaut32.SafeArrayCreateVector(VT_VARIANT, 0, len(seq)) + for index, elem in enumerate(seq): + oledll.oleaut32.SafeArrayPutElement(psa, byref(c_long(index)), byref(VARIANT(elem))) + return psa + + def SafeArray_FromArray(arr): + TYPECODE = { + "d": VT_R8, + "f": VT_R4, + "l": VT_I4, + "i": VT_INT, + "h": VT_I2, + "b": VT_I1, + "I": VT_UINT, + "L": VT_UI4, + "H": VT_UI2, + "B": VT_UI1, + } + vt = TYPECODE[arr.typecode] + psa = oledll.oleaut32.SafeArrayCreateVector(vt, 0, len(arr)) + ptr = c_void_p() + oledll.oleaut32.SafeArrayAccessData(psa, byref(ptr)) + memmove(ptr, arr.buffer_info()[0], len(arr) * arr.itemsize) + oledll.oleaut32.SafeArrayUnaccessData(psa) + return vt, psa + + ################################################################ + + def _get_row(ctype, psa, dim, indices, upperbounds): + # loop over the index of dimension 'dim' + # we have to restore the index of the dimension we're looping over + restore = indices[dim] + + result = [] + for i in range(indices[dim], upperbounds[dim]+1): + indices[dim] = i + if dim+1 == len(indices): + oledll.oleaut32.SafeArrayGetElement(psa, indices, byref(ctype)) + result.append(ctype.value) + else: + result.append(_get_row(ctype, psa, dim+1, indices, upperbounds)) + indices[dim] = restore + return result + + def _get_ubound(psa, dim): + # Return the upper bound of a dimension in a safearray + ubound = c_long() + oledll.oleaut32.SafeArrayGetUBound(psa, dim+1, byref(ubound)) + return ubound.value + + def _get_lbound(psa, dim): + # Return the lower bound of a dimension in a safearray + lb = c_long() + oledll.oleaut32.SafeArrayGetLBound(psa, dim+1, byref(lb)) + return lb.value + + _VT2CTYPE = { + VT_R8: c_double, + VT_R4: c_float, + VT_I4: c_long, + VT_INT: c_int, + VT_I2: c_short, + VT_I1: c_byte, + VT_UI4: c_ulong, + VT_UINT: c_uint, + VT_UI2: c_ushort, + VT_UI1: c_ubyte, + VT_VARIANT: VARIANT + } + + def _get_datatype(psa): + # Return the ctypes data type corresponding to the SAFEARRAY's typecode. + vt = VARTYPE() + oledll.oleaut32.SafeArrayGetVartype(psa, byref(vt)) + return _VT2CTYPE[vt.value] + + def UnpackSafeArray(psa): + """Unpack a SAFEARRAY into a Python list.""" + dim = oledll.oleaut32.SafeArrayGetDim(psa) + indexes = [_get_lbound(psa, d) for d in range(dim)] + indexes = (c_long * dim)(*indexes) + upperbounds = [_get_ubound(psa, d) for d in range(dim)] + return _get_row(_get_datatype(psa)(), psa, 0, indexes, upperbounds) + if __name__ == "__main__": ! dim = 3 ! ! if dim == 2: ! rgsa = (SAFEARRAYBOUND * 2)() ! rgsa[0].lLbound = 3 ! rgsa[0].cElements = 9 ! rgsa[1].lLbound = 7 ! rgsa[1].cElements = 6 + elif dim == 1: + rgsa = (SAFEARRAYBOUND * 1)() + rgsa[0].lLbound = 3 + rgsa[0].cElements = 9 + + elif dim == 3: + + rgsa = (SAFEARRAYBOUND * 3)() + rgsa[0].lLbound = 1 + rgsa[0].cElements = 6 + rgsa[1].lLbound = 2 + rgsa[1].cElements = 5 + rgsa[2].lLbound = 3 + rgsa[2].cElements = 4 + else: + raise ValueError("dim %d not supported" % dim) windll.oleaut32.SafeArrayCreate.restype = POINTER(SAFEARRAY) ! psa = windll.oleaut32.SafeArrayCreate(VT_I4, len(rgsa), rgsa) ! n = 1 ! for b in rgsa: ! n *= b.cElements ! print "%d total elements" % n ! ! ptr = POINTER(c_int)() ! ! oledll.oleaut32.SafeArrayAccessData(psa, byref(ptr)) ! array = (c_int * n)(*range(n)) ! memmove(ptr, array, sizeof(array)) ! oledll.oleaut32.SafeArrayUnaccessData(psa) ! ! import pprint ! pprint.pprint(UnpackSafeArray(psa)) ! ! ## v = VARIANT() ! ## v.value = [("1",), (2, 3, None)] ! ## print v.value Index: typeinfo.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/typeinfo.py,v retrieving revision 1.3.2.6 retrieving revision 1.3.2.7 diff -C2 -d -r1.3.2.6 -r1.3.2.7 *** typeinfo.py 3 Aug 2005 10:03:32 -0000 1.3.2.6 --- typeinfo.py 10 Aug 2005 13:14:04 -0000 1.3.2.7 *************** *** 633,636 **** --- 633,637 ---- _iid_ = GUID("{B196B283-BAB4-101A-B69C-00AA00341D07}") _methods_ = [ + # Returns the ITypeInfo interface for the object's coclass type information. COMMETHOD([], HRESULT, "GetClassInfo", ( ['out'], POINTER(POINTER(ITypeInfo)), "ppTI" ) ) *************** *** 640,643 **** --- 641,645 ---- _iid_ = GUID("{A6BC3AC0-DBAA-11CE-9DE3-00AA004BB851}") _methods_ = [ + # Returns the GUID for the object's outgoing IID for its default event set. COMMETHOD([], HRESULT, "GetGUID", ( ['in'], DWORD, "dwGuidKind" ), Index: client.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/Attic/client.py,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -C2 -d -r1.1.2.4 -r1.1.2.5 *** client.py 3 Aug 2005 10:02:38 -0000 1.1.2.4 --- client.py 10 Aug 2005 13:14:04 -0000 1.1.2.5 *************** *** 299,307 **** interface = getattr(mod, itf_name) # QI for this interface ! result = punk.QueryInterface(interface) ! # Hm, this makes the constants in the module (but not only the ! # constants) available to the returned object. ! result._constants = mod ! return result # Should we do this for POINTER(IUnknown) also? --- 299,303 ---- interface = getattr(mod, itf_name) # QI for this interface ! return punk.QueryInterface(interface) # Should we do this for POINTER(IUnknown) also? |
From: Thomas H. <th...@us...> - 2005-08-05 18:27:17
|
Update of /cvsroot/ctypes/ctypes/comtypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19231 Modified Files: Tag: branch_1_0 __init__.py Log Message: Use CLSCTX_SERVER, not CLSCTX_ALL when clsctx is not specified. Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/__init__.py,v retrieving revision 1.25.2.22 retrieving revision 1.25.2.23 diff -C2 -d -r1.25.2.22 -r1.25.2.23 *** __init__.py 5 Aug 2005 18:13:15 -0000 1.25.2.22 --- __init__.py 5 Aug 2005 18:27:02 -0000 1.25.2.23 *************** *** 600,604 **** """ if clsctx is None: ! clsctx = CLSCTX_ALL p = POINTER(interface)() iid = interface._iid_ --- 600,604 ---- """ if clsctx is None: ! clsctx = CLSCTX_SERVER p = POINTER(interface)() iid = interface._iid_ |
From: Thomas H. <th...@us...> - 2005-08-05 18:13:24
|
Update of /cvsroot/ctypes/ctypes/comtypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15502 Modified Files: Tag: branch_1_0 __init__.py Log Message: Add a com_registry dictionary, this maps interface identifier strings to interface types. Suppress the warning when this happens because we reload() a module. Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/__init__.py,v retrieving revision 1.25.2.21 retrieving revision 1.25.2.22 diff -C2 -d -r1.25.2.21 -r1.25.2.22 *** __init__.py 3 Aug 2005 10:01:47 -0000 1.25.2.21 --- __init__.py 5 Aug 2005 18:13:15 -0000 1.25.2.22 *************** *** 77,80 **** --- 77,82 ---- # The metaclasses... + com_interface_registry = {} + class _cominterface_meta(type): """Metaclass for COM interfaces. Automatically creates high level *************** *** 188,194 **** # we insist on an _iid_ in THIS class! try: ! self.__dict__["_iid_"] except KeyError: raise AttributeError, "this class must define an _iid_" vtbl_offset = self.__get_baseinterface_methodcount() --- 190,208 ---- # we insist on an _iid_ in THIS class! try: ! iid = self.__dict__["_iid_"] except KeyError: raise AttributeError, "this class must define an _iid_" + else: + iid = str(iid) + if iid in com_interface_registry: + # Warn when multiple interfaces are defined with identical iids. + # This would also trigger if we reload() a module that contains + # interface types, so suppress the warning in this case. + other = com_interface_registry[iid] + if self.__name__ != other.__name__ or self.__module__ != other.__module__: + text = "Multiple interface defn: %s" % self.__name__ + warnings.warn(text, UserWarning) + com_interface_registry[iid] = self + del iid vtbl_offset = self.__get_baseinterface_methodcount() |
From: Thomas H. <th...@us...> - 2005-08-05 17:58:42
|
Update of /cvsroot/ctypes/ctypes/comtypes/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11826 Modified Files: Tag: branch_1_0 tlbparser.py Log Message: Handle the two known cases of COM interfaces without a base class. Print a warning on other cases. Index: tlbparser.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/tools/tlbparser.py,v retrieving revision 1.4.2.17 retrieving revision 1.4.2.18 diff -C2 -d -r1.4.2.17 -r1.4.2.18 *** tlbparser.py 5 Aug 2005 13:35:51 -0000 1.4.2.17 --- tlbparser.py 5 Aug 2005 17:58:22 -0000 1.4.2.18 *************** *** 199,202 **** --- 199,211 ---- itf_name, itf_doc = tinfo.GetDocumentation(-1)[0:2] assert ta.cImplTypes <= 1 + if ta.cImplTypes == 0 and itf_name != "IUnknown": + # Windows defines an interface IOleControlTypes in ocidl.idl. + # Don't known what artefact that is - we ignore it. + # It's an interface without methods anyway. + if itf_name != "IOleControlTypes": + message = "Ignoring interface %s which has no base interface" % itf_name + import warnings + warnings.warn(message, UserWarning); + return None itf = typedesc.ComInterface(itf_name, |
From: Thomas H. <th...@us...> - 2005-08-05 17:55:18
|
Update of /cvsroot/ctypes/ctypes/ctypes/wrap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11098 Modified Files: Tag: branch_1_0 codegenerator.py Log Message: If guessing the packing of structures in the code generator fails, print a warning and also write it to the output instead of punting completely. The generated code may or may not work. Index: codegenerator.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/wrap/codegenerator.py,v retrieving revision 1.6.2.2 retrieving revision 1.6.2.3 diff -C2 -d -r1.6.2.2 -r1.6.2.3 *** codegenerator.py 28 Jul 2005 08:53:46 -0000 1.6.2.2 --- codegenerator.py 5 Aug 2005 17:55:07 -0000 1.6.2.3 *************** *** 3,6 **** --- 3,11 ---- # $Log$ + # Revision 1.6.2.3 2005/08/05 17:55:07 theller + # If guessing the packing of structures in the code generator fails, + # print a warning and also write it to the output instead of punting + # completely. The generated code may or may not work. + # # Revision 1.6.2.2 2005/07/28 08:53:46 theller # Use separate streams for imports and code in the generated code. This *************** *** 108,112 **** total_align = 8 # in bits for i, f in enumerate(fields): ! if f.bits: ## print "##XXX FIXME" return -2 # XXX FIXME --- 113,117 ---- total_align = 8 # in bits for i, f in enumerate(fields): ! if f.bits: # this code cannot handle bit field sizes. ## print "##XXX FIXME" return -2 # XXX FIXME *************** *** 118,122 **** if isStruct: if size != f.offset: ! raise PackingError, "field offset (%s/%s)" % (size, f.offset) size += s else: --- 123,127 ---- if isStruct: if size != f.offset: ! raise PackingError, "field %s offset (%s/%s)" % (f.name, size, f.offset) size += s else: *************** *** 445,457 **** pass ! # we don't need _pack_ on Unions (I hope, at least), and ! # not on COM interfaces: ! # ! # Hm, how to detect a COM interface with no methods? IXMLDOMCDATASection is such a beast... ! ## if not isinstance(body.struct, typedesc.Union) and not methods: if not methods: ! pack = calc_packing(body.struct, fields) ! if pack is not None: ! print >> self.stream, "%s._pack_ = %s" % (body.struct.name, pack) if fields: --- 450,466 ---- pass ! # we don't need _pack_ on Unions (I hope, at least), and not ! # on COM interfaces: if not methods: ! try: ! pack = calc_packing(body.struct, fields) ! if pack is not None: ! print >> self.stream, "%s._pack_ = %s" % (body.struct.name, pack) ! except PackingError, details: ! # if packing fails, write a warning comment to the output. ! import warnings ! message = "Structure %s: %s" % (body.struct.name, details) ! warnings.warn(message, UserWarning) ! print >> self.stream, "# WARNING: %s" % details if fields: |
From: Thomas H. <th...@us...> - 2005-08-05 13:36:15
|
Update of /cvsroot/ctypes/ctypes/comtypes/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24390 Modified Files: Tag: branch_1_0 tlbparser.py Log Message: Remove debug print. Index: tlbparser.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/tools/tlbparser.py,v retrieving revision 1.4.2.16 retrieving revision 1.4.2.17 diff -C2 -d -r1.4.2.16 -r1.4.2.17 *** tlbparser.py 5 Aug 2005 13:31:04 -0000 1.4.2.16 --- tlbparser.py 5 Aug 2005 13:35:51 -0000 1.4.2.17 *************** *** 472,478 **** fullname = "%s.%s" % (modname, name) if fullname in self.items: ! # XXX Do we really allow this? if isinstance(value, typedesc.External): - print modname, name return # BUG: We try to register an item that's already registered. --- 472,477 ---- fullname = "%s.%s" % (modname, name) if fullname in self.items: ! # XXX Can we really allow this? It happens, at least. if isinstance(value, typedesc.External): return # BUG: We try to register an item that's already registered. |
From: Thomas H. <th...@us...> - 2005-08-05 13:31:12
|
Update of /cvsroot/ctypes/ctypes/comtypes/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23387 Modified Files: Tag: branch_1_0 tlbparser.py Log Message: We need to register interfaces early, even before the base interface is parsed because the base interface can directly or indirectly refer to the current interface again. This avoids interfaces being parsed more than once. Index: tlbparser.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/tools/tlbparser.py,v retrieving revision 1.4.2.15 retrieving revision 1.4.2.16 diff -C2 -d -r1.4.2.15 -r1.4.2.16 *** tlbparser.py 1 Aug 2005 11:18:11 -0000 1.4.2.15 --- tlbparser.py 5 Aug 2005 13:31:04 -0000 1.4.2.16 *************** *** 200,213 **** assert ta.cImplTypes <= 1 - if ta.cImplTypes: - hr = tinfo.GetRefTypeOfImplType(0) - tibase = tinfo.GetRefTypeInfo(hr) - base = self.parse_typeinfo(tibase) - else: - base = None - members = [] itf = typedesc.ComInterface(itf_name, ! members=members, ! base=base, iid=str(ta.guid), idlflags=self.interface_type_flags(ta.wTypeFlags)) --- 200,206 ---- assert ta.cImplTypes <= 1 itf = typedesc.ComInterface(itf_name, ! members=[], ! base=None, iid=str(ta.guid), idlflags=self.interface_type_flags(ta.wTypeFlags)) *************** *** 216,219 **** --- 209,217 ---- self._register(itf_name, itf) + if ta.cImplTypes: + hr = tinfo.GetRefTypeOfImplType(0) + tibase = tinfo.GetRefTypeInfo(hr) + itf.base = self.parse_typeinfo(tibase) + assert ta.cVars == 0, "vars on an Interface?" *************** *** 472,476 **** def _register(self, name, value, tlib=None): modname = self._typelib_module(tlib) ! self.items["%s.%s" % (modname, name)] = value def parse_typeinfo(self, tinfo): --- 470,482 ---- def _register(self, name, value, tlib=None): modname = self._typelib_module(tlib) ! fullname = "%s.%s" % (modname, name) ! if fullname in self.items: ! # XXX Do we really allow this? ! if isinstance(value, typedesc.External): ! print modname, name ! return ! # BUG: We try to register an item that's already registered. ! raise ValueError, "Bug: Multiple registered" ! self.items[fullname] = value def parse_typeinfo(self, tinfo): |
From: Thomas H. <th...@us...> - 2005-08-03 10:06:15
|
Update of /cvsroot/ctypes/ctypes/comtypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19677 Added Files: Tag: branch_1_0 test_client.py Log Message: Add tests for comtypes.client. --- NEW FILE: test_client.py --- import unittest import comtypes.client from ctypes import POINTER # create the typelib wrapper and import it comtypes.client.make_module("msscript.ocx", friendly_name="msscript") from comtypes.gen import msscript class Test(unittest.TestCase): def test_progid(self): # create from ProgID obj = comtypes.client.CreateObject("MSScriptControl.ScriptControl") self.failUnless(isinstance(obj, POINTER(msscript.IScriptControl))) def test_clsid(self): # create from the CoClass' clsid obj = comtypes.client.CreateObject(msscript.ScriptControl) self.failUnless(isinstance(obj, POINTER(msscript.IScriptControl))) def test_clsid_string(self): # create from string clsid comtypes.client.CreateObject(unicode(msscript.ScriptControl._clsid_)) comtypes.client.CreateObject(str(msscript.ScriptControl._clsid_)) def test_remote(self): ie = comtypes.client.CreateObject("InternetExplorer.Application", machine="localhost") self.failUnlessEqual(ie.Visible, False) ie.Visible = 1 # on a remote machine, this may not work. Probably depends on # how the server is run. self.failUnlessEqual(ie.Visible, True) self.failUnlessEqual(0, ie.Quit()) # 0 == S_OK if __name__ == "__main__": unittest.main() |
From: Thomas H. <th...@us...> - 2005-08-03 10:05:18
|
Update of /cvsroot/ctypes/ctypes/comtypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19554 Modified Files: Tag: branch_1_0 test_typeinfo.py Log Message: Test works now. Index: test_typeinfo.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/unittests/test_typeinfo.py,v retrieving revision 1.3.2.1 retrieving revision 1.3.2.2 diff -C2 -d -r1.3.2.1 -r1.3.2.2 *** test_typeinfo.py 8 Jun 2005 10:06:57 -0000 1.3.2.1 --- test_typeinfo.py 3 Aug 2005 10:05:09 -0000 1.3.2.2 *************** *** 12,19 **** self.failUnless(tlib.GetTypeInfoCount()) tlib.GetDocumentation(-1) ! self.failUnlessEqual(tlib.IsName("IWebBrowser"), True) ! self.failUnlessEqual(tlib.IsName("Spam"), False) self.failUnless(tlib.FindName("IWebBrowser")) ! self.failUnlessEqual(tlib.FindName("Spam"), None) tlib.GetTypeComp() --- 12,19 ---- self.failUnless(tlib.GetTypeInfoCount()) tlib.GetDocumentation(-1) ! self.failUnlessEqual(tlib.IsName("iwebbrowser"), "IWebBrowser") ! self.failUnlessEqual(tlib.IsName("IWEBBROWSER"), "IWebBrowser") self.failUnless(tlib.FindName("IWebBrowser")) ! self.failUnlessEqual(tlib.IsName("Spam"), None) tlib.GetTypeComp() *************** *** 23,29 **** self.failUnlessEqual(tlib, other_tlib) ! ## for n in dir(attr): ! ## if not n.startswith("_"): ! ## print "\t", n, getattr(attr, n) for i in range(tlib.GetTypeInfoCount()): --- 23,29 ---- self.failUnlessEqual(tlib, other_tlib) ! ## for n in dir(attr): ! ## if not n.startswith("_"): ! ## print "\t", n, getattr(attr, n) for i in range(tlib.GetTypeInfoCount()): |
From: Thomas H. <th...@us...> - 2005-08-03 10:03:41
|
Update of /cvsroot/ctypes/ctypes/comtypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19278 Modified Files: Tag: branch_1_0 typeinfo.py Log Message: Several fixes. Implement ITypeLib.IsName. Index: typeinfo.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/typeinfo.py,v retrieving revision 1.3.2.5 retrieving revision 1.3.2.6 diff -C2 -d -r1.3.2.5 -r1.3.2.6 *** typeinfo.py 28 Jul 2005 07:36:23 -0000 1.3.2.5 --- typeinfo.py 3 Aug 2005 10:03:32 -0000 1.3.2.6 *************** *** 218,223 **** # if the value is found. # XXX MUST BE FIXED! ! ## def IsName(self, name, lHashVal=0): ! ## "Check if there is type information for this name" def FindName(self, name, lHashVal=0): --- 218,234 ---- # if the value is found. # XXX MUST BE FIXED! ! def IsName(self, name, lHashVal=0): ! """Check if there is type information for this name. ! ! Returns the name with capitalization found in the type ! library, or None. ! """ ! from ctypes import create_unicode_buffer ! namebuf = create_unicode_buffer(name) ! found = BOOL() ! self.__com_IsName(namebuf, lHashVal, byref(found)) ! if found.value: ! return namebuf[:].split("\0", 1)[0] ! return None def FindName(self, name, lHashVal=0): *************** *** 230,233 **** --- 241,245 ---- if found.value: return memid.value, tinfo + return None ## def ReleaseTLibAttr(self, ptla): *************** *** 468,472 **** ICreateTypeLib._methods_ = [ # C:/Programme/gccxml/bin/Vc71/PlatformSDK/oaidl.h 2149 - # STDMETHOD(HRESULT, 'CreateTypeInfo', [LPOLESTR, TYPEKIND, POINTER(POINTER(ICreateTypeInfo))]), COMMETHOD([], HRESULT, 'CreateTypeInfo', (['in'], LPOLESTR, 'szName'), --- 480,483 ---- *************** *** 490,494 **** (['in'], UINT, 'index'), (['out'], POINTER(POINTER(ITypeInfo)))), ! COMMETHOD([], HRESULT, 'GetTypeInfoOfType', (['in'], UINT, 'index'), (['out'], POINTER(TYPEKIND))), --- 501,505 ---- (['in'], UINT, 'index'), (['out'], POINTER(POINTER(ITypeInfo)))), ! COMMETHOD([], HRESULT, 'GetTypeInfoType', (['in'], UINT, 'index'), (['out'], POINTER(TYPEKIND))), *************** *** 507,521 **** (['out'], POINTER(BSTR))), COMMETHOD([], HRESULT, 'IsName', ! # Strange. Marking this [in, out], and calling it with a string yields ! # TypeError: one character unicode string expected. ! # Marking it [in] accepts the string.?! ! # ! # Both are wrong, because IsName changes the case of the name ! # if it is found - so we must pass a mutable buffer. (['in', 'out'], LPOLESTR, 'name'), - ## (['in'], LPOLESTR, 'name'), (['in', 'optional'], DWORD, 'lHashVal', 0), (['out'], POINTER(BOOL))), ! STDMETHOD(HRESULT, 'FindName', [LPOLESTR, DWORD, POINTER(POINTER(ITypeInfo)), POINTER(MEMBERID), POINTER(USHORT)]), COMMETHOD([], HRESULT, 'ReleaseTLibAttr', (['in'], POINTER(TLIBATTR))) --- 518,532 ---- (['out'], POINTER(BSTR))), COMMETHOD([], HRESULT, 'IsName', ! # IsName changes the casing of the passed in name to ! # match that in the type library. In the automatically ! # wrapped version of this method, ctypes would pass a ! # Python unicode string which would then be changed - ! # very bad. So we have (see above) to implement the ! # IsName method manually. (['in', 'out'], LPOLESTR, 'name'), (['in', 'optional'], DWORD, 'lHashVal', 0), (['out'], POINTER(BOOL))), ! STDMETHOD(HRESULT, 'FindName', [LPOLESTR, DWORD, POINTER(POINTER(ITypeInfo)), ! POINTER(MEMBERID), POINTER(USHORT)]), COMMETHOD([], HRESULT, 'ReleaseTLibAttr', (['in'], POINTER(TLIBATTR))) |
From: Thomas H. <th...@us...> - 2005-08-03 10:02:52
|
Update of /cvsroot/ctypes/ctypes/comtypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19092 Modified Files: Tag: branch_1_0 client.py Log Message: Cleanup. Index: client.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/Attic/client.py,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -C2 -d -r1.1.2.3 -r1.1.2.4 *** client.py 28 Jul 2005 08:48:45 -0000 1.1.2.3 --- client.py 3 Aug 2005 10:02:38 -0000 1.1.2.4 *************** *** 2,6 **** '''High level client level COM support module. ! CreateObject(progid, clsctx=CLSCTX_SERVER, friendly_name=None) Create a COM object, generating the Python typelibrary wrapper on --- 2,6 ---- '''High level client level COM support module. ! CreateObject(progid, machine=None, clsctx=None, friendly_name=None) Create a COM object, generating the Python typelibrary wrapper on *************** *** 9,12 **** --- 9,15 ---- + wrap(comobj, friendly_name=None) + + make_module(typelib, friendly_name=None) *************** *** 81,86 **** from ctypes import * ! from comtypes import GUID, CoCreateInstance ! from comtypes import CLSCTX_INPROC_SERVER, CLSCTX_LOCAL_SERVER, CLSCTX_SERVER from comtypes.automation import IDispatch from comtypes.typeinfo import IProvideClassInfo, LoadTypeLibEx, LoadRegTypeLib --- 84,88 ---- from ctypes import * ! from comtypes import GUID, CoCreateInstance, CoCreateInstanceEx from comtypes.automation import IDispatch from comtypes.typeinfo import IProvideClassInfo, LoadTypeLibEx, LoadRegTypeLib *************** *** 123,133 **** # Hm, couldn'w we directly look for the .py or .pyc/.pyo files? name, rest = fullname.split(".", 1) ! file, pathname, desc = imp.find_module(name) ! if file: ! file.close() for name in rest.split("."): ! file, pathname, desc = imp.find_module(name, [pathname]) ! if file: ! file.close() def _name_module(tlib): --- 125,135 ---- # Hm, couldn'w we directly look for the .py or .pyc/.pyo files? name, rest = fullname.split(".", 1) ! file_, pathname, desc = imp.find_module(name) ! if file_: ! file_.close() for name in rest.split("."): ! file_, pathname, desc = imp.find_module(name, [pathname]) ! if file_: ! file_.close() def _name_module(tlib): *************** *** 220,224 **** try: return _my_import(fullname) ! except Exception, detail: # we could not import the module. What was the reason? try: --- 222,226 ---- try: return _my_import(fullname) ! except Exception: # we could not import the module. What was the reason? try: *************** *** 307,311 **** def CreateObject(progid, ! clsctx=CLSCTX_SERVER, friendly_name=None): """Create a COM object from 'progid', and try to QueryInterface() --- 309,314 ---- def CreateObject(progid, ! machine=None, ! clsctx=None, friendly_name=None): """Create a COM object from 'progid', and try to QueryInterface() *************** *** 317,326 **** a _clsid_ attribute. 'clsctx' specifies how to create the object. 'friendly_name' allows to specify a readable alias name for the typelib wrapper. """ if hasattr(progid, '_clsid_'): - ## if hasattr(progid, "_com_interfaces_"): - ## interface = progid._com_interfaces_[0] - # XXX Something like the above progid = progid._clsid_ if isinstance(progid, GUID): --- 320,327 ---- a _clsid_ attribute. 'clsctx' specifies how to create the object. + 'machine' allows to specify a remote machine to create the object on. 'friendly_name' allows to specify a readable alias name for the typelib wrapper. """ if hasattr(progid, '_clsid_'): progid = progid._clsid_ if isinstance(progid, GUID): *************** *** 333,340 **** else: raise TypeError, progid ! punk = CoCreateInstance(clsid, clsctx=clsctx) ! ## if interface: ! ## # don't wrap if a specific interface was requested ! ## return punk return wrap(punk, friendly_name) --- 334,341 ---- else: raise TypeError, progid ! if machine is None: ! punk = CoCreateInstance(clsid, clsctx=clsctx) ! else: ! punk = CoCreateInstanceEx(clsid, clsctx=clsctx, machine=machine) return wrap(punk, friendly_name) |
From: Thomas H. <th...@us...> - 2005-08-03 10:01:58
|
Update of /cvsroot/ctypes/ctypes/comtypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18879 Modified Files: Tag: branch_1_0 __init__.py Log Message: Fix pychecker warning. Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/__init__.py,v retrieving revision 1.25.2.20 retrieving revision 1.25.2.21 diff -C2 -d -r1.25.2.20 -r1.25.2.21 *** __init__.py 3 Aug 2005 08:57:17 -0000 1.25.2.20 --- __init__.py 3 Aug 2005 10:01:47 -0000 1.25.2.21 *************** *** 541,545 **** try: result = mth(index) ! except WindowsError, detail: raise IndexError, "invalid index" if not result: # we got a NULL com pointer --- 541,545 ---- try: result = mth(index) ! except WindowsError: raise IndexError, "invalid index" if not result: # we got a NULL com pointer |
From: Thomas H. <th...@us...> - 2005-08-03 08:57:26
|
Update of /cvsroot/ctypes/ctypes/comtypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7100 Modified Files: Tag: branch_1_0 __init__.py Log Message: Add CoCreateInstanceEx and related structures. Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/__init__.py,v retrieving revision 1.25.2.19 retrieving revision 1.25.2.20 diff -C2 -d -r1.25.2.19 -r1.25.2.20 *** __init__.py 29 Jul 2005 19:19:15 -0000 1.25.2.19 --- __init__.py 3 Aug 2005 08:57:17 -0000 1.25.2.20 *************** *** 581,595 **** ################################################################ ! def CoCreateInstance(clsid, interface=IUnknown, clsctx=CLSCTX_ALL, punkouter=None): """The basic windows api to create a COM class object and return a pointer to an interface. """ p = POINTER(interface)() iid = interface._iid_ ! CoCreateInstance._api_(byref(clsid), punkouter, clsctx, byref(iid), byref(p)) return p ! CoCreateInstance = stdcall(HRESULT, 'ole32', ! [POINTER(IID), POINTER(IUnknown), c_ulong, ! POINTER(IID), POINTER(c_void_p)]) (CoCreateInstance) ################################################################ --- 581,630 ---- ################################################################ ! def CoCreateInstance(clsid, interface=IUnknown, clsctx=None, punkouter=None): """The basic windows api to create a COM class object and return a pointer to an interface. """ + if clsctx is None: + clsctx = CLSCTX_ALL p = POINTER(interface)() iid = interface._iid_ ! _ole32.CoCreateInstance(byref(clsid), punkouter, clsctx, byref(iid), byref(p)) return p ! ! class MULTI_QI(Structure): ! _fields_ = [("pIID", POINTER(GUID)), ! ("pItf", POINTER(c_void_p)), ! ("hr", HRESULT)] ! ! class COSERVERINFO(Structure): ! _fields_ = [("dwReserved1", c_ulong), ! ("pwszName", c_wchar_p), ! ("pAuthInfo", c_void_p), # wrong! ! ("dwReserved2", c_ulong)] ! ! def CoCreateInstanceEx(clsid, interface=IUnknown, ! clsctx=None, ! machine=None): ! """The basic windows api to create a COM class object and return a ! pointer to an interface, possibly on another machine. ! """ ! if clsctx is None: ! clsctx=CLSCTX_LOCAL_SERVER|CLSCTX_REMOTE_SERVER ! if machine: ! serverinfo = COSERVERINFO() ! serverinfo.pwszName = machine ! psi = byref(serverinfo) ! else: ! psi = None ! multiqi = MULTI_QI() ! multiqi.pIID = pointer(interface._iid_) ! _ole32.CoCreateInstanceEx(byref(clsid), ! None, ! clsctx, ! psi, ! 1, ! byref(multiqi)) ! return cast(multiqi.pItf, POINTER(interface)) ! ################################################################ |
From: Thomas H. <th...@us...> - 2005-08-02 18:01:07
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2679 Modified Files: Tag: branch_1_0 _ctypes.c callproc.c Log Message: Implement a mode flag, based on a patch from Mike Fletcher. Index: callproc.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callproc.c,v retrieving revision 1.127.2.5 retrieving revision 1.127.2.6 diff -C2 -d -r1.127.2.5 -r1.127.2.6 *** callproc.c 19 Apr 2005 13:06:34 -0000 1.127.2.5 --- callproc.c 2 Aug 2005 18:00:56 -0000 1.127.2.6 *************** *** 972,977 **** { char *name; HMODULE hMod; ! if (!PyArg_ParseTuple(args, "s:LoadLibrary", &name)) return NULL; hMod = LoadLibrary(name); --- 972,978 ---- { char *name; + PyObject *ignored; HMODULE hMod; ! if (!PyArg_ParseTuple(args, "s|O:LoadLibrary", &name, &ignored)) return NULL; hMod = LoadLibrary(name); *************** *** 1092,1097 **** int mode = RTLD_NOW; #endif ! if (!PyArg_ParseTuple(args, "z:dlopen", &name)) return NULL; handle = dlopen(name, mode); if (!handle) { --- 1093,1099 ---- int mode = RTLD_NOW; #endif ! if (!PyArg_ParseTuple(args, "z|i:dlopen", &name, &mode)) return NULL; + mode |= RTLD_NOW; handle = dlopen(name, mode); if (!handle) { *************** *** 1504,1508 **** {"_check_HRESULT", check_hresult, METH_VARARGS}, #else ! {"dlopen", py_dl_open, METH_VARARGS, "dlopen a library"}, {"dlclose", py_dl_close, METH_VARARGS, "dlclose a library"}, {"dlsym", py_dl_sym, METH_VARARGS, "find symbol in shared library"}, --- 1506,1511 ---- {"_check_HRESULT", check_hresult, METH_VARARGS}, #else ! {"dlopen", py_dl_open, METH_VARARGS, ! "dlopen(name, flag={RTLD_GLOBAL|RTLD_LOCAL}) open a shared library"}, {"dlclose", py_dl_close, METH_VARARGS, "dlclose a library"}, {"dlsym", py_dl_sym, METH_VARARGS, "find symbol in shared library"}, Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.226.2.15 retrieving revision 1.226.2.16 diff -C2 -d -r1.226.2.15 -r1.226.2.16 *** _ctypes.c 28 Jul 2005 08:57:10 -0000 1.226.2.15 --- _ctypes.c 2 Aug 2005 18:00:52 -0000 1.226.2.16 *************** *** 3988,3991 **** --- 3988,3996 ---- PyModule_AddObject(m, "FUNCFLAG_PYTHONAPI", PyInt_FromLong(FUNCFLAG_PYTHONAPI)); PyModule_AddStringConstant(m, "__version__", "0.9.8"); + + #ifdef RTLD_LOCAL + PyModule_AddObject(m, "RTLD_LOCAL", PyInt_FromLong(RTLD_LOCAL)); + PyModule_AddObject(m, "RTLD_GLOBAL", PyInt_FromLong(RTLD_GLOBAL)); + #endif PyExc_ArgError = PyErr_NewException("ctypes.ArgumentError", NULL, NULL); |
From: Thomas H. <th...@us...> - 2005-08-01 11:21:59
|
Update of /cvsroot/ctypes/ctypes/comtypes/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2717 Modified Files: Tag: branch_1_0 codegenerator.py Log Message: Generate docstrings for custom interfaces. Index: codegenerator.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/tools/codegenerator.py,v retrieving revision 1.6.2.15 retrieving revision 1.6.2.16 diff -C2 -d -r1.6.2.15 -r1.6.2.16 *** codegenerator.py 1 Aug 2005 10:46:27 -0000 1.6.2.15 --- codegenerator.py 1 Aug 2005 11:21:51 -0000 1.6.2.16 *************** *** 177,180 **** --- 177,185 ---- self.need_GUID() print >> self.stream, "class %s(%s):" % (head.itf.name, basename) + doc = getattr(head.itf, "doc", None) + if doc: + doc = doc.split("\0")[0] + if doc: + print >> self.stream, " %r" % doc print >> self.stream, " _iid_ = GUID(%r)" % head.itf.iid print >> self.stream, " _idlflags_ = %s" % head.itf.idlflags |
From: Thomas H. <th...@us...> - 2005-08-01 11:18:22
|
Update of /cvsroot/ctypes/ctypes/comtypes/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1909 Modified Files: Tag: branch_1_0 tlbparser.py Log Message: Docstrings for custom interfaces. Index: tlbparser.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/tools/tlbparser.py,v retrieving revision 1.4.2.14 retrieving revision 1.4.2.15 diff -C2 -d -r1.4.2.14 -r1.4.2.15 *** tlbparser.py 1 Aug 2005 10:45:21 -0000 1.4.2.14 --- tlbparser.py 1 Aug 2005 11:18:11 -0000 1.4.2.15 *************** *** 197,201 **** # TKIND_INTERFACE = 3 def ParseInterface(self, tinfo, ta): ! itf_name, doc = tinfo.GetDocumentation(-1)[0:2] assert ta.cImplTypes <= 1 --- 197,201 ---- # TKIND_INTERFACE = 3 def ParseInterface(self, tinfo, ta): ! itf_name, itf_doc = tinfo.GetDocumentation(-1)[0:2] assert ta.cImplTypes <= 1 *************** *** 212,215 **** --- 212,217 ---- iid=str(ta.guid), idlflags=self.interface_type_flags(ta.wTypeFlags)) + if itf_doc: + itf.doc = itf_doc self._register(itf_name, itf) |
From: Thomas H. <th...@us...> - 2005-08-01 11:11:32
|
Update of /cvsroot/ctypes/ctypes/comtypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv514 Modified Files: Tag: branch_1_0 .cvsignore Log Message: Ignore the comtypes\gen subdirectory. Index: .cvsignore =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/.cvsignore,v retrieving revision 1.1.4.1 retrieving revision 1.1.4.2 diff -C2 -d -r1.1.4.1 -r1.1.4.2 *** .cvsignore 1 Jul 2005 08:29:59 -0000 1.1.4.1 --- .cvsignore 1 Aug 2005 11:10:47 -0000 1.1.4.2 *************** *** 3,4 **** --- 3,5 ---- build dist + gen |
From: Thomas H. <th...@us...> - 2005-08-01 10:46:42
|
Update of /cvsroot/ctypes/ctypes/comtypes/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27890 Modified Files: Tag: branch_1_0 codegenerator.py Log Message: Some typelibs pass the wrong lengths of BSTR. Chop them off at the first NUL character. Index: codegenerator.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/tools/codegenerator.py,v retrieving revision 1.6.2.14 retrieving revision 1.6.2.15 diff -C2 -d -r1.6.2.14 -r1.6.2.15 *** codegenerator.py 29 Jul 2005 19:53:19 -0000 1.6.2.14 --- codegenerator.py 1 Aug 2005 10:46:27 -0000 1.6.2.15 *************** *** 19,23 **** class helpstring(object): def __init__(self, text): ! self.text = text def __repr__(self): --- 19,23 ---- class helpstring(object): def __init__(self, text): ! self.text = text.split("\0")[0] def __repr__(self): *************** *** 139,142 **** --- 139,144 ---- doc = getattr(coclass, "doc", None) if doc: + doc = doc.split("\0")[0] + if doc: print >> self.stream, " %r" % doc print >> self.stream, " _clsid_ = GUID(%r)" % coclass.clsid *************** *** 243,246 **** --- 245,250 ---- doc = getattr(head.itf, "doc", None) if doc: + doc = doc.split("\0")[0] + if doc: print >> self.stream, " %r" % doc print >> self.stream, " _iid_ = GUID(%r)" % head.itf.iid |
From: Thomas H. <th...@us...> - 2005-08-01 10:45:34
|
Update of /cvsroot/ctypes/ctypes/comtypes/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27648 Modified Files: Tag: branch_1_0 tlbparser.py Log Message: Don't convert unicode doc strings to ascii. Index: tlbparser.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/tools/tlbparser.py,v retrieving revision 1.4.2.13 retrieving revision 1.4.2.14 diff -C2 -d -r1.4.2.13 -r1.4.2.14 *** tlbparser.py 29 Jul 2005 19:46:34 -0000 1.4.2.13 --- tlbparser.py 1 Aug 2005 10:45:21 -0000 1.4.2.14 *************** *** 119,123 **** def ParseEnum(self, tinfo, ta): ta = tinfo.GetTypeAttr() ! enum_name, doc, helpcntext, helpfile = tinfo.GetDocumentation(-1) enum = typedesc.Enumeration(enum_name, 32, 32) self._register(enum_name, enum) --- 119,123 ---- def ParseEnum(self, tinfo, ta): ta = tinfo.GetTypeAttr() ! enum_name = tinfo.GetDocumentation(-1)[0] enum = typedesc.Enumeration(enum_name, 32, 32) self._register(enum_name, enum) *************** *** 416,420 **** coclass = typedesc.CoClass(coclass_name, str(ta.guid), self.coclass_type_flags(ta.wTypeFlags)) if doc is not None: ! coclass.doc = str(doc) self._register(coclass_name, coclass) --- 416,420 ---- coclass = typedesc.CoClass(coclass_name, str(ta.guid), self.coclass_type_flags(ta.wTypeFlags)) if doc is not None: ! coclass.doc = doc self._register(coclass_name, coclass) |
From: Thomas H. <th...@us...> - 2005-07-29 19:53:27
|
Update of /cvsroot/ctypes/ctypes/comtypes/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15921 Modified Files: Tag: branch_1_0 codegenerator.py Log Message: Remove debug print. Index: codegenerator.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/tools/codegenerator.py,v retrieving revision 1.6.2.13 retrieving revision 1.6.2.14 diff -C2 -d -r1.6.2.13 -r1.6.2.14 *** codegenerator.py 29 Jul 2005 19:47:34 -0000 1.6.2.13 --- codegenerator.py 29 Jul 2005 19:53:19 -0000 1.6.2.14 *************** *** 292,297 **** arglist = [] for typ, name, idlflags, default in m.arguments: - if 'optional' in idlflags and default is None: - print idlflags if 'lcid' in idlflags:# and 'in' in idlflags: default = lcid --- 292,295 ---- |
From: Thomas H. <th...@us...> - 2005-07-29 19:47:43
|
Update of /cvsroot/ctypes/ctypes/comtypes/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14714 Modified Files: Tag: branch_1_0 codegenerator.py Log Message: Add helpstrings to the generated typelib wrappers. Index: codegenerator.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/tools/codegenerator.py,v retrieving revision 1.6.2.12 retrieving revision 1.6.2.13 diff -C2 -d -r1.6.2.12 -r1.6.2.13 *** codegenerator.py 28 Jul 2005 07:37:56 -0000 1.6.2.12 --- codegenerator.py 29 Jul 2005 19:47:34 -0000 1.6.2.13 *************** *** 17,20 **** --- 17,27 ---- return "dispid(%s)" % self.memid + class helpstring(object): + def __init__(self, text): + self.text = text + + def __repr__(self): + return "helpstring(%r)" % self.text + class Generator(ctypes.wrap.codegenerator.Generator): *************** *** 62,70 **** self._dispid_defined = True _DISPMETHOD_defined = False def need_DISPMETHOD(self): if self._DISPMETHOD_defined: return ! print >> self.imports, "from comtypes import DISPMETHOD, DISPPROPERTY" self._DISPMETHOD_defined = True --- 69,83 ---- self._dispid_defined = True + def need_COMMETHOD(self): + if self._COMMETHOD_defined: + return + print >> self.imports, "from comtypes import helpstring" + super(Generator, self).need_COMMETHOD() + _DISPMETHOD_defined = False def need_DISPMETHOD(self): if self._DISPMETHOD_defined: return ! print >> self.imports, "from comtypes import DISPMETHOD, DISPPROPERTY, helpstring" self._DISPMETHOD_defined = True *************** *** 265,268 **** --- 278,283 ---- # typ, name, idlflags, default idlflags = [dispid(m.memid)] + m.idlflags + if m.doc: + idlflags.insert(1, helpstring(m.doc)) code = " COMMETHOD(%r, %s, '%s'" % ( idlflags, *************** *** 277,281 **** arglist = [] for typ, name, idlflags, default in m.arguments: ! if 'lcid' in idlflags and 'in' in idlflags: default = lcid if default is not None: --- 292,298 ---- arglist = [] for typ, name, idlflags, default in m.arguments: ! if 'optional' in idlflags and default is None: ! print idlflags ! if 'lcid' in idlflags:# and 'in' in idlflags: default = lcid if default is not None: *************** *** 294,300 **** def make_DispMethod(self, m): # typ, name, idlflags, default code = " DISPMETHOD(%r, %s, '%s'" % ( ! [m.dispid] + m.idlflags, self.type_name(m.returns), m.name) --- 311,320 ---- def make_DispMethod(self, m): + idlflags = [dispid(m.dispid)] + m.idlflags + if m.doc: + idlflags.insert(1, helpstring(m.doc)) # typ, name, idlflags, default code = " DISPMETHOD(%r, %s, '%s'" % ( ! idlflags, self.type_name(m.returns), m.name) *************** *** 323,328 **** def make_DispProperty(self, prop): print >> self.stream, " DISPPROPERTY(%r, %s, '%s')," % ( ! [prop.dispid] + prop.idlflags, self.type_name(prop.typ), prop.name) --- 343,351 ---- def make_DispProperty(self, prop): + idlflags = [dispid(prop.dispid)] + prop.idlflags + if prop.doc: + idlflags.insert(1, helpstring(prop.doc)) print >> self.stream, " DISPPROPERTY(%r, %s, '%s')," % ( ! idlflags, self.type_name(prop.typ), prop.name) |
From: Thomas H. <th...@us...> - 2005-07-29 19:46:42
|
Update of /cvsroot/ctypes/ctypes/comtypes/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14475 Modified Files: Tag: branch_1_0 tlbparser.py Log Message: Add doc parameter to DispMethod, DispProperty, and ComMethod constructor. Index: tlbparser.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/tools/tlbparser.py,v retrieving revision 1.4.2.12 retrieving revision 1.4.2.13 diff -C2 -d -r1.4.2.12 -r1.4.2.13 *** tlbparser.py 28 Jul 2005 07:43:33 -0000 1.4.2.12 --- tlbparser.py 29 Jul 2005 19:46:34 -0000 1.4.2.13 *************** *** 218,222 **** for i in range(ta.cFuncs): fd = tinfo.GetFuncDesc(i) ! func_name = tinfo.GetDocumentation(fd.memid)[0] returns = self.make_type(fd.elemdescFunc.tdesc, tinfo) names = tinfo.GetNames(fd.memid, fd.cParams+1) --- 218,223 ---- for i in range(ta.cFuncs): fd = tinfo.GetFuncDesc(i) ! ## func_name = tinfo.GetDocumentation(fd.memid)[0] ! func_name, func_doc = tinfo.GetDocumentation(fd.memid)[:2] returns = self.make_type(fd.elemdescFunc.tdesc, tinfo) names = tinfo.GetNames(fd.memid, fd.cParams+1) *************** *** 226,230 **** flags = self.func_flags(fd.wFuncFlags) flags += self.inv_kind(fd.invkind) ! mth = typedesc.ComMethod(fd.invkind, fd.memid, func_name, returns, flags) for p in range(fd.cParams): typ = self.make_type(fd.lprgelemdescParam[p].tdesc, tinfo) --- 227,231 ---- flags = self.func_flags(fd.wFuncFlags) flags += self.inv_kind(fd.invkind) ! mth = typedesc.ComMethod(fd.invkind, fd.memid, func_name, returns, flags, func_doc) for p in range(fd.cParams): typ = self.make_type(fd.lprgelemdescParam[p].tdesc, tinfo) *************** *** 266,273 **** vd = tinfo.GetVarDesc(i) assert vd.varkind == typeinfo.VAR_DISPATCH ! var_name, doc = tinfo.GetDocumentation(vd.memid)[0:2] typ = self.make_type(vd.elemdescVar.tdesc, tinfo) ! mth = typedesc.DispProperty(vd.memid, var_name, typ, self.var_flags(vd.wVarFlags)) ! mth.doc = str(doc) itf.members.append(mth) --- 267,273 ---- vd = tinfo.GetVarDesc(i) assert vd.varkind == typeinfo.VAR_DISPATCH ! var_name, var_doc = tinfo.GetDocumentation(vd.memid)[0:2] typ = self.make_type(vd.elemdescVar.tdesc, tinfo) ! mth = typedesc.DispProperty(vd.memid, var_name, typ, self.var_flags(vd.wVarFlags), var_doc) itf.members.append(mth) *************** *** 284,288 **** for i in range(basemethods, ta.cFuncs): fd = tinfo.GetFuncDesc(i) ! func_name = tinfo.GetDocumentation(fd.memid)[0] assert func_name not in ("QueryInterface", "AddRef", "Release") --- 284,288 ---- for i in range(basemethods, ta.cFuncs): fd = tinfo.GetFuncDesc(i) ! func_name, func_doc = tinfo.GetDocumentation(fd.memid)[:2] assert func_name not in ("QueryInterface", "AddRef", "Release") *************** *** 295,302 **** flags = self.func_flags(fd.wFuncFlags) flags += self.inv_kind(fd.invkind) ! mth = typedesc.DispMethod(fd.memid, fd.invkind, func_name, returns, flags) ! doc = tinfo.GetDocumentation(fd.memid)[1] ! if doc is not None: ! mth.doc = str(doc) for p in range(fd.cParams): typ = self.make_type(fd.lprgelemdescParam[p].tdesc, tinfo) --- 295,299 ---- flags = self.func_flags(fd.wFuncFlags) flags += self.inv_kind(fd.invkind) ! mth = typedesc.DispMethod(fd.memid, fd.invkind, func_name, returns, flags, func_doc) for p in range(fd.cParams): typ = self.make_type(fd.lprgelemdescParam[p].tdesc, tinfo) |