Commit Graph

43 Commits

Author SHA1 Message Date
Olly Betts d80ce85819 Handle arbitrary expressions as a subscript
We don't actually need to parse expressions in this context so we can
just skip to the matching closing square bracket.
2024-09-30 09:25:00 +13:00
Olly Betts f5b8c97a94 Fix problem with new testcase 2024-09-25 16:25:55 +12:00
Olly Betts 8a9aeba699 Handle arbitrary expressions in method call parameters
We don't actually need to parse expressions in this context so we can
just skip to the matching closing parenthesis.
2024-09-25 13:55:39 +12:00
Olly Betts 9f685e03f0 Add regression test for old bug fix
We don't seem to have anything in the testsuite which exercises this
case.

There's some special handling of casts applied to string literals in the
parser which was committed as part of the fix for this, but removing it
doesn't seem to cause anything to fail (not even this testcase which
it reportedly fixed), and a wide character version seems to work without
any equivalent special handling.  Maybe other things have changed since
which fixed this case without needing special cast handling.  Deserves
further investigation.
2024-09-21 09:04:27 +12:00
Momtchil Momtchev 721a4808b8 remove hacks and implement default arguments 2023-05-31 13:22:35 +02:00
William S Fulton c10a84c775 Cosmetic stray semi-colon removal after %typemap using quotes 2022-08-31 19:40:13 +01:00
Seth R Johnson feeb2516ae "Include what you use" for tests
Many of these tests implicitly required the target language library files to include the headers upstream.
2019-01-06 08:32:34 -05:00
Zackery Spytz 5c19f4de2f [OCaml] Add missing warning filters for OCaml keywords in the test suite 2018-12-31 05:55:10 -07:00
William S Fulton 196a965067 test-suite fixes for compilers that don't support vararg macros
Split TESTCASE_THROW into multiple macros taking different number of arguments.
Fixes Visual Studio compiler errors.
2018-05-06 09:46:37 +01:00
William S Fulton 35b792daed test-suite support for C++17: exception specification throw removal 2018-05-04 20:02:13 +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
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 ff53789dc9 Suppress warning in testcase 2017-06-20 07:00:22 +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 760c008311 Warning fixes for gcc-7
warning: dynamic exception specifications are deprecated in C++11; use 'noexcept' instead [-Wdeprecated]
2017-02-06 20:30:09 +00:00
William S Fulton 62c34fc9d9 Add tests for enum values and static const member variables chars containing escape sequences 2016-01-26 20:16:47 +00:00
William S Fulton b8e1a66a38 Add new feature "python:cdefaultargs"
Controls default argument code generation to obtain the default
arguments from the C++ layer instead of the Python layer.
2015-05-28 20:11:57 +01:00
Vadim Zeitlin 6988b00aba Fix handling of default arguments after ignored ones in Python.
Don't skip checking subsequent arguments just because one of them has "in"
typemap with numinputs=0 attribute.

Add a unit test showing the problem which is relatively rare as it doesn't
happen for the class methods and is hidden unless autodoc feature is used for
the global functions.

Closes #377.
2015-04-27 23:17:14 +02:00
Vadim Zeitlin 5569d91bd0 Fix handling of "default" typemap in Python.
Use "compact" arguments form for the function if "default" typemap is defined
for any of its arguments to allow omitting this argument when calling it from
Python.

Closes #377.
2015-04-23 15:11:05 +02:00
Vadim Zeitlin 0eae8a8efa Fix handling of NULL default argument values for pointer types.
Accept not only manifest pointer types (such as e.g. "void *") but also types
that are typedefs for pointer types when checking whether C++ value of 0 must
be represented as 0 or None in Python.

Closes #365, #376.
2015-04-23 15:11:02 +02:00
William S Fulton 944fbfb426 Python 3 default args fix
Fix 0U and 0L as default args for Python 3 (tests committed in
previously commit of default_args.i).
Relates to issue #294.
2015-01-13 07:55:31 +00:00
William S Fulton 9d87b9f099 Revert introduction of python:defaultargs feature
See issue #294
2015-01-12 21:35:47 +00:00
William S Fulton 679f9395bc Tests for Python default arguments and %pythondefaultargs.
Tests changes in previous commit (see patch #294)
2015-01-11 16:45:53 +00:00
William S Fulton 38ba81811e Fix Python default argument handing broken since swig-3.0.3
Default values are no longer generated as Python code by default.
They must be explicitly turned on using the "python:defaultargs" feature.

Closes #294
Closes #296

The problems in these two issues when "python:defaultargs" is turned
on still need to be fixed and should be addressed in separate patches.
The important thing is the default code generation is now fixed.
2015-01-09 00:34:17 +00:00
Vadim Zeitlin 34787ab98e Python default argument test cases from issue #294 2015-01-09 00:33:57 +00:00
William S Fulton 5d3deb2db1 Fixes for compactdefaultargs and pass by value where the class being passed by value has no default constructor - previously it used SwigValueWrapper
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11312 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2009-06-24 17:20:17 +00:00
Marcelo Matus 4c336ab5ac use include <> instead of "" for system files
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8448 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-01-15 02:08:31 +00:00
William S Fulton 1fad10b79b muffle exception specification ignored warning (VC++). This is only for testcases that introduce exception specifications in the testcase case itself.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8400 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-01-12 23:43:16 +00:00
William S Fulton 473da5b297 php keyword fixes
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7869 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-11-26 08:38:49 +00:00
Marcelo Matus 07df4a57db fixes for valgrind
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7721 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-10-25 14:52:30 +00:00
Marcelo Matus bef269c021 fix for 'staticmethod' kw name
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6911 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2004-12-22 20:32:31 +00:00
Marcelo Matus d6a3c88c56 fix ruby warnings
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6718 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2004-11-12 00:02:07 +00:00
Marcelo Matus f668d1def8 fix seg. fault in errors/.. and revert to previous 1.89 version
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6717 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2004-11-11 23:30:25 +00:00
William S Fulton ed85b98a2d more %rename/%ignore tests
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6706 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2004-11-09 21:27:02 +00:00
William S Fulton fbfca3d2d6 default args added
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6674 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2004-11-05 23:19:00 +00:00
Marcelo Matus 9d3cce855e remove old patch for features + def arg, but save the ignore/rename part. Now everything seems to be working.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6668 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2004-11-04 23:18:01 +00:00
Marcelo Matus 344ab4e1e0 fix ConstMethods order for ruby
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6634 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2004-11-02 22:45:29 +00:00
William S Fulton 6784d7e6cc test for default args in const methods
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6625 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2004-11-02 21:26:26 +00:00
Marcelo Matus ec2d6ba128 more uniform treatment of extern C. This also fix the defarg mechanism when declaring C functions inside C++.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6621 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2004-11-02 19:03:01 +00:00
William S Fulton dc12af75b6 various fixes to remove warnings
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6580 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2004-11-01 21:10:06 +00:00
William S Fulton 7a339354ea default argument tests
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6312 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2004-10-04 20:49:43 +00:00