Commit graph

138 commits

Author SHA1 Message Date
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
William S Fulton
7ee76f93f9 More consistent formatting of examples in documentation 2017-08-16 00:24:25 +01:00
William S Fulton
8753f9652c Namespace documentation minor corrections 2017-08-16 00:24:24 +01:00
Olly Betts
90f9117e10 Fix various comment and documentation typos 2017-08-13 18:04:33 +12:00
William S Fulton
b538070016 Enhance %extend to extend a class with template methods 2017-01-22 10:36:46 +00:00
sunoru
8985c34809 Fix some typos in docs and examples and make the code look nicer. 2016-12-31 23:06:56 +08:00
William S Fulton
6310cdb28a html fix
[skip ci]
2016-11-03 19:26:38 +00:00
William S Fulton
0886fc6fe6 Edit operator[] additions 2016-10-30 14:52:35 +00:00
g
61061ff150 Added description of the operator[] caveats 2016-10-26 23:55:04 -07:00
William S Fulton
268b942865 Consistent formatting of example code in the docs 2016-10-23 20:16:35 +01:00
William S Fulton
3763beb489 Replace tabs with spaces in html docs
wkhtmltopdf is not expanding tabs within <pre> elements to 8 spaces as it
should. Workaround the problem by converting all tabs to an appropriate
number of spaces.
2015-12-30 22:22:33 +00:00
William S Fulton
4e67d5c7a8 Minor html fixes 2015-12-30 22:22:33 +00:00
William S Fulton
925b2a336f HTML fixes for documentation - add meta tag and loose.dtd 2015-12-30 22:22:32 +00:00
William S Fulton
8288ac15a0 Correct links in html documentation using new version of makechap.py
Corrects position of heading text within A and H1, H2, ... elements.
2015-12-30 22:22:32 +00:00
William S Fulton
55e7264d43 Clearer warning message for badly constructed typecheck typemaps 2015-04-14 07:34:40 +01:00
William S Fulton
f25f5cf635 Nested class template doc tweaks 2015-01-16 19:08:41 +00:00
Michael Schaller
007a75480a Updated C++ template documentation with respect to using a nested class as template parameter.
Fixes issue swig/swig#270.
2015-01-05 16:43:49 +01:00
Olly Betts
f541e604e8 Consistently put whitespace outside of <tt>...</tt> and not inside 2014-11-18 12:44:37 +13:00
Olly Betts
e047d2e2bd Remove bogus ; after } in documentation 2014-11-07 15:34:43 +13:00