extern "C" {
#endif
+#define ARRAY_SIZE(A) (sizeof(A)/sizeof(A[0]))
+
typedef enum { PEN_NONE, PEN_DASHED, PEN_DOTTED, PEN_SOLID } pen_type;
typedef enum { FILL_NONE, FILL_SOLID } fill_type;
typedef enum { FONT_REGULAR, FONT_BOLD, FONT_ITALIC } font_type;
void (*errorfn) (char *fmt, ...);
/* plugins */
- gv_plugin_t *apis[NUM_APIS]; /* array of linked lists of plugins for each api */
- gv_plugin_t *api[NUM_APIS]; /* array of current plugins for each api */
+#define ELEM(x) +1
+ /* APIS expands to "+1 +1 ... +1" to give the number of APIs */
+ gv_plugin_t *apis[ APIS ]; /* array of linked-list of plugins per api */
+ gv_plugin_t *api[ APIS ]; /* array of current plugins per api */
+#undef ELEM
void *display; /* window display data for gvdisplay plugin */
gvdisplay_engine_t *display_engine; /* current display engine */
* Define an apis array of name strings using an enumerated api_t as index.
* The enumerated type is defined gvplugin.h. The apis array is
* inititialized here by redefining ELEM and reinvoking APIS.
- *
- * The NUM_APIS is the size of the array.
*/
#define ELEM(x) #x,
static char *apis[] = { APIS }; /* "render", "layout", ... */
{
int api;
- for (api = 0; api < NUM_APIS; api++) {
+ for (api = 0; api < ARRAY_SIZE(apis); api++) {
if (strcmp(str, apis[api]) == 0)
return api;
}
* Define an apis array of name strings using an enumerated api_t as index.
* The enumerated type is defined here. The apis array is
* inititialized in gvplugin.c by redefining ELEM and reinvoking APIS.
- *
- * NUM_APIS is the size of the array.
*/
#define APIS ELEM(render) ELEM(layout) ELEM(display) ELEM(text)
-#define NUM_APIS 4
#define ELEM(x) API_##x,
typedef enum { APIS } api_t; /* API_render, API_layout, ... */