Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.x #1328

Open
wants to merge 935 commits into
base: master
Choose a base branch
from
Open

1.x #1328

wants to merge 935 commits into from

Conversation

qq952670771
Copy link

GlobalDataClient 增加 pop 方法

@qq952670771
Copy link
Author

qq952670771 commented Dec 21, 2020

GlobalDataClient 增加 pop 方法

map.h:50
static PyObject* __py_pop(PyObject* self, PyObject* args);

map.cpp:61
SCRIPT_METHOD_DECLARE("pop", pop, METH_VARARGS, 0)

map.cpp:204
PyObject* Map::__py_pop(PyObject* self, PyObject* args)
{
PyObject* pyKey = PySequence_GetItem(args, 0);
if (!pyKey)
{
PyErr_SetObject(PyExc_KeyError, args);
return NULL;
}

Map* lpScriptData = static_cast<Map*>(self);
PyObject* pyVal = PyDict_GetItem(lpScriptData->pyDict_, pyKey);

Py_DECREF(pyKey);

if (!pyVal)
{
	if (PySequence_Size(args) > 1)
	{
		return PySequence_GetItem(args, 1);
	}
	else
	{
		PyErr_SetObject(PyExc_KeyError, args);
		return NULL;
	}
}
else
{
	PyDict_DelItem(lpScriptData->pyDict_, pyKey);
	lpScriptData->onDataChanged(pyKey, NULL, true);
}

return pyVal;

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants