use long for trap id
[lttv.git] / genevent-new / parser.c
index a2a07e212c054adaca1dea3b9e95152b6a3f91aa..425d390cfa9745bddce0bdf286ddfeb4fcb8811c 100644 (file)
@@ -3,14 +3,15 @@
 parser.c: Generate helper declarations and functions to trace events
   from an event description file.
 
-Copyright (C) 2002, Xianxiu Yang
-Copyright (C) 2002, Michel Dagenais 
-This program is free software; you can redistribute it and/or modify
+           Copyright (C) 2005, Mathieu Desnoyers
+      Copyright (C) 2002, Xianxiu Yang
+      Copyright (C) 2002, Michel Dagenais 
+   This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-the Free Software Foundation; version 2 of the License.
+   the Free Software Foundation; version 2 of the License.
 
-This program is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
 
@@ -557,11 +558,6 @@ void parseFields(parse_file_t *in, field_t *f,
   getLAnglebracket(in);
   f->type = parseType(in,NULL, unnamed_types, named_types);
 
-       /* Those will be set later by preset_field_type_size */
-       f->fixed_root = FIELD_UNKNOWN;
-       f->fixed_parent = FIELD_UNKNOWN;
-       f->fixed_size = FIELD_UNKNOWN;
-
        if(tag) {
                getLAnglebracket(in);
                getForwardslash(in);
@@ -664,7 +660,7 @@ type_descriptor_t *parseType(parse_file_t *in, type_descriptor_t *inType,
     getForwardslash(in);
     getRAnglebracket(in); //<array size=n>
 
-    getLAnglebracket(in); //<subtype> 
+    //getLAnglebracket(in); //<subtype> 
                /* subfield */
                f = (field_t *)memAlloc(sizeof(field_t));
                sequence_push(&(t->fields),f);
@@ -686,13 +682,13 @@ type_descriptor_t *parseType(parse_file_t *in, type_descriptor_t *inType,
     //getForwardslash(in);
     getRAnglebracket(in); //<sequence>
 
-    getLAnglebracket(in); //<sequence size type> 
+    //getLAnglebracket(in); //<sequence size type> 
                /* subfield */
                f = (field_t *)memAlloc(sizeof(field_t));
                sequence_push(&(t->fields),f);
     parseFields(in, f, unnamed_types, named_types, 0);
 
-    getLAnglebracket(in); //<subtype> 
+    //getLAnglebracket(in); //<subtype> 
                /* subfield */
                f = (field_t *)memAlloc(sizeof(field_t));
                sequence_push(&(t->fields),f);
@@ -905,16 +901,22 @@ type_descriptor_t * find_named_type(char *name, table_t * named_types)
   type_descriptor_t *t;
 
   t = table_find(named_types,name);
-  if(t == NULL) {
-    t = (type_descriptor_t *)memAlloc(sizeof(type_descriptor_t));
-    t->type_name = allocAndCopy(name);
-    t->type = NONE;
-    t->fmt = NULL;
-    table_insert(named_types,t->type_name,t);
-    //    table_insert(named_types,allocAndCopy(name),t);
-  }
+
   return t;
-}  
+}
+
+type_descriptor_t * create_named_type(char *name, table_t * named_types)
+{
+  type_descriptor_t *t;
+
+       t = (type_descriptor_t *)memAlloc(sizeof(type_descriptor_t));
+       t->type_name = allocAndCopy(name);
+       t->type = NONE;
+       t->fmt = NULL;
+       table_insert(named_types,t->type_name,t);
+       //    table_insert(named_types,allocAndCopy(name),t);
+       return t;
+}
 
 /*****************************************************************************
  *Function name
@@ -933,7 +935,7 @@ void parseTypeDefinition(parse_file_t * in, sequence_t * unnamed_types,
 
   token = getNameAttribute(in);
   if(token == NULL) in->error(in, "Type has empty name");
-  t = find_named_type(token, named_types);
+  t = create_named_type(token, named_types);
 
   if(t->type != NONE) in->error(in,"redefinition of named type");
   getRAnglebracket(in); //<type name=type_name>
@@ -1232,7 +1234,7 @@ void checkNamedTypesImplemented(table_t * named_types)
  ****************************************************************************/
 
 void generateChecksum(char* facName,
-    unsigned long * checksum, sequence_t * events)
+    unsigned int * checksum, sequence_t * events)
 {
   unsigned long crc ;
   int pos;
@@ -1336,12 +1338,12 @@ unsigned long getTypeChecksum(unsigned long aCrc, type_descriptor_t * type)
       flag = 1;
       break;
     case ARRAY:
-      sprintf(buf,"%llu", type->size);
+      sprintf(buf,"%zu", type->size);
       str = appendString("array ",buf);
       flag = 1;
       break;
     case SEQUENCE:
-      sprintf(buf,"%llu", type->size);
+      sprintf(buf,"%zu", type->size);
       str = appendString("sequence ",buf);
       flag = 1;
       break;
@@ -1363,9 +1365,12 @@ unsigned long getTypeChecksum(unsigned long aCrc, type_descriptor_t * type)
 
   if(type->fmt) crc = partial_crc32(type->fmt,crc);
     
-  if(type->type == ARRAY || type->type == SEQUENCE){
-    crc = getTypeChecksum(crc,type->nested_type);
-  }else if(type->type == STRUCT || type->type == UNION){
+  if(type->type == ARRAY){
+    crc = getTypeChecksum(crc,((field_t*)type->fields.array[0])->type);
+  } else if(type->type ==SEQUENCE) {
+    crc = getTypeChecksum(crc,((field_t*)type->fields.array[0])->type);
+    crc = getTypeChecksum(crc,((field_t*)type->fields.array[1])->type);
+       } else if(type->type == STRUCT || type->type == UNION){
     for(pos =0; pos < type->fields.position; pos++){
       fld = (field_t *) type->fields.array[pos];
       crc = partial_crc32(fld->name,crc);
This page took 0.030733 seconds and 4 git commands to generate.