Browse Source

Fixed the output of forward references in CLI headers.

We now use a sorted set to prevent duplicated references and have a stable ordering.
pull/144/head
triton 12 years ago
parent
commit
a1c4885610
  1. 14
      src/Generator/Generators/CLI/CLIHeadersTemplate.cs

14
src/Generator/Generators/CLI/CLIHeadersTemplate.cs

@ -97,7 +97,13 @@ namespace CppSharp.Generators.CLI @@ -97,7 +97,13 @@ namespace CppSharp.Generators.CLI
// Create a new tree of namespaces out of the type references found.
var rootNamespace = new TranslationUnit();
foreach (var typeRef in typeReferences)
var sortedRefs = typeReferences.ToList();
sortedRefs.Sort((ref1, ref2) =>
string.CompareOrdinal(ref1.FowardReference, ref2.FowardReference));
var forwardRefs = new SortedSet<string>();
foreach (var typeRef in sortedRefs)
{
if (string.IsNullOrWhiteSpace(typeRef.FowardReference))
continue;
@ -106,6 +112,12 @@ namespace CppSharp.Generators.CLI @@ -106,6 +112,12 @@ namespace CppSharp.Generators.CLI
if (!(declaration.Namespace is Namespace))
continue;
if (!forwardRefs.Add(typeRef.FowardReference))
continue;
if (typeRef.Include.InHeader)
continue;
var @namespace = FindCreateNamespace(rootNamespace, declaration);
@namespace.TypeReferences.Add(typeRef);
}

Loading…
Cancel
Save