Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2007-08-20 14:08:59 +0400
committerCampbell Barton <ideasman42@gmail.com>2007-08-20 14:08:59 +0400
commite8c39a5864a400971891932a8580d7e0784c334d (patch)
tree78d1f832fb01dbb787e8bcfe7d9f179133729304 /source/blender/python/api2_2x/gen_utils.c
parent196a3e410458182105b0356d1f9c9230637b216f (diff)
added face sorting to mesh so you can do mesh.faces.sort(...)
uses list sorting internally so is exactly the same as list sorting.
Diffstat (limited to 'source/blender/python/api2_2x/gen_utils.c')
-rw-r--r--source/blender/python/api2_2x/gen_utils.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/source/blender/python/api2_2x/gen_utils.c b/source/blender/python/api2_2x/gen_utils.c
index b1525e103e9..fc592d41786 100644
--- a/source/blender/python/api2_2x/gen_utils.c
+++ b/source/blender/python/api2_2x/gen_utils.c
@@ -918,3 +918,31 @@ int EXPP_dict_set_item_str( PyObject *dict, char *key, PyObject *value)
Py_DECREF( value ); /* delete original */
return ret;
}
+
+/*
+ * Helper function for subtypes that what the base types methods.
+ * The command below needs to have args modified to have 'self' added at the start
+ * ret = PyObject_Call(PyDict_GetItemString(PyList_Type.tp_dict, "sort"), newargs, keywds);
+ *
+ * This is not easy with the python API so adding a function here,
+ * remember to Py_DECREF the tuple after
+ */
+
+PyObject * EXPP_PyTuple_New_Prepend(PyObject *tuple, PyObject *value)
+{
+ PyObject *item;
+ PyObject *new_tuple;
+ int i;
+
+ i = PyTuple_Size(tuple);
+ new_tuple = PyTuple_New(i+1);
+ PyTuple_SetItem(new_tuple, 0, value);
+ Py_INCREF(value);
+ while (i) {
+ i--;
+ item = PyTuple_GetItem(tuple, i);
+ PyTuple_SetItem(new_tuple, i+1, item);
+ Py_INCREF(item);
+ }
+ return new_tuple;
+} \ No newline at end of file