From 489aacc99b7e1c70e247eea5849ebf00dff75f39 Mon Sep 17 00:00:00 2001 From: Tobias Grosser Date: Mon, 12 Dec 2011 00:21:55 +0100 Subject: [PATCH] Introduce new ISL_CTX_(GET|SET)_INT_DEF macro 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 Signed-off-by: Sven Verdoolaege --- include/isl/ctx.h | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/include/isl/ctx.h b/include/isl/ctx.h index 814833b..a772723 100644 --- a/include/isl/ctx.h +++ b/include/isl/ctx.h @@ -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); -- 2.7.4