// @pymethod |PyIDebugApplication|HandleRuntimeError|Description of HandleRuntimeError. PyObject *PyIDebugApplication::HandleRuntimeError(PyObject *self, PyObject *args) { IDebugApplication *pIDA = GetI(self); if ( pIDA == NULL ) return NULL; // @pyparm <o PyIActiveScriptErrorDebug>|pErrorDebug||Description for pErrorDebug // @pyparm <o PyIActiveScriptSite>|pScriptSite||Description for pScriptSite PyObject *obpErrorDebug; PyObject *obpScriptSite; IActiveScriptErrorDebug * pErrorDebug; IActiveScriptSite * pScriptSite; BREAKRESUMEACTION pbra; ERRORRESUMEACTION perra; BOOL pfCallOnScriptError; if ( !PyArg_ParseTuple(args, "OO:HandleRuntimeError", &obpErrorDebug, &obpScriptSite) ) return NULL; BOOL bPythonIsHappy = TRUE; if (!PyCom_InterfaceFromPyInstanceOrObject(obpErrorDebug, IID_IActiveScriptErrorDebug, (void **)&pErrorDebug, TRUE /* bNoneOK */)) bPythonIsHappy = FALSE; if (!PyCom_InterfaceFromPyInstanceOrObject(obpScriptSite, IID_IActiveScriptSite, (void **)&pScriptSite, TRUE /* bNoneOK */)) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIDA->HandleRuntimeError( pErrorDebug, pScriptSite, &pbra, &perra, &pfCallOnScriptError ); if (pErrorDebug) pErrorDebug->Release(); if (pScriptSite) pScriptSite->Release(); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return OleSetOleError(hr); PyObject *pyretval = Py_BuildValue("iii", pbra, perra, pfCallOnScriptError); return pyretval; }
// // IServiceProvider HRESULT STDMETHODCALLTYPE CRScriptCore::QueryService( REFGUID guidService, REFIID riid, void **ppv) { if (!ppv) return E_POINTER; HRESULT hr = E_NOINTERFACE; #ifdef __IRubyWrapper_INTERFACE_DEFINED__ if (m_listServiceProvider.size() > 0) { IServiceProvider* p = m_listServiceProvider.front(); hr = p->QueryService(guidService, riid, ppv); } else { *ppv = NULL; if (InlineIsEqualGUID(guidService, SID_GetCaller) || InlineIsEqualGUID(guidService, IID_IActiveScriptSite)) { IActiveScriptSite* pSite = GetSite(); if (pSite) { hr = pSite->QueryInterface(riid, ppv); } pSite->Release(); } else if (m_pProv) { hr = m_pProv->QueryService(guidService, riid, ppv); } } #endif return hr; }
VALUE CRScriptCore::GetOleObject(VALUE self, LPCOLESTR pstrName) { ItemMapIter it = m_mapItem.find(pstrName); if (it == m_mapItem.end()) { it = (m_mapItem.insert(ItemMap::value_type(pstrName, new CItemHolder))).first; } VALUE obj = Qnil; IDispatch* pDisp = NULL; IActiveScriptSite* pSite = GetSite(); if (pSite) { pDisp = (*it).second->GetDispatch(pSite, const_cast<LPOLESTR>(pstrName), (m_dwThreadID == GetCurrentThreadId())); pSite->Release(); } if (pDisp) { oledataex *pole; // setting free function is not required. because ScriptEngine hold it. obj = Data_Make_Struct(self, oledataex, 0, 0, pole); #ifdef __IRubyWrapper_INTERFACE_DEFINED__ IDispatchEx* pEx; if (QueryInterface(IID_IRubyEngine, (void**)&pole->pEngine) == S_OK) { // adjust ref count (because never release the ptr in WIN32OLEEX) pole->pEngine->Release(); } if (pDisp->QueryInterface(IID_IDispatchEx, (void**)&pEx) == S_OK) { pole->pDispatch = pEx; pole->pServiceProvider = this; pDisp->Release(); } else #endif { pole->pDispatch = pDisp; } ATLTRACE(_T("add OLE Object into list:%08X\n"), pole); m_listOleObj.push_back(reinterpret_cast<oledata*>(pole)); } return obj; }
/* static */ PyObject *PyIActiveScript::SetScriptSite(PyObject *self, PyObject *args) { PY_INTERFACE_METHOD; PyObject *obSite; if ( !PyArg_ParseTuple(args, "O:SetScriptSite", &obSite) ) return NULL; IActiveScript *pIAS = GetI(self); if ( pIAS == NULL ) return NULL; if ( !PyIBase::is_object(obSite, &PyIUnknown::type) ) { PyErr_SetString(PyExc_ValueError, "argument is not a site"); return NULL; } IUnknown *punk = PyIUnknown::GetI(obSite); if ( !punk ) return NULL; /* exception was set by GetI() */ /* note: we don't explicitly hold a reference to punk */ IActiveScriptSite *pIASS; HRESULT hr; Py_BEGIN_ALLOW_THREADS hr = punk->QueryInterface(IID_IActiveScriptSite, (LPVOID*)&pIASS); Py_END_ALLOW_THREADS if ( FAILED(hr) ) return SetPythonCOMError(self, hr); PY_INTERFACE_PRECALL; hr = pIAS->SetScriptSite(pIASS); pIASS->Release(); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return SetPythonCOMError(self, hr); Py_INCREF(Py_None); return Py_None; }