/* datadesc - data description in order to send/recv it in GRAS */
-/* Authors: Olivier Aumage, Martin Quinson */
-/* Copyright (C) 2003, 2004 the GRAS posse. */
+/* Copyright (c) 2003 Olivier Aumage. */
+/* Copyright (c) 2003, 2004 Martin Quinson. */
+/* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
- under the terms of the license (GNU LGPL) which comes with this package. */
+ * under the terms of the license (GNU LGPL) which comes with this package. */
#include "gras/DataDesc/datadesc_private.h"
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(datadesc,gras,"Data description");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(gras_ddt,gras,"Data description");
/* FIXME: make this host-dependent using a trick such as UserData*/
-xbt_set_t gras_datadesc_set_local=NULL;
+/*@null@*/xbt_set_t gras_datadesc_set_local=NULL;
/* callback for array size when sending strings */
static int
-_strlen_cb(gras_cbps_t vars, void *data) {
+_strlen_cb(/*@unused@*/gras_datadesc_type_t type,/*@unused@*/gras_cbps_t vars, void *data) {
- return 1+(long int)strlen(data);
+ return 1+(int)strlen(data);
}
gras_datadesc_set_local = xbt_set_new();
+
+ /* all known datatypes */
+
ddt = gras_datadesc_scalar("signed char",
gras_ddt_scalar_char,
e_gras_dd_scalar_encoding_sint);
ddt = gras_datadesc_scalar("short int",
gras_ddt_scalar_short,
e_gras_dd_scalar_encoding_sint);
+ ddt = gras_datadesc_scalar("short",
+ gras_ddt_scalar_short,
+ e_gras_dd_scalar_encoding_sint);
ddt = gras_datadesc_scalar("unsigned short int",
gras_ddt_scalar_short,
e_gras_dd_scalar_encoding_uint);
ddt = gras_datadesc_scalar("long int",
gras_ddt_scalar_long,
e_gras_dd_scalar_encoding_sint);
+ ddt = gras_datadesc_scalar("long",
+ gras_ddt_scalar_long,
+ e_gras_dd_scalar_encoding_sint);
ddt = gras_datadesc_scalar("unsigned long int",
gras_ddt_scalar_long,
e_gras_dd_scalar_encoding_uint);
ddt = gras_datadesc_array_dyn("char[]",
gras_datadesc_by_name("char"),
_strlen_cb);
- ddt = gras_datadesc_ref("string",ddt);
-
+ gras_datadesc_ref("string",ddt);
+ gras_datadesc_ref("xbt_string_t",ddt);
+
+ /* specific datatype: the exception type (for RPC) */
+ ddt = gras_datadesc_struct("ex_t");
+ gras_datadesc_struct_append(ddt,"msg",gras_datadesc_by_name("string"));
+ gras_datadesc_struct_append(ddt,"category",gras_datadesc_by_name("int"));
+ gras_datadesc_struct_append(ddt,"value",gras_datadesc_by_name("int"));
+
+ gras_datadesc_struct_append(ddt,"remote",gras_datadesc_by_name("short int"));
+
+ gras_datadesc_struct_append(ddt,"host",gras_datadesc_by_name("string"));
+ gras_datadesc_struct_append(ddt,"procname",gras_datadesc_by_name("string"));
+ gras_datadesc_struct_append(ddt,"pid",gras_datadesc_by_name("long int"));
+ gras_datadesc_struct_append(ddt,"file",gras_datadesc_by_name("string"));
+ gras_datadesc_struct_append(ddt,"line",gras_datadesc_by_name("int"));
+ gras_datadesc_struct_append(ddt,"func",gras_datadesc_by_name("string"));
+ gras_datadesc_struct_append(ddt,"used",gras_datadesc_by_name("int"));
+ gras_datadesc_cb_field_push(ddt,"used");
+ gras_datadesc_struct_append(ddt,"bt_strings",
+ gras_datadesc_ref_pop_arr(gras_datadesc_by_name("string")));
+
+ gras_datadesc_struct_close(ddt);
+
+ /* specific datatype: xbt_peer_t */
+ ddt = gras_datadesc_struct("s_xbt_peer_t");
+ gras_datadesc_struct_append(ddt,"name",gras_datadesc_by_name("string"));
+ gras_datadesc_struct_append(ddt,"port",gras_datadesc_by_name("int"));
+ gras_datadesc_struct_close(ddt);
+
+ ddt = gras_datadesc_ref("xbt_peer_t",ddt);
+
+ /* Dict containing the constant value (for the parsing macro) */
+ gras_dd_constants = xbt_dict_new();
+
}
/**
gras_datadesc_exit(void) {
VERB0("Exiting DataDesc");
xbt_set_free(&gras_datadesc_set_local);
+ xbt_dict_free(&gras_dd_constants);
DEBUG0("Exited DataDesc");
}
-/**
- * gras_datadesc_get_name:
- *
- * Returns the name of a datadescription (to ease the debug)
- */
-char *
+/** This is mainly to debug */
+const char *
gras_datadesc_get_name(gras_datadesc_type_t ddt) {
- return ddt->name;
+ return ddt?(const char*)ddt->name:"(null)";
}
-/**
- * gras_datadesc_get_id:
- *
- * Returns the name of a datadescription (to ease the debug)
- */
+/** This is mainly to debug */
int
gras_datadesc_get_id(gras_datadesc_type_t ddt) {
return ddt->code;
*
*/
int gras_datadesc_size(gras_datadesc_type_t type) {
- return type->size[GRAS_THISARCH];
+ return type?type->size[GRAS_THISARCH]:0;
}
/**
* For debugging purpose
*/
void gras_datadesc_type_dump(const gras_datadesc_type_t ddt){
- int cpt;
+ unsigned int cpt;
printf("DataDesc dump:");
if(!ddt) {