Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 25e493b
Author: Dustin Howett <[email protected]>
Date:   Sat Dec 1 10:48:53 2018 -0800

    winmd2objc: make it actually build without 10.0.10240

commit 49fe100
Author: Dustin Howett <[email protected]>
Date:   Sat Dec 1 10:47:37 2018 -0800

    winmd2objc: report slightly better errors for project generation

commit 5b20bba
Author: Dustin Howett <[email protected]>
Date:   Sat Dec 1 10:47:14 2018 -0800

    winmd2objc: work around #2862 by manually managing block lifetime

commit 64beb25
Author: Dustin Howett <[email protected]>
Date:   Sat Dec 1 10:46:21 2018 -0800

    winmd2objc: generate projects that need 10.0.17763

    Refs #2901

commit ffc6575
Author: Dustin Howett <[email protected]>
Date:   Sat Dec 1 10:14:57 2018 -0800

    winmd2objc: fix the include path for InteropBase

    Refs #2904

commit 7013692
Author: Dustin Howett <[email protected]>
Date:   Thu Nov 29 00:17:32 2018 -0800

    winmd2objc: allocate a local to handle by-ref values

    Fixes #2900.
  • Loading branch information
DHowett committed Dec 1, 2018
1 parent 2009e9b commit 64e2edc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
20 changes: 15 additions & 5 deletions tools/winmd2objc/lib/CodeGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1254,7 +1254,17 @@ struct GeneratorVisitor : public Visitor {
parameters += (typeInfo.isIInspectableType() ? param.Name + L"OutUnmarshaled.GetAddressOf()" :
L"&" + param.Name + L"OutUnmarshaled");
} else {
parameters += typeInfo.convertFnWrl(param.Name, false);
if (typeInfo.isValueType && param.Type->PointerKind == ElementPointerKind::ByRef) {
// Specifically, Windows::Foundation::IGuidHelperStatics::Equals(GUID*, GUID*)
// takes these "value types" as pointers.

// Allocate a local to pass them by reference.
temps += L" " + typeInfo.wrlFullName() + L" __" + param.Name + L"_temp = " +
typeInfo.convertFnWrl(param.Name, false) + L";\n";
parameters += L"&__" + param.Name + L"_temp";
} else {
parameters += typeInfo.convertFnWrl(param.Name, false);
}
}
}
}
Expand Down Expand Up @@ -2027,7 +2037,7 @@ struct GeneratorVisitor : public Visitor {
fwprintf(outHeader, L"#pragma comment(lib, \"%s\")\n", libFileName.c_str());
fwprintf(outHeader, L"#endif\n");
fwprintf(outHeader, L"#endif\n");
fwprintf(outHeader, L"#include <UWP/interopBase.h>\n\n");
fwprintf(outHeader, L"#include <UWP/InteropBase.h>\n\n");
fwprintf(outImpl, L"// %s\n// Generated from winmd2objc\n\n", implFileName.c_str());
fwprintf(outImpl, L"#include <COMIncludes.h>\n");
// Unfortunately Windows.h has a macro for GetCurrentTime and WinRT has a function in WindowsUIXamlMediaAnimation called that..
Expand Down Expand Up @@ -2469,8 +2479,8 @@ void generateVCXProj(const pair<wstring, pair<wstring, vector<shared_ptr<NameSpa
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
<AppContainerApplication>true</AppContainerApplication>
<ApplicationType>Windows Store</ApplicationType>
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformMinVersion>10.0.16299.0</WindowsTargetPlatformMinVersion>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformMinVersion>10.0.17763.0</WindowsTargetPlatformMinVersion>
<ApplicationTypeRevision>10.0</ApplicationTypeRevision>
<IncludeOutputsInPackage>false</IncludeOutputsInPackage>
<TargetFramework>uap10.0</TargetFramework>
Expand Down Expand Up @@ -2639,7 +2649,7 @@ void generateVCXProj(const pair<wstring, pair<wstring, vector<shared_ptr<NameSpa

FILE* vcxproj = nullptr;
if (_wfopen_s(&vcxproj, (projectDirectoryPath + L"\\" + module.first + L".vcxproj").c_str(), L"w")) {
wprintf(L"Failed to open vcxproj file\n");
wprintf(L"Failed to open vcxproj file: %s\\%s.vcxproj\n", projectDirectoryPath.c_str(), module.first.c_str());
exit(1);
}

Expand Down
13 changes: 8 additions & 5 deletions tools/winmd2objc/lib/TypeInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ ReturnHandler handleReturnType(const shared_ptr<MemberInfo>& memberInfo, const S
// We need to call the success/failure callbacks as part of our footer (after the function is called):
ret.footer =
L"\n\
auto successRc = makeBlockHolder(success);\n\
auto failureRc = makeBlockHolder(failure);\n\
decltype(success) successRc = [success copy];\n\
decltype(failure) failureRc = [failure copy];\n\
auto completionHandler = ::Microsoft::WRL::Callback<\n\
::Microsoft::WRL::Implements<::Microsoft::WRL::RuntimeClassFlags<\n\
::Microsoft::WRL::WinRtClassicComMix>,\n\
Expand Down Expand Up @@ -262,6 +262,7 @@ ReturnHandler handleReturnType(const shared_ptr<MemberInfo>& memberInfo, const S
failureRc([NSError errorWithDomain:@\"Async\" code:(int)status userInfo:nil]);\n\
}\n\
}\n\
[successRc release]; [failureRc release];\n\
return S_OK;\n\
}\n\
});\n\
Expand Down Expand Up @@ -301,7 +302,7 @@ ReturnHandler handleReturnType(const shared_ptr<MemberInfo>& memberInfo, const S
ret.footer =
L"\n\
if (progress) {\n\
auto progressRc = makeBlockHolder(progress);\n\
decltype(progress) progressRc = [progress copy];\n\
auto progressHandler = ::Microsoft::WRL::Callback<\n\
::Microsoft::WRL::Implements<::Microsoft::WRL::RuntimeClassFlags<\n\
::Microsoft::WRL::WinRtClassicComMix>,\n\
Expand All @@ -314,13 +315,14 @@ ReturnHandler handleReturnType(const shared_ptr<MemberInfo>& memberInfo, const S
progressRc(" +
progressInfo.toObjc->call(progressInfo, L"status") +
L");\n \
[progressRc release];\n\
return S_OK;\n\
}\n\
});\n\
unmarshalledReturn->put_Progress(progressHandler.Get());\n\
}\n\
auto successRc = makeBlockHolder(success);\n\
auto failureRc = makeBlockHolder(failure);\n\
decltype(success) successRc = [success copy];\n\
decltype(failure) failureRc = [failure copy];\n\
auto completionHandler = ::Microsoft::WRL::Callback<\n\
::Microsoft::WRL::Implements<::Microsoft::WRL::RuntimeClassFlags<\n\
::Microsoft::WRL::WinRtClassicComMix>,\n\
Expand Down Expand Up @@ -355,6 +357,7 @@ ReturnHandler handleReturnType(const shared_ptr<MemberInfo>& memberInfo, const S
} else {\n\
if (failureRc) { failureRc([NSError errorWithDomain:@\"Async\" code:(int)status userInfo:nil]); }\n\
}\n\
[successRc release]; [failureRc release];\n\
return S_OK;\n\
}\n\
});\n\
Expand Down
1 change: 0 additions & 1 deletion tools/winmd2objc/lib/libwinmd2objc.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
<Keyword>Win32Proj</Keyword>
<RootNamespace>ConsoleApplication1337</RootNamespace>
<ProjectName>libwinmd2objc</ProjectName>
<TargetPlatformVersion>10.0.10240.0</TargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
Expand Down

0 comments on commit 64e2edc

Please sign in to comment.