summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/cobj.h7
-rw-r--r--src/teams.c6
-rw-r--r--src/teams.h2
3 files changed, 11 insertions, 4 deletions
diff --git a/src/cobj.h b/src/cobj.h
index f8a4fec..196649c 100644
--- a/src/cobj.h
+++ b/src/cobj.h
@@ -10,6 +10,7 @@
#endif /* __COBJ_IMPLS_H__ */
#if defined(__USE_C_OBJSYS__)
+# undef CLASS
# undef GETTER
# undef SETTER
# undef DEFINE
@@ -18,6 +19,10 @@
# undef __USE_C_OBJSYS__
#elif defined(__COBJ_PRIV_IMPLS_H__)
# define UNUSED(arg) while(0 && (arg))
+# define CLASS(klass, data) \
+ typedef struct klass##_impl_struct data __ ## klass ## _impl
+# define TYPE(klass) \
+ __ ## klass ## _impl
# define GETTER(klass, field, type, body, ...) \
type klass##_get_##field(klass self, ## __VA_ARGS__) \
body
@@ -34,6 +39,8 @@
void klass ## _del(klass self, ## __VA_ARGS__) \
body
#else
+# define CLASS(klass) \
+ typedef struct klass ## _impl_struct * klass
# define GETTER(klass, field, type, ...) \
type klass##_get_##field(klass self, ## __VA_ARGS__)
# define SETTER(klass, field, type, ...) \
diff --git a/src/teams.c b/src/teams.c
index a3bf0a2..259c81c 100644
--- a/src/teams.c
+++ b/src/teams.c
@@ -6,16 +6,16 @@
#define __COBJ_PRIV_IMPLS_H__
#include "cobj.h"
-typedef struct team_impl_struct {
+CLASS(team, {
char name[255];
char members[3][255];
char institution[255];
uint8_t solved;
-} TEAM_impl;
+});
// base functions
NEW(team, {
- return (ptr(TEAM_impl))malloc(sizeof(TEAM_impl));
+ return (team)malloc(sizeof(TYPE(team)));
})
DEL(team, {
diff --git a/src/teams.h b/src/teams.h
index 2fc1be3..15aad82 100644
--- a/src/teams.h
+++ b/src/teams.h
@@ -6,7 +6,7 @@
# include "common.h"
// Type definition
-typedef struct team_impl_struct * team;
+CLASS(team);
// base functions
NEW(team);