зеркало из https://github.com/mono/CppSharp.git
Generate valid C# for nested external specializations
Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
This commit is contained in:
Родитель
aab63d0aa3
Коммит
3b0eb1800c
|
@ -155,22 +155,41 @@ namespace CppSharp.Passes
|
|||
{
|
||||
continue;
|
||||
}
|
||||
var modules = (from arg in specialization.Arguments
|
||||
where arg.Type.Type != null
|
||||
&& ASTUtils.IsTypeExternal(
|
||||
template.TranslationUnit.Module, arg.Type.Type)
|
||||
let module = arg.Type.Type.GetModule()
|
||||
where module != null
|
||||
select module).ToList().TopologicalSort(m => m.Dependencies);
|
||||
if (modules.Count > 0)
|
||||
Module module = GetExternalModule(specialization);
|
||||
if (module != null)
|
||||
{
|
||||
var module = modules.Last();
|
||||
module.ExternalClassTemplateSpecializations.Add(specialization);
|
||||
template.Specializations.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Module GetExternalModule(ClassTemplateSpecialization specialization)
|
||||
{
|
||||
Module currentModule = specialization.TemplatedDecl.TemplatedClass.TranslationUnit.Module;
|
||||
List<Module> modules = new List<Module>();
|
||||
foreach (TemplateArgument arg in specialization.Arguments.Where(arg => arg.Type.Type != null))
|
||||
{
|
||||
if (ASTUtils.IsTypeExternal(currentModule, arg.Type.Type))
|
||||
{
|
||||
Module module = arg.Type.Type.GetModule();
|
||||
if (module != null)
|
||||
{
|
||||
modules.Add(module);
|
||||
}
|
||||
}
|
||||
if (arg.Type.Type.TryGetDeclaration(out ClassTemplateSpecialization nestedSpecialization))
|
||||
{
|
||||
Module module = GetExternalModule(nestedSpecialization);
|
||||
if (module != null)
|
||||
{
|
||||
modules.Add(module);
|
||||
}
|
||||
}
|
||||
}
|
||||
return modules.TopologicalSort(m => m.Dependencies).LastOrDefault();
|
||||
}
|
||||
|
||||
private void CheckForInternalSpecialization(Declaration container, AST.Type type)
|
||||
{
|
||||
ASTUtils.CheckTypeForSpecialization(type, container,
|
||||
|
|
|
@ -66,6 +66,7 @@ public:
|
|||
private:
|
||||
TemplateClass<int> t;
|
||||
TemplateClass<Derived> d;
|
||||
TemplateClass<TemplateWithIndependentFields<Derived>> nestedSpecialization;
|
||||
};
|
||||
|
||||
class DLL_API HasVirtualInDependency : public HasVirtualInCore
|
||||
|
|
Загрузка…
Ссылка в новой задаче