From b460674d64df7a598dc057a546e329eba6517287 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Jun 2014 19:25:07 +1000 Subject: Code cleanup: replace macro with function to reduce binary size --- source/blender/python/generic/bgl.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'source/blender/python') diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c index 292d3317a2e..9b819977345 100644 --- a/source/blender/python/generic/bgl.c +++ b/source/blender/python/generic/bgl.c @@ -1381,10 +1381,16 @@ static struct PyModuleDef BGL_module_def = { NULL, /* m_free */ }; +static void expp_addconst_int(PyObject *dict, const char *name, int value) +{ + PyObject *item; + PyDict_SetItemString(dict, name, item = PyLong_FromLong(value)); + Py_DECREF(item); +} PyObject *BPyInit_bgl(void) { - PyObject *submodule, *dict, *item; + PyObject *submodule, *dict; submodule = PyModule_Create(&BGL_module_def); dict = PyModule_GetDict(submodule); @@ -1394,11 +1400,7 @@ PyObject *BPyInit_bgl(void) PyModule_AddObject(submodule, "Buffer", (PyObject *)&BGL_bufferType); Py_INCREF((PyObject *)&BGL_bufferType); -#define EXPP_ADDCONST(x) PyDict_SetItemString(dict, #x, item = PyLong_FromLong((int)x)); Py_DECREF(item) - -/* So, for example: - * EXPP_ADDCONST(GL_CURRENT_BIT) becomes - * PyDict_SetItemString(dict, "GL_CURRENT_BIT", item = PyLong_FromLong(GL_CURRENT_BIT)); Py_DECREF(item) */ +#define EXPP_ADDCONST(x) expp_addconst_int(dict, #x, x) EXPP_ADDCONST(GL_CURRENT_BIT); EXPP_ADDCONST(GL_POINT_BIT); -- cgit v1.2.3