2 /*--------------------------------------------------------------------+
4 |--------------------------------------------------------------------|
6 |--------------------------------------------------------------------|
7 | First version: 03/04/2012 |
8 +--------------------------------------------------------------------+
10 +--------------------------------------------------------------------------+
11 | / __)( ) /__\ ( \/ ) |
12 | ( (__ )(__ /(__)\ \ / Chunky Loop Alteration wizardrY |
13 | \___)(____)(__)(__)(__) |
14 +--------------------------------------------------------------------------+
15 | Copyright (C) 2012 University of Paris-Sud |
17 | This library is free software; you can redistribute it and/or modify it |
18 | under the terms of the GNU Lesser General Public License as published by |
19 | the Free Software Foundation; either version 2.1 of the License, or |
20 | (at your option) any later version. |
22 | This library is distributed in the hope that it will be useful but |
23 | WITHOUT ANY WARRANTY; without even the implied warranty of |
24 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser |
25 | General Public License for more details. |
27 | You should have received a copy of the GNU Lesser General Public License |
28 | along with this software; if not, write to the Free Software Foundation, |
29 | Inc., 51 Franklin Street, Fifth Floor, |
30 | Boston, MA 02110-1301 USA |
32 | Clay, the Chunky Loop Alteration wizardrY |
33 | Written by Joel Poudroux, joel.poudroux@u-psud.fr |
34 +--------------------------------------------------------------------------*/
39 #include <clay/macros.h>
40 #include <clay/data.h>
41 #include <clay/array.h>
42 #include <clay/list.h>
44 clay_data_p
clay_data_malloc(int type
) {
45 clay_data_p tmp
= malloc(sizeof(clay_data_t
));
50 void clay_data_free(clay_data_p d
) {
58 void clay_data_clear(clay_data_p d
) {
67 clay_array_free((clay_array_p
) d
->data
.obj
);
71 clay_list_free((clay_list_p
) d
->data
.obj
);
81 void clay_data_print(FILE* f
, clay_data_p d
) {
87 fprintf(f
, "undef\n");
92 clay_data_print(f
, d
->data
.obj
);
96 fprintf(f
, "int %d\n", d
->data
.integer
);
100 fprintf(f
, "void %d\n", d
->data
.integer
);
104 fprintf(f
, "array ");
105 clay_array_print(f
, d
->data
.obj
, 1);
110 clay_list_print(f
, d
->data
.obj
);
114 fprintf(f
, "string %s\n", (char*) d
->data
.obj
);
120 clay_data_p
clay_data_clone(clay_data_p d
) {
124 clay_data_p newd
= clay_data_malloc(d
->type
);
132 newd
->data
.obj
= clay_data_clone(d
->data
.obj
);
136 newd
->data
.integer
= d
->data
.integer
;
140 newd
->data
.obj
= clay_array_clone(d
->data
.obj
);
144 newd
->data
.obj
= clay_list_clone(d
->data
.obj
);
148 newd
->data
.obj
= strdup((char*) d
->data
.obj
);