Merge branch 'master' into master
This commit is contained in:
commit
f1df34642b
16 changed files with 205 additions and 758 deletions
|
|
@ -228,7 +228,6 @@
|
|||
<li><a href="SWIGPlus.html#SWIGPlus_nn12">Static members</a>
|
||||
<li><a href="SWIGPlus.html#SWIGPlus_member_data">Member data</a>
|
||||
</ul>
|
||||
<li><a href="SWIGPlus.html#SWIGPlus_default_args">Default arguments</a>
|
||||
<li><a href="SWIGPlus.html#SWIGPlus_nn15">Protection</a>
|
||||
<li><a href="SWIGPlus.html#SWIGPlus_nn16">Enums and constants</a>
|
||||
<li><a href="SWIGPlus.html#SWIGPlus_nn17">Friends</a>
|
||||
|
|
@ -236,14 +235,15 @@
|
|||
<li><a href="SWIGPlus.html#SWIGPlus_nn19">Pass and return by value</a>
|
||||
<li><a href="SWIGPlus.html#SWIGPlus_nn20">Inheritance</a>
|
||||
<li><a href="SWIGPlus.html#SWIGPlus_nn21">A brief discussion of multiple inheritance, pointers, and type checking</a>
|
||||
<li><a href="SWIGPlus.html#SWIGPlus_overloaded_methods">Wrapping Overloaded Functions and Methods</a>
|
||||
<li><a href="SWIGPlus.html#SWIGPlus_default_args">Default arguments</a>
|
||||
<li><a href="SWIGPlus.html#SWIGPlus_overloaded_methods">Overloaded functions and methods</a>
|
||||
<ul>
|
||||
<li><a href="SWIGPlus.html#SWIGPlus_nn24">Dispatch function generation</a>
|
||||
<li><a href="SWIGPlus.html#SWIGPlus_nn25">Ambiguity in Overloading</a>
|
||||
<li><a href="SWIGPlus.html#SWIGPlus_ambiguity_resolution_renaming">Ambiguity resolution and renaming</a>
|
||||
<li><a href="SWIGPlus.html#SWIGPlus_nn25">Ambiguity in overloading</a>
|
||||
<li><a href="SWIGPlus.html#SWIGPlus_ambiguity_resolution_renaming">Renaming and ambiguity resolution</a>
|
||||
<li><a href="SWIGPlus.html#SWIGPlus_nn27">Comments on overloading</a>
|
||||
</ul>
|
||||
<li><a href="SWIGPlus.html#SWIGPlus_nn28">Wrapping overloaded operators</a>
|
||||
<li><a href="SWIGPlus.html#SWIGPlus_nn28">Overloaded operators</a>
|
||||
<li><a href="SWIGPlus.html#SWIGPlus_class_extension">Class extension</a>
|
||||
<li><a href="SWIGPlus.html#SWIGPlus_nn30">Templates</a>
|
||||
<ul>
|
||||
|
|
|
|||
|
|
@ -356,7 +356,7 @@ In this case, the exception handler is only attached to declarations
|
|||
named "allocate". This would include both global and member
|
||||
functions. The names supplied to <tt>%exception</tt> follow the same
|
||||
rules as for <tt>%rename</tt> described in the section on
|
||||
<a href="SWIGPlus.html#SWIGPlus_ambiguity_resolution_renaming">Ambiguity resolution and renaming</a>.
|
||||
<a href="SWIGPlus.html#SWIGPlus_ambiguity_resolution_renaming">Renaming and ambiguity resolution</a>.
|
||||
For example, if you wanted to define
|
||||
an exception handler for a specific class, you might write this:
|
||||
</p>
|
||||
|
|
@ -796,7 +796,7 @@ involving <tt>%feature</tt>:
|
|||
</div>
|
||||
|
||||
<p>
|
||||
The name matching rules outlined in the <a href="SWIGPlus.html#SWIGPlus_ambiguity_resolution_renaming">Ambiguity resolution and renaming</a>
|
||||
The name matching rules outlined in the <a href="SWIGPlus.html#SWIGPlus_ambiguity_resolution_renaming">Renaming and ambiguity resolution</a>
|
||||
section applies to all <tt>%feature</tt> directives.
|
||||
In fact the <tt>%rename</tt> directive is just a special form of <tt>%feature</tt>.
|
||||
The matching rules mean that features are very flexible and can be applied with
|
||||
|
|
|
|||
|
|
@ -390,8 +390,7 @@ Although PHP does not support overloading functions natively, swig
|
|||
will generate dispatch functions which will use <tt>%typecheck</tt>
|
||||
typemaps to allow overloading. This dispatch function's operation and
|
||||
precedence is described in <a
|
||||
href="SWIGPlus.html#SWIGPlus_overloaded_methods">Wrapping
|
||||
Overloaded Functions and Methods</a>.
|
||||
href="SWIGPlus.html#SWIGPlus_overloaded_methods">Overloaded functions and methods</a>.
|
||||
</p>
|
||||
|
||||
<!-- This isn't correct for 1.3.30 and needs rewriting to reflect reality
|
||||
|
|
|
|||
|
|
@ -1737,41 +1737,14 @@ careful about namespaces and your use of modules, you can usually
|
|||
avoid these problems.</p>
|
||||
|
||||
<p>
|
||||
<tt>%rename</tt> directive respects function parameters and <i>discriminates default parameters</i> from non-default,
|
||||
which is essential for some languages including Python. Be careful renaming functions having default parameters:
|
||||
When wrapping C code, simple use of identifiers/symbols with <tt>%rename</tt> usually suffices.
|
||||
When wrapping C++ code, simple use of simple identifiers/symbols with <tt>%rename</tt> might be too
|
||||
limiting when using C++ features such as function overloading, default arguments, namespaces, template specialization etc.
|
||||
If you are using the <tt>%rename</tt> directive and C++, make sure you read the
|
||||
<a href="SWIGPlus.html">SWIG and C++</a> chapter and in particular the section on
|
||||
<a href="SWIGPlus.html#SWIGPlus_ambiguity_resolution_renaming">Renaming and ambiguity resolution</a>
|
||||
for method overloading and default arguments.
|
||||
</p>
|
||||
<div class="code"><pre>
|
||||
%rename(toFFVal) to_val(FileFormat, bool bin=false);
|
||||
int to_val(FileFormat flag, bool bin=false)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
%rename(toDFVal) to_val(DirFormat, bool bin);
|
||||
int to_val(DirFormat flag, bool bin=false)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
%rename(toLFVal) to_val(FolderFormat, bool bin);
|
||||
int to_val(FolderFormat flag, bool bin=false)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
</pre></div>
|
||||
|
||||
<p>
|
||||
The SWIG generator yields the following warning for the last renaming:<br/>
|
||||
<tt>
|
||||
rename.i:36: Warning 509: Overloaded method to_val(FolderFormat) effectively ignored,<br/>
|
||||
rename.i:26: Warning 509: as it is shadowed by to_val(DirFormat).<br/>
|
||||
</tt>
|
||||
The renaming performed for the <tt>int to_val(FolderFormat flag, bool bin)</tt>,
|
||||
but not for the <tt>int to_val(FolderFormat flag)</tt>, where the second parameter <tt>bool bin</tt>
|
||||
is omitted taking the default value <tt>false</tt>. See details about the default
|
||||
parameters processing in the <a href="SWIGPlus.html#SWIGPlus_default_args">Default Arguments</a> section.
|
||||
</p>
|
||||
|
||||
|
||||
<p>
|
||||
Closely related to <tt>%rename</tt> is the <tt>%ignore</tt> directive. <tt>%ignore</tt> instructs SWIG
|
||||
|
|
@ -2115,7 +2088,7 @@ except those consisting of capital letters only:
|
|||
<p>
|
||||
Finally, variants of <tt>%rename</tt> and <tt>%ignore</tt> directives can be used to help
|
||||
wrap C++ overloaded functions and methods or C++ methods which use default arguments. This is described in the
|
||||
<a href="SWIGPlus.html#SWIGPlus_ambiguity_resolution_renaming">Ambiguity resolution and renaming</a> section in the C++ chapter.
|
||||
<a href="SWIGPlus.html#SWIGPlus_ambiguity_resolution_renaming">Renaming and ambiguity resolution</a> section in the C++ chapter.
|
||||
</p>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@
|
|||
<li><a href="#SWIGPlus_nn12">Static members</a>
|
||||
<li><a href="#SWIGPlus_member_data">Member data</a>
|
||||
</ul>
|
||||
<li><a href="#SWIGPlus_default_args">Default arguments</a>
|
||||
<li><a href="#SWIGPlus_nn15">Protection</a>
|
||||
<li><a href="#SWIGPlus_nn16">Enums and constants</a>
|
||||
<li><a href="#SWIGPlus_nn17">Friends</a>
|
||||
|
|
@ -39,14 +38,15 @@
|
|||
<li><a href="#SWIGPlus_nn19">Pass and return by value</a>
|
||||
<li><a href="#SWIGPlus_nn20">Inheritance</a>
|
||||
<li><a href="#SWIGPlus_nn21">A brief discussion of multiple inheritance, pointers, and type checking</a>
|
||||
<li><a href="#SWIGPlus_overloaded_methods">Wrapping Overloaded Functions and Methods</a>
|
||||
<li><a href="#SWIGPlus_default_args">Default arguments</a>
|
||||
<li><a href="#SWIGPlus_overloaded_methods">Overloaded functions and methods</a>
|
||||
<ul>
|
||||
<li><a href="#SWIGPlus_nn24">Dispatch function generation</a>
|
||||
<li><a href="#SWIGPlus_nn25">Ambiguity in Overloading</a>
|
||||
<li><a href="#SWIGPlus_ambiguity_resolution_renaming">Ambiguity resolution and renaming</a>
|
||||
<li><a href="#SWIGPlus_nn25">Ambiguity in overloading</a>
|
||||
<li><a href="#SWIGPlus_ambiguity_resolution_renaming">Renaming and ambiguity resolution</a>
|
||||
<li><a href="#SWIGPlus_nn27">Comments on overloading</a>
|
||||
</ul>
|
||||
<li><a href="#SWIGPlus_nn28">Wrapping overloaded operators</a>
|
||||
<li><a href="#SWIGPlus_nn28">Overloaded operators</a>
|
||||
<li><a href="#SWIGPlus_class_extension">Class extension</a>
|
||||
<li><a href="#SWIGPlus_nn30">Templates</a>
|
||||
<ul>
|
||||
|
|
@ -1104,113 +1104,7 @@ a few problems related to structure wrapping and some of SWIG's
|
|||
customization features.
|
||||
</p>
|
||||
|
||||
<H2><a name="SWIGPlus_default_args">6.7 Default arguments</a></H2>
|
||||
|
||||
|
||||
<p>
|
||||
SWIG will wrap all types of functions that have default arguments. For example member functions:
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
<pre>
|
||||
class Foo {
|
||||
public:
|
||||
void bar(int x, int y = 3, int z = 4);
|
||||
};
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
SWIG handles default arguments by generating an extra overloaded method for each defaulted argument.
|
||||
SWIG is effectively handling methods with default arguments as if it was wrapping the equivalent overloaded methods.
|
||||
Thus for the example above, it is as if we had instead given the following to SWIG:
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
<pre>
|
||||
class Foo {
|
||||
public:
|
||||
void bar(int x, int y, int z);
|
||||
void bar(int x, int y);
|
||||
void bar(int x);
|
||||
};
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
The wrappers produced are exactly the same as if the above code was instead fed into SWIG.
|
||||
Details of this are covered later in the <a href="#SWIGPlus_overloaded_methods">Wrapping Overloaded Functions and Methods</a> section.
|
||||
This approach allows SWIG to wrap all possible default arguments, but can be verbose.
|
||||
For example if a method has ten default arguments, then eleven wrapper methods are generated.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Please see the <a href="Customization.html#Customization_features_default_args">Features and default arguments</a>
|
||||
section for more information on using <tt>%feature</tt> with functions with default arguments.
|
||||
The <a href="#SWIGPlus_ambiguity_resolution_renaming">Ambiguity resolution and renaming</a> section
|
||||
also deals with using <tt>%rename</tt> and <tt>%ignore</tt> on methods with default arguments.
|
||||
If you are writing your own typemaps for types used in methods with default arguments, you may also need to write a <tt>typecheck</tt> typemap.
|
||||
See the <a href="Typemaps.html#Typemaps_overloading">Typemaps and overloading</a> section for details or otherwise
|
||||
use the <tt>compactdefaultargs</tt> feature flag as mentioned below.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Compatibility note:</b> Versions of SWIG prior to SWIG-1.3.23 wrapped default arguments slightly differently.
|
||||
Instead a single wrapper method was generated and the default values were copied into the C++ wrappers
|
||||
so that the method being wrapped was then called with all the arguments specified.
|
||||
If the size of the wrappers are a concern then this approach to wrapping methods with default arguments
|
||||
can be re-activated by using the <tt>compactdefaultargs</tt>
|
||||
<a href="Customization.html#Customization_feature_flags">feature flag</a>.
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
<pre>
|
||||
%feature("compactdefaultargs") Foo::bar;
|
||||
class Foo {
|
||||
public:
|
||||
void bar(int x, int y = 3, int z = 4);
|
||||
};
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
||||
<p>
|
||||
This is great for reducing the size of the wrappers, but the caveat is it does not work for the statically typed languages,
|
||||
such as C# and Java,
|
||||
which don't have optional arguments in the language,
|
||||
Another restriction of this feature is that it cannot handle default arguments that are not public.
|
||||
The following example illustrates this:
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
<pre>
|
||||
class Foo {
|
||||
private:
|
||||
static const int spam;
|
||||
public:
|
||||
void bar(int x, int y = spam); // Won't work with %feature("compactdefaultargs") -
|
||||
// private default value
|
||||
};
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
This produces uncompilable wrapper code because default values in C++ are
|
||||
evaluated in the same scope as the member function whereas SWIG
|
||||
evaluates them in the scope of a wrapper function (meaning that the
|
||||
values have to be public).
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The <tt>compactdefaultargs</tt> feature is automatically turned on when wrapping <a href="SWIG.html#SWIG_default_args">C code with default arguments</a>.
|
||||
Some target languages will also automatically turn on this feature
|
||||
if the keyword arguments feature (kwargs) is specified for either C or C++ functions, and the target language supports kwargs,
|
||||
the <tt>compactdefaultargs</tt> feature is also automatically turned on.
|
||||
Keyword arguments are a language feature of some scripting languages, for example Ruby and Python.
|
||||
SWIG is unable to support kwargs when wrapping overloaded methods, so the default approach cannot be used.
|
||||
</p>
|
||||
|
||||
<H2><a name="SWIGPlus_nn15">6.8 Protection</a></H2>
|
||||
<H2><a name="SWIGPlus_nn15">6.7 Protection</a></H2>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -1230,7 +1124,7 @@ until you explicitly give a `<tt>public:</tt>' declaration (This is
|
|||
the same convention used by C++).
|
||||
</p>
|
||||
|
||||
<H2><a name="SWIGPlus_nn16">6.9 Enums and constants</a></H2>
|
||||
<H2><a name="SWIGPlus_nn16">6.8 Enums and constants</a></H2>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -1260,7 +1154,7 @@ Swig_STOUT = Swig::STOUT
|
|||
Members declared as <tt>const</tt> are wrapped as read-only members and do not create constants.
|
||||
</p>
|
||||
|
||||
<H2><a name="SWIGPlus_nn17">6.10 Friends</a></H2>
|
||||
<H2><a name="SWIGPlus_nn17">6.9 Friends</a></H2>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -1321,7 +1215,7 @@ namespace bar {
|
|||
and a wrapper for the method 'blah' will not be generated.
|
||||
</p>
|
||||
|
||||
<H2><a name="SWIGPlus_nn18">6.11 References and pointers</a></H2>
|
||||
<H2><a name="SWIGPlus_nn18">6.10 References and pointers</a></H2>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -1421,7 +1315,7 @@ templates and the STL. This was first added in SWIG-1.3.12.
|
|||
</p>
|
||||
|
||||
|
||||
<H2><a name="SWIGPlus_nn19">6.12 Pass and return by value</a></H2>
|
||||
<H2><a name="SWIGPlus_nn19">6.11 Pass and return by value</a></H2>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -1525,7 +1419,7 @@ classes that don't define a default constructor.
|
|||
It is not used for C++ pointers or references.
|
||||
</p>
|
||||
|
||||
<H2><a name="SWIGPlus_nn20">6.13 Inheritance</a></H2>
|
||||
<H2><a name="SWIGPlus_nn20">6.12 Inheritance</a></H2>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -1711,7 +1605,7 @@ functions for virtual members that are already defined in a base
|
|||
class.
|
||||
</p>
|
||||
|
||||
<H2><a name="SWIGPlus_nn21">6.14 A brief discussion of multiple inheritance, pointers, and type checking</a></H2>
|
||||
<H2><a name="SWIGPlus_nn21">6.13 A brief discussion of multiple inheritance, pointers, and type checking</a></H2>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -1843,7 +1737,113 @@ int y = B_function((B *) pB);
|
|||
In practice, the pointer is held as an integral number in the target language proxy class.
|
||||
</p>
|
||||
|
||||
<H2><a name="SWIGPlus_overloaded_methods">6.15 Wrapping Overloaded Functions and Methods</a></H2>
|
||||
<H2><a name="SWIGPlus_default_args">6.14 Default arguments</a></H2>
|
||||
|
||||
|
||||
<p>
|
||||
SWIG will wrap all types of functions that have default arguments. For example member functions:
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
<pre>
|
||||
class Foo {
|
||||
public:
|
||||
void bar(int x, int y = 3, int z = 4);
|
||||
};
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
SWIG handles default arguments by generating an extra overloaded method for each defaulted argument.
|
||||
SWIG is effectively handling methods with default arguments as if it was wrapping the equivalent overloaded methods.
|
||||
Thus for the example above, it is as if we had instead given the following to SWIG:
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
<pre>
|
||||
class Foo {
|
||||
public:
|
||||
void bar(int x, int y, int z);
|
||||
void bar(int x, int y);
|
||||
void bar(int x);
|
||||
};
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
The wrappers produced are exactly the same as if the above code was instead fed into SWIG.
|
||||
Details of this are covered in the next section <a href="#SWIGPlus_overloaded_methods">Overloaded functions and methods</a>.
|
||||
This approach allows SWIG to wrap all possible default arguments, but can be verbose.
|
||||
For example if a method has ten default arguments, then eleven wrapper methods are generated.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Please see the <a href="Customization.html#Customization_features_default_args">Features and default arguments</a>
|
||||
section for more information on using <tt>%feature</tt> with functions with default arguments.
|
||||
The <a href="#SWIGPlus_ambiguity_resolution_renaming">Renaming and ambiguity resolution</a> section
|
||||
also deals with using <tt>%rename</tt> and <tt>%ignore</tt> on methods with default arguments.
|
||||
If you are writing your own typemaps for types used in methods with default arguments, you may also need to write a <tt>typecheck</tt> typemap.
|
||||
See the <a href="Typemaps.html#Typemaps_overloading">Typemaps and overloading</a> section for details or otherwise
|
||||
use the <tt>compactdefaultargs</tt> feature flag as mentioned below.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Compatibility note:</b> Versions of SWIG prior to SWIG-1.3.23 wrapped default arguments slightly differently.
|
||||
Instead a single wrapper method was generated and the default values were copied into the C++ wrappers
|
||||
so that the method being wrapped was then called with all the arguments specified.
|
||||
If the size of the wrappers are a concern then this approach to wrapping methods with default arguments
|
||||
can be re-activated by using the <tt>compactdefaultargs</tt>
|
||||
<a href="Customization.html#Customization_feature_flags">feature flag</a>.
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
<pre>
|
||||
%feature("compactdefaultargs") Foo::bar;
|
||||
class Foo {
|
||||
public:
|
||||
void bar(int x, int y = 3, int z = 4);
|
||||
};
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
||||
<p>
|
||||
This is great for reducing the size of the wrappers, but the caveat is it does not work for the statically typed languages,
|
||||
such as C# and Java,
|
||||
which don't have optional arguments in the language,
|
||||
Another restriction of this feature is that it cannot handle default arguments that are not public.
|
||||
The following example illustrates this:
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
<pre>
|
||||
class Foo {
|
||||
private:
|
||||
static const int spam;
|
||||
public:
|
||||
void bar(int x, int y = spam); // Won't work with %feature("compactdefaultargs") -
|
||||
// private default value
|
||||
};
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
This produces uncompilable wrapper code because default values in C++ are
|
||||
evaluated in the same scope as the member function whereas SWIG
|
||||
evaluates them in the scope of a wrapper function (meaning that the
|
||||
values have to be public).
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The <tt>compactdefaultargs</tt> feature is automatically turned on when wrapping <a href="SWIG.html#SWIG_default_args">C code with default arguments</a>.
|
||||
Some target languages will also automatically turn on this feature
|
||||
if the keyword arguments feature (kwargs) is specified for either C or C++ functions, and the target language supports kwargs,
|
||||
the <tt>compactdefaultargs</tt> feature is also automatically turned on.
|
||||
Keyword arguments are a language feature of some scripting languages, for example Ruby and Python.
|
||||
SWIG is unable to support kwargs when wrapping overloaded methods, so the default approach cannot be used.
|
||||
</p>
|
||||
|
||||
<H2><a name="SWIGPlus_overloaded_methods">6.15 Overloaded functions and methods</a></H2>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -2031,7 +2031,7 @@ checked in the same order as they appear in this ranking.
|
|||
If you're still confused, don't worry about it---SWIG is probably doing the right thing.
|
||||
</p>
|
||||
|
||||
<H3><a name="SWIGPlus_nn25">6.15.2 Ambiguity in Overloading</a></H3>
|
||||
<H3><a name="SWIGPlus_nn25">6.15.2 Ambiguity in overloading</a></H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -2149,7 +2149,7 @@ it means that the target language module has not yet implemented support for ove
|
|||
functions and methods. The only way to fix the problem is to read the next section.
|
||||
</p>
|
||||
|
||||
<H3><a name="SWIGPlus_ambiguity_resolution_renaming">6.15.3 Ambiguity resolution and renaming</a></H3>
|
||||
<H3><a name="SWIGPlus_ambiguity_resolution_renaming">6.15.3 Renaming and ambiguity resolution</a></H3>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -2562,8 +2562,7 @@ exactly matches the wrapped method:
|
|||
<p>
|
||||
The C++ method can then be called from the target language with the new name no matter how many arguments are specified, for example:
|
||||
<tt>newbar(2, 2.0)</tt>, <tt>newbar(2)</tt> or <tt>newbar()</tt>.
|
||||
However, if the <tt>%rename</tt> does not contain the default arguments, it will only apply to the single equivalent target language overloaded method.
|
||||
So if instead we have:
|
||||
However, if the <tt>%rename</tt> does not contain the default arguments:
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
|
|
@ -2572,9 +2571,24 @@ So if instead we have:
|
|||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
then only one of the three equivalent overloaded methods will be renamed and wrapped as if SWIG parsed:
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
<pre>
|
||||
void Spam::newbar(int i, double d);
|
||||
void Spam::bar(int i);
|
||||
void Spam::bar();
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
The C++ method must then be called from the target language with the new name <tt>newbar(2, 2.0)</tt> when both arguments are supplied
|
||||
or with the original name as <tt>bar(2)</tt> (one argument) or <tt>bar()</tt> (no arguments).
|
||||
</p>
|
||||
|
||||
<p>
|
||||
In fact it is possible to use <tt>%rename</tt> on the equivalent overloaded methods, to rename all the equivalent overloaded methods:
|
||||
</p>
|
||||
|
||||
|
|
@ -2616,7 +2630,7 @@ As a general rule, statically typed languages like Java are able to provide more
|
|||
than dynamically typed languages like Perl, Python, Ruby, and Tcl.
|
||||
</p>
|
||||
|
||||
<H2><a name="SWIGPlus_nn28">6.16 Wrapping overloaded operators</a></H2>
|
||||
<H2><a name="SWIGPlus_nn28">6.16 Overloaded operators</a></H2>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
|
|||
|
|
@ -1133,7 +1133,7 @@ But we can use either use the <tt>get_perimeter()</tt> function of the parent cl
|
|||
|
||||
|
||||
<p>
|
||||
As explained in <a href="SWIGPlus.html#SWIGPlus_overloaded_methods">6.15</a> SWIG provides support for overloaded functions and constructors.
|
||||
As explained in <a href="SWIGPlus.html#SWIGPlus_overloaded_methods">Overloaded functions and methods</a> SWIG provides support for overloaded functions and constructors.
|
||||
</p>
|
||||
|
||||
<p>As SWIG knows pointer types, the overloading works also with pointer types, here is an example with a function <tt>magnify</tt> overloaded for the previous classes <tt>Shape</tt> and <tt>Circle</tt>:
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>SWIG-3.0 Documentation</title>
|
||||
<title>SWIG-4.0 Documentation</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
</head>
|
||||
<body bgcolor="#ffffff">
|
||||
<H1><a name="Sections">SWIG-3.0 Documentation</a></H1>
|
||||
<H1><a name="Sections">SWIG-4.0 Documentation</a></H1>
|
||||
|
||||
<p>
|
||||
Last update : SWIG-4.0.0 (in progress)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>SWIG-3.0 Documentation</title>
|
||||
<title>SWIG-4.0 Documentation</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
</head>
|
||||
<body bgcolor="#ffffff">
|
||||
<H1><a name="index">SWIG-3.0 Documentation</a></H1>
|
||||
<H1><a name="index">SWIG-4.0 Documentation</a></H1>
|
||||
|
||||
The SWIG documentation is available in one of the following formats.
|
||||
<ul>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue