Commit Graph

305 Commits

Author SHA1 Message Date
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
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 6910e5f09c Merge branch 'shared-ptr-template-upcast'
* shared-ptr-template-upcast:
  comments
  Applying shared_ptr template upcast fix to CSharp, adding CSharp test, and cleanup
  Adding test case demonstrating issue where SWIG does not generate a correctly typed, upcasted shared_ptr for a template instantiation deriving from a base class
  WIP - Use the non-encoded type string for upcasting a shared_ptr of a derived type to a shared_ptr of the base type
  comments
  Applying shared_ptr template upcast fix to CSharp, adding CSharp test, and cleanup
  Adding test case demonstrating issue where SWIG does not generate a correctly typed, upcasted shared_ptr for a template instantiation deriving from a base class
  WIP - Use the non-encoded type string for upcasting a shared_ptr of a derived type to a shared_ptr of the base type
2020-01-17 18:45:30 +00:00
William S Fulton 18b2dcd222 C# 'out' or 'ref' removal improvements in director typemaps.
- Add support to DOH Replace for not replacing inside C comments
- Fix removing 'out' or 'ref' when these are present in C comments
  in cstype typemaps.

Closes #1628
2019-11-26 19:39:28 +00:00
William S Fulton 6fb345feb2 'out' or 'ref' usage in a cstype typemap in directors
'out' / 'ref' was not always stripped out in parts of the
director code generation.

Issue #1628
2019-11-26 19:32:34 +00:00
Rokas Kupstys 06345e2aa5 Fix invalid code generated for "%constant enum EnumType ..." and add a test. 2019-08-01 08:55:07 +03:00
Isaac Pascual Monells 63497c8d0e Fix class name for nested classes 2019-07-08 12:49:00 +02:00
etse 3359b4ccab Applying shared_ptr template upcast fix to CSharp, adding CSharp test, and cleanup 2019-05-06 15:30:54 -04:00
William S Fulton 06462acdf9 Fix C# CA1063 warning by implementing the recommended Dispose methods.
Previously just the Dispose() method was generated.
Now the Dispose() and Dispose(bool disposing) methods are generated.
Changes are required if custom "csfinalize", "csdestruct" or "csdestruct_derived"
typemaps are being used. Details in #421 on Github. SWIG will error out if one of
the "csfinalize, "csdestruct" or "csdestruct_derived" typemaps are found. Example
error message:

  foo.h:60: Error: A deprecated csfinalize typemap was found for Foo, please remove
  it and replace all csdestruct, csdestruct_derived and csfinalize typemaps by the
  csdispose, csdispose_derived, csdisposing and csdisposing_derived typemaps.

Closes #421
2019-04-08 19:20:45 +01:00
Rokas Kupstys 0a102e2846 Fix class having method `Connect()` creating a name collision with `SwigDirectorConnect()`.
Issue is fixed by prepending director methods with `SwigDirectorMethod` instead of `SwigDirector`.
2018-09-06 12:43:51 +03: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 60ee821bca Correct C# warning for missing cstype typemap 2018-03-09 06:58:08 +00: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 05badeb1a4 Remove undocumented features used in directors
The jsdowncast and csdowncast features are not documented and I think
these are a relic of something that was never finished.
2017-05-21 17:43:06 +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 7f2849cb0a Merge branch 'Sghirate-master'
* Sghirate-master:
  [C#] static_cast for native directors
2017-05-21 00:22:17 +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
William S Fulton e429a891c9 Revert "csharp : noexcept method can't raise Swig::DirectorPureVirtualException"
This reverts commit 9dcf10138e.
2017-05-13 16:16:17 +01:00
Christophe Duvernois 9dcf10138e csharp : noexcept method can't raise Swig::DirectorPureVirtualException 2017-04-28 11:45:36 +02:00
Christophe Duvernois 4777a0ad3c #526 : propagate c++11 noexcept to director classes 2017-04-27 23:37:15 +02:00
William S Fulton 9d832c30b9 Fix missing filename in error messages when writing out C# files
Closes #882
2017-01-27 18:14:23 +00:00
William S Fulton 0e48622ca3 Merge branch 'wkalinin-override_fix'
* wkalinin-override_fix:
  test case added for "override" from imported module
  #733 - wrong "override" calculation in import mode
2017-01-16 19:48:19 +00: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 01fa85bda7 Add %feature("csdirectordelegatemodifiers") for C#
Enable customization of the delegate access modifiers generated in director classes.
Fixes https://github.com/swig/swig/issues/748
2016-12-24 17:14:36 +00:00
Vladimir Kalinin 91f29c09ae #733 - wrong "override" calculation in import mode 2016-06-27 20:27:10 +03:00
Vladimir Kalinin 0145a07cc3 fix for nested ignored types 2016-05-18 18:07:04 +03: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 5fb6537f69 C# char wrappers fixes for enum values, static const member char values and %csconst
Use hex escaping for char values used as C# constants
2016-03-12 18:52:49 +00:00
William S Fulton 2dec8c5514 Add limited support for %interface_impl and %shared_ptr 2016-03-06 21:20:23 +00:00
William S Fulton 21ee09fc19 Multiple inheritance warning wording tweak 2016-03-06 10:45:39 +00:00
Vladimir Kalinin 7e0b5ccf44 C# "override" fix for "extend" case 2016-03-05 19:34:38 +03:00
William S Fulton 7d76617dc3 Add checks for interface name symbol clashes 2016-03-03 22:48:35 +00:00
William S Fulton a1245ef398 Re-organization of the interface feature common code
Move code to new feature.cxx file.
Activate it in the allocate phase rather than in individual languages.
2016-03-03 08:55:20 +00:00
William S Fulton 14d2341512 Add $interfacename family of special variable expansions
This is a simple expansion expanding to the name of the interface and is
not qualified like $javainterfacename and $csinterfacename.
Expansion within typemaps is much like $javainterfacename otherwise.
Note that expansion within the pure java code typemap,
'javainterfacecode' and similarly pure C# code typemap,
'csinterfacecode' works like $javaclassname/$csclassname and
$&interfacename should not be used, just $interfacename.
2016-02-29 21:18:42 +00:00
William S Fulton c71dba5021 Interface name handling improvements and special variable changes
Support expansion of name attribute in: %feature("interface", name="%s")
%s expands to the proxy class name and all the usual %rename functions
can be used (regex, strip, camelcase etc) to derive the interface name
from the proxy class name.
Rename $interfacename family of special variables to $javainterfacename for Java
Rename $interfacename family of special variables to $csinterfacename for C#
This is to free up $interfacename for simple interface name expansion in forthcoming commit
2016-02-29 20:18:01 +00:00
William S Fulton 2f1c34be58 Support namespaces and nspace with the interface feature for C# 2016-02-26 18:17:20 +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
William S Fulton 66344adf9e Merge branch 'interfaces' of github.com:/swig/swig into interfaces
* 'interfaces' of github.com:/swig/swig:
  IntPtr & HandleRef absolute names used
  virtual/override fix
2016-02-23 07:10:15 +00:00
Vladimir Kalinin 682991762c virtual/override fix 2016-02-14 03:07:53 +03:00
William S Fulton c33b4dc34e Improve interface feature checks
Use common code for missing feature:interface:name attribute checks
Check that all base classes are also marked as interfaces
2016-02-13 13:03:40 +00:00
William S Fulton 645147a5b2 Comments added to interface feature implementation and cosmetic code changes 2016-02-12 20:23:35 +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
Vladimir Kalinin 5768d87deb director generation fixes
Conflicts:
	Lib/java/feature_interface.i
	Source/Modules/csharp.cxx
	Source/Modules/java.cxx
2016-02-12 07:09:17 +00:00