[ctypes-commit] ctypes/comtypes automation.py,1.12.2.9,1.12.2.10
Brought to you by:
theller
From: Thomas H. <th...@us...> - 2005-07-28 08:47:27
|
Update of /cvsroot/ctypes/ctypes/comtypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28478 Modified Files: Tag: branch_1_0 automation.py Log Message: Implement __repr__ for VARIANT and EXCEPINFO. Retrieving NULL VT_UNKNOWN and VT_DISPATCH fields from a VARIANT now return None. Not sure that this is the right thing to do, but the code generation needs this. Fix the next() method of IEnumVARIANT. Fix the IDispatch.Invoke() method. Index: automation.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/automation.py,v retrieving revision 1.12.2.9 retrieving revision 1.12.2.10 diff -C2 -d -r1.12.2.9 -r1.12.2.10 *** automation.py 7 Jul 2005 14:34:14 -0000 1.12.2.9 --- automation.py 28 Jul 2005 08:47:19 -0000 1.12.2.10 *************** *** 146,149 **** --- 146,152 ---- self.value = args[0] + def __repr__(self): + return "VARIANT(%r)" % self.value + def from_param(cls, value): return cls(value) *************** *** 238,247 **** return self._.VT_CY / 10000. elif vt == VT_UNKNOWN: ! ptr = cast(self._.c_void_p, POINTER(IUnknown)).__ctypes_from_outparam__() # cast doesn't call AddRef (it should, imo!) ptr.AddRef() return ptr elif vt == VT_DISPATCH: ! ptr = cast(self._.c_void_p, POINTER(IDispatch)).__ctypes_from_outparam__() # cast doesn't call AddRef (it should, imo!) ptr.AddRef() --- 241,259 ---- return self._.VT_CY / 10000. elif vt == VT_UNKNOWN: ! val = self._.c_void_p ! if not val: ! # We should/could return a NULL COM pointer. ! # But the code generation must be able to construct one ! # from the __repr__ of it. ! return None # XXX? ! ptr = cast(val, POINTER(IUnknown)).__ctypes_from_outparam__() # cast doesn't call AddRef (it should, imo!) ptr.AddRef() return ptr elif vt == VT_DISPATCH: ! val = self._.c_void_p ! if not val: ! return None # XXX? ! ptr = cast(val, POINTER(IDispatch)).__ctypes_from_outparam__() # cast doesn't call AddRef (it should, imo!) ptr.AddRef() *************** *** 305,308 **** --- 317,321 ---- return arg return pointer(VARIANT(arg)) + POINTER(VARIANT).from_param = classmethod(_from_param) del _from_param *************** *** 327,331 **** self.Reset() self.Skip(index) ! fetched = self.Next(1) if fetched: return var.value --- 340,344 ---- self.Reset() self.Skip(index) ! fetched = self.Next(1, byref(var)) if fetched: return var.value *************** *** 352,356 **** class tagEXCEPINFO(Structure): ! pass tagEXCEPINFO._fields_ = [ ('wCode', WORD), --- 365,372 ---- class tagEXCEPINFO(Structure): ! def __repr__(self): ! return "<EXCEPINFO %s %s %s %s>" % \ ! (self.bstrSource, self.bstrDescription, self.pfnDeferredFillIn, ! bool(self.pfnDeferredFillIn)) tagEXCEPINFO._fields_ = [ ('wCode', WORD), *************** *** 361,365 **** ('dwHelpContext', DWORD), ('pvReserved', c_void_p), ! ('pfnDeferredFillIn', WINFUNCTYPE(HRESULT, POINTER(tagEXCEPINFO))), ('scode', SCODE), ] --- 377,382 ---- ('dwHelpContext', DWORD), ('pvReserved', c_void_p), ! ## ('pfnDeferredFillIn', WINFUNCTYPE(HRESULT, POINTER(tagEXCEPINFO))), ! ('pfnDeferredFillIn', c_void_p), ('scode', SCODE), ] *************** *** 433,442 **** if _invkind == DISPATCH_METHOD: dp = DISPPARAMS() dp.cArgs = len(args) dp.cNamedArgs = 0 ! dp.rgvarg = (VARIANT * len(args))() ! for i, a in enumerate(args): ! dp.rgvarg[len(args) - i - 1].value = a elif _invkind == DISPATCH_PROPERTYGET: --- 450,461 ---- if _invkind == DISPATCH_METHOD: + array = (VARIANT * len(args))() + for i, a in enumerate(args): + array[len(args) - i - 1].value = a + dp = DISPPARAMS() dp.cArgs = len(args) dp.cNamedArgs = 0 ! dp.rgvarg = array elif _invkind == DISPATCH_PROPERTYGET: *************** *** 463,466 **** --- 482,487 ---- # signed integers, although in C the HRESULT values are # normally written in hex notation. + print "ARGERR", argerr + print excepinfo raise |