MCPcopy Create free account
hub / github.com/KikoPlayProject/KikoPlay / call

Method call

Extension/Script/scriptbase.cpp:162–195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

160}
161
162QVariantList ScriptBase::call(const char *fname, const QVariantList &params, int nRet, QString &errInfo, bool retUseString)
163{
164 if(!L)
165 {
166 errInfo = "Wrong Lua State";
167 LOG_ERROR(errInfo, "Lua");
168 return QVariantList();
169 }
170 if(lua_getglobal(L, fname) != LUA_TFUNCTION)
171 {
172 errInfo = QString("%1 is not founded").arg(fname);
173 LOG_ERROR(errInfo, id());
174 return QVariantList();
175 }
176 for(auto &p : params)
177 {
178 pushValue(L, p);
179 }
180 if(lua_pcall(L, params.size(), nRet, 0))
181 {
182 errInfo=QString(lua_tostring(L, -1));
183 lua_pop(L,1);
184 LOG_ERROR(errInfo, id());
185 return QVariantList();
186 }
187 QVariantList rets;
188 for(int i=0; i<nRet; ++i)
189 {
190 rets.append(getValue(L, retUseString));
191 lua_pop(L, 1);
192 }
193 std::reverse(rets.begin(), rets.end());
194 return rets;
195}
196
197QVariant ScriptBase::get(const char *name)
198{

Callers 15

sendInhabitMessageFunction · 0.80
nFunction · 0.80
DPlayer.min.jsFile · 0.80
sFunction · 0.80
cFunction · 0.80
uFunction · 0.80
lFunction · 0.80
fFunction · 0.80
eFunction · 0.80
rFunction · 0.80
bFunction · 0.80
bootstrap.min.jsFile · 0.80

Calls 9

lua_getglobalFunction · 0.85
QStringClass · 0.85
pushValueFunction · 0.85
getValueFunction · 0.85
reverseFunction · 0.85
sizeMethod · 0.45
appendMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected