--- a/ui/common/object.c Sun Nov 23 10:49:24 2025 +0100 +++ b/ui/common/object.c Sun Nov 23 11:16:13 2025 +0100 @@ -32,6 +32,7 @@ #include "context.h" #include <cx/linked_list.h> +#include <cx/hash_map.h> #include "../ui/container.h" @@ -108,7 +109,7 @@ UiObject* uic_object_new_toplevel(void) { fflush(stdout); CxMempool *mp = cxMempoolCreateSimple(256); - UiObject *obj = cxCalloc(mp->allocator, 1, sizeof(UiObject)); + UiObject *obj = cxCalloc(mp->allocator, 1, sizeof(UiObjectPrivate)); fflush(stdout); obj->ctx = uic_context(obj, mp); obj->ctx->parent = ui_global_context(); @@ -119,7 +120,7 @@ } UiObject* uic_ctx_object_new(UiContext *ctx, UIWIDGET widget) { - UiObject *newobj = cxCalloc(ctx->allocator, 1, sizeof(UiObject)); + UiObject *newobj = cxCalloc(ctx->allocator, 1, sizeof(UiObjectPrivate)); newobj->ctx = ctx; newobj->widget = widget; uic_object_created(newobj); @@ -170,3 +171,24 @@ fprintf(stderr, "Error: uic_object_remove_second_last_container expected at least 2 containers\n"); } } + +// public API + +void ui_object_set(UiObject *obj, const char *key, void *data) { + UiObjectPrivate *p = (UiObjectPrivate*)obj; + if(!p->ext) { + p->ext = cxHashMapCreate(obj->ctx->mp->allocator, CX_STORE_POINTERS, 4); + } + if(data) { + cxMapPut(p->ext, key, data); + } else { + cxMapRemove(p->ext, key); + } +} + +void* ui_object_get(UiObject *obj, const char *key) { + UiObjectPrivate *p = (UiObjectPrivate*)obj; + if(p->ext) { + return cxMapGet(p->ext, key); + } +}