Changeset 35724 in vbox
- Timestamp:
- Jan 26, 2011 5:16:10 PM (14 years ago)
- Location:
- trunk/include/VBox/com
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/com/defs.h
r35722 r35724 273 273 #define COM_INTERFACE_ENTRY2(a,b) 274 274 #define END_COM_MAP() NS_DECL_ISUPPORTS 275 #define COM_INTERFACE_ENTRY_AGGREGATE(a,b) 275 276 276 277 #define HRESULT nsresult -
trunk/include/VBox/com/listeners.h
r35722 r35724 47 47 48 48 template <class T, class TParam = void* > 49 class ListenerImpl : 49 class ListenerImpl : 50 50 public CComObjectRootEx<CComMultiThreadModel>, 51 51 VBOX_SCRIPTABLE_IMPL(IEventListener) … … 56 56 /* FTM stuff */ 57 57 CComPtr <IUnknown> m_pUnkMarshaler; 58 #else 59 nsAutoRefCnt mRefCnt; 60 NS_DECL_OWNINGTHREAD 58 61 #endif 59 62 … … 61 64 ListenerImpl() 62 65 { 63 } 66 } 64 67 65 68 virtual ~ListenerImpl() … … 69 72 HRESULT init(T* aListener, TParam param) 70 73 { 71 mListener = aListener; 74 mListener = aListener; 72 75 return mListener->init(param); 73 76 } … … 94 97 return CoCreateFreeThreadedMarshaler(this, &m_pUnkMarshaler.p); 95 98 #else 96 mRefCnt = 1;97 99 return S_OK; 98 100 #endif … … 112 114 } 113 115 114 /* On Windows QI implemented by COM_MAP() */115 #ifndef RT_OS_WINDOWS116 NS_IMPL_QUERY_INTERFACE1_INLINE(IEventListener)117 #endif118 119 116 DECLARE_NOT_AGGREGATABLE(ListenerImpl) 120 117 121 118 DECLARE_PROTECT_FINAL_CONSTRUCT() 122 119 120 #ifdef RT_OS_WINDOWS 123 121 BEGIN_COM_MAP(ListenerImpl) 124 COM_INTERFACE_ENTRY(IEventListener) 122 COM_INTERFACE_ENTRY(IEventListener) 125 123 COM_INTERFACE_ENTRY2(IDispatch, IEventListener) 126 124 COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p) 127 125 END_COM_MAP() 126 #else 127 NS_IMETHOD_(nsrefcnt) AddRef(void) 128 { 129 NS_PRECONDITION(PRInt32(mRefCnt) >= 0, "illegal refcnt"); 130 nsrefcnt count; 131 count = PR_AtomicIncrement((PRInt32*)&mRefCnt); 132 NS_LOG_ADDREF(this, count, "ListenerImpl", sizeof(*this)); 133 return count; 134 } 135 136 NS_IMETHOD_(nsrefcnt) Release(void) 137 { 138 nsrefcnt count; 139 NS_PRECONDITION(0 != mRefCnt, "dup release"); 140 count = PR_AtomicDecrement((PRInt32 *)&mRefCnt); 141 NS_LOG_RELEASE(this, count, "ListenerImpl"); 142 if (0 == count) { 143 mRefCnt = 1; /* stabilize */ 144 /* enable this to find non-threadsafe destructors: */ 145 /* NS_ASSERT_OWNINGTHREAD(_class); */ 146 NS_DELETEXPCOM(this); 147 return 0; 148 } 149 return count; 150 } 151 152 NS_IMPL_QUERY_INTERFACE1_INLINE(IEventListener) 153 #endif 128 154 129 155
Note:
See TracChangeset
for help on using the changeset viewer.