[Bf-blender-cvs] [fa3dd5d] master: Cleanup: BLO_read: linking API arg order and name.

Bastien Montagne noreply at git.blender.org
Thu Oct 15 16:12:44 CEST 2015


Commit: fa3dd5d9f43253898ed2a387d07f8fd3cd52f0c6
Author: Bastien Montagne
Date:   Thu Oct 15 16:04:04 2015 +0200
Branches: master
https://developer.blender.org/rBfa3dd5d9f43253898ed2a387d07f8fd3cd52f0c6

Cleanup: BLO_read: linking API arg order and name.

linking API funcs would use 'name, idcode', when all other code here uses
(more sensible) 'idcode, name'.

Also, use 'name' arg name when we expect a bare name, without the prepended ID code, and
'idname' arg name when we expect a complete ID name.

And here too, idcode shall be short, not int!

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

M	source/blender/blenloader/BLO_readfile.h
M	source/blender/blenloader/intern/readfile.c
M	source/blender/python/intern/bpy_library.c
M	source/blender/windowmanager/intern/wm_operators.c
M	source/gameengine/Converter/KX_BlenderSceneConverter.cpp

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

diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h
index c203f65..51b016a 100644
--- a/source/blender/blenloader/BLO_readfile.h
+++ b/source/blender/blenloader/BLO_readfile.h
@@ -96,10 +96,10 @@ bool BLO_has_bfile_extension(const char *str);
 bool BLO_library_path_explode(const char *path, char *r_dir, char **r_group, char **r_name);
 
 struct Main *BLO_library_link_begin(struct Main *mainvar, BlendHandle **bh, const char *filepath);
-struct ID *BLO_library_link_named_part(struct Main *mainl, BlendHandle **bh, const char *idname, const int idcode);
+struct ID *BLO_library_link_named_part(struct Main *mainl, BlendHandle **bh, const short idcode, const char *name);
 struct ID *BLO_library_link_named_part_ex(
         struct Main *mainl, BlendHandle **bh,
-        const char *idname, const int idcode, const short flag,
+        const short idcode, const char *name, const short flag,
         struct Scene *scene, struct View3D *v3d);
 void BLO_library_link_end(struct Main *mainl, BlendHandle **bh, short flag, struct Scene *scene, struct View3D *v3d);
 
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 470d45f..2e79696 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -9617,9 +9617,9 @@ static void give_base_to_groups(
 
 /* returns true if the item was found
  * but it may already have already been appended/linked */
-static ID *link_named_part(Main *mainl, FileData *fd, const char *idname, const short idcode)
+static ID *link_named_part(Main *mainl, FileData *fd, const short idcode, const char *name)
 {
-	BHead *bhead = find_bhead_from_code_name(fd, idcode, idname);
+	BHead *bhead = find_bhead_from_code_name(fd, idcode, name);
 	ID *id;
 
 	if (bhead) {
@@ -9679,10 +9679,10 @@ void BLO_library_link_all(Main *mainl, BlendHandle *bh)
 }
 
 static ID *link_named_part_ex(
-        Main *mainl, FileData *fd, const char *idname, const int idcode, const int flag,
+        Main *mainl, FileData *fd, const short idcode, const char *name, const short flag,
 		Scene *scene, View3D *v3d)
 {
-	ID *id = link_named_part(mainl, fd, idname, idcode);
+	ID *id = link_named_part(mainl, fd, idcode, name);
 
 	if (id && (GS(id->name) == ID_OB)) {	/* loose object: give a base */
 		if (scene) {
@@ -9726,14 +9726,14 @@ static ID *link_named_part_ex(
  *
  * \param mainl The main database to link from (not the active one).
  * \param bh The blender file handle.
- * \param idname The name of the datablock (without the 2 char ID prefix).
  * \param idcode The kind of datablock to link.
- * \return the appended ID when found.
+ * \param name The name of the datablock (without the 2 char ID prefix).
+ * \return the linked ID when found.
  */
-ID *BLO_library_link_named_part(Main *mainl, BlendHandle **bh, const char *idname, const int idcode)
+ID *BLO_library_link_named_part(Main *mainl, BlendHandle **bh, const short idcode, const char *name)
 {
 	FileData *fd = (FileData*)(*bh);
-	return link_named_part(mainl, fd, idname, idcode);
+	return link_named_part(mainl, fd, idcode, name);
 }
 
 /**
@@ -9742,19 +9742,20 @@ ID *BLO_library_link_named_part(Main *mainl, BlendHandle **bh, const char *idnam
  *
  * \param mainl The main database to link from (not the active one).
  * \param bh The blender file handle.
- * \param idname The name of the datablock (without the 2 char ID prefix).
  * \param idcode The kind of datablock to link.
+ * \param name The name of the datablock (without the 2 char ID prefix).
  * \param flag Options for linking, used for instantiating.
  * \param scene The scene in which to instantiate objects/groups (if NULL, no instantiation is done).
  * \param v3d The active View3D (only to define active layers for instantiated objects & groups, can be NULL).
- * \return the appended ID when found.
+ * \return the linked ID when found.
  */
 ID *BLO_library_link_named_part_ex(
-        Main *mainl, BlendHandle **bh, const char *idname, const int idcode, const short flag,
+        Main *mainl, BlendHandle **bh,
+        const short idcode, const char *name, const short flag,
         Scene *scene, View3D *v3d)
 {
 	FileData *fd = (FileData*)(*bh);
-	return link_named_part_ex(mainl, fd, idname, idcode, flag, scene, v3d);
+	return link_named_part_ex(mainl, fd, idcode, name, flag, scene, v3d);
 }
 
 static void link_id_part(FileData *fd, Main *mainvar, ID *id, ID **r_id)
diff --git a/source/blender/python/intern/bpy_library.c b/source/blender/python/intern/bpy_library.c
index fb9fecb..0912ac0 100644
--- a/source/blender/python/intern/bpy_library.c
+++ b/source/blender/python/intern/bpy_library.c
@@ -358,7 +358,7 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args))
 						// printf("  %s\n", item_str);
 
 						if (item_str) {
-							ID *id = BLO_library_link_named_part(mainl, &(self->blo_handle), item_str, idcode);
+							ID *id = BLO_library_link_named_part(mainl, &(self->blo_handle), idcode, item_str);
 							if (id) {
 #ifdef USE_RNA_DATABLOCKS
 								/* swap name for pointer to the id */
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 1245430..5c2e1f8 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -2629,7 +2629,7 @@ static short wm_link_append_flag(wmOperator *op)
 typedef struct WMLinkAppendDataItem {
 	char *name;
 	BLI_bitmap *libraries;  /* All libs (from WMLinkAppendData.libraries) to try to load this ID from. */
-	int idcode;
+	short idcode;
 
 	ID *new_id;
 	void *customdata;
@@ -2675,7 +2675,7 @@ static void wm_link_append_data_library_add(WMLinkAppendData *lapp_data, const c
 }
 
 static WMLinkAppendDataItem *wm_link_append_data_item_add(
-        WMLinkAppendData *lapp_data, const char *idname, const int idcode, void *customdata)
+        WMLinkAppendData *lapp_data, const char *idname, const short idcode, void *customdata)
 {
 	WMLinkAppendDataItem *item = BLI_memarena_alloc(lapp_data->memarena, sizeof(*item));
 	size_t len = strlen(idname) + 1;
@@ -2742,7 +2742,7 @@ static void wm_link_do(
 				continue;
 			}
 
-			new_id = BLO_library_link_named_part_ex(mainl, &bh, item->name, item->idcode, flag, scene, v3d);
+			new_id = BLO_library_link_named_part_ex(mainl, &bh, item->idcode, item->name, flag, scene, v3d);
 			if (new_id) {
 				/* If the link is sucessful, clear item's libs 'todo' flags.
 				 * This avoids trying to link same item with other libraries to come. */
diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
index 4adfcb5..02c00b2 100644
--- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
+++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
@@ -861,7 +861,7 @@ static void load_datablocks(Main *main_tmp, BlendHandle *bpy_openlib, const char
 	int i = 0;
 	LinkNode *n = names;
 	while (n) {
-		BLO_library_link_named_part(main_tmp, &bpy_openlib, (char *)n->link, idcode);
+		BLO_library_link_named_part(main_tmp, &bpy_openlib, idcode, (char *)n->link);
 		n = (LinkNode *)n->next;
 		i++;
 	}




More information about the Bf-blender-cvs mailing list