MCPcopy Create free account
hub / github.com/TypesettingTools/Aegisub / Validate

Method Validate

src/auto4_lua.cpp:756–794  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

754 }
755
756 bool LuaCommand::Validate(const agi::Context *c)
757 {
758 if (!(cmd_type & cmd::COMMAND_VALIDATE)) return true;
759
760 set_context(L, c);
761
762 // Error handler goes under the function to call
763 lua_pushcclosure(L, add_stack_trace, 0);
764
765 GetFeatureFunction("validate");
766 auto subsobj = new LuaAssFile(L, c->ass.get());
767
768 push_value(L, selected_rows(c));
769 if (auto active_line = c->selectionController->GetActiveLine())
770 push_value(L, active_line->Row + c->ass->Info.size() + c->ass->Styles.size() + 1);
771 else
772 lua_pushnil(L);
773
774 int err = lua_pcall(L, 3, 2, -5 /* three args, function, error handler */);
775 subsobj->ProcessingComplete();
776
777 if (err) {
778 wxLogWarning("Runtime error in Lua macro validation function:\n%s", get_wxstring(L, -1));
779 lua_pop(L, 2);
780 return false;
781 }
782
783 bool result = !!lua_toboolean(L, -2);
784
785 wxString new_help_string(get_wxstring(L, -1));
786 if (new_help_string.size()) {
787 help = new_help_string;
788 cmd_type |= cmd::COMMAND_DYNAMIC_HELP;
789 }
790
791 lua_pop(L, 3); // two return values and error handler
792
793 return result;
794 }
795
796 void LuaCommand::operator()(agi::Context *c)
797 {

Callers 4

OnIdleMethod · 0.45
OnContextMenuMethod · 0.45
OnMouseEventMethod · 0.45
UpdateItemMethod · 0.45

Calls 8

set_contextFunction · 0.85
push_valueFunction · 0.85
selected_rowsFunction · 0.85
get_wxstringFunction · 0.85
GetActiveLineMethod · 0.80
ProcessingCompleteMethod · 0.80
getMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected