Merge branch 'master' into master
This commit is contained in:
commit
f1df34642b
16 changed files with 205 additions and 758 deletions
10
.travis.yml
10
.travis.yml
|
|
@ -1,5 +1,4 @@
|
|||
language: cpp
|
||||
group: deprecated-2017Q3 # workaround for failing: pip install pep8
|
||||
matrix:
|
||||
include:
|
||||
- compiler: clang
|
||||
|
|
@ -50,10 +49,11 @@ matrix:
|
|||
env: SWIGLANG=java
|
||||
sudo: required
|
||||
dist: trusty
|
||||
# - compiler: gcc
|
||||
# os: linux
|
||||
# env: SWIGLANG=javascript ENGINE=node
|
||||
# dist: trusty
|
||||
- compiler: gcc
|
||||
os: linux
|
||||
env: SWIGLANG=javascript ENGINE=node
|
||||
sudo: required
|
||||
dist: trusty
|
||||
- compiler: gcc
|
||||
os: linux
|
||||
env: SWIGLANG=javascript ENGINE=jsc
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -5,30 +5,30 @@
|
|||
%}
|
||||
|
||||
// typemaps to completely ignore the input parm and override it
|
||||
%typemap(in) short (Funcs::*ff)(bool) const %{ $1 = &Funcs::FF2; %}
|
||||
%typemap(in) short (Funcs::*cc)(bool) & %{ $1 = &Funcs::CC5; %}
|
||||
%typemap(in) short (Funcs::*gg)(bool) const & %{ $1 = &Funcs::GG8; %}
|
||||
%typemap(in) short (Funcs::*hh)(bool) && %{ $1 = &Funcs::HH11; %}
|
||||
%typemap(in) short (Funcs::*ff)(bool) const %{ $1 = &Funcs::FFF2; %}
|
||||
%typemap(in) short (Funcs::*cc)(bool) & %{ $1 = &Funcs::CCC5; %}
|
||||
%typemap(in) short (Funcs::*gg)(bool) const & %{ $1 = &Funcs::GGG8; %}
|
||||
%typemap(in) short (Funcs::*hh)(bool) && %{ $1 = &Funcs::HHH11; %}
|
||||
|
||||
%typemap(in) short (Funcs::*)(bool) const %{ $1 = &Funcs::FF3; %}
|
||||
%typemap(in) short (Funcs::*)(bool) & %{ $1 = &Funcs::CC6; %}
|
||||
%typemap(in) short (Funcs::*)(bool) const & %{ $1 = &Funcs::GG9; %}
|
||||
%typemap(in) short (Funcs::*)(bool) && %{ $1 = &Funcs::HH12; %}
|
||||
%typemap(in) short (Funcs::*)(bool) const %{ $1 = &Funcs::FFF3; %}
|
||||
%typemap(in) short (Funcs::*)(bool) & %{ $1 = &Funcs::CCC6; %}
|
||||
%typemap(in) short (Funcs::*)(bool) const & %{ $1 = &Funcs::GGG9; %}
|
||||
%typemap(in) short (Funcs::*)(bool) && %{ $1 = &Funcs::HHH12; %}
|
||||
|
||||
%inline %{
|
||||
struct Funcs {
|
||||
short FF1(bool) const { return 1; }
|
||||
short FF2(bool) const { return 2; }
|
||||
short FF3(bool) const { return 3; }
|
||||
short CC4(bool) & { return 4; }
|
||||
short CC5(bool) & { return 5; }
|
||||
short CC6(bool) & { return 6; }
|
||||
short GG7(bool) const & { return 7; }
|
||||
short GG8(bool) const & { return 8; }
|
||||
short GG9(bool) const & { return 9; }
|
||||
short HH10(bool) && { return 10; }
|
||||
short HH11(bool) && { return 11; }
|
||||
short HH12(bool) && { return 12; }
|
||||
short FFF1(bool) const { return 1; }
|
||||
short FFF2(bool) const { return 2; }
|
||||
short FFF3(bool) const { return 3; }
|
||||
short CCC4(bool) & { return 4; }
|
||||
short CCC5(bool) & { return 5; }
|
||||
short CCC6(bool) & { return 6; }
|
||||
short GGG7(bool) const & { return 7; }
|
||||
short GGG8(bool) const & { return 8; }
|
||||
short GGG9(bool) const & { return 9; }
|
||||
short HHH10(bool) && { return 10; }
|
||||
short HHH11(bool) && { return 11; }
|
||||
short HHH12(bool) && { return 12; }
|
||||
};
|
||||
struct TypemapsNamedParms
|
||||
{
|
||||
|
|
@ -68,7 +68,7 @@ struct TypemapsUnnamedParms
|
|||
};
|
||||
%}
|
||||
|
||||
%constant short (Funcs::*FF1_MFP)(bool) const = &Funcs::FF1;
|
||||
%constant short (Funcs::*CC4_MFP)(bool) & = &Funcs::CC4;
|
||||
%constant short (Funcs::*GG7_MFP)(bool) const & = &Funcs::GG7;
|
||||
%constant short (Funcs::*HH10_MFP)(bool) && = &Funcs::HH10;
|
||||
%constant short (Funcs::*FF1_MFP)(bool) const = &Funcs::FFF1;
|
||||
%constant short (Funcs::*CC4_MFP)(bool) & = &Funcs::CCC4;
|
||||
%constant short (Funcs::*GG7_MFP)(bool) const & = &Funcs::GGG7;
|
||||
%constant short (Funcs::*HH10_MFP)(bool) && = &Funcs::HHH10;
|
||||
|
|
|
|||
|
|
@ -8,13 +8,13 @@ namespace std {
|
|||
|
||||
template<class T, size_t N> class array {
|
||||
public:
|
||||
typedef T& reference;
|
||||
typedef const T& const_reference;
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T value_type;
|
||||
typedef T* pointer;
|
||||
typedef const T* const_pointer;
|
||||
typedef T &reference;
|
||||
typedef const T &const_reference;
|
||||
typedef T *pointer;
|
||||
typedef const T *const_pointer;
|
||||
array();
|
||||
array(const array& other);
|
||||
size_type size() const;
|
||||
|
|
|
|||
|
|
@ -1685,285 +1685,6 @@ int ALLEGROCL::top(Node *n) {
|
|||
return SWIG_OK;
|
||||
}
|
||||
|
||||
/* very shamelessly 'borrowed' from overload.cxx, which
|
||||
keeps the below Swig_overload_rank() code to itself.
|
||||
We don't need a dispatch function in the C++ wrapper
|
||||
code; we want it over on the lisp side. */
|
||||
|
||||
#define Swig_overload_rank Allegrocl_swig_overload_rank
|
||||
|
||||
#define MAX_OVERLOAD 256
|
||||
|
||||
/* Overload "argc" and "argv" */
|
||||
// String *argv_template_string;
|
||||
// String *argc_template_string;
|
||||
|
||||
struct Overloaded {
|
||||
Node *n; /* Node */
|
||||
int argc; /* Argument count */
|
||||
ParmList *parms; /* Parameters used for overload check */
|
||||
int error; /* Ambiguity error */
|
||||
};
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_overload_rank()
|
||||
*
|
||||
* This function takes an overloaded declaration and creates a list that ranks
|
||||
* all overloaded methods in an order that can be used to generate a dispatch
|
||||
* function.
|
||||
* Slight difference in the way this function is used by scripting languages and
|
||||
* statically typed languages. The script languages call this method via
|
||||
* Swig_overload_dispatch() - where wrappers for all overloaded methods are generated,
|
||||
* however sometimes the code can never be executed. The non-scripting languages
|
||||
* call this method via Swig_overload_check() for each overloaded method in order
|
||||
* to determine whether or not the method should be wrapped. Note the slight
|
||||
* difference when overloading methods that differ by const only. The
|
||||
* scripting languages will ignore the const method, whereas the non-scripting
|
||||
* languages ignore the first method parsed.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
|
||||
Overloaded nodes[MAX_OVERLOAD];
|
||||
int nnodes = 0;
|
||||
Node *o = Getattr(n, "sym:overloaded");
|
||||
Node *c;
|
||||
|
||||
if (!o)
|
||||
return 0;
|
||||
|
||||
c = o;
|
||||
while (c) {
|
||||
if (Getattr(c, "error")) {
|
||||
c = Getattr(c, "sym:nextSibling");
|
||||
continue;
|
||||
}
|
||||
/* if (SmartPointer && Getattr(c,"cplus:staticbase")) {
|
||||
c = Getattr(c,"sym:nextSibling");
|
||||
continue;
|
||||
} */
|
||||
|
||||
/* Make a list of all the declarations (methods) that are overloaded with
|
||||
* this one particular method name */
|
||||
if (Getattr(c, "wrap:name")) {
|
||||
nodes[nnodes].n = c;
|
||||
nodes[nnodes].parms = Getattr(c, "wrap:parms");
|
||||
nodes[nnodes].argc = emit_num_required(nodes[nnodes].parms);
|
||||
nodes[nnodes].error = 0;
|
||||
nnodes++;
|
||||
}
|
||||
c = Getattr(c, "sym:nextSibling");
|
||||
}
|
||||
|
||||
/* Sort the declarations by required argument count */
|
||||
{
|
||||
int i, j;
|
||||
for (i = 0; i < nnodes; i++) {
|
||||
for (j = i + 1; j < nnodes; j++) {
|
||||
if (nodes[i].argc > nodes[j].argc) {
|
||||
Overloaded t = nodes[i];
|
||||
nodes[i] = nodes[j];
|
||||
nodes[j] = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Sort the declarations by argument types */
|
||||
{
|
||||
int i, j;
|
||||
for (i = 0; i < nnodes - 1; i++) {
|
||||
if (nodes[i].argc == nodes[i + 1].argc) {
|
||||
for (j = i + 1; (j < nnodes) && (nodes[j].argc == nodes[i].argc); j++) {
|
||||
Parm *p1 = nodes[i].parms;
|
||||
Parm *p2 = nodes[j].parms;
|
||||
int differ = 0;
|
||||
int num_checked = 0;
|
||||
while (p1 && p2 && (num_checked < nodes[i].argc)) {
|
||||
// Printf(stdout,"p1 = '%s', p2 = '%s'\n", Getattr(p1,"type"), Getattr(p2,"type"));
|
||||
if (checkAttribute(p1, "tmap:in:numinputs", "0")) {
|
||||
p1 = Getattr(p1, "tmap:in:next");
|
||||
continue;
|
||||
}
|
||||
if (checkAttribute(p2, "tmap:in:numinputs", "0")) {
|
||||
p2 = Getattr(p2, "tmap:in:next");
|
||||
continue;
|
||||
}
|
||||
String *t1 = Getattr(p1, "tmap:typecheck:precedence");
|
||||
String *t2 = Getattr(p2, "tmap:typecheck:precedence");
|
||||
if ((!t1) && (!nodes[i].error)) {
|
||||
Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"Overloaded method %s not supported (incomplete type checking rule - no precedence level in typecheck typemap for '%s').\n",
|
||||
Swig_name_decl(nodes[i].n), SwigType_str(Getattr(p1, "type"), 0));
|
||||
nodes[i].error = 1;
|
||||
} else if ((!t2) && (!nodes[j].error)) {
|
||||
Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s not supported (incomplete type checking rule - no precedence level in typecheck typemap for '%s').\n",
|
||||
Swig_name_decl(nodes[j].n), SwigType_str(Getattr(p2, "type"), 0));
|
||||
nodes[j].error = 1;
|
||||
}
|
||||
if (t1 && t2) {
|
||||
int t1v, t2v;
|
||||
t1v = atoi(Char(t1));
|
||||
t2v = atoi(Char(t2));
|
||||
differ = t1v - t2v;
|
||||
} else if (!t1 && t2)
|
||||
differ = 1;
|
||||
else if (t1 && !t2)
|
||||
differ = -1;
|
||||
else if (!t1 && !t2)
|
||||
differ = -1;
|
||||
num_checked++;
|
||||
if (differ > 0) {
|
||||
Overloaded t = nodes[i];
|
||||
nodes[i] = nodes[j];
|
||||
nodes[j] = t;
|
||||
break;
|
||||
} else if ((differ == 0) && (Strcmp(t1, "0") == 0)) {
|
||||
t1 = Getattr(p1, "ltype");
|
||||
if (!t1) {
|
||||
t1 = SwigType_ltype(Getattr(p1, "type"));
|
||||
if (Getattr(p1, "tmap:typecheck:SWIGTYPE")) {
|
||||
SwigType_add_pointer(t1);
|
||||
}
|
||||
Setattr(p1, "ltype", t1);
|
||||
}
|
||||
t2 = Getattr(p2, "ltype");
|
||||
if (!t2) {
|
||||
t2 = SwigType_ltype(Getattr(p2, "type"));
|
||||
if (Getattr(p2, "tmap:typecheck:SWIGTYPE")) {
|
||||
SwigType_add_pointer(t2);
|
||||
}
|
||||
Setattr(p2, "ltype", t2);
|
||||
}
|
||||
|
||||
/* Need subtype check here. If t2 is a subtype of t1, then we need to change the
|
||||
order */
|
||||
|
||||
if (SwigType_issubtype(t2, t1)) {
|
||||
Overloaded t = nodes[i];
|
||||
nodes[i] = nodes[j];
|
||||
nodes[j] = t;
|
||||
}
|
||||
|
||||
if (Strcmp(t1, t2) != 0) {
|
||||
differ = 1;
|
||||
break;
|
||||
}
|
||||
} else if (differ) {
|
||||
break;
|
||||
}
|
||||
if (Getattr(p1, "tmap:in:next")) {
|
||||
p1 = Getattr(p1, "tmap:in:next");
|
||||
} else {
|
||||
p1 = nextSibling(p1);
|
||||
}
|
||||
if (Getattr(p2, "tmap:in:next")) {
|
||||
p2 = Getattr(p2, "tmap:in:next");
|
||||
} else {
|
||||
p2 = nextSibling(p2);
|
||||
}
|
||||
}
|
||||
if (!differ) {
|
||||
/* See if declarations differ by const only */
|
||||
String *d1 = Getattr(nodes[i].n, "decl");
|
||||
String *d2 = Getattr(nodes[j].n, "decl");
|
||||
if (d1 && d2) {
|
||||
String *dq1 = Copy(d1);
|
||||
String *dq2 = Copy(d2);
|
||||
if (SwigType_isconst(d1)) {
|
||||
Delete(SwigType_pop(dq1));
|
||||
}
|
||||
if (SwigType_isconst(d2)) {
|
||||
Delete(SwigType_pop(dq2));
|
||||
}
|
||||
if (Strcmp(dq1, dq2) == 0) {
|
||||
|
||||
if (SwigType_isconst(d1) && !SwigType_isconst(d2)) {
|
||||
if (script_lang_wrapping) {
|
||||
// Swap nodes so that the const method gets ignored (shadowed by the non-const method)
|
||||
Overloaded t = nodes[i];
|
||||
nodes[i] = nodes[j];
|
||||
nodes[j] = t;
|
||||
}
|
||||
differ = 1;
|
||||
if (!nodes[j].error) {
|
||||
if (script_lang_wrapping) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
|
||||
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"using non-const method %s instead.\n", Swig_name_decl(nodes[i].n));
|
||||
} else {
|
||||
if (!Getattr(nodes[j].n, "overload:ignore")) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"using %s instead.\n", Swig_name_decl(nodes[i].n));
|
||||
}
|
||||
}
|
||||
}
|
||||
nodes[j].error = 1;
|
||||
} else if (!SwigType_isconst(d1) && SwigType_isconst(d2)) {
|
||||
differ = 1;
|
||||
if (!nodes[j].error) {
|
||||
if (script_lang_wrapping) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
|
||||
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"using non-const method %s instead.\n", Swig_name_decl(nodes[i].n));
|
||||
} else {
|
||||
if (!Getattr(nodes[j].n, "overload:ignore")) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"using %s instead.\n", Swig_name_decl(nodes[i].n));
|
||||
}
|
||||
}
|
||||
}
|
||||
nodes[j].error = 1;
|
||||
}
|
||||
}
|
||||
Delete(dq1);
|
||||
Delete(dq2);
|
||||
}
|
||||
}
|
||||
if (!differ) {
|
||||
if (!nodes[j].error) {
|
||||
if (script_lang_wrapping) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s effectively ignored,\n", Swig_name_decl(nodes[j].n));
|
||||
Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"as it is shadowed by %s.\n", Swig_name_decl(nodes[i].n));
|
||||
} else {
|
||||
if (!Getattr(nodes[j].n, "overload:ignore")) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"using %s instead.\n", Swig_name_decl(nodes[i].n));
|
||||
}
|
||||
}
|
||||
nodes[j].error = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
List *result = NewList();
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < nnodes; i++) {
|
||||
if (nodes[i].error)
|
||||
Setattr(nodes[i].n, "overload:ignore", "1");
|
||||
Append(result, nodes[i].n);
|
||||
// Printf(stdout,"[ %d ] %s\n", i, ParmList_errorstr(nodes[i].parms));
|
||||
// Swig_print_node(nodes[i].n);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* end shameless borrowing */
|
||||
|
||||
int any_varargs(ParmList *pl) {
|
||||
Parm *p;
|
||||
|
||||
|
|
|
|||
|
|
@ -454,7 +454,7 @@ String *emit_action(Node *n) {
|
|||
if (catchlist) {
|
||||
int unknown_catch = 0;
|
||||
int has_varargs = 0;
|
||||
Printf(eaction, "}\n");
|
||||
Printf(eaction, "} ");
|
||||
for (Parm *ep = catchlist; ep; ep = nextSibling(ep)) {
|
||||
String *em = Swig_typemap_lookup("throws", ep, "_e", 0);
|
||||
if (em) {
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ static String *getSlot(Node *n = NULL, const char *key = NULL, String *default_s
|
|||
|
||||
static void printSlot(File *f, String *slotval, const char *slotname, const char *functype = NULL) {
|
||||
String *slotval_override = 0;
|
||||
if (functype)
|
||||
if (functype && Strcmp(slotval, "0") == 0)
|
||||
slotval = slotval_override = NewStringf("(%s) %s", functype, slotval);
|
||||
int len = Len(slotval);
|
||||
int fieldwidth = len > 41 ? (len > 61 ? 0 : 61 - len) : 41 - len;
|
||||
|
|
@ -2501,7 +2501,8 @@ public:
|
|||
|
||||
String *tmp = NewString("");
|
||||
String *dispatch;
|
||||
const char *dispatch_code = funpack ? "return %s(self, argc, argv);" : "return %s(self, args);";
|
||||
const char *dispatch_code = funpack ? "return %s(self, argc, argv);" :
|
||||
(builtin_ctor ? "return %s(self, args, NULL);" : "return %s(self, args);");
|
||||
|
||||
if (castmode) {
|
||||
dispatch = Swig_overload_dispatch_cast(n, dispatch_code, &maxargs);
|
||||
|
|
@ -2515,7 +2516,8 @@ public:
|
|||
String *symname = Getattr(n, "sym:name");
|
||||
String *wname = Swig_name_wrapper(symname);
|
||||
|
||||
Printv(f->def, linkage, builtin_ctor ? "int " : "PyObject *", wname, "(PyObject *self, PyObject *args) {", NIL);
|
||||
const char *builtin_kwargs = builtin_ctor ? ", PyObject *SWIGUNUSEDPARM(kwargs)" : "";
|
||||
Printv(f->def, linkage, builtin_ctor ? "int " : "PyObject *", wname, "(PyObject *self, PyObject *args", builtin_kwargs, ") {", NIL);
|
||||
|
||||
Wrapper_add_local(f, "argc", "Py_ssize_t argc");
|
||||
Printf(tmp, "PyObject *argv[%d] = {0}", maxargs + 1);
|
||||
|
|
@ -2729,9 +2731,10 @@ public:
|
|||
Append(wname, overname);
|
||||
}
|
||||
|
||||
const char *builtin_kwargs = builtin_ctor ? ", PyObject *SWIGUNUSEDPARM(kwargs)" : "";
|
||||
if (!allow_kwargs || overname) {
|
||||
if (!varargs) {
|
||||
Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", PyObject *args) {", NIL);
|
||||
Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", PyObject *args", builtin_kwargs, ") {", NIL);
|
||||
} else {
|
||||
Printv(f->def, linkage, wrap_return, wname, "__varargs__", "(PyObject *", self_param, ", PyObject *args, PyObject *varargs) {", NIL);
|
||||
}
|
||||
|
|
@ -2933,11 +2936,7 @@ public:
|
|||
}
|
||||
Printf(parse_args, "if ((nobjs < %d) || (nobjs > %d)) SWIG_fail;\n", num_required, num_arguments);
|
||||
} else {
|
||||
if (noargs) {
|
||||
Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", PyObject *args) {", NIL);
|
||||
} else {
|
||||
Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", PyObject *args) {", NIL);
|
||||
}
|
||||
Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", PyObject *args", builtin_kwargs, ") {", NIL);
|
||||
if (onearg && !builtin_ctor) {
|
||||
Printf(parse_args, "if (!args) SWIG_fail;\n");
|
||||
Append(parse_args, "swig_obj[0] = args;\n");
|
||||
|
|
@ -3241,7 +3240,7 @@ public:
|
|||
// Note: funpack is currently always false for varargs
|
||||
Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", Py_ssize_t nobjs, PyObject **swig_obj) {", NIL);
|
||||
} else {
|
||||
Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", PyObject *args) {", NIL);
|
||||
Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", PyObject *args", builtin_kwargs, ") {", NIL);
|
||||
}
|
||||
Wrapper_add_local(f, "resultobj", builtin_ctor ? "int resultobj" : "PyObject *resultobj");
|
||||
Wrapper_add_local(f, "varargs", "PyObject *varargs");
|
||||
|
|
@ -3351,7 +3350,7 @@ public:
|
|||
closure_name = Copy(wrapper_name);
|
||||
}
|
||||
if (func_type) {
|
||||
String *s = NewStringf("(%s) %s", func_type, closure_name);
|
||||
String *s = NewStringf("%s", closure_name);
|
||||
Delete(closure_name);
|
||||
closure_name = s;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -290,8 +290,6 @@ public:
|
|||
int membervariableHandler(Node *n);
|
||||
|
||||
int typedefHandler(Node *n);
|
||||
static List *Swig_overload_rank(Node *n,
|
||||
bool script_lang_wrapping);
|
||||
|
||||
int memberfunctionHandler(Node *n) {
|
||||
if (debugMode)
|
||||
|
|
@ -1314,260 +1312,6 @@ void R::addAccessor(String *memberName, Wrapper *wrapper, String *name,
|
|||
Printf(stdout, "Adding accessor: %s (%s) => %s\n", memberName, name, tmp);
|
||||
}
|
||||
|
||||
#define MAX_OVERLOAD 256
|
||||
|
||||
struct Overloaded {
|
||||
Node *n; /* Node */
|
||||
int argc; /* Argument count */
|
||||
ParmList *parms; /* Parameters used for overload check */
|
||||
int error; /* Ambiguity error */
|
||||
};
|
||||
|
||||
|
||||
List * R::Swig_overload_rank(Node *n,
|
||||
bool script_lang_wrapping) {
|
||||
Overloaded nodes[MAX_OVERLOAD];
|
||||
int nnodes = 0;
|
||||
Node *o = Getattr(n,"sym:overloaded");
|
||||
|
||||
|
||||
if (!o) return 0;
|
||||
|
||||
Node *c = o;
|
||||
while (c) {
|
||||
if (Getattr(c,"error")) {
|
||||
c = Getattr(c,"sym:nextSibling");
|
||||
continue;
|
||||
}
|
||||
/* if (SmartPointer && Getattr(c,"cplus:staticbase")) {
|
||||
c = Getattr(c,"sym:nextSibling");
|
||||
continue;
|
||||
} */
|
||||
|
||||
/* Make a list of all the declarations (methods) that are overloaded with
|
||||
* this one particular method name */
|
||||
|
||||
if (Getattr(c,"wrap:name")) {
|
||||
nodes[nnodes].n = c;
|
||||
nodes[nnodes].parms = Getattr(c,"wrap:parms");
|
||||
nodes[nnodes].argc = emit_num_required(nodes[nnodes].parms);
|
||||
nodes[nnodes].error = 0;
|
||||
nnodes++;
|
||||
}
|
||||
c = Getattr(c,"sym:nextSibling");
|
||||
}
|
||||
|
||||
/* Sort the declarations by required argument count */
|
||||
{
|
||||
int i,j;
|
||||
for (i = 0; i < nnodes; i++) {
|
||||
for (j = i+1; j < nnodes; j++) {
|
||||
if (nodes[i].argc > nodes[j].argc) {
|
||||
Overloaded t = nodes[i];
|
||||
nodes[i] = nodes[j];
|
||||
nodes[j] = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Sort the declarations by argument types */
|
||||
{
|
||||
int i,j;
|
||||
for (i = 0; i < nnodes-1; i++) {
|
||||
if (nodes[i].argc == nodes[i+1].argc) {
|
||||
for (j = i+1; (j < nnodes) && (nodes[j].argc == nodes[i].argc); j++) {
|
||||
Parm *p1 = nodes[i].parms;
|
||||
Parm *p2 = nodes[j].parms;
|
||||
int differ = 0;
|
||||
int num_checked = 0;
|
||||
while (p1 && p2 && (num_checked < nodes[i].argc)) {
|
||||
if (debugMode) {
|
||||
Printf(stdout,"p1 = '%s', p2 = '%s'\n", Getattr(p1,"type"), Getattr(p2,"type"));
|
||||
}
|
||||
if (checkAttribute(p1,"tmap:in:numinputs","0")) {
|
||||
p1 = Getattr(p1,"tmap:in:next");
|
||||
continue;
|
||||
}
|
||||
if (checkAttribute(p2,"tmap:in:numinputs","0")) {
|
||||
p2 = Getattr(p2,"tmap:in:next");
|
||||
continue;
|
||||
}
|
||||
String *t1 = Getattr(p1,"tmap:typecheck:precedence");
|
||||
String *t2 = Getattr(p2,"tmap:typecheck:precedence");
|
||||
if (debugMode) {
|
||||
Printf(stdout,"t1 = '%s', t2 = '%s'\n", t1, t2);
|
||||
}
|
||||
if ((!t1) && (!nodes[i].error)) {
|
||||
Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"Overloaded method %s not supported (incomplete type checking rule - no precedence level in typecheck typemap for '%s').\n",
|
||||
Swig_name_decl(nodes[i].n), SwigType_str(Getattr(p1, "type"), 0));
|
||||
nodes[i].error = 1;
|
||||
} else if ((!t2) && (!nodes[j].error)) {
|
||||
Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s not supported (incomplete type checking rule - no precedence level in typecheck typemap for '%s').\n",
|
||||
Swig_name_decl(nodes[j].n), SwigType_str(Getattr(p2, "type"), 0));
|
||||
nodes[j].error = 1;
|
||||
}
|
||||
if (t1 && t2) {
|
||||
int t1v, t2v;
|
||||
t1v = atoi(Char(t1));
|
||||
t2v = atoi(Char(t2));
|
||||
differ = t1v-t2v;
|
||||
}
|
||||
else if (!t1 && t2) differ = 1;
|
||||
else if (t1 && !t2) differ = -1;
|
||||
else if (!t1 && !t2) differ = -1;
|
||||
num_checked++;
|
||||
if (differ > 0) {
|
||||
Overloaded t = nodes[i];
|
||||
nodes[i] = nodes[j];
|
||||
nodes[j] = t;
|
||||
break;
|
||||
} else if ((differ == 0) && (Strcmp(t1,"0") == 0)) {
|
||||
t1 = Getattr(p1,"ltype");
|
||||
if (!t1) {
|
||||
t1 = SwigType_ltype(Getattr(p1,"type"));
|
||||
if (Getattr(p1,"tmap:typecheck:SWIGTYPE")) {
|
||||
SwigType_add_pointer(t1);
|
||||
}
|
||||
Setattr(p1,"ltype",t1);
|
||||
}
|
||||
t2 = Getattr(p2,"ltype");
|
||||
if (!t2) {
|
||||
t2 = SwigType_ltype(Getattr(p2,"type"));
|
||||
if (Getattr(p2,"tmap:typecheck:SWIGTYPE")) {
|
||||
SwigType_add_pointer(t2);
|
||||
}
|
||||
Setattr(p2,"ltype",t2);
|
||||
}
|
||||
|
||||
/* Need subtype check here. If t2 is a subtype of t1, then we need to change the
|
||||
order */
|
||||
|
||||
if (SwigType_issubtype(t2,t1)) {
|
||||
Overloaded t = nodes[i];
|
||||
nodes[i] = nodes[j];
|
||||
nodes[j] = t;
|
||||
}
|
||||
|
||||
if (Strcmp(t1,t2) != 0) {
|
||||
differ = 1;
|
||||
break;
|
||||
}
|
||||
} else if (differ) {
|
||||
break;
|
||||
}
|
||||
if (Getattr(p1,"tmap:in:next")) {
|
||||
p1 = Getattr(p1,"tmap:in:next");
|
||||
} else {
|
||||
p1 = nextSibling(p1);
|
||||
}
|
||||
if (Getattr(p2,"tmap:in:next")) {
|
||||
p2 = Getattr(p2,"tmap:in:next");
|
||||
} else {
|
||||
p2 = nextSibling(p2);
|
||||
}
|
||||
}
|
||||
if (!differ) {
|
||||
/* See if declarations differ by const only */
|
||||
String *d1 = Getattr(nodes[i].n, "decl");
|
||||
String *d2 = Getattr(nodes[j].n, "decl");
|
||||
if (d1 && d2) {
|
||||
String *dq1 = Copy(d1);
|
||||
String *dq2 = Copy(d2);
|
||||
if (SwigType_isconst(d1)) {
|
||||
Delete(SwigType_pop(dq1));
|
||||
}
|
||||
if (SwigType_isconst(d2)) {
|
||||
Delete(SwigType_pop(dq2));
|
||||
}
|
||||
if (Strcmp(dq1, dq2) == 0) {
|
||||
|
||||
if (SwigType_isconst(d1) && !SwigType_isconst(d2)) {
|
||||
if (script_lang_wrapping) {
|
||||
// Swap nodes so that the const method gets ignored (shadowed by the non-const method)
|
||||
Overloaded t = nodes[i];
|
||||
nodes[i] = nodes[j];
|
||||
nodes[j] = t;
|
||||
}
|
||||
differ = 1;
|
||||
if (!nodes[j].error) {
|
||||
if (script_lang_wrapping) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
|
||||
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"using non-const method %s instead.\n", Swig_name_decl(nodes[i].n));
|
||||
} else {
|
||||
if (!Getattr(nodes[j].n, "overload:ignore")) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"using %s instead.\n", Swig_name_decl(nodes[i].n));
|
||||
}
|
||||
}
|
||||
}
|
||||
nodes[j].error = 1;
|
||||
} else if (!SwigType_isconst(d1) && SwigType_isconst(d2)) {
|
||||
differ = 1;
|
||||
if (!nodes[j].error) {
|
||||
if (script_lang_wrapping) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
|
||||
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"using non-const method %s instead.\n", Swig_name_decl(nodes[i].n));
|
||||
} else {
|
||||
if (!Getattr(nodes[j].n, "overload:ignore")) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"using %s instead.\n", Swig_name_decl(nodes[i].n));
|
||||
}
|
||||
}
|
||||
}
|
||||
nodes[j].error = 1;
|
||||
}
|
||||
}
|
||||
Delete(dq1);
|
||||
Delete(dq2);
|
||||
}
|
||||
}
|
||||
if (!differ) {
|
||||
if (!nodes[j].error) {
|
||||
if (script_lang_wrapping) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s effectively ignored,\n", Swig_name_decl(nodes[j].n));
|
||||
Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"as it is shadowed by %s.\n", Swig_name_decl(nodes[i].n));
|
||||
} else {
|
||||
if (!Getattr(nodes[j].n, "overload:ignore")) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"using %s instead.\n", Swig_name_decl(nodes[i].n));
|
||||
}
|
||||
}
|
||||
nodes[j].error = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
List *result = NewList();
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < nnodes; i++) {
|
||||
if (nodes[i].error)
|
||||
Setattr(nodes[i].n, "overload:ignore", "1");
|
||||
Append(result,nodes[i].n);
|
||||
// Printf(stdout,"[ %d ] %s\n", i, ParmList_errorstr(nodes[i].parms));
|
||||
// Swig_print_node(nodes[i].n);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void R::dispatchFunction(Node *n) {
|
||||
Wrapper *f = NewWrapper();
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
|
|
|
|||
|
|
@ -33,10 +33,7 @@ case "$SWIGLANG" in
|
|||
"javascript")
|
||||
case "$ENGINE" in
|
||||
"node")
|
||||
travis_retry sudo add-apt-repository -y ppa:chris-lea/node.js
|
||||
travis_retry sudo apt-get -qq update
|
||||
travis_retry sudo apt-get install -qq nodejs rlwrap
|
||||
travis_retry sudo npm install -g node-gyp
|
||||
travis_retry sudo apt-get install -qq nodejs node-gyp
|
||||
;;
|
||||
"jsc")
|
||||
travis_retry sudo apt-get install -qq libwebkitgtk-dev
|
||||
|
|
@ -88,7 +85,7 @@ case "$SWIGLANG" in
|
|||
travis_retry sudo apt-get -qq install php$VER-cli php$VER-dev
|
||||
;;
|
||||
"python")
|
||||
pip install pep8
|
||||
pip install --user pep8
|
||||
if [[ "$PY3" ]]; then
|
||||
travis_retry sudo apt-get install -qq python3-dev
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue