Changeset View
Changeset View
Standalone View
Standalone View
source/blender/python/bmesh/bmesh_py_ops.c
| Show First 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | |||||
| /* __doc__ | /* __doc__ | ||||
| * ------- */ | * ------- */ | ||||
| static char *bmp_slots_as_args(const BMOSlotType slot_types[BMO_OP_MAX_SLOTS], const bool is_out) | static char *bmp_slots_as_args(const BMOSlotType slot_types[BMO_OP_MAX_SLOTS], const bool is_out) | ||||
| { | { | ||||
| DynStr *dyn_str = BLI_dynstr_new(); | DynStr *dyn_str = BLI_dynstr_new(); | ||||
| char *ret; | char *ret; | ||||
| bool quoted; | |||||
| bool set; | |||||
| int i = 0; | int i = 0; | ||||
| while (*slot_types[i].name) { | while (*slot_types[i].name) { | ||||
| quoted = false; | |||||
| set = false; | |||||
| /* cut off '.out' by using a string size arg */ | /* cut off '.out' by using a string size arg */ | ||||
| const int name_len = is_out ? | const int name_len = is_out ? | ||||
| (strchr(slot_types[i].name, '.') - slot_types[i].name) : | (strchr(slot_types[i].name, '.') - slot_types[i].name) : | ||||
| sizeof(slot_types[i].name); | sizeof(slot_types[i].name); | ||||
| const char *value = "<Unknown>"; | const char *value = "<Unknown>"; | ||||
| switch (slot_types[i].type) { | switch (slot_types[i].type) { | ||||
| case BMO_OP_SLOT_BOOL: value = "False"; break; | case BMO_OP_SLOT_BOOL: value = "False"; break; | ||||
| case BMO_OP_SLOT_INT: value = "0"; break; | case BMO_OP_SLOT_INT: | ||||
| if (slot_types[i].subtype.intg == BMO_OP_SLOT_SUBTYPE_INT_ENUM) { | |||||
| value = slot_types[i].enum_flags[0].identifier; | |||||
| quoted = true; | |||||
| } | |||||
| else if (slot_types[i].subtype.intg == BMO_OP_SLOT_SUBTYPE_INT_FLAG) { | |||||
| value = ""; | |||||
| set = true; | |||||
| } | |||||
| else { | |||||
| value = "0"; | |||||
| } | |||||
| break; | |||||
| case BMO_OP_SLOT_FLT: value = "0.0"; break; | case BMO_OP_SLOT_FLT: value = "0.0"; break; | ||||
| case BMO_OP_SLOT_PTR: value = "None"; break; | case BMO_OP_SLOT_PTR: value = "None"; break; | ||||
| case BMO_OP_SLOT_MAT: value = "Matrix()"; break; | case BMO_OP_SLOT_MAT: value = "Matrix()"; break; | ||||
| case BMO_OP_SLOT_VEC: value = "Vector()"; break; | case BMO_OP_SLOT_VEC: value = "Vector()"; break; | ||||
| case BMO_OP_SLOT_ELEMENT_BUF: value = | case BMO_OP_SLOT_ELEMENT_BUF: value = | ||||
| (slot_types[i].subtype.elem & BMO_OP_SLOT_SUBTYPE_ELEM_IS_SINGLE) ? "None" : "[]"; break; | (slot_types[i].subtype.elem & BMO_OP_SLOT_SUBTYPE_ELEM_IS_SINGLE) ? "None" : "[]"; break; | ||||
| case BMO_OP_SLOT_MAPPING: value = "{}"; break; | case BMO_OP_SLOT_MAPPING: value = "{}"; break; | ||||
| } | } | ||||
| BLI_dynstr_appendf(dyn_str, i ? ", %.*s=%s" : "%.*s=%s", name_len, slot_types[i].name, value); | BLI_dynstr_appendf(dyn_str, i ? ", %.*s=%s%s%s%s%s" : "%.*s=%s%s%s%s%s", | ||||
| name_len, slot_types[i].name, | |||||
| set ? "{" : "", quoted ? "'" : "", | |||||
| value, | |||||
| quoted ? "'" : "", set ? "}" : ""); | |||||
| i++; | i++; | ||||
| } | } | ||||
| ret = BLI_dynstr_get_cstring(dyn_str); | ret = BLI_dynstr_get_cstring(dyn_str); | ||||
| BLI_dynstr_free(dyn_str); | BLI_dynstr_free(dyn_str); | ||||
| return ret; | return ret; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 246 Lines • Show Last 20 Lines | |||||