Commit graph

150 commits

Author SHA1 Message Date
Olly Betts
631b41ae7b Use https for swig.org links 2022-10-06 13:16:39 +13:00
Vadim Zeitlin
b9fa8c23bb Make method wrappers suffix optional and disabled by default
Unfortunately the changes of 26bf86322 (Use SWIG-specific for
non-overloaded synthesized functions too, 2021-11-09) did break some
existing code bases using SWIG as they hardcoded the old wrapper
function names.

So turn this off by default and add a global variable allowing to enable
this, which can be done for a specific language only. This is ugly but,
unfortunately, there is no way to use the Language object from the C
function Swig_MethodToFunction(), so the only alternative would be to
add another parameter to it, but it already has 6 of them, so it
wouldn't really be that much better.

See #2366, #2368, #2370.
2022-09-19 12:40:03 +12:00
William S Fulton
e777b054d5 Performance optimisation for parameters passed by value that are C++11 movable.
The C++ wrappers create a temporary variable for a parameter to be passed to a
function. This is initially default constructed and then copy assigned from the
instance being passed in from the target language. This is unchanged, however,
when the temporary variable is passed to wrapped function, it is now done using
std::move. If the type is move constructible, the move constructor will be used
instead of the copy constructor.

Note that the implementation calls std::move for all user-defined types
(non-primitive types passed by value), this excludes anything passed by pointer,
reference and arrays. It does also include any type that has not been
defined/parsed by SWIG, that is, unknown types. std::move is called via the
SWIG_STD_MOVE macro which only calls std::move for C++11 and later code.
2022-07-08 17:41:15 +01:00
William S Fulton
3200a815d4
Merge pull request #2095 from vadz/extend-suffix
Use suffix for static methods added by %extend
2022-01-08 21:11:14 +00:00
Dimitris Apostolou
f586d920f7
Fix typos 2021-11-17 07:07:02 +02:00
Vadim Zeitlin
26bf86322b Use SWIG-specific for non-overloaded synthesized functions too
This avoids conflicts between such functions, which are generated when
using %extend to add static methods to an existing class, and the actual
wrapper functions generated by the backend.

This shouldn't result in any user-visible changes.
2021-11-09 23:35:30 +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
Olly Betts
90f9117e10 Fix various comment and documentation typos 2017-08-13 18:04:33 +12:00
William S Fulton
2e01533b23 Partial support for %constant and structs
Test case is slightly modified from the test case in issue #250

Use of constant objects does not seem to work in Python - the type is
SwigPyObject instead of constant_directive.Type1.
2014-12-18 07:01:08 +00:00
William S Fulton
83749b3937 Fix expansion of the $parentclassname special variable
It incorrectly contains brackets in the expanded name.
Fixes SF Bug 1375.
2014-07-01 20:27:48 +01:00
Olly Betts
36be36d618 Eliminate needless casting away const from string constants 2014-04-30 12:00:23 +12:00
Vladimir Kalinin
e18044185e fixes for director class naming when nested classes are used 2014-03-13 18:58:29 +04:00
William S Fulton
dbf44fc181 Fix std::map and smart pointers.
Fixes problem with method overloading when some methods are added by %extend
and others are real methods and using template default parameters with smart pointers.
This is noticeable as a regression since 2.0.12 when using the default smart pointer
handling for some languages when the smart pointer wraps std::map and other STL containers.

Fixes SF Bug 1363
2014-03-06 19:52:03 +00:00
William S Fulton
2121e1217e Ensure -c++out is not used with -c++
Error checking for this combination implemented as well as correcting
Octave

Also refactor, replacing CPlusPlusOut variable with cparse_cplusplusout
for an implementation which more closely resembles cparse_cplusplus which
is also required in both .c and .cxx files.
2013-12-12 20:52:44 +00:00
William S Fulton
e95ac82651 Nested C class setters restored in c++out mode for Octave
Suitable casts are required so that assignment of instances of nested classes
work as the nested class is duplicated in the global namespace, eg:

struct Outer {
  struct Nested {
    int bar;
  } bar_instance;
};

Outer.bar_instance can now be assigned to.
2013-12-12 09:00:16 +00: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
Karl Wette
70cd52f44d Use "(void)" instead of "()" when wrapping no-argument extension functions. 2013-02-18 22:39:39 +00:00
William S Fulton
b725625e6f Add support for thread_local when specified with other legitimate storage class specifiers - extern and static 2013-02-08 06:36:39 +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
William S Fulton
07c35d61e3 Fix generated code for rvalue references by converting functions returning an rvalue reference into something that can be taken the address of - via a const ref cast. Now the rvalue_reference tests compile under g++-4.7 (C# only atm) 2013-01-24 08:02:34 +00:00
Vladimir Kalinin
7d800a655d Unicode literals 2013-01-21 19:09:56 +00:00
William S Fulton
7841a0d097 Remove cvs/svn Id strings 2013-01-12 01:21:16 +00:00
Brant K. Kyser
6cb5b5487f Use NSPACE_SEPARATOR rather than liter string for package seperator. 2013-01-08 21:28:13 -06:00
Brant K. Kyser
3c12306b21 Remove extra underscore from generated director names to maintain prevent breaking languages that do not support nspace. 2013-01-05 03:40:06 -06:00
Brant K. Kyser
f6ce5f089f Qualify generated SwigDirector class names with namespaces 2013-01-03 21:26:08 -06:00
William S Fulton
d93dc0f8e2 Distinguish between an "abstract" attribute on a class containing a list of abstract members and an "abstract" flag on pure virtual methods - renamed former to "abstracts"
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13935 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-11-24 14:13:58 +00:00
William S Fulton
b17a77c6ea Support special variable expansion in %extend.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13871 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-10-11 19:28:02 +00:00
William S Fulton
24133bacd7 Remove numerous hard coded 'result' variable name in generated c/c++ wrappers. The variable name is now defined in just one place, making it possible to change the name easily if a target language so wishes - see cwrap.c.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12830 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-10-30 21:51:50 +00:00
William S Fulton
c794d08597 Fix %newobject when used in conjunction with %feature(ref). The code from the ref feature was not always being generated for the function specified by %newobject. Documentation for ref and unref moved from Python to the C++ chapter.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12783 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-08-23 19:29:10 +00:00
William S Fulton
a63d456f8a Remove redundant code highlighted by warnings in gcc-4.6
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12536 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-03-14 07:22:08 +00:00
William S Fulton
28af783d18 Templated smart pointers overloaded with both const and non const operator-> generated uncompilable code when the pointee was a class with either public member variables or static methods.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12512 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-03-02 22:30:05 +00:00
Olly Betts
28e277f8c5 Fix typo "the the" -> "the"
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12285 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-10-19 06:31:31 +00:00
William S Fulton
3219746776 Apply patch #3066958 from Mikael Johansson to fix default smart pointer handling when the smart pointer contains both a const and non-const operator->.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12240 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-10-03 13:12:00 +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
William S Fulton
ab1cd03979 merge revisions 11243-11872 from trunk to gsoc2009-matevz
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-matevz@12162 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-07-20 21:58:41 +00:00
William S Fulton
d8cc75946b Improved C++0x rvalue reference implementation differentiating lvalue and rvalue references. The previous implementation treated rvalue references as lvalue references which leads to a number of different wrapping issues.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-matevz@12160 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-07-18 00:19:22 +00:00
Olly Betts
9ed2d0165c Fix comment typo.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12141 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-06-21 03:44:29 +00:00
William S Fulton
7f53260203 merge revisions 11872:11876 from trunk to gsoc2009-matevz branch - license changes
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-matevz@11905 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-03-06 00:51:54 +00:00
William S Fulton
1253657bb4 Add improved namespace support - the nspace feature, working for Java only at the moment.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11896 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-03-04 21:27:23 +00:00
William S Fulton
cb64f65bae SWIG license change - Source moves to GPLv3
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11876 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-02-27 23:53:33 +00:00
William S Fulton
83bd820285 Add typemaps used debugging option (-debug-tmused). Fix missing file/line numbers for typemap warnings and in the output from the -debug-tmsearch/-debug-tmused options
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11802 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-01-04 19:33:52 +00:00
William S Fulton
2bd190dbf1 Revert support for %extend and memberin typemaps added in swig-1.3.39. The memberin typemaps are ignored again for member variables within a %extend block. Documentation inconsistency reported by Torsten Landschoff.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11762 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2009-12-02 00:01:31 +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
William S Fulton
9be7fe899d Add support for %extend and memberin typemaps
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11127 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2009-02-13 07:26:06 +00:00
William S Fulton
f9abd71f76 remove unnecessary temporary variable when wrapping return by reference
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11126 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2009-02-12 21:16:03 +00:00
William S Fulton
839750da9a const / non-const warning fix
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11101 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2009-01-31 19:02:10 +00:00
Haoyu Bai
1d1ee5bae7 Fix broken caused by merge
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11098 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2009-01-30 10:32:59 +00:00
Haoyu Bai
47b4825168 Merged revisions 11085-11086,11088-11089 via svnmerge from
https://swig.svn.sourceforge.net/svnroot/swig/branches/swig-2.0

........
  r11085 | bhy | 2009-01-25 00:21:55 +0800 (Sun, 25 Jan 2009) | 2 lines
  
  Fix const-correctness.
........
  r11086 | bhy | 2009-01-25 02:08:50 +0800 (Sun, 25 Jan 2009) | 2 lines
  
  Correct some function definition in header files, which implementation changed in previous commit caused mismatch.
........
  r11088 | bhy | 2009-01-25 02:38:32 +0800 (Sun, 25 Jan 2009) | 1 line
  
  minor fix and now SWIG is alive again
........
  r11089 | bhy | 2009-01-25 06:07:07 +0800 (Sun, 25 Jan 2009) | 1 line
  
  Correct some bug introduced in previous commits. Now SWIG is pretty good with C++ compiler.
........


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11097 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2009-01-30 10:27:37 +00:00
Haoyu Bai
6d2aef67d9 Replaced all [const] String_or_char * to const_String_or_char_ptr, by the following command:
sed -i "s/\(const \)\?String_or_char \*/const_String_or_char_ptr /g" CParse/* Include/* Modules/* Preprocessor/* Swig/*

This is a preparation for moving to new DOH, since for strong typed objects we need the const_String_or_char_ptr class to implicit convert to and from String * or const char *.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11080 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2009-01-24 13:15:51 +00:00
William S Fulton
49675199f4 Remove some vc++ /W4 warnings
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10540 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2008-06-21 15:23:02 +00:00