Example #1
0
STDMETHODIMP PyGDebugDocumentText::GetText(
		/* [in] */ ULONG cCharacterPosition,
		/* [size_is][length_is][out][in] */ WCHAR __RPC_FAR * pcharText,
		/* [size_is][length_is][out][in] */ SOURCE_TEXT_ATTR __RPC_FAR * pstaTextAttr,
		/* [out][in] */ ULONG __RPC_FAR * pcNumChars,
		/* [in] */ ULONG cMaxChars)
{
	PY_GATEWAY_METHOD;
	PyObject *result;
	HRESULT hr=InvokeViaPolicy("GetText", &result, "iii", cCharacterPosition, cMaxChars, (pstaTextAttr!=NULL));
	if (FAILED(hr)) return hr;
	// Process the Python results, and convert back to the real params
	PyObject *obText, *obAttr;
	if (!PyArg_ParseTuple(result, "OO" , &obText, &obAttr))
		 return PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/);
	BSTR bstr;
	BOOL ok = TRUE;
	ok = PyCom_BstrFromPyObject(obText, &bstr);
	if (ok) {
		*pcNumChars = SysStringLen(bstr);
		wcsncpy(pcharText, bstr, *pcNumChars);
		SysFreeString(bstr);
	}
	if (ok && pstaTextAttr) {
		ok = PyAXDebug_PyObject_AsSOURCE_TEXT_ATTR(obAttr, pstaTextAttr, *pcNumChars);
	}
	Py_DECREF(result);
	if (!ok)
		 return PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/);
	return hr;
}
STDMETHODIMP PyGActiveScriptDebug::GetScriptTextAttributes(
		/* [size_is][in] */ LPCOLESTR pstrCode,
		/* [in] */ ULONG uNumCodeChars,
		/* [in] */ LPCOLESTR pstrDelimiter,
		/* [in] */ DWORD dwFlags,
		/* [size_is][out][in] */ SOURCE_TEXT_ATTR __RPC_FAR * pattr)
{
	PY_GATEWAY_METHOD;
	PyObject *obCode = PyWinObject_FromOLECHAR(pstrCode,uNumCodeChars);
	PyObject *obszpstrDelimiter = PyWinObject_FromOLECHAR(pstrDelimiter);
	PyObject *result;
	HRESULT hr=InvokeViaPolicy("GetScriptTextAttributes", &result, "OOi", obCode, obszpstrDelimiter, dwFlags);
	Py_XDECREF(obCode);
	Py_XDECREF(obszpstrDelimiter);
	if (FAILED(hr)) return hr;
	if (!PyAXDebug_PyObject_AsSOURCE_TEXT_ATTR(result, pattr, uNumCodeChars))
		hr = PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/);
	Py_DECREF(result);
	return hr;
}