diff options
author | Nathan Letwory <nathan@letworyinteractive.com> | 2011-07-14 12:20:19 +0400 |
---|---|---|
committer | Nathan Letwory <nathan@letworyinteractive.com> | 2011-07-14 12:20:19 +0400 |
commit | f70f16723741405ab3c32b9e1f05af35ecf9eb21 (patch) | |
tree | 3101c75220526fe6116960e4b2eccc50a1b74167 /source | |
parent | 4da4943b5ce9514e9fb3d9458f3e52d6b0d310ca (diff) |
Shuffle code so it compiles with MSVC too. (Array of unknown size otherwise).
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/python/generic/bgl.c | 76 |
1 files changed, 37 insertions, 39 deletions
diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c index 1891e13fdc1..18d01f45015 100644 --- a/source/blender/python/generic/bgl.c +++ b/source/blender/python/generic/bgl.c @@ -69,11 +69,44 @@ static PySequenceMethods Buffer_SeqMethods = { }; static void Buffer_dealloc(PyObject *self); -static PyObject *Buffer_tolist(PyObject *self, void *arg); -static PyObject *Buffer_dimensions(PyObject *self, void *arg); static PyObject *Buffer_repr(PyObject *self); -static PyMethodDef Buffer_methods[]; -static PyGetSetDef Buffer_getseters[]; + +static PyObject *Buffer_to_list(PyObject *self) +{ + int i, len= ((Buffer *)self)->dimensions[0]; + PyObject *list= PyList_New(len); + + for (i=0; i<len; i++) { + PyList_SET_ITEM(list, i, Buffer_item(self, i)); + } + + return list; +} + +static PyObject *Buffer_dimensions(PyObject *self, void *UNUSED(arg)) +{ + Buffer *buffer= (Buffer *) self; + PyObject *list= PyList_New(buffer->ndimensions); + int i; + + for (i= 0; i<buffer->ndimensions; i++) { + PyList_SET_ITEM(list, i, PyLong_FromLong(buffer->dimensions[i])); + } + + return list; +} + +static PyMethodDef Buffer_methods[] = { + {"to_list", (PyCFunction)Buffer_to_list, METH_NOARGS, + "return the buffer as a list"}, + {NULL, NULL, 0, NULL} +}; + +static PyGetSetDef Buffer_getseters[] = { + {(char *)"dimensions", (getter)Buffer_dimensions, NULL, NULL, NULL}, + {NULL, NULL, NULL, NULL, NULL} +}; + PyTypeObject BGL_bufferType = { PyVarObject_HEAD_INIT(NULL, 0) @@ -460,41 +493,6 @@ static void Buffer_dealloc(PyObject *self) PyObject_DEL(self); } -static PyObject *Buffer_to_list(PyObject *self) -{ - int i, len= ((Buffer *)self)->dimensions[0]; - PyObject *list= PyList_New(len); - - for (i=0; i<len; i++) { - PyList_SET_ITEM(list, i, Buffer_item(self, i)); - } - - return list; -} - -static PyObject *Buffer_dimensions(PyObject *self, void *UNUSED(arg)) -{ - Buffer *buffer= (Buffer *) self; - PyObject *list= PyList_New(buffer->ndimensions); - int i; - - for (i= 0; i<buffer->ndimensions; i++) { - PyList_SET_ITEM(list, i, PyLong_FromLong(buffer->dimensions[i])); - } - - return list; -} - -static PyMethodDef Buffer_methods[] = { - {"to_list", (PyCFunction)Buffer_to_list, METH_NOARGS, - "return the buffer as a list"}, - {NULL, NULL, 0, NULL} -}; - -static PyGetSetDef Buffer_getseters[] = { - {(char *)"dimensions", (getter)Buffer_dimensions, NULL, NULL, NULL}, - {NULL, NULL, NULL, NULL, NULL} -}; static PyObject *Buffer_repr(PyObject *self) { |