From: Robin Dunn Date: Thu, 9 Sep 2004 18:32:44 +0000 (+0000) Subject: New patch for SWIG, updated to SWIG 1.3.22. Removed old patches that X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/414863fd5239779a647fb12cd5d02093ceee29bc New patch for SWIG, updated to SWIG 1.3.22. Removed old patches that have already been put in to SWIG git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29062 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/wxPython/SWIG/README.txt b/wxPython/SWIG/README.txt index 83bcaf7763..72f8ee8417 100644 --- a/wxPython/SWIG/README.txt +++ b/wxPython/SWIG/README.txt @@ -8,74 +8,50 @@ wxPython. These have been submitted to SWIG's SourceForge patch tracker, so hopefully they will get incorporated into the main SWIG source tree soon. -wxPython currently uses the 20-Feb-2004 version of SWIG. You can get -that version from their CVS using these commands:: +wxPython currently uses the 1.3.22 version of SWIG, which you can get +from https://sourceforge.net/projects/swig/, plus the patches in this +directory. Download the SWIG sources, apply the patch(es) here and +then build as normal. - cvs -d :pserver:anonymous@cvs.sourceforge.net:/cvsroot/swig login - - - cvs -d :pserver:anonymous@cvs.sourceforge.net:/cvsroot/swig \ - checkout -D 20-FEB-2004 SWIG - ------------------------------------------------------------------------ -swig.python-docstring.patch Adds "autodoc" and "docstring" features. - See SF Patch #883402 - - Also changes the "addtofunc" feature to - "pythonappend" and also adds a - "pythonprepend" feature that prepends - pythoncode to the begining of a - SWIG-generated proxy function or method. +swig.python-2.patch - Add support for two new options to the - %module directive. The first allows you - to specify a docstring for the proxy - module, you use it like this:: + Adds the following features to the Python Module in SWIG. See the + updated docs in the patch for more details. - %module(docstring="blah") modulename + %feature("autodoc") + %feature("docstring") + %feature("pythonprepend") + %feature("pythonappend") - And then when generating the - modulename.py file SWIG will make a - docstring using the value given. + %module(docstring="string") + %module(package="string") - The second %module option allows you to - specify the name of the package that the - module will live in. This is useful when - the .i file is %imported by other .i - files. If they are to live in separate - packages then the importer can't do local - imports of the importee. If both modules - have the same package name then nothing - is generated differently than the current - SWIG functionality. If they are - different then the package name of the - importee is prepended to the import - statement and the base class declarations - in the importer. For example:: + https://sourceforge.net/tracker/index.php?func=detail&aid=1023309&group_id=1645&atid=301645 - %module(pacakge="wx") _core - - Multiple %module options can be specfied, - separated by commmas. +------------------------------------------------------------------------ +This patch was applied to SWIG's CVS on 07/12/2004 and is in the +1.3.22 relese. +------------------------------------------------------------------------ -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. +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.) - See SF Patch #864689 + 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.) + See SF Patch #864689 @@ -84,21 +60,21 @@ These patches have already been checked in to SWIG's CVS and are in the 1.3.20 release. ------------------------------------------------------------------------ -swig.SplitLines.patch Adds a new SplitLines function to the DOH - library. See SF Patch #829317. - *Checked in 10/31/2003* - -swig.xml.patch Adds an option that drastically reduces - the size of the XML output of SWIG, which - increases the performance of the - build_renamers script used in the wxPython - build. See SF Patch #829319. - *Checked in 10/31/2003* - -swig.python.patch Lots of changes for SWIG's Python module, - especially in how the proxy code is - generated. See swig.python.patch.txt for - more details, also SF Patch #829325. - *Checked in 10/31/2003* +swig.SplitLines.patch Adds a new SplitLines function to the DOH + library. See SF Patch #829317. + *Checked in 10/31/2003* + +swig.xml.patch Adds an option that drastically reduces + the size of the XML output of SWIG, which + increases the performance of the + build_renamers script used in the wxPython + build. See SF Patch #829319. + *Checked in 10/31/2003* + +swig.python.patch Lots of changes for SWIG's Python module, + especially in how the proxy code is + generated. See swig.python.patch.txt for + more details, also SF Patch #829325. + *Checked in 10/31/2003* ------------------------------------------------------------------------ diff --git a/wxPython/SWIG/swig.SplitLines.patch b/wxPython/SWIG/swig.SplitLines.patch deleted file mode 100644 index 43ea795e7e..0000000000 --- a/wxPython/SWIG/swig.SplitLines.patch +++ /dev/null @@ -1,75 +0,0 @@ -Index: Source/DOH/doh.h -=================================================================== -RCS file: /cvsroot/SWIG/Source/DOH/doh.h,v -retrieving revision 1.7 -diff -u -r1.7 doh.h ---- Source/DOH/doh.h 11 Sep 2003 20:26:53 -0000 1.7 -+++ Source/DOH/doh.h 24 Oct 2003 00:00:41 -0000 -@@ -99,6 +99,7 @@ - #define DohNewHash DOH_NAMESPACE(NewHash) - #define DohNewVoid DOH_NAMESPACE(NewVoid) - #define DohSplit DOH_NAMESPACE(Split) -+#define DohSplitLines DOH_NAMESPACE(SplitLines) - #define DohNone DOH_NAMESPACE(None) - #define DohCall DOH_NAMESPACE(Call) - #define DohObjMalloc DOH_NAMESPACE(ObjMalloc) -@@ -304,6 +305,7 @@ - - extern DOHVoid *DohNewVoid(void *ptr, void (*del)(void *)); - extern DOHList *DohSplit(DOHFile *input, char ch, int nsplits); -+extern DOHList *DohSplitLines(DOHFile *input); - extern DOH *DohNone; - - extern void DohMemoryDebug(void); -@@ -378,6 +380,7 @@ - #define Strchr DohStrchr - #define Copyto DohCopyto - #define Split DohSplit -+#define SplitLines DohSplitLines - #define Setmark DohSetmark - #define Getmark DohGetmark - #define None DohNone -Index: Source/DOH/fio.c -=================================================================== -RCS file: /cvsroot/SWIG/Source/DOH/fio.c,v -retrieving revision 1.2 -diff -u -r1.2 fio.c ---- Source/DOH/fio.c 15 Aug 2003 19:37:27 -0000 1.2 -+++ Source/DOH/fio.c 24 Oct 2003 00:00:42 -0000 -@@ -497,6 +497,36 @@ - } - - /* ----------------------------------------------------------------------------- -+ * DohSplitLines() -+ * -+ * Split an input stream into a list of strings delimited by newline characters. -+ * ----------------------------------------------------------------------------- */ -+ -+DOH * -+DohSplitLines(DOH *in) { -+ DOH *list; -+ DOH *str; -+ int c = 0; -+ -+ list = NewList(); -+ -+ if (DohIsString(in)) { -+ Seek(in,0,SEEK_SET); -+ } -+ -+ while (c != EOF) { -+ str = NewString(""); -+ while ((c = Getc(in)) != '\n' && c != EOF) { -+ Putc(c, str); -+ } -+ Append(list,str); -+ Delete(str); -+ } -+ return list; -+} -+ -+ -+/* ----------------------------------------------------------------------------- - * DohReadline() - * - * Read a single input line and return it as a string. diff --git a/wxPython/SWIG/swig.python-2.patch b/wxPython/SWIG/swig.python-2.patch new file mode 100644 index 0000000000..5ce3520e44 --- /dev/null +++ b/wxPython/SWIG/swig.python-2.patch @@ -0,0 +1,887 @@ +Index: Doc/Manual/Python.html +=================================================================== +RCS file: /cvsroot/swig/SWIG/Doc/Manual/Python.html,v +retrieving revision 1.18 +diff -u -4 -r1.18 Python.html +--- Doc/Manual/Python.html 2 Sep 2004 20:27:14 -0000 1.18 ++++ Doc/Manual/Python.html 6 Sep 2004 21:06:11 -0000 +@@ -86,8 +86,15 @@ +
  • Mapping Python tuples into small arrays +
  • Mapping sequences to C arrays +
  • Pointer handling + ++
  • Docstring Features ++ ++
  • Python Packages + + + + +@@ -2460,9 +2467,8 @@ + customization features as covered in later sections. + +

    26.6.2 Adding additional Python code

    + +- + If writing support code in C isn't enough, it is also possible to write code in + Python. This code gets inserted in to the .py file created by SWIG. One + use of Python code might be to supply a high-level interface to certain functions. + For example: +@@ -2506,8 +2512,46 @@ + soon enough. For now, think of this example as an illustration of + what can be done without having to rely on any of the more advanced + customization features. + ++

    Sometimes you may want to replace or modify the wrapper function ++that SWIG creates in the proxy .py file. The Python module ++in SWIG provides some features that enable you do do this. First, to ++entirely replace a proxy function you can use ++%feature("shadow"). For example: ++ ++

    ++
    ++%module example
    ++%rename(bar_id) bar(int,double);
    ++
    ++// Rewrite bar() to allow some nice overloading
    ++
    ++%feature("shadow") Foo::bar(int) %{
    ++def bar(*args):
    ++    if len(args) == 3:
    ++         return apply(examplec.Foo_bar_id,args)
    ++    return apply(examplec.Foo_bar,args)
    ++%}
    ++    
    ++class Foo {
    ++public:
    ++    int bar(int x);
    ++    int bar(int x, double y);
    ++}
    ++
    ++
    ++ ++ ++Often the proxy function created by SWIG is fine, but you simply want ++to add code to it without touching the rest of the generated function ++body. For these cases SWIG provides the "pythonprepend" and ++"pythonappend" features which do exactly as their names suggest. The ++"pythonprepend" feature will insert its value at the begining of the ++proxy function, and "pythonappend" will insert code at the end of the ++proxy, just before the return statement. ++ ++ +

    26.6.3 Class extension with %extend

    + + + One of the more interesting features of SWIG is that it can extend +@@ -3852,6 +3896,197 @@ + that has a this attribute. In addition, + SWIG_NewPointerObj() can automatically generate a proxy + class object (if applicable). + ++ ++ ++

    26.10 Docstring Features

    ++ ++Usign docstrings in Python code is becoming more and more important ++ans more tools are coming on the scene that take advantage of them, ++everything from full-blown documentaiton generators to class browsers ++and popup call-tips in Python-aware IDEs. Given the way that SWIG ++generates the proxy code by default, your users will normally get ++something like "function_name(*args)" in the popup calltip of ++their IDE which is next to useless when the real function prototype ++might be something like this: ++ ++
    ++
    ++bool function_name(int x, int y, Foo* foo=NULL, Bar* bar=NULL);
    ++
    ++
    ++ ++The features described in this section make it easy for you to add ++docstrings to your modules, functions and methods that can then be ++used by the various tools out there to make the programming experience ++of your users much simpler. ++ ++ ++

    26.10.1 Module docstring

    ++ ++Python allows a docstring at the begining of the .py file ++before any other statements, and it is typically used to give a ++general description of the entire module. SWIG supports this by ++setting an option of the %module directive. For example: ++ ++
    ++
    ++%module(docstring="This is the example module's docstring") example
    ++
    ++
    ++ ++When you have more than just a line or so then you can retain the easy ++readability of the %module directive by using a macro. For ++example: ++ ++
    ++
    ++%define DOCSTRING
    ++"The `XmlResource` class allows program resources defining menus, 
    ++layout of controls on a panel, etc. to be loaded from an XML file."
    ++%enddef
    ++
    ++%module(docstring=DOCSTRING) xrc
    ++
    ++
    ++ ++ ++

    26.10.2 %feature("autodoc")

    ++ ++As alluded to above SWIG will generate all the function and method ++proxy wrappers with just "*args" (or "*args, **kwargs" if the -keyword ++option is used) for a parameter list and will then sort out the ++individual parameters in the C wrapper code. This is nice and simple ++for the wrapper code, but makes it difficult to be programmer and tool ++friendly as anyone looking at the .py file will not be able ++to find out anything about the parameters that the fuctions accept. ++ ++

    But since SWIG does know everything about the fucntion it is ++possible to generate a docstring containing the parameter types, names ++and default values. Since many of the doctring tools are adopting a ++standard of recognizing if the first thing in the docstring is a ++function prototype then using that instead of what they found from ++introspeciton, then life is good once more. ++ ++

    SWIG's Python module provides support for the "autodoc" feature, ++which when attached to a node in the parse tree will cause a docstring ++to be generated that includes the name of the funciton, parameter ++names, default values if any, and return type if any. There are also ++three options for autodoc controlled by the value given to the ++feature, described below. ++ ++

    %feature("autodoc", "0")

    ++ ++When the "0" option is given then the types of the parameters will ++not be included in the autodoc string. For example, given ++this function prototype: ++ ++
    ++
    ++%feature("autodoc", "0");
    ++bool function_name(int x, int y, Foo* foo=NULL, Bar* bar=NULL);
    ++
    ++
    ++ ++Then Python code like this will be generated: ++ ++
    ++
    ++def function_name(*args, **kwargs):
    ++    """function_name(x, y, foo=None, bar=None) -> bool"""
    ++    ...
    ++
    ++
    ++ ++ ++

    %feature("autodoc", "1")

    ++ ++When the "1" option is used then the parameter types will be ++used in the autodoc string. In addition, an atempt is made to ++simplify the type name such that it makes more sense to the Python ++user. Pointer, reference and const info is removed, ++%rename's are evaluated, etc. (This is not always ++successful, but works most of the time. See the next section for what ++to do when it doesn't.) Given the example above, then turning on the ++parameter types with the "1" option will result in Python code like ++this: ++ ++
    ++
    ++def function_name(*args, **kwargs):
    ++    """function_name(int x, int y, Foo foo=None, Bar bar=None) -> bool"""
    ++    ...
    ++
    ++
    ++ ++ ++ ++

    %feature("autodoc", "docstring")

    ++ ++Finally, there are times when the automatically generated autodoc ++string will make no sense for a Python programmer, particularly when a ++typemap is involved. So if you give an explicit value for the autodoc ++feature then that string will be used in place of the automatically ++generated string. For example: ++ ++
    ++
    ++%feature("autodoc", "GetPosition() -> (x, y)") GetPosition;
    ++void GetPosition(int* OUTPUT, int* OUTPUT);
    ++
    ++
    ++ ++ ++

    26.10.3 %feature("docstring")

    ++ ++In addition to the autodoc strings described above, you can also ++attach any arbitrary descriptive text to a node in the parse tree with ++the "docstring" feature. When the proxy module is generated then any ++docstring associated with classes, function or methods are output. ++If an item already has an autodoc string then it is combined with the ++docstring and they are output together. If the docstring is all on a ++single line then it is output like this:: ++ ++
    ++
    ++"""This is the docstring"""
    ++
    ++
    ++ ++Otherwise, to aid readability it is output like this: ++ ++
    ++
    ++"""
    ++This is a multi-line docstring
    ++with more than one line.
    ++"""
    ++
    ++
    ++ ++

    26.11 Python Packages

    ++ ++Using the package option of the %module directive ++allows you to specify what Python package that the module will be ++living in when installed. ++ ++
    ++
    ++%module(package="wx") xrc
    ++
    ++
    ++ ++This is useful when the .i file is %imported by ++another .i file. By default SWIG will assume that the ++importer is able to find the importee with just the module name, but ++if they live in separate Python packages then that won't work. ++However if the importee specifies what its package is with the ++%module option then the Python code generated for the ++importer will use that package name when importing the other module ++and also in base class declarations, etc. if the pacakge name is ++different than its own. ++ ++ ++ + + +Index: Source/Modules/python.cxx +=================================================================== +RCS file: /cvsroot/swig/SWIG/Source/Modules/python.cxx,v +retrieving revision 1.50 +diff -u -4 -r1.50 python.cxx +--- Source/Modules/python.cxx 1 Sep 2004 22:25:56 -0000 1.50 ++++ Source/Modules/python.cxx 6 Sep 2004 21:06:11 -0000 +@@ -19,8 +19,9 @@ + + static String *const_code = 0; + static String *shadow_methods = 0; + static String *module = 0; ++static String *package = 0; + static String *mainmodule = 0; + static String *interface = 0; + static String *global_name = 0; + static int shadow = 1; +@@ -50,8 +51,18 @@ + static int have_constructor; + static int have_repr; + static String *real_classname; + ++/* flags for the make_autodoc function */ ++enum autodoc_t { ++ AUTODOC_CLASS, ++ AUTODOC_CTOR, ++ AUTODOC_DTOR, ++ AUTODOC_STATICFUNC, ++ AUTODOC_FUNC, ++ AUTODOC_METHOD ++}; ++ + static const char *usage = (char *)"\ + Python Options (available with -python)\n\ + -globals - Set used to access C global variable [default: 'cvar']\n\ + -interface - Set the lib name to \n\ +@@ -145,19 +156,22 @@ + * + * use %module(directors="1") modulename at the start of the + * interface file to enable director generation. + */ ++ String* mod_docstring = NULL; + { +- Node *module = Getattr(n, "module"); +- if (module) { +- Node *options = Getattr(module, "options"); ++ Node *mod = Getattr(n, "module"); ++ if (mod) { ++ Node *options = Getattr(mod, "options"); + if (options) { + if (Getattr(options, "directors")) { + allow_directors(); + } + if (Getattr(options, "dirprot")) { + allow_dirprot(); + } ++ mod_docstring = Getattr(options, "docstring"); ++ package = Getattr(options, "package"); + } + } + } + +@@ -257,8 +271,13 @@ + Printv(f_shadow, + "# This file is compatible with both classic and new-style classes.\n", + NIL); + } ++ ++ if (mod_docstring && Len(mod_docstring)) { ++ Printv(f_shadow, "\n\"\"\"\n", mod_docstring, "\n\"\"\"\n", NIL); ++ Delete(mod_docstring); mod_docstring = NULL; ++ } + + Printf(f_shadow,"\nimport %s\n\n", module); + + if (! modern) { +@@ -381,9 +400,28 @@ + virtual int importDirective(Node *n) { + if (shadow) { + String *modname = Getattr(n,"module"); + if (modname) { +- Printf(f_shadow,"import %s\n", modname); ++ Printf(f_shadow,"import "); ++ ++ // Find the module node for this imported module. It should be the ++ // first child but search just in case. ++ Node* mod = firstChild(n); ++ while (mod && Strcmp(nodeType(mod), "module") != 0) ++ mod = nextSibling(mod); ++ ++ // Is the imported module in another package? (IOW, does it use the ++ // %module(package="name") option and it's different than the package ++ // of this module.) ++ Node *options = Getattr(mod, "options"); ++ if (options && Getattr(options, "package")) { ++ String* pkg = Getattr(options, "package"); ++ if (!package || Strcmp(pkg, package) != 0) ++ Printf(f_shadow, "%s.", Getattr(options, "package")); ++ } ++ ++ // finally, output the name of the imported module ++ Printf(f_shadow, "%s\n", modname); + } + } + return Language::importDirective(n); + } +@@ -416,17 +454,25 @@ + * functions. + * ------------------------------------------------------------ */ + + void emitFunctionShadowHelper(Node *n, File *f_dest, String *name, int kw) { +- if ( ! have_addtofunc(n) ) { +- /* If there is no addtofunc directive then just assign from the extension module */ ++ if ( !have_pythonprepend(n) && !have_pythonappend(n) && !have_docstring(n) ) { ++ /* If there is no pythonappend or docstring directive then just assign from the extension module */ + Printv(f_dest, "\n", name, " = ", module, ".", name, "\n", NIL); + } else { + /* Otherwise make a wrapper function to insert the code into */ + Printv(f_dest, "\ndef ", name, "(*args", (kw ? ", **kwargs" : ""), "):\n", NIL); +- Printv(f_dest, tab4, "val = ", funcCallHelper(name, kw), "\n", NIL); +- Printv(f_dest, tab4, addtofunc(n), "\n", NIL); +- Printv(f_dest, tab4, "return val\n", NIL); ++ if ( have_docstring(n) ) ++ Printv(f_dest, tab4, docstring(n, AUTODOC_FUNC, tab4), "\n", NIL); ++ if ( have_pythonprepend(n) ) ++ Printv(f_dest, tab4, pythonprepend(n), "\n", NIL); ++ if ( have_pythonappend(n) ) { ++ Printv(f_dest, tab4, "val = ", funcCallHelper(name, kw), "\n", NIL); ++ Printv(f_dest, tab4, pythonappend(n), "\n", NIL); ++ Printv(f_dest, tab4, "return val\n", NIL); ++ } else { ++ Printv(f_dest, tab4, "return ", funcCallHelper(name, kw), "\n", NIL); ++ } + } + } + + +@@ -440,24 +486,303 @@ + } + + + /* ------------------------------------------------------------ +- * have_addtofunc() +- * Check if there is a %addtofunc directive and it has text ++ * have_docstring() ++ * Check if there is a docstring directive and it has text, ++ * or there is an autodoc flag set + * ------------------------------------------------------------ */ + +- bool have_addtofunc(Node *n) { +- String* str = Getattr(n, "feature:addtofunc"); ++ bool have_docstring(Node *n) { ++ String* str = Getattr(n, "feature:docstring"); ++ return (str != NULL && Len(str) > 0) || ++ (Getattr(n,"feature:autodoc") && !Getattr(n, "feature:noautodoc")); ++ } ++ ++ /* ------------------------------------------------------------ ++ * docstring() ++ * Get the docstring text, stripping off {} if neccessary, ++ * and enclose in triple double quotes. If autodoc is also ++ * set then it will build a combined docstring. ++ * ------------------------------------------------------------ */ ++ ++ String *docstring(Node *n, autodoc_t ad_type, const String* indent) { ++ String* str = Getattr(n, "feature:docstring"); ++ bool have_ds = (str != NULL && Len(str) > 0); ++ bool have_auto = (Getattr(n,"feature:autodoc") && !Getattr(n, "feature:noautodoc")); ++ char* triple_double = "\"\"\""; ++ String* autodoc = NULL; ++ String* doc = NULL; ++ ++ if ( have_ds ) { ++ char* t = Char(str); ++ if (*t == '{') { ++ Delitem(str ,0); ++ Delitem(str,DOH_END); ++ } ++ } ++ ++ if ( have_auto ) { ++ autodoc = make_autodoc(n, ad_type); ++ have_auto = (autodoc != NULL && Len(autodoc) > 0); ++ } ++ ++ // If there is more than one line then make docstrings like this: ++ // ++ // """ ++ // This is line1 ++ // And here is line2 followed by the rest of them ++ // """ ++ // ++ // otherwise, put it all on a single line ++ // ++ if ( have_auto && have_ds ) { // Both autodoc and docstring are present ++ doc = NewString(""); ++ Printv(doc, triple_double, "\n", ++ pythoncode(autodoc, indent), "\n", ++ pythoncode(str, indent), ++ indent, triple_double, NIL); ++ } ++ else if ( !have_auto && have_ds ) { // only docstring ++ if (Strchr(str, '\n') == NULL) { ++ doc = NewStringf("%s%s%s", triple_double, str, triple_double); ++ } ++ else { ++ doc = NewString(""); ++ Printv(doc, triple_double, "\n", ++ pythoncode(str, indent), ++ indent, triple_double, NIL); ++ } ++ } ++ else if ( have_auto && !have_ds ) { // only autodoc ++ if (Strchr(autodoc, '\n') == NULL) { ++ doc = NewStringf("%s%s%s", triple_double, autodoc, triple_double); ++ } ++ else { ++ doc = NewString(""); ++ Printv(doc, triple_double, "\n", ++ pythoncode(autodoc, indent), ++ indent, triple_double, NIL); ++ } ++ } ++ else ++ doc = NewString(""); ++ ++ // Save the generated strings in the parse tree in case they are used later ++ // by post processing tools ++ Setattr(n, "python:docstring", doc); ++ Setattr(n, "python:autodoc", autodoc); ++ return doc; ++ } ++ ++ ++ /* ------------------------------------------------------------ ++ * make_autodoc() ++ * Build a docstring for the node, using parameter and other ++ * info in the parse tree. If the value of the autodoc ++ * attribute is "0" then do not include parameter types, if ++ * it is "1" (the default) then do. If it has some other ++ * value then assume it is supplied by the extension writer ++ * and use it directly. ++ * ------------------------------------------------------------ */ ++ ++ String* make_autodoc(Node *n, autodoc_t ad_type) { ++ ++ if (ad_type == AUTODOC_CLASS) ++ return NULL; // No function call to document in this case ++ ++ // If the function is overloaded then this funciton is called ++ // for the last one. Rewind to the first so the docstrings are ++ // in order. ++ while ( Getattr(n, "sym:previousSibling") ) ++ n = Getattr(n, "sym:previousSibling"); ++ ++ String* doc = NewString(""); ++ while (n) { ++ bool showTypes = false; ++ bool skipAuto = false; ++ ++ // check how should the parameters be rendered? ++ String* autodoc = Getattr(n, "feature:autodoc"); ++ if (Strcmp(autodoc, "0") == 0) ++ showTypes = false; ++ else if (Strcmp(autodoc, "1") == 0) ++ showTypes = true; ++ else { ++ // if not "0" or "1" then autodoc is already the string that should be used ++ Printf(doc, "%s", autodoc); ++ skipAuto = true; ++ } ++ ++ if (!skipAuto) { ++ String* symname = Getattr(n, "sym:name"); ++ SwigType* type = Getattr(n, "type"); ++ ++ if (type) { ++ if (Strcmp(type, "void") == 0) ++ type = NULL; ++ else { ++ SwigType* qt = SwigType_typedef_resolve_all(type); ++ if (SwigType_isenum(qt)) ++ type = NewString("int"); ++ else { ++ type = SwigType_base(type); ++ Node* lookup = Swig_symbol_clookup(type, 0); ++ if (lookup) ++ type = Getattr(lookup, "sym:name"); ++ } ++ } ++ } ++ ++ switch ( ad_type ) { ++ case AUTODOC_CTOR: ++ if ( Strcmp(class_name, symname) == 0) { ++ String* paramList = make_autodocParmList(n, showTypes); ++ if (Len(paramList)) ++ Printf(doc, "__init__(self, %s) -> %s", paramList, class_name); ++ else ++ Printf(doc, "__init__(self) -> %s", class_name); ++ } ++ else ++ Printf(doc, "%s(%s) -> %s", symname, make_autodocParmList(n, showTypes), class_name); ++ break; ++ ++ case AUTODOC_DTOR: ++ Printf(doc, "__del__(self)"); ++ break; ++ ++ case AUTODOC_STATICFUNC: ++ Printf(doc, "%s(%s)", symname, make_autodocParmList(n, showTypes)); ++ if (type) Printf(doc, " -> %s", type); ++ break; ++ ++ case AUTODOC_FUNC: ++ Printf(doc, "%s(%s)", symname, make_autodocParmList(n, showTypes)); ++ if (type) Printf(doc, " -> %s", type); ++ break; ++ ++ case AUTODOC_METHOD: ++ String* paramList = make_autodocParmList(n, showTypes); ++ if (Len(paramList)) ++ Printf(doc, "%s(self, %s)", symname, paramList); ++ else ++ Printf(doc, "%s(self)", symname); ++ if (type) Printf(doc, " -> %s", type); ++ break; ++ } ++ } ++ ++ // if it's overloaded then get the next decl and loop around again ++ n = Getattr(n, "sym:nextSibling"); ++ if (n) ++ Printf(doc, "\n"); ++ } ++ ++ return doc; ++ } ++ ++ ++ String* make_autodocParmList(Node* n, bool showTypes) { ++ String* doc = NewString(""); ++ ParmList* plist = Getattr(n,"parms"); ++ Parm* p; ++ Node* lookup; ++ int lines = 0; ++ const int maxwidth = 50; ++ ++ ++ for (p = plist; p; p = nextSibling(p)) { ++ String* name = Getattr(p, "name"); ++ String* value = Getattr(p, "value"); ++ ++ if ( Len(doc) ) { ++ // add a comma to the previous one if any ++ Printf(doc, ", "); ++ ++ // Do we need to wrap a long line? ++ if ((Len(doc) - lines*maxwidth) > maxwidth) { ++ Printf(doc, "\n%s", tab4); ++ lines += 1; ++ } ++ } ++ ++ // Do the param type too? ++ if (showTypes) { ++ SwigType* type = SwigType_base(Getattr(p, "type")); ++ SwigType* qt = SwigType_typedef_resolve_all(type); ++ if (SwigType_isenum(qt)) ++ type = NewString("int"); ++ else { ++ lookup = Swig_symbol_clookup(type, 0); ++ if (lookup) ++ type = Getattr(lookup, "sym:name"); ++ } ++ Printf(doc, "%s ", type); ++ } ++ ++ if (name) ++ Printf(doc, "%s", name); ++ else ++ Printf(doc, "??"); ++ ++ if (value) { ++ if (Strcmp(value, "NULL") == 0) ++ value = NewString("None"); ++ else { ++ lookup = Swig_symbol_clookup(value, 0); ++ if (lookup) ++ value = Getattr(lookup, "sym:name"); ++ } ++ Printf(doc, "=%s", value); ++ } ++ } ++ ++ return doc; ++ } ++ ++ ++ /* ------------------------------------------------------------ ++ * have_pythonprepend() ++ * Check if there is a %pythonprepend directive and it has text ++ * ------------------------------------------------------------ */ ++ ++ bool have_pythonprepend(Node *n) { ++ String* str = Getattr(n, "feature:pythonprepend"); ++ return (str != NULL && Len(str) > 0); ++ } ++ ++ /* ------------------------------------------------------------ ++ * pythonprepend() ++ * Get the %pythonprepend code, stripping off {} if neccessary ++ * ------------------------------------------------------------ */ ++ ++ String *pythonprepend(Node *n) { ++ String* str = Getattr(n, "feature:pythonprepend"); ++ char* t = Char(str); ++ if (*t == '{') { ++ Delitem(str ,0); ++ Delitem(str,DOH_END); ++ } ++ return str; ++ } ++ ++ /* ------------------------------------------------------------ ++ * have_pythonappend() ++ * Check if there is a %pythonappend directive and it has text ++ * ------------------------------------------------------------ */ ++ ++ bool have_pythonappend(Node *n) { ++ String* str = Getattr(n, "feature:pythonappend"); + return (str != NULL && Len(str) > 0); + } + + /* ------------------------------------------------------------ +- * addtofunc() +- * Get the %addtofunc code, stripping off {} if neccessary ++ * pythonappend() ++ * Get the %pythonappend code, stripping off {} if neccessary + * ------------------------------------------------------------ */ + +- String *addtofunc(Node *n) { +- String* str = Getattr(n, "feature:addtofunc"); ++ String *pythonappend(Node *n) { ++ String* str = Getattr(n, "feature:pythonappend"); + char* t = Char(str); + if (*t == '{') { + Delitem(str ,0); + Delitem(str,DOH_END); +@@ -1686,9 +2011,18 @@ + mod = Getattr(n,"module"); + if (mod) { + String *modname = Getattr(mod,"name"); + if (Strcmp(modname,mainmodule) != 0) { +- importname = NewStringf("%s.%s", modname, Getattr(n,"sym:name")); ++ // check if the module has a package option ++ String* pkg = NULL; ++ Node *options = Getattr(mod, "options"); ++ if (options && Getattr(options, "package")) ++ pkg = Getattr(options, "package"); ++ ++ if (!package || Strcmp(pkg, package) != 0) ++ importname = NewStringf("%s.%s.%s", pkg, modname, Getattr(n,"sym:name")); ++ else ++ importname = NewStringf("%s.%s", modname, Getattr(n,"sym:name")); + } else { + importname = NewString(Getattr(n,"sym:name")); + } + Setattr(n,"python:proxy",importname); +@@ -1760,9 +2094,11 @@ + Printf(f_shadow, modern ? "(object)" : "(_object)"); + } + } + Printf(f_shadow,":\n"); +- ++ if ( Getattr(n, "feature:docstring") ) // don't use have_docstring in this case because autodoc doesn't apply ++ Printv(f_shadow, tab4, docstring(n, AUTODOC_CLASS, tab4), "\n", NIL); ++ + if (!modern) { + Printv(f_shadow,tab4,"__swig_setmethods__ = {}\n",NIL); + if (Len(base_class)) { + Printf(f_shadow,"%sfor _s in [%s]: __swig_setmethods__.update(_s.__swig_setmethods__)\n",tab4,base_class); +@@ -1906,16 +2242,24 @@ + Delete(pyaction); + Printv(f_shadow,pycode,"\n",NIL); + } else { + +- Printv(f_shadow, tab4, "def ", symname, "(*args", (allow_kwargs ? ", **kwargs" : ""), "): ", NIL); +- if ( have_addtofunc(n) ) { +- Printv(f_shadow, "\n", NIL); +- Printv(f_shadow, tab8, "val = ", funcCallHelper(Swig_name_member(class_name,symname), allow_kwargs), "\n", NIL); +- Printv(f_shadow, tab8, addtofunc(n), "\n", NIL); +- Printv(f_shadow, tab8, "return val\n", NIL); ++ Printv(f_shadow, tab4, "def ", symname, "(*args", (allow_kwargs ? ", **kwargs" : ""), "):", NIL); ++ if ( !have_pythonprepend(n) && !have_pythonappend(n) && !have_docstring(n)) { ++ Printv(f_shadow, " return ", funcCallHelper(Swig_name_member(class_name,symname), allow_kwargs), "\n", NIL); + } else { +- Printv(f_shadow, "return ", funcCallHelper(Swig_name_member(class_name,symname), allow_kwargs), "\n", NIL); ++ Printv(f_shadow, "\n", NIL); ++ if ( have_docstring(n) ) ++ Printv(f_shadow, tab8, docstring(n, AUTODOC_METHOD, tab8), "\n", NIL); ++ if ( have_pythonprepend(n) ) ++ Printv(f_shadow, tab8, pythonprepend(n), "\n", NIL); ++ if ( have_pythonappend(n) ) { ++ Printv(f_shadow, tab8, "val = ", funcCallHelper(Swig_name_member(class_name,symname), allow_kwargs), "\n", NIL); ++ Printv(f_shadow, tab8, pythonappend(n), "\n", NIL); ++ Printv(f_shadow, tab8, "return val\n\n", NIL); ++ } else { ++ Printv(f_shadow, tab8, "return ", funcCallHelper(Swig_name_member(class_name,symname), allow_kwargs), "\n\n", NIL); ++ } + } + } + + } +@@ -1930,14 +2274,22 @@ + virtual int staticmemberfunctionHandler(Node *n) { + String *symname = Getattr(n,"sym:name"); + Language::staticmemberfunctionHandler(n); + if (shadow) { +- if ( !classic && have_addtofunc(n) ) { ++ if ( !classic && (have_pythonprepend(n) || have_pythonappend(n) || have_docstring(n)) ) { + int kw = (check_kwargs(n) && !Getattr(n,"sym:overloaded")) ? 1 : 0; + Printv(f_shadow, tab4, "def ", symname, "(*args", (kw ? ", **kwargs" : ""), "):\n", NIL); +- Printv(f_shadow, tab8, "val = ", funcCallHelper(Swig_name_member(class_name, symname), kw), "\n", NIL); +- Printv(f_shadow, tab8, addtofunc(n), "\n", NIL); +- Printv(f_shadow, tab8, "return val\n", NIL); ++ if ( have_docstring(n) ) ++ Printv(f_shadow, tab8, docstring(n, AUTODOC_STATICFUNC, tab8), "\n", NIL); ++ if ( have_pythonprepend(n) ) ++ Printv(f_shadow, tab8, pythonprepend(n), "\n", NIL); ++ if ( have_pythonappend(n) ) { ++ Printv(f_shadow, tab8, "val = ", funcCallHelper(Swig_name_member(class_name, symname), kw), "\n", NIL); ++ Printv(f_shadow, tab8, pythonappend(n), "\n", NIL); ++ Printv(f_shadow, tab8, "return val\n\n", NIL); ++ } else { ++ Printv(f_shadow, tab8, "return ", funcCallHelper(Swig_name_member(class_name, symname), kw), "\n\n", NIL); ++ } + Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname, + " = staticmethod(", symname, ")\n", NIL); + + if (!modern) { +@@ -2022,8 +2374,12 @@ + } + + Printv(f_shadow, tab4, "def __init__(self, *args", + (allow_kwargs ? ", **kwargs" : ""), "):\n", NIL); ++ if ( have_docstring(n) ) ++ Printv(f_shadow, tab8, docstring(n, AUTODOC_CTOR, tab8), "\n", NIL); ++ if ( have_pythonprepend(n) ) ++ Printv(f_shadow, tab8, pythonprepend(n), "\n", NIL); + Printv(f_shadow, pass_self, NIL); + if (!modern) { + Printv(f_shadow, tab8, "_swig_setattr(self, ", rclassname, ", 'this', ", + funcCallHelper(Swig_name_construct(symname), allow_kwargs), ")\n", NIL); +@@ -2036,10 +2392,10 @@ + Printv(f_shadow, tab8, "self.this = newobj.this\n", NIL); + Printv(f_shadow, tab8, "self.thisown = 1\n", NIL); + Printv(f_shadow, tab8, "del newobj.thisown\n", NIL); + } +- if ( have_addtofunc(n) ) +- Printv(f_shadow, tab8, addtofunc(n), "\n", NIL); ++ if ( have_pythonappend(n) ) ++ Printv(f_shadow, tab8, pythonappend(n), "\n\n", NIL); + Delete(pass_self); + } + have_constructor = 1; + } else { +@@ -2055,13 +2411,17 @@ + } else { + + Printv(f_shadow_stubs, "\ndef ", symname, "(*args", + (allow_kwargs ? ", **kwargs" : ""), "):\n", NIL); ++ if ( have_docstring(n) ) ++ Printv(f_shadow_stubs, tab4, docstring(n, AUTODOC_CTOR, tab4), "\n", NIL); ++ if ( have_pythonprepend(n) ) ++ Printv(f_shadow_stubs, tab4, pythonprepend(n), "\n", NIL); + Printv(f_shadow_stubs, tab4, "val = ", + funcCallHelper(Swig_name_construct(symname), allow_kwargs), "\n", NIL); + Printv(f_shadow_stubs, tab4, "val.thisown = 1\n", NIL); +- if ( have_addtofunc(n) ) +- Printv(f_shadow_stubs, tab4, addtofunc(n), "\n", NIL); ++ if ( have_pythonappend(n) ) ++ Printv(f_shadow_stubs, tab4, pythonappend(n), "\n", NIL); + Printv(f_shadow_stubs, tab4, "return val\n", NIL); + } + } + } +@@ -2088,13 +2448,18 @@ + Delete(pyaction); + Printv(f_shadow,pycode,"\n", NIL); + } else { + Printv(f_shadow, tab4, "def __del__(self, destroy=", module, ".", Swig_name_destroy(symname), "):\n", NIL); +- if ( have_addtofunc(n) ) +- Printv(f_shadow, tab8, addtofunc(n), "\n", NIL); ++ if ( have_docstring(n) ) ++ Printv(f_shadow, tab8, docstring(n, AUTODOC_DTOR, tab8), "\n", NIL); ++ if ( have_pythonprepend(n) ) ++ Printv(f_shadow, tab8, pythonprepend(n), "\n", NIL); + Printv(f_shadow, tab8, "try:\n", NIL); +- Printv(f_shadow, tab4, tab8, "if self.thisown: destroy(self)\n", NIL); ++ Printv(f_shadow, tab8, tab4, "if self.thisown: destroy(self)\n", NIL); + Printv(f_shadow, tab8, "except: pass\n", NIL); ++ if ( have_pythonappend(n) ) ++ Printv(f_shadow, tab8, pythonappend(n), "\n", NIL); ++ Printv(f_shadow, "\n", NIL); + } + } + return SWIG_OK; + } diff --git a/wxPython/SWIG/swig.python-docstring.patch b/wxPython/SWIG/swig.python-docstring.patch deleted file mode 100644 index d542fe69aa..0000000000 --- a/wxPython/SWIG/swig.python-docstring.patch +++ /dev/null @@ -1,609 +0,0 @@ -Index: Source/Modules/python.cxx -=================================================================== -RCS file: /cvsroot/swig/SWIG/Source/Modules/python.cxx,v -retrieving revision 1.40 -diff -u -4 -r1.40 python.cxx ---- Source/Modules/python.cxx 24 Jan 2004 00:25:31 -0000 1.40 -+++ Source/Modules/python.cxx 2 Jun 2004 01:38:46 -0000 -@@ -19,8 +19,9 @@ - - static String *const_code = 0; - static String *shadow_methods = 0; - static String *module = 0; -+static String *package = 0; - static String *mainmodule = 0; - static String *interface = 0; - static String *global_name = 0; - static int shadow = 1; -@@ -50,8 +51,18 @@ - static int have_constructor; - static int have_repr; - static String *real_classname; - -+/* flags for the make_autodoc function */ -+enum autodoc_t { -+ AUTODOC_CLASS, -+ AUTODOC_CTOR, -+ AUTODOC_DTOR, -+ AUTODOC_STATICFUNC, -+ AUTODOC_FUNC, -+ AUTODOC_METHOD -+}; -+ - static const char *usage = (char *)"\ - Python Options (available with -python)\n\ - -ldflags - Print runtime libraries to link with\n\ - -globals - Set used to access C global variable [default: 'cvar']\n\ -@@ -146,19 +157,22 @@ - * - * use %module(directors="1") modulename at the start of the - * interface file to enable director generation. - */ -+ String* mod_docstring = NULL; - { -- Node *module = Getattr(n, "module"); -- if (module) { -- Node *options = Getattr(module, "options"); -+ Node *mod = Getattr(n, "module"); -+ if (mod) { -+ Node *options = Getattr(mod, "options"); - if (options) { - if (Getattr(options, "directors")) { - allow_directors(); - } - if (Getattr(options, "dirprot")) { - allow_dirprot(); - } -+ mod_docstring = Getattr(options, "docstring"); -+ package = Getattr(options, "package"); - } - } - } - -@@ -258,8 +272,13 @@ - Printv(f_shadow, - "# This file is compatible with both classic and new-style classes.\n", - NIL); - } -+ -+ if (mod_docstring && Len(mod_docstring)) { -+ Printv(f_shadow, "\n\"\"\"\n", mod_docstring, "\n\"\"\"\n", NIL); -+ Delete(mod_docstring); mod_docstring = NULL; -+ } - - Printf(f_shadow,"\nimport %s\n\n", module); - - if (! modern) { -@@ -382,9 +401,28 @@ - virtual int importDirective(Node *n) { - if (shadow) { - String *modname = Getattr(n,"module"); - if (modname) { -- Printf(f_shadow,"import %s\n", modname); -+ Printf(f_shadow,"import "); -+ -+ // Find the module node for this imported module. It should be the -+ // first child but search just in case. -+ Node* mod = firstChild(n); -+ while (mod && Strcmp(nodeType(mod), "module") != 0) -+ mod = nextSibling(mod); -+ -+ // Is the imported module in another package? (IOW, does it use the -+ // %module(package="name") option and it's different than the package -+ // of this module.) -+ Node *options = Getattr(mod, "options"); -+ if (options && Getattr(options, "package")) { -+ String* pkg = Getattr(options, "package"); -+ if (!package || Strcmp(pkg, package) != 0) -+ Printf(f_shadow, "%s.", Getattr(options, "package")); -+ } -+ -+ // finally, output the name of the imported module -+ Printf(f_shadow, "%s\n", modname); - } - } - return Language::importDirective(n); - } -@@ -417,17 +455,25 @@ - * functions. - * ------------------------------------------------------------ */ - - void emitFunctionShadowHelper(Node *n, File *f_dest, String *name, int kw) { -- if ( ! have_addtofunc(n) ) { -- /* If there is no addtofunc directive then just assign from the extension module */ -+ if ( !have_pythonprepend(n) && !have_pythonappend(n) && !have_docstring(n) ) { -+ /* If there is no pythonappend or docstring directive then just assign from the extension module */ - Printv(f_dest, "\n", name, " = ", module, ".", name, "\n", NIL); - } else { - /* Otherwise make a wrapper function to insert the code into */ - Printv(f_dest, "\ndef ", name, "(*args", (kw ? ", **kwargs" : ""), "):\n", NIL); -- Printv(f_dest, tab4, "val = ", funcCallHelper(name, kw), "\n", NIL); -- Printv(f_dest, tab4, addtofunc(n), "\n", NIL); -- Printv(f_dest, tab4, "return val\n", NIL); -+ if ( have_docstring(n) ) -+ Printv(f_dest, tab4, docstring(n, AUTODOC_FUNC, tab4), "\n", NIL); -+ if ( have_pythonprepend(n) ) -+ Printv(f_dest, tab4, pythonprepend(n), "\n", NIL); -+ if ( have_pythonappend(n) ) { -+ Printv(f_dest, tab4, "val = ", funcCallHelper(name, kw), "\n", NIL); -+ Printv(f_dest, tab4, pythonappend(n), "\n", NIL); -+ Printv(f_dest, tab4, "return val\n", NIL); -+ } else { -+ Printv(f_dest, tab4, "return ", funcCallHelper(name, kw), "\n", NIL); -+ } - } - } - - -@@ -441,24 +487,303 @@ - } - - - /* ------------------------------------------------------------ -- * have_addtofunc() -- * Check if there is a %addtofunc directive and it has text -+ * have_docstring() -+ * Check if there is a docstring directive and it has text, -+ * or there is an autodoc flag set -+ * ------------------------------------------------------------ */ -+ -+ bool have_docstring(Node *n) { -+ String* str = Getattr(n, "feature:docstring"); -+ return (str != NULL && Len(str) > 0) || -+ (Getattr(n,"feature:autodoc") && !Getattr(n, "feature:noautodoc")); -+ } -+ -+ /* ------------------------------------------------------------ -+ * docstring() -+ * Get the docstring text, stripping off {} if neccessary, -+ * and enclose in triple double quotes. If autodoc is also -+ * set then it will build a combined docstring. -+ * ------------------------------------------------------------ */ -+ -+ String *docstring(Node *n, autodoc_t ad_type, const String* indent) { -+ String* str = Getattr(n, "feature:docstring"); -+ bool have_ds = (str != NULL && Len(str) > 0); -+ bool have_auto = (Getattr(n,"feature:autodoc") && !Getattr(n, "feature:noautodoc")); -+ char* triple_double = "\"\"\""; -+ String* autodoc = NULL; -+ String* doc = NULL; -+ -+ if ( have_ds ) { -+ char* t = Char(str); -+ if (*t == '{') { -+ Delitem(str ,0); -+ Delitem(str,DOH_END); -+ } -+ } -+ -+ if ( have_auto ) { -+ autodoc = make_autodoc(n, ad_type); -+ have_auto = (autodoc != NULL && Len(autodoc) > 0); -+ } -+ -+ // If there is more than one line then make docstrings like this: -+ // -+ // """ -+ // This is line1 -+ // And here is line2 followed by the rest of them -+ // """ -+ // -+ // otherwise, put it all on a single line -+ // -+ if ( have_auto && have_ds ) { // Both autodoc and docstring are present -+ doc = NewString(""); -+ Printv(doc, triple_double, "\n", -+ pythoncode(autodoc, indent), "\n", -+ pythoncode(str, indent), -+ indent, triple_double, NIL); -+ } -+ else if ( !have_auto && have_ds ) { // only docstring -+ if (Strchr(str, '\n') == NULL) { -+ doc = NewStringf("%s%s%s", triple_double, str, triple_double); -+ } -+ else { -+ doc = NewString(""); -+ Printv(doc, triple_double, "\n", -+ pythoncode(str, indent), -+ indent, triple_double, NIL); -+ } -+ } -+ else if ( have_auto && !have_ds ) { // only autodoc -+ if (Strchr(autodoc, '\n') == NULL) { -+ doc = NewStringf("%s%s%s", triple_double, autodoc, triple_double); -+ } -+ else { -+ doc = NewString(""); -+ Printv(doc, triple_double, "\n", -+ pythoncode(autodoc, indent), -+ indent, triple_double, NIL); -+ } -+ } -+ else -+ doc = NewString(""); -+ -+ // Save the generated strings in the parse tree in case they are used later -+ // by post processing tools -+ Setattr(n, "python:docstring", doc); -+ Setattr(n, "python:autodoc", autodoc); -+ return doc; -+ } -+ -+ -+ /* ------------------------------------------------------------ -+ * make_autodoc() -+ * Build a docstring for the node, using parameter and other -+ * info in the parse tree. If the value of the autodoc -+ * attribute is "0" then do not include parameter types, if -+ * it is "1" (the default) then do. If it has some other -+ * value then assume it is supplied by the extension writer -+ * and use it directly. -+ * ------------------------------------------------------------ */ -+ -+ String* make_autodoc(Node *n, autodoc_t ad_type) { -+ -+ if (ad_type == AUTODOC_CLASS) -+ return NULL; // No function call to document in this case -+ -+ // If the function is overloaded then this funciton is called -+ // for the last one. Rewind to the first so the docstrings are -+ // in order. -+ while ( Getattr(n, "sym:previousSibling") ) -+ n = Getattr(n, "sym:previousSibling"); -+ -+ String* doc = NewString(""); -+ while (n) { -+ bool showTypes = false; -+ bool skipAuto = false; -+ -+ // check how should the parameters be rendered? -+ String* autodoc = Getattr(n, "feature:autodoc"); -+ if (Strcmp(autodoc, "0") == 0) -+ showTypes = false; -+ else if (Strcmp(autodoc, "1") == 0) -+ showTypes = true; -+ else { -+ // if not "0" or "1" then autodoc is already the string that should be used -+ Printf(doc, "%s", autodoc); -+ skipAuto = true; -+ } -+ -+ if (!skipAuto) { -+ String* symname = Getattr(n, "sym:name"); -+ SwigType* type = Getattr(n, "type"); -+ -+ if (type) { -+ if (Strcmp(type, "void") == 0) -+ type = NULL; -+ else { -+ SwigType* qt = SwigType_typedef_resolve_all(type); -+ if (SwigType_isenum(qt)) -+ type = NewString("int"); -+ else { -+ type = SwigType_base(type); -+ Node* lookup = Swig_symbol_clookup(type, 0); -+ if (lookup) -+ type = Getattr(lookup, "sym:name"); -+ } -+ } -+ } -+ -+ switch ( ad_type ) { -+ case AUTODOC_CTOR: -+ if ( Strcmp(class_name, symname) == 0) { -+ String* paramList = make_autodocParmList(n, showTypes); -+ if (Len(paramList)) -+ Printf(doc, "__init__(self, %s) -> %s", paramList, class_name); -+ else -+ Printf(doc, "__init__(self) -> %s", class_name); -+ } -+ else -+ Printf(doc, "%s(%s) -> %s", symname, make_autodocParmList(n, showTypes), class_name); -+ break; -+ -+ case AUTODOC_DTOR: -+ Printf(doc, "__del__(self)"); -+ break; -+ -+ case AUTODOC_STATICFUNC: -+ Printf(doc, "%s(%s)", symname, make_autodocParmList(n, showTypes)); -+ if (type) Printf(doc, " -> %s", type); -+ break; -+ -+ case AUTODOC_FUNC: -+ Printf(doc, "%s(%s)", symname, make_autodocParmList(n, showTypes)); -+ if (type) Printf(doc, " -> %s", type); -+ break; -+ -+ case AUTODOC_METHOD: -+ String* paramList = make_autodocParmList(n, showTypes); -+ if (Len(paramList)) -+ Printf(doc, "%s(self, %s)", symname, paramList); -+ else -+ Printf(doc, "%s(self)", symname); -+ if (type) Printf(doc, " -> %s", type); -+ break; -+ } -+ } -+ -+ // if it's overloaded then get the next decl and loop around again -+ n = Getattr(n, "sym:nextSibling"); -+ if (n) -+ Printf(doc, "\n"); -+ } -+ -+ return doc; -+ } -+ -+ -+ String* make_autodocParmList(Node* n, bool showTypes) { -+ String* doc = NewString(""); -+ ParmList* plist = Getattr(n,"parms"); -+ Parm* p; -+ Node* lookup; -+ int lines = 0; -+ const int maxwidth = 50; -+ -+ -+ for (p = plist; p; p = nextSibling(p)) { -+ String* name = Getattr(p, "name"); -+ String* value = Getattr(p, "value"); -+ -+ if ( Len(doc) ) { -+ // add a comma to the previous one if any -+ Printf(doc, ", "); -+ -+ // Do we need to wrap a long line? -+ if ((Len(doc) - lines*maxwidth) > maxwidth) { -+ Printf(doc, "\n%s", tab4); -+ lines += 1; -+ } -+ } -+ -+ // Do the param type too? -+ if (showTypes) { -+ SwigType* type = SwigType_base(Getattr(p, "type")); -+ SwigType* qt = SwigType_typedef_resolve_all(type); -+ if (SwigType_isenum(qt)) -+ type = NewString("int"); -+ else { -+ lookup = Swig_symbol_clookup(type, 0); -+ if (lookup) -+ type = Getattr(lookup, "sym:name"); -+ } -+ Printf(doc, "%s ", type); -+ } -+ -+ if (name) -+ Printf(doc, "%s", name); -+ else -+ Printf(doc, "??"); -+ -+ if (value) { -+ if (Strcmp(value, "NULL") == 0) -+ value = NewString("None"); -+ else { -+ lookup = Swig_symbol_clookup(value, 0); -+ if (lookup) -+ value = Getattr(lookup, "sym:name"); -+ } -+ Printf(doc, "=%s", value); -+ } -+ } -+ -+ return doc; -+ } -+ -+ -+ /* ------------------------------------------------------------ -+ * have_pythonprepend() -+ * Check if there is a %pythonprepend directive and it has text -+ * ------------------------------------------------------------ */ -+ -+ bool have_pythonprepend(Node *n) { -+ String* str = Getattr(n, "feature:pythonprepend"); -+ return (str != NULL && Len(str) > 0); -+ } -+ -+ /* ------------------------------------------------------------ -+ * pythonprepend() -+ * Get the %pythonprepend code, stripping off {} if neccessary -+ * ------------------------------------------------------------ */ -+ -+ String *pythonprepend(Node *n) { -+ String* str = Getattr(n, "feature:pythonprepend"); -+ char* t = Char(str); -+ if (*t == '{') { -+ Delitem(str ,0); -+ Delitem(str,DOH_END); -+ } -+ return str; -+ } -+ -+ /* ------------------------------------------------------------ -+ * have_pythonappend() -+ * Check if there is a %pythonappend directive and it has text - * ------------------------------------------------------------ */ - -- bool have_addtofunc(Node *n) { -- String* str = Getattr(n, "feature:addtofunc"); -+ bool have_pythonappend(Node *n) { -+ String* str = Getattr(n, "feature:pythonappend"); - return (str != NULL && Len(str) > 0); - } - - /* ------------------------------------------------------------ -- * addtofunc() -- * Get the %addtofunc code, stripping off {} if neccessary -+ * pythonappend() -+ * Get the %pythonappend code, stripping off {} if neccessary - * ------------------------------------------------------------ */ - -- String *addtofunc(Node *n) { -- String* str = Getattr(n, "feature:addtofunc"); -+ String *pythonappend(Node *n) { -+ String* str = Getattr(n, "feature:pythonappend"); - char* t = Char(str); - if (*t == '{') { - Delitem(str ,0); - Delitem(str,DOH_END); -@@ -1657,9 +1982,18 @@ - mod = Getattr(n,"module"); - if (mod) { - String *modname = Getattr(mod,"name"); - if (Strcmp(modname,mainmodule) != 0) { -- importname = NewStringf("%s.%s", modname, Getattr(n,"sym:name")); -+ // check if the module has a package option -+ String* pkg = NULL; -+ Node *options = Getattr(mod, "options"); -+ if (options && Getattr(options, "package")) -+ pkg = Getattr(options, "package"); -+ -+ if (!package || Strcmp(pkg, package) != 0) -+ importname = NewStringf("%s.%s.%s", pkg, modname, Getattr(n,"sym:name")); -+ else -+ importname = NewStringf("%s.%s", modname, Getattr(n,"sym:name")); - } else { - importname = NewString(Getattr(n,"sym:name")); - } - Setattr(n,"python:proxy",importname); -@@ -1731,9 +2065,11 @@ - Printf(f_shadow, modern ? "(object)" : "(_object)"); - } - } - Printf(f_shadow,":\n"); -- -+ if ( Getattr(n, "feature:docstring") ) // don't use have_docstring in this case because autodoc doesn't apply -+ Printv(f_shadow, tab4, docstring(n, AUTODOC_CLASS, tab4), "\n", NIL); -+ - if (!modern) { - Printv(f_shadow,tab4,"__swig_setmethods__ = {}\n",NIL); - if (Len(base_class)) { - Printf(f_shadow,"%sfor _s in [%s]: __swig_setmethods__.update(_s.__swig_setmethods__)\n",tab4,base_class); -@@ -1866,16 +2202,24 @@ - Delete(pyaction); - Printv(f_shadow,pycode,"\n",NIL); - } else { - -- Printv(f_shadow, tab4, "def ", symname, "(*args", (allow_kwargs ? ", **kwargs" : ""), "): ", NIL); -- if ( have_addtofunc(n) ) { -- Printv(f_shadow, "\n", NIL); -- Printv(f_shadow, tab8, "val = ", funcCallHelper(Swig_name_member(class_name,symname), allow_kwargs), "\n", NIL); -- Printv(f_shadow, tab8, addtofunc(n), "\n", NIL); -- Printv(f_shadow, tab8, "return val\n", NIL); -+ Printv(f_shadow, tab4, "def ", symname, "(*args", (allow_kwargs ? ", **kwargs" : ""), "):", NIL); -+ if ( !have_pythonprepend(n) && !have_pythonappend(n) && !have_docstring(n)) { -+ Printv(f_shadow, " return ", funcCallHelper(Swig_name_member(class_name,symname), allow_kwargs), "\n", NIL); - } else { -- Printv(f_shadow, "return ", funcCallHelper(Swig_name_member(class_name,symname), allow_kwargs), "\n", NIL); -+ Printv(f_shadow, "\n", NIL); -+ if ( have_docstring(n) ) -+ Printv(f_shadow, tab8, docstring(n, AUTODOC_METHOD, tab8), "\n", NIL); -+ if ( have_pythonprepend(n) ) -+ Printv(f_shadow, tab8, pythonprepend(n), "\n", NIL); -+ if ( have_pythonappend(n) ) { -+ Printv(f_shadow, tab8, "val = ", funcCallHelper(Swig_name_member(class_name,symname), allow_kwargs), "\n", NIL); -+ Printv(f_shadow, tab8, pythonappend(n), "\n", NIL); -+ Printv(f_shadow, tab8, "return val\n\n", NIL); -+ } else { -+ Printv(f_shadow, tab8, "return ", funcCallHelper(Swig_name_member(class_name,symname), allow_kwargs), "\n\n", NIL); -+ } - } - } - - } -@@ -1890,14 +2234,22 @@ - virtual int staticmemberfunctionHandler(Node *n) { - String *symname = Getattr(n,"sym:name"); - Language::staticmemberfunctionHandler(n); - if (shadow) { -- if ( !classic && have_addtofunc(n) ) { -+ if ( !classic && (have_pythonprepend(n) || have_pythonappend(n) || have_docstring(n)) ) { - int kw = (check_kwargs(n) && !Getattr(n,"sym:overloaded")) ? 1 : 0; - Printv(f_shadow, tab4, "def ", symname, "(*args", (kw ? ", **kwargs" : ""), "):\n", NIL); -- Printv(f_shadow, tab8, "val = ", funcCallHelper(Swig_name_member(class_name, symname), kw), "\n", NIL); -- Printv(f_shadow, tab8, addtofunc(n), "\n", NIL); -- Printv(f_shadow, tab8, "return val\n", NIL); -+ if ( have_docstring(n) ) -+ Printv(f_shadow, tab8, docstring(n, AUTODOC_STATICFUNC, tab8), "\n", NIL); -+ if ( have_pythonprepend(n) ) -+ Printv(f_shadow, tab8, pythonprepend(n), "\n", NIL); -+ if ( have_pythonappend(n) ) { -+ Printv(f_shadow, tab8, "val = ", funcCallHelper(Swig_name_member(class_name, symname), kw), "\n", NIL); -+ Printv(f_shadow, tab8, pythonappend(n), "\n", NIL); -+ Printv(f_shadow, tab8, "return val\n\n", NIL); -+ } else { -+ Printv(f_shadow, tab8, "return ", funcCallHelper(Swig_name_member(class_name, symname), kw), "\n\n", NIL); -+ } - Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname, - " = staticmethod(", symname, ")\n", NIL); - - if (!modern) { -@@ -1982,8 +2334,12 @@ - } - - Printv(f_shadow, tab4, "def __init__(self, *args", - (allow_kwargs ? ", **kwargs" : ""), "):\n", NIL); -+ if ( have_docstring(n) ) -+ Printv(f_shadow, tab8, docstring(n, AUTODOC_CTOR, tab8), "\n", NIL); -+ if ( have_pythonprepend(n) ) -+ Printv(f_shadow, tab8, pythonprepend(n), "\n", NIL); - Printv(f_shadow, pass_self, NIL); - if (!modern) { - Printv(f_shadow, tab8, "_swig_setattr(self, ", rclassname, ", 'this', ", - funcCallHelper(Swig_name_construct(symname), allow_kwargs), ")\n", NIL); -@@ -1996,10 +2352,10 @@ - Printv(f_shadow, tab8, "self.this = newobj.this\n", NIL); - Printv(f_shadow, tab8, "self.thisown = 1\n", NIL); - Printv(f_shadow, tab8, "del newobj.thisown\n", NIL); - } -- if ( have_addtofunc(n) ) -- Printv(f_shadow, tab8, addtofunc(n), "\n", NIL); -+ if ( have_pythonappend(n) ) -+ Printv(f_shadow, tab8, pythonappend(n), "\n\n", NIL); - Delete(pass_self); - } - have_constructor = 1; - } else { -@@ -2015,13 +2371,17 @@ - } else { - - Printv(f_shadow_stubs, "\ndef ", symname, "(*args", - (allow_kwargs ? ", **kwargs" : ""), "):\n", NIL); -+ if ( have_docstring(n) ) -+ Printv(f_shadow_stubs, tab4, docstring(n, AUTODOC_CTOR, tab4), "\n", NIL); -+ if ( have_pythonprepend(n) ) -+ Printv(f_shadow_stubs, tab4, pythonprepend(n), "\n", NIL); - Printv(f_shadow_stubs, tab4, "val = ", - funcCallHelper(Swig_name_construct(symname), allow_kwargs), "\n", NIL); - Printv(f_shadow_stubs, tab4, "val.thisown = 1\n", NIL); -- if ( have_addtofunc(n) ) -- Printv(f_shadow_stubs, tab4, addtofunc(n), "\n", NIL); -+ if ( have_pythonappend(n) ) -+ Printv(f_shadow_stubs, tab4, pythonappend(n), "\n", NIL); - Printv(f_shadow_stubs, tab4, "return val\n", NIL); - } - } - } -@@ -2048,13 +2408,18 @@ - Delete(pyaction); - Printv(f_shadow,pycode,"\n", NIL); - } else { - Printv(f_shadow, tab4, "def __del__(self, destroy=", module, ".", Swig_name_destroy(symname), "):\n", NIL); -- if ( have_addtofunc(n) ) -- Printv(f_shadow, tab8, addtofunc(n), "\n", NIL); -+ if ( have_docstring(n) ) -+ Printv(f_shadow, tab8, docstring(n, AUTODOC_DTOR, tab8), "\n", NIL); -+ if ( have_pythonprepend(n) ) -+ Printv(f_shadow, tab8, pythonprepend(n), "\n", NIL); - Printv(f_shadow, tab8, "try:\n", NIL); -- Printv(f_shadow, tab4, tab8, "if self.thisown: destroy(self)\n", NIL); -+ Printv(f_shadow, tab8, tab4, "if self.thisown: destroy(self)\n", NIL); - Printv(f_shadow, tab8, "except: pass\n", NIL); -+ if ( have_pythonappend(n) ) -+ Printv(f_shadow, tab8, pythonappend(n), "\n", NIL); -+ Printv(f_shadow, "\n", NIL); - } - } - return SWIG_OK; - } diff --git a/wxPython/SWIG/swig.python.patch b/wxPython/SWIG/swig.python.patch deleted file mode 100644 index 5e09b7900b..0000000000 --- a/wxPython/SWIG/swig.python.patch +++ /dev/null @@ -1,598 +0,0 @@ -Index: Source/Modules/python.cxx -=================================================================== -RCS file: /cvsroot/SWIG/Source/Modules/python.cxx,v -retrieving revision 1.25 -diff -u -r1.25 python.cxx ---- Source/Modules/python.cxx 23 Sep 2003 21:26:04 -0000 1.25 -+++ Source/Modules/python.cxx 30 Oct 2003 02:39:33 -0000 -@@ -292,6 +292,9 @@ - static String *shadow_indent = 0; - static int in_class = 0; - static int classic = 0; -+static int modern = 0; -+static int apply = 0; -+static int new_repr = 0; - - /* C++ Support + Shadow Classes */ - -@@ -306,6 +309,9 @@ - -interface - Set the lib name to \n\ - -keyword - Use keyword arguments\n\ - -classic - Use classic classes only\n\ -+ -modern - Use modern python features only, without compatibility code\n\ -+ -apply - Use apply() in proxy classes\n\ -+ -new_repr - Use more informative version of __repr__ in proxy classes\n\ - -noexcept - No automatic exception handling\n\ - -noproxy - Don't generate proxy classes \n\n"; - -@@ -344,6 +350,12 @@ - } else if ((strcmp(argv[i],"-shadow") == 0) || ((strcmp(argv[i],"-proxy") == 0))) { - shadow = 1; - Swig_mark_arg(i); -+ } else if (strcmp(argv[i],"-apply") == 0) { -+ apply = 1; -+ Swig_mark_arg(i); -+ } else if (strcmp(argv[i],"-new_repr") == 0) { -+ new_repr = 1; -+ Swig_mark_arg(i); - } else if ((strcmp(argv[i],"-noproxy") == 0)) { - shadow = 0; - Swig_mark_arg(i); -@@ -353,6 +365,10 @@ - } else if (strcmp(argv[i],"-classic") == 0) { - classic = 1; - Swig_mark_arg(i); -+ } else if (strcmp(argv[i],"-modern") == 0) { -+ classic = 0; -+ modern = 1; -+ Swig_mark_arg(i); - } else if (strcmp(argv[i],"-help") == 0) { - fputs(usage,stderr); - } else if (strcmp (argv[i], "-ldflags") == 0) { -@@ -480,47 +496,54 @@ - Printv(f_shadow, - "# This file was created automatically by SWIG.\n", - "# Don't modify this file, modify the SWIG interface instead.\n", -- "# This file is compatible with both classic and new-style classes.\n", - NIL); - -- Printf(f_shadow,"import %s\n", module); -- -- // Python-2.2 object hack -- -- Printv(f_shadow, -- "def _swig_setattr(self,class_type,name,value):\n", -- tab4, "if (name == \"this\"):\n", -- tab4, tab4, "if isinstance(value, class_type):\n", -- tab4, tab8, "self.__dict__[name] = value.this\n", -- tab4, tab8, "if hasattr(value,\"thisown\"): self.__dict__[\"thisown\"] = value.thisown\n", -- tab4, tab8, "del value.thisown\n", -- tab4, tab8, "return\n", -- // tab8, "if (name == \"this\") or (name == \"thisown\"): self.__dict__[name] = value; return\n", -- tab4, "method = class_type.__swig_setmethods__.get(name,None)\n", -- tab4, "if method: return method(self,value)\n", -- tab4, "self.__dict__[name] = value\n\n", -- NIL); -+ if (! modern) { -+ Printv(f_shadow, -+ "# This file is compatible with both classic and new-style classes.\n", -+ NIL); -+ } -+ -+ Printf(f_shadow,"\nimport %s\n\n", module); - -- Printv(f_shadow, -- "def _swig_getattr(self,class_type,name):\n", -- tab4, "method = class_type.__swig_getmethods__.get(name,None)\n", -- tab4, "if method: return method(self)\n", -- tab4, "raise AttributeError,name\n\n", -- NIL); -+ if (! modern) { -+ // Python-2.2 object hack -+ Printv(f_shadow, -+ "def _swig_setattr(self,class_type,name,value):\n", -+ tab4, "if (name == \"this\"):\n", -+ tab4, tab4, "if isinstance(value, class_type):\n", -+ tab4, tab8, "self.__dict__[name] = value.this\n", -+ tab4, tab8, "if hasattr(value,\"thisown\"): self.__dict__[\"thisown\"] = value.thisown\n", -+ tab4, tab8, "del value.thisown\n", -+ tab4, tab8, "return\n", -+ // tab8, "if (name == \"this\") or (name == \"thisown\"): self.__dict__[name] = value; return\n", -+ tab4, "method = class_type.__swig_setmethods__.get(name,None)\n", -+ tab4, "if method: return method(self,value)\n", -+ tab4, "self.__dict__[name] = value\n\n", -+ NIL); - -- if (!classic) { -- Printv(f_shadow, -- "import types\n", -- "try:\n", -- " _object = types.ObjectType\n", -- " _newclass = 1\n", -- "except AttributeError:\n", -- " class _object : pass\n", -- " _newclass = 0\n", -- "\n\n", -- NIL); -+ Printv(f_shadow, -+ "def _swig_getattr(self,class_type,name):\n", -+ tab4, "method = class_type.__swig_getmethods__.get(name,None)\n", -+ tab4, "if method: return method(self)\n", -+ tab4, "raise AttributeError,name\n\n", -+ NIL); -+ -+ if (!classic) { -+ Printv(f_shadow, -+ "import types\n", -+ "try:\n", -+ " _object = types.ObjectType\n", -+ " _newclass = 1\n", -+ "except AttributeError:\n", -+ " class _object : pass\n", -+ " _newclass = 0\n", -+ "del types\n", -+ "\n\n", -+ NIL); -+ } - } -- -+ - if (directorsEnabled()) { - // Try loading weakref.proxy, which is only available in Python 2.1 and higher - Printv(f_shadow, -@@ -610,6 +633,83 @@ - return Language::importDirective(n); - } - -+ -+ /* ------------------------------------------------------------ -+ * emitFuncCallHelper() -+ * Write the shadow code to call a function in the extension -+ * module. Takes into account the -apply flag and whether -+ * to use keyword args or not. -+ * ------------------------------------------------------------ */ -+ -+ String *funcCallHelper(String *name, int kw) { -+ String *str; -+ -+ str = NewString(""); -+ if (apply) { -+ Printv(str, "apply(", module, ".", name, ", args", (kw ? ", kwargs" : ""), ")", NIL); -+ } else { -+ Printv(str, module, ".", name, "(*args", (kw ? ", **kwargs" : ""), ")", NIL); -+ } -+ return str; -+ } -+ -+ -+ /* ------------------------------------------------------------ -+ * emitFunctionShadowHelper() -+ * Refactoring some common code out of functionWrapper and -+ * dispatchFunction that writes the proxy code for non-member -+ * functions. -+ * ------------------------------------------------------------ */ -+ -+ void emitFunctionShadowHelper(Node *n, File *f_dest, String *name, int kw) { -+ if ( ! have_addtofunc(n) ) { -+ /* If there is no addtofunc directive then just assign from the extension module */ -+ Printv(f_dest, "\n", name, " = ", module, ".", name, "\n", NIL); -+ } else { -+ /* Otherwise make a wrapper function to insert the code into */ -+ Printv(f_dest, "\ndef ", name, "(*args", (kw ? ", **kwargs" : ""), "):\n", NIL); -+ Printv(f_dest, tab4, "val = ", funcCallHelper(name, kw), "\n", NIL); -+ Printv(f_dest, tab4, addtofunc(n), "\n", NIL); -+ Printv(f_dest, tab4, "return val\n", NIL); -+ } -+ } -+ -+ -+ /* ------------------------------------------------------------ -+ * check_kwargs() -+ * check if using kwargs is allowed for this Node -+ * ------------------------------------------------------------ */ -+ -+ int check_kwargs(Node *n) { -+ return ((use_kw || Getattr(n,"feature:kwargs")) && !Getattr(n, "feature:nokwargs")) ? 1 : 0; -+ } -+ -+ -+ /* ------------------------------------------------------------ -+ * have_addtofunc() -+ * Check if there is a %addtofunc directive and it has text -+ * ------------------------------------------------------------ */ -+ -+ bool have_addtofunc(Node *n) { -+ String* str = Getattr(n, "feature:addtofunc"); -+ return (str != NULL && Len(str) > 0); -+ } -+ -+ /* ------------------------------------------------------------ -+ * addtofunc() -+ * Get the %addtofunc code, stripping off {} if neccessary -+ * ------------------------------------------------------------ */ -+ -+ String *addtofunc(Node *n) { -+ String* str = Getattr(n, "feature:addtofunc"); -+ char* t = Char(str); -+ if (*t == '{') { -+ Delitem(str ,0); -+ Delitem(str,DOH_END); -+ } -+ return str; -+ } -+ - /* ------------------------------------------------------------ - * add_method() - * ------------------------------------------------------------ */ -@@ -650,7 +750,7 @@ - int num_required; - int num_arguments; - int varargs = 0; -- int allow_kwargs = (use_kw || Getattr(n,"feature:kwargs")) ? 1 : 0; -+ int allow_kwargs = check_kwargs(n); - - /* member of a director class? */ - String *nodeType = Getattr(n, "nodeType"); -@@ -1007,11 +1107,7 @@ - - /* Create a shadow for this function (if enabled and not in a member function) */ - if ((shadow) && (!(shadow & PYSHADOW_MEMBER))) { -- if (in_class) { -- Printv(f_shadow_stubs,iname, " = ", module, ".", iname, "\n\n", NIL); -- } else { -- Printv(f_shadow,iname, " = ", module, ".", iname, "\n\n", NIL); -- } -+ emitFunctionShadowHelper(n, in_class ? f_shadow_stubs : f_shadow, iname, allow_kwargs); - } - } else { - if (!Getattr(n,"sym:nextSibling")) { -@@ -1068,7 +1164,7 @@ - - /* Create a shadow for this function (if enabled and not in a member function) */ - if ((shadow) && (!(shadow & PYSHADOW_MEMBER))) { -- Printv(f_shadow_stubs,symname, " = ", module, ".", symname, "\n\n", NIL); -+ emitFunctionShadowHelper(n, f_shadow_stubs, symname, 0); - } - DelWrapper(f); - Delete(dispatch); -@@ -1754,6 +1850,7 @@ - - virtual int classHandler(Node *n) { - int oldclassic = classic; -+ int oldmodern = modern; - - if (shadow) { - -@@ -1763,8 +1860,16 @@ - - if (Getattr(n,"cplus:exceptionclass")) { - classic = 1; -+ modern = 0; -+ } -+ if (Getattr(n,"feature:classic")) { -+ classic = 1; -+ modern = 0; -+ } -+ if (Getattr(n,"feature:modern")) { -+ classic = 0; -+ modern = 1; - } -- if (Getattr(n,"feature:classic")) classic = 1; - - shadow_indent = (String *) tab4; - -@@ -1798,30 +1903,32 @@ - Printf(f_shadow,"(%s)", base_class); - } else { - if (!classic) { -- Printf(f_shadow,"(_object)"); -+ Printf(f_shadow, modern ? "(object)" : "(_object)"); - } - } - Printf(f_shadow,":\n"); - -- Printv(f_shadow,tab4,"__swig_setmethods__ = {}\n",NIL); -- if (Len(base_class)) { -- Printf(f_shadow,"%sfor _s in [%s]: __swig_setmethods__.update(_s.__swig_setmethods__)\n",tab4,base_class); -- } -+ if (!modern) { -+ Printv(f_shadow,tab4,"__swig_setmethods__ = {}\n",NIL); -+ if (Len(base_class)) { -+ Printf(f_shadow,"%sfor _s in [%s]: __swig_setmethods__.update(_s.__swig_setmethods__)\n",tab4,base_class); -+ } - -- Printv(f_shadow, -- tab4, "__setattr__ = lambda self, name, value: _swig_setattr(self, ", class_name, ", name, value)\n", -- NIL); -+ Printv(f_shadow, -+ tab4, "__setattr__ = lambda self, name, value: _swig_setattr(self, ", class_name, ", name, value)\n", -+ NIL); - -- Printv(f_shadow,tab4,"__swig_getmethods__ = {}\n",NIL); -- if (Len(base_class)) { -- Printf(f_shadow,"%sfor _s in [%s]: __swig_getmethods__.update(_s.__swig_getmethods__)\n",tab4,base_class); -- } -+ Printv(f_shadow,tab4,"__swig_getmethods__ = {}\n",NIL); -+ if (Len(base_class)) { -+ Printf(f_shadow,"%sfor _s in [%s]: __swig_getmethods__.update(_s.__swig_getmethods__)\n",tab4,base_class); -+ } - -- Printv(f_shadow, -- tab4, "__getattr__ = lambda self, name: _swig_getattr(self, ", class_name, ", name)\n", -- NIL); -+ Printv(f_shadow, -+ tab4, "__getattr__ = lambda self, name: _swig_getattr(self, ", class_name, ", name)\n", -+ NIL); -+ } - } -- -+ - /* Emit all of the members */ - - in_class = 1; -@@ -1853,21 +1960,37 @@ - - if (!have_repr) { - /* Supply a repr method for this class */ -- Printv(f_shadow, -- tab4, "def __repr__(self):\n", -- tab8, "return \"\" % (self.this,)\n", -- NIL); -+ if (new_repr) { -+ Printv(f_shadow, -+ tab4, "def __repr__(self):\n", -+ tab8, "return \"<%s.%s; proxy of ", CPlusPlus ? "C++ " : "C ", real_classname," instance at %s>\" % (self.__class__.__module__, self.__class__.__name__, self.this,)\n", -+ NIL); -+ } -+ else { -+ Printv(f_shadow, -+ tab4, "def __repr__(self):\n", -+ tab8, "return \"\" % (self.this,)\n", -+ NIL); -+ } - } -- /* Now build the real class with a normal constructor */ -+ /* Now the Ptr class */ - Printv(f_shadow, - "\nclass ", class_name, "Ptr(", class_name, "):\n", -- tab4, "def __init__(self,this):\n", -- tab8, "_swig_setattr(self, ", class_name, ", 'this', this)\n", -- tab8, "if not hasattr(self,\"thisown\"): _swig_setattr(self, ", class_name, ", 'thisown', 0)\n", -+ tab4, "def __init__(self, this):\n", NIL); -+ if (!modern) { -+ Printv(f_shadow, -+ tab8, "_swig_setattr(self, ", class_name, ", 'this', this)\n", -+ tab8, "if not hasattr(self,\"thisown\"): _swig_setattr(self, ", class_name, ", 'thisown', 0)\n", -+ tab8, "_swig_setattr(self, ", class_name, ",self.__class__,", class_name, ")\n", -+ NIL); -+ } else { -+ Printv(f_shadow, -+ tab8, "self.this = this\n", -+ tab8, "if not hasattr(self,\"thisown\"): self.thisown = 0\n", -+ tab8, "self.__class__ = ", class_name, "\n", NIL); - // tab8,"try: self.this = this.this; self.thisown = getattr(this,'thisown',0); this.thisown=0\n", - // tab8,"except AttributeError: self.this = this\n" -- tab8, "_swig_setattr(self, ", class_name, ",self.__class__,", class_name, ")\n", -- NIL); -+ } - - Printf(f_shadow,"%s.%s_swigregister(%sPtr)\n", module, class_name, class_name,0); - shadow_indent = 0; -@@ -1875,6 +1998,7 @@ - Clear(f_shadow_stubs); - } - classic = oldclassic; -+ modern = oldmodern; - return SWIG_OK; - } - -@@ -1894,7 +2018,7 @@ - - if (!Getattr(n,"sym:nextSibling")) { - if (shadow) { -- int allow_kwargs = (use_kw || Getattr(n,"feature:kwargs")) ? 1 : 0; -+ int allow_kwargs = (check_kwargs(n) && !Getattr(n,"sym:overloaded")) ? 1 : 0; - if (Strcmp(symname,"__repr__") == 0) - have_repr = 1; - -@@ -1902,14 +2026,18 @@ - String *pycode = pythoncode(Getattr(n,"feature:shadow"),tab4); - Printv(f_shadow,pycode,"\n",NIL); - } else { -- if (allow_kwargs && !Getattr(n,"sym:overloaded")) { -- Printv(f_shadow,tab4, "def ", symname, "(*args, **kwargs): ", NIL); -- Printv(f_shadow, "return apply(", module, ".", Swig_name_member(class_name,symname), ",args, kwargs)\n", NIL); -- } else { -- Printv(f_shadow, tab4, "def ", symname, "(*args): ", NIL); -- Printv(f_shadow, "return apply(", module, ".", Swig_name_member(class_name,symname), ",args)\n",NIL); -- } -- } -+ -+ Printv(f_shadow, tab4, "def ", symname, "(*args", (allow_kwargs ? ", **kwargs" : ""), "): ", NIL); -+ if ( have_addtofunc(n) ) { -+ Printv(f_shadow, "\n", NIL); -+ Printv(f_shadow, tab8, "val = ", funcCallHelper(Swig_name_member(class_name,symname), allow_kwargs), "\n", NIL); -+ Printv(f_shadow, tab8, addtofunc(n), "\n", NIL); -+ Printv(f_shadow, tab8, "return val\n", NIL); -+ } else { -+ Printv(f_shadow, "return ", funcCallHelper(Swig_name_member(class_name,symname), allow_kwargs), "\n", NIL); -+ } -+ } -+ - } - } - return SWIG_OK; -@@ -1923,10 +2051,28 @@ - String *symname = Getattr(n,"sym:name"); - Language::staticmemberfunctionHandler(n); - if (shadow) { -- Printv(f_shadow, tab4, "__swig_getmethods__[\"", symname, "\"] = lambda x: ", module, ".", Swig_name_member(class_name, symname), "\n", NIL); -- if (!classic) { -- Printv(f_shadow, tab4, "if _newclass:", symname, " = staticmethod(", module, ".", -- Swig_name_member(class_name, symname), ")\n", NIL); -+ if ( !classic && have_addtofunc(n) ) { -+ int kw = (check_kwargs(n) && !Getattr(n,"sym:overloaded")) ? 1 : 0; -+ Printv(f_shadow, tab4, "def ", symname, "(*args", (kw ? ", **kwargs" : ""), "):\n", NIL); -+ Printv(f_shadow, tab8, "val = ", funcCallHelper(Swig_name_member(class_name, symname), kw), "\n", NIL); -+ Printv(f_shadow, tab8, addtofunc(n), "\n", NIL); -+ Printv(f_shadow, tab8, "return val\n", NIL); -+ Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname, -+ " = staticmethod(", symname, ")\n", NIL); -+ -+ if (!modern) { -+ Printv(f_shadow, tab4, "__swig_getmethods__[\"", symname, "\"] = lambda x: ", symname, "\n", NIL); -+ } -+ -+ } else { -+ if (!modern) { -+ Printv(f_shadow, tab4, "__swig_getmethods__[\"", symname, "\"] = lambda x: ", module, ".", Swig_name_member(class_name, symname), "\n", NIL); -+ } -+ if (!classic) { -+ Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname, -+ " = staticmethod(", module, ".", -+ Swig_name_member(class_name, symname), ")\n", NIL); -+ } - } - } - return SWIG_OK; -@@ -1972,7 +2118,7 @@ - - if (!Getattr(n,"sym:nextSibling")) { - if (shadow) { -- int allow_kwargs = (use_kw || Getattr(n,"feature:kwargs")) ? 1 : 0; -+ int allow_kwargs = (check_kwargs(n) && (!Getattr(n,"sym:overloaded"))) ? 1 : 0; - if (!have_constructor) { - if (Getattr(n,"feature:shadow")) { - String *pycode = pythoncode(Getattr(n,"feature:shadow"),tab4); -@@ -1991,18 +2137,25 @@ - tab8, tab4, "args = (self,) + args\n", - NIL); - } -- if ((allow_kwargs) && (!Getattr(n,"sym:overloaded"))) { -- Printv(f_shadow, tab4, "def __init__(self,*args,**kwargs):\n", NIL); -- Printv(f_shadow, pass_self, NIL); -- Printv(f_shadow, tab8, "_swig_setattr(self, ", rclassname, ", 'this', apply(", module, ".", Swig_name_construct(symname), ",args, kwargs))\n", NIL); -- } else { -- Printv(f_shadow, tab4, "def __init__(self,*args):\n",NIL); -- Printv(f_shadow, pass_self, NIL); -- Printv(f_shadow, tab8, "_swig_setattr(self, ", rclassname, ", 'this', apply(", module, ".", Swig_name_construct(symname), ",args))\n", NIL); -- } -- Printv(f_shadow, -- tab8, "_swig_setattr(self, ", rclassname, ", 'thisown', 1)\n", -- NIL); -+ -+ Printv(f_shadow, tab4, "def __init__(self, *args", -+ (allow_kwargs ? ", **kwargs" : ""), "):\n", NIL); -+ Printv(f_shadow, pass_self, NIL); -+ if (!modern) { -+ Printv(f_shadow, tab8, "_swig_setattr(self, ", rclassname, ", 'this', ", -+ funcCallHelper(Swig_name_construct(symname), allow_kwargs), ")\n", NIL); -+ Printv(f_shadow, -+ tab8, "_swig_setattr(self, ", rclassname, ", 'thisown', 1)\n", -+ NIL); -+ } else { -+ Printv(f_shadow, tab8, "newobj = ", -+ funcCallHelper(Swig_name_construct(symname), allow_kwargs), "\n", NIL); -+ Printv(f_shadow, tab8, "self.this = newobj.this\n", NIL); -+ Printv(f_shadow, tab8, "self.thisown = 1\n", NIL); -+ Printv(f_shadow, tab8, "del newobj.thisown\n", NIL); -+ } -+ if ( have_addtofunc(n) ) -+ Printv(f_shadow, tab8, addtofunc(n), "\n", NIL); - Delete(pass_self); - } - have_constructor = 1; -@@ -2014,19 +2167,16 @@ - String *pycode = pythoncode(Getattr(n,"feature:shadow"),""); - Printv(f_shadow_stubs,pycode,"\n",NIL); - } else { -- if ((allow_kwargs) && (!Getattr(n,"sym:overloaded"))) -- Printv(f_shadow_stubs, "def ", symname, "(*args,**kwargs):\n", NIL); -- else -- Printv(f_shadow_stubs, "def ", symname, "(*args):\n", NIL); -- -- Printv(f_shadow_stubs, tab4, "val = apply(", NIL); -- if ((allow_kwargs) && (!Getattr(n,"sym:overloaded"))) -- Printv(f_shadow_stubs, module, ".", Swig_name_construct(symname), ",args,kwargs)\n", NIL); -- else -- Printv(f_shadow_stubs, module, ".", Swig_name_construct(symname), ",args)\n", NIL); -- Printv(f_shadow_stubs,tab4, "val.thisown = 1\n", -- tab4, "return val\n\n", NIL); -- } -+ -+ Printv(f_shadow_stubs, "\ndef ", symname, "(*args", -+ (allow_kwargs ? ", **kwargs" : ""), "):\n", NIL); -+ Printv(f_shadow_stubs, tab4, "val = ", -+ funcCallHelper(Swig_name_construct(symname), allow_kwargs), "\n", NIL); -+ Printv(f_shadow_stubs, tab4, "val.thisown = 1\n", NIL); -+ if ( have_addtofunc(n) ) -+ Printv(f_shadow_stubs, tab4, addtofunc(n), "\n", NIL); -+ Printv(f_shadow_stubs, tab4, "return val\n", NIL); -+ } - } - } - } -@@ -2045,7 +2195,9 @@ - Language::destructorHandler(n); - shadow = oldshadow; - if (shadow) { -- Printv(f_shadow, tab4, "def __del__(self, destroy= ", module, ".", Swig_name_destroy(symname), "):\n", NIL); -+ Printv(f_shadow, tab4, "def __del__(self, destroy=", module, ".", Swig_name_destroy(symname), "):\n", NIL); -+ if ( have_addtofunc(n) ) -+ Printv(f_shadow, tab8, addtofunc(n), "\n", NIL); - Printv(f_shadow, tab8, "try:\n", NIL); - Printv(f_shadow, tab4, tab8, "if self.thisown: destroy(self)\n", NIL); - Printv(f_shadow, tab8, "except: pass\n", NIL); -@@ -2066,21 +2218,22 @@ - shadow = oldshadow; - - if (shadow) { -- int immutable = 0; -- if (!Getattr(n,"feature:immutable")) { -- Printv(f_shadow, tab4, "__swig_setmethods__[\"", symname, "\"] = ", module, ".", Swig_name_set(Swig_name_member(class_name,symname)), "\n", NIL); -- } else { -- immutable = 1; -+ int immutable = (Getattr(n,"feature:immutable") != NULL); -+ if (!modern) { -+ if (!immutable) { -+ Printv(f_shadow, tab4, "__swig_setmethods__[\"", symname, "\"] = ", module, ".", Swig_name_set(Swig_name_member(class_name,symname)), "\n", NIL); -+ } -+ Printv(f_shadow, tab4, "__swig_getmethods__[\"", symname, "\"] = ", module, ".", Swig_name_get(Swig_name_member(class_name,symname)),"\n", NIL); - } -- Printv(f_shadow, tab4, "__swig_getmethods__[\"", symname, "\"] = ", module, ".", Swig_name_get(Swig_name_member(class_name,symname)),"\n", NIL); -- - if (!classic) { - if (immutable) { -- Printv(f_shadow,tab4,"if _newclass:", symname," = property(", module, ".", -+ Printv(f_shadow,tab4, modern ? "" : "if _newclass:", -+ symname," = property(", module, ".", - Swig_name_get(Swig_name_member(class_name,symname)),")\n", NIL); - } else { -- Printv(f_shadow,tab4,"if _newclass:", symname," = property(", -- module, ".", Swig_name_get(Swig_name_member(class_name,symname)),",", -+ Printv(f_shadow,tab4, modern ? "" : "if _newclass:", -+ symname," = property(", -+ module, ".", Swig_name_get(Swig_name_member(class_name,symname)),", ", - module, ".", Swig_name_set(Swig_name_member(class_name,symname)),")\n", NIL); - } - } -@@ -2142,8 +2295,9 @@ - Delitem(temp,0); - Delitem(temp,DOH_END); - } -+ - /* Split the input text into lines */ -- List *clist = DohSplit(temp,'\n',-1); -+ List *clist = DohSplitLines(temp); - Delete(temp); - int initial = 0; - String *s = 0; -@@ -2194,7 +2348,7 @@ - if ((!ImportMode) && ((Cmp(section,"python") == 0) || (Cmp(section,"shadow") == 0))) { - if (shadow) { - String *pycode = pythoncode(code,shadow_indent); -- Printv(f_shadow, pycode, "\n", NIL); -+ Printv(f_shadow, pycode, NIL); - Delete(pycode); - } - } else { diff --git a/wxPython/SWIG/swig.python.patch.txt b/wxPython/SWIG/swig.python.patch.txt deleted file mode 100644 index d6dd4c89ac..0000000000 --- a/wxPython/SWIG/swig.python.patch.txt +++ /dev/null @@ -1,43 +0,0 @@ -This patch makes a number of changes to the SWIG python module. - -1. Add -apply option, and change the default code output to use the - foo(*args, **kw) calling syntax instead of using apply(). If the - -apply option is given then code is generated as before. This is - very similar to Patch #737281 but the new -modern option makes the - second half of that patch unnecessary so it is not included here. - -2. Add -new_repr option. This is the same as my Patch #797002 which I - will mark as closed since it is no longer needed. When this new - option is used then the __repr__ methods that are generated for - proxy classes will be more informative and give details about the - python class and the C++ class. - -3. Add %feature("addtofunc"). It allows you to insert one or more - lines of code inside the shadow method or function that is already - generated, instead of replacing the whole thing like - %feature("shadow") does. For __init__ it goes at the end, for - __del__ it goes at the begining and for all others the code - generated is expanded out to be like - - def Bar(*args, **kwargs): - val = _module.Foo_Bar(*args, **kwargs) - return val - - and the "addtofunc" code is inserted just before the return - statement. If the feature is not used for a particular method or - function then the shorter code is generated just like before. - -4. A little bit of refactoring to make implementing addtofunc a little - easier. - -5. Added a -modern command-line flag that will cause SWIG to omit the - cruft in the proxy modules that allows it to work with versions of - Python prior to 2.2. The result is a simpler, cleaner and faster - python proxy module, but one that requires Python 2.2 or greater. - For most of us this requirement is easy to live with! - - -I've been using and greatly benefiting from all these features with -wxPython for the last few weeks and have had no problems. - -This patch depends upon Patch #829317. diff --git a/wxPython/SWIG/swig.xml.patch b/wxPython/SWIG/swig.xml.patch deleted file mode 100644 index 0cc6368108..0000000000 --- a/wxPython/SWIG/swig.xml.patch +++ /dev/null @@ -1,58 +0,0 @@ -Index: Source/Modules/xml.cxx -=================================================================== -RCS file: /cvsroot/SWIG/Source/Modules/xml.cxx,v -retrieving revision 1.7 -diff -u -r1.7 xml.cxx ---- Source/Modules/xml.cxx 11 Sep 2003 20:26:56 -0000 1.7 -+++ Source/Modules/xml.cxx 30 Oct 2003 01:29:32 -0000 -@@ -14,6 +14,7 @@ - static const char *usage = "\ - XML Options (available with -xml)\n\ - -xmllang - Typedef language\n\ -+ -xmllite - More lightweight version of XML\n\ - ------\n\ - deprecated (use -o): -xml - Use as output file (extension .xml mandatory)\n"; - -@@ -22,6 +23,8 @@ - - //static Node *view_top = 0; - static File *out = 0; -+static int xmllite = 0; -+ - - class XML - : public Language -@@ -79,6 +82,11 @@ - { - fputs( usage, stderr ); - } -+ if( strcmp( argv[iX], "-xmllite" ) == 0 ) -+ { -+ Swig_mark_arg (iX); -+ xmllite = 1; -+ } - } - - // Add a symbol to the parser for conditional compilation -@@ -93,6 +101,7 @@ - { - String *outfile = Getattr(n,"outfile"); - Replaceall(outfile,".cxx", ".xml"); -+ Replaceall(outfile,".cpp", ".xml"); - Replaceall(outfile,".c", ".xml"); - out = NewFile(outfile,"w"); - if (!out) -@@ -159,11 +168,11 @@ - { - Xml_print_baselist( Getattr(obj,k) ); - } -- else if (Cmp(k,"typescope") == 0) -+ else if (!xmllite && Cmp(k,"typescope") == 0) - { - Xml_print_typescope( Getattr(obj,k) ); - } -- else if (Cmp(k,"typetab") == 0) -+ else if (!xmllite && Cmp(k,"typetab") == 0) - { - Xml_print_typetab( Getattr(obj,k) ); - } diff --git a/wxPython/SWIG/swig.xmlout.patch b/wxPython/SWIG/swig.xmlout.patch deleted file mode 100644 index ae17e1899e..0000000000 --- a/wxPython/SWIG/swig.xmlout.patch +++ /dev/null @@ -1,165 +0,0 @@ -Index: Source/Swig/swig.h -=================================================================== -RCS file: /cvsroot/SWIG/Source/Swig/swig.h,v -retrieving revision 1.81 -diff -u -4 -r1.81 swig.h ---- Source/Swig/swig.h 27 Jan 2004 23:39:35 -0000 1.81 -+++ Source/Swig/swig.h 30 Jan 2004 22:22:10 -0000 -@@ -364,8 +364,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.33 -diff -u -4 -r1.33 main.cxx ---- Source/Modules/main.cxx 22 Jan 2004 22:42:15 -0000 1.33 -+++ Source/Modules/main.cxx 30 Jan 2004 22:22:11 -0000 -@@ -91,15 +91,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\ -+ -xmlout - 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) - // -@@ -215,8 +217,9 @@ - char *includefiles[256]; - 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; -@@ -483,8 +486,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) { -@@ -734,8 +749,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.10 -diff -u -4 -r1.10 xml.cxx ---- Source/Modules/xml.cxx 22 Jan 2004 22:42:18 -0000 1.10 -+++ Source/Modules/xml.cxx 30 Jan 2004 22:22:11 -0000 -@@ -197,18 +197,19 @@ - Replaceall( o, "&", "&" ); - Replaceall( o, "<", "<" ); - Replaceall( o, "\"", """ ); - Replaceall( o, "\\", "\\\\" ); -- Printf(out,"\n", ck, o, ++id, o ); -+ Replaceall( o, "\n", " " ); -+ Printf(out,"\n", ck, o, ++id, o ); - Delete(o); - Delete(ck); - } - else - { - o = Getattr(obj,k); - String *ck = NewString(k); - Replaceall( ck, ":", "_" ); -- Printf(out,"\n", ck, o, ++id, o ); -+ Printf(out,"\n", ck, o, ++id, o ); - Delete(ck); - } - } - ki = Next(ki); -@@ -318,11 +319,10 @@ - { - print_indent(0); - Printf( out, "<%ssitem id=\"%ld\" addr=\"%x\" >\n", markup, ++id, n.item ); - Xml_print_attributes( n.item ); -- Printf( out, "\n", markup ); - print_indent(0); -- Printf( out, " />\n" ); -+ Printf( out, "\n", markup ); - n = Next(n); - } - indent_level -= 4; - print_indent(0); -@@ -336,5 +336,36 @@ - return new XML(); - } - extern "C" Language * swig_xml( void ) { - return new_swig_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, " \n" ); -+ xml.Xml_print_tree(obj); - }