// @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; }
// @pymethod int|PyIActiveScriptSite|GetItemInfo| PyObject *PyIActiveScriptSite::GetItemInfo(PyObject *self, PyObject *args) { PY_INTERFACE_METHOD; PyObject *obName; int mask; IActiveScriptSite *pMySite = GetI(self); if (pMySite==NULL) return NULL; if (!PyArg_ParseTuple(args, "Oi:GetItemInfo", &obName, &mask)) return NULL; OLECHAR *name; if (!PyWinObject_AsWCHAR(obName, &name)) return NULL; IUnknown *punk = NULL; ITypeInfo *ptype = NULL; PY_INTERFACE_PRECALL; SCODE sc = pMySite->GetItemInfo(name, mask, &punk, &ptype); PY_INTERFACE_POSTCALL; PyWinObject_FreeWCHAR(name); if (FAILED(sc)) return SetPythonCOMError(self, sc); PyObject *obDispatch = PyCom_PyObjectFromIUnknown(punk, IID_IUnknown); PyObject *obType = PyCom_PyObjectFromIUnknown(ptype, IID_ITypeInfo); PyObject *rc = NULL; if (obDispatch && obType) rc = Py_BuildValue("OO", obDispatch, obType); Py_XDECREF(obDispatch); Py_XDECREF(obType); return rc; }
// @pymethod int|PyIActiveScriptSite|OnScriptTerminate| PyObject *PyIActiveScriptSite::OnScriptTerminate(PyObject *self, PyObject *args) { PY_INTERFACE_METHOD; PyObject *obResult, *obException; if (!PyArg_ParseTuple(args, "OO:OnScriptTerminate", &obResult, &obException)) return NULL; IActiveScriptSite *pMySite = GetI(self); if (pMySite==NULL) return NULL; VARIANT varResult; VARIANT *pVarResult = NULL; if (obResult!=Py_None) { pVarResult = &varResult; VariantInit(&varResult); if (!PyCom_VariantFromPyObject(obResult, pVarResult)) return NULL; } EXCEPINFO excep; EXCEPINFO *pExcep = NULL; if (obException!=Py_None) { pExcep = &excep; memset(pExcep, 0, sizeof(EXCEPINFO)); if (!PyCom_ExcepInfoFromPyObject(obException, pExcep)) return NULL; } PY_INTERFACE_PRECALL; SCODE sc = pMySite->OnScriptTerminate(pVarResult, pExcep); PY_INTERFACE_POSTCALL; if (pVarResult) VariantClear(pVarResult); if (FAILED(sc)) return SetPythonCOMError(self, sc); return PyInt_FromLong(sc); }
IActiveScriptSite* CRubyScript::GetSite() { IActiveScriptSite* pSite = NULL; if (GetCurrentThreadId() == m_dwThreadID) { pSite = m_pSite; pSite->AddRef(); } else { HRESULT hr = m_pGippedSite.Localize(&pSite); ATLTRACE(_T("Localize ScriptSite = %08X\n"), hr); } return pSite; }
// @pymethod int|PyIActiveScriptSite|GetLCID| PyObject *PyIActiveScriptSite::GetLCID(PyObject *self, PyObject *args) { PY_INTERFACE_METHOD; if (!PyArg_ParseTuple(args, ":GetLCID")) return NULL; IActiveScriptSite *pMySite = GetI(self); if (pMySite==NULL) return NULL; unsigned long lcid; PY_INTERFACE_PRECALL; SCODE sc = pMySite->GetLCID(&lcid); PY_INTERFACE_POSTCALL; if (FAILED(sc)) return SetPythonCOMError(self, sc); return PyInt_FromLong(lcid); }
// @pymethod int|PyIActiveScriptSite|OnLeaveScript| PyObject *PyIActiveScriptSite::OnLeaveScript(PyObject *self, PyObject *args) { PY_INTERFACE_METHOD; if (!PyArg_ParseTuple(args, ":OnLeaveScript")) return NULL; IActiveScriptSite *pMySite = GetI(self); if (pMySite==NULL) return NULL; PY_INTERFACE_PRECALL; SCODE sc = pMySite->OnLeaveScript(); PY_INTERFACE_POSTCALL; if (FAILED(sc)) return SetPythonCOMError(self, sc); Py_INCREF(Py_None); return Py_None; }
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; }
// @pymethod int|PyIActiveScriptSite|GetDocVersionString| PyObject *PyIActiveScriptSite::GetDocVersionString(PyObject *self, PyObject *args) { PY_INTERFACE_METHOD; if (!PyArg_ParseTuple(args, ":GetDocVersionString")) return NULL; IActiveScriptSite *pMySite = GetI(self); if (pMySite==NULL) return NULL; BSTR bstr; PY_INTERFACE_PRECALL; SCODE sc = pMySite->GetDocVersionString(&bstr); PY_INTERFACE_POSTCALL; if (FAILED(sc)) return SetPythonCOMError(self, sc); PyObject * rc = MakeBstrToObj(bstr); SysFreeString(bstr); return rc; }
// @pymethod int|PyIActiveScriptSite|OnStateChange| PyObject *PyIActiveScriptSite::OnStateChange(PyObject *self, PyObject *args) { PY_INTERFACE_METHOD; int state; if (!PyArg_ParseTuple(args, "i:OnStateChange", &state)) return NULL; IActiveScriptSite *pMySite = GetI(self); if (pMySite==NULL) return NULL; PY_INTERFACE_PRECALL; SCODE sc = pMySite->OnStateChange((SCRIPTSTATE)state); PY_INTERFACE_POSTCALL; if (FAILED(sc)) // EEK - WSH appears to die if we QI for // IID_ISupportErrorInfo - we don't really // use this extended info (even if it did provide it) return SetPythonCOMError(NULL, sc); Py_INCREF(Py_None); return Py_None; }
/* 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; }
// @pymethod int|PyIActiveScriptSite|OnScriptError| PyObject *PyIActiveScriptSite::OnScriptError(PyObject *self, PyObject *args) { PY_INTERFACE_METHOD; PyObject *obASE; if (!PyArg_ParseTuple(args, "O:OnScriptError", &obASE)) return NULL; IActiveScriptSite *pMySite = GetI(self); if (pMySite==NULL) return NULL; IActiveScriptError *pASE; if (!PyCom_InterfaceFromPyObject(obASE, IID_IActiveScriptError, (void **)&pASE, FALSE)) return NULL; PY_INTERFACE_PRECALL; SCODE sc = pMySite->OnScriptError(pASE); pASE->Release(); PY_INTERFACE_POSTCALL; // no idea why, but under ASP, OnScriptError() will often return // with a KeyboardInterrup set! PyWin_MakePendingCalls(); if (sc != E_FAIL && FAILED(sc)) // E_FAIL is documented as a normal retval. return SetPythonCOMError(self, sc); return PyInt_FromLong(sc); }