- case e_gras_datadesc_type_cat_struct: {
- gras_dd_cat_struct_t struct_data;
- gras_dd_cat_field_t field;
- char *field_src;
- char *field_dst;
-
- struct_data = type->category.struct_data;
- xbt_assert1(struct_data.closed,
- "Please call gras_datadesc_declare_struct_close on %s before copying it",
- type->name);
- VERB1(">> Copy all fields of the structure %s",type->name);
- xbt_dynar_foreach(struct_data.fields, cpt, field) {
- field_src = src + field->offset[GRAS_THISARCH];
- field_dst = dst + field->offset[GRAS_THISARCH];
-
+ case e_gras_datadesc_type_cat_struct:{
+ gras_dd_cat_struct_t struct_data;
+ gras_dd_cat_field_t field;
+ char *field_src;
+ char *field_dst;
+
+ struct_data = type->category.struct_data;
+ xbt_assert(struct_data.closed,
+ "Please call gras_datadesc_declare_struct_close on %s before copying it",
+ type->name);
+ XBT_VERB(">> Copy all fields of the structure %s", type->name);
+ xbt_dynar_foreach(struct_data.fields, cpt, field) {
+ field_src = src + field->offset[GRAS_THISARCH];
+ field_dst = dst + field->offset[GRAS_THISARCH];
+
+ sub_type = field->type;
+
+ if (field->send)
+ field->send(type, state, field_src);
+
+ XBT_DEBUG("Copy field %s", field->name);
+ count +=
+ gras_datadesc_memcpy_rec(state, refs, sub_type, field_src,
+ field_dst, 0, detect_cycle
+ || sub_type->cycle);
+
+ if (XBT_LOG_ISENABLED(gras_ddt_exchange, xbt_log_priority_verbose)) {
+ if (sub_type == gras_datadesc_by_name("unsigned int")) {
+ XBT_VERB("Copied value for field '%s': %d (type: unsigned int)",
+ field->name, *(unsigned int *) field_dst);
+ } else if (sub_type == gras_datadesc_by_name("int")) {
+ XBT_VERB("Copied value for field '%s': %d (type: int)",
+ field->name, *(int *) field_dst);
+
+ } else if (sub_type ==
+ gras_datadesc_by_name("unsigned long int")) {
+ XBT_VERB
+ ("Copied value for field '%s': %ld (type: unsigned long int)",
+ field->name, *(unsigned long int *) field_dst);
+ } else if (sub_type == gras_datadesc_by_name("long int")) {
+ XBT_VERB("Copied value for field '%s': %ld (type: long int)",
+ field->name, *(long int *) field_dst);
+
+ } else if (sub_type == gras_datadesc_by_name("string")) {
+ XBT_VERB("Copied value for field '%s': '%s' (type: string)",
+ field->name, *(char **) field_dst);
+ } else {
+ XBT_VERB("Copied a value for field '%s' (type not scalar?)",
+ field->name);
+ }
+ }
+
+ }
+ XBT_VERB("<< Copied all fields of the structure %s", type->name);
+
+ break;
+ }
+
+ case e_gras_datadesc_type_cat_union:{
+ gras_dd_cat_union_t union_data;
+ gras_dd_cat_field_t field = NULL;
+ unsigned int field_num;
+
+ union_data = type->category.union_data;
+
+ xbt_assert(union_data.closed,
+ "Please call gras_datadesc_declare_union_close on %s before copying it",
+ type->name);
+ /* retrieve the field number */
+ field_num = union_data.selector(type, state, src);
+
+ xbt_assert(field_num > 0,
+ "union field selector of %s gave a negative value",
+ type->name);
+
+ xbt_assert(field_num < xbt_dynar_length(union_data.fields),
+ "union field selector of %s returned %d but there is only %lu fields",
+ type->name, field_num,
+ xbt_dynar_length(union_data.fields));
+
+ /* Copy the content */
+ field =
+ xbt_dynar_get_as(union_data.fields, field_num,
+ gras_dd_cat_field_t);