// This file implements the IActiveScriptParseProcedure Interface and Gateway for Python.
// Generated by makegw.py

#include "stdafx.h"
#include "PyIActiveScriptParseProcedure.h"

// @doc - This file contains autoduck documentation
// ---------------------------------------------------
//
// Interface Implementation

PyIActiveScriptParseProcedure::PyIActiveScriptParseProcedure(IUnknown *pdisp):
	PyIUnknown(pdisp)
{
	ob_type = &type;
}

PyIActiveScriptParseProcedure::~PyIActiveScriptParseProcedure()
{
}

/* static */ IActiveScriptParseProcedure *PyIActiveScriptParseProcedure::GetI(PyObject *self)
{
	return (IActiveScriptParseProcedure *)PyIUnknown::GetI(self);
}

// @pymethod |PyIActiveScriptParseProcedure|ParseProcedureText|Description of ParseProcedureText.
PyObject *PyIActiveScriptParseProcedure::ParseProcedureText(PyObject *self, PyObject *args)
{
	IActiveScriptParseProcedure *pIASPP = GetI(self);
	if ( pIASPP == NULL )
		return NULL;
	// @pyparm <o unicode>|pstrCode||Description for pstrCode
	// @pyparm <o unicode>|pstrFormalParams||Description for pstrFormalParams
	// @pyparm <o unicode>|pstrProcedureName||Description for pstrProcedureName
	// @pyparm <o unicode>|pstrItemName||Description for pstrItemName
	// @pyparm <o PyIUnknown>|punkContext||Description for punkContext
	// @pyparm <o unicode>|pstrDelimiter||Description for pstrDelimiter
	// @pyparm int|dwSourceContextCookie||Description for dwSourceContextCookie
	// @pyparm int|ulStartingLineNumber||Description for ulStartingLineNumber
	// @pyparm int|dwFlags||Description for dwFlags
	PyObject *obpstrCode;
	PyObject *obpstrFormalParams;
	PyObject *obpstrProcedureName;
	PyObject *obpstrItemName;
	PyObject *obpunkContext;
	PyObject *obpstrDelimiter;
	LPOLESTR pstrCode;
	LPOLESTR pstrFormalParams;
	LPOLESTR pstrProcedureName;
	LPOLESTR pstrItemName;
	IUnknown * punkContext;
	LPOLESTR pstrDelimiter;
	DWORD dwSourceContextCookie;
	ULONG ulStartingLineNumber;
	DWORD dwFlags;
	IDispatch * ppdisp;
	if ( !PyArg_ParseTuple(args, "OOOOOOiii:ParseProcedureText", &obpstrCode, &obpstrFormalParams, &obpstrProcedureName, &obpstrItemName, &obpunkContext, &obpstrDelimiter, &dwSourceContextCookie, &ulStartingLineNumber, &dwFlags) )
		return NULL;
	BOOL bPythonIsHappy = TRUE;
	if (!PyCom_BstrFromPyObject(obpstrCode, &pstrCode)) bPythonIsHappy = FALSE;
	if (!PyCom_BstrFromPyObject(obpstrFormalParams, &pstrFormalParams)) bPythonIsHappy = FALSE;
	if (!PyCom_BstrFromPyObject(obpstrProcedureName, &pstrProcedureName)) bPythonIsHappy = FALSE;
	if (!PyCom_BstrFromPyObject(obpstrItemName, &pstrItemName)) bPythonIsHappy = FALSE;
	if (!PyCom_InterfaceFromPyInstanceOrObject(obpunkContext, IID_IUnknown, (void **)&punkContext, TRUE /* bNoneOK */))
		 bPythonIsHappy = FALSE;
	if (!PyCom_BstrFromPyObject(obpstrDelimiter, &pstrDelimiter)) bPythonIsHappy = FALSE;
	if (!bPythonIsHappy) return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIASPP->ParseProcedureText( pstrCode, pstrFormalParams, pstrProcedureName, pstrItemName, punkContext, pstrDelimiter, dwSourceContextCookie, ulStartingLineNumber, dwFlags, &ppdisp );
	if (punkContext) punkContext->Release();
	PY_INTERFACE_POSTCALL;
	SysFreeString(pstrCode);
	SysFreeString(pstrFormalParams);
	SysFreeString(pstrProcedureName);
	SysFreeString(pstrItemName);
	SysFreeString(pstrDelimiter);

	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr);

	return PyCom_PyObjectFromIUnknown(ppdisp, IID_IDispatch, FALSE);
}

// @object PyIActiveScriptParseProcedure|Description of the interface
static struct PyMethodDef PyIActiveScriptParseProcedure_methods[] =
{
	{ "ParseProcedureText", PyIActiveScriptParseProcedure::ParseProcedureText, 1 }, // @pymeth ParseProcedureText|Description of ParseProcedureText
	{ NULL }
};

PyComTypeObject PyIActiveScriptParseProcedure::type("PyIActiveScriptParseProcedure",
		&PyIUnknown::type,
		sizeof(PyIActiveScriptParseProcedure),
		PyIActiveScriptParseProcedure_methods,
		GET_PYCOM_CTOR(PyIActiveScriptParseProcedure));
// ---------------------------------------------------
//
// Gateway Implementation

STDMETHODIMP PyGActiveScriptParseProcedure::ParseProcedureText(
		/* [in] */ LPCOLESTR pstrCode,
		/* [in] */ LPCOLESTR pstrFormalParams,
		/* [in] */ LPCOLESTR pstrProcedureName,
		/* [in] */ LPCOLESTR pstrItemName,
		/* [in] */ IUnknown __RPC_FAR * punkContext,
		/* [in] */ LPCOLESTR pstrDelimiter,
		/* [in] */ DWORD_PTR dwSourceContextCookie,
		/* [in] */ ULONG ulStartingLineNumber,
		/* [in] */ DWORD dwFlags,
		/* [out] */ IDispatch __RPC_FAR *__RPC_FAR * ppdisp)
{
	PY_GATEWAY_METHOD;
	if (ppdisp==NULL) return E_POINTER;
	PyObject *obpstrCode;
	PyObject *obpstrFormalParams;
	PyObject *obpstrProcedureName;
	PyObject *obpstrItemName;
	PyObject *obpunkContext;
	PyObject *obpstrDelimiter;
	obpstrCode = PyWinObject_FromOLECHAR(pstrCode);
	obpstrFormalParams = PyWinObject_FromOLECHAR(pstrFormalParams);
	obpstrProcedureName = PyWinObject_FromOLECHAR(pstrProcedureName);
	obpstrItemName = PyWinObject_FromOLECHAR(pstrItemName);
	obpunkContext = PyCom_PyObjectFromIUnknown(punkContext, IID_IUnknown, TRUE);
	obpstrDelimiter = PyWinObject_FromOLECHAR(pstrDelimiter);
	PyObject *obContext = PyWinObject_FromDWORD_PTR(dwSourceContextCookie);
	PyObject *result;
	HRESULT hr=InvokeViaPolicy("ParseProcedureText", &result, "OOOOOOOii", obpstrCode, obpstrFormalParams, obpstrProcedureName, obpstrItemName, obpunkContext, obpstrDelimiter, obContext, ulStartingLineNumber, dwFlags);
	Py_XDECREF(obpstrCode);
	Py_XDECREF(obpstrFormalParams);
	Py_XDECREF(obpstrProcedureName);
	Py_XDECREF(obpstrItemName);
	Py_XDECREF(obpunkContext);
	Py_XDECREF(obpstrDelimiter);
	Py_XDECREF(obContext);
	if (FAILED(hr)) return hr;
	// Process the Python results, and convert back to the real params
	PyObject *obppdisp;
	if (!PyArg_Parse(result, "O" , &obppdisp)) return PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/);
	BOOL bPythonIsHappy = TRUE;
	if (!PyCom_InterfaceFromPyInstanceOrObject(obppdisp, IID_IDispatch, (void **)ppdisp, TRUE /* bNoneOK */))
		 bPythonIsHappy = FALSE;
	if (!bPythonIsHappy) hr = PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/);
	Py_DECREF(result);
	return hr;
}

