Commit graph

84 commits

Author SHA1 Message Date
William S Fulton
46f7501d94 Cleanup SWIG_VERSION definition
Add Swig_obligatory_macros which must be called by each
target language to define SWIG_VERSION correctly
in the generated code, as well as the language specific
macro SWIGXXX where XXX is the target language name.

Drop the #ifdef SWIGXXX that was previously generated -
I can't see the point of this and if users are defining
this macro somehow, then users will need to change this

Closes #1050
2022-10-13 19:47:43 +01:00
Olly Betts
631b41ae7b Use https for swig.org links 2022-10-06 13:16:39 +13:00
William S Fulton
910fd1e3cf [D] Fix occasional undefined behaviour with inheritance hierarchies
Particularly when using virtual inheritance as the pointers weren't
correctly upcast from derived class to base class when stored in the
base's proxy class.

Fixes commented out test code in cpp11_std_unique_ptr_runme
and li_std_auto_ptr_runme D tests.
2022-08-05 22:30:23 +01:00
William S Fulton
34c219b5f7 Merge branch 'imfunc'
* imfunc:
  Add special variable imfuncname expansion for C# and D
  Test and document imfuncname special variable expansion
  Update docs.
  Also expose  in proxyClassFunctionHandler
  Expose  to javaout typemaps.

Conflicts:
	CHANGES.current
2022-05-30 19:45:28 +01:00
William S Fulton
954f29b032 Add special variable imfuncname expansion for C# and D
Same functionality as Java
2022-05-30 19:43:04 +01:00
Olly Betts
55377bdc08 Add DOH Exit() and SetExitHandler()
Exit() is a wrapper for exit() by default, but SetExitHandler() allows
specifying a function to call instead.

This means that failures within DOH (e.g. Malloc() failing due to lack
of memory) will now perform cleanup such as removing output files.

This commit also cleans up exit statuses so SWIG should now reliably
exit with status 0 if the run was successful and status 1 if there was
an error (or a warning and -Werror was in effect).

Previously in some situations SWIG would try to exit with the status set
to the number of errors encountered, but that's problematic - for
example if there were 256 errors this would result in exit status 0 on
most platforms.  Also some error statuses have special meanings e.g.
those defined by <sysexits.h>.

Also SWIG/Javascript tried to exit with status -1 in a few places (which
typically results in exit status 255).
2022-03-06 12:33:54 +13:00
William S Fulton
b3da344765 Add some comments about shared_ptr upcast code 2020-01-24 19:46:39 +00:00
William S Fulton
564a91864a Refactor upcasts code
In preparation for possible improvement in usage of
SwigType_typedef_resolve_all - a SwigType* should be used,
not a readable name in a String*.
2020-01-23 19:30:03 +00:00
William S Fulton
0425a61fa8 shared_ptr upcast fixes for D
Same changes that were applied to Java/C# in ab7f526805
2020-01-23 18:03:22 +00:00
William S Fulton
831fae3c69 Add the parameters typemap attribute to D and Java destructor wrapper typemaps
Added to the javadestruct, javadestruct_derived, ddispose, ddispose_derived
typemaps to mirror enhanced flexibility in the csdisposing and
csdisposing_derived (C#) typemaps. If provided the contents are generated
as the delete/dispose method's parameters declaration.
2019-04-08 19:20:50 +01:00
luz.paz
60dfa31a67 Misc. typos
found via `codespell` and `grep`
2018-05-17 10:04:23 -04:00
William S Fulton
63a5a8af88 Fix lookup of csconstruct, dconstructor and javaconstruct typemaps
The C++ namespace was previously ignored in the lookup type
2018-05-15 22:26:35 +01:00
William S Fulton
ee17f8d04f C#, D, Java methodmodifiers on destructors
Add support so that the %csmethodmodifiers, %dmethodmodifiers,
%javamethodmodifiers can modify the method modifiers for the destructor wrappers
in the proxy class: dispose, Dispose, delete. With this feature, it is now possible
to make a C# proxy class sealed, eg when wrapping a class X, the virtual method modifiers
can be removed using:

  %typemap(csclassmodifiers) X "public sealed class"
  %csmethodmodifiers X::~X "public /*virtual*/";
2018-05-11 18:09:51 +01:00
William S Fulton
9fb996b83f Consistent spacing in generated exception specifications 2018-05-06 09:46:37 +01:00
William S Fulton
dafe2d6949 Add director typemaps for pointer const ref types 2017-10-24 23:47:40 +01:00
William S Fulton
ae044c1c2f Generation of director method declarations fixes
- Fixes generation of director method declarations containing C++11 ref-qualifiers.
- Fixes generation of director method declarations returning more complex types such
  as const ref pointers.
- Rewrite Swig_method_call to use more up to date code in the core.
2017-10-23 18:55:14 +01:00
William S Fulton
3f8b8fe734 Enhancements for directorin typemaps
The directorin typemaps will now generate a temporary variable
(specified after the type), such as:
%typemap(directorin) MyType (MyType *temp) { ... use temp ... }

The shared_ptr director typemaps have been fixed for use in functions
that take more than one parameter.
2017-10-16 19:28:27 +01:00
William S Fulton
b90a8d7444 Remove unnecessary dynamic_cast in C#/D/Java directors
Also revert the removal of dynamic_cast in the csdowncast feature.
2017-05-21 17:42:27 +01:00
William S Fulton
320df84607 Add missing return for pure virtual director wrappers for D and C# 2017-05-13 23:17:02 +01: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
Christophe Duvernois
4777a0ad3c #526 : propagate c++11 noexcept to director classes 2017-04-27 23:37:15 +02: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
ac495d5c66 Merge branch 'char-escaping'
* char-escaping:
  Add missing string_constant.i testcase
  changes file update for char wrappers
  C# char wrappers fixes for enum values, static const member char values and %csconst
  D testing added for %dmanifestconst and char constants
  Fix wrapping D constants using %dmanifestconst
  Php fix for enum value of '\0'
  Fix static const char member variables wrappers with %javaconst(1).
  Expand char testing in enums and %constant
  Java char changes file update
  Java enum and static member variable escaping fix for chars
  Add tests for enum values and static const member variables chars containing escape sequences
  Minor documentation tweak

Conflicts:
	CHANGES.current
2016-03-12 23:27:51 +00:00
William S Fulton
6840996dba Fix wrapping D constants using %dmanifestconst 2016-03-12 11:26:17 +00:00
William S Fulton
21ee09fc19 Multiple inheritance warning wording tweak 2016-03-06 10:45:39 +00:00
William S Fulton
fc4be01106 Refactor multiple inheritance warnings
Slightly simplify choosing single base class when handling
multiple inheritance and make consistent across more languages.
Modula3 multiple inheritance warnings now warn for all bases
2016-02-12 08:45:22 +00:00
Petre Eftime
0a07cd4c30 Prevent redefinition warnings when compiling with SWIG<module> defined
Signed-off-by: Petre Eftime <petre.p.eftime@intel.com>
2015-12-22 14:33:21 +02:00
William S Fulton
faeaacf112 smartptr feature support - factor out common code 2015-09-25 22:57:59 +01:00
Olly Betts
7ba0652677 Create director_common.swg for language-indep code
Move -DSWIG_DIRECTOR_STATIC handling there, so this is now supported for
all languages with director support, not just Python and PHP.
2015-03-12 19:51:11 +13: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
David Nadlinger
a8cdd1798e D: Emit empty enums as int aliases instead of omitting them.
This fixes test-suite/enum_forward.i.
2014-11-06 23:04:35 +01:00
David Nadlinger
0d6472525c D: Fix name collision between im D module function pointer and actual C function.
Previously, the function pointers were not only declared with
extern(C) calling convention, but actually had C linkage
themselves. Thus, they were exported under their bare names,
potentially colliding with the actual function definitions
in the wrapped library if the dynamic linker decided to
resolve them the wrong way.

This fixes the sneaky1 test case, although I have no idea why
the add() reference in D_add() (via the PLT) is rebound to the
function pointer there and not in all other test cases and
real-world libraries. As far as I can see, there don't seem to
be any special symbol visibility/binding settings involved in
our build system.
2014-11-06 23:04:35 +01:00
David Nadlinger
0b42c6f653 D: Fix allprotected_not.i compilation.
The director cycle breaking code was emitted when protectors
were not actually enabled on the parent class, leading to
swigIsMethodOverridden being called but not declared.
2014-11-06 23:04:34 +01:00
Vadim Zeitlin
9f1af8921f Refactor: move makeParameterName() to common Language base class.
This method was duplicated more or less identically for 4 languages and will
be needed for another one soon, so put it in the base class from which it can
be simply reused instead.

No changes in the program behaviour whatsoever.
2014-08-16 13:11:22 +02:00
Olly Betts
36be36d618 Eliminate needless casting away const from string constants 2014-04-30 12:00:23 +12:00
William S Fulton
cd2085aae7 Fixes for C enums used in an API and the definition of the enum has not been parsed.
For D, this fixes a segfault in SWIG.

Java, C#, D, Go now produce code that compiles, although the definition of the
enum is needed in order to use the enum properly from the target language.
2014-03-28 07:54:03 +00:00
Yung Lee
6e06b50adf Remove non-ascii characters at a comment line in d.cxx that trouble VC++ 2013-04-22 18:28:26 +01:00
William S Fulton
e182b4844c Fix seg fault in SWIG using directors when class and virtual method names are the same except being in different namespaces when the %nspace feature is not being used. 2013-03-19 19:50:44 +00:00
William S Fulton
7841a0d097 Remove cvs/svn Id strings 2013-01-12 01:21:16 +00:00
William S Fulton
5889d7bfdd Merge branch 'SFbug1299' of https://github.com/BrantKyser/swig into BrantKyser-SFbug1299 2013-01-11 23:12:06 +00:00
Brant K. Kyser
e1a59ae2c7 Clean up local variable name that store the director class's name to prevent confusion with the class name. 2013-01-08 21:38:57 -06:00
Olly Betts
f9566ad2df Fix assorted typos.
From https://sourceforge.net/p/swig/patches/332/ and some others too.
2013-01-08 18:47:40 +13:00
Brant K. Kyser
b005c68009 Patch for SourceForge Bug #1299 broke D and C#. Update D module to reflect these changes
NOTE: There are several test failures in the D test suite, so it is difficult to be entirely sure this does not break something.
2013-01-05 04:54:02 -06:00
William S Fulton
89052f3b0a Fix Strcmp - it didn't have consistent null pointer handling - revert to what it used to be - a lightweight wrapper around strcmp which means functions once again must not pass in null to it.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13943 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-12-02 13:36:13 +00: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
0d2c459046 Remove some unused code and pointless variable assignments
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13932 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-11-23 07:38:00 +00:00
David Nadlinger
1752b62156 [D] Fixed namespace handling bug introduced in r13915.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13920 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-11-20 20:06:21 +00:00
William S Fulton
0f0172bc0d Fix possible NULL dereference
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13915 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-11-19 19:48:50 +00:00
William S Fulton
0c7bc36122 Fix obvious copy/paste errors in some director code
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13914 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-11-19 19:47:48 +00:00
William S Fulton
e0967f3e13 Fix unnecessary and inconsistent null pointer checks
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13912 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-11-19 19:44:48 +00:00