[ctypes-commit] ctypes/comtypes __init__.py,1.25.2.6,1.25.2.7
Brought to you by:
theller
From: Thomas H. <th...@us...> - 2005-06-30 13:17:23
|
Update of /cvsroot/ctypes/ctypes/comtypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16255 Modified Files: Tag: branch_1_0 __init__.py Log Message: Slight reorg. CoClass derives from c_void_p, and ideas how to avoid this. Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/__init__.py,v retrieving revision 1.25.2.6 retrieving revision 1.25.2.7 diff -C2 -d -r1.25.2.6 -r1.25.2.7 *** __init__.py 10 Jun 2005 19:57:08 -0000 1.25.2.6 --- __init__.py 30 Jun 2005 13:17:07 -0000 1.25.2.7 *************** *** 100,104 **** p = type(_compointer_base)("POINTER(%s)" % cls.__name__, _ptr_bases, ! {}) from ctypes import _pointer_type_cache _pointer_type_cache[cls] = p --- 100,104 ---- p = type(_compointer_base)("POINTER(%s)" % cls.__name__, _ptr_bases, ! {"__ctypes_from_outparm__": lambda self: self}) from ctypes import _pointer_type_cache _pointer_type_cache[cls] = p *************** *** 114,118 **** try: return sum([len(itf.__dict__["_methods_"]) ! for itf in self.__mro__[1:-1]]) except KeyError, (name,): if name == "_methods_": --- 114,118 ---- try: return sum([len(itf.__dict__["_methods_"]) ! for itf in self.mro()[1:-1]]) except KeyError, (name,): if name == "_methods_": *************** *** 202,205 **** --- 202,209 ---- setattr(self, name, prop) + ################################################################ + # helper classes for COM propget / propput + # Should they be implemented in C for speed? + class bound_named_property(object): def __init__(self, getter, setter, im_inst): *************** *** 229,241 **** return bound_named_property(self.getter, self.setter, im_inst) - class NotYetImplemented(Warning): - pass - - # metaclass for COM interface pointer classes class _compointer_meta(type(c_void_p), _cominterface_meta): ! pass - # base class for COM interface pointer classes class _compointer_base(c_void_p): __metaclass__ = _compointer_meta def __del__(self): --- 233,242 ---- return bound_named_property(self.getter, self.setter, im_inst) class _compointer_meta(type(c_void_p), _cominterface_meta): ! "metaclass for COM interface pointer classes" ! # (no functionality, but avoids a metaclass confict) class _compointer_base(c_void_p): + "base class for COM interface pointer classes" __metaclass__ = _compointer_meta def __del__(self): *************** *** 247,253 **** def __nonzero__(self): # get the .value property of the baseclass, this is the pointer value - # both variants below do the same, and both are equally unreadable ;-) return bool(super(_compointer_base, self).value) - ## return bool(c_void_p.value.__get__(self)) def __cmp__(self, other): --- 248,252 ---- *************** *** 279,282 **** --- 278,282 ---- class BSTR(_SimpleCData): + "The windows BSTR data type" _type_ = "X" def __repr__(self): *************** *** 287,290 **** --- 287,291 ---- ################################################################ + # IDL stuff class helpstring(object): *************** *** 299,302 **** --- 300,312 ---- pass + def STDMETHOD(restype, name, argtypes=()): + "Specifies a COM method slot without idlflags" + # restype, name, argtypes, paramflags, idlflags, docstring + return restype, name, argtypes, None, (), None + + def DISPMETHOD(idlflags, restype, name, *argspec): + # XXX WRONG WRONG WRONG + return COMMETHOD(idlflags, restype, name, *argspec) + ################################################################ *************** *** 314,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): --- 324,327 ---- *************** *** 436,442 **** # 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 _VARIANT_type_hack and typ is _VARIANT_type_hack: # XXX make this a classmethod of VARIANT! --- 442,445 ---- *************** *** 474,482 **** return restype, methodname, tuple(argtypes), tuple(paramflags), tuple(idlflags), helptext - def STDMETHOD(restype, name, argtypes=()): - "Specifies a COM method slot without idlflags" - # restype, name, argtypes, paramflags, idlflags, docstring - return restype, name, argtypes, None, (), None - ################################################################ --- 477,480 ---- *************** *** 554,560 **** ################ ! class CoClass(object): "pass" # creation, and so on --- 552,564 ---- ################ ! class CoClass(c_void_p): "pass" + # The code generation assigns a __ctypes_from_outparm__ to each + # POINTER(<coclass>) when the <coclass> is generated. Maybe we could + # avoid having c_void_p as baseclass in CoClass, generate the + # __ctypes_from_outparm__ method in a metaclass, and also have the + # metaclass mix in the c_void_p (or whatever) into the POINTER(...) + # type? See the IUnknown magic... # creation, and so on |