13#define CREATOR_ID "Created in LiVES main"
18static 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__)
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}");
LIVES_GLOBAL_INLINE boolean lives_struct_is_a(lives_struct_def_t *lsd, const char *st_type)
LIVES_GLOBAL_INLINE void ref_struct(lives_struct_def_t *lsd)
LIVES_GLOBAL_INLINE void unref_struct(lives_struct_def_t *lsd)
LIVES_GLOBAL_INLINE boolean lives_structs_equal(lives_struct_def_t *lsd, lives_struct_def_t *other)
LIVES_GLOBAL_INLINE boolean lives_structs_same_type(lives_struct_def_t *lsd, lives_struct_def_t *other)
LIVES_GLOBAL_INLINE void * copy_struct(lives_struct_def_t *lsd)
uint64_t lsd_check_struct(lives_struct_def_t *lsd)
char * weed_plant_to_header(weed_plant_t *plant, const char *tname)
bonus functions
void * struct_from_template(lives_struct_type st_type)
const lives_struct_def_t * get_lsd(lives_struct_type st_type)
uint64_t lsd_check_match(lives_struct_def_t *lsd1, lives_struct_def_t *lsd2)
LIVES_GLOBAL_INLINE const char * lives_struct_get_creator(lives_struct_def_t *lsd)
@ LIVES_STRUCT_FILE_DETS_T
@ LIVES_STRUCT_CLIP_DATA_T
#define LIVES_FIELD_ARRAY
#define LIVES_FIELD_CHARPTR
#define LIVES_FIELD_FLAG_ZERO_ON_COPY
#define LIVES_FIELD_FLAG_FREE_ON_DELETE
< field wiill be freed in lives_struct_delete free(struct->field)
LIVES_GLOBAL_INLINE boolean lives_strcmp(const char *st1, const char *st2)
returns FALSE if strings match
LIVES_GLOBAL_INLINE char * lives_concat(char *st, char *x)
#define LIVES_GLOBAL_INLINE
int * palettes
number forames from one keyframe to the next, 0 if unknown
char * URI
the URI of this cdata
char * extra_details
only filled if EXTRA_DETAILS_MD5 is set, otherwis NULL
lives_special_field_t ** special_fields
user_data for delete_struct_callback
#define lives_strdup_printf(fmt,...)