Changes in object model: separate class objects to store vtable. Also, nicer UTF-8 display of big numbers.

This commit is contained in:
Hisham Muhammad
2012-12-05 15:12:20 +00:00
parent 2a73405cd0
commit 00b324bfc1
64 changed files with 662 additions and 566 deletions

View File

@ -24,12 +24,6 @@ typedef struct CheckItem_ {
}*/
#ifdef DEBUG
char* CHECKITEM_CLASS = "CheckItem";
#else
#define CHECKITEM_CLASS NULL
#endif
static void CheckItem_delete(Object* cast) {
CheckItem* this = (CheckItem*)cast;
assert (this != NULL);
@ -50,11 +44,13 @@ static void CheckItem_display(Object* cast, RichString* out) {
RichString_append(out, CRT_colors[CHECK_TEXT], this->text);
}
ObjectClass CheckItem_class = {
.display = CheckItem_display,
.delete = CheckItem_delete
};
CheckItem* CheckItem_new(char* text, bool* ref, bool value) {
CheckItem* this = malloc(sizeof(CheckItem));
Object_setClass(this, CHECKITEM_CLASS);
((Object*)this)->display = CheckItem_display;
((Object*)this)->delete = CheckItem_delete;
CheckItem* this = AllocThis(CheckItem);
this->text = text;
this->value = value;
this->ref = ref;