X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/b031f70c51caae219e7d46e9bada476964d1228b..97aa0e698984b850ad794879f10e2978e4ec94fe:/doc/gtut-tour-13-pointers.doc diff --git a/doc/gtut-tour-13-pointers.doc b/doc/gtut-tour-13-pointers.doc index 3c0f6a9500..d58f5e64bd 100644 --- a/doc/gtut-tour-13-pointers.doc +++ b/doc/gtut-tour-13-pointers.doc @@ -11,7 +11,7 @@ how to do things. - \ref GRAS_tut_tour_pointers_use - \ref GRAS_tut_tour_pointers_recap - \ref GRAS_tut_tour_pointers_cste - +
\section GRAS_tut_tour_pointers_intro Introduction to pointers in datadesc \section GRAS_tut_tour_pointers_use Using pointers in datadesc @@ -31,32 +31,32 @@ GRAS_DEFINE_TYPE(array,struct array { void declare_ddt() { gras_datadesc_type_t ddt; - + gras_datadesc_set_const("SIZE",SIZE); /* Set it before */ - gras_datadesc_by_symbol(array); + gras_datadesc_by_symbol(array); } \endverbatim */ - and the this example do use structures as payload, - so we have to declare it to GRAS. Hopefully, this can be done easily by enclosing - the structure declaration within a \ref GRAS_DEFINE_TYPE macro call. It will then copy this - declaration into an hidden string variable, which can be automatically parsed at + and the this example do use structures as payload, + so we have to declare it to GRAS. Hopefully, this can be done easily by enclosing + the structure declaration within a \ref GRAS_DEFINE_TYPE macro call. It will then copy this + declaration into an hidden string variable, which can be automatically parsed at run time. Of course, the declaration is also copied unmodified by this macro, so that it - gets parsed by the compiler also. + gets parsed by the compiler also. There is some semantic that GRAS cannot guess alone and you need to annotate - your declaration to add some. For example, the ctn pointer can be a reference to an - object or a whole array (in which case you also has to specify its size). This is done + your declaration to add some. For example, the ctn pointer can be a reference to an + object or a whole array (in which case you also has to specify its size). This is done with the GRAS_ANNOTE call. It is removed from the text passed to the compiler, but it helps - GRAS getting some information about the semantic of your data. Here, it says that \a ctn is an - array, which size is the result of the operation \a rows * \a cols (with \a rows and \a cols - being the other fields of the structure). + GRAS getting some information about the semantic of your data. Here, it says that \a ctn is an + array, which size is the result of the operation \a rows * \a cols (with \a rows and \a cols + being the other fields of the structure). - Please note that this annotation mechanism is not as robust and cool as this example seems to - imply. If you want to use it yourself, you'd better use the exact right syntax, which is + Please note that this annotation mechanism is not as robust and cool as this example seems to + imply. If you want to use it yourself, you'd better use the exact right syntax, which is detailed in the \ref GRAS_dd section. \skip GRAS_DEFINE_TYPE @@ -69,32 +69,32 @@ void declare_ddt() { #define MAX_LEAFSET COLS GRAS_DEFINE_TYPE(gras_row_t, -struct gras_row_t { - int which_row; +struct gras_row_t { + int which_row; int row[COLS][MAX_ROUTESET]; };) - + typedef struct gras_row_t gras_row_t; - -GRAS_DEFINE_TYPE(gras_welcome_msg_t, + +GRAS_DEFINE_TYPE(gras_welcome_msg_t, struct gras_welcome_msg_t { int id; double time_sent; - + int row_count; gras_row_t *rows GRAS_ANNOTE(size,row_count); - + int leaves[MAX_LEAFSET]; -};) +};) void declare_ddt(void) { gras_datadesc_type_t ddt; - + gras_datadesc_set_const("COLS",COLS); gras_datadesc_set_const("MAX_ROUTESET",MAX_ROUTESET); gras_datadesc_set_const("MAX_LEAFSET",MAX_LEAFSET); - + gras_datadesc_by_symbol(gras_row_t); /* Parse it before */ ddt=gras_datadesc_ref("welcome_msg_t*",gras_datadesc_by_symbol(gras_welcome_msg_t)); - gras_msgtype_declare("welcome",ddt); -} + gras_msgtype_declare("welcome",ddt); +}