summaryrefslogtreecommitdiff
path: root/src/cobj.h
diff options
context:
space:
mode:
authorLibravatar Mubashshir <ahmubashshir@gmail.com>2024-06-05 17:23:45 +0600
committerLibravatar Mubashshir <ahmubashshir@gmail.com>2024-06-05 17:23:45 +0600
commit815eca3e8f367a6fed50be59b10316b5028773aa (patch)
treeda6db4241b77bb54f51a4dfdecb7ab6cece20914 /src/cobj.h
parent83cf6de508664535c77e4d6aa8f0695a3fa7cdf2 (diff)
downloadc-obp-example-815eca3e8f367a6fed50be59b10316b5028773aa.tar.gz
c-obp-example-815eca3e8f367a6fed50be59b10316b5028773aa.zip
Add class declaration helper
Signed-off-by: Mubashshir <ahmubashshir@gmail.com>
Diffstat (limited to '')
-rw-r--r--src/cobj.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/cobj.h b/src/cobj.h
index 196649c..fd28746 100644
--- a/src/cobj.h
+++ b/src/cobj.h
@@ -38,6 +38,22 @@
# define DEL(klass, body, ...) \
void klass ## _del(klass self, ## __VA_ARGS__) \
body
+# define NCLASS(klass, data) \
+ typedef struct __##klass##_impl * klass; \
+ struct __##klass##_impl data
+
+# define LIST(klass, field, type, dim, ...) \
+ type _property_ ## field dim; \
+ type* (*get_ ## field)(klass, ## __VA_ARGS__); \
+ bool (*set_ ## field)(klass, ## __VA_ARGS__, type *)
+
+# define ATOM(klass, field, type, ...) \
+ type _property_ ## field; \
+ type (*get_ ## field)(klass, ## __VA_ARGS__);\
+ bool (*set_ ## field)(klass, ## __VA_ARGS__, type)
+
+# define DEFN(klass, name, type, ...) \
+ type (*name)(klass, ## __VA_ARGS__)
#else
# define CLASS(klass) \
typedef struct klass ## _impl_struct * klass