Commit graph

752 commits

Author SHA1 Message Date
Olly Betts
2ab3f4d744 [Python] Suppress new pycodestyle warning
E252 missing whitespace around parameter equals
2018-04-19 08:41:25 +12:00
William S Fulton
6607acdf3a Merge branch 'davedissian-redundant-typedef-fix'
* davedissian-redundant-typedef-fix:
  Add more runtime typedef_classforward_same_name runtime testing
  Fixed 'typedef class Foo Foo;' edge case by iterating through linked list.
  Added test case for a forward declaration in a typedef with the same name
2018-01-06 15:27:52 +00:00
William S Fulton
cd9b7c3c34 std_basic_string.i fixes
- Remove python code from octave's std_basic_string.i
- Correctly return an error to fix error handling when using std::basic_string in
  overloaded methods - issue #1171.
2018-01-04 07:00:26 +00:00
William S Fulton
ce6960de92 Add more runtime typedef_classforward_same_name runtime testing 2017-12-31 16:37:27 +00:00
William S Fulton
aff36823df Complete switch from pep8 to pycodestyle for Python testing 2017-12-31 16:19:39 +00:00
William S Fulton
b0e29fbdf3 Add missing checks for failures in calls to PyUnicode_AsUTF8String.
Previously a seg fault could occur when passing invalid UTF8 strings (low
surrogates), eg passing u"\udcff" to the C layer (Python 3).
2017-12-04 20:14:04 +00:00
William S Fulton
d0615d98a9 Merge branch 'radarsat1-fix-null-shared_ptr-directors'
* radarsat1-fix-null-shared_ptr-directors:
  Remove duplicate director shared_ptr pointer reference typemaps
  For shared_ptr directorin, make copy of shared_ptr in all cases.
  Add directorin typemap for Python and Ruby shared_ptr.
2017-10-11 09:03:01 +01:00
William S Fulton
dcf8730cf3 Avoid can of worms testing minimum signed int value
Specifying the minimum 32 bit signed int value is not easily portable.
Remove min_32bit_int2 method, min_32bit_int1 provides runtime coverage.

g++ 32bit resulted in:
warning: this decimal constant is unsigned only in ISO C90

and some versions of clang++ resulted in:
error: integer literal is too large to be represented in type 'long' and is subject to undefined behavior under C++98, interpreting as 'unsigned long'; this literal will have type 'long long' in C++11 onwards [-Werror,-Wc++11-compat]
2017-10-07 15:04:19 +01:00
William S Fulton
4a7976a5d8 Fix platorm inconsistency in Python default argument handling.
32 bit and 64 bit compiled versions of SWIG generated different Python files
when default arguments were outside the range of 32 bit signed integers.
The default arguments specified in Python are now only those that are in the
range of a 32 bit signed integer, otherwise the default is obtained from C/C++ code.

Closes #1108
2017-10-06 21:57:04 +01:00
William S Fulton
f4644d7c30 Run overload_complicated testcase
Was marked as broken, seems to work now
2017-10-04 20:43:44 +01:00
William S Fulton
7c1b60f340 Run python_threads testcase
Should have been added in f4a2470325
2017-10-04 08:05:14 +01:00
William S Fulton
a55981b883 Fix C# std::complex pass by value typemaps 2017-10-02 19:07:24 +01:00
William S Fulton
e01cfd70c7 Add missing declaration for std::complex
Fixes missing type information for std::complex in scripting languages.
Closes #732.

Update Javascript and Octave complextest, although they don't actually
get run as they don't work
2017-10-02 19:07:24 +01:00
William S Fulton
e27a606335 Allow an instantiated template to have the same name as the C++ template name
For example, this is now possible:
  template<typename T> struct X { ... };
  %template(X) X<int>;
Closes #1100.
2017-09-29 23:28:04 +01:00
Stephen Sinclair
bda750ee15 Add directorin typemap for Python and Ruby shared_ptr. 2017-09-27 11:22:30 -03:00
William S Fulton
ed4b84f4d3 Fix overloading of shared_ptr method overloading
Add 'equivalent' attribute to typecheck typemap.
Closes #1098.
2017-09-23 15:19:34 +01:00
William S Fulton
f5e1856650 Expand std::shared_ptr testing to C# D Java Python 2017-09-22 20:03:47 +01:00
William S Fulton
b3cca589ca Fixup recent python 2to3 changes 2017-09-20 12:59:05 +01:00
William S Fulton
057e1e44c3 Merge branch 'futatuki-configure-with-2to3-as-different-name'
* futatuki-configure-with-2to3-as-different-name:
  Apply patch to configure with 2to3 rename for 3.0.12
2017-09-19 08:10:27 +01:00
William S Fulton
950edc1c00 Add support for conversion operators with ref-qualifiers 2017-08-30 18:17:05 +01:00
William S Fulton
8a40327aa8 Add unignore for rvalue ref-qualifiers
Use std::move on this pointer as the default approach to supporting
rvalue ref-qualifiers if a user really wants to wrap.

std::move requires <memory> headers so add swigfragments.swg for all
languages to use common fragments. Just header file fragments for now.
2017-08-30 18:17:04 +01:00
William S Fulton
1cf599bccb Improve ref-qualifier implementation
Internally, handle function ref-qualifiers in the function decl type string.
Needed for a whole host of things to work like %feature and %rename.
Add %feature %rename and %ignore testing for ref-qualifiers.
2017-08-30 18:17:04 +01:00
William S Fulton
9e19fe7868 C++11 ref-qualifier support added
Fixes #1059

Methods with rvalue ref-qualifiers are ignored by default as it is not
possible to have an rvalue temporary from the target language (which is
needed to call the rvalue ref-qualified method).
A warning 405 is shown mentioning the ignored rvalue ref-qualifier method
which can be seen with the -Wextra option.

  cpp_refqualifier.i:15: Warning 405: Method with rvalue ref-qualifier ignored h() const &&.

Usually rvalue and lvalue ref-qualifier overloaded methods are written - the
lvalue method will then be wrapped.
2017-08-19 01:02:34 +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
96e99416d7 Add using declarations to templates into typedef table.
Fixes #1051. Using declarations to templates were missing in SWIG's internal typedef tables.
This led to a few problems, such as, templates that did not instantiate and generated
C++ code that did not compile as SWIG did not know what scope the template was
in. This happened mostly when a using declaration was used on a template type in a
completely unrelated namespace.
2017-08-16 00:24:25 +01:00
William S Fulton
aa2932f409 Typemap change for templates
For templates only, the template parameters are fully resolved when
handling typemaps. Without this, it is too hard to have decent rules
to apply typemaps when parameter types are typedef'd and template
parameters have default values.

Fixes %clear for typedefs in templates, eg:

  %typemap("in") XXX<int>::Long "..."
  template typename<T> struct XXX {
    typedef long Long;
  };
  %clear XXX<int>::Long;

as the typemap was previously incorrectly stored as a typemap for long
instead of XXX<int>::Long.
2017-08-16 00:24:06 +01:00
William S Fulton
7be6c10d4a Fix display of documented template types when using the autodoc feature for Python. 2017-07-07 19:35:44 +01:00
Olly Betts
ad7dcb2c87 Merge branch 'm7thon-python23-octal-arguments' 2017-06-23 14:57:05 +12:00
Michael Thon
80ffb169c1 [Python] fix and improve default argument handling
1. Fix negative octals. Currently not handled correctly by `-py3`
   (unusual case, but incorrect).
2. Fix arguments of type "octal + something" (e.g. `0640 | 04`).
   Currently drops everything after the first octal. Nasty!
3. Fix bool arguments "0 + something" (e.g. `0 | 1`) are always
   "False" (unusual case, but incorrect).
4. Remove special handling of "TRUE" and "FALSE" from
   `convertValue` since there's no reason these have to match
   "true" and "false".
5. Remove the Python 2 vs. Python 3 distinction based on the
   `-py3` flag. Now the same python code is produced for default
   arguments for Python 2 and Python 3. For this, octal default
   arguments, e.g. 0644, are now wrapped as `int('644', 8)`. This
   is required, as Python 2 and Python 3 have incompatible syntax
   for octal literals.

Fixes #707
2017-06-23 13:38:49 +12:00
William S Fulton
1d1d0de2d0 Fix python_richcompare test for Python 3.6 2017-06-20 00:02:00 +01:00
William S Fulton
e0c0017839 Remove failing runtime tests for now using Python 2 and -builtin 2017-06-19 20:33:32 +01: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
FUTATSUKI Yasuhito
9d9acba737 Apply patch to configure with 2to3 rename for 3.0.12 2017-06-19 15:42:31 +09:00
William S Fulton
95e8643d70 Rename func to funk in tests to avoid Go keyword problems 2017-06-16 19:24:48 +01:00
William S Fulton
241460eddc director_smartptr runtime tests enhancement
Add same changes from previous commit to additional languages
2017-05-23 21:36:24 +01:00
William S Fulton
81ba06e59e Fix Python negative unsigned default values
Closes #993
2017-05-21 00:02:08 +01:00
William S Fulton
2ec156fb7f Merge branch 'vadz-csharp-complex'
* vadz-csharp-complex:
  Add header to std_complex.i
  Fix linkage problems in C# std::complex wrappers
  C# std::complex wrappers marshalling by value
  C# std::complex wrappers SwigValueWrapper fix
  Use %naturalvar for C# std::complex wrappers
  Allow avoiding generation of unwanted std::complex<T> typemaps
  Also apply csvar{in,out} typemaps to std::complex references
  Add std_complex.i for C# too
  Extend C# complex support to member variables of this type
  Add support for std::complex<> to C#
  Use new unified Mono mcs compiler if available under Unix
2017-05-20 15:21:48 +01:00
William S Fulton
fcde570091 Merge branch 'redbrain-parser-fix'
* redbrain-parser-fix:
  Add testcase for macros with commas in comment
  Fix bug with comments inline in macros  - commit fixes #974

Closes #974
2017-04-27 19:48:25 +01:00
William S Fulton
956495dd47 Add testcase for macros with commas in comment 2017-04-27 19:47:29 +01:00
William S Fulton
7ad8ac92c0 Test c++11 unordered containers in Python 2017-04-25 19:40:08 +01:00
Vadim Zeitlin
ec565f74cf Extend C# complex support to member variables of this type
Define csvar{in,out} typemaps needed to support properties of complex type and
apply the existing cstype and csin ones to them as well.

Add unit test verifying that this works as expected in C# and, also, in
Python, even though no changes were needed there.
2017-04-01 23:51:45 +02:00
William S Fulton
dcc5911839 Fix handling of typedef'd function pointers for Go
Add equivalent runtime tests for Python and Java
2017-03-17 07:49:21 +00:00
William S Fulton
0ccef1424a C++11 alternate syntax for function declarations improvements
Functions can now be declared const/noexcept/final etc
2017-03-10 23:25:31 +00:00
William S Fulton
2a5068bcf2 Add some tests for typedef to member function pointers 2017-03-10 23:25:31 +00:00
William S Fulton
5aff26fcb5 Add support for parsing and wrapping member const function pointers 2017-03-10 23:25:31 +00:00
William S Fulton
67edda3bf5 Remove unused cvsignore target 2017-03-10 23:25:31 +00:00
William S Fulton
d6d7afb755 Enhance %extend to extend a class with template constructors 2017-01-24 19:01:43 +00:00
William S Fulton
481ebfab45 Enhance %extend to extend a class with static template methods 2017-01-24 19:01:43 +00:00
William S Fulton
b538070016 Enhance %extend to extend a class with template methods 2017-01-22 10:36:46 +00:00
William S Fulton
4c1152efcd Merge branch 'fschlimb-templ_def_cache'
* fschlimb-templ_def_cache:
  Add template_default_cache runtime tests
  Fix template_default_cache testcase
  template_default_cache is a multi-module test
  using 2-level caching as suggested by @wsfulton
  account for explicitly qualified scopes
  adding test
  restricting chaching template default types
2017-01-16 07:50:13 +00:00