From 9b200f1e9808ecd14f6f5375346be0580e182aaf Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Sun, 8 Jun 2025 23:07:23 +0800 Subject: [PATCH 08/12] scriptable: revert 5ef32df Reverts https://github.com/DeaDBeeF-Player/deadbeef/commit/5ef32dfcad5d984f6d3c393404ad90c690d9a484 --- shared/scriptable/scriptable.c | 15 +++------------ shared/scriptable/scriptable.h | 10 ++++++++-- src/scriptable/scriptable_dsp.c | 13 ++++++------- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/shared/scriptable/scriptable.c b/shared/scriptable/scriptable.c index cd96b4015..9517a741f 100644 --- a/shared/scriptable/scriptable.c +++ b/shared/scriptable/scriptable.c @@ -5,12 +5,6 @@ #include "scriptable.h" #include -typedef struct scriptableKeyValue_s { - struct scriptableKeyValue_s *next; - char *key; - char *value; -} scriptableKeyValue_t; - struct scriptableItem_s { struct scriptableItem_s *next; uint64_t flags; @@ -215,12 +209,9 @@ return item->parent; } -void scriptableItemPropertiesForEach(scriptableItem_t *item, int(^block)(const char *key, const char *value)) { - for (scriptableKeyValue_t *kv = item->properties; kv != NULL; kv = kv->next) { - if (!block(kv->key, kv->value)) { - break; - } - } +scriptableKeyValue_t * +scriptableItemProperties(scriptableItem_t *item) { + return item->properties; } uint64_t scriptableItemFlags(scriptableItem_t *item) { diff --git a/shared/scriptable/scriptable.h b/shared/scriptable/scriptable.h index 6696da823..d150960f9 100644 --- a/shared/scriptable/scriptable.h +++ b/shared/scriptable/scriptable.h @@ -17,6 +17,12 @@ extern "C" { #endif +typedef struct scriptableKeyValue_s { + struct scriptableKeyValue_s *next; + char *key; + char *value; +} scriptableKeyValue_t; + // TODO: this seems to be only used by factories, // could be refactored to return string arrays. typedef struct stringListItem_s { @@ -151,8 +157,8 @@ scriptableItem_t * scriptableItemParent (scriptableItem_t *item); -void -scriptableItemPropertiesForEach (scriptableItem_t *item, int (^block) (const char *key, const char *value)); +scriptableKeyValue_t * +scriptableItemProperties (scriptableItem_t *item); const char * scriptableItemConfigDialog (scriptableItem_t *item); diff --git a/src/scriptable/scriptable_dsp.c b/src/scriptable/scriptable_dsp.c index b3b01d6d9..019677ba7 100644 --- a/shared/scriptable/scriptable_dsp.c +++ b/shared/scriptable/scriptable_dsp.c @@ -285,21 +285,21 @@ return NULL; } - __block growableBuffer_t buffer; + growableBuffer_t buffer; growableBufferInitWithSize(&buffer, 1000); DB_dsp_t *dsp = dspPluginForId(pluginId); if (!dsp) { // when a plugin is missing: write out all numeric-name properties, in their original order - scriptableItemPropertiesForEach(node, ^int(const char *key, const char *value) { - int intKey = atoi (key); + for (scriptableKeyValue_t *kv = scriptableItemProperties(node); kv; kv = kv->next) { + int intKey = atoi (kv->key); char stringKey[10]; snprintf (stringKey, sizeof (stringKey), "%d", intKey); - if (!strcmp (stringKey, key)) { - growableBufferPrintf(&buffer, "\t%s\n", value); + if (!strcmp (stringKey, kv->key)) { + growableBufferPrintf(&buffer, "\t%s\n", kv->value); } return 1; - }); + } } else { // when a plugin is present, create a context, and get the values from plugin