mirror of https://github.com/mono/CppSharp.git
c-sharpdotnetmonobindingsbridgecclangcpluspluscppsharpglueinteropparserparsingpinvokeswigsyntax-treevisitorsxamarinxamarin-bindings
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
922 B
36 lines
922 B
using CppSharp.Types; |
|
|
|
namespace CppSharp.Passes |
|
{ |
|
class SortDeclarationsPass : TranslationUnitPass |
|
{ |
|
public SortDeclarationsPass() |
|
{ |
|
|
|
} |
|
|
|
private static void SortDeclarations(Namespace @namespace) |
|
{ |
|
@namespace.Classes.Sort((c, c1) => |
|
(int)(c.DefinitionOrder - c1.DefinitionOrder)); |
|
|
|
foreach (var childNamespace in @namespace.Namespaces) |
|
SortDeclarations(childNamespace); |
|
} |
|
|
|
public override bool VisitTranslationUnit(TranslationUnit unit) |
|
{ |
|
SortDeclarations(unit); |
|
return true; |
|
} |
|
} |
|
|
|
public static class SortDeclarationsExtensions |
|
{ |
|
public static void SortDeclarations(this PassBuilder builder) |
|
{ |
|
var pass = new SortDeclarationsPass(); |
|
builder.AddPass(pass); |
|
} |
|
} |
|
}
|
|
|