Changeset 60765 in vbox for trunk/include
- Timestamp:
- Apr 29, 2016 2:26:58 PM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 106960
- Location:
- trunk/include/VBox/com
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/com/defs.h
r60506 r60765 4 4 5 5 /* 6 * Copyright (C) 2006-201 5Oracle Corporation6 * Copyright (C) 2006-2016 Oracle Corporation 7 7 * 8 8 * This file is part of VirtualBox Open Source Edition (OSE), as … … 82 82 #include <objbase.h> 83 83 #ifndef VBOX_COM_NO_ATL 84 # define _ATL_FREE_THREADED 85 86 # include <atlbase.h> 87 #include <atlcom.h> 88 #endif 84 85 /* Do not use actual ATL, just provide a superficial lookalike ourselves. */ 86 # include <VBox/com/microatl.h> 87 #endif /* VBOX_COM_NO_ATL */ 89 88 90 89 #define NS_DECL_ISUPPORTS … … 126 125 #define IN_GUID GUID 127 126 /** Output GUID argument of interface method declaration. */ 128 #define OUT_GUID GUID *127 #define OUT_GUID GUID * 129 128 130 129 /** Makes the name of the getter interface function (n must be capitalized). */ … … 250 249 * @param I interface class 251 250 */ 252 #define COM_IIDOF(I) _ ATL_IIDOF(I)251 #define COM_IIDOF(I) __uuidof(I) 253 252 254 253 /** … … 280 279 281 280 #include <nsID.h> 281 282 #ifndef VBOX_COM_NO_ATL 283 284 namespace ATL 285 { 282 286 283 287 #define ATL_NO_VTABLE … … 292 296 #define END_COM_MAP() NS_DECL_ISUPPORTS 293 297 #define COM_INTERFACE_ENTRY_AGGREGATE(a,b) 298 299 /* A few very simple ATL emulator classes to provide 300 * FinalConstruct()/FinalRelease() functionality with XPCOM. */ 301 302 class CComMultiThreadModel 303 { 304 }; 305 306 template <class DummyThreadModel> class CComObjectRootEx 307 { 308 public: 309 HRESULT FinalConstruct() 310 { 311 return S_OK; 312 } 313 void FinalRelease() 314 { 315 } 316 }; 317 318 template <class DummyThreadModel> class CComObject 319 { 320 public: 321 virtual ~CComObject() { this->FinalRelease(); } 322 }; 323 324 } /* namespace ATL */ 325 326 #endif /* !VBOX_COM_NO_ATL */ 294 327 295 328 #define HRESULT nsresult … … 394 427 #define COM_STRUCT_OR_CLASS(I) class I 395 428 396 namespace ATL397 {398 399 /* A few very simple ATL emulator classes to provide400 * FinalConstruct()/FinalRelease() functionality on Linux. */401 402 class CComMultiThreadModel403 {404 };405 406 template <class Base> class CComObjectRootEx : public Base407 {408 public:409 HRESULT FinalConstruct() { return S_OK; }410 void FinalRelease() {}411 };412 413 template <class Base> class CComObject : public Base414 {415 public:416 virtual ~CComObject() { this->FinalRelease(); }417 };418 419 } /* namespace ATL */420 421 using namespace ATL;422 423 429 /* helper functions */ 424 430 extern "C" 425 431 { 426 BSTR SysAllocString(const OLECHAR *sz);432 BSTR SysAllocString(const OLECHAR *sz); 427 433 BSTR SysAllocStringByteLen(char *psz, unsigned int len); 428 434 BSTR SysAllocStringLen(const OLECHAR *pch, unsigned int cch); … … 434 440 } 435 441 442 #ifndef VBOX_COM_NO_ATL 443 436 444 /** 437 445 * 'Constructor' for the component class. … … 455 463 } \ 456 464 \ 457 CComObject <_InstanceClass> *inst = new CComObject <_InstanceClass>();\465 CComObject<_InstanceClass> *inst = new CComObject<_InstanceClass>(); \ 458 466 if (NULL == inst) { \ 459 467 rv = NS_ERROR_OUT_OF_MEMORY; \ … … 486 494 nsresult rv; \ 487 495 \ 488 _InstanceClass * inst = NULL; /* initialized to shut up gcc */\496 _InstanceClass *inst = NULL; /* initialized to shut up gcc */ \ 489 497 \ 490 498 *aResult = NULL; \ … … 510 518 return rv; \ 511 519 } 520 521 #endif /* !VBOX_COM_NO_ATL */ 512 522 513 523 #endif /* !defined(VBOX_WITH_XPCOM) */ … … 529 539 { 530 540 541 #ifndef VBOX_COM_NO_ATL 542 531 543 // use this macro to implement scriptable interfaces 532 544 #ifdef RT_OS_WINDOWS 533 545 #define VBOX_SCRIPTABLE_IMPL(iface) \ 534 public IDispatchImpl<iface, &IID_##iface, &LIBID_VirtualBox,\535 kTypeLibraryMajorVersion, kTypeLibraryMinorVersion>546 public ATL::IDispatchImpl<iface, &IID_##iface, &LIBID_VirtualBox, \ 547 kTypeLibraryMajorVersion, kTypeLibraryMinorVersion> 536 548 537 549 #define VBOX_SCRIPTABLE_DISPATCH_IMPL(iface) \ 538 STDMETHOD(QueryInterface)(REFIID riid , void **ppObj)\550 STDMETHOD(QueryInterface)(REFIID riid, void **ppObj) \ 539 551 { \ 540 552 if (riid == IID_##iface) \ 541 553 { \ 542 *ppObj = (iface *)this;\554 *ppObj = (iface *)this; \ 543 555 AddRef(); \ 544 556 return S_OK; \ … … 546 558 if (riid == IID_IUnknown) \ 547 559 { \ 548 *ppObj = (IUnknown *)this;\560 *ppObj = (IUnknown *)this; \ 549 561 AddRef(); \ 550 562 return S_OK; \ … … 552 564 if (riid == IID_IDispatch) \ 553 565 { \ 554 *ppObj = (IDispatch *)this;\566 *ppObj = (IDispatch *)this; \ 555 567 AddRef(); \ 556 568 return S_OK; \ … … 559 571 return E_NOINTERFACE; \ 560 572 } 561 562 563 #define VBOX_DEFAULT_INTERFACE_ENTRIES(iface) \564 COM_INTERFACE_ENTRY(ISupportErrorInfo) \565 COM_INTERFACE_ENTRY(iface) \566 COM_INTERFACE_ENTRY2(IDispatch,iface) \567 COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p)568 573 #else 569 574 #define VBOX_SCRIPTABLE_IMPL(iface) \ 570 575 public iface 571 576 #define VBOX_SCRIPTABLE_DISPATCH_IMPL(iface) 572 #define VBOX_DEFAULT_INTERFACE_ENTRIES(iface)573 577 #endif 574 578 579 #endif /* !VBOX_COM_NO_ATL */ 575 580 576 581 } /* namespace com */
Note:
See TracChangeset
for help on using the changeset viewer.