/* Macros for object-oriented programming in C. * Author: Mark A. Sheldon * Copyright March 2008 * * To do: * o Can use SEND macro on class object for * class methods. It doesn't hurt to send them a this. Counld trea * NEW this way, too. * o Make macros for declaring/defining class and instance methods? */ #define NEW(class, ...) (class)->ops->new(__VA_ARGS__) /* The following uses a GNU extension to the ANSI standard: ## will, * in the GNU extension eat the preceeding comma if no arguments are * provided after the message and will leave it if there are some. */ #define SEND(recipient, message, ...) \ (recipient)->ops->message((recipient), ##__VA_ARGS__) #define PRIVATE static #define PUBLIC #define BOOL int typedef struct object_s { struct object_s *class; } *Object;