[commit] r2535 - trunk/SDK/BON/Common
GMESRC Repository Notifications
gme-commit at list.isis.vanderbilt.edu
Wed Sep 24 09:55:04 CDT 2014
Author: ksmyth
Date: Wed Sep 24 09:55:04 2014
New Revision: 2535
Log:
Towards supporting compilation without MFC/ATL
Modified:
trunk/SDK/BON/Common/ComHelp.h
trunk/SDK/BON/Common/Console.cpp
trunk/SDK/BON/Common/Console.h
trunk/SDK/BON/Common/Exceptions.h
Modified: trunk/SDK/BON/Common/ComHelp.h
==============================================================================
--- trunk/SDK/BON/Common/ComHelp.h Wed Sep 24 09:54:59 2014 (r2534)
+++ trunk/SDK/BON/Common/ComHelp.h Wed Sep 24 09:55:04 2014 (r2535)
@@ -1,17 +1,10 @@
#pragma once
-#include <afxtempl.h>
#include <unknwn.h>
-#include <atlbase.h>
#include <comdef.h>
// --------------------------- MACROS
-inline void COMVERIFY(HRESULT hr)
-{
- VERIFY(SUCCEEDED(hr));
-}
-
inline void COMASSERT(HRESULT hr)
{
ASSERT(SUCCEEDED(hr));
@@ -19,6 +12,15 @@
// --------------------------- CBstr
+#ifdef __AFX_H__
+#include <afxtempl.h>
+
+inline void COMVERIFY(HRESULT hr)
+{
+ VERIFY(SUCCEEDED(hr));
+}
+
+
class CBstr
{
public:
@@ -67,3 +69,4 @@
BSTR s;
};
+#endif
Modified: trunk/SDK/BON/Common/Console.cpp
==============================================================================
--- trunk/SDK/BON/Common/Console.cpp Wed Sep 24 09:54:59 2014 (r2534)
+++ trunk/SDK/BON/Common/Console.cpp Wed Sep 24 09:55:04 2014 (r2535)
@@ -2,6 +2,7 @@
#include "Console.h"
#include "Gme.h"
+#include <comdef.h>
namespace GMEConsole
{
@@ -11,7 +12,7 @@
{
CComPtr<IMgaClient> client;
CComQIPtr<IDispatch> pDispatch;
- HRESULT s1 = project->GetClientByName(CComBSTR(L"GME.Application"), &client);
+ HRESULT s1 = project->GetClientByName(_bstr_t(L"GME.Application"), &client);
if ((SUCCEEDED(s1)) && (client != 0))
{
@@ -24,10 +25,12 @@
}
void Console::ReleaseConsole() {
if (gmeoleapp)
- gmeoleapp.Release();
+ {
+ gmeoleapp.Detach()->Release();
+ }
}
- void Console::WriteLine(const CString& message, msgtype_enum type)
+ void Console::WriteLine(const TCHAR* message, msgtype_enum type)
{
if (gmeoleapp == 0) {
switch (type) {
@@ -42,50 +45,49 @@
}
}
else {
- COMTHROW(gmeoleapp->ConsoleMessage( CComBSTR(message.GetLength(),message),type));
+ COMTHROW(gmeoleapp->ConsoleMessage(_bstr_t(message), type));
}
}
void Console::Clear()
{
if (gmeoleapp != 0) {
- CComBSTR empty(L"");
- COMTHROW(gmeoleapp->put_ConsoleContents(empty));
+ COMTHROW(gmeoleapp->put_ConsoleContents(NULL));
}
}
- void Console::SetContents(const CString& contents)
+ void Console::SetContents(const TCHAR* contents)
{
if (gmeoleapp != 0) {
- COMTHROW(gmeoleapp->put_ConsoleContents( CComBSTR(contents.GetLength(),contents)));
+ COMTHROW(gmeoleapp->put_ConsoleContents(_bstr_t(contents)));
}
}
- void Console::NavigateTo(const CString& url)
+ void Console::NavigateTo(const TCHAR* url)
{
if (gmeoleapp != 0) {
- COMTHROW(gmeoleapp->ConsoleNavigateTo(CComBSTR(url.GetLength(), url)));
+ COMTHROW(gmeoleapp->ConsoleNavigateTo(_bstr_t(url)));
}
}
- void Console::Error::WriteLine(const CString& message)
+ void Console::Error::WriteLine(const TCHAR* message)
{
Console::WriteLine(message,MSG_ERROR);
}
- void Console::Out::WriteLine(const CString& message)
+ void Console::Out::WriteLine(const TCHAR* message)
{
Console::WriteLine(message, MSG_NORMAL);
}
- void Console::Warning::WriteLine(const CString& message)
+ void Console::Warning::WriteLine(const TCHAR* message)
{
Console::WriteLine(message, MSG_WARNING);
}
- void Console::Info::writeLine(const CString& message)
+ void Console::Info::writeLine(const TCHAR* message)
{
Console::WriteLine(message,MSG_INFO);
}
- void Console::Info::WriteLine(const CString& message)
+ void Console::Info::WriteLine(const TCHAR* message)
{
Console::WriteLine(message,MSG_INFO);
}
Modified: trunk/SDK/BON/Common/Console.h
==============================================================================
--- trunk/SDK/BON/Common/Console.h Wed Sep 24 09:54:59 2014 (r2534)
+++ trunk/SDK/BON/Common/Console.h Wed Sep 24 09:55:04 2014 (r2535)
@@ -16,35 +16,35 @@
static void SetupConsole(CComPtr<IMgaProject> project);
static void ReleaseConsole();
- static void WriteLine(const CString& message, msgtype_enum type);
+ static void WriteLine(const TCHAR* message, msgtype_enum type);
static void Clear();
- static void SetContents(const CString& contents);
+ static void SetContents(const TCHAR* contents);
- static void NavigateTo(const CString& url);
+ static void NavigateTo(const TCHAR* url);
class Error
{
public:
- static void WriteLine(const CString& message);
+ static void WriteLine(const TCHAR* message);
};
class Out
{
public:
- static void WriteLine(const CString& message);
+ static void WriteLine(const TCHAR* message);
};
class Warning
{
public:
- static void WriteLine(const CString& message);
+ static void WriteLine(const TCHAR* message);
};
class Info
{
public:
- static void WriteLine(const CString& message);
+ static void WriteLine(const TCHAR* message);
// deprecated:
- static void writeLine(const CString& message);
+ static void writeLine(const TCHAR* message);
};
};
}
\ No newline at end of file
Modified: trunk/SDK/BON/Common/Exceptions.h
==============================================================================
--- trunk/SDK/BON/Common/Exceptions.h Wed Sep 24 09:54:59 2014 (r2534)
+++ trunk/SDK/BON/Common/Exceptions.h Wed Sep 24 09:55:04 2014 (r2535)
@@ -32,17 +32,23 @@
template<class T>
-inline void COMCHECK2(const CComPtr<T>& p, const HRESULT hr)
+inline void COMCHECK2(T* p, const HRESULT hr)
{
if (!SUCCEEDED(hr)) {
const IID piid = __uuidof(T);
- CComQIPtr<ISupportErrorInfo> supportErrorInfo = p;
+ ISupportErrorInfo* supportErrorInfo;
+ p->QueryInterface(__uuidof(ISupportErrorInfo), &supportErrorInfo);
if (supportErrorInfo != NULL && supportErrorInfo->InterfaceSupportsErrorInfo(piid) == S_OK) {
- CComQIPtr<IErrorInfo> errorInfo;
+ p->Release();
+ IErrorInfo* errorInfo;
GetErrorInfo(0, &errorInfo);
_bstr_t bstr;
- errorInfo->GetDescription(bstr.GetAddress());
+ if (errorInfo)
+ {
+ errorInfo->GetDescription(bstr.GetAddress());
+ errorInfo->Release();
+ }
BON::Exception exception(hr, "?");
exception << static_cast<const TCHAR*>(bstr);
@@ -54,11 +60,6 @@
}
}
-template<class T>
-inline void COMCHECK2(T* p, const HRESULT hr) {
- COMCHECK2(CComPtr<T>(p), hr);
-}
-
#define ASSERTTHROW( exc ) \
{ \
ASSERT( ( exc.getErrorMessage().c_str(), false ) ); \
More information about the gme-commit
mailing list