1 Index: Source/Swig/swig.h
2 ===================================================================
3 RCS file: /cvsroot/SWIG/Source/Swig/swig.h,v
4 retrieving revision 1.76
5 diff -u -4 -r1.76 swig.h
6 --- Source/Swig/swig.h 11 Nov 2003 20:16:35 -0000 1.76
7 +++ Source/Swig/swig.h 18 Dec 2003 22:03:45 -0000
9 extern void Swig_print_tags(File *obj, Node *root);
10 extern void Swig_print_tree(Node *obj);
11 extern void Swig_print_node(Node *obj);
13 +extern void Swig_print_xml(Node *obj, String* filename);
15 /* -- Wrapper function Object */
19 Index: Source/Modules/main.cxx
20 ===================================================================
21 RCS file: /cvsroot/SWIG/Source/Modules/main.cxx,v
22 retrieving revision 1.27
23 diff -u -4 -r1.27 main.cxx
24 --- Source/Modules/main.cxx 16 Dec 2003 03:43:51 -0000 1.27
25 +++ Source/Modules/main.cxx 18 Dec 2003 22:03:45 -0000
27 -Wall - Enable all warning messages\n\
28 -Wallkw - Enable warning messages for all the languages keywords\n\
29 -Werror - Force to treat the warnings as errors\n\
30 -w<n> - Suppress warning number <n>\n\
31 + -xmlout <file> - Write an XML version of the parse tree to file after normal processing\n\
35 static int freeze = 0;
36 static String *lang_config = 0;
37 static char *cpp_extension = (char *) "cxx";
38 static String *outdir = 0;
39 +static String *xmlout = 0;
41 // -----------------------------------------------------------------------------
42 // check_suffix(char *name)
46 extern int check_suffix(char *);
56 } else if (strcmp(argv[i],"-dump_tree") == 0) {
59 + } else if (strcmp(argv[i],"-dump_xml") == 0) {
62 + } else if (strcmp(argv[i],"-xmlout") == 0) {
66 + xmlout = NewString(argv[i+1]);
71 } else if (strcmp(argv[i],"-nocontract") == 0) {
73 Swig_contract_mode_set(0);
74 } else if (strcmp(argv[i],"-browse") == 0) {
82 + Swig_print_xml(top, xmlout);
85 if (tm_debug) Swig_typemap_debug();
86 if (memory_debug) DohMemoryDebug();
87 Index: Source/Modules/xml.cxx
88 ===================================================================
89 RCS file: /cvsroot/SWIG/Source/Modules/xml.cxx,v
90 retrieving revision 1.8
91 diff -u -4 -r1.8 xml.cxx
92 --- Source/Modules/xml.cxx 31 Oct 2003 17:42:40 -0000 1.8
93 +++ Source/Modules/xml.cxx 18 Dec 2003 22:03:45 -0000
95 Printf(stderr,"*** Can't open '%s'\n", outfile);
96 SWIG_exit(EXIT_FAILURE);
99 - Printf( out, "<?xml version=\"1.0\" ?> \n" );
100 + Printf( out, "<?xml version=\"1.0\" ?> \n" );
105 @@ -197,18 +197,19 @@
106 Replaceall( o, "&", "&" );
107 Replaceall( o, "<", "<" );
108 Replaceall( o, "\"", """ );
109 Replaceall( o, "\\", "\\\\" );
110 - Printf(out,"<attribute name=\"%s\" value=\"%s\" id=\"%ld\" addr=\"%x\" />\n", ck, o, ++id, o );
111 + Replaceall( o, "\n", " " );
112 + Printf(out,"<attribute name=\"%s\" value=\"%s\" id=\"%ld\" addr=\"%x\" />\n", ck, o, ++id, o );
119 String *ck = NewString(k);
120 Replaceall( ck, ":", "_" );
121 - Printf(out,"<attribute name=\"%s\" value=\"%x\" id=\"%ld\" addr=\"%x\" />\n", ck, o, ++id, o );
122 + Printf(out,"<attribute name=\"%s\" value=\"%x\" id=\"%ld\" addr=\"%x\" />\n", ck, o, ++id, o );
127 @@ -318,11 +319,10 @@
130 Printf( out, "<%ssitem id=\"%ld\" addr=\"%x\" >\n", markup, ++id, n.item );
131 Xml_print_attributes( n.item );
132 - Printf( out, "</%ssitem >\n", markup );
134 - Printf( out, " />\n" );
135 + Printf( out, "</%ssitem >\n", markup );
141 Language * swig_xml( void )
148 +/* -----------------------------------------------------------------------------
151 + * Dump an XML version of the parse tree. This is different from using the -xml
152 + * language module normally as it allows the real language module to process the
153 + * tree first, possibly stuffing in new attributes, so the XML that is output ends
154 + * up being a post-processing version of the tree.
155 + * ----------------------------------------------------------------------------- */
158 +Swig_print_xml(DOH *obj, String* filename)
167 + out = NewFile(filename, "w");
169 + Printf(stderr,"*** Can't open '%s'\n", filename);
170 + SWIG_exit(EXIT_FAILURE);
174 + Printf( out, "<?xml version=\"1.0\" ?> \n" );
175 + xml.Xml_print_tree(obj);