Commit: fde14db4893eb118ddefac9c3b9573cc471d8bc4
Author: Bastien Montagne
Date:   Wed Apr 15 12:50:04 2015 +0200
Branches: asset-engine
https://developer.blender.org/rBfde14db4893eb118ddefac9c3b9573cc471d8bc4

Switch definitively to int32[4] for uuid's, mixing mixing it with char[16] is 
confusing at least.

This is only on human-level anyway... And endianess should not be an issue
either, hopefully, that way!

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

M       release/scripts/startup/bl_operators/amber.py
M       source/blender/editors/space_file/filelist.c
M       source/blender/editors/space_file/filelist.h
M       source/blender/makesdna/DNA_space_types.h

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

diff --git a/release/scripts/startup/bl_operators/amber.py 
b/release/scripts/startup/bl_operators/amber.py
index 9ddcfc7..ce1eebe 100644
--- a/release/scripts/startup/bl_operators/amber.py
+++ b/release/scripts/startup/bl_operators/amber.py
@@ -93,6 +93,14 @@ def uuid_revision_gen(used_uuids, variant_uuid, number, 
size, time):
     return _uuid_gen_single(used_uuids, uuid_root, variant_uuid, str(number), 
str(size), str(timestamp))
 
 
+def uuid_unpack(uuid_hexstr):
+    return struct.unpack("!iiii", binascii.unhexlify(uuid_hexstr).ljust(16, 
b'\0'))
+
+
+def uuid_pack(uuid_iv4):
+    return binascii.hexlify(struct.pack("!iiii", uuid_iv4))
+
+
 #############
 # Amber Jobs.
 class AmberJob:
@@ -126,15 +134,15 @@ class AmberJobList(AmberJob):
                 for vuuid, v in e["variants"].items():
                     new_revisions = {}
                     for ruuid, r in v["revisions"].items():
-                        new_revisions[struct.unpack("!iiii", 
binascii.unhexlify(ruuid).ljust(16, b'\0'))] = r
-                    new_variants[struct.unpack("!iiii", 
binascii.unhexlify(vuuid).ljust(16, b'\0'))] = v
+                        new_revisions[uuid_unpack(ruuid)] = r
+                    new_variants[uuid_unpack(vuuid)] = v
                     v["revisions"] = new_revisions
                     ruuid = v["revision_default"]
-                    v["revision_default"] = struct.unpack("!iiii", 
binascii.unhexlify(ruuid).ljust(16, b'\0'))
-                new_entries[struct.unpack("!iiii", 
binascii.unhexlify(euuid).ljust(16, b'\0'))] = e
+                    v["revision_default"] = uuid_unpack(ruuid)
+                new_entries[uuid_unpack(euuid)] = e
                 e["variants"] = new_variants
                 vuuid = e["variant_default"]
-                e["variant_default"] = struct.unpack("!iiii", 
binascii.unhexlify(vuuid).ljust(16, b'\0'))
+                e["variant_default"] = uuid_unpack(vuuid)
             repo["entries"] = new_entries
         print(repo)
         return repo
diff --git a/source/blender/editors/space_file/filelist.c 
b/source/blender/editors/space_file/filelist.c
index a673391..e7a7ef5 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -1122,7 +1122,7 @@ static void filelist_cache_init(FileListEntryCache *cache)
        cache->misc_cursor = 0;
 
        /* XXX This assumes uint is 32 bits and uuid is 128 bits (char[16]), be 
careful! */
-       cache->uuids = BLI_ghash_new_ex(BLI_ghashutil_uinthash_v4, 
BLI_ghashutil_uinthash_v4_cmp,
+       cache->uuids = BLI_ghash_new_ex(BLI_ghashutil_uinthash_v4_p, 
BLI_ghashutil_uinthash_v4_cmp,
                                        __func__, FILELIST_ENTRYCACHESIZE * 2);
 }
 
@@ -1536,7 +1536,7 @@ int filelist_file_findpath(struct FileList *filelist, 
const char *filename)
        return -1;
 }
 
-FileDirEntry *filelist_entry_find_uuid(struct FileList *filelist, const char 
uuid[ASSET_UUID_LENGTH])
+FileDirEntry *filelist_entry_find_uuid(struct FileList *filelist, const int 
uuid[4])
 {
        if (filelist->filelist.nbr_entries_filtered < 0) {
                return NULL;
@@ -2129,7 +2129,7 @@ FileDirEntryArr *filelist_selection_get(FileList 
*filelist, FileCheckType check,
        strcpy(selection->root, filelist->filelist.root);
 
        for (; !BLI_ghashIterator_done(iter); BLI_ghashIterator_step(iter)) {
-               const char *uuid = BLI_ghashIterator_getKey(iter);
+               const int *uuid = BLI_ghashIterator_getKey(iter);
                FileDirEntry *entry_org = filelist_entry_find_uuid(filelist, 
uuid);
 
                BLI_assert(BLI_ghashIterator_getValue(iter));
diff --git a/source/blender/editors/space_file/filelist.h 
b/source/blender/editors/space_file/filelist.h
index 3907f11..6f7a1d0 100644
--- a/source/blender/editors/space_file/filelist.h
+++ b/source/blender/editors/space_file/filelist.h
@@ -91,7 +91,7 @@ int                 filelist_empty(struct FileList *filelist);
 int                 filelist_numfiles(struct FileList *filelist);
 struct FileDirEntry *filelist_file(struct FileList *filelist, int index);
 int                 filelist_file_findpath(struct FileList *filelist, const 
char *file);
-FileDirEntry *      filelist_entry_find_uuid(struct FileList *filelist, const 
char uuid[ASSET_UUID_LENGTH]);
+FileDirEntry *      filelist_entry_find_uuid(struct FileList *filelist, const 
int uuid[4]);
 bool                filelist_file_cache_block(struct FileList *filelist, const 
int index);
 
 bool                filelist_force_reset(struct FileList *filelist);
diff --git a/source/blender/makesdna/DNA_space_types.h 
b/source/blender/makesdna/DNA_space_types.h
index e9c384b..f1fc19b 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -751,9 +751,9 @@ typedef enum eDirEntry_SelectFlag {
 
 /* Used to communicate with asset engines outside of 'import' context. */
 typedef struct AssetUUID {
-       char uuid_asset[16];     /* ASSET_UUID_LENGTH */
-       char uuid_variant[16];   /* ASSET_UUID_LENGTH */
-       char uuid_revision[16];  /* ASSET_UUID_LENGTH */
+       int uuid_asset[4];
+       int uuid_variant[4];
+       int uuid_revision[4];
 } AssetUUID;
 
 typedef struct AssetUUIDList {
@@ -769,7 +769,7 @@ typedef struct FileDirEntryRevision {
         * asset/variant/version (concatenating the three into a single 72 
bytes one).
         * Handled as bytes, **but** NULL-terminated (because of RNA).
         */
-       char uuid[16];  /* ASSET_UUID_LENGTH */
+       int uuid[4];
 
        char *comment;
 
@@ -796,7 +796,7 @@ typedef struct FileDirEntryVariant {
         * asset/variant/version (concatenating the three into a single 72 
bytes one).
         * Handled as bytes, **but** NULL-terminated (because of RNA).
         */
-       char uuid[16];  /* ASSET_UUID_LENGTH */
+       int uuid[4];
 
        char *name;
        char *description;
@@ -814,7 +814,7 @@ typedef struct FileDirEntry {
         * asset/variant/version (concatenating the three into a single 72 
bytes one).
         * Handled as bytes, **but** NULL-terminated (because of RNA).
         */
-       char uuid[16];  /* ASSET_UUID_LENGTH */
+       int uuid[4];
 
        char *name;
        char *description;

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to