MCPcopy Create free account
hub / github.com/MonaSolutions/MonaServer / ClearCollectionParameters

Method ClearCollectionParameters

MonaServer/sources/Script.cpp:265–293  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

263
264
265void Script::ClearCollectionParameters(lua_State* pState, const char* field,const Parameters& parameters) {
266 // index -1 must be the collection
267 if (!lua_getmetatable(pState, -1))
268 return;
269 string buffer;
270
271 lua_getfield(pState, -1, String::Format(buffer,"|",field,"OnChange").c_str());
272 Parameters::OnChange::Type* pOnChange((Parameters::OnChange::Type*)lua_touserdata(pState, -1));
273 lua_pop(pState, 1);
274 lua_pushnil(pState);
275 lua_setfield(pState, -2, buffer.c_str());
276
277 lua_getfield(pState, -1, String::Format(buffer,"|",field,"OnClear").c_str());
278 Parameters::OnClear::Type* pOnClear((Parameters::OnClear::Type*)lua_touserdata(pState, -1));
279 lua_pop(pState, 1);
280 lua_pushnil(pState);
281 lua_setfield(pState, -2, buffer.c_str());
282
283 lua_pop(pState, 1); // metatable
284
285 if (pOnChange) {
286 parameters.OnChange::unsubscribe(*pOnChange);
287 delete pOnChange;
288 }
289 if (pOnClear) {
290 parameters.OnClear::unsubscribe(*pOnClear);
291 delete pOnClear;
292 }
293}
294
295int Script::Item(lua_State *pState) {
296 SCRIPT_BEGIN(pState)

Callers

nothing calls this directly

Calls 1

FormatClass · 0.85

Tested by

no test coverage detected