| 694 | } |
| 695 | |
| 696 | LuaCommand::LuaCommand(lua_State *L) |
| 697 | : LuaFeature(L) |
| 698 | , display(check_wxstring(L, 1)) |
| 699 | , help(get_wxstring(L, 2)) |
| 700 | , cmd_type(cmd::COMMAND_NORMAL) |
| 701 | { |
| 702 | lua_getfield(L, LUA_REGISTRYINDEX, "filename"); |
| 703 | cmd_name = agi::format("automation/lua/%s/%s", check_string(L, -1), check_string(L, 1)); |
| 704 | |
| 705 | if (!lua_isfunction(L, 3)) |
| 706 | error(L, "The macro processing function must be a function"); |
| 707 | |
| 708 | if (lua_isfunction(L, 4)) |
| 709 | cmd_type |= cmd::COMMAND_VALIDATE; |
| 710 | |
| 711 | if (lua_isfunction(L, 5)) |
| 712 | cmd_type |= cmd::COMMAND_TOGGLE; |
| 713 | |
| 714 | // new table for containing the functions for this feature |
| 715 | lua_createtable(L, 0, 3); |
| 716 | |
| 717 | // store processing function |
| 718 | push_value(L, "run"); |
| 719 | lua_pushvalue(L, 3); |
| 720 | lua_rawset(L, -3); |
| 721 | |
| 722 | // store validation function |
| 723 | push_value(L, "validate"); |
| 724 | lua_pushvalue(L, 4); |
| 725 | lua_rawset(L, -3); |
| 726 | |
| 727 | // store active function |
| 728 | push_value(L, "isactive"); |
| 729 | lua_pushvalue(L, 5); |
| 730 | lua_rawset(L, -3); |
| 731 | |
| 732 | // store the table in the registry |
| 733 | RegisterFeature(); |
| 734 | |
| 735 | LuaScript::GetScriptObject(L)->RegisterCommand(this); |
| 736 | } |
| 737 | |
| 738 | LuaCommand::~LuaCommand() |
| 739 | { |
nothing calls this directly
no test coverage detected