Commit graph

107 commits

Author SHA1 Message Date
William S Fulton
67c4c2186c Support multiple arguments in variadic templates.
Remove warning SWIGWARN_CPP11_VARIADIC_TEMPLATE which was issued if more
than one argument was used for a variadic template.

SwigType enhancement: 'v.' now represents a variadic argument.
2022-12-22 21:23:39 +00:00
William S Fulton
2a1711e436 Slightly better decltype() support for expressions
decltype now accepts C++ expressions instead of just an ID, such as:

  int i,j;
  ...  decltype(i+j) ...
  ...  decltype(&i) ...

These result in a warning for non-trivial expressions which SWIG cannot evaluate:

  Warning 344: Unable to deduce decltype for 'i+j'.

See 'Type Inference' in CPlusPlus.html for workarounds.

Issue #1589
Issue #1590
2022-11-26 01:16:20 +00:00
William S Fulton
973590ff91 R rtypecheck typemaps
Further switch to use rtypecheck typemaps instead of hard coded logic.
The full switch to typemaps is deferred until swig-4.2 as it can't be fully
backwards compatible. For now a warning is provided to help the
transition. It provides the full typemap that should be placed into
a user's interface file, for example:

%typemap("rtype") int32_t * "integer"
void testmethod(int32_t * i);
void testmethod();

If there is no rtypecheck typemap for int32_t *, the warning shown is:

example.i:7: Warning 750: Optional rtypecheck code is deprecated. Add the
following typemap to fix as the next version of SWIG will not work without it:
%typemap("rtypecheck") int32_t * %{ (is.integer($arg) || is.numeric($arg)) %}

The warning is shown for any code that previously used "numeric", "integer" or
"character" for the rtype typemap. Copying the rtypecheck typemap as
shown into the user interface file will provide the appropriate fix and
the warning will disappear. This is important to do as swig-4.2 will
not be able to provide this helpful warning.
2022-11-05 08:40:26 +00:00
Olly Betts
631b41ae7b Use https for swig.org links 2022-10-06 13:16:39 +13:00
Zackery Spytz
cb887ed2d4 Add support for the <=> operator (C++20) 2022-07-27 09:12:40 +12:00
Olly Betts
892557e799 Improve #include guard macros
Avoid using reserved identifiers such as `_DOHINT_H` (fixes #1989),
fix cases where the name doesn't match the filename, and make the naming
more consistent and less likely to collide with include guards in other
headers.
2022-07-19 09:35:46 +12:00
William S Fulton
ed42422d1c Add support for wchar_t * and std::wstring Unicode strings on Linux
Initial contributions for Linux provided in issue #1233, modified to work
on both Windows and Linux. Dual support is possible by detecting
the sizeof wchar_t which is different on each of these systems.
2022-05-02 21:08:19 +01:00
Olly Betts
9eb75a0c07 Improve typemap method and attribute checking
Specifying a value on the typemap method now gives an error, e.g.:

%typemap(argout=123) char * ""

The old way of specifying a language name in the typemap attributes
is no longer supported (it has been deprecated for 16 years).

Closes #891
2022-03-03 18:46:15 +13:00
William S Fulton
064b8148ea Correct WARN_JAVA_TYPEMAP_INTERFACEMODIFIERS_UNDEF warning number 2022-03-01 23:10:25 +00:00
Olly Betts
b127e11f1e Fix typos in docs and comments 2022-02-27 18:15:46 +13: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
017900d57e Extern template tweaks
Document extern template functions support.
Extern templates result in new warning to differentiate
from template explicit instantiation definition warning.
2022-01-25 00:28:08 +00:00
Olly Betts
12f3a85916 [Modula3] Remove code for Modula3
We dropped support for it in SWIG 4.0.0 and nobody has stepped forward
to revive it in over 2 years.

See #2009.
2021-05-16 08:42:39 +12:00
Olly Betts
9ddc9dceb7 Remove support for $source and $target
These were officially deprecated in 2001, and attempts to use them have
resulted in a warning (including a pointer to what to update them to)
for most if not all of that time.

Fixes #1984
2021-04-30 10:20:14 +12:00
William S Fulton
c1b004f4fa Add access modifier support for interface feature
Add ability to change the modifiers for the C# and Java
interface generated when using the %interface macros.

For C# use the 'csinterfacemodifiers' typemap.
For Java use the 'javainterfacemodifiers' typemap.

For example:

  %typemap(csinterfacemodifiers) X "internal interface"

Closes #1874
2020-09-25 18:54:25 +01:00
John McFarland
841d4b5fb9 Add iterator safety check in DoxygenParser::parse
If the code called by DoxygenParser::parse does not behave correctly,
it may move the iterator m_tokenListIt past the value endParsingIndex.
This was not caught by the previous checks and could lead to
dereferencing an invalid m_tokenListIt iterator value (and segfault).
This is now protected against by using a less than check in the while
loop instead of not equals.  A warning is also printed if
endParsingIndex is exceeded.
2019-07-06 11:30:56 -05:00
Zackery Spytz
c3d652c785 Fix the handling of director classes with final methods
Generated SwigDirector_* classes were attempting to override
methods marked as final.

In addition, give a warning if the destructor of a director class is
final.

Closes #564.
2019-02-22 06:28:53 -07:00
William S Fulton
9defd8e033 Add support for differentiating target language statuses
Three status: Disabled, Experimental and Supported.

Any target language classified as 'Experimental' will issue new warning
524 SWIGWARN_LANG_EXPERIMENTAL.
Any target language classified as 'Disabled' will error out.

Languages will be classified in forthcoming commits.

Issue #1437
2019-02-04 18:46:16 +00:00
William S Fulton
396910c100 Doxygen warnings cleanup
- Remove unused warnings.
- Refactor some warnings.
- Document all Doxygen warnings.
2018-06-05 18:40:30 +01:00
William S Fulton
15f16155f2 Move doxygen warning numbers
Move out of the range reserved for language modules
2018-06-01 21:00:06 +01:00
Vadim Zeitlin
db65ae5aea Merge branch 'master' into doxygen
Fix the usual conflicts in autodoc unit test due to fixing the
divergences in autodoc generation between builtin and default cases in
this branch.
2017-09-19 14:02:53 +02: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
Vadim Zeitlin
e668c47b70 Merge branch 'master' into doxygen
The way Python docstrings are indented has changed on master, so use the
standard inspect module in Python autodoc unit test to ignore the differences
in their indentation level between -builtin and non-builtin cases to make the
test still pass with the branch version, which avoids the use of different
(but almost identical) values in the test itself.
2016-12-12 01:24:17 +01:00
William S Fulton
257822cc6d Warning header cosmetics
C++11 aliasing warnings are no longer needed as missing functionality
has been implemented.
2016-11-02 09:08:50 +00:00
William S Fulton
e7bb3afa0c Create javainterfacecode and csinterfacecode typemaps
The interface feature is no longer hard coded and can
be controlled by a user via these new typemaps.
2016-02-23 07:30:00 +00:00
Vadim Zeitlin
302955a152 Another merge with master.
Updated Doxygen error numbers yet again, as Python errors got added in the
meanwhile, pushing the Doxygen ones further off.

And re-merged PEP8/whitespace-related conflicts in autodoc_runme.py once again
(if anybody is looking for a motivating example about why significant
whitespace is bad, here is a great use case).
2015-07-20 00:44:26 +02:00
Olly Betts
822b2355c0 Improve handling of whitespace in %pythoncode
Previously SWIG looked at the indentation of the first line and removed
that many characters from each subsequent line, regardless of what those
characters were.  This was made worse because SWIG's preprocessor removes
any whitespace before a '#'.  Fixes github issue #379, reported by Joe
Orton.
2015-06-29 22:12:38 +12:00
Vadim Zeitlin
300ccce46c Another merge with master.
Change Doxygen error codes to start at 740 instead of at 720 as the latter was
taken by Scilab in the meanwhile.

Resolve conflicts in autodoc_runme.py once again.
2015-02-16 23:46:39 +01:00
Simon Marchetto
cc8b859162 scilab: use language specific warnings for too long identifier names 2014-07-21 12:47:27 +02:00
Vadim Zeitlin
1ebd2334b8 Merge branch 'master' into doxygen
Merge with ~3.0.1 sources from master.
2014-04-30 18:37:57 +02:00
Vladimir Kalinin
4744ea8903 added forward declaration instead of ignored nested class (resurrected old code) 2014-02-03 01:03:37 +04:00
Vladimir Kalinin
2f3d93e93a Nested classes support is diversified, depending on the language capability. If the language cannot support nested classes, they will be unconditionally moved to the global namespace. If language module does not override Language::nestedClassesSupport() function, nested classes will be ignored, unless "feature:flatnested" is used. 2014-02-02 22:38:13 +04:00
William S Fulton
0f4ceaf592 Deprecation of the 'nestedworkaround' feature
Also add in macros for the flatnested feature which can be used in place
of the nestedworkaround feature
2013-12-13 08:11:17 +00:00
Vladimir Kalinin
b63c4839fe Nested classes support
Closes #89
Squash merge branch 'master' of https://github.com/wkalinin/swig into wkalinin-nested

By Vladimir Kalinin
* 'master' of https://github.com/wkalinin/swig:
  CPlusPlusOut mode for Octave
  nested class illustration
  fixed "Abstract" flag for nested classes added an example enabled anonymous nested structs runtime test
  porting
  warnings disabled
  porting fixes
  java runtime tests ported
  nested class closing bracket offset fixed
  removed double nested template (not supported by %template parsing)
  template_nested test extended
  parent field made public
  property access fixed
  replaced tabs with spaces
  warning W-reorder
  deprecated warnings removed, derived_nested runtime test added
  optimized string indenting
  Nested classes indenting
  nested classes docs
  fixed the order in which flattened inner classes are added after the outer
  Private nested classes were getting into the type table.
  Java getProxyName() fix for nested classes fixes the case when nested classes is forward declared
  Fix for a case when a nested class inherits from the same base as the outer. (Base class constructor declaration is found first in this case)
  merge fix
  nested C struct first immediate declaration incorrectly renamed sample fixed
  tests updated to reflect nested classes support
  Java nested classes support (1)
  flattening should remove the link to the outer class
  access mode correctly set/restored for nested classes
  nested templates should be skipped while flattening (template nodes themselves, not expanded versions) also non-public nested classes should be ignored
  If nested classes are not supported, default behaviour is flattening, not ignoring flag "nested" is preserved, so, the nested classes can be ignored by user
  nested workaround test updated
  template instantiated within a class is marked as nested for ignoring purposes
  %ignore not applied to the nested classed, because "nested" flag is set too late
  typedef name takes precedence over the real name (reason?)
  unnamed structs should be processed for all the languages
  nested C struct instances are wrapped as "immutable"
  tree building
  typedef declaration for unnamed C structures fixed
  nested classes "flattening"
  fixed %ignoring nested classes
  renamed "nested" attribute to "nested:outer" added "nested" flag, to be used with $ignore (it is not removed while flattening) added nestedClassesSupported() function to the Language interface
  renamed "nested" attribute to "nested:outer" added "nested" flag, to be used with $ignore (it is not removed while flattening) added nestedClassesSupported() function to the Language interface
  tree iteration fix
  dirclassname variable names unified memory issue fixed
  merge error
  ignore unnamed structs for C++
  unnamed nested C structs naming & unnesting
  class added to classes hash under typedef name
  private nested classes skipped
  test updated due to nested templates support
  anonymous structs with inheritance fixed nested_class test to allow anonymous structs w/o declarator
  tests updated: nested workaround removed from namespace_class.i propagated nested template declaration to the C++ file
  injected members scope
  nested tempplates fixes, nested structures in "C" mode parsing added utility function "appendSibling" (like "appendChild")
  nested unnamed structures parsing fixes, access mode restored on nested class end, tdname is properly patched with outer class name prefix
  memory management fixes
  nested templates (1)
  Nested unnamed structs
  Nested class support (1)
  Nested class support (1)
2013-11-29 07:02:34 +00:00
Marvin Greenberg
6736e74127 Add feature director:except for improved director exception handling in Java
Closes #91
2013-10-22 20:44:35 +01:00
William S Fulton
bcb7aee022 Merge branch 'master' into gsoc2009-matevz
Conflicts:
	Examples/Makefile.in
	Examples/guile/Makefile.in
	Lib/php/php.swg
	Makefile.in
	Source/CParse/parser.y
	configure.ac
2013-10-10 07:26:09 +01:00
William S Fulton
d1b40b468b Fix C code where a typedef name was used for constructor and destructor names in %extend. Deprecate use of typedef names for constructor and destructor names going forwards. 2013-02-18 22:40:42 +00:00
William S Fulton
b80f4dc5e2 Restrict the name used in %extend to be just the struct/class name and not a typedef to a class/struct. Typedefs were only partially working anyway. Anonymous struct typedefs excluded. Deprecate with a warning for now. 2013-02-18 19:53:37 +00:00
William S Fulton
d613ef42f2 Rework std::initializer_list handling to warn about usage in any method, not just constructors. A typemap is used to issue the warning and can be overridden with user defined behaviour. 2013-02-04 20:03:22 +00:00
William S Fulton
e805d5f925 Merge branch 'master' into gsoc2009-matevz
parser.y still to be fixed up

Conflicts:
	Doc/Devel/engineering.html
	Examples/Makefile.in
	Lib/allegrocl/allegrocl.swg
	Lib/csharp/csharp.swg
	Lib/csharp/enums.swg
	Lib/csharp/enumsimple.swg
	Lib/csharp/enumtypesafe.swg
	Lib/java/java.swg
	Lib/python/pydocs.swg
	Lib/r/rtype.swg
	Source/Include/swigwarn.h
	Source/Modules/octave.cxx
	Source/Modules/python.cxx
	Source/Modules/ruby.cxx
	Source/Swig/scanner.c
	Source/Swig/stype.c
	Source/Swig/swig.h
	configure.ac
2013-01-28 07:01:37 +00:00
Brant K. Kyser
3bdcb14117 Add jniclasspackage pragma & change error regarding use of nspace without -package to warning. 2013-01-17 08:13:03 +00:00
William S Fulton
171435f989 Provide unique c++11 warnings which were previously hijacking another warning
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-matevz@13846 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-09-21 06:37:30 +00:00
Dmitry Kabak
3eed72b659 Updated Doxygen warning system
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13598 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-08-11 15:23:18 +00:00
William S Fulton
4c6f66577a Add warnings for badly named destructors. Fix %extend and destructors for templates - they weren't always being wrapped. Fix destructor "name" attribute.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12804 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-09-13 06:15:29 +00:00
William S Fulton
0913f41fb4 Change preprocessing error for tokens appearing after #else and #end to warning. Add some missing warning documentation and a couple of warning messages tidy up.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12467 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-02-17 21:54:13 +00:00
William S Fulton
3d7799fe0d New warning when the smartptr feature is missing in some classes in an inheritance chain. Errors test-suite now uses Python instead of Tcl as testing language
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12395 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-01-17 21:12:35 +00:00
David Nadlinger
3477a9dff1 [D] Replaced the term "wrap D module" with "intermediary D module" (including names derived from it).
This was suggested by wsfulton on the mailing list in order to bring the D module in line with the C# one, the naming scheme of which is intended to be language-independent.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12319 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-11-28 23:12:03 +00:00
David Nadlinger
03aefbc6e9 Added support for the D programming languge.
It is still a bit rough around some edges, particularly with regard to multi-threading and operator overloading, and there are some documentation bits missing, but it should be fine for basic use.

The test-suite should build and run fine with the current versions of DMD, LDC and Tango (at least) on Linux x86_64 and Mac OS X 10.6.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12299 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-11-18 00:24:02 +00:00
William S Fulton
40e64b14f1 Allocate warnings 700-799 for languages modules. Note 900-999 was and is documented as reserved for user defined warnings.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12230 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-09-27 05:40:14 +00:00
William S Fulton
25ff4e4927 merge revisions 11877-12162 from trunk to gsoc2009-matevz
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-matevz@12164 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-07-20 23:35:40 +00:00