From 815eca3e8f367a6fed50be59b10316b5028773aa Mon Sep 17 00:00:00 2001 From: Mubashshir Date: Wed, 5 Jun 2024 17:23:45 +0600 Subject: Add class declaration helper Signed-off-by: Mubashshir --- src/cobj.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/cobj.h') 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 -- cgit v1.2.3