From c740efcd3a79e882982dbe4f0dff483c52045776 Mon Sep 17 00:00:00 2001 From: Muktesh Date: Fri, 3 Feb 2017 14:04:56 -0800 Subject: [PATCH] Objc2Winmd binary update: (#1913) * Objc2Winmd binary update: Fixed memory leak issues with IAsyncOperation implementation * ObjC2Winmd binary update: Removed unnecessary comments --- bin/objc2winmd.exe | 4 +- .../UWP/ObjCHelperAsyncImplementation.h | 57 ++++++++++++++++++- 2 files changed, 56 insertions(+), 5 deletions(-) diff --git a/bin/objc2winmd.exe b/bin/objc2winmd.exe index 7656c5dd7e..d45196498d 100644 --- a/bin/objc2winmd.exe +++ b/bin/objc2winmd.exe @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:eaecb99a41f6959c0359b9b4589dfa53520813ba96c955d34a37231f75e7a16e -size 2267648 +oid sha256:60c378dc7c27b801e86d33f99da8c36994e9eda76671cec68ac3da3e6343d869 +size 579072 diff --git a/include/Platform/Universal Windows/UWP/ObjCHelperAsyncImplementation.h b/include/Platform/Universal Windows/UWP/ObjCHelperAsyncImplementation.h index 85a3bba3e3..d553c5da62 100644 --- a/include/Platform/Universal Windows/UWP/ObjCHelperAsyncImplementation.h +++ b/include/Platform/Universal Windows/UWP/ObjCHelperAsyncImplementation.h @@ -25,9 +25,7 @@ inline std::wstring getWString(const char* str) { return std::wstring(&str[0], &str[len - 1]); } -//ABI::FacebookSDK::FBSDKLoginKit::FBSDKLoginManagerLoginResult -//ABI::FacebookSDK::FBSDKLoginKit::IFBSDKLoginManagerLoginResult -template +template class AsyncOperationImpl : public RuntimeClass< RuntimeClassFlags, @@ -77,4 +75,57 @@ class AsyncOperationImpl : void OnClose() override {} void OnCancel() override {} }; + +template +class AsyncOperationImpl : + public RuntimeClass< + RuntimeClassFlags, + IAsyncOperation, + AsyncBase>> { + + typedef RuntimeClass, + IAsyncOperation, + AsyncBase>> RuntimeClassT; + + // This will fail for double pointer (and higher level pointers), but we do not care so much about them. + InspectableClass((std::wstring(L"Windows.Foundation.IAsyncOperation") + getWString(typeid(std::remove_pointer).name())).c_str(), BaseTrust); + + ComPtr::type> _result; +public: + AsyncOperationImpl() + { + Start(); + } + IFACEMETHODIMP put_Completed(IAsyncOperationCompletedHandler *pCompleteHandler) override + { + return AsyncBase::PutOnComplete(pCompleteHandler); + } + IFACEMETHODIMP get_Completed(IAsyncOperationCompletedHandler **ppCompleteHandler) override + { + return AsyncBase::GetOnComplete(ppCompleteHandler); + } + void setResult(resultInterfaceType result) + { + _result.Attach(result); + FireCompletion(); + } + IFACEMETHODIMP GetResults(resultInterfaceType* results) override + { + *results = 0; + HRESULT hr = AsyncBase::CheckValidStateForResultsCall(); + if (SUCCEEDED(hr)) + { + // Implicit AddRef + ComPtr::type> ptr = _result; + *results = ptr.Detach(); + } + return hr; + } + HRESULT OnStart() override + { + return S_OK; + } + void OnClose() override {} + void OnCancel() override {} +}; } \ No newline at end of file