@@ -94,6 +94,28 @@ json::Value toJSON(const ExceptionBreakpointsFilter &EBF) {
94
94
return result;
95
95
}
96
96
97
+ bool fromJSON (const json::Value &Params, ColumnType &CT, json::Path P) {
98
+ auto rawColumnType = Params.getAsString ();
99
+ if (!rawColumnType) {
100
+ P.report (" expected a string" );
101
+ return false ;
102
+ }
103
+ std::optional<ColumnType> columnType =
104
+ StringSwitch<std::optional<ColumnType>>(*rawColumnType)
105
+ .Case (" string" , eColumnTypeString)
106
+ .Case (" number" , eColumnTypeNumber)
107
+ .Case (" boolean" , eColumnTypeBoolean)
108
+ .Case (" unixTimestampUTC " , eColumnTypeTimestamp)
109
+ .Default (std::nullopt);
110
+ if (!columnType) {
111
+ P.report (" unexpected value, expected 'string', 'number', 'boolean', or "
112
+ " 'unixTimestampUTC'" );
113
+ return false ;
114
+ }
115
+ CT = *columnType;
116
+ return true ;
117
+ }
118
+
97
119
json::Value toJSON (const ColumnType &T) {
98
120
switch (T) {
99
121
case eColumnTypeString:
@@ -108,6 +130,14 @@ json::Value toJSON(const ColumnType &T) {
108
130
llvm_unreachable (" unhandled column type." );
109
131
}
110
132
133
+ bool fromJSON (const llvm::json::Value &Params, ColumnDescriptor &CD,
134
+ llvm::json::Path P) {
135
+ llvm::json::ObjectMapper O (Params, P);
136
+ return O && O.map (" attributeName" , CD.attributeName ) &&
137
+ O.map (" label" , CD.label ) && O.mapOptional (" format" , CD.format ) &&
138
+ O.mapOptional (" type" , CD.type ) && O.mapOptional (" width" , CD.width );
139
+ }
140
+
111
141
json::Value toJSON (const ColumnDescriptor &CD) {
112
142
json::Object result{{" attributeName" , CD.attributeName }, {" label" , CD.label }};
113
143
@@ -149,6 +179,30 @@ json::Value toJSON(const BreakpointModeApplicability &BMA) {
149
179
llvm_unreachable (" unhandled breakpoint mode applicability." );
150
180
}
151
181
182
+ bool fromJSON (const llvm::json::Value &Params, BreakpointModeApplicability &BMA,
183
+ llvm::json::Path P) {
184
+ auto rawApplicability = Params.getAsString ();
185
+ if (!rawApplicability) {
186
+ P.report (" expected a string" );
187
+ return false ;
188
+ }
189
+ std::optional<BreakpointModeApplicability> applicability =
190
+ llvm::StringSwitch<std::optional<BreakpointModeApplicability>>(
191
+ *rawApplicability)
192
+ .Case (" source" , eBreakpointModeApplicabilitySource)
193
+ .Case (" exception" , eBreakpointModeApplicabilityException)
194
+ .Case (" data" , eBreakpointModeApplicabilityData)
195
+ .Case (" instruction" , eBreakpointModeApplicabilityInstruction)
196
+ .Default (std::nullopt);
197
+ if (!applicability) {
198
+ P.report (" unexpected value, expected 'source', 'exception', 'data', or "
199
+ " 'instruction'" );
200
+ return false ;
201
+ }
202
+ BMA = *applicability;
203
+ return true ;
204
+ }
205
+
152
206
json::Value toJSON (const BreakpointMode &BM) {
153
207
json::Object result{
154
208
{" mode" , BM.mode },
@@ -162,6 +216,14 @@ json::Value toJSON(const BreakpointMode &BM) {
162
216
return result;
163
217
}
164
218
219
+ bool fromJSON (const llvm::json::Value &Params, BreakpointMode &BM,
220
+ llvm::json::Path P) {
221
+ llvm::json::ObjectMapper O (Params, P);
222
+ return O && O.map (" mode" , BM.mode ) && O.map (" label" , BM.label ) &&
223
+ O.mapOptional (" description" , BM.description ) &&
224
+ O.map (" appliesTo" , BM.appliesTo );
225
+ }
226
+
165
227
static llvm::StringLiteral ToString (AdapterFeature feature) {
166
228
switch (feature) {
167
229
case eAdapterFeatureANSIStyling:
@@ -320,6 +382,26 @@ llvm::json::Value toJSON(const BreakpointReason &BR) {
320
382
llvm_unreachable (" unhandled breakpoint reason." );
321
383
}
322
384
385
+ bool fromJSON (const llvm::json::Value &Params, BreakpointReason &BR,
386
+ llvm::json::Path P) {
387
+ auto rawReason = Params.getAsString ();
388
+ if (!rawReason) {
389
+ P.report (" expected a string" );
390
+ return false ;
391
+ }
392
+ std::optional<BreakpointReason> reason =
393
+ llvm::StringSwitch<std::optional<BreakpointReason>>(*rawReason)
394
+ .Case (" pending" , BreakpointReason::eBreakpointReasonPending)
395
+ .Case (" failed" , BreakpointReason::eBreakpointReasonFailed)
396
+ .Default (std::nullopt);
397
+ if (!reason) {
398
+ P.report (" unexpected value, expected 'pending' or 'failed'" );
399
+ return false ;
400
+ }
401
+ BR = *reason;
402
+ return true ;
403
+ }
404
+
323
405
json::Value toJSON (const Breakpoint &BP) {
324
406
json::Object result{{" verified" , BP.verified }};
325
407
@@ -348,6 +430,20 @@ json::Value toJSON(const Breakpoint &BP) {
348
430
return result;
349
431
}
350
432
433
+ bool fromJSON (const llvm::json::Value &Params, Breakpoint &BP,
434
+ llvm::json::Path P) {
435
+ llvm::json::ObjectMapper O (Params, P);
436
+ return O && O.mapOptional (" id" , BP.id ) && O.map (" verified" , BP.verified ) &&
437
+ O.mapOptional (" message" , BP.message ) &&
438
+ O.mapOptional (" source" , BP.source ) && O.mapOptional (" line" , BP.line ) &&
439
+ O.mapOptional (" column" , BP.column ) &&
440
+ O.mapOptional (" endLine" , BP.endLine ) &&
441
+ O.mapOptional (" endColumn" , BP.endColumn ) &&
442
+ O.mapOptional (" instructionReference" , BP.instructionReference ) &&
443
+ O.mapOptional (" offset" , BP.offset ) &&
444
+ O.mapOptional (" reason" , BP.reason );
445
+ }
446
+
351
447
bool fromJSON (const llvm::json::Value &Params, SourceBreakpoint &SB,
352
448
llvm::json::Path P) {
353
449
json::ObjectMapper O (Params, P);
0 commit comments