Skip to content
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
16 changes: 16 additions & 0 deletions TestComponent/ComposableClosable.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "pch.h"
#include "ComposableClosable.h"
#include "ComposableClosable.g.cpp"

namespace winrt::TestComponent::implementation
{
void ComposableClosable::Close()
{
m_closed = true;
}

bool ComposableClosable::IsClosed()
{
return m_closed;
}
}
24 changes: 24 additions & 0 deletions TestComponent/ComposableClosable.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#pragma once
#include "ComposableClosable.g.h"

namespace winrt::TestComponent::implementation
{
struct ComposableClosable : ComposableClosableT<ComposableClosable>
{
private:
bool m_closed{};

public:
ComposableClosable() = default;

void Close();
bool IsClosed();
};
}

namespace winrt::TestComponent::factory_implementation
{
struct ComposableClosable : ComposableClosableT<ComposableClosable, implementation::ComposableClosable>
{
};
}
21 changes: 21 additions & 0 deletions TestComponent/ComposableMap.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include "pch.h"
#include "ComposableMap.h"
#include "ComposableMap.g.cpp"

namespace winrt::TestComponent::implementation
{
std::map<hstring, int32_t>& ComposableMap::get_container() noexcept
{
return m_values;
}

std::map<hstring, int32_t> const& ComposableMap::get_container() const noexcept
{
return m_values;
}

Windows::Foundation::Collections::IMapView<hstring, int32_t> ComposableMap::GetView() const
{
return single_threaded_map(std::map<hstring, int32_t>(m_values)).GetView();
}
}
28 changes: 28 additions & 0 deletions TestComponent/ComposableMap.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#pragma once
#include "ComposableMap.g.h"

namespace winrt::TestComponent::implementation
{
struct ComposableMap : ComposableMapT<ComposableMap>, map_base<ComposableMap, hstring, int32_t>
{
private:
std::map<hstring, int32_t> m_values;

public:
ComposableMap() = default;

std::map<hstring, int32_t>& get_container() noexcept;
std::map<hstring, int32_t> const& get_container() const noexcept;

// map_base's own GetView() returns the class itself, as a class that
// also implements IMapView does, which this class does not.
Windows::Foundation::Collections::IMapView<hstring, int32_t> GetView() const;
};
}

namespace winrt::TestComponent::factory_implementation
{
struct ComposableMap : ComposableMapT<ComposableMap, implementation::ComposableMap>
{
};
}
21 changes: 21 additions & 0 deletions TestComponent/ComposableVector.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include "pch.h"
#include "ComposableVector.h"
#include "ComposableVector.g.cpp"

namespace winrt::TestComponent::implementation
{
std::vector<int32_t>& ComposableVector::get_container() noexcept
{
return m_values;
}

std::vector<int32_t> const& ComposableVector::get_container() const noexcept
{
return m_values;
}

Windows::Foundation::Collections::IVectorView<int32_t> ComposableVector::GetView() const
{
return single_threaded_vector(std::vector<int32_t>(m_values)).GetView();
}
}
28 changes: 28 additions & 0 deletions TestComponent/ComposableVector.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#pragma once
#include "ComposableVector.g.h"

namespace winrt::TestComponent::implementation
{
struct ComposableVector : ComposableVectorT<ComposableVector>, vector_base<ComposableVector, int32_t>
{
private:
std::vector<int32_t> m_values;

public:
ComposableVector() = default;

std::vector<int32_t>& get_container() noexcept;
std::vector<int32_t> const& get_container() const noexcept;

// vector_base's own GetView() returns the class itself, as a class
// that also implements IVectorView does, which this class does not.
Windows::Foundation::Collections::IVectorView<int32_t> GetView() const;
};
}

namespace winrt::TestComponent::factory_implementation
{
struct ComposableVector : ComposableVectorT<ComposableVector, implementation::ComposableVector>
{
};
}
22 changes: 22 additions & 0 deletions TestComponent/TestComponent.idl
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,28 @@ namespace TestComponent
Int32 ReadOverridableValue();
}

// Composable classes that implement a collection or IClosable, as XAML's
// ResourceDictionary, DependencyObjectCollection and
// DesktopWindowXamlSource do, for testing that a projection gives a
// derived class the protocols of the class it derives from.
unsealed runtimeclass ComposableVector : Windows.Foundation.Collections.IVector<Int32>
{
ComposableVector();
}

unsealed runtimeclass ComposableMap : Windows.Foundation.Collections.IMap<String, Int32>
{
ComposableMap();
}

unsealed runtimeclass ComposableClosable : Windows.Foundation.IClosable
{
ComposableClosable();

// Whether Close() has been called.
Boolean IsClosed{ get; };
}

// An async action whose every step the caller drives, for testing how a
// projection waits for an operation, cancels it and lets go of it.
//
Expand Down
2 changes: 1 addition & 1 deletion TestComponent/TestComponent.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata minClientVersion="2.5">
<id>PyWinRT.TestWinRT</id>
<version>1.7.0</version>
<version>1.8.0</version>
<title>TestWinRT</title>
<authors>Microsoft</authors>
<license type="expression">MIT</license>
Expand Down
6 changes: 6 additions & 0 deletions TestComponent/TestComponent.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@
<ClInclude Include="ControlledAsync.h" />
<ClInclude Include="Class.h" />
<ClInclude Include="Composable.h" />
<ClInclude Include="ComposableClosable.h" />
<ClInclude Include="ComposableMap.h" />
<ClInclude Include="ComposableVector.h" />
<ClInclude Include="CountedFactory.h" />
<ClInclude Include="Derived.h" />
<ClInclude Include="DerivedOverride.h" />
Expand All @@ -167,6 +170,9 @@
<ClCompile Include="AsyncOperationSource.cpp" />
<ClCompile Include="Class.cpp" />
<ClCompile Include="Composable.cpp" />
<ClCompile Include="ComposableClosable.cpp" />
<ClCompile Include="ComposableMap.cpp" />
<ClCompile Include="ComposableVector.cpp" />
<ClCompile Include="CountedFactory.cpp" />
<ClCompile Include="Derived.cpp" />
<ClCompile Include="DerivedOverride.cpp" />
Expand Down
6 changes: 6 additions & 0 deletions TestComponent/TestComponent.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
<ClCompile Include="AsyncOperationSource.cpp" />
<ClCompile Include="CountedFactory.cpp" />
<ClCompile Include="FactoryCounter.cpp" />
<ClCompile Include="ComposableClosable.cpp" />
<ClCompile Include="ComposableMap.cpp" />
<ClCompile Include="ComposableVector.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h" />
Expand All @@ -40,6 +43,9 @@
<ClInclude Include="ControlledAsync.h" />
<ClInclude Include="CountedFactory.h" />
<ClInclude Include="FactoryCounter.h" />
<ClInclude Include="ComposableClosable.h" />
<ClInclude Include="ComposableMap.h" />
<ClInclude Include="ComposableVector.h" />
</ItemGroup>
<ItemGroup>
<Midl Include="TestComponent.idl" />
Expand Down
Loading