MCPcopy Create free account
hub / github.com/VCVRack/Rack / json_array_foreach

Function json_array_foreach

src/app/RackWidget.cpp:273–291  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

271 size_t moduleIndex;
272 json_t* moduleJ;
273 json_array_foreach(modulesJ, moduleIndex, moduleJ) {
274 // module
275 json_t* idJ = json_object_get(moduleJ, "id");
276 if (!idJ)
277 continue;
278 int64_t id = json_integer_value(idJ);
279 // TODO Legacy v0.6?
280 ModuleWidget* mw = getModule(id);
281 if (!mw) {
282 WARN("Cannot find ModuleWidget %lld", (long long) id);
283 continue;
284 }
285
286 // pos
287 math::Vec pos = mw->box.pos.minus(RACK_OFFSET);
288 pos = pos.div(RACK_GRID_SIZE).round();
289 json_t* posJ = json_pack("[i, i]", (int) pos.x, (int) pos.y);
290 json_object_set_new(moduleJ, "pos", posJ);
291 }
292
293 // Calculate plug orders
294 std::map<Widget*, int> plugOrders;

Callers

nothing calls this directly

Calls 15

VecClass · 0.85
moduleWidgetFromJsonFunction · 0.85
minusMethod · 0.80
roundMethod · 0.80
divMethod · 0.80
multMethod · 0.80
plusMethod · 0.80
addChildMethod · 0.80
whatMethod · 0.80
getTopLeftMethod · 0.80
getBottomRightMethod · 0.80
selectMethod · 0.80

Tested by

no test coverage detected