ctypes-commit Mailing List for ctypes (Page 47)
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-06-03 17:56:43
|
Update of /cvsroot/ctypes/ctypes/win32/com In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12672 Modified Files: Tag: branch_1_0 connectionpoints.py Log Message: In Fire_Event, which calls IDispatch::Invoke, the parameters must be packed in reverse direction into the DISPPARAMS rgvarg array. Index: connectionpoints.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/win32/com/connectionpoints.py,v retrieving revision 1.10.4.1 retrieving revision 1.10.4.2 diff -C2 -d -r1.10.4.1 -r1.10.4.2 *** connectionpoints.py 6 May 2005 09:56:12 -0000 1.10.4.1 --- connectionpoints.py 3 Jun 2005 17:56:32 -0000 1.10.4.2 *************** *** 117,126 **** memid = c_int() self._typeinfo.GetIDsOfNames(byref(c_wchar_p(name)), 1, byref(memid)) for p in self._connections.values(): params = DISPPARAMS() ! params.cArgs = len(args) ! rgvarg = params.rgvarg = (VARIANT * len(args))() for i, a in enumerate(args): ! rgvarg[i].value = a p.Invoke(memid.value, byref(GUID()), --- 117,127 ---- memid = c_int() self._typeinfo.GetIDsOfNames(byref(c_wchar_p(name)), 1, byref(memid)) + len_args = len(args) for p in self._connections.values(): params = DISPPARAMS() ! cArgs = params.cArgs = len(args) ! rgvarg = params.rgvarg = (VARIANT * len_args)() for i, a in enumerate(args): ! rgvarg[len_args - i - 1].value = a p.Invoke(memid.value, byref(GUID()), *************** *** 133,138 **** return S_OK - - ################################################################ # A Base class for events delivered to a dispinterface --- 134,137 ---- |
From: Thomas H. <th...@us...> - 2005-06-03 17:53:41
|
Update of /cvsroot/ctypes/ctypes/win32/com In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11395 Modified Files: Tag: branch_1_0 automation.py Log Message: Rearrange some safearray code. Index: automation.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/win32/com/automation.py,v retrieving revision 1.21.2.2 retrieving revision 1.21.2.3 diff -C2 -d -r1.21.2.2 -r1.21.2.3 *** automation.py 6 May 2005 09:58:43 -0000 1.21.2.2 --- automation.py 3 Jun 2005 17:53:22 -0000 1.21.2.3 *************** *** 404,407 **** --- 404,412 ---- self.vt = VT_DATE self._.VT_R8 = com_days + elif typ in (list, tuple, array.array): + self._.VT_I4 = _CreateVector(value) + self.vt = VT_ARRAY | VT_VARIANT + elif type(typ) is type(c_int * 0): + raise "NYI" else: raise TypeError, "don't know how to store %r in a VARIANT" % value *************** *** 473,506 **** raise "NYI" elif self.vt & VT_ARRAY: ! TYPECODE = { ! 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, ! } ! ! # idea: use a LONG array (array.array('l') ! # to specify indices? ! # requires buffer support for function calls ! psa = self._.VT_I4 ! dim = oleaut32.SafeArrayGetDim(psa) ! assert dim == 1 ! lb, ub = c_long(), c_long() ! oleaut32.SafeArrayGetLBound(psa, 1, byref(lb)) ! oleaut32.SafeArrayGetUBound(psa, 1, byref(ub)) ! ix = c_long() ! data = TYPECODE[self.vt & ~VT_ARRAY]() ! result = [] ! for i in range(lb.value, ub.value+1): ! ix.value = i ! oleaut32.SafeArrayGetElement(psa, byref(ix), byref(data)) ! result.append(data.value) ! return result else: raise TypeError, "don't know how to convert typecode %d" % self.vt --- 478,482 ---- raise "NYI" elif self.vt & VT_ARRAY: ! return _DecodeArray(self._.voidp, self.vt & ~VT_ARRAY) else: raise TypeError, "don't know how to convert typecode %d" % self.vt *************** *** 537,540 **** --- 513,577 ---- ################################################################ + def _CreateVector(seq): + # create a one dimensional SAFEARRAY of type VT_VARIANT + sab = SAFEARRAYBOUND(len(seq), -3) # lower bound always 0 + psa = oleaut32.SafeArrayCreate(VT_VARIANT, 1, byref(sab)) + ix = c_long() + item = VARIANT() + for index, v in enumerate(seq): + ix.value = index -3 + item.value = v + oleaut32.SafeArrayPutElement(psa, byref(ix), byref(item)) + # Hm, whya can't the VARIANT clear itself? + item.value = None + return psa + + + VT_2_CTYPE = { + 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 _DecodeArray(psa, vt): + # idea: use a LONG array (array.array('l') + # to specify indices? + # requires buffer support for function calls + dim = oleaut32.SafeArrayGetDim(psa) + assert dim == 1 + lb, ub = c_long(), c_long() + oleaut32.SafeArrayGetLBound(psa, 1, byref(lb)) + oleaut32.SafeArrayGetUBound(psa, 1, byref(ub)) + + if (vt & ~VT_ARRAY) == VT_INT: + ARR = c_int * (ub.value+1 - lb.value) + arr = ARR() + ptr = c_void_p() + oleaut32.SafeArrayAccessData(psa, byref(ptr)) + memmove(arr, ptr, sizeof(arr)) + oleaut32.SafeArrayUnaccessData(psa) + return arr[:] + + ix = c_long() + data = VT_2_CTYPE[vt & ~VT_ARRAY]() + result = [] + for i in range(lb.value, ub.value+1): + ix.value = i + oleaut32.SafeArrayGetElement(psa, byref(ix), byref(data)) + result.append(data.value) + if vt == VT_VARIANT: + data.value = None + return result + + + ################################################################ class DISPPARAMS(Structure): *************** *** 914,918 **** # test code ! if __debug__: if __name__ == "__main__": print repr(VARIANT("String").value) --- 951,955 ---- # test code ! if 0 and __debug__: if __name__ == "__main__": print repr(VARIANT("String").value) *************** *** 950,951 **** --- 987,998 ---- else: print i, repr(dst.value) + + if __name__ == "__main__": + ## import sys + arr = (c_int * 3)(1, 2, 3) + ## print len(arr) + ## print dim(arr) + v = VARIANT() + v.value = array.array("i", (1, 2, 3)) + v.value = arr + print v.value |
From: Thomas H. <th...@us...> - 2005-06-03 09:51:38
|
Update of /cvsroot/ctypes/ctypes/comtypes/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25928 Modified Files: Tag: branch_1_0 tlbparser.py Log Message: Different TYPEFLAGS values meaningful for coclasses and interfaces. Index: tlbparser.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/tools/tlbparser.py,v retrieving revision 1.4.2.1 retrieving revision 1.4.2.2 diff -C2 -d -r1.4.2.1 -r1.4.2.2 *** tlbparser.py 2 Jun 2005 12:32:58 -0000 1.4.2.1 --- tlbparser.py 3 Jun 2005 09:51:18 -0000 1.4.2.2 *************** *** 213,217 **** base=base, iid=str(ta.guid), ! idlflags=self.type_flags(ta.wTypeFlags)) self.items[itf_name] = itf --- 213,217 ---- base=base, iid=str(ta.guid), ! idlflags=self.interface_type_flags(ta.wTypeFlags)) self.items[itf_name] = itf *************** *** 257,261 **** base=base, iid=str(ta.guid), ! idlflags=self.type_flags(ta.wTypeFlags)) itf.doc = str(doc) self.items[itf_name] = itf --- 257,261 ---- base=base, iid=str(ta.guid), ! idlflags=self.interface_type_flags(ta.wTypeFlags)) itf.doc = str(doc) self.items[itf_name] = itf *************** *** 344,348 **** return [NAMES[bit] for bit in NAMES if bit & flags] ! def type_flags(self, flags): # map TYPEFLAGS values to idl attributes NAMES = {typeinfo.TYPEFLAG_FAPPOBJECT: "appobject", --- 344,348 ---- return [NAMES[bit] for bit in NAMES if bit & flags] ! def coclass_type_flags(self, flags): # map TYPEFLAGS values to idl attributes NAMES = {typeinfo.TYPEFLAG_FAPPOBJECT: "appobject", *************** *** 366,369 **** --- 366,391 ---- [NEGATIVE_NAMES[bit] for bit in NEGATIVE_NAMES if not (bit & flags)] + def interface_type_flags(self, flags): + # map TYPEFLAGS values to idl attributes + NAMES = {typeinfo.TYPEFLAG_FAPPOBJECT: "appobject", + # typeinfo.TYPEFLAG_FCANCREATE: + typeinfo.TYPEFLAG_FLICENSED: "licensed", + # typeinfo.TYPEFLAG_FPREDECLID: + typeinfo.TYPEFLAG_FHIDDEN: "hidden", + typeinfo.TYPEFLAG_FCONTROL: "control", + typeinfo.TYPEFLAG_FDUAL: "dual", + typeinfo.TYPEFLAG_FNONEXTENSIBLE: "nonextensible", + typeinfo.TYPEFLAG_FOLEAUTOMATION: "oleautomation", + typeinfo.TYPEFLAG_FRESTRICTED: "restricted", + typeinfo.TYPEFLAG_FAGGREGATABLE: "aggregatable", + # typeinfo.TYPEFLAG_FREPLACEABLE: + # typeinfo.TYPEFLAG_FDISPATCHABLE # computed, no flag for this + typeinfo.TYPEFLAG_FREVERSEBIND: "reversebind", + typeinfo.TYPEFLAG_FPROXY: "proxy", + } + NEGATIVE_NAMES = {} + return [NAMES[bit] for bit in NAMES if bit & flags] + \ + [NEGATIVE_NAMES[bit] for bit in NEGATIVE_NAMES if not (bit & flags)] + def var_flags(self, flags): NAMES = {typeinfo.VARFLAG_FREADONLY: "readonly", *************** *** 389,393 **** # version, control, hidden, and appobject coclass_name, doc = tinfo.GetDocumentation(-1)[0:2] ! coclass = typedesc.CoClass(coclass_name, str(ta.guid), self.type_flags(ta.wTypeFlags)) if doc is not None: coclass.doc = str(doc) --- 411,415 ---- # version, control, hidden, and appobject coclass_name, doc = tinfo.GetDocumentation(-1)[0:2] ! coclass = typedesc.CoClass(coclass_name, str(ta.guid), self.coclass_type_flags(ta.wTypeFlags)) if doc is not None: coclass.doc = str(doc) |
From: Thomas H. <th...@us...> - 2005-06-03 09:49:50
|
Update of /cvsroot/ctypes/ctypes/comtypes/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25052 Modified Files: Tag: branch_1_0 codegenerator.py Log Message: Generate DISPMETHOD code. Index: codegenerator.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/tools/codegenerator.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 *** codegenerator.py 2 Jun 2005 12:14:27 -0000 1.6.2.1 --- codegenerator.py 3 Jun 2005 09:49:30 -0000 1.6.2.2 *************** *** 42,45 **** --- 42,52 ---- self._dispid_defined = True + _DISPMETHOD_defined = False + def need_DISPMETHOD(self): + if self._DISPMETHOD_defined: + return + print >> self.imports, "from comtypes import DISPMETHOD" + self._DISPMETHOD_defined = True + ################################################################ # top-level typedesc generators *************** *** 137,142 **** raise TypeError, m - print >> self.stream, "%s._methods_ = [" % body.itf.name self.need_dispid() for m in body.itf.members: if isinstance(m, typedesc.DispMethod): --- 144,150 ---- raise TypeError, m self.need_dispid() + self.need_DISPMETHOD() + print >> self.stream, "%s._methods_ = [" % body.itf.name for m in body.itf.members: if isinstance(m, typedesc.DispMethod): |
From: Thomas H. <th...@us...> - 2005-06-03 09:48:45
|
Update of /cvsroot/ctypes/ctypes/comtypes/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24512 Added Files: Tag: branch_1_0 __init__.py Log Message: Make comtypes.tools a package. --- NEW FILE: __init__.py --- # the comtypes.tools package |
From: Thomas H. <th...@us...> - 2005-06-03 09:48:05
|
Update of /cvsroot/ctypes/ctypes/comtypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24200 Modified Files: Tag: branch_1_0 automation.py Log Message: Make VARIANT available in the comtypes module, without making comtypes dependend on comtypes.automation. Index: automation.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/automation.py,v retrieving revision 1.12.2.2 retrieving revision 1.12.2.3 diff -C2 -d -r1.12.2.2 -r1.12.2.3 *** automation.py 3 Jun 2005 07:27:31 -0000 1.12.2.2 --- automation.py 3 Jun 2005 09:47:56 -0000 1.12.2.3 *************** *** 266,269 **** --- 266,275 ---- VARIANTARG = VARIANT + # Hack alert. Make the VARIANT type available in the comtypes module, + # once comtypes.automation has been imported. See comment in + # comtypes\__init__.py. + import comtypes + comtypes._VARIANT_type_hack = VARIANT + # A little magic. Override the default .from_param classmethod of # POINTER(VARIANT). This allows to pass values which can be stored in |
From: Thomas H. <th...@us...> - 2005-06-03 09:44:56
|
Update of /cvsroot/ctypes/ctypes/comtypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22746 Modified Files: Tag: branch_1_0 __init__.py Log Message: Better handling of 'optional' parameters. Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/__init__.py,v retrieving revision 1.25.2.3 retrieving revision 1.25.2.4 diff -C2 -d -r1.25.2.3 -r1.25.2.4 *** __init__.py 3 Jun 2005 07:26:39 -0000 1.25.2.3 --- __init__.py 3 Jun 2005 09:44:44 -0000 1.25.2.4 *************** *** 1,4 **** --- 1,8 ---- # requires ctypes 0.9.3 or later import new + import warnings + + class IDLWarning(UserWarning): + pass try: *************** *** 388,393 **** if "optional" in idl: if defval is _NOTHING: ! # It's not nice to import VARIANT here! ! from comtypes.automation import VARIANT if typ is VARIANT: defval = VARIANT() --- 392,402 ---- if "optional" in idl: if defval is _NOTHING: ! # XXX We don't want to make this module import ! # comtypes.automation but we need VARIANT. So ! # comtypes.automation sets it from the outside into ! # this module, when it is imported. Hack, hack. ! # ! # XXX Should probably use a different name, so that it ! # can't be imported from this module by accident. if typ is VARIANT: defval = VARIANT() *************** *** 395,399 **** defval = pointer(VARIANT()) else: ! raise TypeError, "idl flag 'optional' only allowed for VARIANT and VARIANT*" paramflags.append((pflags, argname, defval)) else: --- 404,411 ---- defval = pointer(VARIANT()) else: ! msg = "'optional' only allowed for VARIANT and VARIANT*, not for %s" \ ! % typ.__name__ ! warnings.warn(msg, IDLWarning, stacklevel=2) ! defval = typ() paramflags.append((pflags, argname, defval)) else: |
From: Thomas H. <th...@us...> - 2005-06-03 07:27:51
|
Update of /cvsroot/ctypes/ctypes/comtypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12116 Modified Files: Tag: branch_1_0 automation.py Log Message: A little magic. Override the default .from_param classmethod of POINTER(VARIANT). This allows to pass values which can be stored in VARIANTs as function parameters declared as POINTER(VARIANT). See InternetExplorer's Navigate method, for example. Index: automation.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/automation.py,v retrieving revision 1.12.2.1 retrieving revision 1.12.2.2 diff -C2 -d -r1.12.2.1 -r1.12.2.2 *** automation.py 2 Jun 2005 13:15:39 -0000 1.12.2.1 --- automation.py 3 Jun 2005 07:27:31 -0000 1.12.2.2 *************** *** 266,269 **** --- 266,280 ---- VARIANTARG = VARIANT + # A little magic. Override the default .from_param classmethod of + # POINTER(VARIANT). This allows to pass values which can be stored in + # VARIANTs as function parameters declared as POINTER(VARIANT). + # See InternetExplorer's Navigate method, for example. + def _from_param(self, arg): + if isinstance(arg, POINTER(VARIANT)): + return arg + return pointer(VARIANT(arg)) + POINTER(VARIANT).from_param = classmethod(_from_param) + del _from_param + ##from _ctypes import VARIANT_set ##import new |
From: Thomas H. <th...@us...> - 2005-06-03 07:27:01
|
Update of /cvsroot/ctypes/ctypes/comtypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11538 Modified Files: Tag: branch_1_0 __init__.py Log Message: Add DISPMETHOD so that generated code can be imported - it will not work yet, though. Use the default parameter values from generated code. Make sure that 'optional' is only used for VARIANT and VARIANT* - that's what MSDN requires (although in practice MIDL only generates a warning if you use other types). Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/__init__.py,v retrieving revision 1.25.2.2 retrieving revision 1.25.2.3 diff -C2 -d -r1.25.2.2 -r1.25.2.3 *** __init__.py 2 Jun 2005 11:57:46 -0000 1.25.2.2 --- __init__.py 3 Jun 2005 07:26:39 -0000 1.25.2.3 *************** *** 300,303 **** --- 300,305 ---- "out": 2, "retval": 8, + "optional": 16, + # PARAMFLAG_HASDEFAULT: 0x20 } *************** *** 307,310 **** --- 309,321 ---- return result & 3 # that's what _ctypes accept + def DISPMETHOD(idlflags, restype, name, *argspec): + # XXX WRONG WRONG WRONG + return COMMETHOD(idlflags, restype, name, *argspec) + + _NOTHING = object() + def _unpack_argspec(idl, typ, name=None, defval=_NOTHING): + return idl, typ, name, defval + + def COMMETHOD(idlflags, restype, methodname, *argspec): "Specifies a COM method slot with idlflags" *************** *** 312,318 **** argtypes = [] - def unpack(idl, typ, name=None): - return idl, typ, name - # collect all helpstring instances helptext = [t.text for t in idlflags if isinstance(t, helpstring)] --- 323,326 ---- *************** *** 376,384 **** # for item in argspec: ! idl, typ, argname = unpack(*item) pflags = encode_idl(idl) ! if 2 & pflags: ! rettype = typ._type_ ! paramflags.append((pflags, argname)) argtypes.append(typ) if "propget" in idlflags: --- 384,402 ---- # for item in argspec: ! idl, typ, argname, defval = _unpack_argspec(*item) pflags = encode_idl(idl) ! if "optional" in idl: ! if defval is _NOTHING: ! # It's not nice to import VARIANT here! ! from comtypes.automation import VARIANT ! if typ is VARIANT: ! defval = VARIANT() ! elif typ is POINTER(VARIANT): ! defval = pointer(VARIANT()) ! else: ! raise TypeError, "idl flag 'optional' only allowed for VARIANT and VARIANT*" ! paramflags.append((pflags, argname, defval)) ! else: ! paramflags.append((pflags, argname)) argtypes.append(typ) if "propget" in idlflags: |
From: Thomas H. <th...@us...> - 2005-06-02 13:15:48
|
Update of /cvsroot/ctypes/ctypes/comtypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24172 Modified Files: Tag: branch_1_0 automation.py Log Message: Some SAFEARRAY support. Index: automation.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/automation.py,v retrieving revision 1.12 retrieving revision 1.12.2.1 diff -C2 -d -r1.12 -r1.12.2.1 *** automation.py 16 Mar 2005 12:29:32 -0000 1.12 --- automation.py 2 Jun 2005 13:15:39 -0000 1.12.2.1 *************** *** 1,4 **** # comtypes.automation module - from ctypes import * from _ctypes import CopyComPointer --- 1,3 ---- *************** *** 413,416 **** --- 412,419 ---- } + def _midlSAFEARRAY(aType): + from comtypes.sa import SAFEARRAY + return POINTER(SAFEARRAY) + ################################################################ |
From: Thomas H. <th...@us...> - 2005-06-02 12:33:45
|
Update of /cvsroot/ctypes/ctypes/ctypes/wrap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2642 Modified Files: Tag: branch_1_0 codegenerator.py Log Message: Fix some pychecker warnings. Index: codegenerator.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/wrap/codegenerator.py,v retrieving revision 1.6 retrieving revision 1.6.2.1 diff -C2 -d -r1.6 -r1.6.2.1 *** codegenerator.py 16 Mar 2005 07:51:19 -0000 1.6 --- codegenerator.py 2 Jun 2005 12:33:35 -0000 1.6.2.1 *************** *** 3,6 **** --- 3,9 ---- # $Log$ + # Revision 1.6.2.1 2005/06/02 12:33:35 theller + # Fix some pychecker warnings. + # # Revision 1.6 2005/03/16 07:51:19 theller # _COMMETHOD_defined was never set to True. *************** *** 35,42 **** from sets import Set as set ! try: ! import cStringIO as StringIO ! except ImportError: ! import StringIO --- 38,45 ---- from sets import Set as set ! ##try: ! ## import cStringIO as StringIO ! ##except ImportError: ! ## import StringIO *************** *** 384,387 **** --- 387,391 ---- except (TypeError, ValueError), detail: print "Could not init", tp.name, tp.init, detail + ## raise return print >> self.stream, \ *************** *** 492,496 **** basename = body.struct.bases[0].name print >> self.stream, "%s._methods_ = %s._methods + [" % \ ! (body.struct.name, body.struct.bases[0].name) else: print >> self.stream, "%s._methods_ = [" % body.struct.name --- 496,500 ---- basename = body.struct.bases[0].name print >> self.stream, "%s._methods_ = %s._methods + [" % \ ! (body.struct.name, basename) else: print >> self.stream, "%s._methods_ = [" % body.struct.name |
From: Thomas H. <th...@us...> - 2005-06-02 12:33:06
|
Update of /cvsroot/ctypes/ctypes/comtypes/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2275 Modified Files: Tag: branch_1_0 tlbparser.py Log Message: Add some SAFEARRAY support. Emit dispid's for COMMETHOD. Generate typeflags for coclasses, handle 'noncreatable' correctly. Provide two toplevel classes, one for parsing TLB files, the other for parsing COM typelib pointers. Index: tlbparser.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/tools/tlbparser.py,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -C2 -d -r1.4 -r1.4.2.1 *** tlbparser.py 16 Mar 2005 14:25:12 -0000 1.4 --- tlbparser.py 2 Jun 2005 12:32:58 -0000 1.4.2.1 *************** *** 32,36 **** IDISPATCH_type = typedesc.Typedef("IDispatch", None) IUNKNOWN_type = typedesc.Typedef("IUnknown", None) ! SAFEARRAY_type = typedesc.Typedef("SAFEARRAY", None) # faked COM data types --- 32,38 ---- IDISPATCH_type = typedesc.Typedef("IDispatch", None) IUNKNOWN_type = typedesc.Typedef("IUnknown", None) ! ! def midlSAFEARRAY(typ): ! return typedesc.SAFEARRAYType(typ) # faked COM data types *************** *** 64,69 **** automation.VT_VOID: typedesc.FundamentalType("void", 0, 0), # 24 automation.VT_HRESULT: HRESULT_type, # 25 - # This is wrong. We must create separate SAFEARRAY(type) things. - # automation.VT_SAFEARRAY: SAFEARRAY_type, # 27 automation.VT_LPSTR: PTR(char_type), # 30 automation.VT_LPWSTR: PTR(wchar_t_type), # 31 --- 66,69 ---- *************** *** 71,74 **** --- 71,75 ---- #automation.VT_PTR = 26 # below + #automation.VT_SAFEARRAY = 27 #automation.VT_CARRAY = 28 # below #automation.VT_USERDEFINED = 29 # below *************** *** 81,90 **** ################################################################ ! class TlbParser(object): ! ! def __init__(self, path): ! self.tlib = typeinfo.LoadTypeLibEx(path, regkind=typeinfo.REGKIND_REGISTER) ! self.items = {} ! self.tlib.GetLibAttr() def make_type(self, tdesc, tinfo): --- 82,86 ---- ################################################################ ! class Parser(object): def make_type(self, tdesc, tinfo): *************** *** 113,122 **** elif tdesc.vt == automation.VT_SAFEARRAY: ! # SAFEARRAY(long), see Don Box pp.331f ! print "SAFEARRAY", tdesc._.lptdesc[0].vt ! raise "HALT" ! return SAFEARRAY_type - # VT_SAFEARRAY ??? raise "NYI", tdesc.vt --- 109,116 ---- elif tdesc.vt == automation.VT_SAFEARRAY: ! # SAFEARRAY(<type>), see Don Box pp.331f ! itemtype = self.make_type(tdesc._.lptdesc[0], tinfo) ! return midlSAFEARRAY(itemtype) raise "NYI", tdesc.vt *************** *** 219,223 **** base=base, iid=str(ta.guid), ! idlflags=self.idl_flags(ta.wTypeFlags)) self.items[itf_name] = itf --- 213,217 ---- base=base, iid=str(ta.guid), ! idlflags=self.type_flags(ta.wTypeFlags)) self.items[itf_name] = itf *************** *** 234,238 **** flags = self.func_flags(fd.wFuncFlags) flags += self.inv_kind(fd.invkind) ! mth = typedesc.ComMethod(fd.invkind, func_name, returns, flags) for p in range(fd.cParams): typ = self.make_type(fd.lprgelemdescParam[p].tdesc, tinfo) --- 228,232 ---- 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) *************** *** 263,267 **** base=base, iid=str(ta.guid), ! idlflags=self.idl_flags(ta.wTypeFlags)) itf.doc = str(doc) self.items[itf_name] = itf --- 257,261 ---- base=base, iid=str(ta.guid), ! idlflags=self.type_flags(ta.wTypeFlags)) itf.doc = str(doc) self.items[itf_name] = itf *************** *** 350,354 **** return [NAMES[bit] for bit in NAMES if bit & flags] ! def idl_flags(self, flags): # map TYPEFLAGS values to idl attributes NAMES = {typeinfo.TYPEFLAG_FAPPOBJECT: "appobject", --- 344,348 ---- return [NAMES[bit] for bit in NAMES if bit & flags] ! def type_flags(self, flags): # map TYPEFLAGS values to idl attributes NAMES = {typeinfo.TYPEFLAG_FAPPOBJECT: "appobject", *************** *** 368,372 **** typeinfo.TYPEFLAG_FPROXY: "proxy", } ! return [NAMES[bit] for bit in NAMES if bit & flags] def var_flags(self, flags): --- 362,368 ---- typeinfo.TYPEFLAG_FPROXY: "proxy", } ! NEGATIVE_NAMES = {typeinfo.TYPEFLAG_FCANCREATE: "noncreatable"} ! return [NAMES[bit] for bit in NAMES if bit & flags] + \ ! [NEGATIVE_NAMES[bit] for bit in NEGATIVE_NAMES if not (bit & flags)] def var_flags(self, flags): *************** *** 393,397 **** # version, control, hidden, and appobject coclass_name, doc = tinfo.GetDocumentation(-1)[0:2] ! coclass = typedesc.CoClass(coclass_name, str(ta.guid), self.idl_flags(ta.wTypeFlags)) if doc is not None: coclass.doc = str(doc) --- 389,393 ---- # version, control, hidden, and appobject coclass_name, doc = tinfo.GetDocumentation(-1)[0:2] ! coclass = typedesc.CoClass(coclass_name, str(ta.guid), self.type_flags(ta.wTypeFlags)) if doc is not None: coclass.doc = str(doc) *************** *** 483,486 **** --- 479,493 ---- return self.items + class TlbFileParser(Parser): + "Parses a type library from a file" + def __init__(self, path): + self.tlib = typeinfo.LoadTypeLibEx(path, regkind=typeinfo.REGKIND_REGISTER) + self.items = {} + + class TypeLibParser(Parser): + def __init__(self, tlib): + self.tlib = tlib + self.items = {} + ################################################################ *************** *** 490,499 **** # XXX infinite loop? ## path = r"mshtml.tlb" # has propputref # has SAFEARRAY ! ## path = "msscript.ocx" # has SAFEARRAY ## path = r"c:\Programme\Microsoft Office\Office\MSWORD8.OLB" # has propputref ! # has SAFEARRAY ## path = r"msi.dll" # DispProperty # fails packing IDLDESC ## path = r"C:\Dokumente und Einstellungen\thomas\Desktop\tlb\win.tlb" --- 497,513 ---- # XXX infinite loop? ## path = r"mshtml.tlb" # has propputref + # has SAFEARRAY ! # HRESULT Run(BSTR, SAFEARRAY(VARIANT)*, VARIANT*) ! path = "msscript.ocx" ! # has SAFEARRAY + # HRESULT AddAddress(SAFEARRAY(BSTR)*, SAFEARRAY(BSTR)*) ## path = r"c:\Programme\Microsoft Office\Office\MSWORD8.OLB" # has propputref ! ! # has SAFEARRAY: ! # SAFEARRAY(unsigned char) FileSignatureInfo(BSTR, long, MsiSignatureInfo) ## path = r"msi.dll" # DispProperty + # fails packing IDLDESC ## path = r"C:\Dokumente und Einstellungen\thomas\Desktop\tlb\win.tlb" *************** *** 517,522 **** ## path = r"C:\Dokumente und Einstellungen\thomas\Desktop\tlb\threadapi.tlb" known_symbols = {} ! for name in ("comtypes.automation", "comtypes", "ctypes"): mod = __import__(name) for submodule in name.split(".")[1:]: --- 531,540 ---- ## path = r"C:\Dokumente und Einstellungen\thomas\Desktop\tlb\threadapi.tlb" + ## path = r"..\samples\BITS\bits2_0.tlb" + + ## path = r"c:\vc98\include\activscp.tlb" + known_symbols = {} ! for name in ("comtypes.typeinfo", "comtypes.automation", "comtypes", "ctypes"): mod = __import__(name) for submodule in name.split(".")[1:]: *************** *** 525,529 **** known_symbols[name] = mod.__name__ ! p = TlbParser(path) items = p.parse() --- 543,547 ---- known_symbols[name] = mod.__name__ ! p = TlbFileParser(path) items = p.parse() *************** *** 537,540 **** gen.generate_code(items.values()) if __name__ == "__main__": ! main() --- 555,586 ---- gen.generate_code(items.values()) + def test(tlib, ofi): + known_symbols = {} + for name in ("comtypes.typeinfo", "comtypes.automation", "comtypes", "ctypes"): + mod = __import__(name) + for submodule in name.split(".")[1:]: + mod = getattr(mod, submodule) + for name in mod.__dict__: + known_symbols[name] = mod.__name__ + p = TypeLibParser(tlib) + + items = p.parse() + + from codegenerator import Generator + + gen = Generator(ofi, + use_decorators=True, + known_symbols=known_symbols, + ## searched_dlls=None, + ) + gen.generate_code(items.values()) + if __name__ == "__main__": ! if 1: ! main() ! else: ! from comtypes.typeinfo import LoadRegTypeLib ! from comtypes import GUID ! import sys ! tlib = LoadRegTypeLib(GUID("{6BC096BB-0CE6-11D1-BAAE-00C04FC2E20D}"), 1, 0) ! test(tlib, sys.stdout) |
From: Thomas H. <th...@us...> - 2005-06-02 12:15:37
|
Update of /cvsroot/ctypes/ctypes/comtypes/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25136 Modified Files: Tag: branch_1_0 typedesc.py Log Message: Add some SAFEARRAY support. Emit dispid's for COMMETHOD. Index: typedesc.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/tools/typedesc.py,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -C2 -d -r1.1 -r1.1.2.1 *** typedesc.py 4 Feb 2005 21:19:41 -0000 1.1 --- typedesc.py 2 Jun 2005 12:15:28 -0000 1.1.2.1 *************** *** 3,13 **** from ctypes.wrap.typedesc import * class ComMethod(object): # custom COM method, parsed from typelib ! def __init__(self, invkind, name, returns, idlflags): self.invkind = invkind self.name = name self.returns = returns self.idlflags = idlflags self.arguments = [] --- 3,18 ---- from ctypes.wrap.typedesc import * + class SAFEARRAYType(object): + def __init__(self, typ): + self.typ = typ + class ComMethod(object): # custom COM method, parsed from typelib ! def __init__(self, invkind, memid, name, returns, idlflags): self.invkind = invkind self.name = name self.returns = returns self.idlflags = idlflags + self.memid = memid self.arguments = [] |
From: Thomas H. <th...@us...> - 2005-06-02 12:14:42
|
Update of /cvsroot/ctypes/ctypes/comtypes/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24599 Modified Files: Tag: branch_1_0 codegenerator.py Log Message: Add some support for SAFEARRAY types. Add dispid. Add CoClass. Override the PointerType method, so that cominterface definitions are generated in the correct order. Fix some pychecker warnings. Index: codegenerator.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/tools/codegenerator.py,v retrieving revision 1.6 retrieving revision 1.6.2.1 diff -C2 -d -r1.6 -r1.6.2.1 *** codegenerator.py 16 Mar 2005 14:22:41 -0000 1.6 --- codegenerator.py 2 Jun 2005 12:14:27 -0000 1.6.2.1 *************** *** 5,15 **** --- 5,64 ---- import ctypes.wrap.codegenerator + class dispid(object): + def __init__(self, memid): + self.memid = memid + + def __repr__(self): + return "dispid(%s)" % self.memid + class Generator(ctypes.wrap.codegenerator.Generator): + def type_name(self, t, generate=True): + # Return a string, containing an expression which can be used to + # refer to the type. Assumes the * namespace is available. + if isinstance(t, typedesc.SAFEARRAYType): + return "_midlSAFEARRAY(%s)" % self.type_name(t.typ) + return super(Generator, self).type_name(t, generate) + + _midlSAFEARRAY_defined = False + def need_midlSAFEARRAY(self): + if self._midlSAFEARRAY_defined: + return + print >> self.imports, "from comtypes.automation import _midlSAFEARRAY" + self._midlSAFEARRAY_defined = True + + _CoClass_defined = False + def need_CoClass(self): + if self._CoClass_defined: + return + print >> self.imports, "from comtypes import CoClass" + self._CoClass_defined = True + + _dispid_defined = False + def need_dispid(self): + if self._dispid_defined: + return + print >> self.imports, "from comtypes import dispid" + self._dispid_defined = True + ################################################################ # top-level typedesc generators # + def SAFEARRAYType(self, sa): + self.generate(sa.typ) + self.need_midlSAFEARRAY() + + def PointerType(self, tp): + if type(tp.typ) is typedesc.ComInterface: + # this defines the class + self.generate(tp.typ.get_head()) + # this defines the _methods_ + self.more.add(tp.typ) + else: + super(Generator, self).PointerType(tp) + def CoClass(self, coclass): self.need_GUID() + self.need_CoClass() print >> self.stream, "class %s(CoClass):" % coclass.name doc = getattr(coclass, "doc", None) *************** *** 23,27 **** if i[1] & 2 == 0] sources = [i[0].name for i in coclass.interfaces ! if i[1] & 2] if implemented: print >> self.stream, "%s._com_interfaces_ = [%s]" % (coclass.name, ", ".join(implemented)) --- 72,76 ---- if i[1] & 2 == 0] sources = [i[0].name for i in coclass.interfaces ! if i[1] & 2 == 2] if implemented: print >> self.stream, "%s._com_interfaces_ = [%s]" % (coclass.name, ", ".join(implemented)) *************** *** 51,54 **** --- 100,104 ---- self.need_COMMETHOD() + self.need_dispid() print >> self.stream, "%s._methods_ = [" % body.itf.name for m in body.itf.members: *************** *** 88,91 **** --- 138,142 ---- print >> self.stream, "%s._methods_ = [" % body.itf.name + self.need_dispid() for m in body.itf.members: if isinstance(m, typedesc.DispMethod): *************** *** 102,107 **** def make_ComMethod(self, m): # typ, name, idlflags, default code = " COMMETHOD(%r, %s, '%s'" % ( ! m.idlflags, self.type_name(m.returns), m.name) --- 153,159 ---- def make_ComMethod(self, m): # typ, name, idlflags, default + idlflags = [dispid(m.memid)] + m.idlflags code = " COMMETHOD(%r, %s, '%s'" % ( ! idlflags, self.type_name(m.returns), m.name) |
From: Thomas H. <th...@us...> - 2005-06-02 12:07:26
|
Update of /cvsroot/ctypes/ctypes/comtypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21231 Modified Files: Tag: branch_1_0 typeinfo.py Log Message: Add __repr__ methods to TLIBATTR and TYPEATTR types. Add IProvideClassInfo and IProvideClassInfo2 interfaces. Index: typeinfo.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/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 *** typeinfo.py 11 May 2005 12:49:36 -0000 1.3.2.1 --- typeinfo.py 2 Jun 2005 12:07:16 -0000 1.3.2.2 *************** *** 4,11 **** import weakref - # Should probably be changed to use COMMETHOD! - from ctypes import * from comtypes import STDMETHOD from comtypes import _GUID, GUID from comtypes.automation import BSTR --- 4,10 ---- import weakref from ctypes import * from comtypes import STDMETHOD + from comtypes import COMMETHOD from comtypes import _GUID, GUID from comtypes.automation import BSTR *************** *** 467,477 **** class tagTLIBATTR(Structure): # C:/Programme/gccxml/bin/Vc71/PlatformSDK/oaidl.h 4437 ! pass TLIBATTR = tagTLIBATTR class tagTYPEATTR(Structure): # C:/Programme/gccxml/bin/Vc71/PlatformSDK/oaidl.h 672 ! pass TYPEATTR = tagTYPEATTR class tagFUNCDESC(Structure): # C:/Programme/gccxml/bin/Vc71/PlatformSDK/oaidl.h 769 --- 466,481 ---- class tagTLIBATTR(Structure): # C:/Programme/gccxml/bin/Vc71/PlatformSDK/oaidl.h 4437 ! def __repr__(self): ! return "TLIBATTR(GUID=%s, Version=%s.%s, LCID=%s, FLags=0x%x)" % \ ! (self.guid, self.wMajorVerNum, self.wMinorVerNum, self.lcid, self.wLibFlags) TLIBATTR = tagTLIBATTR class tagTYPEATTR(Structure): # C:/Programme/gccxml/bin/Vc71/PlatformSDK/oaidl.h 672 ! def __repr__(self): ! return "TYPEATTR(GUID=%s, typekind=%s, funcs=%s, vars=%s, impltypes=%s)" % \ ! (self.guid, self.typekind, self.cFuncs, self.cVars, self.cImplTypes) TYPEATTR = tagTYPEATTR + class tagFUNCDESC(Structure): # C:/Programme/gccxml/bin/Vc71/PlatformSDK/oaidl.h 769 *************** *** 592,595 **** --- 596,615 ---- ] + class IProvideClassInfo(IUnknown): + _iid_ = GUID("{B196B283-BAB4-101A-B69C-00AA00341D07}") + _methods_ = [ + COMMETHOD([], HRESULT, "GetClassInfo", + ( ['out'], POINTER(POINTER(ITypeInfo)), "ppTI" ) ) + ] + + class IProvideClassInfo2(IProvideClassInfo): + _iid_ = GUID("{A6BC3AC0-DBAA-11CE-9DE3-00AA004BB851}") + _methods_ = [ + COMMETHOD([], HRESULT, "GetGUID", + ( ['in'], DWORD, "dwGuidKind" ), + ( ['out', 'retval'], POINTER(GUID), "pGUID" )) + ] + + ################################################################ # Structure fields *************** *** 772,773 **** --- 792,794 ---- assert sizeof(tagARRAYDESC) == 20, sizeof(tagARRAYDESC) assert alignment(tagARRAYDESC) == 4, alignment(tagARRAYDESC) + |
From: Thomas H. <th...@us...> - 2005-06-02 11:58:00
|
Update of /cvsroot/ctypes/ctypes/comtypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16032 Modified Files: Tag: branch_1_0 __init__.py Log Message: Add CoClass and dispid (for generated wrappers). Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/__init__.py,v retrieving revision 1.25.2.1 retrieving revision 1.25.2.2 diff -C2 -d -r1.25.2.1 -r1.25.2.2 *** __init__.py 29 Apr 2005 20:28:12 -0000 1.25.2.1 --- __init__.py 2 Jun 2005 11:57:46 -0000 1.25.2.2 *************** *** 291,294 **** --- 291,297 ---- self.value = value + class dispid(int): + pass + ################################################################ *************** *** 438,443 **** ################ ! ##class CoClass(object): ! ## # creation, and so on ## def create_instance(self): --- 441,449 ---- ################ ! class CoClass(object): ! "pass" ! ! ! # creation, and so on ## def create_instance(self): |
From: Thomas H. <th...@us...> - 2005-05-20 20:19:10
|
Update of /cvsroot/ctypes/ctypes/win32/com In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21164 Modified Files: Tag: branch_1_0 shelllink.py Log Message: Correct SetIDList argument types. Index: shelllink.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/win32/com/shelllink.py,v retrieving revision 1.2.4.1 retrieving revision 1.2.4.2 diff -C2 -d -r1.2.4.1 -r1.2.4.2 *** shelllink.py 18 May 2005 07:04:40 -0000 1.2.4.1 --- shelllink.py 20 May 2005 20:18:50 -0000 1.2.4.2 *************** *** 16,20 **** STDMETHOD(HRESULT, "GetPath", LPSTR, c_int, POINTER(WIN32_FIND_DATAA), DWORD), STDMETHOD(HRESULT, "GetIDList", POINTER(POINTER(ITEMIDLIST))), ! STDMETHOD(HRESULT, "SetIDList", POINTER(POINTER(ITEMIDLIST))), STDMETHOD(HRESULT, "GetDescription", LPSTR, c_int), STDMETHOD(HRESULT, "SetDescription", LPCSTR), --- 16,20 ---- STDMETHOD(HRESULT, "GetPath", LPSTR, c_int, POINTER(WIN32_FIND_DATAA), DWORD), STDMETHOD(HRESULT, "GetIDList", POINTER(POINTER(ITEMIDLIST))), ! STDMETHOD(HRESULT, "SetIDList", POINTER(ITEMIDLIST)), STDMETHOD(HRESULT, "GetDescription", LPSTR, c_int), STDMETHOD(HRESULT, "SetDescription", LPCSTR), *************** *** 41,45 **** STDMETHOD(HRESULT, "GetPath", LPWSTR, c_int, POINTER(WIN32_FIND_DATAA), DWORD), STDMETHOD(HRESULT, "GetIDList", POINTER(POINTER(ITEMIDLIST))), ! STDMETHOD(HRESULT, "SetIDList", POINTER(POINTER(ITEMIDLIST))), STDMETHOD(HRESULT, "GetDescription", LPWSTR, c_int), STDMETHOD(HRESULT, "SetDescription", LPCWSTR), --- 41,45 ---- STDMETHOD(HRESULT, "GetPath", LPWSTR, c_int, POINTER(WIN32_FIND_DATAA), DWORD), STDMETHOD(HRESULT, "GetIDList", POINTER(POINTER(ITEMIDLIST))), ! STDMETHOD(HRESULT, "SetIDList", POINTER(ITEMIDLIST)), STDMETHOD(HRESULT, "GetDescription", LPWSTR, c_int), STDMETHOD(HRESULT, "SetDescription", LPCWSTR), |
From: Thomas H. <th...@us...> - 2005-05-20 20:14:47
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20086 Modified Files: Tag: branch_1_0 ChangeLog Log Message: Index: ChangeLog =================================================================== RCS file: /cvsroot/ctypes/ctypes/ChangeLog,v retrieving revision 1.86.2.7 retrieving revision 1.86.2.8 diff -C2 -d -r1.86.2.7 -r1.86.2.8 *** ChangeLog 16 May 2005 23:29:19 -0000 1.86.2.7 --- ChangeLog 20 May 2005 20:14:36 -0000 1.86.2.8 *************** *** 1,6 **** --- 1,18 ---- + 2005-05-20 Thomas Heller <th...@py...> + + * source\_ctypes.c: Also don't call __new__ when a ctypes instance + is created from a base object. + 2005-05-17 Andreas Degert <ad...@pa...> * source/gcc, README.txt: merged with HEAD + 2005-05-11 Thomas Heller <th...@py...> + + * source\_ctypes.c (CData_FromBaseObj): Don't call __init__, only + __new__, when a ctypes instance is retrieved from a base object. + This avoids confusion when structure fields containing structures + (for example) are accessed. + 2005-05-06 Thomas Heller <th...@py...> *************** *** 71,79 **** Juan Carlos Coruna. ! * ctypes.wrap.h2xml script: Added two command line options to ! include preprocessor symbols into the xml file (the was the ! default before), and to not delete temporary files which may help ! locating problems in the compilation. The latter was suggested by ! 'Bryan' on the ctypes-users list. Expanded the default excluded symbols list on Windows, so that --- 83,91 ---- Juan Carlos Coruna. ! * ctypes.wrap.h2xml script: Added command line options to include ! preprocessor symbols into the xml file (that was the default ! before), and to not delete temporary files which may help locating ! problems in the compilation. The latter was suggested by 'Bryan' ! on the ctypes-users list. Expanded the default excluded symbols list on Windows, so that *************** *** 85,89 **** 2005-03-16 Thomas Heller <th...@py...> ! * ctypes\source\_ctyopes.c: Subclasses of c_char_p, c_wchar_p, and c_void_p were not able to override the from_param class method in their class definitions because SimpleType_new overwrote them. --- 97,101 ---- 2005-03-16 Thomas Heller <th...@py...> ! * ctypes\source\_ctypes.c: Subclasses of c_char_p, c_wchar_p, and c_void_p were not able to override the from_param class method in their class definitions because SimpleType_new overwrote them. |
From: Thomas H. <th...@us...> - 2005-05-20 20:09:28
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18721 Modified Files: Tag: branch_1_0 _ctypes.c Log Message: Don't call __new__ when creating a reference to a ctypes instance. Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.226.2.11 retrieving revision 1.226.2.12 diff -C2 -d -r1.226.2.11 -r1.226.2.12 *** _ctypes.c 19 May 2005 18:12:10 -0000 1.226.2.11 --- _ctypes.c 20 May 2005 20:09:18 -0000 1.226.2.12 *************** *** 1813,1831 **** obj->b_size = dict->size; } - - - static PyObject * - _type_new(PyObject *type, PyObject *args, PyObject *kwds) - { - static PyObject* empty_tuple; - if (!empty_tuple) - empty_tuple = PyTuple_New(0); - if (!PyType_Check(type)) { - PyErr_SetString(PyExc_TypeError, "BUG: expected a type object"); - return NULL; - } - return ((PyTypeObject *)type)->tp_new((PyTypeObject *)type, - args ? args : empty_tuple, kwds); - } static PyObject * --- 1813,1816 ---- *************** *** 1833,1864 **** { CDataObject *cmem; ! static PyObject *empty_tuple; ! ! if (empty_tuple == NULL) { ! empty_tuple = PyTuple_New(0); ! if (empty_tuple == NULL) ! return NULL; ! } ! if (base && !CDataObject_Check(base)) { PyErr_SetString(PyExc_TypeError, ! "expected a ctype type"); return NULL; } ! ! cmem = (CDataObject *)_type_new(type, NULL, NULL); if (cmem == NULL) return NULL; ! if (!CDataObject_Check(cmem)) { ! Py_DECREF(cmem); ! PyErr_SetString(PyExc_TypeError, ! "BUG: type call did not return a CDataObject"); ! return NULL; ! } ! if (cmem->b_needsfree) ! PyMem_Free(cmem->b_ptr); ! cmem->b_ptr = NULL; if (base) { /* use base's buffer */ cmem->b_ptr = adr; cmem->b_needsfree = 0; --- 1818,1839 ---- { CDataObject *cmem; ! StgDictObject *dict; ! assert(PyType_Check(type)); ! dict = PyType_stgdict(type); ! if (!dict) { PyErr_SetString(PyExc_TypeError, ! "abstract class"); return NULL; } ! dict->flags |= DICTFLAG_FINAL; ! cmem = (CDataObject *)((PyTypeObject *)type)->tp_alloc((PyTypeObject *)type, 0); if (cmem == NULL) return NULL; ! assert(CDataObject_Check(cmem)); ! cmem->b_length = dict->length; if (base) { /* use base's buffer */ + assert(CDataObject_Check(base)); cmem->b_ptr = adr; cmem->b_needsfree = 0; *************** *** 1867,1872 **** cmem->b_index = index; } else { /* copy contents of adr */ ! StgDictObject *dict = PyType_stgdict(type); ! CData_MallocBuffer(cmem, PyType_stgdict(type)); memcpy(cmem->b_ptr, adr, dict->size); cmem->b_index = index; --- 1842,1846 ---- cmem->b_index = index; } else { /* copy contents of adr */ ! CData_MallocBuffer(cmem, dict); memcpy(cmem->b_ptr, adr, dict->size); cmem->b_index = index; *************** *** 1877,1883 **** /* Box a memory block into a CData instance. - - We create an new instance, free the memory it contains, and fill in the - memory pointer afterwards. */ PyObject * --- 1851,1854 ---- *************** *** 1885,1903 **** { CDataObject *pd; ! pd = (CDataObject *)_type_new(type, NULL, NULL); ! if (!pd) ! return NULL; ! if (!CDataObject_Check(pd)) { ! Py_DECREF(pd); PyErr_SetString(PyExc_TypeError, ! "BUG: type call did not return a CDataObject"); return NULL; } ! if (pd->b_needsfree) { ! pd->b_needsfree = 0; ! PyMem_Free(pd->b_ptr); ! } pd->b_ptr = buf; return (PyObject *)pd; } --- 1856,1876 ---- { CDataObject *pd; + StgDictObject *dict; ! assert(PyType_Check(type)); ! dict = PyType_stgdict(type); ! if (!dict) { PyErr_SetString(PyExc_TypeError, ! "abstract class"); return NULL; } ! dict->flags |= DICTFLAG_FINAL; ! ! pd = (CDataObject *)((PyTypeObject *)type)->tp_alloc((PyTypeObject *)type, 0); ! if (!pd) ! return NULL; ! assert(CDataObject_Check(pd)); pd->b_ptr = buf; + pd->b_length = dict->length; return (PyObject *)pd; } *************** *** 2048,2052 **** { CDataObject *obj; - int length; StgDictObject *dict; --- 2021,2024 ---- *************** *** 2058,2062 **** } dict->flags |= DICTFLAG_FINAL; - length = dict->length; obj = (CDataObject *)type->tp_alloc(type, 0); --- 2030,2033 ---- *************** *** 2067,2071 **** obj->b_index = 0; obj->b_objects = NULL; ! obj->b_length = length; CData_MallocBuffer(obj, dict); --- 2038,2042 ---- obj->b_index = 0; obj->b_objects = NULL; ! obj->b_length = dict->length; CData_MallocBuffer(obj, dict); |
From: Thomas H. <th...@us...> - 2005-05-20 20:06:55
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18170 Modified Files: Tag: branch_1_0 test_init.py Log Message: Check that __new__ wasn't called. Index: test_init.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_init.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 *** test_init.py 11 May 2005 18:28:38 -0000 1.1.2.1 --- test_init.py 20 May 2005 20:06:47 -0000 1.1.2.2 *************** *** 5,8 **** --- 5,15 ---- _fields_ = [("a", c_int), ("b", c_int)] + new_was_called = False + + def __new__(cls): + result = super(X, cls).__new__(cls) + result.new_was_called = True + return result + def __init__(self): self.a = 9 *************** *** 16,29 **** def test_get(self): # make sure the only accessing a nested structure ! # doesn't call the structure's __init__ y = Y() self.failUnlessEqual((y.x.a, y.x.b), (0, 0)) ! # But explicitely creating an X structure calls __init__, of course. x = X() self.failUnlessEqual((x.a, x.b), (9, 12)) y.x = x self.failUnlessEqual((y.x.a, y.x.b), (9, 12)) if __name__ == "__main__": --- 23,39 ---- def test_get(self): # make sure the only accessing a nested structure ! # doesn't call the structure's __new__ and __init__ y = Y() self.failUnlessEqual((y.x.a, y.x.b), (0, 0)) + self.failUnlessEqual(y.x.new_was_called, False) ! # But explicitely creating an X structure calls __new__ and __init__, of course. x = X() self.failUnlessEqual((x.a, x.b), (9, 12)) + self.failUnlessEqual(x.new_was_called, True) y.x = x self.failUnlessEqual((y.x.a, y.x.b), (9, 12)) + self.failUnlessEqual(y.x.new_was_called, False) if __name__ == "__main__": |
From: Thomas H. <th...@us...> - 2005-05-19 18:12:25
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14039 Modified Files: Tag: branch_1_0 _ctypes.c Log Message: CData_AtAddress isn't declared static in source/ctypes.h. Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.226.2.10 retrieving revision 1.226.2.11 diff -C2 -d -r1.226.2.10 -r1.226.2.11 *** _ctypes.c 11 May 2005 18:56:28 -0000 1.226.2.10 --- _ctypes.c 19 May 2005 18:12:10 -0000 1.226.2.11 *************** *** 1881,1885 **** memory pointer afterwards. */ ! static PyObject * CData_AtAddress(PyObject *type, void *buf) { --- 1881,1885 ---- memory pointer afterwards. */ ! PyObject * CData_AtAddress(PyObject *type, void *buf) { |
From: Thomas H. <th...@us...> - 2005-05-18 07:12:07
|
Update of /cvsroot/ctypes/ctypes/win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3695 Modified Files: Tag: branch_1_0 wintypes.py Log Message: Add WIN32_FIND_DATAW Structure. Index: wintypes.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/win32/wintypes.py,v retrieving revision 1.8 retrieving revision 1.8.4.1 diff -C2 -d -r1.8 -r1.8.4.1 *** wintypes.py 23 Apr 2004 18:13:51 -0000 1.8 --- wintypes.py 18 May 2005 07:11:56 -0000 1.8.4.1 *************** *** 71,75 **** MAX_PATH = 260 - # there's also a unicode version of that class WIN32_FIND_DATAA(Structure): _fields_ = [("dwFileAttributes", DWORD), --- 71,74 ---- *************** *** 83,84 **** --- 82,95 ---- ("cFileName", c_char * MAX_PATH), ("cAlternameFileName", c_char * 14)] + + class WIN32_FIND_DATAW(Structure): + _fields_ = [("dwFileAttributes", DWORD), + ("ftCreationTime", FILETIME), + ("ftLastAccessTime", FILETIME), + ("ftLastWriteTime", FILETIME), + ("nFileSizeHigh", DWORD), + ("nFileSizeLow", DWORD), + ("dwReserved0", DWORD), + ("dwReserved1", DWORD), + ("cFileName", c_wchar * MAX_PATH), + ("cAlternameFileName", c_wchar * 14)] |
From: Thomas H. <th...@us...> - 2005-05-18 07:06:23
|
Update of /cvsroot/ctypes/ctypes/win32/com In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2389 Modified Files: Tag: branch_1_0 ChangeLog Log Message: *** empty log message *** Index: ChangeLog =================================================================== RCS file: /cvsroot/ctypes/ctypes/win32/com/ChangeLog,v retrieving revision 1.8.4.1 retrieving revision 1.8.4.2 diff -C2 -d -r1.8.4.1 -r1.8.4.2 *** ChangeLog 6 May 2005 12:17:55 -0000 1.8.4.1 --- ChangeLog 18 May 2005 07:06:00 -0000 1.8.4.2 *************** *** 1,2 **** --- 1,8 ---- + 2005-05-18 Thomas Heller <th...@py...> + + * ctypes/com/shelllink.py: Corrected the argument types for + IShellLink::GetIDList and IShellLink::SetIDList. Thanks to Jürgen + Urner. + 2005-05-06 Thomas Heller <th...@py...> |
From: Thomas H. <th...@us...> - 2005-05-18 07:05:04
|
Update of /cvsroot/ctypes/ctypes/win32/com In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2087 Modified Files: Tag: branch_1_0 shelllink.py Log Message: Corrected the argument types for IShellLink::GetIDList and IShellLink::SetIDList. Thanks to Jürgen Urner. Index: shelllink.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/win32/com/shelllink.py,v retrieving revision 1.2 retrieving revision 1.2.4.1 diff -C2 -d -r1.2 -r1.2.4.1 *** shelllink.py 20 Apr 2004 20:18:03 -0000 1.2 --- shelllink.py 18 May 2005 07:04:40 -0000 1.2.4.1 *************** *** 15,20 **** _methods_ = IUnknown._methods_ + [ STDMETHOD(HRESULT, "GetPath", LPSTR, c_int, POINTER(WIN32_FIND_DATAA), DWORD), ! STDMETHOD(HRESULT, "GetIDList", POINTER(ITEMIDLIST)), ! STDMETHOD(HRESULT, "SetIDList", POINTER(ITEMIDLIST)), STDMETHOD(HRESULT, "GetDescription", LPSTR, c_int), STDMETHOD(HRESULT, "SetDescription", LPCSTR), --- 15,20 ---- _methods_ = IUnknown._methods_ + [ STDMETHOD(HRESULT, "GetPath", LPSTR, c_int, POINTER(WIN32_FIND_DATAA), DWORD), ! STDMETHOD(HRESULT, "GetIDList", POINTER(POINTER(ITEMIDLIST))), ! STDMETHOD(HRESULT, "SetIDList", POINTER(POINTER(ITEMIDLIST))), STDMETHOD(HRESULT, "GetDescription", LPSTR, c_int), STDMETHOD(HRESULT, "SetDescription", LPCSTR), *************** *** 40,45 **** _methods_ = IUnknown._methods_ + [ STDMETHOD(HRESULT, "GetPath", LPWSTR, c_int, POINTER(WIN32_FIND_DATAA), DWORD), ! STDMETHOD(HRESULT, "GetIDList", POINTER(ITEMIDLIST)), ! STDMETHOD(HRESULT, "SetIDList", POINTER(ITEMIDLIST)), STDMETHOD(HRESULT, "GetDescription", LPWSTR, c_int), STDMETHOD(HRESULT, "SetDescription", LPCWSTR), --- 40,45 ---- _methods_ = IUnknown._methods_ + [ STDMETHOD(HRESULT, "GetPath", LPWSTR, c_int, POINTER(WIN32_FIND_DATAA), DWORD), ! STDMETHOD(HRESULT, "GetIDList", POINTER(POINTER(ITEMIDLIST))), ! STDMETHOD(HRESULT, "SetIDList", POINTER(POINTER(ITEMIDLIST))), STDMETHOD(HRESULT, "GetDescription", LPWSTR, c_int), STDMETHOD(HRESULT, "SetDescription", LPCWSTR), |
From: Andreas D. <ad...@us...> - 2005-05-17 02:57:58
|
Update of /cvsroot/ctypes/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6981/ctypes Added Files: util.py Log Message: added (platform dependent helpers) --- NEW FILE: util.py --- import os, re, tempfile if os.name == "posix": def findLib_gcc(name): expr = '[^\(\)\s]*lib%s\.[^\(\)\s]*' % name cmd = 'if type gcc &>/dev/null; then CC=gcc; else CC=cc; fi;' \ '$CC -Wl,-t -o /dev/null 2>&1 -l' + name try: fdout, outfile = tempfile.mkstemp() fd = os.popen(cmd) trace = fd.read() err = fd.close() finally: try: os.unlink(outfile) except OSError, e: if e.errno != errno.ENOENT: raise res = re.search(expr, trace) if not res: return None return res.group(0) def findLib_ld(name): expr = '/[^\(\)\s]*lib%s\.[^\(\)\s]*' % name res = re.search(expr, os.popen('/sbin/ldconfig -p 2>/dev/null').read()) if not res: return None return res.group(0) def get_soname(f): cmd = "objdump -p -j .dynamic 2>/dev/null " + f res = re.search(r'\sSONAME\s+([^\s]+)', os.popen(cmd).read()) if not res: return f return res.group(1) def findLib(name): lib = findLib_ld(name) if not lib: lib = findLib_gcc(name) if not lib: return [name] return [get_soname(lib)] |