python interface: make rethrow Python 3 compatible
[isl.git] / isl_pw_morph_templ.c
bloba90fea12168f38a6baf8461efe4020e45371cf85
1 /*
2 * Copyright 2010 INRIA Saclay
4 * Use of this software is governed by the MIT license
6 * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France,
7 * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod,
8 * 91893 Orsay, France
9 */
11 __isl_give PW *FN(PW,morph_domain)(__isl_take PW *pw,
12 __isl_take isl_morph *morph)
14 int i;
15 isl_ctx *ctx;
17 if (!pw || !morph)
18 goto error;
20 ctx = isl_space_get_ctx(pw->dim);
21 isl_assert(ctx, isl_space_is_domain_internal(morph->dom->dim, pw->dim),
22 goto error);
24 pw = FN(PW,cow)(pw);
25 if (!pw)
26 goto error;
27 pw->dim = isl_space_extend_domain_with_range(
28 isl_space_copy(morph->ran->dim), pw->dim);
29 if (!pw->dim)
30 goto error;
32 for (i = 0; i < pw->n; ++i) {
33 pw->p[i].set = isl_morph_set(isl_morph_copy(morph), pw->p[i].set);
34 if (!pw->p[i].set)
35 goto error;
36 pw->p[i].FIELD = FN(EL,morph_domain)(pw->p[i].FIELD,
37 isl_morph_copy(morph));
38 if (!pw->p[i].FIELD)
39 goto error;
42 isl_morph_free(morph);
44 return pw;
45 error:
46 FN(PW,free)(pw);
47 isl_morph_free(morph);
48 return NULL;