diff --git a/src/Generator/Extensions/TypeExtensions.cs b/src/Generator/Extensions/TypeExtensions.cs index 12200fe559..df28b169dd 100644 --- a/src/Generator/Extensions/TypeExtensions.cs +++ b/src/Generator/Extensions/TypeExtensions.cs @@ -8,6 +8,9 @@ public static class TypeExtensions { public static int GetWidth(this Type type, ParserTargetInfo targetInfo) { + if (type is TemplateSpecializationType specializationType) + type = specializationType.Desugared.Type; + if (type.IsPrimitiveType(out var primitiveType)) return (int)primitiveType.GetInfo(targetInfo, out _).Width; @@ -26,6 +29,9 @@ public static int GetWidth(this Type type, ParserTargetInfo targetInfo) public static int GetAlignment(this Type type, ParserTargetInfo targetInfo) { + if (type is TemplateSpecializationType specializationType) + type = specializationType.Desugared.Type; + if (type.IsPrimitiveType(out var primitiveType)) return (int)primitiveType.GetInfo(targetInfo, out _).Alignment; diff --git a/src/Generator/Generators/CSharp/CSharpSources.cs b/src/Generator/Generators/CSharp/CSharpSources.cs index 390ce327ab..d13b03246c 100644 --- a/src/Generator/Generators/CSharp/CSharpSources.cs +++ b/src/Generator/Generators/CSharp/CSharpSources.cs @@ -128,7 +128,8 @@ group s by s.TemplatedDecl.TemplatedClass into template var declarationContexts = new Stack(); while (!(declContext is TranslationUnit)) { - declarationContexts.Push(declContext); + if (!(declContext is Namespace @namespace) || !@namespace.IsInline) + declarationContexts.Push(declContext); declContext = declContext.Namespace; } diff --git a/src/Generator/Passes/TrimSpecializationsPass.cs b/src/Generator/Passes/TrimSpecializationsPass.cs index b79fe63d5e..3c0df01920 100644 --- a/src/Generator/Passes/TrimSpecializationsPass.cs +++ b/src/Generator/Passes/TrimSpecializationsPass.cs @@ -138,8 +138,7 @@ private void CleanSpecializations(Class template) template.Specializations.All(s => s.Ignore)) template.ExplicitlyIgnore(); - if (template.Fields.Any(f => f.Type.Desugar() is TemplateParameterType)) - MoveExternalSpecializations(template); + TryMoveExternalSpecializations(template); } /// @@ -147,7 +146,7 @@ private void CleanSpecializations(Class template) /// the library their template is located in, to the module of said external types. /// /// The template to check for external specializations. - private static void MoveExternalSpecializations(Class template) + private static void TryMoveExternalSpecializations(Class template) { for (int i = template.Specializations.Count - 1; i >= 0; i--) { diff --git a/tests/NamespacesDerived/NamespacesDerived.h b/tests/NamespacesDerived/NamespacesDerived.h index b1e8e7bfa4..5d14ebe2bb 100644 --- a/tests/NamespacesDerived/NamespacesDerived.h +++ b/tests/NamespacesDerived/NamespacesDerived.h @@ -2,6 +2,7 @@ #include "../NamespacesBase/NamespacesBase.h" #include "Independent.h" #include +#include // Namespace clashes with NamespacesBase.OverlappingNamespace // Test whether qualified names turn out right. @@ -105,7 +106,13 @@ class CustomAllocator class DLL_API Ignored { private: - std::basic_string, CustomAllocator> f; + std::basic_string, CustomAllocator> customAllocatedString; +}; + +class DLL_API StdFields +{ +private: + std::vector> customAllocatedVector; }; DLL_API bool operator<<(const Base& b, const char* str);