Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-04-17 07:17:24 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-04-17 07:21:24 +0300
commite12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch)
tree8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/windowmanager/message_bus
parentb3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff)
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211. For details on usage and instructions for migrating branches without conflicts, see: https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'source/blender/windowmanager/message_bus')
-rw-r--r--source/blender/windowmanager/message_bus/intern/wm_message_bus.c293
-rw-r--r--source/blender/windowmanager/message_bus/intern/wm_message_bus_intern.h22
-rw-r--r--source/blender/windowmanager/message_bus/intern/wm_message_bus_rna.c506
-rw-r--r--source/blender/windowmanager/message_bus/intern/wm_message_bus_static.c124
-rw-r--r--source/blender/windowmanager/message_bus/wm_message_bus.h350
5 files changed, 644 insertions, 651 deletions
diff --git a/source/blender/windowmanager/message_bus/intern/wm_message_bus.c b/source/blender/windowmanager/message_bus/intern/wm_message_bus.c
index 3dab006defe..2cb8cc40995 100644
--- a/source/blender/windowmanager/message_bus/intern/wm_message_bus.c
+++ b/source/blender/windowmanager/message_bus/intern/wm_message_bus.c
@@ -43,106 +43,108 @@ static wmMsgTypeInfo wm_msg_types[WM_MSG_TYPE_NUM] = {{{NULL}}};
typedef void (*wmMsgTypeInitFn)(wmMsgTypeInfo *);
static wmMsgTypeInitFn wm_msg_init_fn[WM_MSG_TYPE_NUM] = {
- WM_msgtypeinfo_init_rna,
- WM_msgtypeinfo_init_static,
+ WM_msgtypeinfo_init_rna,
+ WM_msgtypeinfo_init_static,
};
void WM_msgbus_types_init(void)
{
- for (uint i = 0; i < WM_MSG_TYPE_NUM; i++) {
- wm_msg_init_fn[i](&wm_msg_types[i]);
- }
+ for (uint i = 0; i < WM_MSG_TYPE_NUM; i++) {
+ wm_msg_init_fn[i](&wm_msg_types[i]);
+ }
}
struct wmMsgBus *WM_msgbus_create(void)
{
- struct wmMsgBus *mbus = MEM_callocN(sizeof(*mbus), __func__);
- const uint gset_reserve = 512;
- for (uint i = 0; i < WM_MSG_TYPE_NUM; i++) {
- wmMsgTypeInfo *info = &wm_msg_types[i];
- mbus->messages_gset[i] = BLI_gset_new_ex(info->gset.hash_fn, info->gset.cmp_fn, __func__, gset_reserve);
- }
- return mbus;
+ struct wmMsgBus *mbus = MEM_callocN(sizeof(*mbus), __func__);
+ const uint gset_reserve = 512;
+ for (uint i = 0; i < WM_MSG_TYPE_NUM; i++) {
+ wmMsgTypeInfo *info = &wm_msg_types[i];
+ mbus->messages_gset[i] = BLI_gset_new_ex(
+ info->gset.hash_fn, info->gset.cmp_fn, __func__, gset_reserve);
+ }
+ return mbus;
}
void WM_msgbus_destroy(struct wmMsgBus *mbus)
{
- for (uint i = 0; i < WM_MSG_TYPE_NUM; i++) {
- wmMsgTypeInfo *info = &wm_msg_types[i];
- BLI_gset_free(mbus->messages_gset[i], info->gset.key_free_fn);
- }
- MEM_freeN(mbus);
+ for (uint i = 0; i < WM_MSG_TYPE_NUM; i++) {
+ wmMsgTypeInfo *info = &wm_msg_types[i];
+ BLI_gset_free(mbus->messages_gset[i], info->gset.key_free_fn);
+ }
+ MEM_freeN(mbus);
}
void WM_msgbus_clear_by_owner(struct wmMsgBus *mbus, void *owner)
{
- wmMsgSubscribeKey *msg_key, *msg_key_next;
- for (msg_key = mbus->messages.first; msg_key; msg_key = msg_key_next) {
- msg_key_next = msg_key->next;
-
- wmMsgSubscribeValueLink *msg_lnk_next;
- for (wmMsgSubscribeValueLink *msg_lnk = msg_key->values.first; msg_lnk; msg_lnk = msg_lnk_next) {
- msg_lnk_next = msg_lnk->next;
- if (msg_lnk->params.owner == owner) {
- if (msg_lnk->params.tag) {
- mbus->messages_tag_count -= 1;
- }
- if (msg_lnk->params.free_data) {
- msg_lnk->params.free_data(msg_key, &msg_lnk->params);
- }
- BLI_remlink(&msg_key->values, msg_lnk);
- MEM_freeN(msg_lnk);
- }
- }
-
- if (BLI_listbase_is_empty(&msg_key->values)) {
- const wmMsg *msg = wm_msg_subscribe_value_msg_cast(msg_key);
- wmMsgTypeInfo *info = &wm_msg_types[msg->type];
- BLI_remlink(&mbus->messages, msg_key);
- bool ok = BLI_gset_remove(mbus->messages_gset[msg->type], msg_key, info->gset.key_free_fn);
- BLI_assert(ok);
- UNUSED_VARS_NDEBUG(ok);
- }
- }
+ wmMsgSubscribeKey *msg_key, *msg_key_next;
+ for (msg_key = mbus->messages.first; msg_key; msg_key = msg_key_next) {
+ msg_key_next = msg_key->next;
+
+ wmMsgSubscribeValueLink *msg_lnk_next;
+ for (wmMsgSubscribeValueLink *msg_lnk = msg_key->values.first; msg_lnk;
+ msg_lnk = msg_lnk_next) {
+ msg_lnk_next = msg_lnk->next;
+ if (msg_lnk->params.owner == owner) {
+ if (msg_lnk->params.tag) {
+ mbus->messages_tag_count -= 1;
+ }
+ if (msg_lnk->params.free_data) {
+ msg_lnk->params.free_data(msg_key, &msg_lnk->params);
+ }
+ BLI_remlink(&msg_key->values, msg_lnk);
+ MEM_freeN(msg_lnk);
+ }
+ }
+
+ if (BLI_listbase_is_empty(&msg_key->values)) {
+ const wmMsg *msg = wm_msg_subscribe_value_msg_cast(msg_key);
+ wmMsgTypeInfo *info = &wm_msg_types[msg->type];
+ BLI_remlink(&mbus->messages, msg_key);
+ bool ok = BLI_gset_remove(mbus->messages_gset[msg->type], msg_key, info->gset.key_free_fn);
+ BLI_assert(ok);
+ UNUSED_VARS_NDEBUG(ok);
+ }
+ }
}
void WM_msg_dump(struct wmMsgBus *mbus, const char *info_str)
{
- printf(">>>> %s\n", info_str);
- for (wmMsgSubscribeKey *key = mbus->messages.first; key; key = key->next) {
- const wmMsg *msg = wm_msg_subscribe_value_msg_cast(key);
- const wmMsgTypeInfo *info = &wm_msg_types[msg->type];
- info->repr(stdout, key);
- }
- printf("<<<< %s\n", info_str);
+ printf(">>>> %s\n", info_str);
+ for (wmMsgSubscribeKey *key = mbus->messages.first; key; key = key->next) {
+ const wmMsg *msg = wm_msg_subscribe_value_msg_cast(key);
+ const wmMsgTypeInfo *info = &wm_msg_types[msg->type];
+ info->repr(stdout, key);
+ }
+ printf("<<<< %s\n", info_str);
}
void WM_msgbus_handle(struct wmMsgBus *mbus, struct bContext *C)
{
- if (mbus->messages_tag_count == 0) {
- // printf("msgbus: skipping\n");
- return;
- }
-
- if (false) {
- WM_msg_dump(mbus, __func__);
- }
-
- // uint a = 0, b = 0;
- for (wmMsgSubscribeKey *key = mbus->messages.first; key; key = key->next) {
- for (wmMsgSubscribeValueLink *msg_lnk = key->values.first; msg_lnk; msg_lnk = msg_lnk->next) {
- if (msg_lnk->params.tag) {
- msg_lnk->params.notify(C, key, &msg_lnk->params);
- msg_lnk->params.tag = false;
- mbus->messages_tag_count -= 1;
- }
- // b++;
- }
- // a++;
- }
- BLI_assert(mbus->messages_tag_count == 0);
- mbus->messages_tag_count = 0;
- // printf("msgbus: keys=%u values=%u\n", a, b);
+ if (mbus->messages_tag_count == 0) {
+ // printf("msgbus: skipping\n");
+ return;
+ }
+
+ if (false) {
+ WM_msg_dump(mbus, __func__);
+ }
+
+ // uint a = 0, b = 0;
+ for (wmMsgSubscribeKey *key = mbus->messages.first; key; key = key->next) {
+ for (wmMsgSubscribeValueLink *msg_lnk = key->values.first; msg_lnk; msg_lnk = msg_lnk->next) {
+ if (msg_lnk->params.tag) {
+ msg_lnk->params.notify(C, key, &msg_lnk->params);
+ msg_lnk->params.tag = false;
+ mbus->messages_tag_count -= 1;
+ }
+ // b++;
+ }
+ // a++;
+ }
+ BLI_assert(mbus->messages_tag_count == 0);
+ mbus->messages_tag_count = 0;
+ // printf("msgbus: keys=%u values=%u\n", a, b);
}
/**
@@ -155,82 +157,79 @@ void WM_msgbus_handle(struct wmMsgBus *mbus, struct bContext *C)
* \return The key for this subscription.
* note that this is only needed in rare cases when the key needs further manipulation.
*/
-wmMsgSubscribeKey *WM_msg_subscribe_with_key(
- struct wmMsgBus *mbus,
- const wmMsgSubscribeKey *msg_key_test,
- const wmMsgSubscribeValue *msg_val_params)
+wmMsgSubscribeKey *WM_msg_subscribe_with_key(struct wmMsgBus *mbus,
+ const wmMsgSubscribeKey *msg_key_test,
+ const wmMsgSubscribeValue *msg_val_params)
{
- const uint type = wm_msg_subscribe_value_msg_cast(msg_key_test)->type;
- const wmMsgTypeInfo *info = &wm_msg_types[type];
- wmMsgSubscribeKey *key;
-
- BLI_assert(wm_msg_subscribe_value_msg_cast(msg_key_test)->id != NULL);
-
- void **r_key;
- if (!BLI_gset_ensure_p_ex(mbus->messages_gset[type], msg_key_test, &r_key)) {
- key = *r_key = MEM_mallocN(info->msg_key_size, __func__);
- memcpy(key, msg_key_test, info->msg_key_size);
- BLI_addtail(&mbus->messages, key);
- }
- else {
- key = *r_key;
- for (wmMsgSubscribeValueLink *msg_lnk = key->values.first; msg_lnk; msg_lnk = msg_lnk->next) {
- if ((msg_lnk->params.notify == msg_val_params->notify) &&
- (msg_lnk->params.owner == msg_val_params->owner) &&
- (msg_lnk->params.user_data == msg_val_params->user_data))
- {
- return key;
- }
- }
- }
-
- wmMsgSubscribeValueLink *msg_lnk = MEM_mallocN(sizeof(wmMsgSubscribeValueLink), __func__);
- msg_lnk->params = *msg_val_params;
- BLI_addtail(&key->values, msg_lnk);
- return key;
+ const uint type = wm_msg_subscribe_value_msg_cast(msg_key_test)->type;
+ const wmMsgTypeInfo *info = &wm_msg_types[type];
+ wmMsgSubscribeKey *key;
+
+ BLI_assert(wm_msg_subscribe_value_msg_cast(msg_key_test)->id != NULL);
+
+ void **r_key;
+ if (!BLI_gset_ensure_p_ex(mbus->messages_gset[type], msg_key_test, &r_key)) {
+ key = *r_key = MEM_mallocN(info->msg_key_size, __func__);
+ memcpy(key, msg_key_test, info->msg_key_size);
+ BLI_addtail(&mbus->messages, key);
+ }
+ else {
+ key = *r_key;
+ for (wmMsgSubscribeValueLink *msg_lnk = key->values.first; msg_lnk; msg_lnk = msg_lnk->next) {
+ if ((msg_lnk->params.notify == msg_val_params->notify) &&
+ (msg_lnk->params.owner == msg_val_params->owner) &&
+ (msg_lnk->params.user_data == msg_val_params->user_data)) {
+ return key;
+ }
+ }
+ }
+
+ wmMsgSubscribeValueLink *msg_lnk = MEM_mallocN(sizeof(wmMsgSubscribeValueLink), __func__);
+ msg_lnk->params = *msg_val_params;
+ BLI_addtail(&key->values, msg_lnk);
+ return key;
}
void WM_msg_publish_with_key(struct wmMsgBus *mbus, wmMsgSubscribeKey *msg_key)
{
- CLOG_INFO(
- WM_LOG_MSGBUS_SUB, 2,
- "tagging subscribers: (ptr=%p, len=%d)",
- msg_key, BLI_listbase_count(&msg_key->values)
- );
-
- for (wmMsgSubscribeValueLink *msg_lnk = msg_key->values.first; msg_lnk; msg_lnk = msg_lnk->next) {
- if (false) { /* make an option? */
- msg_lnk->params.notify(NULL, msg_key, &msg_lnk->params);
- }
- else {
- if (msg_lnk->params.tag == false) {
- msg_lnk->params.tag = true;
- mbus->messages_tag_count += 1;
- }
- }
- }
+ CLOG_INFO(WM_LOG_MSGBUS_SUB,
+ 2,
+ "tagging subscribers: (ptr=%p, len=%d)",
+ msg_key,
+ BLI_listbase_count(&msg_key->values));
+
+ for (wmMsgSubscribeValueLink *msg_lnk = msg_key->values.first; msg_lnk;
+ msg_lnk = msg_lnk->next) {
+ if (false) { /* make an option? */
+ msg_lnk->params.notify(NULL, msg_key, &msg_lnk->params);
+ }
+ else {
+ if (msg_lnk->params.tag == false) {
+ msg_lnk->params.tag = true;
+ mbus->messages_tag_count += 1;
+ }
+ }
+ }
}
-void WM_msg_id_update(
- struct wmMsgBus *mbus,
- struct ID *id_src, struct ID *id_dst)
+void WM_msg_id_update(struct wmMsgBus *mbus, struct ID *id_src, struct ID *id_dst)
{
- for (uint i = 0; i < WM_MSG_TYPE_NUM; i++) {
- wmMsgTypeInfo *info = &wm_msg_types[i];
- if (info->update_by_id != NULL) {
- info->update_by_id(mbus, id_src, id_dst);
- }
- }
+ for (uint i = 0; i < WM_MSG_TYPE_NUM; i++) {
+ wmMsgTypeInfo *info = &wm_msg_types[i];
+ if (info->update_by_id != NULL) {
+ info->update_by_id(mbus, id_src, id_dst);
+ }
+ }
}
void WM_msg_id_remove(struct wmMsgBus *mbus, const struct ID *id)
{
- for (uint i = 0; i < WM_MSG_TYPE_NUM; i++) {
- wmMsgTypeInfo *info = &wm_msg_types[i];
- if (info->remove_by_id != NULL) {
- info->remove_by_id(mbus, id);
- }
- }
+ for (uint i = 0; i < WM_MSG_TYPE_NUM; i++) {
+ wmMsgTypeInfo *info = &wm_msg_types[i];
+ if (info->remove_by_id != NULL) {
+ info->remove_by_id(mbus, id);
+ }
+ }
}
/** \} */
@@ -241,18 +240,16 @@ void WM_msg_id_remove(struct wmMsgBus *mbus, const struct ID *id)
* \note While we could have a separate type for ID's, use RNA since there is enough overlap.
* \{ */
-
/**
* \note #wmMsgBus.messages_tag_count isn't updated, caller must handle.
*/
-void wm_msg_subscribe_value_free(
- wmMsgSubscribeKey *msg_key, wmMsgSubscribeValueLink *msg_lnk)
+void wm_msg_subscribe_value_free(wmMsgSubscribeKey *msg_key, wmMsgSubscribeValueLink *msg_lnk)
{
- if (msg_lnk->params.free_data) {
- msg_lnk->params.free_data(msg_key, &msg_lnk->params);
- }
- BLI_remlink(&msg_key->values, msg_lnk);
- MEM_freeN(msg_lnk);
+ if (msg_lnk->params.free_data) {
+ msg_lnk->params.free_data(msg_key, &msg_lnk->params);
+ }
+ BLI_remlink(&msg_key->values, msg_lnk);
+ MEM_freeN(msg_lnk);
}
/** \} */
diff --git a/source/blender/windowmanager/message_bus/intern/wm_message_bus_intern.h b/source/blender/windowmanager/message_bus/intern/wm_message_bus_intern.h
index 3b22d88a188..0eac9e234be 100644
--- a/source/blender/windowmanager/message_bus/intern/wm_message_bus_intern.h
+++ b/source/blender/windowmanager/message_bus/intern/wm_message_bus_intern.h
@@ -24,28 +24,28 @@
/* wm_message_bus.h must be included first */
struct wmMsgBus {
- struct GSet *messages_gset[WM_MSG_TYPE_NUM];
- /** Messages in order of being added. */
- ListBase messages;
- /** Avoid checking messages when no tags exist. */
- uint messages_tag_count;
+ struct GSet *messages_gset[WM_MSG_TYPE_NUM];
+ /** Messages in order of being added. */
+ ListBase messages;
+ /** Avoid checking messages when no tags exist. */
+ uint messages_tag_count;
};
-void wm_msg_subscribe_value_free(
- struct wmMsgSubscribeKey *msg_key, struct wmMsgSubscribeValueLink *msg_lnk);
+void wm_msg_subscribe_value_free(struct wmMsgSubscribeKey *msg_key,
+ struct wmMsgSubscribeValueLink *msg_lnk);
typedef struct wmMsgSubscribeKey_Generic {
- wmMsgSubscribeKey head;
- wmMsg msg;
+ wmMsgSubscribeKey head;
+ wmMsg msg;
} wmMsgSubscribeKey_Generic;
BLI_INLINE const wmMsg *wm_msg_subscribe_value_msg_cast(const wmMsgSubscribeKey *key)
{
- return &((wmMsgSubscribeKey_Generic *)key)->msg;
+ return &((wmMsgSubscribeKey_Generic *)key)->msg;
}
BLI_INLINE wmMsg *wm_msg_subscribe_value_msg_cast_mut(wmMsgSubscribeKey *key)
{
- return &((wmMsgSubscribeKey_Generic *)key)->msg;
+ return &((wmMsgSubscribeKey_Generic *)key)->msg;
}
#endif /* __WM_MESSAGE_BUS_INTERN_H__ */
diff --git a/source/blender/windowmanager/message_bus/intern/wm_message_bus_rna.c b/source/blender/windowmanager/message_bus/intern/wm_message_bus_rna.c
index 02300128e9f..227a21726f4 100644
--- a/source/blender/windowmanager/message_bus/intern/wm_message_bus_rna.c
+++ b/source/blender/windowmanager/message_bus/intern/wm_message_bus_rna.c
@@ -39,301 +39,290 @@
BLI_INLINE uint void_hash_uint(const void *key)
{
- size_t y = (size_t)key >> (sizeof(void *));
- return (unsigned int)y;
+ size_t y = (size_t)key >> (sizeof(void *));
+ return (unsigned int)y;
}
static uint wm_msg_rna_gset_hash(const void *key_p)
{
- const wmMsgSubscribeKey_RNA *key = key_p;
- const wmMsgParams_RNA *params = &key->msg.params;
-// printf("%s\n", RNA_struct_identifier(params->ptr.type));
- uint k = void_hash_uint(params->ptr.type);
- k ^= void_hash_uint(params->ptr.data);
- k ^= void_hash_uint(params->ptr.id.data);
- k ^= void_hash_uint(params->prop);
- return k;
+ const wmMsgSubscribeKey_RNA *key = key_p;
+ const wmMsgParams_RNA *params = &key->msg.params;
+ // printf("%s\n", RNA_struct_identifier(params->ptr.type));
+ uint k = void_hash_uint(params->ptr.type);
+ k ^= void_hash_uint(params->ptr.data);
+ k ^= void_hash_uint(params->ptr.id.data);
+ k ^= void_hash_uint(params->prop);
+ return k;
}
static bool wm_msg_rna_gset_cmp(const void *key_a_p, const void *key_b_p)
{
- const wmMsgParams_RNA *params_a = &((const wmMsgSubscribeKey_RNA *)key_a_p)->msg.params;
- const wmMsgParams_RNA *params_b = &((const wmMsgSubscribeKey_RNA *)key_b_p)->msg.params;
- return !(
- (params_a->ptr.type ==
- params_b->ptr.type) &&
- (params_a->ptr.id.data ==
- params_b->ptr.id.data) &&
- (params_a->ptr.data ==
- params_b->ptr.data) &&
- (params_a->prop ==
- params_b->prop)
- );
+ const wmMsgParams_RNA *params_a = &((const wmMsgSubscribeKey_RNA *)key_a_p)->msg.params;
+ const wmMsgParams_RNA *params_b = &((const wmMsgSubscribeKey_RNA *)key_b_p)->msg.params;
+ return !((params_a->ptr.type == params_b->ptr.type) &&
+ (params_a->ptr.id.data == params_b->ptr.id.data) &&
+ (params_a->ptr.data == params_b->ptr.data) && (params_a->prop == params_b->prop));
}
static void wm_msg_rna_gset_key_free(void *key_p)
{
- wmMsgSubscribeKey_RNA *key = key_p;
- wmMsgSubscribeValueLink *msg_lnk_next;
- for (wmMsgSubscribeValueLink *msg_lnk = key->head.values.first; msg_lnk; msg_lnk = msg_lnk_next) {
- msg_lnk_next = msg_lnk->next;
- wm_msg_subscribe_value_free(&key->head, msg_lnk);
- }
- if (key->msg.params.data_path != NULL) {
- MEM_freeN(key->msg.params.data_path);
- }
- MEM_freeN(key);
+ wmMsgSubscribeKey_RNA *key = key_p;
+ wmMsgSubscribeValueLink *msg_lnk_next;
+ for (wmMsgSubscribeValueLink *msg_lnk = key->head.values.first; msg_lnk;
+ msg_lnk = msg_lnk_next) {
+ msg_lnk_next = msg_lnk->next;
+ wm_msg_subscribe_value_free(&key->head, msg_lnk);
+ }
+ if (key->msg.params.data_path != NULL) {
+ MEM_freeN(key->msg.params.data_path);
+ }
+ MEM_freeN(key);
}
static void wm_msg_rna_repr(FILE *stream, const wmMsgSubscribeKey *msg_key)
{
- const wmMsgSubscribeKey_RNA *m = (wmMsgSubscribeKey_RNA *)msg_key;
- const char *none = "<none>";
- fprintf(stream,
- "<wmMsg_RNA %p, "
- "id='%s', "
- "%s.%s values_len=%d\n",
- m, m->msg.head.id,
- m->msg.params.ptr.type ? RNA_struct_identifier(m->msg.params.ptr.type) : none,
- m->msg.params.prop ? RNA_property_identifier((PropertyRNA *)m->msg.params.prop) : none,
- BLI_listbase_count(&m->head.values));
+ const wmMsgSubscribeKey_RNA *m = (wmMsgSubscribeKey_RNA *)msg_key;
+ const char *none = "<none>";
+ fprintf(stream,
+ "<wmMsg_RNA %p, "
+ "id='%s', "
+ "%s.%s values_len=%d\n",
+ m,
+ m->msg.head.id,
+ m->msg.params.ptr.type ? RNA_struct_identifier(m->msg.params.ptr.type) : none,
+ m->msg.params.prop ? RNA_property_identifier((PropertyRNA *)m->msg.params.prop) : none,
+ BLI_listbase_count(&m->head.values));
}
-static void wm_msg_rna_update_by_id(
- struct wmMsgBus *mbus,
- ID *id_src, ID *id_dst)
+static void wm_msg_rna_update_by_id(struct wmMsgBus *mbus, ID *id_src, ID *id_dst)
{
- GSet *gs = mbus->messages_gset[WM_MSG_TYPE_RNA];
- GSetIterator gs_iter;
- BLI_gsetIterator_init(&gs_iter, gs);
- while (BLI_gsetIterator_done(&gs_iter) == false) {
- wmMsgSubscribeKey_RNA *key = BLI_gsetIterator_getKey(&gs_iter);
- BLI_gsetIterator_step(&gs_iter);
- if (key->msg.params.ptr.id.data == id_src) {
-
- /* GSet always needs updating since the key changes. */
- BLI_gset_remove(gs, key, NULL);
-
- /* Remove any non-persistent values, so a single persistent
- * value doesn't modify behavior for the rest. */
- for (wmMsgSubscribeValueLink *msg_lnk = key->head.values.first, *msg_lnk_next;
- msg_lnk;
- msg_lnk = msg_lnk_next)
- {
- msg_lnk_next = msg_lnk->next;
- if (msg_lnk->params.is_persistent == false) {
- if (msg_lnk->params.tag) {
- mbus->messages_tag_count -= 1;
- }
- wm_msg_subscribe_value_free(&key->head, msg_lnk);
- }
- }
-
- bool remove = true;
-
- if (BLI_listbase_is_empty(&key->head.values)) {
- /* Remove, no reason to keep. */
- }
- else if (key->msg.params.ptr.data == key->msg.params.ptr.id.data) {
- /* Simple, just update the ID. */
- key->msg.params.ptr.data = id_dst;
- key->msg.params.ptr.id.data = id_dst;
- remove = false;
- }
- else {
- /* We need to resolve this from the new ID pointer. */
- PointerRNA idptr;
- RNA_id_pointer_create(id_dst, &idptr);
- PointerRNA ptr;
- PropertyRNA *prop = NULL;
- if (RNA_path_resolve(&idptr, key->msg.params.data_path, &ptr, &prop) &&
- (prop == NULL) == (key->msg.params.prop == NULL))
- {
- key->msg.params.ptr = ptr;
- key->msg.params.prop = prop;
- remove = false;
- }
- }
-
- if (remove) {
- for (wmMsgSubscribeValueLink *msg_lnk = key->head.values.first, *msg_lnk_next;
- msg_lnk;
- msg_lnk = msg_lnk_next)
- {
- msg_lnk_next = msg_lnk->next;
- if (msg_lnk->params.is_persistent == false) {
- if (msg_lnk->params.tag) {
- mbus->messages_tag_count -= 1;
- }
- wm_msg_subscribe_value_free(&key->head, msg_lnk);
- }
- }
- /* Failed to persist, remove the key. */
- BLI_remlink(&mbus->messages, key);
- wm_msg_rna_gset_key_free(key);
- }
- else {
- /* note that it's not impossible this key exists, however it is very unlikely
- * since a subscriber would need to register in the middle of an undo for eg. so assert for now. */
- BLI_assert(!BLI_gset_haskey(gs, key));
- BLI_gset_add(gs, key);
- }
- }
- }
+ GSet *gs = mbus->messages_gset[WM_MSG_TYPE_RNA];
+ GSetIterator gs_iter;
+ BLI_gsetIterator_init(&gs_iter, gs);
+ while (BLI_gsetIterator_done(&gs_iter) == false) {
+ wmMsgSubscribeKey_RNA *key = BLI_gsetIterator_getKey(&gs_iter);
+ BLI_gsetIterator_step(&gs_iter);
+ if (key->msg.params.ptr.id.data == id_src) {
+
+ /* GSet always needs updating since the key changes. */
+ BLI_gset_remove(gs, key, NULL);
+
+ /* Remove any non-persistent values, so a single persistent
+ * value doesn't modify behavior for the rest. */
+ for (wmMsgSubscribeValueLink *msg_lnk = key->head.values.first, *msg_lnk_next; msg_lnk;
+ msg_lnk = msg_lnk_next) {
+ msg_lnk_next = msg_lnk->next;
+ if (msg_lnk->params.is_persistent == false) {
+ if (msg_lnk->params.tag) {
+ mbus->messages_tag_count -= 1;
+ }
+ wm_msg_subscribe_value_free(&key->head, msg_lnk);
+ }
+ }
+
+ bool remove = true;
+
+ if (BLI_listbase_is_empty(&key->head.values)) {
+ /* Remove, no reason to keep. */
+ }
+ else if (key->msg.params.ptr.data == key->msg.params.ptr.id.data) {
+ /* Simple, just update the ID. */
+ key->msg.params.ptr.data = id_dst;
+ key->msg.params.ptr.id.data = id_dst;
+ remove = false;
+ }
+ else {
+ /* We need to resolve this from the new ID pointer. */
+ PointerRNA idptr;
+ RNA_id_pointer_create(id_dst, &idptr);
+ PointerRNA ptr;
+ PropertyRNA *prop = NULL;
+ if (RNA_path_resolve(&idptr, key->msg.params.data_path, &ptr, &prop) &&
+ (prop == NULL) == (key->msg.params.prop == NULL)) {
+ key->msg.params.ptr = ptr;
+ key->msg.params.prop = prop;
+ remove = false;
+ }
+ }
+
+ if (remove) {
+ for (wmMsgSubscribeValueLink *msg_lnk = key->head.values.first, *msg_lnk_next; msg_lnk;
+ msg_lnk = msg_lnk_next) {
+ msg_lnk_next = msg_lnk->next;
+ if (msg_lnk->params.is_persistent == false) {
+ if (msg_lnk->params.tag) {
+ mbus->messages_tag_count -= 1;
+ }
+ wm_msg_subscribe_value_free(&key->head, msg_lnk);
+ }
+ }
+ /* Failed to persist, remove the key. */
+ BLI_remlink(&mbus->messages, key);
+ wm_msg_rna_gset_key_free(key);
+ }
+ else {
+ /* note that it's not impossible this key exists, however it is very unlikely
+ * since a subscriber would need to register in the middle of an undo for eg. so assert for now. */
+ BLI_assert(!BLI_gset_haskey(gs, key));
+ BLI_gset_add(gs, key);
+ }
+ }
+ }
}
static void wm_msg_rna_remove_by_id(struct wmMsgBus *mbus, const ID *id)
{
- GSet *gs = mbus->messages_gset[WM_MSG_TYPE_RNA];
- GSetIterator gs_iter;
- BLI_gsetIterator_init(&gs_iter, gs);
- while (BLI_gsetIterator_done(&gs_iter) == false) {
- wmMsgSubscribeKey_RNA *key = BLI_gsetIterator_getKey(&gs_iter);
- BLI_gsetIterator_step(&gs_iter);
- if (key->msg.params.ptr.id.data == id) {
- /* Clear here so we can decrement 'messages_tag_count'. */
- for (wmMsgSubscribeValueLink *msg_lnk = key->head.values.first, *msg_lnk_next;
- msg_lnk;
- msg_lnk = msg_lnk_next)
- {
- msg_lnk_next = msg_lnk->next;
- if (msg_lnk->params.tag) {
- mbus->messages_tag_count -= 1;
- }
- wm_msg_subscribe_value_free(&key->head, msg_lnk);
- }
-
- BLI_remlink(&mbus->messages, key);
- BLI_gset_remove(gs, key, NULL);
- wm_msg_rna_gset_key_free(key);
- }
- }
+ GSet *gs = mbus->messages_gset[WM_MSG_TYPE_RNA];
+ GSetIterator gs_iter;
+ BLI_gsetIterator_init(&gs_iter, gs);
+ while (BLI_gsetIterator_done(&gs_iter) == false) {
+ wmMsgSubscribeKey_RNA *key = BLI_gsetIterator_getKey(&gs_iter);
+ BLI_gsetIterator_step(&gs_iter);
+ if (key->msg.params.ptr.id.data == id) {
+ /* Clear here so we can decrement 'messages_tag_count'. */
+ for (wmMsgSubscribeValueLink *msg_lnk = key->head.values.first, *msg_lnk_next; msg_lnk;
+ msg_lnk = msg_lnk_next) {
+ msg_lnk_next = msg_lnk->next;
+ if (msg_lnk->params.tag) {
+ mbus->messages_tag_count -= 1;
+ }
+ wm_msg_subscribe_value_free(&key->head, msg_lnk);
+ }
+
+ BLI_remlink(&mbus->messages, key);
+ BLI_gset_remove(gs, key, NULL);
+ wm_msg_rna_gset_key_free(key);
+ }
+ }
}
void WM_msgtypeinfo_init_rna(wmMsgTypeInfo *msgtype_info)
{
- msgtype_info->gset.hash_fn = wm_msg_rna_gset_hash;
- msgtype_info->gset.cmp_fn = wm_msg_rna_gset_cmp;
- msgtype_info->gset.key_free_fn = wm_msg_rna_gset_key_free;
+ msgtype_info->gset.hash_fn = wm_msg_rna_gset_hash;
+ msgtype_info->gset.cmp_fn = wm_msg_rna_gset_cmp;
+ msgtype_info->gset.key_free_fn = wm_msg_rna_gset_key_free;
- msgtype_info->repr = wm_msg_rna_repr;
- msgtype_info->update_by_id = wm_msg_rna_update_by_id;
- msgtype_info->remove_by_id = wm_msg_rna_remove_by_id;
+ msgtype_info->repr = wm_msg_rna_repr;
+ msgtype_info->update_by_id = wm_msg_rna_update_by_id;
+ msgtype_info->remove_by_id = wm_msg_rna_remove_by_id;
- msgtype_info->msg_key_size = sizeof(wmMsgSubscribeKey_RNA);
+ msgtype_info->msg_key_size = sizeof(wmMsgSubscribeKey_RNA);
}
/* -------------------------------------------------------------------------- */
-
-wmMsgSubscribeKey_RNA *WM_msg_lookup_rna(struct wmMsgBus *mbus, const wmMsgParams_RNA *msg_key_params)
+wmMsgSubscribeKey_RNA *WM_msg_lookup_rna(struct wmMsgBus *mbus,
+ const wmMsgParams_RNA *msg_key_params)
{
- wmMsgSubscribeKey_RNA key_test;
- key_test.msg.params = *msg_key_params;
- return BLI_gset_lookup(mbus->messages_gset[WM_MSG_TYPE_RNA], &key_test);
+ wmMsgSubscribeKey_RNA key_test;
+ key_test.msg.params = *msg_key_params;
+ return BLI_gset_lookup(mbus->messages_gset[WM_MSG_TYPE_RNA], &key_test);
}
void WM_msg_publish_rna_params(struct wmMsgBus *mbus, const wmMsgParams_RNA *msg_key_params)
{
- wmMsgSubscribeKey_RNA *key;
-
- const char *none = "<none>";
- CLOG_INFO(
- WM_LOG_MSGBUS_PUB, 2,
- "rna(id='%s', %s.%s)",
- msg_key_params->ptr.id.data ? ((ID *)msg_key_params->ptr.id.data)->name : none,
- msg_key_params->ptr.type ? RNA_struct_identifier(msg_key_params->ptr.type) : none,
- msg_key_params->prop ? RNA_property_identifier((PropertyRNA *)msg_key_params->prop) : none
- );
-
- if ((key = WM_msg_lookup_rna(mbus, msg_key_params))) {
- WM_msg_publish_with_key(mbus, &key->head);
- }
-
- /* Support anonymous subscribers, this may be some extra overhead
- * but we want to be able to be more ambiguous. */
- if (msg_key_params->ptr.id.data || msg_key_params->ptr.data) {
- wmMsgParams_RNA msg_key_params_anon = *msg_key_params;
-
- /* We might want to enable this later? */
- if (msg_key_params_anon.prop != NULL) {
- /* All properties for this type. */
- msg_key_params_anon.prop = NULL;
- if ((key = WM_msg_lookup_rna(mbus, &msg_key_params_anon))) {
- WM_msg_publish_with_key(mbus, &key->head);
- }
- msg_key_params_anon.prop = msg_key_params->prop;
- }
-
- msg_key_params_anon.ptr.id.data = NULL;
- msg_key_params_anon.ptr.data = NULL;
- if ((key = WM_msg_lookup_rna(mbus, &msg_key_params_anon))) {
- WM_msg_publish_with_key(mbus, &key->head);
- }
-
- /* Support subscribers to a type. */
- if (msg_key_params->prop) {
- msg_key_params_anon.prop = NULL;
- if ((key = WM_msg_lookup_rna(mbus, &msg_key_params_anon))) {
- WM_msg_publish_with_key(mbus, &key->head);
- }
- }
- }
+ wmMsgSubscribeKey_RNA *key;
+
+ const char *none = "<none>";
+ CLOG_INFO(WM_LOG_MSGBUS_PUB,
+ 2,
+ "rna(id='%s', %s.%s)",
+ msg_key_params->ptr.id.data ? ((ID *)msg_key_params->ptr.id.data)->name : none,
+ msg_key_params->ptr.type ? RNA_struct_identifier(msg_key_params->ptr.type) : none,
+ msg_key_params->prop ? RNA_property_identifier((PropertyRNA *)msg_key_params->prop) :
+ none);
+
+ if ((key = WM_msg_lookup_rna(mbus, msg_key_params))) {
+ WM_msg_publish_with_key(mbus, &key->head);
+ }
+
+ /* Support anonymous subscribers, this may be some extra overhead
+ * but we want to be able to be more ambiguous. */
+ if (msg_key_params->ptr.id.data || msg_key_params->ptr.data) {
+ wmMsgParams_RNA msg_key_params_anon = *msg_key_params;
+
+ /* We might want to enable this later? */
+ if (msg_key_params_anon.prop != NULL) {
+ /* All properties for this type. */
+ msg_key_params_anon.prop = NULL;
+ if ((key = WM_msg_lookup_rna(mbus, &msg_key_params_anon))) {
+ WM_msg_publish_with_key(mbus, &key->head);
+ }
+ msg_key_params_anon.prop = msg_key_params->prop;
+ }
+
+ msg_key_params_anon.ptr.id.data = NULL;
+ msg_key_params_anon.ptr.data = NULL;
+ if ((key = WM_msg_lookup_rna(mbus, &msg_key_params_anon))) {
+ WM_msg_publish_with_key(mbus, &key->head);
+ }
+
+ /* Support subscribers to a type. */
+ if (msg_key_params->prop) {
+ msg_key_params_anon.prop = NULL;
+ if ((key = WM_msg_lookup_rna(mbus, &msg_key_params_anon))) {
+ WM_msg_publish_with_key(mbus, &key->head);
+ }
+ }
+ }
}
void WM_msg_publish_rna(struct wmMsgBus *mbus, PointerRNA *ptr, PropertyRNA *prop)
{
- WM_msg_publish_rna_params(mbus, &(wmMsgParams_RNA){ .ptr = *ptr, .prop = prop, });
+ WM_msg_publish_rna_params(mbus,
+ &(wmMsgParams_RNA){
+ .ptr = *ptr,
+ .prop = prop,
+ });
}
-void WM_msg_subscribe_rna_params(
- struct wmMsgBus *mbus,
- const wmMsgParams_RNA *msg_key_params,
- const wmMsgSubscribeValue *msg_val_params,
- const char *id_repr)
+void WM_msg_subscribe_rna_params(struct wmMsgBus *mbus,
+ const wmMsgParams_RNA *msg_key_params,
+ const wmMsgSubscribeValue *msg_val_params,
+ const char *id_repr)
{
- wmMsgSubscribeKey_RNA msg_key_test = {{NULL}};
-
- /* use when added */
- msg_key_test.msg.head.id = id_repr;
- msg_key_test.msg.head.type = WM_MSG_TYPE_RNA;
- /* for lookup */
- msg_key_test.msg.params = *msg_key_params;
-
- const char *none = "<none>";
- CLOG_INFO(
- WM_LOG_MSGBUS_SUB, 3,
- "rna(id='%s', %s.%s, info='%s')",
- msg_key_params->ptr.id.data ? ((ID *)msg_key_params->ptr.id.data)->name : none,
- msg_key_params->ptr.type ? RNA_struct_identifier(msg_key_params->ptr.type) : none,
- msg_key_params->prop ? RNA_property_identifier((PropertyRNA *)msg_key_params->prop) : none,
- id_repr
- );
-
- wmMsgSubscribeKey_RNA *msg_key = (wmMsgSubscribeKey_RNA *)WM_msg_subscribe_with_key(
- mbus, &msg_key_test.head, msg_val_params);
-
- if (msg_val_params->is_persistent) {
- if (msg_key->msg.params.data_path == NULL) {
- if (msg_key->msg.params.ptr.data != msg_key->msg.params.ptr.id.data) {
- /* We assume prop type can't change. */
- msg_key->msg.params.data_path = RNA_path_from_ID_to_struct(&msg_key->msg.params.ptr);
- }
- }
- }
+ wmMsgSubscribeKey_RNA msg_key_test = {{NULL}};
+
+ /* use when added */
+ msg_key_test.msg.head.id = id_repr;
+ msg_key_test.msg.head.type = WM_MSG_TYPE_RNA;
+ /* for lookup */
+ msg_key_test.msg.params = *msg_key_params;
+
+ const char *none = "<none>";
+ CLOG_INFO(WM_LOG_MSGBUS_SUB,
+ 3,
+ "rna(id='%s', %s.%s, info='%s')",
+ msg_key_params->ptr.id.data ? ((ID *)msg_key_params->ptr.id.data)->name : none,
+ msg_key_params->ptr.type ? RNA_struct_identifier(msg_key_params->ptr.type) : none,
+ msg_key_params->prop ? RNA_property_identifier((PropertyRNA *)msg_key_params->prop) :
+ none,
+ id_repr);
+
+ wmMsgSubscribeKey_RNA *msg_key = (wmMsgSubscribeKey_RNA *)WM_msg_subscribe_with_key(
+ mbus, &msg_key_test.head, msg_val_params);
+
+ if (msg_val_params->is_persistent) {
+ if (msg_key->msg.params.data_path == NULL) {
+ if (msg_key->msg.params.ptr.data != msg_key->msg.params.ptr.id.data) {
+ /* We assume prop type can't change. */
+ msg_key->msg.params.data_path = RNA_path_from_ID_to_struct(&msg_key->msg.params.ptr);
+ }
+ }
+ }
}
-void WM_msg_subscribe_rna(
- struct wmMsgBus *mbus,
- PointerRNA *ptr, const PropertyRNA *prop,
- const wmMsgSubscribeValue *msg_val_params,
- const char *id_repr)
+void WM_msg_subscribe_rna(struct wmMsgBus *mbus,
+ PointerRNA *ptr,
+ const PropertyRNA *prop,
+ const wmMsgSubscribeValue *msg_val_params,
+ const char *id_repr)
{
- WM_msg_subscribe_rna_params(
- mbus,
- &(const wmMsgParams_RNA){
- .ptr = *ptr,
- .prop = prop,
- },
- msg_val_params, id_repr);
+ WM_msg_subscribe_rna_params(mbus,
+ &(const wmMsgParams_RNA){
+ .ptr = *ptr,
+ .prop = prop,
+ },
+ msg_val_params,
+ id_repr);
}
/** \} */
@@ -344,20 +333,21 @@ void WM_msg_subscribe_rna(
* \note While we could have a separate type for ID's, use RNA since there is enough overlap.
* \{ */
-void WM_msg_subscribe_ID(
- struct wmMsgBus *mbus, ID *id, const wmMsgSubscribeValue *msg_val_params,
- const char *id_repr)
+void WM_msg_subscribe_ID(struct wmMsgBus *mbus,
+ ID *id,
+ const wmMsgSubscribeValue *msg_val_params,
+ const char *id_repr)
{
- wmMsgParams_RNA msg_key_params = {{{NULL}}};
- RNA_id_pointer_create(id, &msg_key_params.ptr);
- WM_msg_subscribe_rna_params(mbus, &msg_key_params, msg_val_params, id_repr);
+ wmMsgParams_RNA msg_key_params = {{{NULL}}};
+ RNA_id_pointer_create(id, &msg_key_params.ptr);
+ WM_msg_subscribe_rna_params(mbus, &msg_key_params, msg_val_params, id_repr);
}
void WM_msg_publish_ID(struct wmMsgBus *mbus, ID *id)
{
- wmMsgParams_RNA msg_key_params = {{{NULL}}};
- RNA_id_pointer_create(id, &msg_key_params.ptr);
- WM_msg_publish_rna_params(mbus, &msg_key_params);
+ wmMsgParams_RNA msg_key_params = {{{NULL}}};
+ RNA_id_pointer_create(id, &msg_key_params.ptr);
+ WM_msg_publish_rna_params(mbus, &msg_key_params);
}
/** \} */
diff --git a/source/blender/windowmanager/message_bus/intern/wm_message_bus_static.c b/source/blender/windowmanager/message_bus/intern/wm_message_bus_static.c
index 29b59ebf9ae..f3784b35499 100644
--- a/source/blender/windowmanager/message_bus/intern/wm_message_bus_static.c
+++ b/source/blender/windowmanager/message_bus/intern/wm_message_bus_static.c
@@ -32,106 +32,108 @@
#include "WM_message.h"
#include "message_bus/intern/wm_message_bus_intern.h"
-
/* -------------------------------------------------------------------------- */
static uint wm_msg_static_gset_hash(const void *key_p)
{
- const wmMsgSubscribeKey_Static *key = key_p;
- const wmMsgParams_Static *params = &key->msg.params;
- uint k = params->event;
- return k;
+ const wmMsgSubscribeKey_Static *key = key_p;
+ const wmMsgParams_Static *params = &key->msg.params;
+ uint k = params->event;
+ return k;
}
static bool wm_msg_static_gset_cmp(const void *key_a_p, const void *key_b_p)
{
- const wmMsgParams_Static *params_a = &((const wmMsgSubscribeKey_Static *)key_a_p)->msg.params;
- const wmMsgParams_Static *params_b = &((const wmMsgSubscribeKey_Static *)key_b_p)->msg.params;
- return !(
- (params_a->event ==
- params_b->event)
- );
+ const wmMsgParams_Static *params_a = &((const wmMsgSubscribeKey_Static *)key_a_p)->msg.params;
+ const wmMsgParams_Static *params_b = &((const wmMsgSubscribeKey_Static *)key_b_p)->msg.params;
+ return !((params_a->event == params_b->event));
}
static void wm_msg_static_gset_key_free(void *key_p)
{
- wmMsgSubscribeKey *key = key_p;
- wmMsgSubscribeValueLink *msg_lnk_next;
- for (wmMsgSubscribeValueLink *msg_lnk = key->values.first; msg_lnk; msg_lnk = msg_lnk_next) {
- msg_lnk_next = msg_lnk->next;
- BLI_remlink(&key->values, msg_lnk);
- MEM_freeN(msg_lnk);
- }
- MEM_freeN(key);
+ wmMsgSubscribeKey *key = key_p;
+ wmMsgSubscribeValueLink *msg_lnk_next;
+ for (wmMsgSubscribeValueLink *msg_lnk = key->values.first; msg_lnk; msg_lnk = msg_lnk_next) {
+ msg_lnk_next = msg_lnk->next;
+ BLI_remlink(&key->values, msg_lnk);
+ MEM_freeN(msg_lnk);
+ }
+ MEM_freeN(key);
}
static void wm_msg_static_repr(FILE *stream, const wmMsgSubscribeKey *msg_key)
{
- const wmMsgSubscribeKey_Static *m = (wmMsgSubscribeKey_Static *)msg_key;
- fprintf(stream,
- "<wmMsg_Static %p, "
- "id='%s', "
- "values_len=%d\n",
- m, m->msg.head.id,
- BLI_listbase_count(&m->head.values));
+ const wmMsgSubscribeKey_Static *m = (wmMsgSubscribeKey_Static *)msg_key;
+ fprintf(stream,
+ "<wmMsg_Static %p, "
+ "id='%s', "
+ "values_len=%d\n",
+ m,
+ m->msg.head.id,
+ BLI_listbase_count(&m->head.values));
}
-
void WM_msgtypeinfo_init_static(wmMsgTypeInfo *msgtype_info)
{
- msgtype_info->gset.hash_fn = wm_msg_static_gset_hash;
- msgtype_info->gset.cmp_fn = wm_msg_static_gset_cmp;
- msgtype_info->gset.key_free_fn = wm_msg_static_gset_key_free;
- msgtype_info->repr = wm_msg_static_repr;
+ msgtype_info->gset.hash_fn = wm_msg_static_gset_hash;
+ msgtype_info->gset.cmp_fn = wm_msg_static_gset_cmp;
+ msgtype_info->gset.key_free_fn = wm_msg_static_gset_key_free;
+ msgtype_info->repr = wm_msg_static_repr;
- msgtype_info->msg_key_size = sizeof(wmMsgSubscribeKey_Static);
+ msgtype_info->msg_key_size = sizeof(wmMsgSubscribeKey_Static);
}
/* -------------------------------------------------------------------------- */
-
-wmMsgSubscribeKey_Static *WM_msg_lookup_static(struct wmMsgBus *mbus, const wmMsgParams_Static *msg_key_params)
+wmMsgSubscribeKey_Static *WM_msg_lookup_static(struct wmMsgBus *mbus,
+ const wmMsgParams_Static *msg_key_params)
{
- wmMsgSubscribeKey_Static key_test;
- key_test.msg.params = *msg_key_params;
- return BLI_gset_lookup(mbus->messages_gset[WM_MSG_TYPE_STATIC], &key_test);
+ wmMsgSubscribeKey_Static key_test;
+ key_test.msg.params = *msg_key_params;
+ return BLI_gset_lookup(mbus->messages_gset[WM_MSG_TYPE_STATIC], &key_test);
}
void WM_msg_publish_static_params(struct wmMsgBus *mbus, const wmMsgParams_Static *msg_key_params)
{
- CLOG_INFO(WM_LOG_MSGBUS_PUB, 2, "static(event=%d)", msg_key_params->event);
+ CLOG_INFO(WM_LOG_MSGBUS_PUB, 2, "static(event=%d)", msg_key_params->event);
- wmMsgSubscribeKey_Static *key = WM_msg_lookup_static(mbus, msg_key_params);
- if (key) {
- WM_msg_publish_with_key(mbus, &key->head);
- }
+ wmMsgSubscribeKey_Static *key = WM_msg_lookup_static(mbus, msg_key_params);
+ if (key) {
+ WM_msg_publish_with_key(mbus, &key->head);
+ }
}
void WM_msg_publish_static(struct wmMsgBus *mbus, int event)
{
- WM_msg_publish_static_params(mbus, &(wmMsgParams_Static){ .event = event, });
+ WM_msg_publish_static_params(mbus,
+ &(wmMsgParams_Static){
+ .event = event,
+ });
}
-void WM_msg_subscribe_static_params(
- struct wmMsgBus *mbus,
- const wmMsgParams_Static *msg_key_params,
- const wmMsgSubscribeValue *msg_val_params,
- const char *id_repr)
+void WM_msg_subscribe_static_params(struct wmMsgBus *mbus,
+ const wmMsgParams_Static *msg_key_params,
+ const wmMsgSubscribeValue *msg_val_params,
+ const char *id_repr)
{
- wmMsgSubscribeKey_Static msg_key_test = {{NULL}};
+ wmMsgSubscribeKey_Static msg_key_test = {{NULL}};
- /* use when added */
- msg_key_test.msg.head.id = id_repr;
- msg_key_test.msg.head.type = WM_MSG_TYPE_STATIC;
- /* for lookup */
- msg_key_test.msg.params = *msg_key_params;
+ /* use when added */
+ msg_key_test.msg.head.id = id_repr;
+ msg_key_test.msg.head.type = WM_MSG_TYPE_STATIC;
+ /* for lookup */
+ msg_key_test.msg.params = *msg_key_params;
- WM_msg_subscribe_with_key(mbus, &msg_key_test.head, msg_val_params);
+ WM_msg_subscribe_with_key(mbus, &msg_key_test.head, msg_val_params);
}
-void WM_msg_subscribe_static(
- struct wmMsgBus *mbus,
- int event,
- const wmMsgSubscribeValue *msg_val_params,
- const char *id_repr)
+void WM_msg_subscribe_static(struct wmMsgBus *mbus,
+ int event,
+ const wmMsgSubscribeValue *msg_val_params,
+ const char *id_repr)
{
- WM_msg_subscribe_static_params(mbus, &(const wmMsgParams_Static){ .event = event, }, msg_val_params, id_repr);
+ WM_msg_subscribe_static_params(mbus,
+ &(const wmMsgParams_Static){
+ .event = event,
+ },
+ msg_val_params,
+ id_repr);
}
diff --git a/source/blender/windowmanager/message_bus/wm_message_bus.h b/source/blender/windowmanager/message_bus/wm_message_bus.h
index 6d9a31ede6c..4a8bce52992 100644
--- a/source/blender/windowmanager/message_bus/wm_message_bus.h
+++ b/source/blender/windowmanager/message_bus/wm_message_bus.h
@@ -34,85 +34,86 @@ struct wmMsgSubscribeKey;
struct wmMsgSubscribeValue;
struct wmMsgSubscribeValueLink;
-typedef void (*wmMsgNotifyFn)(
- struct bContext *C, struct wmMsgSubscribeKey *msg_key, struct wmMsgSubscribeValue *msg_val);
-typedef void (*wmMsgSubscribeValueFreeDataFn)(
- struct wmMsgSubscribeKey *msg_key, struct wmMsgSubscribeValue *msg_val);
+typedef void (*wmMsgNotifyFn)(struct bContext *C,
+ struct wmMsgSubscribeKey *msg_key,
+ struct wmMsgSubscribeValue *msg_val);
+typedef void (*wmMsgSubscribeValueFreeDataFn)(struct wmMsgSubscribeKey *msg_key,
+ struct wmMsgSubscribeValue *msg_val);
/* Exactly what arguments here is not obvious. */
-typedef void (*wmMsgSubscribeValueUpdateIdFn)(
- struct bContext *C,
- struct wmMsgBus *mbus,
- struct ID *id_src, struct ID *id_dst,
- struct wmMsgSubscribeValue *msg_val);
+typedef void (*wmMsgSubscribeValueUpdateIdFn)(struct bContext *C,
+ struct wmMsgBus *mbus,
+ struct ID *id_src,
+ struct ID *id_dst,
+ struct wmMsgSubscribeValue *msg_val);
enum {
- WM_MSG_TYPE_RNA = 0,
- WM_MSG_TYPE_STATIC = 1,
+ WM_MSG_TYPE_RNA = 0,
+ WM_MSG_TYPE_STATIC = 1,
};
#define WM_MSG_TYPE_NUM 2
typedef struct wmMsgTypeInfo {
- struct {
- unsigned int (*hash_fn)(const void *msg);
- bool (*cmp_fn)(const void *a, const void *b);
- void (*key_free_fn)(void *key);
- } gset;
-
- void (*update_by_id)(struct wmMsgBus *mbus, struct ID *id_src, struct ID *id_dst);
- void (*remove_by_id)(struct wmMsgBus *mbus, const struct ID *id);
- void (*repr)(FILE *stream, const struct wmMsgSubscribeKey *msg_key);
-
- /* sizeof(wmMsgSubscribeKey_*) */
- uint msg_key_size;
+ struct {
+ unsigned int (*hash_fn)(const void *msg);
+ bool (*cmp_fn)(const void *a, const void *b);
+ void (*key_free_fn)(void *key);
+ } gset;
+
+ void (*update_by_id)(struct wmMsgBus *mbus, struct ID *id_src, struct ID *id_dst);
+ void (*remove_by_id)(struct wmMsgBus *mbus, const struct ID *id);
+ void (*repr)(FILE *stream, const struct wmMsgSubscribeKey *msg_key);
+
+ /* sizeof(wmMsgSubscribeKey_*) */
+ uint msg_key_size;
} wmMsgTypeInfo;
typedef struct wmMsg {
- unsigned int type;
-// #ifdef DEBUG
- /* For debugging: '__func__:__LINE__'. */
- const char *id;
-// #endif
+ unsigned int type;
+ // #ifdef DEBUG
+ /* For debugging: '__func__:__LINE__'. */
+ const char *id;
+ // #endif
} wmMsg;
typedef struct wmMsgSubscribeKey {
- /** Linked list for predicable ordering, otherwise we would depend on ghash bucketing. */
- struct wmMsgSubscribeKey *next, *prev;
- ListBase values;
- /* over-alloc, eg: wmMsgSubscribeKey_RNA */
- /* Last member will be 'wmMsg_*' */
+ /** Linked list for predicable ordering, otherwise we would depend on ghash bucketing. */
+ struct wmMsgSubscribeKey *next, *prev;
+ ListBase values;
+ /* over-alloc, eg: wmMsgSubscribeKey_RNA */
+ /* Last member will be 'wmMsg_*' */
} wmMsgSubscribeKey;
/** One of many in #wmMsgSubscribeKey.values */
typedef struct wmMsgSubscribeValue {
- struct wmMsgSubscribe *next, *prev;
-
- /** Handle, used to iterate and clear. */
- void *owner;
- /** User data, can be whatever we like, free using the 'free_data' callback if it's owned. */
- void *user_data;
-
- /** Callbacks */
- wmMsgNotifyFn notify;
- wmMsgSubscribeValueUpdateIdFn update_id;
- wmMsgSubscribeValueFreeDataFn free_data;
-
- /** Keep this subscriber if possible. */
- uint is_persistent : 1;
- /* tag to run when handling events,
- * we may want option for immediate execution. */
- uint tag : 1;
+ struct wmMsgSubscribe *next, *prev;
+
+ /** Handle, used to iterate and clear. */
+ void *owner;
+ /** User data, can be whatever we like, free using the 'free_data' callback if it's owned. */
+ void *user_data;
+
+ /** Callbacks */
+ wmMsgNotifyFn notify;
+ wmMsgSubscribeValueUpdateIdFn update_id;
+ wmMsgSubscribeValueFreeDataFn free_data;
+
+ /** Keep this subscriber if possible. */
+ uint is_persistent : 1;
+ /* tag to run when handling events,
+ * we may want option for immediate execution. */
+ uint tag : 1;
} wmMsgSubscribeValue;
/** One of many in #wmMsgSubscribeKey.values */
typedef struct wmMsgSubscribeValueLink {
- struct wmMsgSubscribeValueLink *next, *prev;
- wmMsgSubscribeValue params;
+ struct wmMsgSubscribeValueLink *next, *prev;
+ wmMsgSubscribeValue params;
} wmMsgSubscribeValueLink;
void WM_msgbus_types_init(void);
struct wmMsgBus *WM_msgbus_create(void);
-void WM_msgbus_destroy(struct wmMsgBus *mbus);
+void WM_msgbus_destroy(struct wmMsgBus *mbus);
void WM_msgbus_clear_by_owner(struct wmMsgBus *mbus, void *owner);
@@ -120,167 +121,170 @@ void WM_msg_dump(struct wmMsgBus *mbus, const char *info);
void WM_msgbus_handle(struct wmMsgBus *mbus, struct bContext *C);
void WM_msg_publish_with_key(struct wmMsgBus *mbus, wmMsgSubscribeKey *msg_key);
-wmMsgSubscribeKey *WM_msg_subscribe_with_key(
- struct wmMsgBus *mbus,
- const wmMsgSubscribeKey *msg_key_test,
- const wmMsgSubscribeValue *msg_val_params);
-
-void WM_msg_id_update(
- struct wmMsgBus *mbus,
- struct ID *id_src, struct ID *id_dst);
+wmMsgSubscribeKey *WM_msg_subscribe_with_key(struct wmMsgBus *mbus,
+ const wmMsgSubscribeKey *msg_key_test,
+ const wmMsgSubscribeValue *msg_val_params);
+
+void WM_msg_id_update(struct wmMsgBus *mbus, struct ID *id_src, struct ID *id_dst);
void WM_msg_id_remove(struct wmMsgBus *mbus, const struct ID *id);
/* -------------------------------------------------------------------------- */
/* wm_message_bus_static.c */
enum {
- /* generic window redraw */
- WM_MSG_STATICTYPE_WINDOW_DRAW = 0,
- WM_MSG_STATICTYPE_SCREEN_EDIT = 1,
- WM_MSG_STATICTYPE_FILE_READ = 2,
+ /* generic window redraw */
+ WM_MSG_STATICTYPE_WINDOW_DRAW = 0,
+ WM_MSG_STATICTYPE_SCREEN_EDIT = 1,
+ WM_MSG_STATICTYPE_FILE_READ = 2,
};
typedef struct wmMsgParams_Static {
- int event;
+ int event;
} wmMsgParams_Static;
typedef struct wmMsg_Static {
- wmMsg head; /* keep first */
- wmMsgParams_Static params;
+ wmMsg head; /* keep first */
+ wmMsgParams_Static params;
} wmMsg_Static;
typedef struct wmMsgSubscribeKey_Static {
- wmMsgSubscribeKey head;
- wmMsg_Static msg;
+ wmMsgSubscribeKey head;
+ wmMsg_Static msg;
} wmMsgSubscribeKey_Static;
void WM_msgtypeinfo_init_static(wmMsgTypeInfo *msg_type);
-wmMsgSubscribeKey_Static *WM_msg_lookup_static(
- struct wmMsgBus *mbus, const wmMsgParams_Static *msg_key_params);
-void WM_msg_publish_static_params(
- struct wmMsgBus *mbus,
- const wmMsgParams_Static *msg_key_params);
-void WM_msg_publish_static(
- struct wmMsgBus *mbus,
- /* wmMsgParams_Static (expanded) */
- int event);
-void WM_msg_subscribe_static_params(
- struct wmMsgBus *mbus,
- const wmMsgParams_Static *msg_key_params,
- const wmMsgSubscribeValue *msg_val_params,
- const char *id_repr);
-void WM_msg_subscribe_static(
- struct wmMsgBus *mbus,
- int event,
- const wmMsgSubscribeValue *msg_val_params,
- const char *id_repr);
+wmMsgSubscribeKey_Static *WM_msg_lookup_static(struct wmMsgBus *mbus,
+ const wmMsgParams_Static *msg_key_params);
+void WM_msg_publish_static_params(struct wmMsgBus *mbus, const wmMsgParams_Static *msg_key_params);
+void WM_msg_publish_static(struct wmMsgBus *mbus,
+ /* wmMsgParams_Static (expanded) */
+ int event);
+void WM_msg_subscribe_static_params(struct wmMsgBus *mbus,
+ const wmMsgParams_Static *msg_key_params,
+ const wmMsgSubscribeValue *msg_val_params,
+ const char *id_repr);
+void WM_msg_subscribe_static(struct wmMsgBus *mbus,
+ int event,
+ const wmMsgSubscribeValue *msg_val_params,
+ const char *id_repr);
/* -------------------------------------------------------------------------- */
/* wm_message_bus_rna.c */
typedef struct wmMsgParams_RNA {
- /** when #PointerRNA.data & id.data are NULL. match against all. */
- PointerRNA ptr;
- /** when NULL, match against any property. */
- const PropertyRNA *prop;
-
- /**
- * Optional RNA data path for persistent RNA properties, ignore if NULL.
- * otherwise it's allocated.
- */
- char *data_path;
+ /** when #PointerRNA.data & id.data are NULL. match against all. */
+ PointerRNA ptr;
+ /** when NULL, match against any property. */
+ const PropertyRNA *prop;
+
+ /**
+ * Optional RNA data path for persistent RNA properties, ignore if NULL.
+ * otherwise it's allocated.
+ */
+ char *data_path;
} wmMsgParams_RNA;
typedef struct wmMsg_RNA {
- wmMsg head; /* keep first */
- wmMsgParams_RNA params;
+ wmMsg head; /* keep first */
+ wmMsgParams_RNA params;
} wmMsg_RNA;
typedef struct wmMsgSubscribeKey_RNA {
- wmMsgSubscribeKey head;
- wmMsg_RNA msg;
+ wmMsgSubscribeKey head;
+ wmMsg_RNA msg;
} wmMsgSubscribeKey_RNA;
#ifdef __GNUC__
-#define _WM_MESSAGE_EXTERN_BEGIN \
- _Pragma("GCC diagnostic push"); \
- _Pragma("GCC diagnostic ignored \"-Wredundant-decls\"");
-#define _WM_MESSAGE_EXTERN_END \
- _Pragma("GCC diagnostic pop");
+# define _WM_MESSAGE_EXTERN_BEGIN \
+ _Pragma("GCC diagnostic push"); \
+ _Pragma("GCC diagnostic ignored \"-Wredundant-decls\"");
+# define _WM_MESSAGE_EXTERN_END _Pragma("GCC diagnostic pop");
#else
-#define _WM_MESSAGE_EXTERN_BEGIN
-#define _WM_MESSAGE_EXTERN_END
+# define _WM_MESSAGE_EXTERN_BEGIN
+# define _WM_MESSAGE_EXTERN_END
#endif
void WM_msgtypeinfo_init_rna(wmMsgTypeInfo *msg_type);
-wmMsgSubscribeKey_RNA *WM_msg_lookup_rna(
- struct wmMsgBus *mbus, const wmMsgParams_RNA *msg_key_params);
-void WM_msg_publish_rna_params(
- struct wmMsgBus *mbus, const wmMsgParams_RNA *msg_key_params);
-void WM_msg_publish_rna(
- struct wmMsgBus *mbus,
- /* wmMsgParams_RNA (expanded) */
- PointerRNA *ptr, PropertyRNA *prop);
-void WM_msg_subscribe_rna_params(
- struct wmMsgBus *mbus,
- const wmMsgParams_RNA *msg_key_params,
- const wmMsgSubscribeValue *msg_val_params,
- const char *id_repr);
-void WM_msg_subscribe_rna(
- struct wmMsgBus *mbus,
- PointerRNA *ptr, const PropertyRNA *prop,
- const wmMsgSubscribeValue *msg_val_params,
- const char *id_repr);
+wmMsgSubscribeKey_RNA *WM_msg_lookup_rna(struct wmMsgBus *mbus,
+ const wmMsgParams_RNA *msg_key_params);
+void WM_msg_publish_rna_params(struct wmMsgBus *mbus, const wmMsgParams_RNA *msg_key_params);
+void WM_msg_publish_rna(struct wmMsgBus *mbus,
+ /* wmMsgParams_RNA (expanded) */
+ PointerRNA *ptr,
+ PropertyRNA *prop);
+void WM_msg_subscribe_rna_params(struct wmMsgBus *mbus,
+ const wmMsgParams_RNA *msg_key_params,
+ const wmMsgSubscribeValue *msg_val_params,
+ const char *id_repr);
+void WM_msg_subscribe_rna(struct wmMsgBus *mbus,
+ PointerRNA *ptr,
+ const PropertyRNA *prop,
+ const wmMsgSubscribeValue *msg_val_params,
+ const char *id_repr);
/* ID variants */
-void WM_msg_subscribe_ID(
- struct wmMsgBus *mbus, struct ID *id, const wmMsgSubscribeValue *msg_val_params,
- const char *id_repr);
-void WM_msg_publish_ID(
- struct wmMsgBus *mbus, struct ID *id);
-
-#define WM_msg_publish_rna_prop(mbus, id_, data_, type_, prop_) { \
- wmMsgParams_RNA msg_key_params_ = {{{0}}}; \
- _WM_MESSAGE_EXTERN_BEGIN; \
- extern PropertyRNA rna_##type_##_##prop_; \
- _WM_MESSAGE_EXTERN_END; \
- RNA_pointer_create(id_, &RNA_##type_, data_, &msg_key_params_.ptr); \
- msg_key_params_.prop = &rna_##type_##_##prop_; \
- WM_msg_publish_rna_params(mbus, &msg_key_params_); \
-} ((void)0)
-#define WM_msg_subscribe_rna_prop(mbus, id_, data_, type_, prop_, value) { \
- wmMsgParams_RNA msg_key_params_ = {{{0}}}; \
- _WM_MESSAGE_EXTERN_BEGIN; \
- extern PropertyRNA rna_##type_##_##prop_; \
- _WM_MESSAGE_EXTERN_END; \
- RNA_pointer_create(id_, &RNA_##type_, data_, &msg_key_params_.ptr); \
- msg_key_params_.prop = &rna_##type_##_##prop_; \
- WM_msg_subscribe_rna_params(mbus, &msg_key_params_, value, __func__); \
-} ((void)0)
+void WM_msg_subscribe_ID(struct wmMsgBus *mbus,
+ struct ID *id,
+ const wmMsgSubscribeValue *msg_val_params,
+ const char *id_repr);
+void WM_msg_publish_ID(struct wmMsgBus *mbus, struct ID *id);
+
+#define WM_msg_publish_rna_prop(mbus, id_, data_, type_, prop_) \
+ { \
+ wmMsgParams_RNA msg_key_params_ = {{{0}}}; \
+ _WM_MESSAGE_EXTERN_BEGIN; \
+ extern PropertyRNA rna_##type_##_##prop_; \
+ _WM_MESSAGE_EXTERN_END; \
+ RNA_pointer_create(id_, &RNA_##type_, data_, &msg_key_params_.ptr); \
+ msg_key_params_.prop = &rna_##type_##_##prop_; \
+ WM_msg_publish_rna_params(mbus, &msg_key_params_); \
+ } \
+ ((void)0)
+#define WM_msg_subscribe_rna_prop(mbus, id_, data_, type_, prop_, value) \
+ { \
+ wmMsgParams_RNA msg_key_params_ = {{{0}}}; \
+ _WM_MESSAGE_EXTERN_BEGIN; \
+ extern PropertyRNA rna_##type_##_##prop_; \
+ _WM_MESSAGE_EXTERN_END; \
+ RNA_pointer_create(id_, &RNA_##type_, data_, &msg_key_params_.ptr); \
+ msg_key_params_.prop = &rna_##type_##_##prop_; \
+ WM_msg_subscribe_rna_params(mbus, &msg_key_params_, value, __func__); \
+ } \
+ ((void)0)
/* Anonymous variants (for convenience) */
-#define WM_msg_subscribe_rna_anon_type(mbus, type_, value) { \
- WM_msg_subscribe_rna_params( \
- mbus, \
- &(const wmMsgParams_RNA){ \
- .ptr = (PointerRNA){ .type = &RNA_##type_, }, \
- .prop = NULL, \
- }, \
- value, __func__); \
-} ((void)0)
-#define WM_msg_subscribe_rna_anon_prop(mbus, type_, prop_, value) { \
- _WM_MESSAGE_EXTERN_BEGIN; \
- extern PropertyRNA rna_##type_##_##prop_; \
- _WM_MESSAGE_EXTERN_END; \
- WM_msg_subscribe_rna_params( \
- mbus, \
- &(const wmMsgParams_RNA){ \
- .ptr = (PointerRNA){ .type = &RNA_##type_, }, \
- .prop = &rna_##type_##_##prop_, \
- }, \
- value, __func__); \
-} ((void)0)
+#define WM_msg_subscribe_rna_anon_type(mbus, type_, value) \
+ { \
+ WM_msg_subscribe_rna_params(mbus, \
+ &(const wmMsgParams_RNA){ \
+ .ptr = \
+ (PointerRNA){ \
+ .type = &RNA_##type_, \
+ }, \
+ .prop = NULL, \
+ }, \
+ value, \
+ __func__); \
+ } \
+ ((void)0)
+#define WM_msg_subscribe_rna_anon_prop(mbus, type_, prop_, value) \
+ { \
+ _WM_MESSAGE_EXTERN_BEGIN; \
+ extern PropertyRNA rna_##type_##_##prop_; \
+ _WM_MESSAGE_EXTERN_END; \
+ WM_msg_subscribe_rna_params(mbus, \
+ &(const wmMsgParams_RNA){ \
+ .ptr = \
+ (PointerRNA){ \
+ .type = &RNA_##type_, \
+ }, \
+ .prop = &rna_##type_##_##prop_, \
+ }, \
+ value, \
+ __func__); \
+ } \
+ ((void)0)
#endif /* __WM_MESSAGE_BUS_H__ */