Mercurial > games > semicongine
comparison fuhtark_test/include/winapi/comdef.h @ 1500:91c8c3b7cbf0
add: futhark tests for generating vulkan api
| author | sam <sam@basx.dev> |
|---|---|
| date | Wed, 26 Nov 2025 21:36:48 +0700 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1499:1f58458b7ef7 | 1500:91c8c3b7cbf0 |
|---|---|
| 1 /** | |
| 2 * This file has no copyright assigned and is placed in the Public Domain. | |
| 3 * This file is part of the w64 mingw-runtime package. | |
| 4 * No warranty is given; refer to the file DISCLAIMER within this package. | |
| 5 */ | |
| 6 #ifndef _INC_COMDEF | |
| 7 #define _INC_COMDEF | |
| 8 | |
| 9 #include <_mingw.h> | |
| 10 | |
| 11 #ifndef RC_INVOKED | |
| 12 | |
| 13 #ifndef __cplusplus | |
| 14 #error Native Compiler support only available in C++ compiler | |
| 15 #endif | |
| 16 | |
| 17 #include <ole2.h> | |
| 18 #include <olectl.h> | |
| 19 #include <comutil.h> | |
| 20 | |
| 21 #ifndef WINAPI | |
| 22 #define WINAPI __stdcall | |
| 23 #endif | |
| 24 | |
| 25 #ifdef __cplusplus | |
| 26 | |
| 27 class _com_error; | |
| 28 void WINAPI _com_raise_error(HRESULT hr,IErrorInfo *perrinfo = 0); | |
| 29 void WINAPI _set_com_error_handler(void (WINAPI *pHandler)(HRESULT hr,IErrorInfo *perrinfo)); | |
| 30 void WINAPI _com_issue_error(HRESULT); | |
| 31 void WINAPI _com_issue_errorex(HRESULT,IUnknown*,REFIID); | |
| 32 HRESULT WINAPI _com_dispatch_propget(IDispatch*,DISPID,VARTYPE,void*); | |
| 33 HRESULT __cdecl _com_dispatch_propput(IDispatch*,DISPID,VARTYPE,...); | |
| 34 HRESULT __cdecl _com_dispatch_method(IDispatch*,DISPID,WORD,VARTYPE,void*,const wchar_t*,...); | |
| 35 HRESULT WINAPI _com_dispatch_raw_propget(IDispatch*,DISPID,VARTYPE,void*) throw(); | |
| 36 HRESULT __cdecl _com_dispatch_raw_propput(IDispatch*,DISPID,VARTYPE,...) throw(); | |
| 37 HRESULT __cdecl _com_dispatch_raw_method(IDispatch*,DISPID,WORD,VARTYPE,void*,const wchar_t*,...) throw(); | |
| 38 | |
| 39 class _com_error { | |
| 40 public: | |
| 41 _com_error(HRESULT hr,IErrorInfo *perrinfo = NULL,bool fAddRef = false) throw(); | |
| 42 _com_error(const _com_error &that) throw(); | |
| 43 virtual ~_com_error() throw(); | |
| 44 _com_error &operator=(const _com_error &that) throw(); | |
| 45 HRESULT Error() const throw(); | |
| 46 WORD WCode() const throw(); | |
| 47 IErrorInfo *ErrorInfo() const throw(); | |
| 48 _bstr_t Description() const; | |
| 49 DWORD HelpContext() const throw(); | |
| 50 _bstr_t HelpFile() const; | |
| 51 _bstr_t Source() const; | |
| 52 GUID GUID() const throw(); | |
| 53 const TCHAR *ErrorMessage() const throw(); | |
| 54 static HRESULT WCodeToHRESULT(WORD wCode) throw(); | |
| 55 static WORD HRESULTToWCode(HRESULT hr) throw(); | |
| 56 private: | |
| 57 enum { | |
| 58 WCODE_HRESULT_FIRST = MAKE_HRESULT(SEVERITY_ERROR,FACILITY_ITF,0x200),WCODE_HRESULT_LAST = MAKE_HRESULT(SEVERITY_ERROR,FACILITY_ITF+1,0) - 1 | |
| 59 }; | |
| 60 const HRESULT m_hresult; | |
| 61 IErrorInfo *m_perrinfo; | |
| 62 mutable TCHAR *m_pszMsg; | |
| 63 }; | |
| 64 | |
| 65 inline _com_error::_com_error(HRESULT hr,IErrorInfo *perrinfo,bool fAddRef) throw() : m_hresult(hr),m_perrinfo(perrinfo),m_pszMsg(NULL) { | |
| 66 if(m_perrinfo!=NULL && fAddRef) m_perrinfo->AddRef(); | |
| 67 } | |
| 68 | |
| 69 inline _com_error::_com_error(const _com_error &that) throw() : m_hresult(that.m_hresult),m_perrinfo(that.m_perrinfo),m_pszMsg(NULL) { | |
| 70 if(m_perrinfo!=NULL) m_perrinfo->AddRef(); | |
| 71 } | |
| 72 | |
| 73 inline _com_error::~_com_error() throw() { | |
| 74 if(m_perrinfo!=NULL) m_perrinfo->Release(); | |
| 75 if(m_pszMsg!=NULL) LocalFree((HLOCAL)m_pszMsg); | |
| 76 } | |
| 77 | |
| 78 inline _com_error &_com_error::operator=(const _com_error &that) throw() { | |
| 79 if(this!=&that) { | |
| 80 this->_com_error::~_com_error(); | |
| 81 this->_com_error::_com_error(that); | |
| 82 } | |
| 83 return *this; | |
| 84 } | |
| 85 | |
| 86 inline HRESULT _com_error::Error() const throw() { return m_hresult; } | |
| 87 inline WORD _com_error::WCode() const throw() { return HRESULTToWCode(m_hresult); } | |
| 88 | |
| 89 inline IErrorInfo *_com_error::ErrorInfo() const throw() { | |
| 90 if(m_perrinfo!=NULL) m_perrinfo->AddRef(); | |
| 91 return m_perrinfo; | |
| 92 } | |
| 93 | |
| 94 inline _bstr_t _com_error::Description() const { | |
| 95 BSTR bstr = NULL; | |
| 96 if(m_perrinfo!=NULL) m_perrinfo->GetDescription(&bstr); | |
| 97 return _bstr_t(bstr,false); | |
| 98 } | |
| 99 | |
| 100 inline DWORD _com_error::HelpContext() const throw() { | |
| 101 DWORD dwHelpContext = 0; | |
| 102 if(m_perrinfo!=NULL) m_perrinfo->GetHelpContext(&dwHelpContext); | |
| 103 return dwHelpContext; | |
| 104 } | |
| 105 | |
| 106 inline _bstr_t _com_error::HelpFile() const { | |
| 107 BSTR bstr = NULL; | |
| 108 if(m_perrinfo!=NULL) m_perrinfo->GetHelpFile(&bstr); | |
| 109 return _bstr_t(bstr,false); | |
| 110 } | |
| 111 | |
| 112 inline _bstr_t _com_error::Source() const { | |
| 113 BSTR bstr = NULL; | |
| 114 if(m_perrinfo!=NULL) m_perrinfo->GetSource(&bstr); | |
| 115 return _bstr_t(bstr,false); | |
| 116 } | |
| 117 | |
| 118 inline _GUID _com_error::GUID() const throw() { | |
| 119 _GUID guid; | |
| 120 memset (&guid, 0, sizeof (_GUID)); | |
| 121 if(m_perrinfo!=NULL) m_perrinfo->GetGUID(&guid); | |
| 122 return guid; | |
| 123 } | |
| 124 | |
| 125 inline const TCHAR *_com_error::ErrorMessage() const throw() { | |
| 126 if(!m_pszMsg) { | |
| 127 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,NULL,m_hresult,MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),(LPTSTR)&m_pszMsg,0,NULL); | |
| 128 if(m_pszMsg!=NULL) { | |
| 129 int nLen = lstrlen(m_pszMsg); | |
| 130 if(nLen > 1 && m_pszMsg[nLen - 1]=='\n') { | |
| 131 m_pszMsg[nLen-1] = 0; | |
| 132 if(m_pszMsg[nLen - 2]=='\r') m_pszMsg[nLen-2] = 0; | |
| 133 } | |
| 134 } else { | |
| 135 m_pszMsg = (LPTSTR)LocalAlloc(0,32 *sizeof(TCHAR)); | |
| 136 if(m_pszMsg!=NULL) { | |
| 137 WORD wCode = WCode(); | |
| 138 if(wCode!=0) { | |
| 139 _COM_PRINTF_S_1(m_pszMsg,32,TEXT("IDispatch error #%d"),wCode); | |
| 140 } else { | |
| 141 _COM_PRINTF_S_1(m_pszMsg,32,TEXT("Unknown error 0x%0lX"),m_hresult); | |
| 142 } | |
| 143 } | |
| 144 } | |
| 145 } | |
| 146 return m_pszMsg; | |
| 147 } | |
| 148 | |
| 149 inline HRESULT _com_error::WCodeToHRESULT(WORD wCode) throw() { return wCode >= 0xFE00 ? WCODE_HRESULT_LAST : WCODE_HRESULT_FIRST + wCode; } | |
| 150 inline WORD _com_error::HRESULTToWCode(HRESULT hr) throw() { return (hr >= WCODE_HRESULT_FIRST && hr <= WCODE_HRESULT_LAST) ? WORD(hr - WCODE_HRESULT_FIRST) : 0; } | |
| 151 | |
| 152 typedef int __missing_type__; | |
| 153 | |
| 154 #if !defined(_COM_SMARTPTR) | |
| 155 #if !defined(_INC_COMIP) | |
| 156 #include <comip.h> | |
| 157 #endif | |
| 158 #define _COM_SMARTPTR _com_ptr_t | |
| 159 #define _COM_SMARTPTR_LEVEL2 _com_IIID | |
| 160 #endif | |
| 161 #if defined(_COM_SMARTPTR) | |
| 162 #if !defined(_COM_SMARTPTR_TYPEDEF) | |
| 163 #if defined(_COM_SMARTPTR_LEVEL2) | |
| 164 #define _COM_SMARTPTR_TYPEDEF(Interface,IID) typedef _COM_SMARTPTR<_COM_SMARTPTR_LEVEL2<Interface,&IID> > Interface ## Ptr | |
| 165 #else | |
| 166 #define _COM_SMARTPTR_TYPEDEF(Interface,IID) typedef _COM_SMARTPTR<Interface,&IID> Interface ## Ptr | |
| 167 #endif | |
| 168 #endif | |
| 169 #endif | |
| 170 | |
| 171 #if !defined(_COM_NO_STANDARD_GUIDS_) && USE___UUIDOF != 0 | |
| 172 #if defined(__IFontDisp_INTERFACE_DEFINED__) | |
| 173 __if_not_exists(Font) | |
| 174 { | |
| 175 struct Font : IFontDisp {}; | |
| 176 } | |
| 177 _COM_SMARTPTR_TYPEDEF(Font,__uuidof(IDispatch)); | |
| 178 #endif | |
| 179 #if defined(__IFontEventsDisp_INTERFACE_DEFINED__) | |
| 180 __if_not_exists(FontEvents) | |
| 181 { | |
| 182 struct FontEvents : IFontEventsDisp {}; | |
| 183 } | |
| 184 _COM_SMARTPTR_TYPEDEF(FontEvents,__uuidof(IDispatch)); | |
| 185 #endif | |
| 186 #if defined(__IPictureDisp_INTERFACE_DEFINED__) | |
| 187 __if_not_exists(Picture) | |
| 188 { | |
| 189 struct Picture : IPictureDisp {}; | |
| 190 } | |
| 191 _COM_SMARTPTR_TYPEDEF(Picture,__uuidof(IDispatch)); | |
| 192 #endif | |
| 193 | |
| 194 #include "comdefsp.h" | |
| 195 #endif | |
| 196 #endif | |
| 197 | |
| 198 #endif /* __cplusplus */ | |
| 199 | |
| 200 #endif |
