HRESULT CComTypeInfoHolder::GetIDsOfNames(REFIID /*riid*/, LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgdispid) { ITypeInfo* pInfo;; HRESULT hRes = GetTI(lcid, &pInfo); return (pInfo != NULL) ? pInfo->GetIDsOfNames(rgszNames, cNames, rgdispid) : hRes; }
STDMETHODIMP InterfaceAdapter::GetIDsOfNames ( InterfaceAdapter *pThis, REFIID, OLECHAR **rgszNames, UINT cNames, LCID, DISPID *rgDispId) { ITypeInfo *pTypeInfo = pThis->m_dispatchImpl.typeInfo(); return pTypeInfo->GetIDsOfNames(rgszNames, cNames, rgDispId); }
STDMETHODIMP CBaseDispatch::GetIDsOfNames( REFIID riid, OLECHAR ** rgszNames, UINT cNames, LCID lcid, DISPID * rgdispid) { // although the IDispatch riid is dead, we use this to pass from // the interface implementation class to us the iid we are talking about. ITypeInfo * pti; HRESULT hr = GetTypeInfo(riid, 0, lcid, &pti); if (SUCCEEDED(hr)) { hr = pti->GetIDsOfNames(rgszNames, cNames, rgdispid); pti->Release(); } return hr; }
// @pymethod int|PyITypeInfo|GetIDsOfNames|Maps between member names and member IDs, and parameter names and parameter IDs. static PyObject *typeinfo_getidsofnames(PyObject *self, PyObject *args) { // XXX - todo - merge this code with PyIDispatch::GetIDsOfNames ITypeInfo *pti = PyITypeInfo::GetI(self); if (pti==NULL) return NULL; UINT i; int argc = PyTuple_GET_SIZE(args); if ( argc < 1 ) { PyErr_SetString(PyExc_TypeError, "At least one argument must be supplied"); return NULL; } LCID lcid = LOCALE_SYSTEM_DEFAULT; UINT offset = 0; if ( argc > 1 ) { PyObject *ob = PyTuple_GET_ITEM(args, 0); lcid=PyLong_AsLong(ob); if (lcid==-1 && PyErr_Occurred()){ PyErr_Clear(); lcid=LOCALE_SYSTEM_DEFAULT; } else offset = 1; } UINT cNames = argc - offset; OLECHAR FAR* FAR* rgszNames = new LPOLESTR[cNames]; for ( i = 0 ; i < cNames; ++i ) { PyObject *ob = PyTuple_GET_ITEM(args, i + offset); if (!PyWinObject_AsBstr(ob, rgszNames+i)) { for (;i>0;i--) PyWinObject_FreeBstr(rgszNames[i-1]); delete [] rgszNames; return NULL; } } DISPID FAR* rgdispid = new DISPID[cNames]; PY_INTERFACE_PRECALL; HRESULT hr = pti->GetIDsOfNames(rgszNames, cNames, rgdispid); PY_INTERFACE_POSTCALL; for (i=0;i<cNames;i++) PyWinObject_FreeBstr(rgszNames[i]); delete [] rgszNames; if ( FAILED(hr) ){ delete [] rgdispid; return PyCom_BuildPyException(hr, pti, IID_ITypeInfo); } PyObject *result; /* if we have just one name, then return a single DISPID (int) */ if ( cNames == 1 ) { result = PyInt_FromLong(rgdispid[0]); } else { result = PyTuple_New(cNames); if ( result ) { for ( i = 0; i < cNames; ++i ) { PyObject *ob = PyInt_FromLong(rgdispid[i]); if ( !ob ) { delete [] rgdispid; return NULL; } PyTuple_SET_ITEM(result, i, ob); } } } delete [] rgdispid; return result; }