[GCC-XML]extra tags needed

Michael Santy mike.santy at dynetics.com
Tue Feb 12 11:03:00 EST 2002


Let me first say that the GCC-XML work has a lot of potential.  We are
planning on using it on production code in the company I work for.  However,
the XML output lacks a few attributes that we were needing.  The first thing
that was lacking was access information for fields in classes.  To enable
this output, change the print_variable_begin_tag to:

static void
print_variable_begin_tag (FILE* file, unsigned long indent, tree vd)
{
  const char* name = xml_get_encoded_string (DECL_NAME (vd));

  const char* access;
  int is_protected = TREE_PROTECTED(vd),
      is_private   = TREE_PRIVATE(vd);
  //TREE_PUBLIC(vd) always returns true for some reason, so we ignore it
  if(!is_protected && !is_private) {
    access = "public";
  }
  else if(is_private) {
    access = "private";
  }
  else if(is_protected) {
    access = "protected";
  }

  print_indent (file, indent);
  fprintf (file,
           "<Variable name=\"%s\" access=\"%s\">\n",
           name,
           access);
}

The second attribute that we were lacking involves retrieving values from
enumeration instances.  Suppose I have declared:

enum foo_enum { ITEM1=10, ITEM2=20, ITEM3=100 };

I want to be able to retrieve the values for ITEM1, ITEM2, and ITEM3,
instead of assuming that the elements are 0, 1, and 2, respectively.  I have
looked through gcc's "tree.h" and have found no way to access these values.
Does anybody have any suggestions.

Thanks a bunch,

Mike Santy




More information about the gccxml mailing list