fix enums
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 15 Dec 2005 16:12:54 +0000 (16:12 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 15 Dec 2005 16:12:54 +0000 (16:12 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@1383 04897980-b3bd-0310-b5e0-8ef037075253

genevent-new/genevent.c
genevent-new/parser.c
genevent-new/parser.h

index 88cecb69c5d5c821ac971bafee618926c328cf78..9113a11ceec1d968ed2941ad667be46d86a60e8b 100644 (file)
@@ -411,7 +411,8 @@ int print_type_declaration(type_descriptor_t * td, FILE *fd, unsigned int tabs,
                        fprintf(fd, " {\n");
                        for(unsigned int i=0;i<td->labels.position;i++){
                                print_tabs(1, fd);
-                               fprintf(fd, "LTTNG_%s", ((char*)(td->labels.array[i])));
+                               fprintf(fd, "LTTNG_%s = %d", ((char*)td->labels.array[i]),
+            (*(int*)td->labels_values.array[i]));
                                fprintf(fd, ",\n");
                        }
                        fprintf(fd, "};\n");
index 425d390cfa9745bddce0bdf286ddfeb4fcb8811c..42c38c316a52e9101cb45a610a82305ff6db88ec 100644 (file)
@@ -723,9 +723,12 @@ type_descriptor_t *parseType(parse_file_t *in, type_descriptor_t *inType,
     getRAnglebracket(in); //</sequence>
   }
   else if(strcmp(token,"enum") == 0) {
-    char * str, *str1;
+    char * str;
+    int value = -1;
+
     t->type = ENUM;
     sequence_init(&(t->labels));
+    sequence_init(&(t->labels_values));
     sequence_init(&(t->labels_description));
                t->already_printed = 0;
     getTypeAttributes(in, t, unnamed_types, named_types);
@@ -740,17 +743,18 @@ type_descriptor_t *parseType(parse_file_t *in, type_descriptor_t *inType,
     getLAnglebracket(in);
     token = getToken(in); //"label" or "/"
     while(strcmp("label",token) == 0){
+      int *label_value = malloc(sizeof(int));
+      
       str   = allocAndCopy(getNameAttribute(in));      
       token = getValueStrAttribute(in);
-      if(token){
-       str1 = appendString(str,"=");
-       free(str);
-       str = appendString(str1,token);
-       free(str1);
-       sequence_push(&(t->labels),str);
-      }
-      else
-       sequence_push(&(t->labels),str);
+      
+       sequence_push(&(t->labels),str);
+
+      if(token) value = strtol(token, NULL, 0);
+      else value++;
+
+      *label_value = value;
+      sequence_push(&(t->labels_values), label_value);
 
       getForwardslash(in);
       getRAnglebracket(in);
@@ -1397,6 +1401,10 @@ void freeType(type_descriptor_t * tp)
       free(tp->labels.array[pos2]);
     }
     sequence_dispose(&(tp->labels));
+    for(pos2 = 0; pos2 < tp->labels_values.position; pos2++) {
+      free(tp->labels_values.array[pos2]);
+    }
+    sequence_dispose(&(tp->labels_values));
   }
   if(tp->type == STRUCT) {
     for(pos2 = 0; pos2 < tp->fields.position; pos2++) {
index cf90b7a7814e4023a8db48c9a7aae08c27e6d04a..810c46cb3ee0394d458f60f5c8a8b829ebd1e086 100644 (file)
@@ -107,6 +107,7 @@ typedef struct _type_descriptor {
   char *fmt;
   size_t size;
   sequence_t labels; // for enumeration
+  sequence_t labels_values; // for enumeration
        sequence_t labels_description;
        int     already_printed;
   sequence_t fields; // for structure, array and sequence
@@ -139,7 +140,7 @@ typedef struct _facility {
        char * capname;
   char * description;
   sequence_t events;
-  sequence_t unnamed_types;
+  sequence_t unnamed_types; //FIXME : remove
   table_t named_types;
        unsigned int checksum;
 } facility_t;
This page took 0.026153 seconds and 4 git commands to generate.