[Bf-blender-cvs] [7dbc39a] tmp-id-users: Correction to last commit and add docstring

Campbell Barton noreply at git.blender.org
Wed Jan 6 19:16:55 CET 2016


Commit: 7dbc39a57c558db457a8cbc53004eb2d160e44f7
Author: Campbell Barton
Date:   Thu Jan 7 05:09:31 2016 +1100
Branches: tmp-id-users
https://developer.blender.org/rB7dbc39a57c558db457a8cbc53004eb2d160e44f7

Correction to last commit and add docstring

===================================================================

M	source/blender/python/intern/bpy_rna_id_collection.c

===================================================================

diff --git a/source/blender/python/intern/bpy_rna_id_collection.c b/source/blender/python/intern/bpy_rna_id_collection.c
index 745f55b..7ca3451 100644
--- a/source/blender/python/intern/bpy_rna_id_collection.c
+++ b/source/blender/python/intern/bpy_rna_id_collection.c
@@ -125,6 +125,14 @@ static bool foreach_libblock_id_user_map_callback(void *user_data, ID **id_p, in
 	return true;
 }
 
+/**
+ * Takes a set of strings and map it to and array of booleans.
+ *
+ * Useful when the values aren't flags.
+ *
+ * \param type_convert_sign: Maps signed to unsuigned range,
+ * needed when we want to use the full range of a signed short/char.
+ */
 static BLI_bitmap *pyrna_set_to_bitmap(
         EnumPropertyItem *items, PyObject *value,
         int type_size, bool type_convert_sign,
@@ -153,11 +161,20 @@ static BLI_bitmap *pyrna_set_to_bitmap(
 		}
 
 		int index = ret;
+
 		if (type_convert_sign) {
 			if (type_size == 2) {
-				union { signed short as_sign; unsigned short as_unsign; } ret_convert;
-				ret_convert.as_sign = (short)ret;
-				index = (int)ret_convert.as_unsign;
+				union { signed short as_signed; unsigned short as_unsigned; } ret_convert;
+				ret_convert.as_signed = (signed short)ret;
+				index = (int)ret_convert.as_unsigned;
+			}
+			else if (type_size == 1) {
+				union { signed char as_signed; unsigned char as_unsigned; } ret_convert;
+				ret_convert.as_signed = (signed char)ret;
+				index = (int)ret_convert.as_unsigned;
+			}
+			else {
+				BLI_assert(0);
 			}
 		}
 		BLI_assert(index < bitmap_size);
@@ -217,14 +234,6 @@ static PyObject *bpy_user_map(PyObject *UNUSED(self), PyObject *args, PyObject *
 
 	if (key_types) {
 		key_types_bitmap = pyrna_set_to_bitmap(
-		        rna_enum_id_type_items, key_types, sizeof(short), true, USHRT_MAX, "types");
-		if (key_types_bitmap == NULL) {
-			goto error;
-		}
-	}
-
-	if (key_types) {
-		key_types_bitmap = pyrna_set_to_bitmap(
 		        rna_enum_id_type_items, key_types, sizeof(short), true, USHRT_MAX, "key types");
 		if (key_types_bitmap == NULL) {
 			goto error;




More information about the Bf-blender-cvs mailing list