| 339 | } |
| 340 | |
| 341 | TSReturnCode |
| 342 | TSRemapNewInstance(int argc, char *argv[], void **ih, char *errbuf, int errbuf_size) |
| 343 | { |
| 344 | int ret; |
| 345 | char script[TS_LUA_MAX_SCRIPT_FNAME_LENGTH] = ""; |
| 346 | char const *inline_script = ""; |
| 347 | int fn = 0; |
| 348 | int states = ts_lua_max_state_count; |
| 349 | int ljgc = 0; |
| 350 | int jit = 1; |
| 351 | static const struct option longopt[] = { |
| 352 | {"states", required_argument, 0, 's'}, |
| 353 | {"jit", required_argument, 0, 'j'}, |
| 354 | {"inline", required_argument, 0, 'i'}, |
| 355 | {"ljgc", required_argument, 0, 'g'}, |
| 356 | {0, 0, 0, 0 }, |
| 357 | }; |
| 358 | |
| 359 | argc--; |
| 360 | argv++; |
| 361 | |
| 362 | for (;;) { |
| 363 | int opt; |
| 364 | |
| 365 | opt = getopt_long(argc, (char *const *)argv, "", longopt, nullptr); |
| 366 | switch (opt) { |
| 367 | case 's': |
| 368 | states = atoi(optarg); |
| 369 | Dbg(dbg_ctl, "[%s] setting number of lua VMs [%d]", __FUNCTION__, states); |
| 370 | // set state |
| 371 | break; |
| 372 | case 'j': |
| 373 | jit = atoi(optarg); |
| 374 | if (jit == 0) { |
| 375 | Dbg(dbg_ctl, "[%s] disable JIT mode for remap plugin", __FUNCTION__); |
| 376 | for (int index = 0; index < ts_lua_max_state_count; ++index) { |
| 377 | ts_lua_main_ctx *const main_ctx = (ts_lua_main_ctx_array + index); |
| 378 | lua_State *const lstate = main_ctx->lua; |
| 379 | if (luaJIT_setmode(lstate, 0, LUAJIT_MODE_ENGINE | LUAJIT_MODE_OFF) == 0) { |
| 380 | TSError("[ts_lua][%s] Failed to disable JIT mode for remap plugin", __FUNCTION__); |
| 381 | } |
| 382 | } |
| 383 | } |
| 384 | break; |
| 385 | case 'i': |
| 386 | inline_script = optarg; |
| 387 | break; |
| 388 | case 'g': |
| 389 | ljgc = atoi(optarg); |
| 390 | break; |
| 391 | } |
| 392 | |
| 393 | if (opt == -1) { |
| 394 | break; |
| 395 | } |
| 396 | } |
| 397 | |
| 398 | if (states < 1 || ts_lua_max_state_count < states) { |
nothing calls this directly
no test coverage detected