Skip to content

Commit

Permalink
Remove generated 'As<I>()' methods for static types
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio0694 committed May 10, 2024
1 parent ba64f52 commit 67350cf
Showing 1 changed file with 0 additions and 39 deletions.
39 changes: 0 additions & 39 deletions src/cswinrt/code_writers.h
Original file line number Diff line number Diff line change
Expand Up @@ -2501,8 +2501,6 @@ Marshal.Release(inner);

void write_attributed_types(writer& w, TypeDef const& type)
{
bool factory_written{};

for (auto&& [interface_name, factory] : get_attributed_types(w, type))
{
if (factory.activatable)
Expand All @@ -2513,43 +2511,6 @@ Marshal.Release(inner);
{
write_composable_constructors(w, factory.type, type, factory.visible ? "public"sv : "protected"sv);
}
else if (factory.statics)
{
if (!factory_written)
{
factory_written = true;

bool has_base_factory{};
auto extends = type.Extends();
while(!has_base_factory)
{
auto base_semantics = get_type_semantics(extends);
if (std::holds_alternative<object_type>(base_semantics))
{
break;
}
for_typedef(w, base_semantics, [&](auto base_type)
{
for (auto&& [_, base_factory] : get_attributed_types(w, base_type))
{
if (base_factory.statics)
{
has_base_factory = true;
break;
}
}
extends = base_type.Extends();
});
}

w.write(R"(
public static %I As<I>() => ActivationFactory.Get("%.%").AsInterface<I>();
)",
has_base_factory ? "new " : "",
type.TypeNamespace(),
type.TypeName());
}
}
}

write_static_members(w, type);
Expand Down

0 comments on commit 67350cf

Please sign in to comment.