michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsXPTCUtils_h__ michael@0: #define nsXPTCUtils_h__ michael@0: michael@0: #include "xptcall.h" michael@0: michael@0: /** michael@0: * A helper class that initializes an xptcall helper at construction michael@0: * and releases it at destruction. michael@0: */ michael@0: class nsAutoXPTCStub : protected nsIXPTCProxy michael@0: { michael@0: public: michael@0: nsISomeInterface* mXPTCStub; michael@0: michael@0: protected: michael@0: nsAutoXPTCStub() : mXPTCStub(nullptr) { } michael@0: michael@0: nsresult michael@0: InitStub(const nsIID& aIID) michael@0: { michael@0: return NS_GetXPTCallStub(aIID, this, &mXPTCStub); michael@0: } michael@0: michael@0: ~nsAutoXPTCStub() michael@0: { michael@0: if (mXPTCStub) michael@0: NS_DestroyXPTCallStub(mXPTCStub); michael@0: } michael@0: }; michael@0: michael@0: #endif // nsXPTCUtils_h__