From: compudj Date: Mon, 6 Jun 2005 13:42:05 +0000 (+0000) Subject: add enum description support X-Git-Tag: v0.12.20~2551 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=8c6ca411f1f7dc33394552044fcfc0bed6e961b4;p=lttv.git add enum description support git-svn-id: http://ltt.polymtl.ca/svn@938 04897980-b3bd-0310-b5e0-8ef037075253 --- diff --git a/genevent/genevent.c b/genevent/genevent.c index 14bc6ddd..5adf8788 100644 --- a/genevent/genevent.c +++ b/genevent/genevent.c @@ -175,10 +175,7 @@ void generateFile(char *name){ fprintf(hFp, "#endif //_LTT_FACILITY_%s_H_\n",fac->capname); /* generate .h file, calls to register the facility at init time */ - fprintf(lFp, "#ifndef _LTT_FACILITY_LOADER_%s_H_\n",fac->capname); - fprintf(lFp, "#define _LTT_FACILITY_LOADER_%s_H_\n\n",fac->capname); - generateLoaderfile(lFp,fac->name,nbEvent,checksum); - fprintf(lFp, "#endif //_LTT_FACILITY_LOADER_%s_H_\n",fac->capname); + generateLoaderfile(lFp,fac->name,nbEvent,checksum,fac->capname); fclose(hFp); fclose(lFp); @@ -316,9 +313,13 @@ void generateEnumDefinition(FILE * fp, type_descriptor * type){ fprintf(fp,"enum {\n"); for(pos = 0; pos < type->labels.position; pos++){ fprintf(fp,"\t%s", type->labels.array[pos]); - if (pos != type->labels.position - 1) fprintf(fp,",\n"); + if (pos != type->labels.position - 1) fprintf(fp,","); + if(type->labels_description.array[pos] != NULL) + fprintf(fp,"\t/* %s */\n",type->labels_description.array[pos]); + else + fprintf(fp,"\n"); } - fprintf(fp,"\n};\n\n\n"); + fprintf(fp,"};\n\n\n"); } /***************************************************************************** @@ -579,8 +580,11 @@ char * getTypeStr(type_descriptor * td){ * nbEvent : number of events in the facility * checksum : checksum for the facility ****************************************************************************/ -void generateLoaderfile(FILE * fp, char * facName, int nbEvent, unsigned long checksum){ - //will be removed later +void generateLoaderfile(FILE * fp, char * facName, int nbEvent, unsigned long checksum, char *capname){ + fprintf(fp, "#ifndef _LTT_FACILITY_LOADER_%s_H_\n",capname); + fprintf(fp, "#define _LTT_FACILITY_LOADER_%s_H_\n\n",capname); + fprintf(fp,"#include \n", facName, checksum); + fprintf(fp,"#include \n\n", facName, checksum); fprintf(fp,"ltt_facility_t\tltt_facility_%s_%X;\n\n", facName, checksum); fprintf(fp,"EXPORT_SYMBOL(ltt_facility_%s_%X);\n\n",facName, checksum); @@ -589,6 +593,7 @@ void generateLoaderfile(FILE * fp, char * facName, int nbEvent, unsigned long ch fprintf(fp,"#define LTT_FACILITY_CHECKSUM\t\t\t0x%X\n", checksum); fprintf(fp,"#define LTT_FACILITY_NAME\t\t\t\t\t\"%s\"\n", facName); fprintf(fp,"#define LTT_FACILITY_NUM_EVENTS\t\t%d\n\n", nbEvent); + fprintf(fp, "#endif //_LTT_FACILITY_LOADER_%s_H_\n",capname); } diff --git a/genevent/genevent.h b/genevent/genevent.h index 991985fd..11ffda0d 100644 --- a/genevent/genevent.h +++ b/genevent/genevent.h @@ -4,7 +4,7 @@ void generateHfile(FILE *); void generateTypeDefs(FILE *); void generateEnumEvent(FILE * fp,char * facName, int * nbEvent, unsigned long checksum); void generateStructFunc(FILE * fp, char * facName, unsigned long checksum); -void generateLoaderfile(FILE * fp, char * facName, int nbEvent, unsigned long checksum); +void generateLoaderfile(FILE * fp, char * facName, int nbEvent, unsigned long checksum, char *capname); void generateEnumDefinition(FILE * fp, type_descriptor * fHead); char * getTypeStr(type_descriptor * td); diff --git a/genevent/parser.c b/genevent/parser.c index fe0e0147..5a756211 100644 --- a/genevent/parser.c +++ b/genevent/parser.c @@ -513,6 +513,7 @@ type_descriptor *parseType(parse_file *in, type_descriptor *inType, char * str, *str1; t->type = ENUM; sequence_init(&(t->labels)); + sequence_init(&(t->labels_description)); t->size = getSizeAttribute(in); t->fmt = allocAndCopy(getFormatAttribute(in)); getRAnglebracket(in); @@ -524,17 +525,22 @@ type_descriptor *parseType(parse_file *in, type_descriptor *inType, 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); + str1 = appendString(str,"="); + free(str); + str = appendString(str1,token); + free(str1); + sequence_push(&(t->labels),str); + } + else + sequence_push(&(t->labels),str); getForwardslash(in); getRAnglebracket(in); + //read description if any. May be NULL. + str = allocAndCopy(getDescription(in)); + sequence_push(&(t->labels_description),str); + //next label definition getLAnglebracket(in); token = getToken(in); //"label" or "/" @@ -542,7 +548,7 @@ type_descriptor *parseType(parse_file *in, type_descriptor *inType, if(strcmp("/",token))in->error(in, "not a valid enum definition"); token = getName(in); if(strcmp("enum",token))in->error(in, "not a valid enum definition"); - getRAnglebracket(in); // + getRAnglebracket(in); // } else if(strcmp(token,"int") == 0) { t->type = INT; diff --git a/genevent/parser.h b/genevent/parser.h index 368d656e..5383b11a 100644 --- a/genevent/parser.h +++ b/genevent/parser.h @@ -103,6 +103,7 @@ typedef struct _type_descriptor { char *fmt; int size; sequence labels; // for enumeration + sequence labels_description; sequence fields; // for structure struct _type_descriptor *nested_type; // for array and sequence } type_descriptor;