@@ -78,24 +78,24 @@ static json::Value serializeComment(const CommentInfo &Comment) {
78
78
79
79
static void serializeCommonAttributes (const Info &I, json::Object &Obj,
80
80
std::optional<StringRef> RepositoryUrl) {
81
- Obj[" Name" ] = I.Name . str () ;
81
+ Obj[" Name" ] = I.Name ;
82
82
Obj[" USR" ] = toHex (toStringRef (I.USR ));
83
83
84
84
if (!I.Path .empty ())
85
- Obj[" Path" ] = I.Path . str () ;
85
+ Obj[" Path" ] = I.Path ;
86
86
87
87
if (!I.Namespace .empty ()) {
88
88
Obj[" Namespace" ] = json::Array ();
89
89
for (const auto &NS : I.Namespace )
90
- Obj[" Namespace" ].getAsArray ()->push_back (NS.Name . str () );
90
+ Obj[" Namespace" ].getAsArray ()->push_back (NS.Name );
91
91
}
92
92
93
93
if (!I.Description .empty ()) {
94
94
json::Value DescArray = json::Array ();
95
95
auto &DescArrayRef = *DescArray.getAsArray ();
96
96
for (const auto &Comment : I.Description )
97
97
DescArrayRef.push_back (serializeComment (Comment));
98
- Obj[" Description" ] = std::move ( DescArray) ;
98
+ Obj[" Description" ] = DescArray;
99
99
}
100
100
101
101
// Namespaces aren't SymbolInfos, so they dont have a DefLoc
@@ -115,19 +115,21 @@ static void serializeReference(const Reference &Ref, Object &ReferenceObj,
115
115
ReferenceObj[" Link" ] = Path;
116
116
ReferenceObj[" Name" ] = Ref.Name ;
117
117
ReferenceObj[" QualName" ] = Ref.QualName ;
118
- ReferenceObj[" ID " ] = toHex (toStringRef (Ref.USR ));
118
+ ReferenceObj[" USR " ] = toHex (toStringRef (Ref.USR ));
119
119
}
120
120
121
- static void serializeReference (Object &Obj, SmallVector<Reference, 4 > References, std::string Key) {
121
+ static void serializeReference (const SmallVector<Reference, 4 > &References,
122
+ Object &Obj, std::string Key) {
122
123
json::Value ReferencesArray = Array ();
123
124
json::Array &ReferencesArrayRef = *ReferencesArray.getAsArray ();
124
125
for (const auto & Reference : References) {
125
- Object ReferenceObject = Object ();
126
+ json::Value ReferenceVal = Object ();
127
+ auto &ReferenceObj = *ReferenceVal.getAsObject ();
126
128
auto BasePath = Reference.getRelativeFilePath (" " );
127
- serializeReference (Reference, ReferenceObject , BasePath);
128
- ReferencesArrayRef.push_back (std::move (ReferenceObject) );
129
- }
130
- Obj[Key] = std::move ( ReferencesArray) ;
129
+ serializeReference (Reference, ReferenceObj , BasePath);
130
+ ReferencesArrayRef.push_back (ReferenceVal );
131
+ }
132
+ Obj[Key] = ReferencesArray;
131
133
}
132
134
133
135
// Although namespaces and records both have ScopeChildren, they serialize them
@@ -139,41 +141,74 @@ static void serializeCommonChildren(const ScopeChildren &Children,
139
141
json::Value EnumsArray = Array ();
140
142
auto &EnumsArrayRef = *EnumsArray.getAsArray ();
141
143
for (const auto &Enum : Children.Enums ) {
142
- json::Object EnumObj;
144
+ json::Value EnumVal = Object ();
145
+ auto &EnumObj = *EnumVal.getAsObject ();
143
146
serializeInfo (Enum, EnumObj, RepositoryUrl);
144
- EnumsArrayRef.push_back (std::move (EnumObj) );
147
+ EnumsArrayRef.push_back (EnumVal );
145
148
}
146
- Obj[" Enums" ] = std::move ( EnumsArray) ;
149
+ Obj[" Enums" ] = EnumsArray;
147
150
}
148
151
149
152
if (!Children.Typedefs .empty ()) {
150
153
json::Value TypedefsArray = Array ();
151
154
auto &TypedefsArrayRef = *TypedefsArray.getAsArray ();
152
155
for (const auto &Typedef : Children.Typedefs ) {
153
- json::Object TypedefObj;
156
+ json::Value TypedefVal = Object ();
157
+ auto &TypedefObj = *TypedefVal.getAsObject ();
154
158
serializeInfo (Typedef, TypedefObj, RepositoryUrl);
155
- TypedefsArrayRef.push_back (std::move (TypedefObj) );
159
+ TypedefsArrayRef.push_back (TypedefVal );
156
160
}
157
- Obj[" Typedefs" ] = std::move ( TypedefsArray) ;
161
+ Obj[" Typedefs" ] = TypedefsArray;
158
162
}
159
163
160
164
if (!Children.Records .empty ()) {
161
165
json::Value RecordsArray = Array ();
162
166
auto &RecordsArrayRef = *RecordsArray.getAsArray ();
163
167
for (const auto &Record : Children.Records ) {
164
- json::Object RecordObj;
168
+ json::Value RecordVal = Object ();
169
+ auto &RecordObj = *RecordVal.getAsObject ();
165
170
SmallString<64 > BasePath = Record.getRelativeFilePath (" " );
166
171
serializeReference (Record, RecordObj, BasePath);
167
- RecordsArrayRef.push_back (std::move (RecordObj) );
172
+ RecordsArrayRef.push_back (RecordVal );
168
173
}
169
- Obj[" Records" ] = std::move ( RecordsArray) ;
174
+ Obj[" Records" ] = RecordsArray;
170
175
}
171
176
}
172
177
178
+ static void serializeInfo (const TemplateInfo &Template, Object &Obj) {
179
+ json::Value TemplateVal = Object ();
180
+ auto &TemplateObj = *TemplateVal.getAsObject ();
181
+
182
+ if (Template.Specialization ) {
183
+ json::Value TemplateSpecializationVal = Object ();
184
+ auto &TemplateSpecializationObj = *TemplateSpecializationVal.getAsObject ();
185
+ TemplateSpecializationObj[" SpecializationOf" ] =
186
+ toHex (toStringRef (Template.Specialization ->SpecializationOf ));
187
+ if (!Template.Specialization ->Params .empty ()) {
188
+ json::Value ParamsArray = Array ();
189
+ auto &ParamsArrayRef = *ParamsArray.getAsArray ();
190
+ for (const auto &Param : Template.Specialization ->Params )
191
+ ParamsArrayRef.push_back (Param.Contents );
192
+ TemplateSpecializationObj[" Parameters" ] = ParamsArray;
193
+ }
194
+ TemplateObj[" Specialization" ] = TemplateSpecializationVal;
195
+ }
196
+
197
+ if (!Template.Params .empty ()) {
198
+ json::Value ParamsArray = Array ();
199
+ auto &ParamsArrayRef = *ParamsArray.getAsArray ();
200
+ for (const auto &Param : Template.Params )
201
+ ParamsArrayRef.push_back (Param.Contents );
202
+ TemplateObj[" Parameters" ] = ParamsArray;
203
+ }
204
+
205
+ Obj[" Template" ] = TemplateVal;
206
+ }
207
+
173
208
static void serializeInfo (const TypeInfo &I, Object &Obj) {
174
209
Obj[" Name" ] = I.Type .Name ;
175
210
Obj[" QualName" ] = I.Type .QualName ;
176
- Obj[" ID " ] = toHex (toStringRef (I.Type .USR ));
211
+ Obj[" USR " ] = toHex (toStringRef (I.Type .USR ));
177
212
Obj[" IsTemplate" ] = I.IsTemplate ;
178
213
Obj[" IsBuiltIn" ] = I.IsBuiltIn ;
179
214
}
@@ -191,13 +226,17 @@ static void serializeInfo(const FunctionInfo &F, json::Object &Obj,
191
226
json::Value ParamsArray = json::Array ();
192
227
auto &ParamsArrayRef = *ParamsArray.getAsArray ();
193
228
for (const auto &Param : F.Params ) {
194
- json::Object ParamObj;
229
+ json::Value ParamVal = Object ();
230
+ auto &ParamObj = *ParamVal.getAsObject ();
195
231
ParamObj[" Name" ] = Param.Name ;
196
232
ParamObj[" Type" ] = Param.Type .Name ;
197
- ParamsArrayRef.push_back (std::move (ParamObj) );
233
+ ParamsArrayRef.push_back (ParamVal );
198
234
}
199
- Obj[" Params" ] = std::move ( ParamsArray) ;
235
+ Obj[" Params" ] = ParamsArray;
200
236
}
237
+
238
+ if (F.Template )
239
+ serializeInfo (F.Template .value (), Obj);
201
240
}
202
241
203
242
static void serializeInfo (const EnumInfo &I, json::Object &Obj,
@@ -206,26 +245,28 @@ static void serializeInfo(const EnumInfo &I, json::Object &Obj,
206
245
Obj[" Scoped" ] = I.Scoped ;
207
246
208
247
if (I.BaseType ) {
209
- json::Object BaseTypeObj;
248
+ json::Value BaseTypeVal = Object ();
249
+ auto &BaseTypeObj = *BaseTypeVal.getAsObject ();
210
250
BaseTypeObj[" Name" ] = I.BaseType ->Type .Name ;
211
251
BaseTypeObj[" QualName" ] = I.BaseType ->Type .QualName ;
212
- BaseTypeObj[" ID " ] = toHex (toStringRef (I.BaseType ->Type .USR ));
213
- Obj[" BaseType" ] = std::move (BaseTypeObj) ;
252
+ BaseTypeObj[" USR " ] = toHex (toStringRef (I.BaseType ->Type .USR ));
253
+ Obj[" BaseType" ] = BaseTypeVal ;
214
254
}
215
255
216
256
if (!I.Members .empty ()) {
217
257
json::Value MembersArray = Array ();
218
258
auto &MembersArrayRef = *MembersArray.getAsArray ();
219
259
for (const auto &Member : I.Members ) {
220
- json::Object MemberObj;
260
+ json::Value MemberVal = Object ();
261
+ auto &MemberObj = *MemberVal.getAsObject ();
221
262
MemberObj[" Name" ] = Member.Name ;
222
263
if (!Member.ValueExpr .empty ())
223
264
MemberObj[" ValueExpr" ] = Member.ValueExpr ;
224
265
else
225
266
MemberObj[" Value" ] = Member.Value ;
226
- MembersArrayRef.push_back (std::move (MemberObj) );
267
+ MembersArrayRef.push_back (MemberVal );
227
268
}
228
- Obj[" Members" ] = std::move ( MembersArray) ;
269
+ Obj[" Members" ] = MembersArray;
229
270
}
230
271
}
231
272
@@ -234,82 +275,89 @@ static void serializeInfo(const TypedefInfo &I, json::Object &Obj,
234
275
serializeCommonAttributes (I, Obj, RepositoryUrl);
235
276
Obj[" TypeDeclaration" ] = I.TypeDeclaration ;
236
277
Obj[" IsUsing" ] = I.IsUsing ;
237
- Object TypeObj = Object ();
278
+ json::Value TypeVal = Object ();
279
+ auto &TypeObj = *TypeVal.getAsObject ();
238
280
serializeInfo (I.Underlying , TypeObj);
239
- Obj[" Underlying" ] = std::move (TypeObj) ;
281
+ Obj[" Underlying" ] = TypeVal ;
240
282
}
241
283
242
284
static void serializeInfo (const RecordInfo &I, json::Object &Obj,
243
285
std::optional<StringRef> RepositoryUrl) {
244
286
serializeCommonAttributes (I, Obj, RepositoryUrl);
245
- Obj[" FullName" ] = I.Name . str () ;
287
+ Obj[" FullName" ] = I.FullName ;
246
288
Obj[" TagType" ] = getTagType (I.TagType );
247
289
Obj[" IsTypedef" ] = I.IsTypeDef ;
248
290
249
291
if (!I.Children .Functions .empty ()) {
250
- json::Value PublicFunctionArr = Array ();
251
- json::Array &PublicFunctionARef = *PublicFunctionArr .getAsArray ();
252
- json::Value ProtectedFunctionArr = Array ();
253
- json::Array &ProtectedFunctionARef = *ProtectedFunctionArr .getAsArray ();
292
+ json::Value PubFunctionsArray = Array ();
293
+ json::Array &PubFunctionsArrayRef = *PubFunctionsArray .getAsArray ();
294
+ json::Value ProtFunctionsArray = Array ();
295
+ json::Array &ProtFunctionsArrayRef = *ProtFunctionsArray .getAsArray ();
254
296
255
297
for (const auto &Function : I.Children .Functions ) {
256
- json::Object FunctionObj;
298
+ json::Value FunctionVal = Object ();
299
+ auto &FunctionObj = *FunctionVal.getAsObject ();
257
300
serializeInfo (Function, FunctionObj, RepositoryUrl);
258
301
AccessSpecifier Access = Function.Access ;
259
302
if (Access == AccessSpecifier::AS_public)
260
- PublicFunctionARef .push_back (std::move (FunctionObj) );
303
+ PubFunctionsArrayRef .push_back (FunctionVal );
261
304
else if (Access == AccessSpecifier::AS_protected)
262
- ProtectedFunctionARef .push_back (std::move (FunctionObj) );
305
+ ProtFunctionsArrayRef .push_back (FunctionVal );
263
306
}
264
307
265
- if (!PublicFunctionARef .empty ())
266
- Obj[" PublicFunctions" ] = std::move (PublicFunctionArr) ;
267
- if (!ProtectedFunctionARef .empty ())
268
- Obj[" ProtectedFunctions" ] = std::move (ProtectedFunctionArr) ;
308
+ if (!PubFunctionsArrayRef .empty ())
309
+ Obj[" PublicFunctions" ] = PubFunctionsArray ;
310
+ if (!ProtFunctionsArrayRef .empty ())
311
+ Obj[" ProtectedFunctions" ] = ProtFunctionsArray ;
269
312
}
270
313
271
314
if (!I.Members .empty ()) {
272
- json::Value PublicMembers = Array ();
273
- json::Array &PubMemberRef = *PublicMembers .getAsArray ();
274
- json::Value ProtectedMembers = Array ();
275
- json::Array &ProtMemberRef = *ProtectedMembers .getAsArray ();
315
+ json::Value PublicMembersArray = Array ();
316
+ json::Array &PubMembersArrayRef = *PublicMembersArray .getAsArray ();
317
+ json::Value ProtectedMembersArray = Array ();
318
+ json::Array &ProtMembersArrayRef = *ProtectedMembersArray .getAsArray ();
276
319
277
320
for (const MemberTypeInfo &Member : I.Members ) {
278
- json::Object MemberObj = Object ();
321
+ json::Value MemberVal = Object ();
322
+ auto &MemberObj = *MemberVal.getAsObject ();
279
323
MemberObj[" Name" ] = Member.Name ;
280
324
MemberObj[" Type" ] = Member.Type .Name ;
281
325
282
326
if (Member.Access == AccessSpecifier::AS_public)
283
- PubMemberRef .push_back (std::move (MemberObj) );
327
+ PubMembersArrayRef .push_back (MemberVal );
284
328
else if (Member.Access == AccessSpecifier::AS_protected)
285
- ProtMemberRef .push_back (std::move (MemberObj) );
329
+ ProtMembersArrayRef .push_back (MemberVal );
286
330
}
287
331
288
- if (!PubMemberRef .empty ())
289
- Obj[" PublicMembers" ] = std::move (PublicMembers) ;
290
- if (!ProtMemberRef .empty ())
291
- Obj[" ProtectedMembers" ] = std::move (ProtectedMembers) ;
332
+ if (!PubMembersArrayRef .empty ())
333
+ Obj[" PublicMembers" ] = PublicMembersArray ;
334
+ if (!ProtMembersArrayRef .empty ())
335
+ Obj[" ProtectedMembers" ] = ProtectedMembersArray ;
292
336
}
293
337
294
338
if (!I.Bases .empty ()) {
295
339
json::Value BasesArray = Array ();
296
340
json::Array &BasesArrayRef = *BasesArray.getAsArray ();
297
341
for (const auto &BaseInfo : I.Bases ) {
298
- Object BaseInfoObj = Object ();
342
+ json::Value BaseInfoVal = Object ();
343
+ auto &BaseInfoObj = *BaseInfoVal.getAsObject ();
299
344
serializeInfo (BaseInfo, BaseInfoObj, RepositoryUrl);
300
345
BaseInfoObj[" IsVirtual" ] = BaseInfo.IsVirtual ;
301
346
BaseInfoObj[" Access" ] = getAccessSpelling (BaseInfo.Access );
302
347
BaseInfoObj[" IsParent" ] = BaseInfo.IsParent ;
303
- BasesArrayRef.push_back (std::move (BaseInfoObj) );
348
+ BasesArrayRef.push_back (BaseInfoVal );
304
349
}
305
- Obj[" Bases" ] = std::move ( BasesArray) ;
350
+ Obj[" Bases" ] = BasesArray;
306
351
}
307
352
308
353
if (!I.Parents .empty ())
309
- serializeReference (Obj, I.Parents , " Parents" );
354
+ serializeReference (I.Parents , Obj , " Parents" );
310
355
311
356
if (!I.VirtualParents .empty ())
312
- serializeReference (Obj, I.VirtualParents , " VirtualParents" );
357
+ serializeReference (I.VirtualParents , Obj, " VirtualParents" );
358
+
359
+ if (I.Template )
360
+ serializeInfo (I.Template .value (), Obj);
313
361
314
362
serializeCommonChildren (I.Children , Obj, RepositoryUrl);
315
363
}
0 commit comments