MCPcopy Create free account
hub / github.com/PlotJuggler/PlotJuggler / validateScript

Method validateScript

pj_runtime/src/DataProcessorService.cpp:418–443  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

416}
417
418Status DataProcessorService::validateScript(
419 std::string_view script, std::string_view language, std::string_view params_json) {
420 // Luau and Python backends are available; anything else is rejected.
421 const std::string lang = language.empty() ? "luau" : std::string(language);
422 if (lang != "luau" && lang != "python") {
423 return PJ::unexpected("unsupported script language '" + lang + "' (only 'luau' or 'python' are available)");
424 }
425 const std::string src(script);
426 const std::string params(params_json.empty() ? "{}" : std::string(params_json));
427 // Compile through the matching backend. Python uses a transient catalogue (the
428 // embedded interpreter is process-global); Luau reuses the installed catalogue.
429 Expected<std::unique_ptr<proc::DataProcessor>> compiled =
430 (lang == "python") ? scripting::FilterCatalogue(scripting::makePythonEngine())
431 .makeProcessorFromSource(src, "__validate__", params)
432 : filter_catalogue_ ? filter_catalogue_->makeProcessorFromSource(src, "__validate__", params)
433 : scripting::FilterCatalogue(scripting::makeLuauEngine())
434 .makeProcessorFromSource(src, "__validate__", params);
435 if (!compiled.has_value()) {
436 return PJ::unexpected(compiled.error()); // syntax / module-load error
437 }
438 // Compilation-only: do NOT run a synthetic test point. A SISO test sample carries
439 // only (t, value), so a valid MULTI-INPUT function (using v1..vN) would see those
440 // as nil and falsely report "no output". Runtime/empty-output is instead caught by
441 // the live preview, which runs the real node with the real inputs.
442 return PJ::okStatus();
443}
444
445namespace {
446

Callers 1

onValidateMethod · 0.80

Calls 5

makePythonEngineFunction · 0.85
makeLuauEngineFunction · 0.85
FilterCatalogueClass · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected