2 @page GRAS_tut_tour_pointers Lesson 13: Defining structure containing pointers (TODO)
4 This lesson is a bit different from the other ones. It aims at explaining
5 several features of the automatic datadesc parsing. Since it would be a bit
6 long otherwise, the lesson is organized as a FAQ, with little examples of
9 \section GRAS_tut_tour_pointers_toc Table of Contents
10 - \ref GRAS_tut_tour_pointers_cste
15 \section GRAS_tut_tour_pointers_cste How to have constants in parsed structures?
17 You can use gras_datadesc_set_const() to explain GRAS about the value of
18 your \#define'd constants.
22 GRAS_DEFINE_TYPE(array,struct array {
27 gras_datadesc_type_t ddt;
29 gras_datadesc_set_const("SIZE",SIZE); /* Set it before */
30 gras_datadesc_by_symbol(array);
38 #define MAX_ROUTESET 10
39 #define MAX_LEAFSET COLS
41 GRAS_DEFINE_TYPE(gras_row_t,
44 int row[COLS][MAX_ROUTESET];
47 typedef struct gras_row_t gras_row_t;
49 GRAS_DEFINE_TYPE(gras_welcome_msg_t,
50 struct gras_welcome_msg_t {
55 gras_row_t *rows GRAS_ANNOTE(size,row_count);
57 int leaves[MAX_LEAFSET];
60 void declare_ddt(void) {
61 gras_datadesc_type_t ddt;
63 gras_datadesc_set_const("COLS",COLS);
64 gras_datadesc_set_const("MAX_ROUTESET",MAX_ROUTESET);
65 gras_datadesc_set_const("MAX_LEAFSET",MAX_LEAFSET);
67 gras_datadesc_by_symbol(gras_row_t); /* Parse it before */
68 ddt=gras_datadesc_ref("welcome_msg_t*",gras_datadesc_by_symbol(gras_welcome_msg_t));
69 gras_msgtype_declare("welcome",ddt);