78 #define REGISTRY_FIELDS \ 79 struct registry_fields registry_data 85 #define REGISTRY_ACCESS_FIELD(CONTAINER) \ 94 struct registry_container;
132 struct registry_container *container,
137 struct registry_container *container,
142 struct registry_container *container,
154 #define DEFINE_REGISTRY(TAG, ACCESS) \ 155 struct registry_data_registry TAG ## _data_registry = { NULL, 0 }; \ 157 const struct TAG ## _data * \ 158 register_ ## TAG ## _data_with_cleanup (void (*save) (struct TAG *, void *), \ 159 void (*free) (struct TAG *, void *)) \ 161 return (struct TAG ## _data *) \ 162 register_data_with_cleanup (&TAG ## _data_registry, \ 163 (registry_data_callback) save, \ 164 (registry_data_callback) free); \ 167 const struct TAG ## _data * \ 168 register_ ## TAG ## _data (void) \ 170 return register_ ## TAG ## _data_with_cleanup (NULL, NULL); \ 174 TAG ## _alloc_data (struct TAG *container) \ 176 struct registry_fields *rdata = &ACCESS (container)->registry_data; \ 178 registry_alloc_data (&TAG ## _data_registry, rdata); \ 182 TAG ## registry_callback_adaptor (registry_data_callback func, \ 183 struct registry_container *container, \ 186 struct TAG *tagged_container = (struct TAG *) container; \ 188 registry_ ## TAG ## _callback tagged_func \ 189 = (registry_ ## TAG ## _callback) func; \ 191 tagged_func (tagged_container, data); \ 195 clear_ ## TAG ## _data (struct TAG *container) \ 197 struct registry_fields *rdata = &ACCESS (container)->registry_data; \ 199 registry_clear_data (&TAG ## _data_registry, \ 200 TAG ## registry_callback_adaptor, \ 201 (struct registry_container *) container, \ 206 TAG ## _free_data (struct TAG *container) \ 208 struct registry_fields *rdata = &ACCESS (container)->registry_data; \ 210 registry_container_free_data (&TAG ## _data_registry, \ 211 TAG ## registry_callback_adaptor, \ 212 (struct registry_container *) container, \ 217 set_ ## TAG ## _data (struct TAG *container, \ 218 const struct TAG ## _data *data, \ 221 struct registry_fields *rdata = &ACCESS (container)->registry_data; \ 223 registry_set_data (rdata, \ 224 (struct registry_data *) data, \ 229 TAG ## _data (struct TAG *container, const struct TAG ## _data *data) \ 231 struct registry_fields *rdata = &ACCESS (container)->registry_data; \ 233 return registry_data (rdata, \ 234 (struct registry_data *) data); \ 240 #define DECLARE_REGISTRY(TAG) \ 241 struct TAG ## _data; \ 242 typedef void (*registry_ ## TAG ## _callback) (struct TAG *, void *); \ 243 extern const struct TAG ## _data *register_ ## TAG ## _data (void); \ 244 extern const struct TAG ## _data *register_ ## TAG ## _data_with_cleanup \ 245 (registry_ ## TAG ## _callback save, registry_ ## TAG ## _callback free); \ 246 extern void clear_ ## TAG ## _data (struct TAG *); \ 247 extern void set_ ## TAG ## _data (struct TAG *, \ 248 const struct TAG ## _data *data, \ 250 extern void *TAG ## _data (struct TAG *, \ 251 const struct TAG ## _data *data); void * registry_data(struct registry_fields *fields, const struct registry_data *data)
struct registry_data_registration * next
const struct registry_data * register_data_with_cleanup(struct registry_data_registry *registry, registry_data_callback save, registry_data_callback free)
unsigned num_registrations
void registry_alloc_data(struct registry_data_registry *registry, struct registry_fields *registry_fields)
struct registry_data_registration * registrations
void registry_set_data(struct registry_fields *fields, const struct registry_data *data, void *value)
struct registry_data * data
registry_data_callback save
void registry_container_free_data(struct registry_data_registry *data_registry, registry_callback_adaptor adaptor, struct registry_container *container, struct registry_fields *fields)
void registry_clear_data(struct registry_data_registry *data_registry, registry_callback_adaptor adaptor, struct registry_container *container, struct registry_fields *fields)
void(* registry_callback_adaptor)(registry_data_callback func, struct registry_container *container, void *data)
registry_data_callback free
void(* registry_data_callback)(struct registry_container *, void *)