aboutsummaryrefslogtreecommitdiffstats
path: root/Object.c
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2016-04-11 13:00:15 +0200
committerDaniel Lange <DLange@git.local>2016-04-11 13:00:15 +0200
commitd3c9975943df58e293359b87905d19ff1fd52061 (patch)
treee416378879f60e8d538b1b25963904f767d30ff4 /Object.c
downloaddebian_htop-d3c9975943df58e293359b87905d19ff1fd52061.tar.gz
debian_htop-d3c9975943df58e293359b87905d19ff1fd52061.tar.bz2
debian_htop-d3c9975943df58e293359b87905d19ff1fd52061.zip
Imported Upstream version 0.5upstream/0.5
Diffstat (limited to 'Object.c')
-rw-r--r--Object.c60
1 files changed, 60 insertions, 0 deletions
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 <stdlib.h>
+#include <stdio.h>
+#include <stdbool.h>
+
+#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);
+}

© 2014-2024 Faster IT GmbH | imprint | privacy policy