Skip to content

Improvements to the CppWinrt code generator. - #350

Merged
simeoncran merged 4 commits into
masterfrom
CppWinrtImprovements
Sep 16, 2020
Merged

simeoncran merged 4 commits into
masterfrom
CppWinrtImprovements

Conversation

@simeoncran

Copy link
Copy Markdown
Contributor

Up until now, the Cppwinrt code generator was a hack on top of the CX code generator that was enough to get certain projects unblocked but was not anything close to a general solution. With this change I am separating the CX and Cppwinrt code generators, removing all of the hacks that switched between CX and cppwinrt, and making the output work with the cppwinrt tools.

As a result, we now output .IDL files for each Lottie file in addition to the .h and .cpp files. The generated code is designed to work with the code generated by cppwinrt.exe from the IDL.

This change does not enable cppwinrt for all Lotties - there is some work still do do with some geometries, and getting this thing tested is going to take a long time, but it is much closer to the dream than what we had before, and fixing it to deal with issues we uncover will be a lot simpler.

@simeoncran
simeoncran requested a review from a team as a code owner September 15, 2020 22:15

@simeoncran simeoncran Sep 15, 2020 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fix the alphabetization of these. #Closed


public override string TypeVector4 { get; } = "float4";

public override string TypeMatrix3x2 { get; } = "float3x2";

@simeoncran simeoncran Sep 16, 2020 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Alphabetize #Closed


public override string Vector4(Vector4 value) => $"new Vector4({Float(value.X)}, {Float(value.Y)}, {Float(value.Z)}, {Float(value.W)})";

public override string CanvasFigureLoop(CanvasFigureLoop value)

@simeoncran simeoncran Sep 16, 2020 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Alphabetize #Closed


public override string TypeVector4 { get; } = "float4";

public override string TypeMatrix3x2 { get; } = "float3x2";

@simeoncran simeoncran Sep 16, 2020 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Alphabetize
#Closed


namespace Microsoft.Toolkit.Uwp.UI.Lottie.UIData.CodeGen.Cx
{
sealed class CppNamespaceListBuilder

@derobinsMSFT derobinsMSFT Sep 16, 2020 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

CppNamespaceListBuilder [](start = 17, length = 23)

This class is identical in both the Cx and Cppwinrt namespaces. I know this PR is about separating the codegen for CX and C++/WinRT, but can this class be shared? #Closed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It could, but as you say, this PR separates the code generators on purpose. Any shared behavior needs to be tested on both CX and cppwinrt, which doubles the maintenance cost for any shared code.
My dream is that one day the CX code goes away completely anyway.


In reply to: 489611120 [](ancestors = 489611120)

#if PUBLIC_UIDataCodeGen
public
#endif
sealed class CppwinrtInstantiatorGenerator : InstantiatorGeneratorBase

@derobinsMSFT derobinsMSFT Sep 16, 2020 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

CppwinrtInstantiatorGenerator [](start = 17, length = 29)

What about this file was modified besides changing directories? It's not easy to tell what was changed from Codeflow, but the file is not shown as just a "moved" file either. #Closed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Consider it all brand new code. We really didn't support cppwinrt before... it was just some hacks to modify the cx output to do what one particular project needed, but it was never right.


In reply to: 489612853 [](ancestors = 489612853)

builder.WriteLine("#include ");

builder.WriteLine("#include ");
builder.WriteLine("#include ");

@raymond-wh-leung raymond-wh-leung Sep 16, 2020 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

winrt/Windows.UI.Composition.h [](start = 41, length = 30)

Should it check whether it is WinUi3 before including this file? #Closed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point. BTW, I don't know whether Winui3 works for any of this anyway.


In reply to: 489617240 [](ancestors = 489617240)

: $"{NormalizedNamespace}.{UnqualifiedName}";

///
/// A non-language-specific name that can be used for display

@derobinsMSFT derobinsMSFT Sep 16, 2020 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

name [](start = 36, length = 4)

Nit: "namespace"? #Closed

builder.WriteLine("#else");
builder.WriteLine("#include ");
builder.WriteLine("#endif");
builder.WriteLine("#include ");

@raymond-wh-leung raymond-wh-leung Sep 16, 2020 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[](start = 44, length = 36)

Curious what is the diff between "Windows.Graphics.Effects.Interop.h" and "windows.graphics.effects.interop.h" #Closed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The casing of the name. ;-). Seems to be a bug.


In reply to: 489620231 [](ancestors = 489620231)

protected override void WriteCanvasGeometryCombinationFactory(CodeBuilder builder, CanvasGeometry.Combination obj, string typeName, string fieldName)
{
builder.WriteLine($"{typeName} result;");
builder.WriteLine("ID2D1Geometry *geoA = nullptr, *geoB = nullptr;");

@raymond-wh-leung raymond-wh-leung Sep 16, 2020 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ID2D1Geometry * [](start = 31, length = 15)

ComPtr like the other ones in this block? #Closed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is one of the geometry cases that is not handled yet. Anything using raw raw pointers or ComPtr in the cppwinrt generator is just copied from cx and will be fixed later.


In reply to: 489622758 [](ancestors = 489622758)

UINT*,
::ABI::Windows::Graphics::Effects::GRAPHICS_EFFECT_PROPERTY_MAPPING*) override
{
return E_INVALIDARG;

@raymond-wh-leung raymond-wh-leung Sep 16, 2020 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

E_INVALIDARG [](start = 19, length = 12)

E_NOTIMPL #Closed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's implemented. There are no named property mappings, so any name you give us is invalid.


In reply to: 489633599 [](ancestors = 489633599)

@raymond-wh-leung raymond-wh-leung left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

:shipit:


// Write out each namespace using.
foreach (var n in namespaces)
// Add fields and proeprty declarations for each of the theme properties.

@derobinsMSFT derobinsMSFT Sep 16, 2020 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

proeprty [](start = 29, length = 9)

"property" #Closed

}

builder.Class.Public.WriteLine($"winrt::{_animatedVisualTypeName} TryCreateAnimatedVisual(");
builder.Class.Public.Indent();

@derobinsMSFT derobinsMSFT Sep 16, 2020 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

builder.Class.Public.Indent(); [](start = 12, length = 30)

Missing an Unindent() below. #Closed

@derobinsMSFT derobinsMSFT left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

:shipit:

@simeoncran
simeoncran merged commit b8566da into master Sep 16, 2020
@delete-merged-branch
delete-merged-branch Bot deleted the CppWinrtImprovements branch September 16, 2020 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants