Commit graph

270 commits

Author SHA1 Message Date
William S Fulton
32e7074d9b Whitespace fixes in STL wrappers 2017-06-03 18:36:59 +01:00
William S Fulton
fdca8e9829 Better variable naming consistency in STL containers 2017-05-26 22:37:29 +01:00
William S Fulton
2ec156fb7f Merge branch 'vadz-csharp-complex'
* vadz-csharp-complex:
  Add header to std_complex.i
  Fix linkage problems in C# std::complex wrappers
  C# std::complex wrappers marshalling by value
  C# std::complex wrappers SwigValueWrapper fix
  Use %naturalvar for C# std::complex wrappers
  Allow avoiding generation of unwanted std::complex<T> typemaps
  Also apply csvar{in,out} typemaps to std::complex references
  Add std_complex.i for C# too
  Extend C# complex support to member variables of this type
  Add support for std::complex<> to C#
  Use new unified Mono mcs compiler if available under Unix
2017-05-20 15:21:48 +01:00
William S Fulton
fb941315c1 Add header to std_complex.i 2017-05-19 20:25:15 +01:00
William S Fulton
57ec5ec056 Fix linkage problems in C# std::complex wrappers
Fix warnings and subsequent exception trying to use wrappers:
Warning C4190: 'CSharp_complextestNamespace_VectorStdCplx_getitemcopy'
has C-linkage specified, but returns UDT 'SwigSystemNumericsComplex'
which is incompatible with C

Rename swig_complex_typemaps macro to SWIG_COMPLEX_TYPEMAPS
2017-05-19 19:52:39 +01:00
William S Fulton
e11e1c4cb8 C# std::complex wrappers marshalling by value
Change the wrapping to marshall directly to the .net
System.Numerics.Complex type instead of using an intermediate
std::complex .net type.
2017-05-19 08:15:01 +01:00
William S Fulton
8c13ee2411 C# std::complex wrappers SwigValueWrapper fix
Fix std::complex constructor declaration to stop SwigValueWrapper from
being generated
2017-05-19 07:10:43 +01:00
William S Fulton
bb758d7810 Use %naturalvar for C# std::complex wrappers 2017-05-19 06:58:54 +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
ab1e9f5bd9 Consistent whitespace amongst all the shared_ptr and intrusive_ptr typemaps
[skip ci]
2017-04-20 19:21:47 +01:00
Vadim Zeitlin
03f229b314 Allow avoiding generation of unwanted std::complex<T> typemaps
In many cases, only one of std::complex<double> and std::complex<float> is
used, so while we continue to define typemaps for both by default, for
compatibility with the other modules, add a possibility to avoid generating
the code for the unwanted specialization by predefining the corresponding
SWIG_NO_STD_COMPLEX_$TYPE before including this file.
2017-04-15 20:28:30 +02:00
Vadim Zeitlin
95aa3d9389 Also apply csvar{in,out} typemaps to std::complex references
This is needed to handle the artificial complex-valued properties created
using %naturalvar correctly.
2017-04-15 20:18:24 +02:00
Vadim Zeitlin
485efd511f Add std_complex.i for C# too
For consistency with the other modules (Python, Ruby and JS), allow including
<std_complex.i> directly when using C# too instead of including <complex.i>
which only works in C++ mode (i.e. when using std::complex) anyhow with C# for
now.
2017-04-14 19:23:31 +02:00
Vadim Zeitlin
ec565f74cf Extend C# complex support to member variables of this type
Define csvar{in,out} typemaps needed to support properties of complex type and
apply the existing cstype and csin ones to them as well.

Add unit test verifying that this works as expected in C# and, also, in
Python, even though no changes were needed there.
2017-04-01 23:51:45 +02:00
Vadim Zeitlin
aa047c43f7 Add support for std::complex<> to C#
Create Lib/csharp/complex.i with simplest possible typemaps mapping
std::complex<> to System.Numerics.Complex.
2017-04-01 23:51:45 +02:00
William S Fulton
279744603f Merge branch 'vadz-use-cstype-vector-typemap'
* vadz-use-cstype-vector-typemap:
  Don't hardcode C# type corresponding to size_t in vector typemaps
2017-03-24 07:29:41 +00:00
William S Fulton
72ba741d1c Fix wrapping of references/pointers and qualifiers to member pointers
Also fix Go wrapping of member const function pointers.
2017-03-16 21:04:38 +00:00
Vadim Zeitlin
bf11d5ee7a Don't hardcode C# type corresponding to size_t in vector typemaps
The C# type corresponding to size_t may be changed by redefining its "cstype"
type typemap, but this broke compilation of the code using std::vector<> as
the typemap generating it assumed that size_t was always represented by uint
in C#. Make this work in all cases by explicitly looking up cstype of size_t
instead.

Notice that it may be quite useful, and even necessary, to map size_t to int
as when generating C# assembly for use with COM, via .NET interop, as some COM
clients, notably VBA-using ones, including all Microsoft Office applications,
don't support unsigned types and can't call methods using or returning uint in
C# at all.
2017-03-15 23:17:03 +01:00
Jean-Claude Manoli
18ac3030df Replace ICollection with IEnumerable<T>
Adding a constructor that accepts IEnumerable<T> avoids the boxing and unboxing overhead of the original constructor, when the type parameter is a value type. This also allows passing IList<T>, which does not implement ICollection (ironically the generated type implements IList<T>).

Kept the original constructor for backward compatibility, but replaced ICollection with IEnumerable for added flexibility.
2017-02-05 08:02:14 +01:00
William S Fulton
449aa08124 %extend changes and remove default use of javatype, dtype, cstype %typemaps
1) The %extend directive can now optionally support one of the 'class', 'struct' or 'union'.
2) The SWIG library no longer uses the javatype, dtype or cstype typemaps, thereby
   completely freeing them up for users to use without having to replicate the library
   code that they previously added

Tested by changes to test: java_lib_arrays
2017-01-15 16:50:24 +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
d48b1712a8 Merge branch 'myd7349-master'
* myd7349-master:
  Convert the Java runtime testcase cpp11_li_std_array_runme to C#
  Add C++11 std::array interface file for C#
  SWIG_STD_VECTOR_ENHANCED for std::wstring
2016-10-30 22:27:47 +00:00
William S Fulton
e9e6a99f0f Add missing VOID_INT_PTR director typemaps 2016-10-23 16:18:05 +01:00
Daniel Vollmer
ce1cb85d86 Add <typeinfo> header for std::bad_cast 2016-09-17 13:24:32 +02:00
Daniel Vollmer
2dc87d7485 Add std::bad_cast to std_except.i
This exception occurs when dynamic_cast<T&> fails.

Fixes #783.
2016-09-17 10:26:54 +02:00
Heinrich Schuchardt
073948777e Csharp: CLS compliance - keyword rename
SWIG C# can be used to wrap native libraries as common language
interface compatible assemblies.
If you want to use the assemblies with other languages like
Visual Basic these assemblies should comply to the
Common Language Specification (CLS).

Lib/csharp/csharpkw.swg defines rename rules to avoid collisions
with keywords. Unfortunately these rules prepend an underscore.
Parameters starting with underscores are not CLS compliant.

Hence the rules should be changed to append the underscore
instead of prepending it.

Tested with
make check-csharp-test-suite

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: Olly Betts <olly@survex.com>
2016-09-09 16:40:18 +02:00
myd7349
b1151b34f2 Add C++11 std::array interface file for C# 2016-07-05 10:41:59 +08:00
myd7349
46791437a4 SWIG_STD_VECTOR_ENHANCED for std::wstring 2016-07-04 14:28:46 +08:00
William S Fulton
06c47fbcdc Correct file format to unix 2016-05-28 00:45:24 +01:00
William S Fulton
ff21a0bca9 Remove unused variables from C# boost::intrusive_ptr wrappers 2016-05-28 00:45:24 +01:00
William S Fulton
98a31ff633 Fix directorin SWIGTYPE typemaps to make a copy as these are used for pass by value.
Closes #434
2016-05-14 21:32:24 +01:00
William S Fulton
dc4e0ab0f6 interface macro argument name tweaks 2016-03-11 19:47:08 +00:00
William S Fulton
e1dfad1a3b Change the name of the interface in %feature to be more portable
Use SwigInterface as a suffix to the class name when naming the
interface class instead of using a simple I as a prefix.
%feature_custom can be used to use I as a prefix if so desired.
2016-03-08 08:42:16 +00:00
William S Fulton
5cf20086a4 Rename feature_interface.i to swiginterface.i 2016-03-03 08:55:20 +00:00
William S Fulton
7f3f8fd76a Use rstrip instead of regex encoder in %feature_rename
The regex encoder is not always available in SWIG builds.
2016-03-03 08:55:10 +00:00
William S Fulton
3000824c94 Interface macros: %interface %interface_impl %interface_custom 2016-03-02 07:10:58 +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
Vladimir Kalinin
1ba81241d7 IntPtr & HandleRef absolute names used 2016-02-14 03:09:12 +03:00
William S Fulton
abccc13a4a Merge branch 'interfaces' into interfaces2
* interfaces:
  Remove unnecessary interfaces for concrete classes
  cosmetic code formatting changes
  Correct interface name attributes that are internal
  interface macro changes to support templates
  Test non-virtual method in Derived classes
  interface tests for a most derived class inheriting the interfaces further up the chain
  Rename GetCPtr/getCPtr to SWIGInterfaceUpcast
  interface feature support for const ref pointers (used by the STL)
  Interface feature support for arrays
  More interface feature testing for return values
  interface feature support for passing by value
  interface feature support for references
  Multiple inheritance parameters as pointers testing
  Simplify multiple_inheritance_abstract Java runtime test
  Warning fixes
  Rename test functions in multiple_inheritance_abstract testcase
  Formatting fixes in generated code for interface feature
  Cosmetic spacing changes in test case
  interface feature typemap corrections to handle NULL pointers
  interface test added
  javadirectorin fix
  interface implementation visibility
  interface inheritance (2)
  interface inheritance (1)
  feature:interface ported to Java
  propagate non-abstract "interface" base methods (3)
  propagate non-abstract "interface" base methods (2)
  propagate non-abstract "interface" base methods (1)
  namespace support added GetCPtr now returns HandleRef "feature:interface:name" is now mandatory attribute
  interfaces (1)
  interfaces (1)

Conflicts:
	Source/Modules/csharp.cxx
	Source/Modules/java.cxx
2016-02-11 19:37:31 +00:00
William S Fulton
f82efac231 interface macro changes to support templates
The C++ type must be last in the argument list to support templates with
multiple arguments which are separated by commas.
Affects DECLARE_INTERFACE and DECLARE_INTERFACE_RENAME.
2016-02-09 07:02:42 +00:00
William S Fulton
72e5c221b6 Rename GetCPtr/getCPtr to SWIGInterfaceUpcast
This is then similarly named to other similar functions:
SWIGUpcast and SWIGSmartPtrUpcast
2016-02-08 20:49:46 +00:00
William S Fulton
e8907132cc interface feature support for const ref pointers (used by the STL)
Also interface feature return by value fixes
2016-02-07 13:58:47 +00:00
William S Fulton
5b86e2af13 Interface feature support for arrays 2016-02-06 20:15:48 +00:00
William S Fulton
a1f2d60535 interface feature support for passing by value
Also add in missing $owner for governing ownership when returning pointers and references
2016-02-06 20:15:40 +00:00
William S Fulton
a7370b7bc0 Formatting fixes in generated code for interface feature 2016-02-06 16:34:24 +00:00
William S Fulton
236822b488 Warning fixes in generated C# code for 64bit Visual C++ on Windows. 2015-07-03 20:59:24 +01:00
William S Fulton
fd8dcf44bf C++11 strongly typed enum fixes for directors
Tests added for previous commit. Further refinements to patch #308 and
fixes #307.
2015-01-15 19:48:07 +00:00