summaryrefslogtreecommitdiff
path: root/polly/lib/External/isl/isl_list_read_yaml_templ.c
blob: 5b6143df9ee47e80e36dfbdb4b70821b9102d6e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
 * Copyright 2013      Ecole Normale Superieure
 *
 * Use of this software is governed by the MIT license
 *
 * Written by Sven Verdoolaege,
 * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France
 */

#include <isl/stream.h>

#include <isl_list_macro.h>

/* Read a sequence of EL objects and return them as a list.
 */
static __isl_give LIST(EL) *FN(isl_stream_yaml_read,LIST(EL_BASE))(
	isl_stream *s)
{
	isl_ctx *ctx;
	LIST(EL) *list;
	isl_bool more;

	ctx = isl_stream_get_ctx(s);

	if (isl_stream_yaml_read_start_sequence(s) < 0)
		return NULL;

	list = FN(LIST(EL),alloc)(ctx, 0);
	while ((more = isl_stream_yaml_next(s)) == isl_bool_true) {
		EL *el;

		el = FN(isl_stream_read,EL_BASE)(s);
		list = FN(LIST(EL),add)(list, el);
	}

	if (more < 0 || isl_stream_yaml_read_end_sequence(s) < 0)
		return FN(LIST(EL),free)(list);

	return list;
}