a „oew&ã@s(dZddlZdd„Zdd„Zdd„ZdS) a9Utility file for generating PyIEnum support. This is almost a 'template' file. It simplay contains almost full C++ source code for PyIEnum* support, and the Python code simply substitutes the appropriate interface name. This module is notmally not used directly - the @makegw@ module automatically calls this. éNcCs|dtjvo|dtjv S)Nré)ÚstringZ uppercase)Úenumtype©rú;C:\Program Files\Certbot\pkgs\win32com\makegw\makegwenum.pyÚis_interface_enumsrcCsd|jdd…}t|ƒrNext(celt, rgVar, &celtFetched); PY_INTERFACE_POSTCALL; if ( HRESULT_CODE(hr) != ERROR_NO_MORE_ITEMS && FAILED(hr) ) { delete [] rgVar; return PyCom_BuildPyException(hr,pIE%(enumtype)s, IID_IE%(enumtype)s); } PyObject *result = PyTuple_New(celtFetched); if ( result != NULL ) { for ( i = celtFetched; i--; ) { %(converter)s if ( ob == NULL ) { Py_DECREF(result); result = NULL; break; } PyTuple_SET_ITEM(result, i, ob); } } /* for ( i = celtFetched; i--; ) // *** possibly cleanup each structure element??? */ delete [] rgVar; return result; } // @pymethod |PyIEnum%(enumtype)s|Skip|Skips over the next specified elementes. PyObject *PyIEnum%(enumtype)s::Skip(PyObject *self, PyObject *args) { long celt; if ( !PyArg_ParseTuple(args, "l:Skip", &celt) ) return NULL; IEnum%(enumtype)s *pIE%(enumtype)s = GetI(self); if ( pIE%(enumtype)s == NULL ) return NULL; PY_INTERFACE_PRECALL; HRESULT hr = pIE%(enumtype)s->Skip(celt); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIE%(enumtype)s, IID_IE%(enumtype)s); Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIEnum%(enumtype)s|Reset|Resets the enumeration sequence to the beginning. PyObject *PyIEnum%(enumtype)s::Reset(PyObject *self, PyObject *args) { if ( !PyArg_ParseTuple(args, ":Reset") ) return NULL; IEnum%(enumtype)s *pIE%(enumtype)s = GetI(self); if ( pIE%(enumtype)s == NULL ) return NULL; PY_INTERFACE_PRECALL; HRESULT hr = pIE%(enumtype)s->Reset(); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIE%(enumtype)s, IID_IE%(enumtype)s); Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIEnum%(enumtype)s|Clone|Creates another enumerator that contains the same enumeration state as the current one PyObject *PyIEnum%(enumtype)s::Clone(PyObject *self, PyObject *args) { if ( !PyArg_ParseTuple(args, ":Clone") ) return NULL; IEnum%(enumtype)s *pIE%(enumtype)s = GetI(self); if ( pIE%(enumtype)s == NULL ) return NULL; IEnum%(enumtype)s *pClone; PY_INTERFACE_PRECALL; HRESULT hr = pIE%(enumtype)s->Clone(&pClone); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIE%(enumtype)s, IID_IE%(enumtype)s); return PyCom_PyObjectFromIUnknown(pClone, IID_IEnum%(enumtype)s, FALSE); } // @object PyIEnum%(enumtype)s|A Python interface to IEnum%(enumtype)s static struct PyMethodDef PyIEnum%(enumtype)s_methods[] = { { "Next", PyIEnum%(enumtype)s::Next, 1 }, // @pymeth Next|Retrieves a specified number of items in the enumeration sequence. { "Skip", PyIEnum%(enumtype)s::Skip, 1 }, // @pymeth Skip|Skips over the next specified elementes. { "Reset", PyIEnum%(enumtype)s::Reset, 1 }, // @pymeth Reset|Resets the enumeration sequence to the beginning. { "Clone", PyIEnum%(enumtype)s::Clone, 1 }, // @pymeth Clone|Creates another enumerator that contains the same enumeration state as the current one. { NULL } }; PyComEnumTypeObject PyIEnum%(enumtype)s::type("PyIEnum%(enumtype)s", &PyIUnknown::type, sizeof(PyIEnum%(enumtype)s), PyIEnum%(enumtype)s_methods, GET_PYCOM_CTOR(PyIEnum%(enumtype)s)); ©ÚnamerÚlocalsÚwrite)ÚfÚ interfacerÚenum_interfaceÚ converterZ arraydeclarerrrÚ_write_enumifc_cpps&ÿÿÿÿ €çÿrcCsd|jdd…}t|ƒr (int)celt) len = celt; if ( pCeltFetched ) *pCeltFetched = len; int i; for ( i = 0; i < len; ++i ) { PyObject *ob = PySequence_GetItem(result, i); if ( ob == NULL ) goto error; %(converter)s { Py_DECREF(result); return PyCom_SetCOMErrorFromPyException(IID_IEnum%(enumtype)s); } } Py_DECREF(result); return len < (int)celt ? S_FALSE : S_OK; error: PyErr_Clear(); // just in case Py_DECREF(result); return PyCom_HandleIEnumNoSequence(IID_IEnum%(enumtype)s); } STDMETHODIMP PyGEnum%(enumtype)s::Skip( /* [in] */ ULONG celt) { PY_GATEWAY_METHOD; return InvokeViaPolicy("Skip", NULL, "i", celt); } STDMETHODIMP PyGEnum%(enumtype)s::Reset(void) { PY_GATEWAY_METHOD; return InvokeViaPolicy("Reset"); } STDMETHODIMP PyGEnum%(enumtype)s::Clone( /* [out] */ IEnum%(enumtype)s __RPC_FAR *__RPC_FAR *ppEnum) { PY_GATEWAY_METHOD; PyObject * result; HRESULT hr = InvokeViaPolicy("Clone", &result); if ( FAILED(hr) ) return hr; /* ** Make sure we have the right kind of object: we should have some kind ** of IUnknown subclass wrapped into a PyIUnknown instance. */ if ( !PyIBase::is_object(result, &PyIUnknown::type) ) { /* the wrong kind of object was returned to us */ Py_DECREF(result); return PyCom_SetCOMErrorFromSimple(E_FAIL, IID_IEnum%(enumtype)s); } /* ** Get the IUnknown out of the thing. note that the Python ob maintains ** a reference, so we don't have to explicitly AddRef() here. */ IUnknown *punk = ((PyIUnknown *)result)->m_obj; if ( !punk ) { /* damn. the object was released. */ Py_DECREF(result); return PyCom_SetCOMErrorFromSimple(E_FAIL, IID_IEnum%(enumtype)s); } /* ** Get the interface we want. note it is returned with a refcount. ** This QI is actually going to instantiate a PyGEnum%(enumtype)s. */ hr = punk->QueryInterface(IID_IEnum%(enumtype)s, (LPVOID *)ppEnum); /* done with the result; this DECREF is also for */ Py_DECREF(result); return PyCom_CheckIEnumNextResult(hr, IID_IEnum%(enumtype)s); } r )rrrrrZ argdeclarerrrÚ_write_enumgw_cppÆsÿÿ   vŠÿr)Ú__doc__rrrrrrrrÚs  2