| 441 | } |
| 442 | |
| 443 | int set_default_config(lua_State *L) { |
| 444 | int top = lua_gettop(L); |
| 445 | |
| 446 | if (top != 1) { |
| 447 | return 0; |
| 448 | } |
| 449 | |
| 450 | if (lua_istable(L, 1)) { |
| 451 | try { |
| 452 | LuaCodeFormat::ConfigMap configMap; |
| 453 | |
| 454 | lua_pushnil(L); |
| 455 | while (lua_next(L, -2) != 0) { |
| 456 | auto key = luaToString(L, -2); |
| 457 | auto value = luaToString(L, -1); |
| 458 | |
| 459 | if (key != "nil") { |
| 460 | configMap.insert({key, value}); |
| 461 | } |
| 462 | |
| 463 | lua_pop(L, 1); |
| 464 | } |
| 465 | |
| 466 | LuaCodeFormat::GetInstance().SetDefaultCodeStyle(configMap); |
| 467 | lua_pushboolean(L, true); |
| 468 | return 1; |
| 469 | } catch (std::exception &e) { |
| 470 | std::string err = e.what(); |
| 471 | lua_settop(L, top); |
| 472 | lua_pushboolean(L, false); |
| 473 | lua_pushlstring(L, err.c_str(), err.size()); |
| 474 | return 2; |
| 475 | } |
| 476 | } |
| 477 | |
| 478 | return 0; |
| 479 | } |
| 480 | |
| 481 | int set_nonstandard_symbol(lua_State *L) { |
| 482 | int top = lua_gettop(L); |
nothing calls this directly
no test coverage detected