-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Produce custom winmd files. Still need to fix being able to mix XAML …
…and custom winmd in the generated output
- Loading branch information
Showing
17 changed files
with
471 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"profiles": { | ||
"Codegen": { | ||
"commandName": "Project", | ||
"commandLineArgs": "-winmd \"C:\\Users\\asklar\\source\\repos\\react-native-xaml\\example\\windows\\RuntimeComponent1\\Debug\\Merged\\RuntimeComponent1.winmd\" -cppout C:\\temp\\1 -tsout C:\\temp\\1" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include "pch.h" | ||
#include "BlankUserControl.h" | ||
#if __has_include("BlankUserControl.g.cpp") | ||
#include "BlankUserControl.g.cpp" | ||
#endif | ||
|
||
using namespace winrt; | ||
using namespace Windows::UI::Xaml; | ||
|
||
namespace winrt::RuntimeComponent1::implementation | ||
{ | ||
BlankUserControl::BlankUserControl() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
int32_t BlankUserControl::MyProperty() | ||
{ | ||
throw hresult_not_implemented(); | ||
} | ||
|
||
void BlankUserControl::MyProperty(int32_t /* value */) | ||
{ | ||
throw hresult_not_implemented(); | ||
} | ||
|
||
void BlankUserControl::ClickHandler(IInspectable const&, RoutedEventArgs const&) | ||
{ | ||
Button().Content(box_value(L"Clicked")); | ||
} | ||
|
||
winrt::Windows::UI::Xaml::DependencyProperty BlankUserControl::MyPropertyProperty() { | ||
if (m_myPropertyProperty == nullptr) { | ||
auto typeMetadata = PropertyMetadata::Create(winrt::box_value(0), [](const DependencyObject& sender, const DependencyPropertyChangedEventArgs& args) { | ||
if (auto control = sender.try_as<winrt::RuntimeComponent1::BlankUserControl>()) { | ||
auto v = winrt::unbox_value<int32_t>(args.NewValue()); | ||
control.MyProperty(v); | ||
} | ||
}); | ||
m_myPropertyProperty = winrt::Windows::UI::Xaml::DependencyProperty::Register(L"MyProperty", winrt::xaml_typename<int32_t>(), winrt::xaml_typename<winrt::RuntimeComponent1::BlankUserControl>(), typeMetadata); | ||
} | ||
return m_myPropertyProperty; | ||
} | ||
winrt::Windows::UI::Xaml::DependencyProperty BlankUserControl::m_myPropertyProperty = nullptr; | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#pragma once | ||
|
||
#include "winrt/Windows.UI.Xaml.h" | ||
#include "winrt/Windows.UI.Xaml.Markup.h" | ||
#include "winrt/Windows.UI.Xaml.Interop.h" | ||
#include "winrt/Windows.UI.Xaml.Controls.Primitives.h" | ||
#include "BlankUserControl.g.h" | ||
|
||
namespace winrt::RuntimeComponent1::implementation | ||
{ | ||
struct BlankUserControl : BlankUserControlT<BlankUserControl> | ||
{ | ||
BlankUserControl(); | ||
|
||
int32_t MyProperty(); | ||
void MyProperty(int32_t value); | ||
|
||
void ClickHandler(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& args); | ||
|
||
static winrt::Windows::UI::Xaml::DependencyProperty MyPropertyProperty(); | ||
private: | ||
static winrt::Windows::UI::Xaml::DependencyProperty m_myPropertyProperty; | ||
|
||
}; | ||
} | ||
|
||
namespace winrt::RuntimeComponent1::factory_implementation | ||
{ | ||
struct BlankUserControl : BlankUserControlT<BlankUserControl, implementation::BlankUserControl> | ||
{ | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace RuntimeComponent1 | ||
{ | ||
[default_interface] | ||
runtimeclass BlankUserControl : Windows.UI.Xaml.Controls.UserControl | ||
{ | ||
BlankUserControl(); | ||
Int32 MyProperty; | ||
|
||
static Windows.UI.Xaml.DependencyProperty MyPropertyProperty{ get; }; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<UserControl | ||
x:Class="RuntimeComponent1.BlankUserControl" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:RuntimeComponent1" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d"> | ||
|
||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center"> | ||
<Button x:Name="Button" Click="ClickHandler">Click Me</Button> | ||
</StackPanel> | ||
</UserControl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include "pch.h" | ||
#include "Class.h" | ||
#include "Class.g.cpp" | ||
|
||
namespace winrt::RuntimeComponent1::implementation | ||
{ | ||
int32_t Class::MyProperty() | ||
{ | ||
throw hresult_not_implemented(); | ||
} | ||
|
||
void Class::MyProperty(int32_t /* value */) | ||
{ | ||
throw hresult_not_implemented(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#pragma once | ||
|
||
#include "Class.g.h" | ||
|
||
namespace winrt::RuntimeComponent1::implementation | ||
{ | ||
struct Class : ClassT<Class> | ||
{ | ||
Class() = default; | ||
|
||
int32_t MyProperty(); | ||
void MyProperty(int32_t value); | ||
}; | ||
} | ||
|
||
namespace winrt::RuntimeComponent1::factory_implementation | ||
{ | ||
struct Class : ClassT<Class, implementation::Class> | ||
{ | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace RuntimeComponent1 | ||
{ | ||
[default_interface] | ||
runtimeclass Class | ||
{ | ||
Class(); | ||
Int32 MyProperty; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ImportGroup Label="PropertySheets" /> | ||
<PropertyGroup Label="UserMacros" /> | ||
<!-- | ||
To customize common C++/WinRT project properties: | ||
* right-click the project node | ||
* expand the Common Properties item | ||
* select the C++/WinRT property page | ||
For more advanced scenarios, and complete documentation, please see: | ||
https://github.com/Microsoft/cppwinrt/tree/master/nuget | ||
--> | ||
<PropertyGroup /> | ||
<ItemDefinitionGroup /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
EXPORTS | ||
DllCanUnloadNow = WINRT_CanUnloadNow PRIVATE | ||
DllGetActivationFactory = WINRT_GetActivationFactory PRIVATE |
Oops, something went wrong.