]> git.saurik.com Git - wxWidgets.git/blob - wxPython/SWIG/swig.xmlout.patch
Updated the docstring patch to match current SWIG CVS line numbers and
[wxWidgets.git] / wxPython / SWIG / swig.xmlout.patch
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 11 Dec 2003 18:12:49 -0000
8 @@ -350,8 +350,10 @@
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);
12
13 +extern void Swig_print_xml(Node *obj, String* filename);
14 +
15 /* -- Wrapper function Object */
16
17 typedef struct {
18 Hash *localh;
19 Index: Source/Modules/main.cxx
20 ===================================================================
21 RCS file: /cvsroot/SWIG/Source/Modules/main.cxx,v
22 retrieving revision 1.23
23 diff -u -4 -r1.23 main.cxx
24 --- Source/Modules/main.cxx 8 Dec 2003 23:42:37 -0000 1.23
25 +++ Source/Modules/main.cxx 11 Dec 2003 18:12:50 -0000
26 @@ -85,15 +85,17 @@
27 -v - Run in verbose mode\n\
28 -version - Print SWIG version number\n\
29 -Wall - Enable all warning messages\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\
32 \n";
33
34 // Local variables
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;
40
41 // -----------------------------------------------------------------------------
42 // check_suffix(char *name)
43 //
44 @@ -222,8 +224,9 @@
45 int includecount = 0;
46 extern int check_suffix(char *);
47 int dump_tags = 0;
48 int dump_tree = 0;
49 + int dump_xml = 0;
50 int browse = 0;
51 int dump_typedef = 0;
52 int dump_classes = 0;
53 int werror = 0;
54 @@ -482,8 +485,20 @@
55 Swig_mark_arg(i);
56 } else if (strcmp(argv[i],"-dump_tree") == 0) {
57 dump_tree = 1;
58 Swig_mark_arg(i);
59 + } else if (strcmp(argv[i],"-dump_xml") == 0) {
60 + dump_xml = 1;
61 + Swig_mark_arg(i);
62 + } else if (strcmp(argv[i],"-xmlout") == 0) {
63 + dump_xml = 1;
64 + Swig_mark_arg(i);
65 + if (argv[i+1]) {
66 + xmlout = NewString(argv[i+1]);
67 + Swig_mark_arg(i+1);
68 + } else {
69 + Swig_arg_error();
70 + }
71 } else if (strcmp(argv[i],"-nocontract") == 0) {
72 Swig_mark_arg(i);
73 Swig_contract_mode_set(0);
74 } else if (strcmp(argv[i],"-browse") == 0) {
75 @@ -725,8 +740,11 @@
76 }
77 }
78 if (dump_tree) {
79 Swig_print_tree(top);
80 + }
81 + if (dump_xml) {
82 + Swig_print_xml(top, xmlout);
83 }
84 }
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 11 Dec 2003 18:12:50 -0000
94 @@ -24,9 +24,8 @@
95 //static Node *view_top = 0;
96 static File *out = 0;
97 static int xmllite = 0;
98
99 -
100 class XML
101 : public Language
102 {
103
104 @@ -109,9 +108,9 @@
105 Printf(stderr,"*** Can't open '%s'\n", outfile);
106 SWIG_exit(EXIT_FAILURE);
107 }
108 }
109 - Printf( out, "<?xml version=\"1.0\" ?> \n" );
110 + Printf( out, "<?xml version=\"1.0\" ?> \n" );
111 Xml_print_tree(n);
112 return SWIG_OK;
113 }
114
115 @@ -197,18 +196,19 @@
116 Replaceall( o, "&", "&amp;" );
117 Replaceall( o, "<", "&lt;" );
118 Replaceall( o, "\"", "&quot;" );
119 Replaceall( o, "\\", "\\\\" );
120 - Printf(out,"<attribute name=\"%s\" value=\"%s\" id=\"%ld\" addr=\"%x\" />\n", ck, o, ++id, o );
121 + Replaceall( o, "\n", "&#10;" );
122 + Printf(out,"<attribute name=\"%s\" value=\"%s\" id=\"%ld\" addr=\"%x\" />\n", ck, o, ++id, o );
123 Delete(o);
124 Delete(ck);
125 }
126 else
127 {
128 o = Getattr(obj,k);
129 String *ck = NewString(k);
130 Replaceall( ck, ":", "_" );
131 - Printf(out,"<attribute name=\"%s\" value=\"%x\" id=\"%ld\" addr=\"%x\" />\n", ck, o, ++id, o );
132 + Printf(out,"<attribute name=\"%s\" value=\"%x\" id=\"%ld\" addr=\"%x\" />\n", ck, o, ++id, o );
133 Delete(ck);
134 }
135 }
136 ki = Next(ki);
137 @@ -318,11 +318,10 @@
138 {
139 print_indent(0);
140 Printf( out, "<%ssitem id=\"%ld\" addr=\"%x\" >\n", markup, ++id, n.item );
141 Xml_print_attributes( n.item );
142 - Printf( out, "</%ssitem >\n", markup );
143 print_indent(0);
144 - Printf( out, " />\n" );
145 + Printf( out, "</%ssitem >\n", markup );
146 n = Next(n);
147 }
148 indent_level -= 4;
149 print_indent(0);
150 @@ -337,5 +336,36 @@
151 Language * swig_xml( void )
152 {
153 return new XML();
154 }
155 +}
156 +
157 +
158 +/* -----------------------------------------------------------------------------
159 + * Swig_print_xml
160 + *
161 + * Dump an XML version of the parse tree. This is different from using the -xml
162 + * language module normally as it allows the real language module to process the
163 + * tree first, possibly stuffing in new attributes, so the XML that is output ends
164 + * up being a post-processing version of the tree.
165 + * ----------------------------------------------------------------------------- */
166 +
167 +void
168 +Swig_print_xml(DOH *obj, String* filename)
169 +{
170 + XML xml;
171 + xmllite = 1;
172 +
173 + if (! filename) {
174 + out = stdout;
175 + }
176 + else {
177 + out = NewFile(filename, "w");
178 + if (!out) {
179 + Printf(stderr,"*** Can't open '%s'\n", filename);
180 + SWIG_exit(EXIT_FAILURE);
181 + }
182 + }
183 +
184 + Printf( out, "<?xml version=\"1.0\" ?> \n" );
185 + xml.Xml_print_tree(obj);
186 }