MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / set_default_config

Function set_default_config

CodeFormatLib/src/CodeFormatLib.cpp:443–479  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

441}
442
443int 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
481int set_nonstandard_symbol(lua_State *L) {
482 int top = lua_gettop(L);

Callers

nothing calls this directly

Calls 11

lua_gettopFunction · 0.85
lua_pushnilFunction · 0.85
lua_nextFunction · 0.85
luaToStringFunction · 0.85
lua_pushbooleanFunction · 0.85
lua_settopFunction · 0.85
lua_pushlstringFunction · 0.85
insertMethod · 0.45
SetDefaultCodeStyleMethod · 0.45
whatMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected