From: compudj Date: Thu, 10 Nov 2005 14:20:32 +0000 (+0000) Subject: sequence length type X-Git-Tag: v0.12.20~2172 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=be97b9537557ac5ed4b010dbacb26be3452f6035;p=lttv.git sequence length type git-svn-id: http://ltt.polymtl.ca/svn@1317 04897980-b3bd-0310-b5e0-8ef037075253 --- diff --git a/genevent-new/README b/genevent-new/README index ad31d648..951f146c 100644 --- a/genevent-new/README +++ b/genevent-new/README @@ -48,7 +48,7 @@ to the slowest. a unsigned int len and const unsigned char *name. you must use a sequence to declare this efficiently : - /> + 3 - The C code presents a \0 terminated string. diff --git a/genevent-new/parser.c b/genevent-new/parser.c index ce416ed9..17ebef72 100644 --- a/genevent-new/parser.c +++ b/genevent-new/parser.c @@ -174,7 +174,8 @@ char *allocAndCopy(char *str) * **************************************************************************/ -void getTypeAttributes(parse_file_t *in, type_descriptor_t *t) +void getTypeAttributes(parse_file_t *in, type_descriptor_t *t, + sequence_t * unnamed_types, table_t * named_types) { char * token; @@ -198,7 +199,7 @@ void getTypeAttributes(parse_file_t *in, type_descriptor_t *t) // if(car == EOF) in->error(in,"name was expected"); // else if(car == '\"') t->type_name = allocAndCopy(getQuotedString(in)); // else t->type_name = allocAndCopy(getName(in)); - } else if(!strcmp("size",token) || !strcmp("lengthsize", token)) { + } else if(!strcmp("size",token)) { getEqual(in); t->size = getSize(in); } else if(!strcmp("align",token)) { @@ -601,7 +602,7 @@ type_descriptor_t *parseType(parse_file_t *in, type_descriptor_t *inType, if(strcmp(token,"struct") == 0) { t->type = STRUCT; - getTypeAttributes(in, t); + getTypeAttributes(in, t, unnamed_types, named_types); getRAnglebracket(in); // getLAnglebracket(in); // token = getToken(in); @@ -624,7 +625,7 @@ type_descriptor_t *parseType(parse_file_t *in, type_descriptor_t *inType, } else if(strcmp(token,"union") == 0) { t->type = UNION; - getTypeAttributes(in, t); + getTypeAttributes(in, t, unnamed_types, named_types); getRAnglebracket(in); // getLAnglebracket(in); // @@ -647,7 +648,7 @@ type_descriptor_t *parseType(parse_file_t *in, type_descriptor_t *inType, } else if(strcmp(token,"array") == 0) { t->type = ARRAY; - getTypeAttributes(in, t); + getTypeAttributes(in, t, unnamed_types, named_types); if(t->size == 0) in->error(in, "Array has empty size"); getForwardslash(in); getRAnglebracket(in); // @@ -663,14 +664,33 @@ type_descriptor_t *parseType(parse_file_t *in, type_descriptor_t *inType, } else if(strcmp(token,"sequence") == 0) { t->type = SEQUENCE; - getTypeAttributes(in, t); - if(t->size == 0) in->error(in, "Sequence has empty lengthsize"); - getForwardslash(in); - getRAnglebracket(in); // + //getTypeAttributes(in, t, unnamed_types, named_types); + //getForwardslash(in); + getRAnglebracket(in); // - getLAnglebracket(in); // - t->nested_type = parseType(in,NULL, unnamed_types, named_types); + getLAnglebracket(in); // + t->length_type = parseType(in, NULL, unnamed_types, named_types); + getLAnglebracket(in); // + + t->nested_type = parseType(in, NULL, unnamed_types, named_types); + + if(t->length_type == NULL) in->error(in, "Sequence has no length type"); + switch(t->length_type->type) { + case UINT_FIXED : + case UCHAR : + case USHORT : + case UINT : + case ULONG : + case SIZE_T : + case OFF_T : + break; + default: + in->error(in, "Wrong length type for sequence"); + } + + + if(t->nested_type == NULL) in->error(in, "Sequence has no nested type"); getLAnglebracket(in); // getForwardslash(in); token = getName(in); @@ -683,7 +703,7 @@ type_descriptor_t *parseType(parse_file_t *in, type_descriptor_t *inType, sequence_init(&(t->labels)); sequence_init(&(t->labels_description)); t->already_printed = 0; - getTypeAttributes(in, t); + getTypeAttributes(in, t, unnamed_types, named_types); //if(t->size == 0) in->error(in, "Sequence has empty size"); //Mathieu : we fix enum size to 4 bytes. GCC is always like this. //fox copy optimisation. @@ -725,100 +745,100 @@ type_descriptor_t *parseType(parse_file_t *in, type_descriptor_t *inType, } else if(strcmp(token,"int_fixed") == 0) { t->type = INT_FIXED; - getTypeAttributes(in, t); + getTypeAttributes(in, t, unnamed_types, named_types); if(t->size == 0) in->error(in, "int has empty size"); getForwardslash(in); getRAnglebracket(in); } else if(strcmp(token,"uint_fixed") == 0) { t->type = UINT_FIXED; - getTypeAttributes(in, t); + getTypeAttributes(in, t, unnamed_types, named_types); if(t->size == 0) in->error(in, "uint has empty size"); getForwardslash(in); getRAnglebracket(in); } else if(strcmp(token,"char") == 0) { t->type = CHAR; - getTypeAttributes(in, t); + getTypeAttributes(in, t, unnamed_types, named_types); getForwardslash(in); getRAnglebracket(in); } else if(strcmp(token,"uchar") == 0) { t->type = UCHAR; - getTypeAttributes(in, t); + getTypeAttributes(in, t, unnamed_types, named_types); getForwardslash(in); getRAnglebracket(in); } else if(strcmp(token,"short") == 0) { t->type = SHORT; - getTypeAttributes(in, t); + getTypeAttributes(in, t, unnamed_types, named_types); getForwardslash(in); getRAnglebracket(in); } else if(strcmp(token,"ushort") == 0) { t->type = USHORT; - getTypeAttributes(in, t); + getTypeAttributes(in, t, unnamed_types, named_types); getForwardslash(in); getRAnglebracket(in); } else if(strcmp(token,"int") == 0) { t->type = INT; - getTypeAttributes(in, t); + getTypeAttributes(in, t, unnamed_types, named_types); getForwardslash(in); getRAnglebracket(in); } else if(strcmp(token,"uint") == 0) { t->type = UINT; - getTypeAttributes(in, t); + getTypeAttributes(in, t, unnamed_types, named_types); getForwardslash(in); getRAnglebracket(in); } else if(strcmp(token,"pointer") == 0) { t->type = POINTER; - getTypeAttributes(in, t); + getTypeAttributes(in, t, unnamed_types, named_types); getForwardslash(in); getRAnglebracket(in); } else if(strcmp(token,"long") == 0) { t->type = LONG; - getTypeAttributes(in, t); + getTypeAttributes(in, t, unnamed_types, named_types); getForwardslash(in); getRAnglebracket(in); } else if(strcmp(token,"ulong") == 0) { t->type = ULONG; - getTypeAttributes(in, t); + getTypeAttributes(in, t, unnamed_types, named_types); getForwardslash(in); getRAnglebracket(in); } else if(strcmp(token,"size_t") == 0) { t->type = SIZE_T; - getTypeAttributes(in, t); + getTypeAttributes(in, t, unnamed_types, named_types); getForwardslash(in); getRAnglebracket(in); } else if(strcmp(token,"ssize_t") == 0) { t->type = SSIZE_T; - getTypeAttributes(in, t); + getTypeAttributes(in, t, unnamed_types, named_types); getForwardslash(in); getRAnglebracket(in); } else if(strcmp(token,"off_t") == 0) { t->type = OFF_T; - getTypeAttributes(in, t); + getTypeAttributes(in, t, unnamed_types, named_types); getForwardslash(in); getRAnglebracket(in); } else if(strcmp(token,"float") == 0) { t->type = FLOAT; - getTypeAttributes(in, t); + getTypeAttributes(in, t, unnamed_types, named_types); getForwardslash(in); getRAnglebracket(in); } else if(strcmp(token,"string") == 0) { t->type = STRING; - getTypeAttributes(in, t); + getTypeAttributes(in, t, unnamed_types, named_types); getForwardslash(in); getRAnglebracket(in); } diff --git a/genevent-new/parser.h b/genevent-new/parser.h index e19dc93d..58879098 100644 --- a/genevent-new/parser.h +++ b/genevent-new/parser.h @@ -113,6 +113,7 @@ typedef struct _type_descriptor { int already_printed; sequence_t fields; // for structure struct _type_descriptor *nested_type; // for array and sequence + struct _type_descriptor *length_type; // for sequence int alignment; } type_descriptor_t; diff --git a/genevent-new/test.xml b/genevent-new/test.xml index 34ca9b09..6a328bdd 100644 --- a/genevent-new/test.xml +++ b/genevent-new/test.xml @@ -102,8 +102,9 @@ - - + + +