Updated the docstring patch to match current SWIG CVS line numbers and
such. Added swig.xmlout.patch, which fixes a couple problems in the XML output of SWIG: an extra "/>" was removed and newlines in attribute values were changed to the #10; entity reference so they will be preserved by parsers. Also, added options for dumping or writing to a file the XML of the parse tree *after* other language modules have been run (previously you could only do the XML output *instead of* a regular language module.) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24774 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -14,11 +14,24 @@ source tree soon.
|
|||||||
|
|
||||||
swig.python-docstring.patch Adds "autodoc" and "docstring" features.
|
swig.python-docstring.patch Adds "autodoc" and "docstring" features.
|
||||||
|
|
||||||
|
swig.xmlout.patch Fixes a couple problems in the XML output
|
||||||
|
of SWIG: an extra "/>" was removed and
|
||||||
|
newlines in attribute values were changed
|
||||||
|
to the #10; entity reference so they will
|
||||||
|
be preserved by parsers.
|
||||||
|
|
||||||
|
Also, added options for dumping or
|
||||||
|
writing to a file the XML of the parse
|
||||||
|
tree *after* other language modules have
|
||||||
|
been run (previously you could only do
|
||||||
|
the XML output *instead of* a regular
|
||||||
|
language module.)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
These patches have already been checked in to SWIG's CVS
|
These patches have already been checked in to SWIG's CVS and will be
|
||||||
|
in the 1.3.20 release.
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
swig.SplitLines.patch Adds a new SplitLines function to the DOH
|
swig.SplitLines.patch Adds a new SplitLines function to the DOH
|
||||||
|
@@ -1,16 +1,15 @@
|
|||||||
Index: Source/Modules/python.cxx
|
Index: Source/Modules/python.cxx
|
||||||
===================================================================
|
===================================================================
|
||||||
RCS file: /cvsroot/SWIG/Source/Modules/python.cxx,v
|
RCS file: /cvsroot/SWIG/Source/Modules/python.cxx,v
|
||||||
retrieving revision 1.28
|
retrieving revision 1.33
|
||||||
diff -u -4 -r1.28 python.cxx
|
diff -u -4 -r1.33 python.cxx
|
||||||
--- Source/Modules/python.cxx 18 Nov 2003 20:19:15 -0000 1.28
|
--- Source/Modules/python.cxx 9 Dec 2003 02:52:07 -0000 1.33
|
||||||
+++ Source/Modules/python.cxx 27 Nov 2003 00:52:28 -0000
|
+++ Source/Modules/python.cxx 11 Dec 2003 18:11:22 -0000
|
||||||
@@ -67,8 +67,19 @@
|
@@ -54,8 +54,17 @@
|
||||||
-new_repr - Use more informative version of __repr__ in proxy classes\n\
|
static int have_constructor;
|
||||||
-noexcept - No automatic exception handling\n\
|
static int have_repr;
|
||||||
-noproxy - Don't generate proxy classes \n\n";
|
static String *real_classname;
|
||||||
|
|
||||||
+
|
|
||||||
+/* flags for the make_autodoc function */
|
+/* flags for the make_autodoc function */
|
||||||
+enum autodoc_t {
|
+enum autodoc_t {
|
||||||
+ AUTODOC_CLASS,
|
+ AUTODOC_CLASS,
|
||||||
@@ -20,12 +19,11 @@ diff -u -4 -r1.28 python.cxx
|
|||||||
+ AUTODOC_FUNC
|
+ AUTODOC_FUNC
|
||||||
+};
|
+};
|
||||||
+
|
+
|
||||||
+
|
static const char *usage = (char *)"\
|
||||||
class PYTHON : public Language {
|
Python Options (available with -python)\n\
|
||||||
public:
|
-ldflags - Print runtime libraries to link with\n\
|
||||||
|
-globals <name> - Set <name> used to access C global variable [default: 'cvar']\n\
|
||||||
/* ------------------------------------------------------------
|
@@ -417,17 +426,23 @@
|
||||||
@@ -414,17 +425,23 @@
|
|
||||||
* functions.
|
* functions.
|
||||||
* ------------------------------------------------------------ */
|
* ------------------------------------------------------------ */
|
||||||
|
|
||||||
@@ -54,7 +52,7 @@ diff -u -4 -r1.28 python.cxx
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -438,8 +455,246 @@
|
@@ -441,8 +456,246 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -301,7 +299,7 @@ diff -u -4 -r1.28 python.cxx
|
|||||||
* Check if there is a %addtofunc directive and it has text
|
* Check if there is a %addtofunc directive and it has text
|
||||||
* ------------------------------------------------------------ */
|
* ------------------------------------------------------------ */
|
||||||
|
|
||||||
@@ -1660,9 +1915,11 @@
|
@@ -1663,9 +1916,11 @@
|
||||||
Printf(f_shadow, modern ? "(object)" : "(_object)");
|
Printf(f_shadow, modern ? "(object)" : "(_object)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -314,7 +312,7 @@ diff -u -4 -r1.28 python.cxx
|
|||||||
Printv(f_shadow,tab4,"__swig_setmethods__ = {}\n",NIL);
|
Printv(f_shadow,tab4,"__swig_setmethods__ = {}\n",NIL);
|
||||||
if (Len(base_class)) {
|
if (Len(base_class)) {
|
||||||
Printf(f_shadow,"%sfor _s in [%s]: __swig_setmethods__.update(_s.__swig_setmethods__)\n",tab4,base_class);
|
Printf(f_shadow,"%sfor _s in [%s]: __swig_setmethods__.update(_s.__swig_setmethods__)\n",tab4,base_class);
|
||||||
@@ -1795,16 +2052,22 @@
|
@@ -1798,16 +2053,22 @@
|
||||||
Delete(pyaction);
|
Delete(pyaction);
|
||||||
Printv(f_shadow,pycode,"\n",NIL);
|
Printv(f_shadow,pycode,"\n",NIL);
|
||||||
} else {
|
} else {
|
||||||
@@ -344,7 +342,7 @@ diff -u -4 -r1.28 python.cxx
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1819,14 +2082,20 @@
|
@@ -1822,14 +2083,20 @@
|
||||||
virtual int staticmemberfunctionHandler(Node *n) {
|
virtual int staticmemberfunctionHandler(Node *n) {
|
||||||
String *symname = Getattr(n,"sym:name");
|
String *symname = Getattr(n,"sym:name");
|
||||||
Language::staticmemberfunctionHandler(n);
|
Language::staticmemberfunctionHandler(n);
|
||||||
@@ -369,7 +367,7 @@ diff -u -4 -r1.28 python.cxx
|
|||||||
" = staticmethod(", symname, ")\n", NIL);
|
" = staticmethod(", symname, ")\n", NIL);
|
||||||
|
|
||||||
if (!modern) {
|
if (!modern) {
|
||||||
@@ -1911,8 +2180,10 @@
|
@@ -1914,8 +2181,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
Printv(f_shadow, tab4, "def __init__(self, *args",
|
Printv(f_shadow, tab4, "def __init__(self, *args",
|
||||||
@@ -380,7 +378,7 @@ diff -u -4 -r1.28 python.cxx
|
|||||||
if (!modern) {
|
if (!modern) {
|
||||||
Printv(f_shadow, tab8, "_swig_setattr(self, ", rclassname, ", 'this', ",
|
Printv(f_shadow, tab8, "_swig_setattr(self, ", rclassname, ", 'this', ",
|
||||||
funcCallHelper(Swig_name_construct(symname), allow_kwargs), ")\n", NIL);
|
funcCallHelper(Swig_name_construct(symname), allow_kwargs), ")\n", NIL);
|
||||||
@@ -1926,9 +2197,9 @@
|
@@ -1929,9 +2198,9 @@
|
||||||
Printv(f_shadow, tab8, "self.thisown = 1\n", NIL);
|
Printv(f_shadow, tab8, "self.thisown = 1\n", NIL);
|
||||||
Printv(f_shadow, tab8, "del newobj.thisown\n", NIL);
|
Printv(f_shadow, tab8, "del newobj.thisown\n", NIL);
|
||||||
}
|
}
|
||||||
@@ -391,7 +389,7 @@ diff -u -4 -r1.28 python.cxx
|
|||||||
}
|
}
|
||||||
have_constructor = 1;
|
have_constructor = 1;
|
||||||
} else {
|
} else {
|
||||||
@@ -1944,8 +2215,10 @@
|
@@ -1947,8 +2216,10 @@
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
Printv(f_shadow_stubs, "\ndef ", symname, "(*args",
|
Printv(f_shadow_stubs, "\ndef ", symname, "(*args",
|
||||||
@@ -402,7 +400,7 @@ diff -u -4 -r1.28 python.cxx
|
|||||||
funcCallHelper(Swig_name_construct(symname), allow_kwargs), "\n", NIL);
|
funcCallHelper(Swig_name_construct(symname), allow_kwargs), "\n", NIL);
|
||||||
Printv(f_shadow_stubs, tab4, "val.thisown = 1\n", NIL);
|
Printv(f_shadow_stubs, tab4, "val.thisown = 1\n", NIL);
|
||||||
if ( have_addtofunc(n) )
|
if ( have_addtofunc(n) )
|
||||||
@@ -1977,13 +2250,15 @@
|
@@ -1980,13 +2251,15 @@
|
||||||
Delete(pyaction);
|
Delete(pyaction);
|
||||||
Printv(f_shadow,pycode,"\n", NIL);
|
Printv(f_shadow,pycode,"\n", NIL);
|
||||||
} else {
|
} else {
|
||||||
|
186
wxPython/SWIG/swig.xmlout.patch
Normal file
186
wxPython/SWIG/swig.xmlout.patch
Normal file
@@ -0,0 +1,186 @@
|
|||||||
|
Index: Source/Swig/swig.h
|
||||||
|
===================================================================
|
||||||
|
RCS file: /cvsroot/SWIG/Source/Swig/swig.h,v
|
||||||
|
retrieving revision 1.76
|
||||||
|
diff -u -4 -r1.76 swig.h
|
||||||
|
--- Source/Swig/swig.h 11 Nov 2003 20:16:35 -0000 1.76
|
||||||
|
+++ Source/Swig/swig.h 11 Dec 2003 18:12:49 -0000
|
||||||
|
@@ -350,8 +350,10 @@
|
||||||
|
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
|
||||||
|
retrieving revision 1.23
|
||||||
|
diff -u -4 -r1.23 main.cxx
|
||||||
|
--- Source/Modules/main.cxx 8 Dec 2003 23:42:37 -0000 1.23
|
||||||
|
+++ Source/Modules/main.cxx 11 Dec 2003 18:12:50 -0000
|
||||||
|
@@ -85,15 +85,17 @@
|
||||||
|
-v - Run in verbose mode\n\
|
||||||
|
-version - Print SWIG version number\n\
|
||||||
|
-Wall - Enable all warning messages\n\
|
||||||
|
-w<n> - Suppress warning number <n>\n\
|
||||||
|
+ -xmlout <file> - Write an XML version of the parse tree to file after normal processing\n\
|
||||||
|
\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)
|
||||||
|
//
|
||||||
|
@@ -222,8 +224,9 @@
|
||||||
|
int includecount = 0;
|
||||||
|
extern int check_suffix(char *);
|
||||||
|
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;
|
||||||
|
@@ -482,8 +485,20 @@
|
||||||
|
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) {
|
||||||
|
@@ -725,8 +740,11 @@
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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
|
||||||
|
retrieving revision 1.8
|
||||||
|
diff -u -4 -r1.8 xml.cxx
|
||||||
|
--- Source/Modules/xml.cxx 31 Oct 2003 17:42:40 -0000 1.8
|
||||||
|
+++ Source/Modules/xml.cxx 11 Dec 2003 18:12:50 -0000
|
||||||
|
@@ -24,9 +24,8 @@
|
||||||
|
//static Node *view_top = 0;
|
||||||
|
static File *out = 0;
|
||||||
|
static int xmllite = 0;
|
||||||
|
|
||||||
|
-
|
||||||
|
class XML
|
||||||
|
: public Language
|
||||||
|
{
|
||||||
|
|
||||||
|
@@ -109,9 +108,9 @@
|
||||||
|
Printf(stderr,"*** Can't open '%s'\n", outfile);
|
||||||
|
SWIG_exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- Printf( out, "<?xml version=\"1.0\" ?> \n" );
|
||||||
|
+ Printf( out, "<?xml version=\"1.0\" ?> \n" );
|
||||||
|
Xml_print_tree(n);
|
||||||
|
return SWIG_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -197,18 +196,19 @@
|
||||||
|
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);
|
||||||
|
@@ -318,11 +318,10 @@
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
@@ -337,5 +336,36 @@
|
||||||
|
Language * swig_xml( void )
|
||||||
|
{
|
||||||
|
return new XML();
|
||||||
|
}
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+/* -----------------------------------------------------------------------------
|
||||||
|
+ * 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);
|
||||||
|
}
|
Reference in New Issue
Block a user