From d3c9975943df58e293359b87905d19ff1fd52061 Mon Sep 17 00:00:00 2001 From: Daniel Lange Date: Mon, 11 Apr 2016 13:00:15 +0200 Subject: Imported Upstream version 0.5 --- Object.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Object.c (limited to 'Object.c') diff --git a/Object.c b/Object.c new file mode 100644 index 0000000..3a8c628 --- /dev/null +++ b/Object.c @@ -0,0 +1,60 @@ +/* +htop +(C) 2004 Hisham H. Muhammad +Released under the GNU GPL, see the COPYING file +in the source distribution for its full text. +*/ + +#include "Object.h" +#include "RichString.h" +#include "CRT.h" +#include +#include +#include + +#include "debug.h" + +/*{ +typedef struct Object_ Object; + +typedef void(*Method_Object_display)(Object*, RichString*); +typedef bool(*Method_Object_equals)(const Object*, const Object*); +typedef void(*Method_Object_delete)(Object*); + +struct Object_ { + char* class; + Method_Object_display display; + Method_Object_equals equals; + Method_Object_delete delete; +}; +}*/ + +/* private property */ +char* OBJECT_CLASS = "Object"; + +void Object_new() { + Object* this; + this = malloc(sizeof(Object)); + this->class = OBJECT_CLASS; + this->display = Object_display; + this->equals = Object_equals; + this->delete = Object_delete; +} + +bool Object_instanceOf(Object* this, char* class) { + return this->class == class; +} + +void Object_delete(Object* this) { + free(this); +} + +void Object_display(Object* this, RichString* out) { + char objAddress[50]; + sprintf(objAddress, "%s @ %p", this->class, (void*) this); + RichString_write(out, CRT_colors[DEFAULT_COLOR], objAddress); +} + +bool Object_equals(const Object* this, const Object* o) { + return (this == o); +} -- cgit v1.2.3