2003-12-11 14:46:13 -05:00
|
|
|
Index: Source/Swig/swig.h
|
2003-12-11 14:07:00 -05:00
|
|
|
===================================================================
|
|
|
|
RCS file: /cvsroot/SWIG/Source/Swig/swig.h,v
|
2004-01-22 17:31:34 -05:00
|
|
|
retrieving revision 1.79
|
|
|
|
diff -u -4 -r1.79 swig.h
|
|
|
|
--- Source/Swig/swig.h 15 Jan 2004 22:46:07 -0000 1.79
|
|
|
|
+++ Source/Swig/swig.h 22 Jan 2004 01:57:53 -0000
|
|
|
|
@@ -354,8 +354,10 @@
|
2003-12-11 14:07:00 -05:00
|
|
|
extern void Swig_print_tags(File *obj, Node *root);
|
|
|
|
extern void Swig_print_tree(Node *obj);
|
|
|
|
extern void Swig_print_node(Node *obj);
|
|
|
|
|
|
|
|
+extern void Swig_print_xml(Node *obj, String* filename);
|
|
|
|
+
|
|
|
|
/* -- Wrapper function Object */
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
Hash *localh;
|
|
|
|
Index: Source/Modules/main.cxx
|
|
|
|
===================================================================
|
|
|
|
RCS file: /cvsroot/SWIG/Source/Modules/main.cxx,v
|
2004-01-22 17:31:34 -05:00
|
|
|
retrieving revision 1.32
|
|
|
|
diff -u -4 -r1.32 main.cxx
|
|
|
|
--- Source/Modules/main.cxx 15 Jan 2004 22:46:05 -0000 1.32
|
|
|
|
+++ Source/Modules/main.cxx 22 Jan 2004 01:57:53 -0000
|
|
|
|
@@ -94,15 +94,17 @@
|
|
|
|
-w+321,401,-402 \n\
|
|
|
|
\n\
|
|
|
|
where code 321(+) is added, and 401(no sign) and 402(-) \n\
|
|
|
|
are suppressed. See documentation for code meanings.\n\
|
2003-12-11 14:25:33 -05:00
|
|
|
+ -xmlout <file> - Write an XML version of the parse tree to file after normal processing\n\
|
2003-12-11 14:07:00 -05:00
|
|
|
\n";
|
|
|
|
|
|
|
|
// Local variables
|
|
|
|
static int freeze = 0;
|
|
|
|
static String *lang_config = 0;
|
|
|
|
static char *cpp_extension = (char *) "cxx";
|
|
|
|
static String *outdir = 0;
|
|
|
|
+static String *xmlout = 0;
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// check_suffix(char *name)
|
|
|
|
//
|
2004-01-22 17:31:34 -05:00
|
|
|
@@ -218,8 +220,9 @@
|
|
|
|
char *includefiles[256];
|
2003-12-11 14:07:00 -05:00
|
|
|
int includecount = 0;
|
|
|
|
int dump_tags = 0;
|
|
|
|
int dump_tree = 0;
|
|
|
|
+ int dump_xml = 0;
|
|
|
|
int browse = 0;
|
|
|
|
int dump_typedef = 0;
|
|
|
|
int dump_classes = 0;
|
|
|
|
int werror = 0;
|
2004-01-22 17:31:34 -05:00
|
|
|
@@ -486,8 +489,20 @@
|
2003-12-11 14:07:00 -05:00
|
|
|
Swig_mark_arg(i);
|
|
|
|
} else if (strcmp(argv[i],"-dump_tree") == 0) {
|
|
|
|
dump_tree = 1;
|
|
|
|
Swig_mark_arg(i);
|
|
|
|
+ } else if (strcmp(argv[i],"-dump_xml") == 0) {
|
|
|
|
+ dump_xml = 1;
|
|
|
|
+ Swig_mark_arg(i);
|
|
|
|
+ } else if (strcmp(argv[i],"-xmlout") == 0) {
|
|
|
|
+ dump_xml = 1;
|
|
|
|
+ Swig_mark_arg(i);
|
|
|
|
+ if (argv[i+1]) {
|
|
|
|
+ xmlout = NewString(argv[i+1]);
|
|
|
|
+ Swig_mark_arg(i+1);
|
|
|
|
+ } else {
|
|
|
|
+ Swig_arg_error();
|
|
|
|
+ }
|
|
|
|
} else if (strcmp(argv[i],"-nocontract") == 0) {
|
|
|
|
Swig_mark_arg(i);
|
|
|
|
Swig_contract_mode_set(0);
|
|
|
|
} else if (strcmp(argv[i],"-browse") == 0) {
|
2004-01-22 17:31:34 -05:00
|
|
|
@@ -737,8 +752,11 @@
|
2003-12-11 14:07:00 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (dump_tree) {
|
|
|
|
Swig_print_tree(top);
|
|
|
|
+ }
|
|
|
|
+ if (dump_xml) {
|
|
|
|
+ Swig_print_xml(top, xmlout);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (tm_debug) Swig_typemap_debug();
|
|
|
|
if (memory_debug) DohMemoryDebug();
|
|
|
|
Index: Source/Modules/xml.cxx
|
|
|
|
===================================================================
|
|
|
|
RCS file: /cvsroot/SWIG/Source/Modules/xml.cxx,v
|
2004-01-22 17:31:34 -05:00
|
|
|
retrieving revision 1.9
|
|
|
|
diff -u -4 -r1.9 xml.cxx
|
|
|
|
--- Source/Modules/xml.cxx 28 Dec 2003 21:47:58 -0000 1.9
|
|
|
|
+++ Source/Modules/xml.cxx 22 Jan 2004 01:57:53 -0000
|
2003-12-11 14:46:13 -05:00
|
|
|
@@ -109,9 +109,9 @@
|
2003-12-11 14:07:00 -05:00
|
|
|
Printf(stderr,"*** Can't open '%s'\n", outfile);
|
|
|
|
SWIG_exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
- Printf( out, "<?xml version=\"1.0\" ?> \n" );
|
2003-12-11 14:46:13 -05:00
|
|
|
+ Printf( out, "<?xml version=\"1.0\" ?> \n" );
|
2003-12-11 14:07:00 -05:00
|
|
|
Xml_print_tree(n);
|
|
|
|
return SWIG_OK;
|
|
|
|
}
|
|
|
|
|
2003-12-11 14:46:13 -05:00
|
|
|
@@ -197,18 +197,19 @@
|
2003-12-11 14:07:00 -05:00
|
|
|
Replaceall( o, "&", "&" );
|
|
|
|
Replaceall( o, "<", "<" );
|
|
|
|
Replaceall( o, "\"", """ );
|
|
|
|
Replaceall( o, "\\", "\\\\" );
|
|
|
|
- Printf(out,"<attribute name=\"%s\" value=\"%s\" id=\"%ld\" addr=\"%x\" />\n", ck, o, ++id, o );
|
|
|
|
+ Replaceall( o, "\n", " " );
|
|
|
|
+ Printf(out,"<attribute name=\"%s\" value=\"%s\" id=\"%ld\" addr=\"%x\" />\n", ck, o, ++id, o );
|
|
|
|
Delete(o);
|
|
|
|
Delete(ck);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
o = Getattr(obj,k);
|
|
|
|
String *ck = NewString(k);
|
|
|
|
Replaceall( ck, ":", "_" );
|
|
|
|
- Printf(out,"<attribute name=\"%s\" value=\"%x\" id=\"%ld\" addr=\"%x\" />\n", ck, o, ++id, o );
|
|
|
|
+ Printf(out,"<attribute name=\"%s\" value=\"%x\" id=\"%ld\" addr=\"%x\" />\n", ck, o, ++id, o );
|
|
|
|
Delete(ck);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ki = Next(ki);
|
2003-12-11 14:46:13 -05:00
|
|
|
@@ -318,11 +319,10 @@
|
2003-12-11 14:07:00 -05:00
|
|
|
{
|
|
|
|
print_indent(0);
|
|
|
|
Printf( out, "<%ssitem id=\"%ld\" addr=\"%x\" >\n", markup, ++id, n.item );
|
|
|
|
Xml_print_attributes( n.item );
|
|
|
|
- Printf( out, "</%ssitem >\n", markup );
|
|
|
|
print_indent(0);
|
|
|
|
- Printf( out, " />\n" );
|
|
|
|
+ Printf( out, "</%ssitem >\n", markup );
|
|
|
|
n = Next(n);
|
|
|
|
}
|
|
|
|
indent_level -= 4;
|
|
|
|
print_indent(0);
|
2004-01-22 17:31:34 -05:00
|
|
|
@@ -334,5 +334,36 @@
|
|
|
|
|
|
|
|
extern "C" Language *
|
|
|
|
swig_xml( void ) {
|
|
|
|
return new XML();
|
2003-12-11 14:07:00 -05:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+/* -----------------------------------------------------------------------------
|
|
|
|
+ * Swig_print_xml
|
|
|
|
+ *
|
|
|
|
+ * Dump an XML version of the parse tree. This is different from using the -xml
|
|
|
|
+ * language module normally as it allows the real language module to process the
|
|
|
|
+ * tree first, possibly stuffing in new attributes, so the XML that is output ends
|
|
|
|
+ * up being a post-processing version of the tree.
|
|
|
|
+ * ----------------------------------------------------------------------------- */
|
|
|
|
+
|
|
|
|
+void
|
|
|
|
+Swig_print_xml(DOH *obj, String* filename)
|
|
|
|
+{
|
|
|
|
+ XML xml;
|
|
|
|
+ xmllite = 1;
|
|
|
|
+
|
|
|
|
+ if (! filename) {
|
|
|
|
+ out = stdout;
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ out = NewFile(filename, "w");
|
|
|
|
+ if (!out) {
|
|
|
|
+ Printf(stderr,"*** Can't open '%s'\n", filename);
|
|
|
|
+ SWIG_exit(EXIT_FAILURE);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Printf( out, "<?xml version=\"1.0\" ?> \n" );
|
|
|
|
+ xml.Xml_print_tree(obj);
|
|
|
|
}
|