Commit graph

1,423 commits

Author SHA1 Message Date
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
c454f2ce2f Documentation corrections to use targetlang formatting 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
Olly Betts
a92137a708 [C++11] Allow static_assert at the top level
And disallow it right after template<T>).

Fixes https://github.com/swig/swig/issues/1031 reported by Artem V L.
2017-08-04 14:09:30 +12:00
William S Fulton
687cf9c9c1 Add missing %python:maybecall to operator overloads.
This ensures NotImplemented is returned on error so that the Python
interpreter will handle the operators correctly instead of throwing an
exception. NotImplemented was not being returned for non-builtin wrappers
when the operator overload did not have a function overload.

See PEP 207 and https://docs.python.org/3/library/constants.html#NotImplemented

Mentioned in SF patch #303 and SF bug #1208.
2017-06-19 19:25:27 +01:00
William S Fulton
10e73a5bfb Java jboxtype typemap documentation and tidy up 2017-06-05 20:47:49 +01:00
William S Fulton
57a89f987d Fix %import and %fragment forced inclusion to not generate code. 2017-06-03 18:37:05 +01:00
William S Fulton
857a62425c Formatting fixes in Lisp docs 2017-06-03 18:37:05 +01:00
William S Fulton
10172161bf Update STL library documentation 2017-05-20 15:38:38 +01:00
Olly Betts
9a0180c56c Merge pull request #970 from nihal95/master
Adds pragma version directive for php5 and php7.  Fixes #360.
2017-05-16 17:47:35 +12:00
William S Fulton
07ab80b49e Add raise methods for throwing c++ exceptions in C#, Java, D
The director c++ exceptions are thrown in a helper method instead of in
the director overloaded method. This circumvents compiler warnings about
throwing exceptions when the method has an exception specification or
noexcept. If the exception is thrown, abort will still be called!
In Java, the "director:noexcept" typemap can be used to do something
else. This typemap should be ported to the other languages too.
2017-05-13 17:01:15 +01:00
Nihal
21108781a7 Add documentation and examples for php version pragma.
Pragma version to specify versions for PHP5 and PHP7 extensions.
See issue #360.
2017-05-08 12:02:53 +05:30
William S Fulton
28f7d61986 Bump version to 4.0.0 2017-04-21 19:36:09 +01:00
Simon Marchetto
c06c9b3853 [Scilab] New parameter targetversion to specify the Scilab target version (5, 6, ..) for code generation
With Scilab 6 target specified, identifier names truncation is disabled (no longer necessary)

Signed-off-by: Simon Marchetto <simon.marchetto@scilab-enterprises.com>
2017-04-12 13:54:42 +02:00
Julien Schueller
7350e9fffa Typo in Python.html 2017-03-24 14:22:53 +01:00
William S Fulton
f0f2fd2dae Merge branch 'tleonhardt-python_threads'
* tleonhardt-python_threads:
  Style fixes for Python threads documentation changes
  Finished updating Python docs for -threads option
  Started making changes to Python.html to document support for multithreaded Python SWIG applications.
2017-03-24 08:22:51 +00:00
William S Fulton
d888fabc0c Style fixes for Python threads documentation changes 2017-03-24 08:22:16 +00:00
スノル
970b0fdca3 Add the missing parenthese.
I'm sorry that I didn't notice this last time.
2017-03-20 20:47:08 -05:00
William S Fulton
da381668a2 Python doc correction for %pybuffer_mutable_string usage
[skip ci]
2017-03-17 19:02:38 +00:00
Todd Leonhardt
bcf8d927f0 Finished updating Python docs for -threads option 2017-03-01 17:51:47 -05:00
Olly Betts
b451fc464b Escape literal > in HTML 2017-03-02 08:45:45 +13:00
Todd Leonhardt
52d12bc415 Started making changes to Python.html to document support for multithreaded Python SWIG applications. 2017-02-28 20:53:30 -05:00
William S Fulton
d6a349997c C++11 hash tables documentation 2017-02-10 19:49:58 +00:00
William S Fulton
2ab08e493f Bump version to 3.0.13
[skip ci]
2017-01-28 00:23:59 +00:00
William S Fulton
ac916b006a Add 3.0.12 release notes and date
[skip ci]
2017-01-26 19:24:40 +00:00
William S Fulton
b538070016 Enhance %extend to extend a class with template methods 2017-01-22 10:36:46 +00:00
Karl Wette
e24ec40895 Octave: add support for version 4.2
- .travis.yml:
  - ppa:kwwette/octaves has Octave version 4.2, also run C++11 tests
- configure.ac:
  - prefer Octave program "octave-cli" to "octave"
  - extract any -std=* flags from CXX, add to OCTAVE_CXXFLAGS
- Lib/typemaps/fragments.swg:
  - SWIG_isfinite_func(): extern "C++" is required as this fragment can
    end up inside an extern "C" { } block
- Lib/octave:
  - add std_wstring.i (copied from std_string.i) for C++11 tests
- Lib/octave/octrun.swg:
  - move Octave version-checking macros to octruntime.swg
  - Octave single()/double() functions now call .as_single()/.as_double()
    methods; redirect calls to __float__() method as per .scalar_value()
  - << and >> operators are no longer supported by Octave
- Lib/octave/octruntime.swg:
  - move Octave version-checking macros here for conditional #includes
  - #include interpreter.h instead of #toplev.h
  - #include call-stack.h (now needed for octave_call_stack)
  - unwind_protect is now in octave:: namespace
  - error_state and warning_state are deprecated; use try/catch to catch
    errors in feval() instead
  - always set octave_exit = ::_Exit, to try to prevent segfault on exit
- Lib/octave/octopers.swg:
  - << and >> operators are no longer supported by Octave
- Lib/octave/exception.i:
  - Add macro SWIG_RETHROW_OCTAVE_EXCEPTIONS which rethrows any
    exceptions raised by Octave >= 4.2
- Examples/test-suite/exception_order.i:
  - Use macro SWIG_RETHROW_OCTAVE_EXCEPTIONS to rethrow exceptions
    raised by error() function in Octave >= 4.2
- Update Doc/Manual/Octave.html and CHANGES.current
2017-01-22 11:53:12 +13:00
Karl Wette
52455b81d2 Octave: move Travis build over to trusty
- trusty has Octave version 3.8
- ppa:kwwette/octaves has Octave version 4.0
- Update Doc/Manual/Octave.html
2017-01-22 11:53:12 +13:00
William S Fulton
c238036448 Ruby doc tweak
[skip ci]
2017-01-20 19:53:47 +00:00
William S Fulton
9503f2ebe8 Fix typo in ruby docs 2017-01-20 19:16:51 +00:00
Vadim Zeitlin
93c1d531f5 Improve advice for finding the Ruby headers include directories
Don't advise using "$:", which is for Ruby models, and doesn't include/map to
the directories containing the headers. Advise using rbconfig module instead.

The new instructions are known to work out of the box both under Linux and
macOS.

[skip ci]
2017-01-20 18:21:31 +01:00
William S Fulton
6ec243c093 Fix Java directorin typemap example 2017-01-17 19:27:16 +00:00
William S Fulton
19f21d1dd5 Reference %proxycode from javacode typemap section in docs 2017-01-13 20:52:33 +00:00
William S Fulton
3d2e57b0f2 Add %proxycode directive for adding code into proxy classes for C#, D and Java 2017-01-13 20:43:50 +00:00
William S Fulton
88e2d02ead Document %insert filename and add test for it 2017-01-13 20:43:50 +00:00
William S Fulton
92d694225a Update wiki links to new Github wiki site
[skip ci]
2017-01-05 18:39:57 +00:00
William S Fulton
caed1110fb Remove redundant cpp11.html file
This was superceded by Doc/Manual/CPlusPlus11.html
2017-01-05 07:37:40 +00:00
William S Fulton
5b49ad3485 Correct some whitespace changes 2017-01-01 14:28:49 +00:00
sunoru
9a6f82ab31 Realign for some comments. 2016-12-31 23:29:45 +08:00
sunoru
8985c34809 Fix some typos in docs and examples and make the code look nicer. 2016-12-31 23:06:56 +08:00