BFObject.h 1012 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #ifndef BF_OBJECT_H_INCLUDED
  2. #define BF_OBJECT_H_INCLUDED
  3. typedef void * BFID;
  4. #define BF_JOIN_AID(A, B) A##B
  5. #define BF_JOIN(A, B) BF_JOIN_AID(A, B)
  6. #define BF_JOIN3(A, B, C) BF_JOIN(BF_JOIN(A, B), C)
  7. #define BF_JOIN4(A, B, C, D) BF_JOIN(BF_JOIN3(A, B, C), D)
  8. #define bf_message(RESULT, NAME, ...) \
  9. extern int BF_JOIN(bf_message_, NAME); \
  10. extern RESULT BF_JOIN(bf_method_, NAME) (BFID self, __VA_ARGS__)
  11. #define bf_method(RESULT, SELFTYPE, NAME, ...) \
  12. int BF_JOIN4(bf_message_, SELFTYPE, _, NAME); \
  13. RESULT BF_JOIN(bf_method_, NAME) (BFID selfid, __VA_ARGS__) { \
  14. SELFTYPE * self = (SELFTYPE *) selfid;
  15. #define bf_endmethod }
  16. typedef struct Ohohoho_ {
  17. int frotz;
  18. } Ohoho;
  19. bf_message(BFID, frotz_, int value);
  20. bf_method(BFID, Ohoho, frotz_, int value)
  21. self->frotz = value;
  22. return self;
  23. bf_endmethod
  24. #endif