From: compudj Date: Thu, 26 Jan 2006 19:52:20 +0000 (+0000) Subject: parser.c fix for enums X-Git-Tag: v0.12.20~1995 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=64a6ab100d91bcccd1a5abcd4f507f3060d58817;p=lttv.git parser.c fix for enums git-svn-id: http://ltt.polymtl.ca/svn@1494 04897980-b3bd-0310-b5e0-8ef037075253 --- diff --git a/genevent-new/genevent.c b/genevent-new/genevent.c index aba40e52..04be9cd8 100644 --- a/genevent-new/genevent.c +++ b/genevent-new/genevent.c @@ -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); diff --git a/genevent-new/parser.c b/genevent-new/parser.c index 6dbf402d..785cb652 100644 --- a/genevent-new/parser.c +++ b/genevent-new/parser.c @@ -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); // //getLAnglebracket(in); // diff --git a/genevent-new/parser.h b/genevent-new/parser.h index 4215f286..5a4c5b02 100644 --- a/genevent-new/parser.h +++ b/genevent-new/parser.h @@ -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;