36 #include <cx/mempool.h> |
36 #include <cx/mempool.h> |
37 |
37 |
38 static CxMap *documents; |
38 static CxMap *documents; |
39 |
39 |
40 void uic_docmgr_init() { |
40 void uic_docmgr_init() { |
41 documents = cxHashMapCreate(cxDefaultAllocator, CX_STORE_POINTERS, 32); |
41 if (!documents) { |
|
42 documents = cxHashMapCreate(cxDefaultAllocator, CX_STORE_POINTERS, 32); |
|
43 } |
42 } |
44 } |
43 |
45 |
44 void ui_set_document(UiObject *obj, void *document) { |
46 void ui_set_document(UiObject *obj, void *document) { |
45 uic_context_detach_all(obj->ctx); |
47 uic_context_detach_all(obj->ctx); |
46 obj->ctx->attach_document(obj->ctx, document); |
48 obj->ctx->attach_document(obj->ctx, document); |
78 // TODO |
80 // TODO |
79 return NULL; |
81 return NULL; |
80 } |
82 } |
81 |
83 |
82 void* ui_document_new(size_t size) { |
84 void* ui_document_new(size_t size) { |
83 CxMempool *mp = cxBasicMempoolCreate(256); |
85 CxMempool *mp = cxMempoolCreate(256, NULL); |
84 const CxAllocator *a = mp->allocator; |
86 const CxAllocator *a = mp->allocator; |
85 UiContext *ctx = cxCalloc(a, 1, sizeof(UiContext)); |
87 UiContext *ctx = cxCalloc(a, 1, sizeof(UiContext)); |
86 ctx->attach_document = uic_context_attach_document; |
88 ctx->attach_document = uic_context_attach_document; |
87 ctx->detach_document2 = uic_context_detach_document2; |
89 ctx->detach_document2 = uic_context_detach_document2; |
88 ctx->allocator = a; |
90 ctx->allocator = a; |