[Bf-blender-cvs] [6cdc7c9] asset-engine: Add 'ensure_uuids' callback to API, fix some flags in RNA code.
Bastien Montagne
noreply at git.blender.org
Thu Apr 21 10:15:28 CEST 2016
Commit: 6cdc7c95877a9e129c89563cc5fd8c57fbf13cf2
Author: Bastien Montagne
Date: Wed Apr 20 17:08:42 2016 +0200
Branches: asset-engine
https://developer.blender.org/rB6cdc7c95877a9e129c89563cc5fd8c57fbf13cf2
Add 'ensure_uuids' callback to API, fix some flags in RNA code.
===================================================================
M source/blender/blenkernel/BKE_asset.h
M source/blender/makesrna/intern/rna_asset.c
M source/blender/windowmanager/intern/wm_files_link.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_asset.h b/source/blender/blenkernel/BKE_asset.h
index 6a93922..b0ed429 100644
--- a/source/blender/blenkernel/BKE_asset.h
+++ b/source/blender/blenkernel/BKE_asset.h
@@ -90,9 +90,6 @@ typedef void (*ae_kill)(struct AssetEngine *engine, const int job_id);
/* FILEBROWSER - List everything available at given root path - only returns numbers of entries! */
typedef int (*ae_list_dir)(struct AssetEngine *engine, const int job_id, struct FileDirEntryArr *entries_r);
-/* Ensure given assets (uuids) are really available for append/link (some kind of 'anticipated loading'...). */
-typedef int (*ae_ensure_entries)(struct AssetEngine *engine, const int job_id, struct AssetUUIDList *uuids);
-
/* 'update' hook, called to prepare updating of given entries (typically after a file (re)load).
* Engine should check whether given assets are still valid, if they should be updated, etc.
* uuids tagged as needing reload will then be reloaded as new ones
@@ -102,6 +99,11 @@ typedef int (*ae_ensure_entries)(struct AssetEngine *engine, const int job_id, s
* (else 'link' between old IDs and reloaded ones would be broken). */
typedef int (*ae_update_check)(struct AssetEngine *engine, const int job_id, struct AssetUUIDList *uuids);
+/* Ensure given assets (uuids) are really available for append/link (some kind of 'anticipated loading'...).
+ * Note: Engine should expect any kind of UUIDs it produced here
+ * (i.e. real ones as well as 'virtual' filebrowsing ones). */
+typedef int (*ae_ensure_uuids)(struct AssetEngine *engine, const int job_id, struct AssetUUIDList *uuids);
+
/* ***** All callbacks below are blocking. They shall be completed upon return. ***** */
/* FILEBROWSER - Perform sorting and/or filtering on engines' side.
@@ -159,7 +161,8 @@ typedef struct AssetEngineType {
ae_sort_filter sort_filter;
ae_entries_block_get entries_block_get;
ae_entries_uuid_get entries_uuid_get;
- ae_ensure_entries ensure_entries;
+
+ ae_ensure_uuids ensure_uuids;
ae_load_pre load_pre;
ae_load_post load_post;
diff --git a/source/blender/makesrna/intern/rna_asset.c b/source/blender/makesrna/intern/rna_asset.c
index 5b27985..d8a73b3 100644
--- a/source/blender/makesrna/intern/rna_asset.c
+++ b/source/blender/makesrna/intern/rna_asset.c
@@ -419,86 +419,116 @@ static int rna_ae_list_dir(AssetEngine *engine, const int job_id, FileDirEntryAr
return ret_job_id;
}
-static bool rna_ae_load_pre(AssetEngine *engine, AssetUUIDList *uuids, struct FileDirEntryArr *entries_r)
+static int rna_ae_update_check(AssetEngine *engine, const int job_id, AssetUUIDList *uuids)
{
- extern FunctionRNA rna_AssetEngine_load_pre_func;
+ extern FunctionRNA rna_AssetEngine_update_check_func;
PointerRNA ptr;
PropertyRNA *parm;
ParameterList list;
FunctionRNA *func;
void *ret;
- bool ret_success;
+ int ret_job_id;
+
+ BLI_assert(job_id != AE_JOB_ID_INVALID);
RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr);
- func = &rna_AssetEngine_load_pre_func;
+ func = &rna_AssetEngine_update_check_func;
RNA_parameter_list_create(&list, &ptr, func);
+ RNA_parameter_set_lookup(&list, "job_id", &job_id);
RNA_parameter_set_lookup(&list, "uuids", &uuids);
- RNA_parameter_set_lookup(&list, "entries", &entries_r);
engine->type->ext.call(NULL, &ptr, func, &list);
- parm = RNA_function_find_parameter(NULL, func, "success_return");
+ parm = RNA_function_find_parameter(NULL, func, "job_id_return");
RNA_parameter_get(&list, parm, &ret);
- ret_success = ((*(int *)ret) != 0);
+ ret_job_id = *(int *)ret;
RNA_parameter_list_free(&list);
- return ret_success;
+ return ret_job_id;
}
-static void rna_ae_check_dir(AssetEngine *engine, char *r_dir)
+static int rna_ae_ensure_uuids(AssetEngine *engine, const int job_id, AssetUUIDList *uuids)
{
- extern FunctionRNA rna_AssetEngine_check_dir_func;
+ extern FunctionRNA rna_AssetEngine_ensure_uuids_func;
PointerRNA ptr;
+ PropertyRNA *parm;
ParameterList list;
FunctionRNA *func;
- /* XXX Hacking around bpyrna incapacity to handle strings as return values... To be fixed... some day... */
- FileDirEntryArr entries = {0};
- FileDirEntryArr *entries_p = &entries;
- BLI_strncpy(entries.root, r_dir, FILE_MAX);
+ void *ret;
+ int ret_job_id;
+
+ BLI_assert(job_id != AE_JOB_ID_INVALID);
RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr);
- func = &rna_AssetEngine_check_dir_func;
+ func = &rna_AssetEngine_ensure_uuids_func;
RNA_parameter_list_create(&list, &ptr, func);
- RNA_parameter_set_lookup(&list, "entries", &entries_p);
+ RNA_parameter_set_lookup(&list, "job_id", &job_id);
+ RNA_parameter_set_lookup(&list, "uuids", &uuids);
engine->type->ext.call(NULL, &ptr, func, &list);
- BLI_strncpy(r_dir, entries.root, FILE_MAX);
+ parm = RNA_function_find_parameter(NULL, func, "job_id_return");
+ RNA_parameter_get(&list, parm, &ret);
+ ret_job_id = *(int *)ret;
RNA_parameter_list_free(&list);
+
+ return ret_job_id;
}
-static int rna_ae_update_check(AssetEngine *engine, const int job_id, AssetUUIDList *uuids)
+static bool rna_ae_load_pre(AssetEngine *engine, AssetUUIDList *uuids, struct FileDirEntryArr *entries_r)
{
- extern FunctionRNA rna_AssetEngine_update_check_func;
+ extern FunctionRNA rna_AssetEngine_load_pre_func;
PointerRNA ptr;
PropertyRNA *parm;
ParameterList list;
FunctionRNA *func;
void *ret;
- int ret_job_id;
-
- BLI_assert(job_id != AE_JOB_ID_INVALID);
+ bool ret_success;
RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr);
- func = &rna_AssetEngine_update_check_func;
+ func = &rna_AssetEngine_load_pre_func;
RNA_parameter_list_create(&list, &ptr, func);
- RNA_parameter_set_lookup(&list, "job_id", &job_id);
RNA_parameter_set_lookup(&list, "uuids", &uuids);
+ RNA_parameter_set_lookup(&list, "entries", &entries_r);
engine->type->ext.call(NULL, &ptr, func, &list);
- parm = RNA_function_find_parameter(NULL, func, "job_id_return");
+ parm = RNA_function_find_parameter(NULL, func, "success_return");
RNA_parameter_get(&list, parm, &ret);
- ret_job_id = *(int *)ret;
+ ret_success = ((*(int *)ret) != 0);
RNA_parameter_list_free(&list);
- return ret_job_id;
+ return ret_success;
+}
+
+static void rna_ae_check_dir(AssetEngine *engine, char *r_dir)
+{
+ extern FunctionRNA rna_AssetEngine_check_dir_func;
+ PointerRNA ptr;
+ ParameterList list;
+ FunctionRNA *func;
+
+ /* XXX Hacking around bpyrna incapacity to handle strings as return values... To be fixed... some day... */
+ FileDirEntryArr entries = {0};
+ FileDirEntryArr *entries_p = &entries;
+ BLI_strncpy(entries.root, r_dir, FILE_MAX);
+
+ RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr);
+ func = &rna_AssetEngine_check_dir_func;
+
+ RNA_parameter_list_create(&list, &ptr, func);
+ RNA_parameter_set_lookup(&list, "entries", &entries_p);
+ engine->type->ext.call(NULL, &ptr, func, &list);
+
+ BLI_strncpy(r_dir, entries.root, FILE_MAX);
+
+ RNA_parameter_list_free(&list);
}
static bool rna_ae_sort_filter(
@@ -617,7 +647,7 @@ static StructRNA *rna_AssetEngine_register(Main *bmain, ReportList *reports, voi
AssetEngineType *aet, dummyaet = {NULL};
AssetEngine dummyengine = {NULL};
PointerRNA dummyptr;
- int have_function[10];
+ int have_function[11];
/* setup dummy engine & engine type to store static properties in */
dummyengine.type = &dummyaet;
@@ -658,13 +688,15 @@ static StructRNA *rna_AssetEngine_register(Main *bmain, ReportList *reports, voi
aet->update_check = (have_function[4]) ? rna_ae_update_check : NULL;
- aet->load_pre = (have_function[5]) ? rna_ae_load_pre : NULL;
+ aet->ensure_uuids = (have_function[5]) ? rna_ae_ensure_uuids : NULL;
+
+ aet->load_pre = (have_function[6]) ? rna_ae_load_pre : NULL;
- aet->check_dir = (have_function[6]) ? rna_ae_check_dir : NULL;
+ aet->check_dir = (have_function[7]) ? rna_ae_check_dir : NULL;
- aet->sort_filter = (have_function[7]) ? rna_ae_sort_filter : NULL;
- aet->entries_block_get = (have_function[8]) ? rna_ae_entries_block_get : NULL;
- aet->entries_uuid_get = (have_function[9]) ? rna_ae_entries_uuid_get : NULL;
+ aet->sort_filter = (have_function[8]) ? rna_ae_sort_filter : NULL;
+ aet->entries_block_get = (have_function[9]) ? rna_ae_entries_block_get : NULL;
+ aet->entries_uuid_get = (have_function[10]) ? rna_ae_entries_uuid_get : NULL;
BLI_addtail(&asset_engines, aet);
@@ -1130,7 +1162,7 @@ static void rna_def_asset_engine(BlenderRNA *brna)
/* Status callback */
func = RNA_def_function(srna, "status", NULL);
RNA_def_function_ui_description(func, "Get status of whole engine, or a given job");
- RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
+ RNA_def_function_flag(func, FUNC_REGISTER);
RNA_def_int(func, "job_id", AE_JOB_ID_UNSET, AE_JOB_ID_INVALID, INT_MAX, "",
"Job ID (JOB_ID_UNSET to get engine status itself)", AE_JOB_ID_INVALID, INT_MAX);
parm = RNA_def_enum(func, "status_return", asset_engine_status_types, 0, "", "Status of given job or whole engine");
@@ -1140,7 +1172,7 @@ static void rna_def_asset_engine(BlenderRNA *brna)
/* Progress callback */
func = RNA_def_function(srna, "progress", NULL);
RNA_def_function_ui_description(func, "Get progress of a given job, or all running ones (between 0.0 and 1.0)");
- RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
+ RNA_def_function_flag(func, FUNC_REGISTER);
RNA_def_int(func, "job_id", AE_JOB_ID_UNSET, AE_JOB_ID_INVALID, INT_MAX, "",
"Job ID (JOB_ID_UNSET to get average progress of all running jobs)", AE_JOB_ID_INVALID, INT_MAX);
parm = RNA_def_float(func, "progress_return", 0.0f, 0.0f, 1.0f, "", "Progress", 0.0f, 1.0f);
@@ -1149,14 +1181,14 @@ static void rna_def_asset_engine(BlenderRNA *brna)
/* Kill job callback */
func = RNA_def_function(srna, "kill", NULL);
RNA_def_function_ui_description(func, "Unconditionnaly stop a given job, or all running ones");
- RNA_def_function_flag(func, FUNC_REGISTER_OPTIONAL);
+ RNA_def_function_flag(func, FUNC_REGISTER);
RNA_def_int(func, "job_id", AE_JOB_ID_UNSET, AE_JOB_ID_INVALID, INT_MAX, "",
"Job ID (JOB_ID_UNSET to kill all)", AE_JOB_ID_INVALID, INT_MAX);
/* Main listing callba
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list