1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/xpcom/glue/nsXPTCUtils.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,35 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +#ifndef nsXPTCUtils_h__ 1.9 +#define nsXPTCUtils_h__ 1.10 + 1.11 +#include "xptcall.h" 1.12 + 1.13 +/** 1.14 + * A helper class that initializes an xptcall helper at construction 1.15 + * and releases it at destruction. 1.16 + */ 1.17 +class nsAutoXPTCStub : protected nsIXPTCProxy 1.18 +{ 1.19 +public: 1.20 + nsISomeInterface* mXPTCStub; 1.21 + 1.22 +protected: 1.23 + nsAutoXPTCStub() : mXPTCStub(nullptr) { } 1.24 + 1.25 + nsresult 1.26 + InitStub(const nsIID& aIID) 1.27 + { 1.28 + return NS_GetXPTCallStub(aIID, this, &mXPTCStub); 1.29 + } 1.30 + 1.31 + ~nsAutoXPTCStub() 1.32 + { 1.33 + if (mXPTCStub) 1.34 + NS_DestroyXPTCallStub(mXPTCStub); 1.35 + } 1.36 +}; 1.37 + 1.38 +#endif // nsXPTCUtils_h__