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
29 changes: 0 additions & 29 deletions cppwinrt/code_writers.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,49 +126,20 @@ namespace cppwinrt
}
#endif

static void write_module_aware_export_macro_push(writer& w)
{
w.write(R"(
#pragma push_macro("WINRT_EXPORT")
#undef WINRT_EXPORT
)");
}

static void write_module_aware_export_macro_pop(writer& w)
{
w.write(R"(
#pragma pop_macro("WINRT_EXPORT")
)");
}

static void write_module_aware_export_includes_start(writer& w)
{
w.write(R"(
#if !defined(WINRT_MODULE)
#define WINRT_EXPORT
)");
}

static void write_module_aware_export_includes_end(writer& w)
{
w.write(R"(
#else
#define WINRT_EXPORT export
#endif
)");
}

[[nodiscard]] static finish_with wrap_module_aware_export_macro_guard(writer& w, bool enable_module)
{
if (enable_module)
{
write_module_aware_export_macro_push(w);
return { w, write_module_aware_export_macro_pop };
}

return { w, write_nothing };
}

[[nodiscard]] static finish_with wrap_module_aware_includes_guard(writer& w, bool enable_module)
{
if (enable_module)
Expand Down
6 changes: 6 additions & 0 deletions cppwinrt/component_writers.h
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,12 @@ catch (...) { return winrt::to_hresult(); }
return;
}

w.write(R"(
#ifndef WINRT_EXPORT
#define WINRT_EXPORT
#endif
)");

auto wrap_type = wrap_type_namespace(w, type_namespace);

for (auto&&[factory_name, factory] : get_factories(w, type))
Expand Down
9 changes: 0 additions & 9 deletions cppwinrt/file_writers.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ namespace cppwinrt
w.write(strings::base_version_odr, CPPWINRT_VERSION_STRING);
{
auto wrap_file_guard = wrap_open_file_guard(w, "BASE");
auto wrap_export_macro_guard = wrap_module_aware_export_macro_guard(w, settings.modules);

{
// In module builds, generated projection headers must be "module-aware":
Expand Down Expand Up @@ -183,7 +182,6 @@ namespace cppwinrt
if (settings.modules)
{
get_namespace_module_imports(c, ns, w, module_imports);
write_module_aware_export_macro_pop(w);
}
else
{
Expand All @@ -196,7 +194,6 @@ namespace cppwinrt

if (settings.modules)
{
write_module_aware_export_macro_push(w);
write_module_aware_export_includes_start(w);
}

Expand Down Expand Up @@ -230,7 +227,6 @@ namespace cppwinrt
if (settings.modules)
{
get_namespace_module_imports(c, ns, w, module_imports);
write_module_aware_export_macro_pop(w);
}
else
{
Expand All @@ -244,7 +240,6 @@ namespace cppwinrt

if (settings.modules)
{
write_module_aware_export_macro_push(w);
write_module_aware_export_includes_start(w);
}

Expand Down Expand Up @@ -282,7 +277,6 @@ namespace cppwinrt
if (settings.modules)
{
get_namespace_module_imports(c, ns, w, module_imports);
write_module_aware_export_macro_pop(w);
}
else
{
Expand All @@ -298,7 +292,6 @@ namespace cppwinrt

if (settings.modules)
{
write_module_aware_export_macro_push(w);
write_module_aware_export_includes_start(w);
}

Expand Down Expand Up @@ -658,7 +651,6 @@ export import winrt.base;
if (settings.modules)
{
get_namespace_module_imports(c, ns, w, module_imports);
write_module_aware_export_macro_pop(w);
}
else
{
Expand All @@ -671,7 +663,6 @@ export import winrt.base;

if (settings.modules)
{
write_module_aware_export_macro_push(w);
write_module_aware_export_includes_start(w);
}

Expand Down
9 changes: 3 additions & 6 deletions strings/base_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,12 @@
#pragma warning(disable : 4268)
#endif

// Transition: compatibility
#ifndef WINRT_MODULE

#ifndef WINRT_EXPORT
#ifdef WINRT_MODULE
#define WINRT_EXPORT export
#else
#define WINRT_EXPORT
#endif

#endif

// <windowsnumerics.impl.h> pulls in large, hard-to-control legacy headers. In header builds we keep the
// existing behavior, but in module builds it's provided by the winrt.numerics module.
#ifndef WINRT_MODULE
Expand Down