[commit] r2386 - trunk/SDK/BON/Common

GMESRC Repository Notifications gme-commit at list.isis.vanderbilt.edu
Mon Oct 14 16:26:39 CDT 2013


Author: ksmyth
Date: Mon Oct 14 16:26:39 2013
New Revision: 2386

Log:
Let interpreters implement ISupporterErrorInfo. Set error info based on _com_error

Modified:
   trunk/SDK/BON/Common/ComHelp.cpp
   trunk/SDK/BON/Common/ComponentObj.cpp
   trunk/SDK/BON/Common/ComponentObj.h

Modified: trunk/SDK/BON/Common/ComHelp.cpp
==============================================================================
--- trunk/SDK/BON/Common/ComHelp.cpp	Mon Oct 14 16:26:26 2013	(r2385)
+++ trunk/SDK/BON/Common/ComHelp.cpp	Mon Oct 14 16:26:39 2013	(r2386)
@@ -16,3 +16,17 @@
 		SetErrorInfo(0, errorInfo);
 	}
 }
+
+__declspec(noreturn) void ThrowComError(HRESULT hr, LPOLESTR err)
+{
+	ICreateErrorInfoPtr errCreate;
+	if (SUCCEEDED(CreateErrorInfo(&errCreate))
+		&& SUCCEEDED(errCreate->SetDescription(const_cast<wchar_t*>(err)))
+		&& SUCCEEDED(errCreate->SetSource(const_cast<wchar_t*>(g_COCLASS_PROGIDW)))
+		)
+	{
+		IErrorInfoPtr errorInfo = errCreate;
+		throw _com_error(hr, errorInfo.Detach());
+	}
+	throw _com_error(hr);
+}

Modified: trunk/SDK/BON/Common/ComponentObj.cpp
==============================================================================
--- trunk/SDK/BON/Common/ComponentObj.cpp	Mon Oct 14 16:26:26 2013	(r2385)
+++ trunk/SDK/BON/Common/ComponentObj.cpp	Mon Oct 14 16:26:39 2013	(r2386)
@@ -346,6 +346,9 @@
 #endif
 	INTERFACE_PART(CComponentObj, IID_IMgaComponent, Component)
 	INTERFACE_PART(CComponentObj, IID_IGMEVersionInfo, VersionInfo)
+#ifdef GME_COMPONENT_ISUPPORTERRORINFO
+	INTERFACE_PART(CComponentObj, IID_ISupportErrorInfo, SupportErrorInfo)
+#endif
 END_INTERFACE_MAP()
 
 // We register the ComponentClass
@@ -897,8 +900,9 @@
 
 	ASSERT( gme != NULL );
 
-
-	return pThis->rawcomp.Invoke(gme, psa, param);
+	COMTRY {
+		return pThis->rawcomp.Invoke(gme, psa, param);
+	} COMCATCH(;);
 }
 
 
@@ -908,8 +912,9 @@
 
 	ASSERT( gme != NULL );
 
-
-	return pThis->rawcomp.InvokeEx(gme, currentobj, selectedobjs, param);
+	COMTRY {
+		return pThis->rawcomp.InvokeEx(gme, currentobj, selectedobjs, param);
+	} COMCATCH(;);
 }
 
 STDMETHODIMP COMCLASS::ObjectsInvokeEx( IMgaProject *gme,  IMgaObject *currentobj,  IMgaObjects *selectedobjs,  long param) {
@@ -919,7 +924,9 @@
 	ASSERT( gme != NULL );
 
 
-	return pThis->rawcomp.ObjectsInvokeEx(gme, currentobj, selectedobjs, param);
+	COMTRY {
+		return pThis->rawcomp.ObjectsInvokeEx(gme, currentobj, selectedobjs, param);
+	} COMCATCH(;);
 }
 
 // You may also want to modify the implementations for the following methods
@@ -949,7 +956,8 @@
 };
 STDMETHODIMP COMCLASS::get_InteractiveMode(VARIANT_BOOL *enabled) {
 	COMPROLOGUE;
-	if(enabled) *enabled = pThis->interactive ? VARIANT_TRUE : VARIANT_FALSE;
+	if (enabled)
+		*enabled = pThis->interactive ? VARIANT_TRUE : VARIANT_FALSE;
 	return S_OK;
 };
 
@@ -965,15 +973,17 @@
 STDMETHODIMP COMCLASS::get_ComponentParameter( BSTR name, VARIANT *pVal )
 {
 	COMPROLOGUE;
-	pThis->rawcomp.get_ComponentParameter(name, pVal);
-	return S_OK;
+	COMTRY {
+		pThis->rawcomp.get_ComponentParameter(name, pVal);
+	} COMCATCH(;);
 }
 
 STDMETHODIMP COMCLASS::put_ComponentParameter( BSTR name, VARIANT newVal )
 {
 	COMPROLOGUE;
-	return pThis->rawcomp.put_ComponentParameter(name, newVal);
-	return S_OK;
+	COMTRY {
+		return pThis->rawcomp.put_ComponentParameter(name, newVal);
+	} COMCATCH(;);
 }
 
 #endif // BUILDER_OBJECT_NETWORK_V2
@@ -1046,6 +1056,33 @@
 #undef COMCLASS
 #undef COMPROLOGUE
 
+/////////////////////////////////////////////////////////////////////////////
+// CComponentObj::XSupportErrorInfo
+
+#define COMCLASS		CComponentObj::XSupportErrorInfo
+#define COMPROLOGUE		METHOD_PROLOGUE(CComponentObj, SupportErrorInfo)
+
+STDMETHODIMP_(ULONG) COMCLASS::AddRef()
+{
+	COMPROLOGUE;
+	return pThis->ExternalAddRef();
+}
+
+STDMETHODIMP_(ULONG) COMCLASS::Release()
+{
+	COMPROLOGUE;
+	return pThis->ExternalRelease();
+}
+
+STDMETHODIMP COMCLASS::QueryInterface(REFIID riid, void** ppv)
+{
+	COMPROLOGUE;
+	return pThis->ExternalQueryInterface(&riid, ppv);
+}
+
+#undef COMCLASS
+#undef COMPROLOGUE
+
 // --------------------------- CComponentReg
 
 CComponentReg::CComponentReg()

Modified: trunk/SDK/BON/Common/ComponentObj.h
==============================================================================
--- trunk/SDK/BON/Common/ComponentObj.h	Mon Oct 14 16:26:26 2013	(r2385)
+++ trunk/SDK/BON/Common/ComponentObj.h	Mon Oct 14 16:26:39 2013	(r2386)
@@ -12,14 +12,12 @@
 
 #if defined(BUILDER_OBJECT_NETWORK)
 #else
-// BY PAKA BEGIN
 #ifdef BUILDER_OBJECT_NETWORK_V2
 #include "BON.h"
 #include <BON2Component.h>
 #else
 #include <RawComponent.h>
 #endif // BUILDER_OBJECT_NETWORK_V2
-// BY PAKA END
 #endif // BUILDER_OBJECT_NETWORK
 
 #pragma once
@@ -158,6 +156,16 @@
 		STDMETHODIMP get_version(enum GMEInterfaceVersion *pVal);
 	END_INTERFACE_PART(VersionInfo)
 
+	BEGIN_INTERFACE_PART(SupportErrorInfo, ISupportErrorInfo)
+		STDMETHODIMP InterfaceSupportsErrorInfo(REFIID riid)
+		{
+			if (riid == __uuidof(IMgaComponentEx) || riid == __uuidof(IMgaComponent))
+			{
+				return S_OK;
+			}
+			return S_FALSE;
+		}
+	END_INTERFACE_PART(SupportErrorInfo)
 public:
 	bool interactive;
 


More information about the gme-commit mailing list