@@ -94,6 +94,28 @@ json::Value toJSON(const ExceptionBreakpointsFilter &EBF) {
9494 return result;
9595}
9696
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+
97119json::Value toJSON (const ColumnType &T) {
98120 switch (T) {
99121 case eColumnTypeString:
@@ -108,6 +130,14 @@ json::Value toJSON(const ColumnType &T) {
108130 llvm_unreachable (" unhandled column type." );
109131}
110132
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+
111141json::Value toJSON (const ColumnDescriptor &CD) {
112142 json::Object result{{" attributeName" , CD.attributeName }, {" label" , CD.label }};
113143
@@ -149,6 +179,30 @@ json::Value toJSON(const BreakpointModeApplicability &BMA) {
149179 llvm_unreachable (" unhandled breakpoint mode applicability." );
150180}
151181
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+
152206json::Value toJSON (const BreakpointMode &BM) {
153207 json::Object result{
154208 {" mode" , BM.mode },
@@ -162,6 +216,14 @@ json::Value toJSON(const BreakpointMode &BM) {
162216 return result;
163217}
164218
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+
165227static llvm::StringLiteral ToString (AdapterFeature feature) {
166228 switch (feature) {
167229 case eAdapterFeatureANSIStyling:
@@ -320,6 +382,26 @@ llvm::json::Value toJSON(const BreakpointReason &BR) {
320382 llvm_unreachable (" unhandled breakpoint reason." );
321383}
322384
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+
323405json::Value toJSON (const Breakpoint &BP) {
324406 json::Object result{{" verified" , BP.verified }};
325407
@@ -348,6 +430,20 @@ json::Value toJSON(const Breakpoint &BP) {
348430 return result;
349431}
350432
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+
351447bool fromJSON (const llvm::json::Value &Params, SourceBreakpoint &SB,
352448 llvm::json::Path P) {
353449 json::ObjectMapper O (Params, P);
0 commit comments