Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Objc2Winmd binary update: #1913

Merged
merged 2 commits into from
Feb 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bin/objc2winmd.exe
Git LFS file not shown
Original file line number Diff line number Diff line change
Expand Up @@ -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<typename resultType, typename resultInterfaceType>
template<typename resultType, typename resultInterfaceType, bool = _is_COM_Object(resultInterfaceType)>
class AsyncOperationImpl :
public RuntimeClass<
RuntimeClassFlags<WinRtClassicComMix>,
Expand Down Expand Up @@ -77,4 +75,57 @@ class AsyncOperationImpl :
void OnClose() override {}
void OnCancel() override {}
};

template<typename resultType, typename resultInterfaceType>
class AsyncOperationImpl<resultType, resultInterfaceType, true> :
public RuntimeClass<
RuntimeClassFlags<WinRtClassicComMix>,
IAsyncOperation<resultType>,
AsyncBase<IAsyncOperationCompletedHandler<resultType>>> {

typedef RuntimeClass<RuntimeClassFlags<WinRtClassicComMix>,
IAsyncOperation<resultType>,
AsyncBase<IAsyncOperationCompletedHandler<resultType>>> 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<resultType>).name())).c_str(), BaseTrust);

ComPtr<typename std::remove_pointer<resultInterfaceType>::type> _result;
public:
AsyncOperationImpl()
{
Start();
}
IFACEMETHODIMP put_Completed(IAsyncOperationCompletedHandler<resultType> *pCompleteHandler) override
{
return AsyncBase::PutOnComplete(pCompleteHandler);
}
IFACEMETHODIMP get_Completed(IAsyncOperationCompletedHandler<resultType> **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<typename std::remove_pointer<resultInterfaceType>::type> ptr = _result;
*results = ptr.Detach();
}
return hr;
}
HRESULT OnStart() override
{
return S_OK;
}
void OnClose() override {}
void OnCancel() override {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is all duplicated. It would be nice to avoid the duplication.

However, for now, let's leave it.
I'd really like to switch to some WRL templates if they exist.

I'll file a task to:

  1. find and swtich to a supported WRL template.
  2. If that doesn't exist, clean this up.

};
}