summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Mubashshir <ahmubashshir@gmail.com>2025-05-22 23:07:54 +0600
committerLibravatar Mubashshir <ahmubashshir@gmail.com>2025-05-22 23:41:24 +0600
commit7475b4879cdc270c1d7723686ae7e9ad3c0e0736 (patch)
tree33e8c410ac086aeaac7fd00a0b32b23ae6e287a8
parent29b8e5efb43bdb71737f1b417fedb3b1558bb9af (diff)
downloadc-obp-example-master.tar.gz
c-obp-example-master.zip
Auto Add Deleter to classHEADmaster
Signed-off-by: Mubashshir <ahmubashshir@gmail.com>
-rw-r--r--src/cobj.h9
-rw-r--r--src/teams.c5
2 files changed, 6 insertions, 8 deletions
diff --git a/src/cobj.h b/src/cobj.h
index 1e5c75e..328a6aa 100644
--- a/src/cobj.h
+++ b/src/cobj.h
@@ -6,7 +6,6 @@
# undef DefaultDelete
# undef Define
# undef Del
-# undef DelF
# undef Func
# undef GET
# undef Get
@@ -71,10 +70,12 @@
# define New(klass, body, ...) \
klass klass ## _new(__VA_ARGS__) { \
klass self = (klass)malloc(sizeof(TYPE(klass))); \
- if(self != NULL) body; \
+ if(self != NULL) { \
+ self->destroy = (& klass ## _delete); \
+ body; \
+ } \
return self; \
}
-
# define Del(klass, body, ...) \
void klass ## _delete(klass self, ## __VA_ARGS__) \
body
@@ -85,8 +86,6 @@
# define Func(klass, name) \
(self->name) = (& klass ## _ ## name)
-# define DelF(klass) \
- (self->destroy) = (&klass ## _delete)
# define Self(name) \
self->_property_ ## name
diff --git a/src/teams.c b/src/teams.c
index b0233f5..c3f7858 100644
--- a/src/teams.c
+++ b/src/teams.c
@@ -81,9 +81,9 @@ Def(team, find_champion, team, {
return champion;
}, ptr(team) teams, size_t num)
-Del(team, DefaultDelete)
-// base functions
+// Class Body
+Del(team, DefaultDelete)
New(team, {
Prop(team, name);
Prop(team, member_name);
@@ -92,5 +92,4 @@ New(team, {
Func(team, printf);
Func(team, fprintf);
Func(team, find_champion);
- DelF(team);
})