MCPcopy Create free account
hub / github.com/DreamSourceLab/DSView / gen_decoders_json

Method gen_decoders_json

DSView/pv/storesession.cpp:1235–1322  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1233}
1234
1235bool StoreSession::gen_decoders_json(QJsonArray &array)
1236{
1237 for(auto s : _session->get_decode_signals()) {
1238 QJsonObject dec_obj;
1239 QJsonArray stack_array;
1240 QJsonObject show_obj;
1241 const auto &stack = s->decoder();
1242 const auto &decoderList = stack->stack();
1243
1244 for(auto dec : decoderList)
1245 {
1246 QJsonArray ch_array;
1247 const srd_decoder *const d = dec->decoder();;
1248 const bool have_probes = (d->channels || d->opt_channels) != 0;
1249
1250 if (have_probes) {
1251 auto binded_probes = dec->binded_probe_list();
1252 for(auto probe : binded_probes) {
1253 QJsonObject ch_obj;
1254 int binded_index = dec->binded_probe_index(probe);
1255 ch_obj[probe->id] = QJsonValue::fromVariant(binded_index);
1256 ch_array.push_back(ch_obj);
1257 }
1258 }
1259
1260 QJsonObject options_obj;
1261 auto dec_binding = new prop::binding::DecoderOptions(stack, dec);
1262
1263 for (GSList *l = d->options; l; l = l->next)
1264 {
1265 const srd_decoder_option *const opt =
1266 (srd_decoder_option*)l->data;
1267
1268 if (g_variant_is_of_type(opt->def, G_VARIANT_TYPE("d"))) {
1269 GVariant *const var = dec_binding->getter(opt->id);
1270 if (var != NULL) {
1271 options_obj[opt->id] = QJsonValue::fromVariant(g_variant_get_double(var));
1272 g_variant_unref(var);
1273 }
1274 } else if (g_variant_is_of_type(opt->def, G_VARIANT_TYPE("x"))) {
1275 GVariant *const var = dec_binding->getter(opt->id);
1276 if (var != NULL) {
1277 options_obj[opt->id] = QJsonValue::fromVariant(get_integer(var));
1278 g_variant_unref(var);
1279 }
1280 } else if (g_variant_is_of_type(opt->def, G_VARIANT_TYPE("s"))) {
1281 GVariant *const var = dec_binding->getter(opt->id);
1282 if (var != NULL) {
1283 const char *sz = g_variant_get_string(var, NULL);
1284 options_obj[opt->id] = QJsonValue::fromVariant(QString(sz));
1285 g_variant_unref(var);
1286 }
1287 }else {
1288 continue;
1289 }
1290 }
1291
1292 if (have_probes) {

Callers 1

gen_config_jsonMethod · 0.80

Calls 11

binded_probe_listMethod · 0.80
binded_probe_indexMethod · 0.80
getterMethod · 0.80
shownMethod · 0.80
get_nameMethod · 0.80
get_view_indexMethod · 0.80
get_rows_gshowMethod · 0.80
title_idMethod · 0.80
decoderMethod · 0.45
dataMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected