// @pymethod |PyIActiveScriptDebug|GetScriptletTextAttributes|Description of GetScriptletTextAttributes.
PyObject *PyIActiveScriptDebug::GetScriptletTextAttributes(PyObject *self, PyObject *args)
{
	PY_INTERFACE_METHOD;
	IActiveScriptDebug *pIASD = GetI(self);
	if ( pIASD == NULL )
		return NULL;
	// @pyparm string|pstrCode||The script block text.
	// @pyparm string|pstrDelimiter||See <om PyIActiveScriptParse::ParseScriptText> for a description of this argument.
	// @pyparm int|dwFlags||See <om PyIActiveScriptParse::ParseScriptText> for a description of this argument.
	DWORD dwFlags;
	PyObject *obCode, *obDelim;
	if ( !PyArg_ParseTuple(args, "OOi:GetScriptletTextAttributes", &obCode, &obDelim, &dwFlags) )
		return NULL;
	BOOL bPythonIsHappy = TRUE;
	WCHAR *pstrDelimiter;
	BSTR bstr;
	if (!PyWinObject_AsWCHAR(obDelim, &pstrDelimiter)) bPythonIsHappy = FALSE;
	if (!PyCom_BstrFromPyObject(obCode, &bstr)) bPythonIsHappy = FALSE;
	if (!bPythonIsHappy) return NULL;
	ULONG uNumCodeChars = SysStringLen(bstr);
	SOURCE_TEXT_ATTR *pattr = new SOURCE_TEXT_ATTR[uNumCodeChars];
	PY_INTERFACE_PRECALL;
	HRESULT hr = pIASD->GetScriptletTextAttributes( bstr, uNumCodeChars, pstrDelimiter, dwFlags, pattr );
	PY_INTERFACE_POSTCALL;
	SysFreeString(bstr);
	PyWinObject_FreeWCHAR(pstrDelimiter);
	if ( FAILED(hr) )
		return SetPythonCOMError(self,hr);

	return PyAXDebug_PyObject_FromSOURCE_TEXT_ATTR(pattr, uNumCodeChars);
}
Beispiel #2
0
// @pymethod |PyIDebugDocumentText|GetText|Description of GetText.
PyObject *PyIDebugDocumentText::GetText(PyObject *self, PyObject *args)
{
	IDebugDocumentText *pIDDT = GetI(self);
	if ( pIDDT == NULL )
		return NULL;
	PyObject *obpcharText;
	ULONG cCharacterPosition;
	ULONG cMaxChars;
	BOOL bWantAttr = 1;
	// @pyparm int|cCharacterPosition||
	// @pyparm int|cMaxChars||Max chars to return
	// @pyparm int|bWantAttr|1|Should the attributes be returned?
	if ( !PyArg_ParseTuple(args, "ii|i:GetText", &cCharacterPosition, &cMaxChars, &bWantAttr) )
		return NULL;
	OLECHAR *buf = new OLECHAR [cMaxChars+1];
	SOURCE_TEXT_ATTR *attrbuf = bWantAttr ? new SOURCE_TEXT_ATTR [cMaxChars+1] : NULL;
	ULONG cNumChars = 0;
	PY_INTERFACE_PRECALL;
	HRESULT hr = pIDDT->GetText( cCharacterPosition, buf, attrbuf, &cNumChars, cMaxChars );
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return SetPythonCOMError(self, hr);
	obpcharText = PyWinObject_FromOLECHAR(buf, cNumChars);
	PyObject *obattr;
	if (attrbuf) {
		obattr = PyAXDebug_PyObject_FromSOURCE_TEXT_ATTR(attrbuf, cNumChars);
	} else {
		obattr = Py_None;
		Py_INCREF(Py_None);
	}
	PyObject *pyretval = Py_BuildValue("OO", obpcharText, obattr);
	Py_XDECREF(obpcharText);
	Py_XDECREF(obattr);
	delete [] buf;
	delete [] attrbuf;
	return pyretval;
}