objects

objects in c
git clone https://noulin.net/git/objects.git
Log | Files | Refs | README | LICENSE

commit 074b8f7887361e447930a256bc2455944bea79b9
parent 75142e61fd6ce705ce2453657fb436854494c46c
Author: Remy Noulin (Spartatek) <remy.noulin@spartatek.se>
Date:   Tue, 21 Feb 2017 13:58:41 +0100

indentation

main.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)

Diffstat:
Mmain.c | 14++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/main.c b/main.c @@ -5,25 +5,31 @@ void print(char *s) { printf(s); } +// Class: class typedef struct class classt; +// Members typedef void (*printt)(char *string); typedef void (*terminateClasstt)(classt **self); -struct class { int a; printt print; terminateClasstt terminate;}; - +struct class { + int a; + printt print; + terminateClasstt terminate; +}; +// Initiate/Terminate Objects #define createclasst(obj) classt obj; initiateclasst(&obj) #define createAllocateclasst(obj) classt *obj; initiateAllocateclasst(&obj) void initiateclasst(classt *self); void terminateclasst(classt **self); void initiateAllocateclasst(classt **self) { - + (*self) = malloc(sizeof(classt)); initiateclasst(*self); } void initiateclasst(classt *self) { - + self->terminate = terminateclasst; self->a = 0; self->print = print;