parser.c fix for enums
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 26 Jan 2006 19:52:20 +0000 (19:52 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 26 Jan 2006 19:52:20 +0000 (19:52 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@1494 04897980-b3bd-0310-b5e0-8ef037075253

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

index aba40e528d204b411c2dcef8c54ec93d245b85e7..04be9cd8701c9543ceba003a335be0b71d49c050 100644 (file)
@@ -386,6 +386,8 @@ int print_type_declaration(type_descriptor_t * td, FILE *fd, unsigned int tabs,
        char basename[PATH_MAX];
        unsigned int basename_len = 0;
        
+       if(td->custom_write) return 0;  /* Does print custom type */
+       
        strncpy(basename, nest_name, PATH_MAX);
        basename_len = strlen(basename);
        
@@ -666,6 +668,7 @@ int print_type_write(type_descriptor_t * td, FILE *fd, unsigned int tabs,
        char basename[PATH_MAX];
        unsigned int basename_len = 0;
        char get_ptr_char[2] = "";
+       char custom[PATH_MAX] = "";
        
        strncpy(basename, nest_name, PATH_MAX);
        basename_len = strlen(basename);
@@ -690,6 +693,10 @@ int print_type_write(type_descriptor_t * td, FILE *fd, unsigned int tabs,
                strcpy(get_ptr_char, "&");
        }
 
+       if(td->custom_write) {
+               strcpy(custom, "_custom");
+       }
+
        switch(td->type) {
                case INT_FIXED:
                case UINT_FIXED:
@@ -734,32 +741,32 @@ int print_type_write(type_descriptor_t * td, FILE *fd, unsigned int tabs,
                case STRING:
                        print_tabs(tabs, fd);
                        fprintf(fd,
-                                       "lttng_write_string_%s(buffer, to_base, to, from, len, %s%s);\n",
-                                       basename, obj_prefix, field_name);
+                                       "lttng_write%s_string_%s(buffer, to_base, to, from, len, %s%s);\n",
+                                       custom, basename, obj_prefix, field_name);
                        break;
                case SEQUENCE:
                        print_tabs(tabs, fd);
                        fprintf(fd,
-                                       "lttng_write_sequence_%s(buffer, to_base, to, from, len, %s%s%s);",
-                                       basename, get_ptr_char, obj_prefix, field_name);
+                                       "lttng_write%s_sequence_%s(buffer, to_base, to, from, len, %s%s%s);",
+                                       custom, basename, get_ptr_char, obj_prefix, field_name);
                        break;
                case STRUCT:
                        print_tabs(tabs, fd);
                        fprintf(fd,
-                                       "lttng_write_struct_%s(buffer, to_base, to, from, len, %s%s%s);",
-                                       basename, get_ptr_char, obj_prefix, field_name);
+                                       "lttng_write%s_struct_%s(buffer, to_base, to, from, len, %s%s%s);",
+                                       custom, basename, get_ptr_char, obj_prefix, field_name);
                        break;
                case UNION:
                        print_tabs(tabs, fd);
                        fprintf(fd,
-                                       "lttng_write_union_%s(buffer, to_base, to, from, len, %s%s%s);",
-                                       basename, get_ptr_char, obj_prefix, field_name);
+                                       "lttng_write%s_union_%s(buffer, to_base, to, from, len, %s%s%s);",
+                                       custom, basename, get_ptr_char, obj_prefix, field_name);
                        break;
                case ARRAY:
                        print_tabs(tabs, fd);
                        fprintf(fd,
-                                       "lttng_write_array_%s(buffer, to_base, to, from, len, %s%s);",
-                                       basename, obj_prefix, field_name);
+                                       "lttng_write%s_array_%s(buffer, to_base, to, from, len, %s%s);",
+                                       custom, basename, obj_prefix, field_name);
                        break;
                case NONE:
                        printf("Error : type NONE unexpected\n");
@@ -831,6 +838,8 @@ int print_type_alignment_fct(type_descriptor_t * td, FILE *fd,
        char basename[PATH_MAX];
        unsigned int basename_len = 0;
        
+       if(td->custom_write) return 0;  /* Does print custom type */
+
        strncpy(basename, nest_name, PATH_MAX);
        basename_len = strlen(basename);
        
@@ -977,6 +986,8 @@ int print_type_write_fct(type_descriptor_t * td, FILE *fd, unsigned int tabs,
        char basename[PATH_MAX];
        unsigned int basename_len = 0;
        
+       if(td->custom_write) return 0;  /* Does print custom type */
+
        strncpy(basename, nest_name, PATH_MAX);
        basename_len = strlen(basename);
        
index 6dbf402d76fd4f008f8d8c5cce17378df0617b15..785cb652aaf2a47e7771024817649956274c6f28 100644 (file)
@@ -182,6 +182,7 @@ void getTypeAttributes(parse_file_t *in, type_descriptor_t *t,
 
   t->fmt = NULL;
   t->size = 0;
+  t->custom_write = 0;
   
   while(1) {
     token = getToken(in); 
@@ -202,6 +203,8 @@ void getTypeAttributes(parse_file_t *in, type_descriptor_t *t,
     } else if(!strcmp("size",token)) {
       getEqual(in);
       t->size = getSize(in);
+    } else if(!strcmp("custom_write", token)) {
+      t->custom_write = 1;
     }
   }
 }
@@ -335,22 +338,20 @@ char *getNameAttribute(parse_file_t *in)
   
   while(1) {
     token = getToken(in); 
-    if(strcmp("/",token) == 0 || strcmp(">",token) == 0){
-      ungetToken(in);
-      break;
-    }
-
     if(!strcmp("name",token)) {
       getEqual(in);
       car = seekNextChar(in);
       if(car == EOF) in->error(in,"name was expected");
       else if(car == '\"') name = allocAndCopy(getQuotedString(in));
       else name = allocAndCopy(getName(in));
+    } else {
+      ungetToken(in);
+      break;
     }
+
   }
   if(name == NULL) in->error(in, "Name was expected");
   return name;
-  
 }
 
 
@@ -680,8 +681,8 @@ type_descriptor_t *parseType(parse_file_t *in, type_descriptor_t *inType,
   else if(strcmp(token,"sequence") == 0) {
     t->type = SEQUENCE;
     sequence_init(&(t->fields));
-    //getTypeAttributes(in, t, unnamed_types, named_types);
-    //getForwardslash(in);
+    getTypeAttributes(in, t, unnamed_types, named_types);
+    getForwardslash(in);
     getRAnglebracket(in); //<sequence>
 
     //getLAnglebracket(in); //<sequence size type> 
index 4215f286cd82077ad90b90df4a49ed305d88c345..5a4c5b02cb1e41fd884be1de3de633508d9a45d6 100644 (file)
@@ -111,6 +111,7 @@ typedef struct _type_descriptor {
        sequence_t labels_description;
        int     already_printed;
   sequence_t fields; // for structure, array and sequence (field_t type)
+  int  custom_write;  /* Should we use a custom write function ? */
 } type_descriptor_t;
 
 
This page took 0.029674 seconds and 4 git commands to generate.