+ }
+ ERROR2("No field nammed %s in %s",field_name,type->name);
+ xbt_abort();
+
+}
+
+/**
+ * gras_datadesc_cb_field_send:
+ *
+ * Add a pre-send callback to the given field of the datadesc (which must be a struct or union).
+ * (useful to push the sizes of the upcoming arrays, for example)
+ */
+void gras_datadesc_cb_field_send (gras_datadesc_type_t type,
+ const char *field_name,
+ gras_datadesc_type_cb_void_t send) {
+
+ gras_datadesc_type_t sub_type=gras_dd_find_field(type,field_name);
+ sub_type->send = send;
+}
+
+/**
+ * gras_datadesc_cb_field_push:
+ *
+ * Add a pre-send callback to the given field resulting in its value to be pushed to
+ * the stack of sizes. It must be a int, unsigned int, long int or unsigned long int.
+ */
+void gras_datadesc_cb_field_push (gras_datadesc_type_t type,
+ const char *field_name) {
+
+ gras_datadesc_type_t sub_type=gras_dd_find_field(type,field_name);
+ if (!strcmp("int",sub_type->name)) {
+ sub_type->send = gras_datadesc_cb_push_int;
+ } else if (!strcmp("unsigned int",sub_type->name)) {
+ sub_type->send = gras_datadesc_cb_push_uint;
+ } else if (!strcmp("long int",sub_type->name)) {
+ sub_type->send = gras_datadesc_cb_push_lint;
+ } else if (!strcmp("unsigned long int",sub_type->name)) {
+ sub_type->send = gras_datadesc_cb_push_ulint;
+ } else {
+ ERROR1("Field %s is not an int, unsigned int, long int neither unsigned long int",
+ sub_type->name);
+ xbt_abort();
+ }
+}
+/**
+ * gras_datadesc_cb_field_recv:
+ *
+ * Add a post-receive callback to the given field of the datadesc (which must be a struct or union).
+ * (useful to put the function pointers to the right value, for example)
+ */
+void gras_datadesc_cb_field_recv(gras_datadesc_type_t type,
+ const char *field_name,
+ gras_datadesc_type_cb_void_t recv) {
+
+ gras_datadesc_type_t sub_type=gras_dd_find_field(type,field_name);
+ sub_type->recv = recv;
+}
+
+/**
+ * gras_datadesc_free:
+ *
+ * Free a datadesc. Should only be called at xbt_exit.
+ */
+void gras_datadesc_free(gras_datadesc_type_t *type) {
+
+ DEBUG1("Let's free ddt %s",(*type)->name);
+
+ switch ((*type)->category_code) {
+ case e_gras_datadesc_type_cat_scalar:
+ case e_gras_datadesc_type_cat_ref:
+ case e_gras_datadesc_type_cat_array:
+ /* nothing to free in there */
+ break;
+
+ case e_gras_datadesc_type_cat_ignored:
+ if ((*type)->category.ignored_data.free_func) {
+ (*type)->category.ignored_data.free_func
+ ((*type)->category.ignored_data.default_value);
+ }
+ break;
+
+ case e_gras_datadesc_type_cat_struct:
+ xbt_dynar_free(&( (*type)->category.struct_data.fields ));
+ break;
+
+ case e_gras_datadesc_type_cat_union:
+ xbt_dynar_free(&( (*type)->category.union_data.fields ));
+ break;
+
+ default:
+ /* datadesc was invalid. Killing it is like euthanasy, I guess */
+ break;
+ }
+ xbt_free((*type)->name);
+ xbt_free(*type);
+ type=NULL;
+}
+
+/**
+ * gras_datadesc_type_cmp:
+ *
+ * Compares two datadesc types with the same semantic than strcmp.
+ *
+ * This comparison does not take the set headers into account (name and ID),
+ * but only the payload (actual type description).
+ */
+int gras_datadesc_type_cmp(const gras_datadesc_type_t d1,
+ const gras_datadesc_type_t d2) {
+ int ret,cpt;
+ gras_dd_cat_field_t field1,field2;
+ gras_datadesc_type_t field_desc_1,field_desc_2;
+
+ if (d1 == d2) return 0; /* easy optimization */
+
+ if (!d1 && d2) {
+ DEBUG0("ddt_cmp: !d1 && d2 => 1");
+ return 1;
+ }
+ if (!d1 && !d2) {
+ DEBUG0("ddt_cmp: !d1 && !d2 => 0");
+ return 0;
+ }
+ if ( d1 && !d2) {
+ DEBUG0("ddt_cmp: d1 && !d2 => -1");
+ return -1;
+ }