Revision: 10775
http://swig.svn.sourceforge.net/swig/?rev=10775&view=rev
Author: bhy
Date: 2008-08-18 03:26:06 +0000 (Mon, 18 Aug 2008)
Log Message:
-----------
revised doc
Modified Paths:
--------------
branches/gsoc2008-bhy/Doc/Manual/Python.html
Modified: branches/gsoc2008-bhy/Doc/Manual/Python.html
===================================================================
--- branches/gsoc2008-bhy/Doc/Manual/Python.html 2008-08-17 23:49:15 UTC (rev 10774)
+++ branches/gsoc2008-bhy/Doc/Manual/Python.html 2008-08-18 03:26:06 UTC (rev 10775)
@@ -101,8 +101,13 @@
<li><a href="#Python_nn71">%feature("docstring")</a>
</ul>
<li><a href="#Python_nn72">Python Packages</a>
-<li><a href="#Python_nn73">Notes on Python 3.0 Support</a>
+<li><a href="#Python_nn73">Python 3 Support</a>
+<ul>
+<li><a href="#Python_nn74">Function annotation</a>
+<li><a href="#Python_nn75">Buffer interface</a>
+<li><a href="#Python_nn76">Abstract base classes</a>
</ul>
+</ul>
</div>
<!-- INDEX -->
@@ -114,9 +119,9 @@
<p>
This chapter describes SWIG's support of Python. SWIG is compatible
-with most recent Python versions including Python 2.2 as well as older
-versions dating back to Python 1.5.2. For the best results, consider using Python
-2.0 or newer.
+with most recent Python versions including Python 3.0 and Python 2.6,
+as well as older versions dating back to Python 2.0. For the best results,
+consider using Python 2.3 or newer.
</p>
<p>
@@ -4951,15 +4956,16 @@
different than its own.
</p>
-<H2><a name="Python_nn73"></a>30.12 Notes on Python 3.0 Support</H2>
+<H2><a name="Python_nn73"></a>30.12 Python 3 Support</H2>
<p>
-SWIG is able to support Python 3.0. The wrapper code
-generated by SWIG can be compiled with both Python 2.x or 3.0. Further more, by
+SWIG is able to support Python 3.0. The wrapper code generated by
+SWIG can be compiled with both Python 2.x or 3.0. Further more, by
passing the <tt>-py3</tt> command line option to SWIG, wrapper code
-with some Python 3 specific features can be generated (see below subsections
-for details of these features). The <tt>-py3</tt> also forcely disable
-some incompatable features for Python 3, such as <tt>-classic</tt>.
+with some Python 3 specific features can be generated (see below
+subsections for details of these features). The <tt>-py3</tt> also
+disable some incompatible features for Python 3, such as
+<tt>-classic</tt>.
<p>
There is a list of known-to-be-broken features in Python 3:
@@ -4972,18 +4978,20 @@
</p>
<p>
-The following is Python 3.0 new features that currently supported by SWIG.
+The following is Python 3.0 new features that currently supported by
+SWIG.
</p>
<H3><a name="Python_nn74"></a>30.12.1 Function annotation</H3>
<p>
-The <tt>-py3</tt> option will enable function annotation support. Then SWIG
-would be able to generate proxy method definition like this:
+The <tt>-py3</tt> option will enable function annotation support. And
+then SWIG would be able to generate proxy method definition like
+this:
</p>
<div class="code"><pre>
- def foo(self, bar : "int" = 0) : ...
+ def foo(self, bar : "int" = 0) -> "void" : ...
</pre></div>
<p>
@@ -4993,16 +5001,16 @@
<H3><a name="Python_nn75"></a>30.12.2 Buffer interface</H3>
<p>
-Byffer protocal get revised in Python 3. SWIG also gain a series of new
-typemaps to support buffer interface. These typemap macros are defined in
-<tt>pybuffer.i</tt>, you can include it to use them. By using these typemaps,
-your warpped function would able to accept any Python object that exposed
-suitable buffer interface as parameter.
+Buffer protocol get revised in Python 3. SWIG also gain a series of
+new typemaps to support buffer interface. These typemap macros are
+defined in <tt>pybuffer.i</tt>, so you can include it to use them.
+By using these typemaps, your wrapped function would be able to
+accept any Python object that exposed suitable buffer interface.
</p>
<p>
-For example, the <tt>get_path()</tt> function put the path string into
-the memory pointed by its argument:
+For example, the <tt>get_path()</tt> function put the path string
+into the memory pointed by its argument:
</p>
<div class="code"><pre>
@@ -5010,9 +5018,9 @@
</pre></div>
<p>
-Then you can write typemap like this: (the following example is applied to
-both Python 3.0 and 2.6, since the <tt>bytearray</tt> type is backported to
-2.6.
+Then you can write typemap like this: (the following example is
+applied to both Python 3.0 and 2.6, since the <tt>bytearray</tt> type
+is backported to 2.6.
</p>
@@ -5023,18 +5031,19 @@
</pre></div>
<p>
-And then in Python side the wrapped get_path could be used in this way:
+And then in Python side the wrapped get_path could be used in this
+way:
</p>
<div class="targetlang"><pre>
>>> p = bytearray(10)
>>> get_path(p)
>>> print(p)
-bytearray(b'\\Foo\\Bar\x00\x00')
+bytearray(b'/Foo/Bar/\x00')
</pre></div>
<p>
-The macros defined in <tt>pybuffer.i</tt> is similar to those in
+The macros defined in <tt>pybuffer.i</tt> is similar to those in
<tt>cstring.i</tt>:
</p>
@@ -5045,9 +5054,9 @@
<div class="indent">
<p>
-The macro can be used to generate a typemap which map buffer of an object
-to a pointer provided by <tt>parm</tt> and a size argument provided by
-<tt>size_parm</tt>. For example:
+The macro can be used to generate a typemap which maps buffer of an
+object to a pointer provided by <tt>parm</tt> and a size argument
+provided by <tt>size_parm</tt>. For example:
</p>
<div class="code"><pre>
@@ -5077,8 +5086,8 @@
<div class="indent">
<p>
-This typemap macro assume the buffer is a zero terminated string, and
-map the pointer of the buffer to <tt>parm</tt>. For example:
+This typemap macro requires the buffer is a zero terminated string,
+and maps the pointer of the buffer to <tt>parm</tt>. For example:
</p>
<div class="code"><pre>
@@ -5101,8 +5110,9 @@
<p>
Both <tt>%pybuffer_mutable_binary</tt> and <tt>%pybuffer_mutable_string</tt>
-require the provided buffer is mutable, eg. they can accept a <tt>bytearray</tt>
-type but can't accept a immutable <tt>byte</tt> type.
+require the provided buffer is mutable, eg. they can accept a
+<tt>bytearray</tt> type but can't accept a immutable <tt>byte</tt>
+type.
</p>
</div>
@@ -5114,10 +5124,11 @@
<div class="indent">
<p>
-This macro map an object's buffer to a pointer <tt>parm</tt> and a size
-<tt>size_parm</tt>. It is similar to <tt>%pybuffer_mutable_binary</tt>, except
-the <tt>%pybuffer_binary</tt> could accept both mutable and immutable buffer.
-As a result, your function should not modify the buffer.
+This macro maps an object's buffer to a pointer <tt>parm</tt> and a
+size <tt>size_parm</tt>. It is similar to
+<tt>%pybuffer_mutable_binary</tt>, except the
+<tt>%pybuffer_binary</tt> could accept both mutable and immutable
+buffer. As a result, your function should not modify the buffer.
</p>
</div>
@@ -5129,9 +5140,10 @@
<div class="indent">
<p>
-This macro map an object's buffer as a string pointer <tt>parm</tt>. It is
-similar to <tt>%pybuffer_mutable_string</tt> but the buffer could be both
-mutable and immutable. And your function should not modify the buffer.
+This macro maps an object's buffer as a string pointer <tt>parm</tt>.
+It is similar to <tt>%pybuffer_mutable_string</tt> but the buffer
+could be both mutable and immutable. And your function should not
+modify the buffer.
</p>
</div>
@@ -5140,9 +5152,10 @@
<H3><a name="Python_nn76"></a>30.12.3 Abstract base classes</H3>
<p>
-By include <tt>pyabc.i</tt> and provide the <tt>-py3</tt> command line option
-when calling SWIG, the proxy classes of STL containers would automatically has
-an appropriate abstract base class. For example, the following SWIG interface:
+By include <tt>pyabc.i</tt> and provide the <tt>-py3</tt> command
+line option when calling SWIG, the proxy classes of STL containers
+would automatically gain an appropriate abstract base class. For
+example, the following SWIG interface:
</p>
<div class="code"><pre>
@@ -5157,13 +5170,14 @@
</pre></div>
<p>
-will generate Python proxy class <tt>Mapii</tt> inherits from <tt>collections.MutableMap</tt>
-and proxy class <tt>IntList</tt> inehrits from <tt>collections.MutableSequence</tt>.
+will generate Python proxy class <tt>Mapii</tt> inherits from
+<tt>collections.MutableMap</tt> and proxy class <tt>IntList</tt>
+inherits from <tt>collections.MutableSequence</tt>.
</p>
<p>
-<tt>pyabc.i</tt> also provides a macro <tt>%pythonabc</tt> could be used to define
-abstract base class for your own C++ class:
+<tt>pyabc.i</tt> also provides a macro <tt>%pythonabc</tt> could be
+used to define abstract base class for your own C++ class:
</p>
<div class="code"><pre>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|