13 #define CREATOR_ID "Created in LiVES main"
18 static void init_lsd_tab(
void) {
25 if (st_type < LIVES_STRUCT_FIRST || st_type >=
LIVES_N_STRUCTS)
return NULL;
27 else if (lsd_table[st_type])
return lsd_table[st_type];
36 "priv", 0, NULL, NULL, NULL);
38 "URI", 0, NULL, NULL, NULL);
40 "title", 1024, NULL, NULL, NULL);
42 "author", 1024, NULL, NULL, NULL);
44 "comment", 1024, NULL, NULL, NULL);
46 "palettes", 4, NULL, NULL, NULL);
47 lives_struct_init(lsd, cdata, &cdata->
lsd);
57 "name", 0, NULL, NULL, NULL);
59 "md5sum", 0, NULL, NULL, NULL);
61 "extra_details", 0, NULL, NULL, NULL);
62 lives_struct_init_p(lsd, fdets, &fdets->
lsd);
71 lsd_table[st_type] = lsd;
78 if (!lsd)
return NULL;
79 return lives_struct_create(lsd);
84 if (lsd)
return lives_struct_copy(lsd);
90 if (lsd) lives_struct_unref(lsd);
95 if (lsd) lives_struct_ref(lsd);
100 if (lsd)
return lives_struct_get_class_data(lsd);
106 if (lsd && other)
return (lives_struct_get_uid(lsd) == lives_struct_get_uid(other));
112 if (lsd)
return (!
lives_strcmp(lives_struct_get_type(lsd), st_type));
124 #define CHECK_VERBOSE 0
126 #define errprint(...) fprintf(stderr, __VA_ARGS__)
128 #define errprint(...)
133 uint64_t id, eid, uid;
137 errprint(
"lsd_check: lsd1 is NULL\n");
145 id = lives_struct_get_identifier(lsd);
148 errprint(
"lsd_check: lsd (%p) has non-standard identifier 0X%016lX\n", lsd,
id);
150 eid = lives_struct_get_end_id(lsd);
153 errprint(
"lsd_check: lsd (%p) has non-standard end_id 0X%016lX\n", lsd, eid);
155 if (eid != (
id ^ 0xFFFFFFFFFFFFFFFF))
156 errprint(
"lsd_check: lsd (%p) has non matching identifier / end_id pair\n"
157 "0X%016lX 0X%016lX should be 0X%016lX\n", lsd,
id, eid,
id ^ 0xFFFFFFFFFFFFFFFF);
159 uid = lives_struct_get_uid(lsd);
161 errprint(
"lsd_check: lsd (%p) has no unique_id\n", lsd);
163 else if (uid < (1 << 20))
164 errprint(
"lsd_check: lsd (%p) has unique_id 0X%016lX\n"
165 "The probability of this is < 1 in 17.5 trillion\n", lsd, uid);
168 errprint(
"lsd_check: lsd (%p) has alternate class_data [%s]\n"
169 "Ours is [%s]\n", lsd, (
char *)lives_struct_get_class_data(lsd),
CREATOR_ID);
178 errprint(
"lsd_check: lsd1 is NULL\n");
182 errprint(
"lsd_check: lsd1 is NULL\n");
188 errprint(
"lsd_check: lsd1 type is %s but lsd2 type is %s\n",
189 lives_struct_get_type(lsd1), lives_struct_get_type(lsd2));
193 sz1 = lives_struct_get_size(lsd1);
194 sz2 = lives_struct_get_size(lsd2);
196 errprint(
"lsd_check: lsd1 (%p) size is %lu but lsd2 (%p) size is %lu\n",
197 lsd1, sz1, lsd2, sz2);
198 if (sz1 > sz2) err |= (1ul << 49);
199 else err |= (1ul << 50);
201 if (
lives_strcmp(lives_struct_get_last_field(lsd1), lives_struct_get_last_field(lsd2))) {
202 errprint(
"lsd_check: lsd1 (%p) last field [%s]\n"
203 "is not the same as lsd2 (%p) last field [%s]\n",
204 lsd1, lives_struct_get_last_field(lsd1),
205 lsd2, lives_struct_get_last_field(lsd2));
211 errprint(
"lsd_check: checking lsd1 (%p)\n", lsd1);
213 errprint(
"lsd_check: checking lsd2 (%p)\n", lsd2);
223 char **leaves = weed_plant_list_leaves(plant, NULL);
224 char *hdr, *ar = NULL, *line;
227 hdr = lives_strdup(
"typedef struct {");
229 hdr = lives_strdup(
"struct {");
231 for (
int i = 0; leaves[i]; i++) {
232 uint32_t st = weed_leaf_seed_type(plant, leaves[i]);
233 weed_size_t ne = weed_leaf_num_elements(plant, leaves[i]);
236 case WEED_SEED_INT: tp =
"int ";
break;
237 case WEED_SEED_BOOLEAN: tp =
"boolean ";
break;
238 case WEED_SEED_DOUBLE: tp =
"double ";
break;
239 case WEED_SEED_STRING: tp =
"char *";
break;
240 case WEED_SEED_INT64: tp =
"int64_t ";
break;
241 case WEED_SEED_FUNCPTR: tp =
"lives_func_t *";
break;
242 case WEED_SEED_VOIDPTR: tp =
"void *";
break;
243 case WEED_SEED_PLANTPTR: tp =
"weed_plant_t *";
break;
244 default: tp =
"void *";
break;
259 line = lives_strdup(
"\n}");