mirror of
https://github.com/znc/znc.git
synced 2026-03-28 17:42:41 +01:00
Refactor default return values of callbacks of perl/python modules
See #1424
This commit is contained in:
@@ -248,14 +248,6 @@ while (<$in>) {
|
||||
my ($type, $name, $args, $default) = /(\S+)\s+(\w+)\((.*)\)(?:=(\w+))?/ or next;
|
||||
$type =~ s/(EModRet)/CModule::$1/;
|
||||
$type =~ s/^\s*(.*?)\s*$/$1/;
|
||||
unless (defined $default) {
|
||||
given ($type) {
|
||||
when ('bool') { $default = 'true' }
|
||||
when ('CModule::EModRet') { $default = 'CONTINUE' }
|
||||
when ('CString') { $default = '""' }
|
||||
when (/\*$/) { $default = "($type)nullptr" }
|
||||
}
|
||||
}
|
||||
my @arg = map {
|
||||
my ($t, $v) = /^\s*(.*\W)\s*(\w+)\s*$/;
|
||||
$t =~ s/^\s*(.*?)\s*$/$1/;
|
||||
@@ -263,10 +255,13 @@ while (<$in>) {
|
||||
{type=>$t, var=>$v, base=>$tb, mod=>$tm//'', pyvar=>"pyArg_$v", error=>"can't convert parameter '$v' to PyObject"}
|
||||
} split /,/, $args;
|
||||
|
||||
unless (defined $default) {
|
||||
$default = "CModule::$name(" . (join ', ', map { $_->{var} } @arg) . ")";
|
||||
}
|
||||
|
||||
unshift @arg, {type=>'$func$', var=>"", base=>"", mod=>"", pyvar=>"pyName", error=>"can't convert string '$name' to PyObject"};
|
||||
|
||||
my $cleanup = '';
|
||||
$default = '' if $type eq 'void';
|
||||
|
||||
say $out "$type CPyModule::$name($args) {";
|
||||
for my $a (@arg) {
|
||||
@@ -413,7 +408,7 @@ while (<$in>) {
|
||||
say $out "\t\t} else { result = (CModule::EModRet)x; }";
|
||||
}
|
||||
when ('bool') {
|
||||
say $out "\t\tint x = PyObject_IsTrue(pyRes);";
|
||||
say $out "\t\tint x = PyObject_IsTrue(pyRes);";
|
||||
say $out "\t\tif (-1 == x) {";
|
||||
say $out "\t\t\tCString sPyErr = m_pModPython->GetPyExceptionStr();";
|
||||
say $out "\t\t\tDEBUG".'("modpython: " << (GetUser() ? GetUser()->GetUserName() : CString("<no user>")) << "/" << GetModName() << '."\"/$name was expected to return EModRet but: \" << sPyErr);";
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
bool OnBoot()=true
|
||||
bool WebRequiresLogin()=true
|
||||
bool WebRequiresAdmin()=false
|
||||
bool OnBoot()
|
||||
bool WebRequiresLogin()
|
||||
bool WebRequiresAdmin()
|
||||
CString GetWebMenuTitle()
|
||||
bool OnWebPreRequest(CWebSock& WebSock, const CString& sPageName)=false
|
||||
bool OnWebRequest(CWebSock& WebSock, const CString& sPageName, CTemplate& Tmpl)=false
|
||||
VWebSubPages* _GetSubPages()
|
||||
bool OnWebPreRequest(CWebSock& WebSock, const CString& sPageName)
|
||||
bool OnWebRequest(CWebSock& WebSock, const CString& sPageName, CTemplate& Tmpl)
|
||||
VWebSubPages* _GetSubPages()=nullptr
|
||||
void OnPreRehash()
|
||||
void OnPostRehash()
|
||||
void OnIRCDisconnected()
|
||||
@@ -59,10 +59,10 @@ EModRet OnChanMsg(CNick& Nick, CChan& Channel, CString& sMessage)
|
||||
EModRet OnPrivNotice(CNick& Nick, CString& sMessage)
|
||||
EModRet OnChanNotice(CNick& Nick, CChan& Channel, CString& sMessage)
|
||||
EModRet OnTopic(CNick& Nick, CChan& Channel, CString& sTopic)
|
||||
bool OnServerCapAvailable(const CString& sCap)=false
|
||||
bool OnServerCapAvailable(const CString& sCap)
|
||||
void OnServerCapResult(const CString& sCap, bool bSuccess)
|
||||
EModRet OnTimerAutoJoin(CChan& Channel)
|
||||
bool OnEmbeddedWebRequest(CWebSock& WebSock, const CString& sPageName, CTemplate& Tmpl)=false
|
||||
bool OnEmbeddedWebRequest(CWebSock& WebSock, const CString& sPageName, CTemplate& Tmpl)
|
||||
EModRet OnAddNetwork(CIRCNetwork& Network, CString& sErrorRet)
|
||||
EModRet OnDeleteNetwork(CIRCNetwork& Network)
|
||||
EModRet OnSendToClient(CString& sLine, CClient& Client)
|
||||
@@ -106,7 +106,7 @@ void OnClientConnect(CZNCSock* pSock, const CString& sHost, unsigned short uPort
|
||||
void OnFailedLogin(const CString& sUsername, const CString& sRemoteIP)
|
||||
EModRet OnUnknownUserRaw(CClient* pClient, CString& sLine)
|
||||
EModRet OnUnknownUserRawMessage(CMessage& Message)
|
||||
bool IsClientCapSupported(CClient* pClient, const CString& sCap, bool bState)=false
|
||||
bool IsClientCapSupported(CClient* pClient, const CString& sCap, bool bState)
|
||||
void OnClientCapRequest(CClient* pClient, const CString& sCap, bool bState)
|
||||
EModRet OnModuleLoading(const CString& sModName, const CString& sArgs, CModInfo::EModuleType eType, bool& bSuccess, CString& sRetMsg)
|
||||
EModRet OnModuleUnloading(CModule* pModule, bool& bSuccess, CString& sRetMsg)
|
||||
|
||||
Reference in New Issue
Block a user