Changeset View
Changeset View
Standalone View
Standalone View
source/blender/python/intern/bpy_utils_units.c
| Show First 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | static PyObject *py_structseq_from_strings(PyTypeObject *py_type, | ||||
| const char **str_items) | const char **str_items) | ||||
| { | { | ||||
| PyObject *py_struct_seq; | PyObject *py_struct_seq; | ||||
| int pos = 0; | int pos = 0; | ||||
| const char **str_iter; | const char **str_iter; | ||||
| PyStructSequence_Field *desc; | PyStructSequence_Field *desc; | ||||
| /* initialize array */ | /* Initialize array. */ | ||||
| /* We really populate the contexts' fields here! */ | /* We really populate the contexts' fields here! */ | ||||
| for (str_iter = str_items, desc = py_sseq_desc->fields; *str_iter; str_iter++, desc++) { | for (str_iter = str_items, desc = py_sseq_desc->fields; *str_iter; str_iter++, desc++) { | ||||
| desc->name = (char *)*str_iter; | desc->name = (char *)*str_iter; | ||||
| desc->doc = NULL; | desc->doc = NULL; | ||||
| } | } | ||||
| /* end sentinel */ | /* end sentinel */ | ||||
| desc->name = desc->doc = NULL; | desc->name = desc->doc = NULL; | ||||
| PyStructSequence_InitType(py_type, py_sseq_desc); | PyStructSequence_InitType(py_type, py_sseq_desc); | ||||
| /* initialize pytype */ | /* Initialize the Python type. */ | ||||
| py_struct_seq = PyStructSequence_New(py_type); | py_struct_seq = PyStructSequence_New(py_type); | ||||
| BLI_assert(py_struct_seq != NULL); | BLI_assert(py_struct_seq != NULL); | ||||
| for (str_iter = str_items; *str_iter; str_iter++) { | for (str_iter = str_items; *str_iter; str_iter++) { | ||||
| PyStructSequence_SET_ITEM(py_struct_seq, pos++, PyUnicode_FromString(*str_iter)); | PyStructSequence_SET_ITEM(py_struct_seq, pos++, PyUnicode_FromString(*str_iter)); | ||||
| } | } | ||||
| return py_struct_seq; | return py_struct_seq; | ||||
| ▲ Show 20 Lines • Show All 257 Lines • Show Last 20 Lines | |||||