X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=formats%2Fctf%2Fmetadata%2Fctf-visitor-xml.c;h=7f08031a1e08a579b68af62ebcee97a34f645f5e;hp=a4d8549f280aa22a3ee116ad54a568b9cb6d245c;hb=7d4192cb80178ad534e460d56f67e55679c7d8ee;hpb=fe41395a55903f52ae9c6abf1d95c2a903a97ce0 diff --git a/formats/ctf/metadata/ctf-visitor-xml.c b/formats/ctf/metadata/ctf-visitor-xml.c index a4d8549f..7f08031a 100644 --- a/formats/ctf/metadata/ctf-visitor-xml.c +++ b/formats/ctf/metadata/ctf-visitor-xml.c @@ -22,15 +22,17 @@ #include #include #include +#include #include #include #include "ctf-scanner.h" #include "ctf-parser.h" #include "ctf-ast.h" -#define printf_dbg(fmt, args...) fprintf(stderr, "%s: " fmt, __func__, ## args) +#define fprintf_dbg(fd, fmt, args...) fprintf(fd, "%s: " fmt, __func__, ## args) -static void print_tabs(FILE *fd, int depth) +static +void print_tabs(FILE *fd, int depth) { int i; @@ -38,6 +40,7 @@ static void print_tabs(FILE *fd, int depth) fprintf(fd, "\t"); } +static int ctf_visitor_print_unary_expression(FILE *fd, int depth, struct ctf_node *node) { int ret = 0; @@ -73,34 +76,34 @@ int ctf_visitor_print_unary_expression(FILE *fd, int depth, struct ctf_node *nod case UNARY_SIGNED_CONSTANT: print_tabs(fd, depth); fprintf(fd, "u.unary_expression.u.signed_constant); + fprintf(fd, "%" PRId64, node->u.unary_expression.u.signed_constant); fprintf(fd, " />\n"); break; case UNARY_UNSIGNED_CONSTANT: print_tabs(fd, depth); fprintf(fd, "u.unary_expression.u.signed_constant); + fprintf(fd, "%" PRIu64, node->u.unary_expression.u.signed_constant); fprintf(fd, " />\n"); break; case UNARY_SBRAC: print_tabs(fd, depth); - fprintf(fd, ""); + fprintf(fd, "\n"); ret = ctf_visitor_print_unary_expression(fd, depth + 1, node->u.unary_expression.u.sbrac_exp); if (ret) return ret; print_tabs(fd, depth); - fprintf(fd, ""); + fprintf(fd, "\n"); break; case UNARY_NESTED: print_tabs(fd, depth); - fprintf(fd, ""); + fprintf(fd, "\n"); ret = ctf_visitor_print_unary_expression(fd, depth + 1, node->u.unary_expression.u.nested_exp); if (ret) return ret; print_tabs(fd, depth); - fprintf(fd, ""); + fprintf(fd, "\n"); break; case UNARY_UNKNOWN: @@ -112,6 +115,7 @@ int ctf_visitor_print_unary_expression(FILE *fd, int depth, struct ctf_node *nod return 0; } +static int ctf_visitor_print_type_specifier(FILE *fd, int depth, struct ctf_node *node) { print_tabs(fd, depth); @@ -149,7 +153,10 @@ int ctf_visitor_print_type_specifier(FILE *fd, int depth, struct ctf_node *node) fprintf(fd, "bool"); break; case TYPESPEC_COMPLEX: - fprintf(fd, "complex"); + fprintf(fd, "_Complex"); + break; + case TYPESPEC_IMAGINARY: + fprintf(fd, "_Imaginary"); break; case TYPESPEC_CONST: fprintf(fd, "const"); @@ -168,6 +175,7 @@ int ctf_visitor_print_type_specifier(FILE *fd, int depth, struct ctf_node *node) return 0; } +static int ctf_visitor_print_type_declarator(FILE *fd, int depth, struct ctf_node *node) { int ret = 0; @@ -210,13 +218,17 @@ int ctf_visitor_print_type_declarator(FILE *fd, int depth, struct ctf_node *node print_tabs(fd, depth); fprintf(fd, "\n"); } - if (node->u.type_declarator.u.nested.length) { + if (!cds_list_empty(&node->u.type_declarator.u.nested.length)) { print_tabs(fd, depth); fprintf(fd, "\n"); - ret = ctf_visitor_print_xml(fd, depth + 1, - node->u.type_declarator.u.nested.length); + } + cds_list_for_each_entry(iter, &node->u.type_declarator.u.nested.length, + siblings) { + ret = ctf_visitor_print_xml(fd, depth + 1, iter); if (ret) return ret; + } + if (!cds_list_empty(&node->u.type_declarator.u.nested.length)) { print_tabs(fd, depth); fprintf(fd, "\n"); } @@ -532,12 +544,18 @@ int ctf_visitor_print_xml(FILE *fd, int depth, struct ctf_node *node) fprintf(fd, "\n"); depth++; - if (node->u._enum.container_type) { + if (!cds_list_empty(&node->u._enum.container_type)) { print_tabs(fd, depth); fprintf(fd, "\n"); - ret = ctf_visitor_print_xml(fd, depth + 1, node->u._enum.container_type); + } + + cds_list_for_each_entry(iter, &node->u._enum.container_type, + siblings) { + ret = ctf_visitor_print_xml(fd, depth + 1, iter); if (ret) return ret; + } + if (!cds_list_empty(&node->u._enum.container_type)) { print_tabs(fd, depth); fprintf(fd, "\n"); }