-
Notifications
You must be signed in to change notification settings - Fork 526
/
Copy pathQueryHelpers.cs
48 lines (40 loc) · 1.32 KB
/
QueryHelpers.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System.Linq;
using CppSharp.AST;
namespace CppSharp.Generator.Tests
{
public static class LibraryQueryExtensions
{
public static Namespace Namespace(this TranslationUnit unit, string name)
{
return unit.FindNamespace(name);
}
public static Class Class(this ASTContext context, string name)
{
return context.FindClass(name).First();
}
public static Function Function(this ASTContext context, string name)
{
return context.FindFunction(name).First();
}
public static Enumeration Enum(this ASTContext context, string name)
{
return context.FindEnum(name).First();
}
public static TypedefNameDecl Typedef(this ASTContext context, string name)
{
return context.FindTypedef(name).First();
}
public static Field Field(this Class @class, string name)
{
return @class.Fields.Find(field => field.Name == name);
}
public static Method Method(this Class @class, string name)
{
return @class.Methods.Find(method => method.Name == name);
}
public static Parameter Param(this Function function, int index)
{
return function.Parameters[index];
}
}
}