add enum description support
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Mon, 6 Jun 2005 13:42:05 +0000 (13:42 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Mon, 6 Jun 2005 13:42:05 +0000 (13:42 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@938 04897980-b3bd-0310-b5e0-8ef037075253

genevent/genevent.c
genevent/genevent.h
genevent/parser.c
genevent/parser.h

index 14bc6ddd720d2b061ba74ad26e64cf8e8d25e85d..5adf87885fe9af8237f7c14e3bafc6ee5248754d 100644 (file)
@@ -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 <linux/ltt-facilities.h>\n", facName, checksum);
+  fprintf(fp,"#include <linux/module.h>\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);
 }
 
 
index 991985fd1e27c6541566e4b9ecf6b2e0c602acf1..11ffda0d914076810886bd9f8fb1ff0c02ca48e4 100644 (file)
@@ -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);
 
index fe0e01470d182b4997afe4525f287d6d2eb15e53..5a756211a8dd9b01f23fba8cc6132c13ded61441 100644 (file)
@@ -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); //</label>
+      getRAnglebracket(in); //</label>
   }
   else if(strcmp(token,"int") == 0) {
     t->type = INT;
index 368d656e1d608862af6d2e958f5933ec45e480f1..5383b11ad8c575602a043dba64a39c15e642bff8 100644 (file)
@@ -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;
This page took 0.027389 seconds and 4 git commands to generate.