Infer the backend from the payload's leading bytes / first-line directive (data-only ABI: nothing executable crosses, so the host picks the backend from the bytes). WASM/Python are recognized but diagnosed as unavailable in this build.
| 279 | // (data-only ABI: nothing executable crosses, so the host picks the backend from |
| 280 | // the bytes). WASM/Python are recognized but diagnosed as unavailable in this build. |
| 281 | Expected<std::string> inferTransformBackend(const std::string& script) { |
| 282 | if (script.size() >= 4 && script.compare(0, 4, "\0asm", 4) == 0) { |
| 283 | return PJ::unexpected("pj.data_processors: WASM backend is reserved for a future host build"); |
| 284 | } |
| 285 | const std::size_t nl = script.find('\n'); |
| 286 | const std::string first = script.substr(0, nl == std::string::npos ? script.size() : nl); |
| 287 | if (first.find("pj-script: luau") != std::string::npos || first.find("pj-script: lua") != std::string::npos) { |
| 288 | return std::string("luau"); |
| 289 | } |
| 290 | if (first.find("pj-script: python") != std::string::npos) { |
| 291 | return std::string("python"); |
| 292 | } |
| 293 | return PJ::unexpected( |
| 294 | "pj.data_processors: unrecognized script backend directive (expected '-- pj-script: <lang>' on line 1)"); |
| 295 | } |
| 296 | } // namespace |
| 297 | |
| 298 | std::string DataProcessorService::makeTransformKey(std::string_view plugin_id, std::string_view id) { |
no test coverage detected