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
This commit is contained in:
parent
ca63e8e992
commit
414863fd52
@ -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
|
||||
<press ENTER for empty password>
|
||||
|
||||
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
|
||||
swig.python-2.patch
|
||||
|
||||
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.
|
||||
Adds the following features to the Python Module in SWIG. See the
|
||||
updated docs in the patch for more details.
|
||||
|
||||
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::
|
||||
%feature("autodoc")
|
||||
%feature("docstring")
|
||||
%feature("pythonprepend")
|
||||
%feature("pythonappend")
|
||||
|
||||
%module(docstring="blah") modulename
|
||||
%module(docstring="string")
|
||||
%module(package="string")
|
||||
|
||||
And then when generating the
|
||||
modulename.py file SWIG will make a
|
||||
docstring using the value given.
|
||||
|
||||
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::
|
||||
|
||||
%module(pacakge="wx") _core
|
||||
|
||||
Multiple %module options can be specfied,
|
||||
separated by commmas.
|
||||
https://sourceforge.net/tracker/index.php?func=detail&aid=1023309&group_id=1645&atid=301645
|
||||
|
||||
|
||||
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.
|
||||
------------------------------------------------------------------------
|
||||
This patch was applied to SWIG's CVS on 07/12/2004 and is in the
|
||||
1.3.22 relese.
|
||||
------------------------------------------------------------------------
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
|
||||
|
||||
@ -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.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.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.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*
|
||||
|
||||
------------------------------------------------------------------------
|
||||
|
@ -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.
|
@ -1,10 +1,288 @@
|
||||
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 @@
|
||||
<li><a href="#Python_nn62">Mapping Python tuples into small arrays</a>
|
||||
<li><a href="#Python_nn63">Mapping sequences to C arrays</a>
|
||||
<li><a href="#Python_nn64">Pointer handling</a>
|
||||
</ul>
|
||||
+<li><a href="#Python_nn65">Docstring Features</a>
|
||||
+<ul>
|
||||
+<li><a href="#Python_nn66">Module docstring</a>
|
||||
+<li><a href="#Python_nn67">%feature("autodoc")</a>
|
||||
+<li><a href="#Python_nn68">%feature("docstring")</a>
|
||||
+</ul>
|
||||
+<li><a href="#Python_nn70">Python Packages</a>
|
||||
</ul>
|
||||
<!-- INDEX -->
|
||||
|
||||
|
||||
@@ -2460,9 +2467,8 @@
|
||||
customization features as covered in later sections.
|
||||
|
||||
<H3><a name="Python_nn42"></a>26.6.2 Adding additional Python code</H3>
|
||||
|
||||
-
|
||||
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 <tt>.py</tt> 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.
|
||||
|
||||
+<p>Sometimes you may want to replace or modify the wrapper function
|
||||
+that SWIG creates in the proxy <tt>.py</tt> 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
|
||||
+<tt>%feature("shadow")</tt>. For example:
|
||||
+
|
||||
+<blockquote>
|
||||
+<pre>
|
||||
+%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);
|
||||
+}
|
||||
+</pre>
|
||||
+</blockquote>
|
||||
+
|
||||
+
|
||||
+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.
|
||||
+
|
||||
+
|
||||
<H3><a name="Python_nn43"></a>26.6.3 Class extension with %extend</H3>
|
||||
|
||||
|
||||
One of the more interesting features of SWIG is that it can extend
|
||||
@@ -3852,6 +3896,197 @@
|
||||
that has a <tt>this</tt> attribute. In addition,
|
||||
<tt>SWIG_NewPointerObj()</tt> can automatically generate a proxy
|
||||
class object (if applicable).
|
||||
|
||||
+
|
||||
+
|
||||
+<H2><a name="Python_nn65"></a>26.10 Docstring Features</H2>
|
||||
+
|
||||
+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 <tt>"function_name(*args)"</tt> in the popup calltip of
|
||||
+their IDE which is next to useless when the real function prototype
|
||||
+might be something like this:
|
||||
+
|
||||
+<blockquote>
|
||||
+<pre>
|
||||
+bool function_name(int x, int y, Foo* foo=NULL, Bar* bar=NULL);
|
||||
+</pre>
|
||||
+</blockquote>
|
||||
+
|
||||
+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.
|
||||
+
|
||||
+
|
||||
+<H3><a name="Python_nn66"></a>26.10.1 Module docstring</H3>
|
||||
+
|
||||
+Python allows a docstring at the begining of the <tt>.py</tt> 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 <tt>%module</tt> directive. For example:
|
||||
+
|
||||
+<blockquote>
|
||||
+<pre>
|
||||
+%module(docstring="This is the example module's docstring") example
|
||||
+</pre>
|
||||
+</blockquote>
|
||||
+
|
||||
+When you have more than just a line or so then you can retain the easy
|
||||
+readability of the <tt>%module</tt> directive by using a macro. For
|
||||
+example:
|
||||
+
|
||||
+<blockquote>
|
||||
+<pre>
|
||||
+%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
|
||||
+</pre>
|
||||
+</blockquote>
|
||||
+
|
||||
+
|
||||
+<H3><a name="Python_nn67"></a>26.10.2 %feature("autodoc")</H3>
|
||||
+
|
||||
+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 <tt>.py</tt> file will not be able
|
||||
+to find out anything about the parameters that the fuctions accept.
|
||||
+
|
||||
+<p>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.
|
||||
+
|
||||
+<p>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.
|
||||
+
|
||||
+<H4>%feature("autodoc", "0")</H4>
|
||||
+
|
||||
+When the "0" option is given then the types of the parameters will
|
||||
+<em>not</em> be included in the autodoc string. For example, given
|
||||
+this function prototype:
|
||||
+
|
||||
+<blockquote>
|
||||
+<pre>
|
||||
+%feature("autodoc", "0");
|
||||
+bool function_name(int x, int y, Foo* foo=NULL, Bar* bar=NULL);
|
||||
+</pre>
|
||||
+</blockquote>
|
||||
+
|
||||
+Then Python code like this will be generated:
|
||||
+
|
||||
+<blockquote>
|
||||
+<pre>
|
||||
+def function_name(*args, **kwargs):
|
||||
+ """function_name(x, y, foo=None, bar=None) -> bool"""
|
||||
+ ...
|
||||
+</pre>
|
||||
+</blockquote>
|
||||
+
|
||||
+
|
||||
+<H4>%feature("autodoc", "1")</H4>
|
||||
+
|
||||
+When the "1" option is used then the parameter types <em>will</em> 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,
|
||||
+<tt>%rename</tt>'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:
|
||||
+
|
||||
+<blockquote>
|
||||
+<pre>
|
||||
+def function_name(*args, **kwargs):
|
||||
+ """function_name(int x, int y, Foo foo=None, Bar bar=None) -> bool"""
|
||||
+ ...
|
||||
+</pre>
|
||||
+</blockquote>
|
||||
+
|
||||
+
|
||||
+
|
||||
+<H4>%feature("autodoc", "docstring")</H4>
|
||||
+
|
||||
+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:
|
||||
+
|
||||
+<blockquote>
|
||||
+<pre>
|
||||
+%feature("autodoc", "GetPosition() -> (x, y)") GetPosition;
|
||||
+void GetPosition(int* OUTPUT, int* OUTPUT);
|
||||
+</pre>
|
||||
+</blockquote>
|
||||
+
|
||||
+
|
||||
+<H3><a name="Python_nn68"></a>26.10.3 %feature("docstring")</H3>
|
||||
+
|
||||
+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::
|
||||
+
|
||||
+<blockquote>
|
||||
+<pre>
|
||||
+"""This is the docstring"""
|
||||
+</pre>
|
||||
+</blockquote>
|
||||
+
|
||||
+Otherwise, to aid readability it is output like this:
|
||||
+
|
||||
+<blockquote>
|
||||
+<pre>
|
||||
+"""
|
||||
+This is a multi-line docstring
|
||||
+with more than one line.
|
||||
+"""
|
||||
+</pre>
|
||||
+</blockquote>
|
||||
+
|
||||
+<H2><a name="Python_nn70"></a>26.11 Python Packages</H2>
|
||||
+
|
||||
+Using the <tt>package</tt> option of the <tt>%module</tt> directive
|
||||
+allows you to specify what Python package that the module will be
|
||||
+living in when installed.
|
||||
+
|
||||
+<blockquote>
|
||||
+<pre>
|
||||
+%module(package="wx") xrc
|
||||
+</pre>
|
||||
+</blockquote>
|
||||
+
|
||||
+This is useful when the <tt>.i</tt> file is <tt>%import</tt>ed by
|
||||
+another <tt>.i</tt> 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
|
||||
+<tt>%module</tt> 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.
|
||||
+
|
||||
+
|
||||
+
|
||||
</body>
|
||||
</html>
|
||||
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
|
||||
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;
|
||||
@ -32,9 +310,9 @@ diff -u -4 -r1.40 python.cxx
|
||||
+
|
||||
static const char *usage = (char *)"\
|
||||
Python Options (available with -python)\n\
|
||||
-ldflags - Print runtime libraries to link with\n\
|
||||
-globals <name> - Set <name> used to access C global variable [default: 'cvar']\n\
|
||||
@@ -146,19 +157,22 @@
|
||||
-interface <lib>- Set the lib name to <lib>\n\
|
||||
@@ -145,19 +156,22 @@
|
||||
*
|
||||
* use %module(directors="1") modulename at the start of the
|
||||
* interface file to enable director generation.
|
||||
@ -60,7 +338,7 @@ diff -u -4 -r1.40 python.cxx
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,8 +272,13 @@
|
||||
@@ -257,8 +271,13 @@
|
||||
Printv(f_shadow,
|
||||
"# This file is compatible with both classic and new-style classes.\n",
|
||||
NIL);
|
||||
@ -74,7 +352,7 @@ diff -u -4 -r1.40 python.cxx
|
||||
Printf(f_shadow,"\nimport %s\n\n", module);
|
||||
|
||||
if (! modern) {
|
||||
@@ -382,9 +401,28 @@
|
||||
@@ -381,9 +400,28 @@
|
||||
virtual int importDirective(Node *n) {
|
||||
if (shadow) {
|
||||
String *modname = Getattr(n,"module");
|
||||
@ -104,7 +382,7 @@ diff -u -4 -r1.40 python.cxx
|
||||
}
|
||||
return Language::importDirective(n);
|
||||
}
|
||||
@@ -417,17 +455,25 @@
|
||||
@@ -416,17 +454,25 @@
|
||||
* functions.
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
@ -135,7 +413,7 @@ diff -u -4 -r1.40 python.cxx
|
||||
}
|
||||
|
||||
|
||||
@@ -441,24 +487,303 @@
|
||||
@@ -440,24 +486,303 @@
|
||||
}
|
||||
|
||||
|
||||
@ -145,8 +423,10 @@ diff -u -4 -r1.40 python.cxx
|
||||
+ * 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) ||
|
||||
@ -423,10 +703,8 @@ diff -u -4 -r1.40 python.cxx
|
||||
+ /* ------------------------------------------------------------
|
||||
+ * 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);
|
||||
@ -447,7 +725,7 @@ diff -u -4 -r1.40 python.cxx
|
||||
if (*t == '{') {
|
||||
Delitem(str ,0);
|
||||
Delitem(str,DOH_END);
|
||||
@@ -1657,9 +1982,18 @@
|
||||
@@ -1686,9 +2011,18 @@
|
||||
mod = Getattr(n,"module");
|
||||
if (mod) {
|
||||
String *modname = Getattr(mod,"name");
|
||||
@ -467,7 +745,7 @@ diff -u -4 -r1.40 python.cxx
|
||||
importname = NewString(Getattr(n,"sym:name"));
|
||||
}
|
||||
Setattr(n,"python:proxy",importname);
|
||||
@@ -1731,9 +2065,11 @@
|
||||
@@ -1760,9 +2094,11 @@
|
||||
Printf(f_shadow, modern ? "(object)" : "(_object)");
|
||||
}
|
||||
}
|
||||
@ -480,7 +758,7 @@ diff -u -4 -r1.40 python.cxx
|
||||
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 @@
|
||||
@@ -1906,16 +2242,24 @@
|
||||
Delete(pyaction);
|
||||
Printv(f_shadow,pycode,"\n",NIL);
|
||||
} else {
|
||||
@ -512,7 +790,7 @@ diff -u -4 -r1.40 python.cxx
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1890,14 +2234,22 @@
|
||||
@@ -1930,14 +2274,22 @@
|
||||
virtual int staticmemberfunctionHandler(Node *n) {
|
||||
String *symname = Getattr(n,"sym:name");
|
||||
Language::staticmemberfunctionHandler(n);
|
||||
@ -539,7 +817,7 @@ diff -u -4 -r1.40 python.cxx
|
||||
" = staticmethod(", symname, ")\n", NIL);
|
||||
|
||||
if (!modern) {
|
||||
@@ -1982,8 +2334,12 @@
|
||||
@@ -2022,8 +2374,12 @@
|
||||
}
|
||||
|
||||
Printv(f_shadow, tab4, "def __init__(self, *args",
|
||||
@ -552,7 +830,7 @@ diff -u -4 -r1.40 python.cxx
|
||||
if (!modern) {
|
||||
Printv(f_shadow, tab8, "_swig_setattr(self, ", rclassname, ", 'this', ",
|
||||
funcCallHelper(Swig_name_construct(symname), allow_kwargs), ")\n", NIL);
|
||||
@@ -1996,10 +2352,10 @@
|
||||
@@ -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);
|
||||
@ -565,7 +843,7 @@ diff -u -4 -r1.40 python.cxx
|
||||
}
|
||||
have_constructor = 1;
|
||||
} else {
|
||||
@@ -2015,13 +2371,17 @@
|
||||
@@ -2055,13 +2411,17 @@
|
||||
} else {
|
||||
|
||||
Printv(f_shadow_stubs, "\ndef ", symname, "(*args",
|
||||
@ -585,7 +863,7 @@ diff -u -4 -r1.40 python.cxx
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2048,13 +2408,18 @@
|
||||
@@ -2088,13 +2448,18 @@
|
||||
Delete(pyaction);
|
||||
Printv(f_shadow,pycode,"\n", NIL);
|
||||
} else {
|
@ -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 <lib>- Set the lib name to <lib>\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 \"<C ", class_name," instance at %s>\" % (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 \"<C ", real_classname," instance at %s>\" % (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 {
|
@ -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.
|
@ -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 <lang> - Typedef language\n\
|
||||
+ -xmllite - More lightweight version of XML\n\
|
||||
------\n\
|
||||
deprecated (use -o): -xml <output.xml> - Use <output.xml> 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) );
|
||||
}
|
@ -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 <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)
|
||||
//
|
||||
@@ -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,"<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 +319,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);
|
||||
@@ -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, "<?xml version=\"1.0\" ?> \n" );
|
||||
+ xml.Xml_print_tree(obj);
|
||||
}
|
Loading…
Reference in New Issue
Block a user