Skip to content

Commit

Permalink
Merge pull request #186 from swig-fortran/fix-master
Browse files Browse the repository at this point in the history
Merge upstream master
  • Loading branch information
sethrj authored Aug 18, 2023
2 parents f100a20 + f420043 commit 4b24b54
Show file tree
Hide file tree
Showing 111 changed files with 4,199 additions and 953 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ jobs:
# Stricter compile flags for examples. Various headers and SWIG generated code prevents full use of -pedantic.
cflags=$($GITHUB_WORKSPACE/Tools/testflags.py --language $SWIGLANG --cflags --std=$CSTD --compiler=$CC)
cxxflags=$($GITHUB_WORKSPACE/Tools/testflags.py --language $SWIGLANG --cxxflags --std=$CPPSTD --compiler=$CC)
if -n "$FC"; then fcflags=$($GITHUB_WORKSPACE/Tools/testflags.py --language $SWIGLANG --fcflags --std=$FCSTD --compiler=$FC); fi
if test -n "$FC"; then fcflags=$($GITHUB_WORKSPACE/Tools/testflags.py --language $SWIGLANG --fcflags --std=$FCSTD --compiler=$FC); fi
make check-$SWIGLANG-version
make check-$SWIGLANG-enabled
make $SWIGJOBS check-$SWIGLANG-examples CFLAGS="$cflags" CXXFLAGS="$cxxflags" FCFLAGS="$fcflags"
Expand Down
107 changes: 104 additions & 3 deletions CHANGES.current
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,107 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
Version 4.2.0 (in progress)
===========================

2023-08-09: olly
[Ruby] Remove -feature command line option which has been
deprecated since SWIG 1.3.32 in 2007. Use -init_name instead.

2023-08-06: wsfulton
Add support for using declarations to introduce templated member
methods and for inheriting templated constructors, such as:

struct Base {
// templated constructor
template <typename T> Base(const T &t, const char *s) {}
// templated member method
template <typename T> void template_method(const T &t, const char *s) {}
};

%template(Base) Base::Base<int>;
%template(template_method) Base::template_method<double>;

struct Derived : Base {
using Base::Base;
using Base::template_method;
};

Previously the templated methods and constructors were ignored and
not introduced into the Derived class.

2023-08-04: wsfulton
Fix using declarations for inheritance hierarchies more than
two deep and the using declarations are overloaded. Using declarations
from a base class' base were not available for use in the target
language. For example in the code below, Using1::usingmethod(int i)
was not wrapped for use in Using3:

struct Using1 {
protected:
void usingmethod(int i) {}
};
struct Using2 : Using1 {
protected:
void usingmethod(int i, int j) {}
using Using1::usingmethod;
};
struct Using3 : Using2 {
void usingmethod(int i, int j, int k) {}
using Using2::usingmethod;
};

Similarly for C++11 using declarations for inheriting constructors.

2023-08-02: wsfulton
https://sourceforge.net/p/swig/bugs/932/
Fix missing constructor generation due to abstract class test
failure when a method is declared in the class along with a
using declaration and the using declaration is declared before
the method that implemented the pure virtual method, such as:

struct ConcreteDerived : AbstractBase {
ConcreteDerived() {} // was not wrapped
using AbstractBase::f;
virtual void f(int n) override {}
};

2023-08-02: olly
[PHP] Implement overloading between different integer types and
between double and float.

2023-07-29: wsfulton
https://sourceforge.net/p/swig/bugs/678/
Fix %copyctor used on class hierarchies with non-const copy
constructors. Previously SWIG always attempted to call a copy
constructor taking a const reference parameter instead of a
non-const reference parameter.

2023-07-28: wsfulton
#2541 Fix overloading of templated constructors and %copyctor.

2023-07-21: wsfulton
Don't generate a default constructor wrapper when a class has a
templated constructor, as there isn't actually an implied default
constructor. For example:

struct TConstructor3 {
template<typename T> TConstructor3(T val) {}
};

Previously wrappers were generated for a non-existent default
constructor which failed to compile.

2023-07-15: wsfulton
C++11 using declarations for inheriting constructors has now been
extended to support the directors feature.

2023-07-13: wsfulton
C++11 using declarations for inheriting constructors support now
also includes inheriting implicitly defined default constructors
from the base class.

2023-07-04: wsfulton
#2641 Add support for C++11 using declarations for inheriting
constructors.

2023-06-30: wsfulton
#2640 Fix syntax error parsing an expression which calls a function
with no parameters within additional brackets.
Expand Down Expand Up @@ -34,9 +135,9 @@ Version 4.2.0 (in progress)
shadowclassmodifiers Use %typemap(javaclassmodifiers)

2023-06-24: wsfulton
#2616 Fix directors and allprotected mode and using declarations.
Previously SWIG either seg faulted or generated code that did not
compile.
#2616 https://sourceforge.net/p/swig/bugs/1102/ Fix directors and
allprotected mode and using declarations. Previously SWIG either
seg faulted or generated code that did not compile.

2023-06-20: olly
#2486 Fix handling of template in array size, which was being
Expand Down
16 changes: 8 additions & 8 deletions Doc/Manual/CPlusPlus11.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ <H2><a name="CPlusPlus11_introduction">7.1 Introduction</a></H2>


<p>This chapter gives you a brief overview about the SWIG
implementation of the C++11 standard. This part of SWIG is still a work in
progress.
implementation of the C++11 standard.
</p>
<p>SWIG supports the new C++ syntax changes with some minor limitations
in some areas such as decltype expressions and variadic templates. Wrappers for the
Expand Down Expand Up @@ -863,12 +862,9 @@ <H3><a name="CPlusPlus11_object_construction_improvement">7.2.10 Object construc

<p>
The second improvement is constructor inheritance via a <tt>using</tt> declaration.
This is parsed correctly, but the additional constructors are not currently added to the derived proxy class in the target language.
An example is shown below:
<!--
The extra constructors provided by the <tt>using</tt> syntax will add the appropriate constructors into the target language proxy derived classes.
In the example below a wrapper for the <tt>DerivedClass(int)</tt> is added to <tt>DerivedClass</tt>:
-->
The extra constructors provided by the <tt>using</tt> declaration will add the appropriate constructors into the target language proxy derived classes.
In the example below a wrapper for the <tt>DerivedClass(int)</tt> constructor is added to <tt>DerivedClass</tt>:

</p>

<div class="code"><pre>
Expand All @@ -883,6 +879,10 @@ <H3><a name="CPlusPlus11_object_construction_improvement">7.2.10 Object construc
};
</pre></div>

<p>
<b>Compatibility note:</b> SWIG-4.2.0 was the first version to generate wrappers for constructors inherited via <tt>using</tt> declarations.
</p>

<p>
The final part is member initialization at the site of the declaration.
This kind of initialization is handled by SWIG.
Expand Down
1 change: 1 addition & 0 deletions Doc/Manual/Python.html
Original file line number Diff line number Diff line change
Expand Up @@ -3568,6 +3568,7 @@ <H3><a name="Python_nn42">34.6.2 Adding additional Python code</a></H3>

<p> where <tt>$action</tt> will be replaced by the call to
the C/C++ proper method.
Note that this does not include the arguments to the C/C++ method.
</p>

<p>
Expand Down
3 changes: 2 additions & 1 deletion Doc/Manual/SWIG.html
Original file line number Diff line number Diff line change
Expand Up @@ -2527,8 +2527,9 @@ <H2><a name="SWIG_nn31">5.5 Structures and unions</a></H2>
</p>

<div class="code"><pre>
foo.i:5: Warning 302: Identifier 'Foo' redefined (ignored),
foo.i:5: Warning 302: Redefinition of identifier 'Foo' as Foo(void) ignored,
foo.i:1: Warning 302: previous definition of 'Foo'.

</pre></div>

<p>
Expand Down
5 changes: 5 additions & 0 deletions Doc/Manual/SWIGPlus.html
Original file line number Diff line number Diff line change
Expand Up @@ -5347,6 +5347,11 @@ <H2><a name="SWIGPlus_nn35">6.26 Using declarations and inheritance</a></H2>
</pre>
</div>

<p>
The C++11 standard supports using declarations for inheriting constructors and this is covered in
<a href="CPlusPlus11_object_construction_improvement">Object construction improvement</a>.
</p>

<p>
C++ <tt>using</tt> declarations can also be used to change access when applicable.
For example, protected methods in a base class can be made public in a derived class:
Expand Down
4 changes: 2 additions & 2 deletions Doc/Manual/Warnings.html
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ <H3><a name="Warnings_nn12">19.9.3 C/C++ Parser (300-399)</a></H3>

<ul>
<li>301. <tt>class</tt> keyword used, but not in C++ mode.
<li>302. Identifier '<em>name</em>' redefined (ignored).
<li>302. Redefinition of identifier '<em>name</em>' as <em>decl</em> ignored.
<li>303. <tt>%extend</tt> defined for an undeclared class '<em>name</em>'.
<li>305. Bad constant value (ignored).
<li>306. '<em>identifier</em>' is private in this context.
Expand All @@ -409,7 +409,7 @@ <H3><a name="Warnings_nn12">19.9.3 C/C++ Parser (300-399)</a></H3>
<li>319. No access specifier given for base class <em>name</em> (ignored).
<li>320. Explicit template instantiation ignored.
<li>321. <em>identifier</em> conflicts with a built-in name.
<li>322. Redundant redeclaration of '<em>name</em>'.
<li>322. Redundant redeclaration of identifier '<em>name</em>' as <em>decl</em> ignored.
<li>323. Recursive scope inheritance of '<em>name</em>'.
<li>324. Named nested template instantiations not supported. Processing as if no name was given to %template().
<li>325. Nested <em>kind</em> not currently supported (<em>name</em> ignored).
Expand Down
1 change: 0 additions & 1 deletion Examples/fortran/templated/runme.f90
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ program main
use ISO_FORTRAN_ENV
implicit none

integer, parameter :: STDOUT = OUTPUT_UNIT
type(Thing_Int) :: it
type(Thing_Dbl) :: dt

Expand Down
31 changes: 31 additions & 0 deletions Examples/test-suite/abstract_inherit_using.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
%module abstract_inherit_using

%inline %{
class AbstractBase
{
public:
virtual void f(int n) = 0;
void f(const char *another_representation_of_n) {}
virtual ~AbstractBase() {}
};

class ConcreteDerived1 : public AbstractBase
{
public:
ConcreteDerived1() {}

// Abstract test always worked
virtual void f(int n) {}
using AbstractBase::f;
};

class ConcreteDerived2 : public AbstractBase
{
public:
ConcreteDerived2() {}

// SWIG thought this class was abstract when using declaration was before method f and didn't generate constructor
using AbstractBase::f;
virtual void f(int n) {}
};
%}
2 changes: 0 additions & 2 deletions Examples/test-suite/access_change.i
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,3 @@ public:
%template(BaseInt) Base<int>;
%template(DerivedInt) Derived<int>;
%template(BottomInt) Bottom<int>;


8 changes: 7 additions & 1 deletion Examples/test-suite/bools.i
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
%rename(BoolSt) BoolStructure;
#endif

/* We had to rename this in the C++ API being wrapped due to a collision with
* a value typedef in newer ocaml headers, so use %rename to avoid having to
* update all the runme files which use it.
*/
%rename(value) bool_value;

%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK); /* memory leak when setting a ptr/ref variable */
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) constbool; /* Ruby, wrong class name */

Expand Down Expand Up @@ -44,7 +50,7 @@ const bool* const_pbo(const bool* b) {
}

// helper function
bool value(bool* b) {
bool bool_value(bool* b) {
return *b;
}

Expand Down
7 changes: 7 additions & 0 deletions Examples/test-suite/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ CPP_TEST_CASES += \
constant_pointers \
constover \
constructor_copy \
constructor_copy_non_const \
constructor_exception \
constructor_explicit \
constructor_ignore \
Expand All @@ -160,6 +161,7 @@ CPP_TEST_CASES += \
conversion_namespace \
conversion_ns_template \
conversion_operators \
copyctor \
cplusplus_throw \
cpp_basic \
cpp_enum \
Expand Down Expand Up @@ -473,6 +475,7 @@ CPP_TEST_CASES += \
template_namespace_forward_declaration \
template_using_directive_and_declaration_forward \
template_using_directive_typedef \
template_using_member_default_arg \
template_nested \
template_nested_flat \
template_nested_typemaps \
Expand All @@ -496,6 +499,7 @@ CPP_TEST_CASES += \
template_specialization \
template_specialization_defarg \
template_specialization_enum \
template_specialization_using_declaration \
template_static \
template_tbase_template \
template_template_parameters \
Expand Down Expand Up @@ -564,6 +568,7 @@ CPP_TEST_CASES += \
using_extend \
using_inherit \
using_member \
using_member_multiple_inherit \
using_member_scopes \
using_namespace \
using_namespace_loop \
Expand Down Expand Up @@ -598,6 +603,7 @@ CPP11_TEST_CASES += \
cpp11_default_delete \
cpp11_delegating_constructors \
cpp11_director_enums \
cpp11_director_using_constructor \
cpp11_directors \
cpp11_explicit_conversion_operators \
cpp11_final_class \
Expand Down Expand Up @@ -637,6 +643,7 @@ CPP11_TEST_CASES += \
cpp11_uniform_initialization \
cpp11_unrestricted_unions \
cpp11_userdefined_literals \
cpp11_using_constructor \
cpp11_using_typedef_struct \
cpp11_variadic_function_templates \
cpp11_variadic_templates \
Expand Down
Loading

0 comments on commit 4b24b54

Please sign in to comment.