@@ -10,19 +10,19 @@ namespace ClangSharp;
10
10
11
11
public class CXXRecordDecl : RecordDecl
12
12
{
13
- private readonly Lazy < IReadOnlyList < CXXBaseSpecifier > > _bases ;
14
- private readonly Lazy < IReadOnlyList < CXXConstructorDecl > > _ctors ;
13
+ private readonly LazyList < CXXBaseSpecifier > _bases ;
14
+ private readonly LazyList < CXXConstructorDecl > _ctors ;
15
15
private readonly Lazy < FunctionTemplateDecl > _dependentLambdaCallOperator ;
16
16
private readonly Lazy < ClassTemplateDecl > _describedClassTemplate ;
17
17
private readonly Lazy < CXXDestructorDecl ? > _destructor ;
18
- private readonly Lazy < IReadOnlyList < FriendDecl > > _friends ;
18
+ private readonly LazyList < FriendDecl > _friends ;
19
19
private readonly Lazy < CXXRecordDecl > _instantiatedFromMemberClass ;
20
20
private readonly Lazy < CXXMethodDecl > _lambdaCallOperator ;
21
21
private readonly Lazy < Decl > _lambdaContextDecl ;
22
22
private readonly Lazy < CXXMethodDecl > _lambdaStaticInvoker ;
23
- private readonly Lazy < IReadOnlyList < CXXMethodDecl > > _methods ;
23
+ private readonly LazyList < CXXMethodDecl > _methods ;
24
24
private readonly Lazy < CXXRecordDecl > _templateInstantiationPattern ;
25
- private readonly Lazy < IReadOnlyList < CXXBaseSpecifier > > _vbases ;
25
+ private readonly LazyList < CXXBaseSpecifier > _vbases ;
26
26
27
27
internal CXXRecordDecl ( CXCursor handle ) : this ( handle , handle . Kind , CX_DeclKind_CXXRecord )
28
28
{
@@ -35,93 +35,31 @@ private protected CXXRecordDecl(CXCursor handle, CXCursorKind expectedCursorKind
35
35
throw new ArgumentOutOfRangeException ( nameof ( handle ) ) ;
36
36
}
37
37
38
- _bases = new Lazy < IReadOnlyList < CXXBaseSpecifier > > ( ( ) => {
39
- var numBases = Handle . NumBases ;
40
- var bases = new List < CXXBaseSpecifier > ( numBases ) ;
41
-
42
- for ( var i = 0 ; i < numBases ; i ++ )
43
- {
44
- var @base = TranslationUnit . GetOrCreate < CXXBaseSpecifier > ( Handle . GetBase ( unchecked ( ( uint ) i ) ) ) ;
45
- bases . Add ( @base ) ;
46
- }
47
-
48
- return bases ;
49
- } ) ;
50
-
51
- _ctors = new Lazy < IReadOnlyList < CXXConstructorDecl > > ( ( ) => {
52
- var numCtors = Handle . NumCtors ;
53
- var ctors = new List < CXXConstructorDecl > ( numCtors ) ;
54
-
55
- for ( var i = 0 ; i < numCtors ; i ++ )
56
- {
57
- var ctor = TranslationUnit . GetOrCreate < CXXConstructorDecl > ( Handle . GetCtor ( unchecked ( ( uint ) i ) ) ) ;
58
- ctors . Add ( ctor ) ;
59
- }
60
-
61
- return ctors ;
62
- } ) ;
63
-
38
+ _bases = LazyList . Create < CXXBaseSpecifier > ( Handle . NumBases , ( i ) => TranslationUnit . GetOrCreate < CXXBaseSpecifier > ( Handle . GetBase ( unchecked ( ( uint ) i ) ) ) ) ;
39
+ _ctors = LazyList . Create < CXXConstructorDecl > ( Handle . NumCtors , ( i ) => TranslationUnit . GetOrCreate < CXXConstructorDecl > ( Handle . GetCtor ( unchecked ( ( uint ) i ) ) ) ) ;
64
40
_dependentLambdaCallOperator = new Lazy < FunctionTemplateDecl > ( ( ) => TranslationUnit . GetOrCreate < FunctionTemplateDecl > ( Handle . DependentLambdaCallOperator ) ) ;
65
41
_describedClassTemplate = new Lazy < ClassTemplateDecl > ( ( ) => TranslationUnit . GetOrCreate < ClassTemplateDecl > ( Handle . DescribedCursorTemplate ) ) ;
66
42
_destructor = new Lazy < CXXDestructorDecl ? > ( ( ) => {
67
43
var destructor = Handle . Destructor ;
68
44
return destructor . IsNull ? null : TranslationUnit . GetOrCreate < CXXDestructorDecl > ( Handle . Destructor ) ;
69
45
} ) ;
70
-
71
- _friends = new Lazy < IReadOnlyList < FriendDecl > > ( ( ) => {
72
- var numFriends = Handle . NumFriends ;
73
- var friends = new List < FriendDecl > ( numFriends ) ;
74
-
75
- for ( var i = 0 ; i < numFriends ; i ++ )
76
- {
77
- var friend = TranslationUnit . GetOrCreate < FriendDecl > ( Handle . GetFriend ( unchecked ( ( uint ) i ) ) ) ;
78
- friends . Add ( friend ) ;
79
- }
80
-
81
- return friends ;
82
- } ) ;
83
-
46
+ _friends = LazyList . Create < FriendDecl > ( Handle . NumFriends , ( i ) => TranslationUnit . GetOrCreate < FriendDecl > ( Handle . GetFriend ( unchecked ( ( uint ) i ) ) ) ) ;
84
47
_instantiatedFromMemberClass = new Lazy < CXXRecordDecl > ( ( ) => TranslationUnit . GetOrCreate < CXXRecordDecl > ( Handle . InstantiatedFromMember ) ) ;
85
48
_lambdaCallOperator = new Lazy < CXXMethodDecl > ( ( ) => TranslationUnit . GetOrCreate < CXXMethodDecl > ( Handle . LambdaCallOperator ) ) ;
86
49
_lambdaContextDecl = new Lazy < Decl > ( ( ) => TranslationUnit . GetOrCreate < Decl > ( Handle . LambdaContextDecl ) ) ;
87
50
_lambdaStaticInvoker = new Lazy < CXXMethodDecl > ( ( ) => TranslationUnit . GetOrCreate < CXXMethodDecl > ( Handle . LambdaStaticInvoker ) ) ;
88
-
89
- _methods = new Lazy < IReadOnlyList < CXXMethodDecl > > ( ( ) => {
90
- var numMethods = Handle . NumMethods ;
91
- var methods = new List < CXXMethodDecl > ( numMethods ) ;
92
-
93
- for ( var i = 0 ; i < numMethods ; i ++ )
94
- {
95
- var method = TranslationUnit . GetOrCreate < CXXMethodDecl > ( Handle . GetMethod ( unchecked ( ( uint ) i ) ) ) ;
96
- methods . Add ( method ) ;
97
- }
98
-
99
- return methods ;
100
- } ) ;
101
-
51
+ _methods = LazyList . Create < CXXMethodDecl > ( Handle . NumMethods , ( i ) => TranslationUnit . GetOrCreate < CXXMethodDecl > ( Handle . GetMethod ( unchecked ( ( uint ) i ) ) ) ) ;
102
52
_templateInstantiationPattern = new Lazy < CXXRecordDecl > ( ( ) => TranslationUnit . GetOrCreate < CXXRecordDecl > ( Handle . TemplateInstantiationPattern ) ) ;
103
-
104
- _vbases = new Lazy < IReadOnlyList < CXXBaseSpecifier > > ( ( ) => {
105
- var numVBases = Handle . NumVBases ;
106
- var vbases = new List < CXXBaseSpecifier > ( numVBases ) ;
107
-
108
- for ( var i = 0 ; i < numVBases ; i ++ )
109
- {
110
- var vbase = TranslationUnit . GetOrCreate < CXXBaseSpecifier > ( Handle . GetVBase ( unchecked ( ( uint ) i ) ) ) ;
111
- vbases . Add ( vbase ) ;
112
- }
113
-
114
- return vbases ;
115
- } ) ;
53
+ _vbases = LazyList . Create < CXXBaseSpecifier > ( Handle . NumVBases , ( i ) => TranslationUnit . GetOrCreate < CXXBaseSpecifier > ( Handle . GetVBase ( unchecked ( ( uint ) i ) ) ) ) ;
116
54
}
117
55
118
56
public bool IsAbstract => Handle . CXXRecord_IsAbstract ;
119
57
120
- public IReadOnlyList < CXXBaseSpecifier > Bases => _bases . Value ;
58
+ public IReadOnlyList < CXXBaseSpecifier > Bases => _bases ;
121
59
122
60
public new CXXRecordDecl CanonicalDecl => ( CXXRecordDecl ) base . CanonicalDecl ;
123
61
124
- public IReadOnlyList < CXXConstructorDecl > Ctors => _ctors . Value ;
62
+ public IReadOnlyList < CXXConstructorDecl > Ctors => _ctors ;
125
63
126
64
public new CXXRecordDecl ? Definition => ( CXXRecordDecl ? ) base . Definition ;
127
65
@@ -131,7 +69,7 @@ private protected CXXRecordDecl(CXCursor handle, CXCursorKind expectedCursorKind
131
69
132
70
public CXXDestructorDecl ? Destructor => _destructor . Value ;
133
71
134
- public IReadOnlyList < FriendDecl > Friends => _friends . Value ;
72
+ public IReadOnlyList < FriendDecl > Friends => _friends ;
135
73
136
74
public bool HasDefinition => Definition is not null ;
137
75
@@ -159,7 +97,7 @@ private protected CXXRecordDecl(CXCursor handle, CXCursorKind expectedCursorKind
159
97
160
98
public CXXMethodDecl LambdaStaticInvoker => _lambdaStaticInvoker . Value ;
161
99
162
- public IReadOnlyList < CXXMethodDecl > Methods => _methods . Value ;
100
+ public IReadOnlyList < CXXMethodDecl > Methods => _methods ;
163
101
164
102
public new CXXRecordDecl MostRecentDecl => ( CXXRecordDecl ) base . MostRecentDecl ;
165
103
@@ -189,5 +127,5 @@ public CXXRecordDecl MostRecentNonInjectedDecl
189
127
190
128
public CXXRecordDecl TemplateInstantiationPattern => _templateInstantiationPattern . Value ;
191
129
192
- public IReadOnlyList < CXXBaseSpecifier > VBases => _vbases . Value ;
130
+ public IReadOnlyList < CXXBaseSpecifier > VBases => _vbases ;
193
131
}
0 commit comments