Commit Graph

156 Commits

Author SHA1 Message Date
Olly Betts a268c71607 Remove remains of %nestedworkaround
Also the nestedworkaround feature it uses - both were deprecated over 10
years ago in SWIG 3.0.0.  Since then uses of these have done nothing
except emit a warning.
2024-09-12 14:41:24 +12:00
William S Fulton 42890f4388 Enhance docs with non-assignable C++ classes and member variables 2024-08-02 19:06:31 +01:00
William S Fulton a0b792eea4 Enhance documentation for MSVC and setting __cplusplus
Help/recommend users to correctly set the __cplusplus macro in order to
benefit from modern standards based features that SWIG provides.

Closes #2860
2024-07-03 19:29:56 +01:00
William S Fulton 71e639bd13 Add docs for %nspacemove 2024-06-01 13:41:51 +01:00
Olly Betts a1cafe585d Fix Python examples in manual to use print(...)
Python 3 dropped support for `print` without parentheses.  The
amended examples should still work in Python 2.
2024-03-20 16:19:17 +13:00
William S Fulton dcc1471dd3 Add missing use of move constructor
instead of copy constructor when passing movable types. This was
previously implemented only for parameters passed to a global function
or static member function and is now extended to member methods.

Enhancement to e777b054d5.
2024-03-06 21:46:58 +00:00
Olly Betts e49db2e461 Update output to match what SWIG actually gives 2024-01-31 10:31:24 +13:00
Olly Betts 98aace6f03 Fix manual grammar 2024-01-29 16:20:26 +13:00
William S Fulton 158fbdc760 Improve friend function documentation
Add unqualified friend example in docs as a testcase
2024-01-15 18:52:05 +00:00
William S Fulton 605a768497 Minor tweaks and docs for the cs:defaultargs feature 2023-12-20 19:45:27 +00:00
Chris Hilton 867b2396f4 feature("cs:defaultargs") review changes
Expanding test cases, which found a bug with static methods and global
functions (they needed their own special handling).

Fixing code to match swig style rules and some other code quality.

And documentation fixes.
2023-12-01 10:17:24 -06:00
Chris Hilton b6409b584f feature("cs:defaultargs")
We need a way to specify default arguments for functions.  Sometimes
we can just take the arguments straight from c++ literals.  Sometimes
you can't, and need to specify those by hand.

So to make this work we:

 1. Shutoff handling all "defaultargs" variants of methods and constructors
    which have cs:defaultargs defined for their node.  This gets us a single
    constructor or method and skips the variants.
 2. As we emit arguments in the function declaration, check if there is a
    definition for it it from cs:defaultargs, if so, use that.  If not,
    and the method has a cs:defaultargs declaration, then fall back to the
    literal expression from c++.
2023-11-30 13:09:18 -06:00
William S Fulton 61e60271fe Add support for C++11 using declarations for inheriting constructors
Closes #2641
2023-07-04 12:07:16 +01:00
Olly Betts af7099432c Remove deprecated -make_default, -no_default, etc 2023-06-15 15:06:04 +12:00
Olly Betts 736c052d7d Remove long deprecated features
These features were all deprecated in 1.3.26 (October 9, 2005)
or before (many long before), so all more than 17 years and 3 new major
versions ago which seems more than enough time for users to have stopped
using them, especially as most emit a deprecation warning if used.
2023-06-15 15:05:15 +12:00
William S Fulton 5a8d58c3a7 Merge branch 'rtests2'
* rtests2:
  more r tests
  more r tests
  added testcase pointer_reference
  [PHP] Update docs for removal of -noproxy in SWIG 4.1.0

Conflicts:
	CHANGES.current
2022-11-23 21:12:07 +00:00
William S Fulton 4729cf2b1f Duplicate class template instantiations via %template changes
Named duplicate class template instantiations now issue a warning and are ignored.
Duplicate empty class template instantiations are quietly ignored.

The test cases are fixed for this new behaviour.

This commit is a pre-requisite for the near future so that the Python
builtin wrappers can correctly use the SwigType_namestr function without
generating duplicate symbol names.
2022-11-18 19:35:47 +00:00
Olly Betts f1f77c218f [PHP] Update docs for removal of -noproxy in SWIG 4.1.0
Closes #2419
2022-11-13 15:23:42 +13:00
Olly Betts 631b41ae7b Use https for swig.org links 2022-10-06 13:16:39 +13:00
William S Fulton bf36bf7d8a Movable and move-only types supported in "out" typemaps.
Enhance SWIGTYPE "out" typemaps to use std::move when copying
objects, thereby making use of move semantics when wrapping a function returning
by value if the returned type supports move semantics.

Wrapping functions that return move only types 'by value' now work out the box
without having to provide custom typemaps.

The implementation removed all casts in the "out" typemaps to allow the compiler to
appropriately choose calling a move constructor, where possible, otherwise a copy
constructor. The implementation alsoand required modifying SwigValueWrapper to
change a cast operator from:

  SwigValueWrapper::operator T&() const;

to

  #if __cplusplus >=201103L
    SwigValueWrapper::operator T&&() const;
  #else
    SwigValueWrapper::operator T&() const;
  #endif

This is not backwards compatible for C++11 and later when using the valuewrapper feature
if a cast is explicitly being made in user supplied "out" typemaps. Suggested change
in custom "out" typemaps for C++11 and later code:

1. Try remove the cast altogether to let the compiler use an appropriate implicit cast.
2. Change the cast, for example, from static_cast<X &> to static_cast<X &&>, using the
   __cplusplus macro if all versions of C++ need to be supported.

Issue #999
Closes #1044

More about the commit:
Added some missing "varout" typemaps for Ocaml which was falling back to
use "out" typemaps as they were missing.

Ruby std::set fix for SwigValueWrapper C++11 changes.
2022-06-30 17:26:48 +01:00
Olly Betts 8f54f6180a Update docs for expression parsing improvements 2022-03-04 16:36:04 +13:00
William S Fulton 5682d940e5 HTML fixes 2022-03-02 19:42:44 +00:00
William S Fulton 79a1bbee8b Using declarations in inheritance hierarchy improvements.
- Improved documentation for using declarations.
- Issue new warning WARN_LANG_USING_NAME_DIFFERENT when there
  is a conflict in the target language name to be used when
  introducing a method via a using declaration. Previously
  the method was silently ignored. Issue #1840. Issue #655.
2022-02-26 12:46:06 +00:00
William S Fulton fa8c89ddf5 Move docs on replacing c++ class methods to C++ section
[skip ci]
2022-01-27 21:25:35 +00:00
Olly Betts a2fc5ecaff Fix "dobule" typos in docs
Fixes #2043.
2021-07-06 10:56:48 +12:00
William S Fulton b7bcb338cf Add C++20 documentation chapter 2020-06-08 20:56:40 +01:00
William S Fulton 7070320335 Revert "Add C++20 documentation chapter"
This reverts commit 36e8d521de.

Conflicts:
	Doc/Manual/R.html
2020-06-08 20:06:55 +01:00
William S Fulton 36e8d521de Add C++20 documentation chapter
[skip-ci]
2020-01-28 20:31:53 +00:00
William S Fulton 12a245183f Clear up some confusion over ANSI vs ISO C/C++ support
Issue #890
2019-04-18 20:04:20 +01:00
William S Fulton 6791f8b769 Add linkchecker3 make target to check internal links
Make sure all internal links use # anchors which are needed for wkhtmltopdf
2019-04-15 19:31:32 +01:00
Zackery Spytz b7a400f991 [OCaml] Add a typecheck typemap for SWIGTYPE
This fixes many of the remaining warnings in the OCaml test suite.

Add multiple runtime tests.
2019-02-16 01:07:31 -07:00
William S Fulton a5b301ba83 Add a documentation chapter on C++14 2019-02-11 18:59:46 +00:00
William S Fulton c33f352069 python -> Python in html docs 2018-08-21 22:41:02 +01:00
William S Fulton 066c396ad6 Add C++17 documentation chapter 2018-05-14 21:29:46 +01:00
William S Fulton 449ba627f5 Typo fix in SWIGPlus.html docs 2018-02-07 23:07:22 +00:00
William S Fulton 34712c0108 Improve Java director exception customization documentation 2017-11-29 20:32:15 +00:00
William S Fulton e67f9c5067 Enhance documentation with callback techniques
Add section about callbacks from C/C++ to target language via directors

[skip ci]
2017-11-01 07:47:54 +00:00
William S Fulton ace15d5cf7 C++ docs minor update 2017-10-27 17:58:59 +01:00
William S Fulton 9cc05a22f6 Improve docs for %rename and C++ features like default args 2017-09-14 18:51:36 +01:00
William S Fulton d5d97a4069 Overloaded methods section renamed slightly in docs 2017-09-14 18:51:36 +01:00
William S Fulton ff52610dc5 Move C++ 'Default arguments' section in manual 2017-09-14 18:51:36 +01:00
William S Fulton 330ef362f4 Add docs for C++11 ref-qualifiers 2017-08-30 18:17:04 +01:00
William S Fulton 32a454cfef Merge branch 'templates-scope-enforcement'
* templates-scope-enforcement:
  Test a few %template errors
  Add using declarations to templates into typedef table.
  Fix type lookup in the presence of using directives and using declarations
  More docs on %template
  Testcase fix for nameclash in php
  %template scope enforcement and class definition fixes
  Template documentation tweaks
  More consistent formatting of examples in documentation
  More consistent formatting of examples in documentation
  Documentation corrections to use targetlang formatting
  More consistent formatting of examples in documentation
  More consistent formatting of examples in documentation
  More consistent formatting of examples in documentation
  Namespace documentation minor corrections
  Improve description of template_parameters_resolve
  Minor code optimisation in template_parameters_resolve
  Fix scope lookup for template parameters containing unary scope operators
  Typemap change for templates
2017-08-16 21:44:51 +01:00
William S Fulton 8bf81b8718 More docs on %template 2017-08-16 00:24:25 +01:00
William S Fulton 959e627208 %template scope enforcement and class definition fixes
The scoping rules around %template have been specified and enforced.
The %template directive for a class template is the equivalent to an
explicit instantiation of a C++ class template. The scope for a valid
%template instantiation is now the same as the scope required for a
valid explicit instantiation of a C++ template. A definition of the
template for the explicit instantiation must be in scope where the
instantiation is declared and must not be enclosed within a different
namespace.

For example, a few %template and explicit instantiations of std::vector
are shown below:

  // valid
  namespace std {
    %template(vin) vector<int>;
    template class vector<int>;
  }

  // valid
  using namespace std;
  %template(vin) vector<int>;
  template class vector<int>;

  // valid
  using std::vector;
  %template(vin) vector<int>;
  template class vector<int>;

  // ill-formed
  namespace unrelated {
    using std::vector;
    %template(vin) vector<int>;
    template class vector<int>;
  }

  // ill-formed
  namespace unrelated {
    using namespace std;
    %template(vin) vector<int>;
    template class vector<int>;
  }

  // ill-formed
  namespace unrelated {
    namespace std {
      %template(vin) vector<int>;
      template class vector<int>;
    }
  }

  // ill-formed
  namespace unrelated {
    %template(vin) std::vector<int>;
    template class std::vector<int>;
  }

When the scope is incorrect, an error now occurs such as:

cpp_template_scope.i:34: Error: 'vector' resolves to 'std::vector' and
was incorrectly instantiated in scope 'unrelated' instead of within scope 'std'.

Previously SWIG accepted the ill-formed examples above but this led to
numerous subtle template scope problems especially in the presence of
using declarations and using directives as well as with %feature and %typemap.

Actually, a valid instantiation is one which conforms to the C++03
standard as C++11 made a change to disallow using declarations and
using directives to find a template.

  // valid C++03, ill-formed C++11
  using std::vector;
  template class vector<int>;

Similar fixes for defining classes using forward class references have
also been put in place. For example:

namespace Space1 {
  struct A;
}
namespace Space2 {
  struct Space1::A {
    void x();
  }
}

will now error out with:

cpp_class_definition.i:5: Error: 'Space1::A' resolves to 'Space1::A' and
was incorrectly instantiated in scope 'Space2' instead of within scope 'Space1'.
2017-08-16 00:24:25 +01:00
William S Fulton 97ae9d66bc Template documentation tweaks
Add subsections to the template documentation
Rewrite some of the template introduction
2017-08-16 00:24:25 +01:00
William S Fulton 5779aa8d79 More consistent formatting of examples in documentation 2017-08-16 00:24:25 +01:00
William S Fulton 04131a988f More consistent formatting of examples in documentation 2017-08-16 00:24:25 +01:00
William S Fulton ba45861b46 More consistent formatting of examples in documentation 2017-08-16 00:24:25 +01:00
William S Fulton 8052211ac5 More consistent formatting of examples in documentation 2017-08-16 00:24:25 +01:00