From: Sven Verdoolaege Date: Tue, 13 Apr 2010 07:30:02 +0000 (+0200) Subject: add isl_stream_read_map X-Git-Tag: isl-0.03~250 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6c573431f5641840f006dd6b5c2a14da59a9f4ff;p=platform%2Fupstream%2Fisl.git add isl_stream_read_map --- diff --git a/include/isl_stream.h b/include/isl_stream.h index 2a896a2..2480e2f 100644 --- a/include/isl_stream.h +++ b/include/isl_stream.h @@ -81,6 +81,7 @@ enum isl_token_type isl_stream_register_keyword(struct isl_stream *s, const char *name); struct isl_obj isl_stream_read_obj(struct isl_stream *s); +__isl_give isl_map *isl_stream_read_map(struct isl_stream *s, int nparam); #if defined(__cplusplus) } diff --git a/isl_input.c b/isl_input.c index 8b8480a..9d9788f 100644 --- a/isl_input.c +++ b/isl_input.c @@ -1367,6 +1367,22 @@ struct isl_obj isl_stream_read_obj(struct isl_stream *s) return obj_read(s, -1); } +__isl_give isl_map *isl_stream_read_map(struct isl_stream *s, int nparam) +{ + struct isl_obj obj; + struct isl_map *map; + + obj = obj_read(s, nparam); + if (obj.v) + isl_assert(s->ctx, obj.type == isl_obj_map || + obj.type == isl_obj_set, goto error); + + return obj.v; +error: + obj.type->free(obj.v); + return NULL; +} + static struct isl_basic_map *basic_map_read(struct isl_stream *s, int nparam) { struct isl_obj obj; @@ -1448,27 +1464,25 @@ error: __isl_give isl_map *isl_map_read_from_file(struct isl_ctx *ctx, FILE *input, int nparam) { - struct isl_obj obj; struct isl_map *map; struct isl_stream *s = isl_stream_new_file(ctx, input); if (!s) return NULL; - obj = obj_read(s, nparam); + map = isl_stream_read_map(s, nparam); isl_stream_free(s); - return obj.v; + return map; } __isl_give isl_map *isl_map_read_from_str(struct isl_ctx *ctx, const char *str, int nparam) { - struct isl_obj obj; struct isl_map *map; struct isl_stream *s = isl_stream_new_str(ctx, str); if (!s) return NULL; - obj = obj_read(s, nparam); + map = isl_stream_read_map(s, nparam); isl_stream_free(s); - return obj.v; + return map; } __isl_give isl_set *isl_set_read_from_file(struct isl_ctx *ctx,