Introduce new ISL_CTX_(GET|SET)_INT_DEF macro
authorTobias Grosser <tobias@grosser.es>
Sun, 11 Dec 2011 23:21:55 +0000 (00:21 +0100)
committerSven Verdoolaege <skimo@kotnet.org>
Mon, 12 Dec 2011 19:55:22 +0000 (20:55 +0100)
This macro uses the same implementation as the corresponding
BOOL and CHOICE macros. Hence, we simplify BOOL and CHOICE by
forwarding to the new INT macro.

Signed-off-by: Tobias Grosser <tobias@grosser.es>
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
include/isl/ctx.h

index 814833b..a772723 100644 (file)
@@ -164,7 +164,7 @@ st *isl_ctx_peek_ ## prefix(isl_ctx *ctx)                           \
        return (st *)isl_ctx_peek_options(ctx, &(args));                \
 }
 
-#define ISL_CTX_GET_BOOL_DEF(prefix,st,args,field)                     \
+#define ISL_CTX_GET_INT_DEF(prefix,st,args,field)                      \
 int prefix ## _get_ ## field(isl_ctx *ctx)                             \
 {                                                                      \
        st *options;                                                    \
@@ -176,7 +176,7 @@ int prefix ## _get_ ## field(isl_ctx *ctx)                          \
        return options->field;                                          \
 }
 
-#define ISL_CTX_SET_BOOL_DEF(prefix,st,args,field)                     \
+#define ISL_CTX_SET_INT_DEF(prefix,st,args,field)                      \
 int prefix ## _set_ ## field(isl_ctx *ctx, int val)                    \
 {                                                                      \
        st *options;                                                    \
@@ -189,30 +189,17 @@ int prefix ## _set_ ## field(isl_ctx *ctx, int val)                       \
        return 0;                                                       \
 }
 
+#define ISL_CTX_GET_BOOL_DEF(prefix,st,args,field)                     \
+       ISL_CTX_GET_INT_DEF(prefix,st,args,field)
+
+#define ISL_CTX_SET_BOOL_DEF(prefix,st,args,field)                     \
+       ISL_CTX_SET_INT_DEF(prefix,st,args,field)
+
 #define ISL_CTX_GET_CHOICE_DEF(prefix,st,args,field)                   \
-int prefix ## _get_ ## field(isl_ctx *ctx)                             \
-{                                                                      \
-       st *options;                                                    \
-       options = isl_ctx_peek_ ## prefix(ctx);                         \
-       if (!options)                                                   \
-               isl_die(ctx, isl_error_invalid,                         \
-                       "isl_ctx does not reference " #prefix,          \
-                       return -1);                                     \
-       return options->field;                                          \
-}
+       ISL_CTX_GET_INT_DEF(prefix,st,args,field)
 
 #define ISL_CTX_SET_CHOICE_DEF(prefix,st,args,field)                   \
-int prefix ## _set_ ## field(isl_ctx *ctx, int val)                    \
-{                                                                      \
-       st *options;                                                    \
-       options = isl_ctx_peek_ ## prefix(ctx);                         \
-       if (!options)                                                   \
-               isl_die(ctx, isl_error_invalid,                         \
-                       "isl_ctx does not reference " #prefix,          \
-                       return -1);                                     \
-       options->field = val;                                           \
-       return 0;                                                       \
-}
+       ISL_CTX_SET_INT_DEF(prefix,st,args,field)
 
 enum isl_error isl_ctx_last_error(isl_ctx *ctx);
 void isl_ctx_reset_error(isl_ctx *ctx);