diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2012-12-05 15:12:20 +0000 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2012-12-05 15:12:20 +0000 |
commit | 00b324bfc162030b575e03795dcfcaac56bd0b4d (patch) | |
tree | fbaada243839b0b67351856e2d02a2e8184bf65f /ListItem.c | |
parent | 2a73405cd060b543d56987650327b18078a137d7 (diff) |
Changes in object model: separate class objects to store vtable. Also, nicer UTF-8 display of big numbers.
Diffstat (limited to 'ListItem.c')
-rw-r--r-- | ListItem.c | 16 |
1 files changed, 6 insertions, 10 deletions
@@ -26,12 +26,6 @@ typedef struct ListItem_ { }*/ -#ifdef DEBUG -char* LISTITEM_CLASS = "ListItem"; -#else -#define LISTITEM_CLASS NULL -#endif - static void ListItem_delete(Object* cast) { ListItem* this = (ListItem*)cast; free(this->value); @@ -49,11 +43,13 @@ static void ListItem_display(Object* cast, RichString* out) { RichString_write(out, CRT_colors[DEFAULT_COLOR], this->value/*buffer*/); } +ObjectClass ListItem_class = { + .display = ListItem_display, + .delete = ListItem_delete +}; + ListItem* ListItem_new(const char* value, int key) { - ListItem* this = malloc(sizeof(ListItem)); - Object_setClass(this, LISTITEM_CLASS); - ((Object*)this)->display = ListItem_display; - ((Object*)this)->delete = ListItem_delete; + ListItem* this = AllocThis(ListItem); this->value = strdup(value); this->key = key; return this; |