Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
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
2 changes: 1 addition & 1 deletion deps/prebuilt/Universal Windows/ARM/RTObjCInterop.dll
Git LFS file not shown
2 changes: 1 addition & 1 deletion deps/prebuilt/Universal Windows/ARM/RTObjCInterop.lib
Git LFS file not shown
2 changes: 1 addition & 1 deletion deps/prebuilt/Universal Windows/ARM/RTObjCInterop.pdb
Git LFS file not shown
2 changes: 1 addition & 1 deletion deps/prebuilt/Universal Windows/x86/RTObjCInterop.dll
Git LFS file not shown
2 changes: 1 addition & 1 deletion deps/prebuilt/Universal Windows/x86/RTObjCInterop.lib
Git LFS file not shown
2 changes: 1 addition & 1 deletion deps/prebuilt/Universal Windows/x86/RTObjCInterop.pdb
Git LFS file not shown
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
//******************************************************************************
//
// Copyright (c) 2015 Microsoft Corporation. All rights reserved.
//
// This code is licensed under the MIT License (MIT).
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
//******************************************************************************

#pragma once

#include "RTHelpers.h"
#import <Foundation/Foundation.h>

namespace ObjCAsync {
inline std::wstring getWString(const char* str) {
int len = strlen(str);
return std::wstring(&str[0], &str[len - 1]);
}

//ABI::FacebookSDK::FBSDKLoginKit::FBSDKLoginManagerLoginResult
//ABI::FacebookSDK::FBSDKLoginKit::IFBSDKLoginManagerLoginResult
template<typename resultType, typename resultInterfaceType>
class AsyncOperationImpl :
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);

resultInterfaceType _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 = result;
FireCompletion();
}
IFACEMETHODIMP GetResults(resultInterfaceType* results) override
{
*results = 0;
HRESULT hr = AsyncBase::CheckValidStateForResultsCall();
if (SUCCEEDED(hr))
{
*results = _result;
}
return hr;
}
HRESULT OnStart() override
{
return S_OK;
}
void OnClose() override {}
void OnCancel() override {}
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//******************************************************************************
//
// Copyright (c) 2015 Microsoft Corporation. All rights reserved.
//
// This code is licensed under the MIT License (MIT).
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
//******************************************************************************

#pragma once

#include "RTHelpers.h"
#import <Foundation/Foundation.h>

namespace CommonConvertors {
WINRT_EXPORT_FN
Microsoft::WRL::ComPtr<IInspectable> convertNSDictionaryToPropertySet(id obj);
WINRT_EXPORT_FN
Microsoft::WRL::ComPtr<IInspectable> convertNSErrorToPropertySet(id obj);
WINRT_EXPORT_FN
id convertPropertySetToNSDictionary(Microsoft::WRL::ComPtr<ABI::Windows::Foundation::Collections::IMapView<HSTRING, IInspectable*>> ip);
WINRT_EXPORT_FN
ComPtr<ABI::Windows::Foundation::IPropertyValueStatics> propertyValueCreator();

// NSDate to IPropertyValue for DateTime.
WINRT_EXPORT_FN
ABI::Windows::Foundation::DateTime convertNSDateToWinRT(NSDate* obj);

// IReference<DateTime> to NSDate
WINRT_EXPORT_FN
NSDate* convertWinRTToNSDate(ABI::Windows::Foundation::DateTime dt);

// NSURL Convertors
WINRT_EXPORT_FN
ComPtr<ABI::Windows::Storage::IStorageFile> convertNSURLToWinRTStorageFile(NSURL* obj);
WINRT_EXPORT_FN
ComPtr<ABI::Windows::Foundation::IUriRuntimeClass> convertNSURLToWinRTUri(NSURL* obj);
WINRT_EXPORT_FN
NSURL* convertWinRTStorageFileToNSURL(const ComPtr<ABI::Windows::Storage::IStorageFile> storageFile);
WINRT_EXPORT_FN
NSURL* convertWinRTUriToNSURL(const ComPtr<ABI::Windows::Foundation::IUriRuntimeClass> uri);
}
33 changes: 2 additions & 31 deletions include/Platform/Universal Windows/UWP/ObjCHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,5 @@

#pragma once

#include "RTHelpers.h"
#import <Foundation/Foundation.h>

namespace CommonConvertors {
WINRT_EXPORT_FN
Microsoft::WRL::ComPtr<IInspectable> convertNSDictionaryToPropertySet(id obj);
WINRT_EXPORT_FN
Microsoft::WRL::ComPtr<IInspectable> convertNSErrorToPropertySet(id obj);
WINRT_EXPORT_FN
id convertPropertySetToNSDictionary(Microsoft::WRL::ComPtr<ABI::Windows::Foundation::Collections::IMapView<HSTRING, IInspectable*>> ip);
WINRT_EXPORT_FN
ComPtr<ABI::Windows::Foundation::IPropertyValueStatics> propertyValueCreator();

// NSDate to IPropertyValue for DateTime.
WINRT_EXPORT_FN
ABI::Windows::Foundation::DateTime convertNSDateToWinRT(NSDate* obj);

// IReference<DateTime> to NSDate
WINRT_EXPORT_FN
NSDate* convertWinRTToNSDate(ABI::Windows::Foundation::DateTime dt);

// NSURL Convertors
WINRT_EXPORT_FN
ComPtr<ABI::Windows::Storage::IStorageFile> convertNSURLToWinRTStorageFile(NSURL* obj);
WINRT_EXPORT_FN
ComPtr<ABI::Windows::Foundation::IUriRuntimeClass> convertNSURLToWinRTUri(NSURL* obj);
WINRT_EXPORT_FN
NSURL* convertWinRTStorageFileToNSURL(const ComPtr<ABI::Windows::Storage::IStorageFile> storageFile);
WINRT_EXPORT_FN
NSURL* convertWinRTUriToNSURL(const ComPtr<ABI::Windows::Foundation::IUriRuntimeClass> uri);
}
#include "ObjCHelperCommonConvertors.h"
#include "ObjCHelperAsyncImplementation.h"