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.
This commit is contained in:
Vadim Zeitlin 2017-09-19 13:54:41 +02:00
commit db65ae5aea
371 changed files with 9815 additions and 3191 deletions

View file

@ -14,7 +14,7 @@
%naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
// destructor mods
%feature("unref") TYPE
%feature("unref") TYPE
//"if (debug_shared) { cout << \"deleting use_count: \" << (*smartarg1).use_count() << \" [\" << (boost::get_deleter<SWIG_null_deleter>(*smartarg1) ? std::string(\"CANNOT BE DETERMINED SAFELY\") : ( (*smartarg1).get() ? (*smartarg1)->getValue() : std::string(\"NULL PTR\") )) << \"]\" << endl << flush; }\n"
"(void)arg1; delete smartarg1;"
@ -28,7 +28,7 @@
return $null;
}
$1 = *argp; %}
%typemap(out) CONST TYPE
%typemap(out) CONST TYPE
%{ $result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); %}
// plain pointer
@ -66,7 +66,7 @@
%typemap(in, canthrow=1) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & ($*1_ltype tempnull)
%{ $1 = $input ? ($1_ltype)$input : &tempnull; %}
%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &
%{ $result = *$1 ? new $*1_ltype(*$1) : 0; %}
%{ $result = *$1 ? new $*1_ltype(*$1) : 0; %}
// shared_ptr by pointer
%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * ($*1_ltype tempnull)
@ -80,7 +80,7 @@
%{ temp = $input ? *($1_ltype)&$input : &tempnull;
$1 = &temp; %}
%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *&
%{ *($1_ltype)&$result = (*$1 && **$1) ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(**$1) : 0; %}
%{ *($1_ltype)&$result = (*$1 && **$1) ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(**$1) : 0; %}
// various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug
%typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
@ -91,20 +91,20 @@
%}
%typemap (ctype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
%typemap (ctype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &,
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *,
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "void *"
%typemap (imtype, out="global::System.IntPtr") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
%typemap (imtype, out="global::System.IntPtr") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &,
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *,
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "global::System.Runtime.InteropServices.HandleRef"
%typemap (cstype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
%typemap (cstype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &,
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *,
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "$typemap(cstype, TYPE)"
%typemap(csin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
%typemap(csin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &,
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *,
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "$typemap(cstype, TYPE).getCPtr($csinput)"

5
Lib/csharp/complex.i Normal file
View file

@ -0,0 +1,5 @@
#ifdef __cplusplus
%include <std_complex.i>
#else
#error C# module only supports complex in C++ mode.
#endif

View file

@ -843,6 +843,13 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
$*csclassname ret = (cPtr == global::System.IntPtr.Zero) ? null : new $*csclassname(cPtr, $owner);$excode
return ret;
}
%typemap(csvarout, excode=SWIGEXCODE) SWIGTYPE *const& %{
get {
global::System.IntPtr cPtr = $imcall;
$*csclassname ret = (cPtr == global::System.IntPtr.Zero) ? null : new $*csclassname(cPtr, $owner);$excode
return ret;
} %}
%typemap(in) SWIGTYPE *const& ($*1_ltype temp = 0)
%{ temp = ($*1_ltype)$input;
$1 = ($1_ltype)&temp; %}
@ -1011,6 +1018,8 @@ SWIG_CSBODY_TYPEWRAPPER(internal, protected, internal, SWIGTYPE)
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }
%apply SWIGTYPE (CLASS::*) { SWIGTYPE (CLASS::*const) }
%apply SWIGTYPE & { SWIGTYPE (CLASS::*const&) }
/* csharp keywords */
%include <csharpkw.swg>

View file

@ -41,6 +41,10 @@ namespace Swig {
public:
DirectorPureVirtualException(const char *msg) : DirectorException(std::string("Attempt to invoke pure virtual method ") + msg) {
}
static void raise(const char *msg) {
throw DirectorPureVirtualException(msg);
}
};
}

View file

@ -174,7 +174,7 @@
bool empty() const;
%rename(Fill) fill;
void fill(const value_type& val);
void fill(const value_type& value);
%rename(Swap) swap;
void swap(array& other);
@ -192,9 +192,9 @@
else
throw std::out_of_range("index");
}
void setitem(int index, const_reference val) throw (std::out_of_range) {
void setitem(int index, const_reference value) throw (std::out_of_range) {
if (index>=0 && index<(int)$self->size())
(*$self)[index] = val;
(*$self)[index] = value;
else
throw std::out_of_range("index");
}

92
Lib/csharp/std_complex.i Normal file
View file

@ -0,0 +1,92 @@
/* -----------------------------------------------------------------------------
* std_complex.i
*
* Typemaps for handling std::complex<float> and std::complex<double> as a .NET
* System.Numerics.Complex type. Requires .NET 4 minimum.
* ----------------------------------------------------------------------------- */
%{
#include <complex>
%}
%fragment("SwigSystemNumericsComplex", "header") {
extern "C" {
// Identical to the layout of System.Numerics.Complex, but does assume that it is
// LayoutKind.Sequential on the managed side
struct SwigSystemNumericsComplex {
double real;
double imag;
};
}
SWIGINTERN SwigSystemNumericsComplex SwigCreateSystemNumericsComplex(double real, double imag) {
SwigSystemNumericsComplex cpx;
cpx.real = real;
cpx.imag = imag;
return cpx;
}
}
namespace std {
%naturalvar complex;
template<typename T>
class complex
{
public:
complex(T re = T(), T im = T());
};
}
%define SWIG_COMPLEX_TYPEMAPS(T)
%typemap(ctype, fragment="SwigSystemNumericsComplex") std::complex<T>, const std::complex<T> & "SwigSystemNumericsComplex"
%typemap(imtype) std::complex<T>, const std::complex<T> & "System.Numerics.Complex"
%typemap(cstype) std::complex<T>, const std::complex<T> & "System.Numerics.Complex"
%typemap(in) std::complex<T>($*1_ltype temp), const std::complex<T> &($*1_ltype temp)
%{temp = std::complex< double >($input.real, $input.imag);
$1 = &temp;%}
%typemap(out, null="SwigCreateSystemNumericsComplex(0.0, 0.0)") std::complex<T>
%{$result = SwigCreateSystemNumericsComplex($1.real(), $1.imag());%}
%typemap(out, null="SwigCreateSystemNumericsComplex(0.0, 0.0)") const std::complex<T> &
%{$result = SwigCreateSystemNumericsComplex($1->real(), $1->imag());%}
%typemap(cstype) std::complex<T>, const std::complex<T> & "System.Numerics.Complex"
%typemap(csin) std::complex<T>, const std::complex<T> & "$csinput"
%typemap(csout, excode=SWIGEXCODE) std::complex<T>, const std::complex<T> & {
System.Numerics.Complex ret = $imcall;$excode
return ret;
}
%typemap(csvarin, excode=SWIGEXCODE2) const std::complex<T> & %{
set {
$imcall;$excode
}
%}
%typemap(csvarout, excode=SWIGEXCODE2) const std::complex<T> & %{
get {
System.Numerics.Complex ret = $imcall;$excode
return ret;
}
%}
%template() std::complex<T>;
%enddef
// By default, typemaps for both std::complex<double> and std::complex<float>
// are defined, but one of them can be disabled by predefining the
// corresponding symbol before including this file.
#ifndef SWIG_NO_STD_COMPLEX_DOUBLE
SWIG_COMPLEX_TYPEMAPS(double)
#endif
#ifndef SWIG_NO_STD_COMPLEX_FLOAT
SWIG_COMPLEX_TYPEMAPS(float)
#endif

View file

@ -4,14 +4,14 @@
* SWIG typemaps for std::map< K, T, C >
*
* The C# wrapper is made to look and feel like a C# System.Collections.Generic.IDictionary<>.
*
*
* Using this wrapper is fairly simple. For example, to create a map from integers to doubles use:
*
* %include <std_map.i>
* %template(MapIntDouble) std::map<int, double>
*
* Notes:
* 1) IEnumerable<> is implemented in the proxy class which is useful for using LINQ with
* 1) IEnumerable<> is implemented in the proxy class which is useful for using LINQ with
* C++ std::map wrappers.
*
* Warning: heavy macro usage in this file. Use swig -E to get a sane view on the real file contents!
@ -55,8 +55,8 @@
}
public bool IsReadOnly {
get {
return false;
get {
return false;
}
}
@ -84,7 +84,7 @@
return vals;
}
}
public void Add(global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> item) {
Add(item.Key, item.Value);
}
@ -143,7 +143,7 @@
/// whenever the collection is modified. This has been done for changes in the size of the
/// collection but not when one of the elements of the collection is modified as it is a bit
/// tricky to detect unmanaged code that modifies the collection under our feet.
public sealed class $csclassnameEnumerator : global::System.Collections.IEnumerator,
public sealed class $csclassnameEnumerator : global::System.Collections.IEnumerator,
global::System.Collections.Generic.IEnumerator<global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>>
{
private $csclassname collectionRef;
@ -206,7 +206,7 @@
currentObject = null;
}
}
%}
public:
@ -239,11 +239,11 @@
return iter != $self->end();
}
void Add(const key_type& key, const mapped_type& val) throw (std::out_of_range) {
void Add(const key_type& key, const mapped_type& value) throw (std::out_of_range) {
std::map< K, T, C >::iterator iter = $self->find(key);
if (iter != $self->end())
throw std::out_of_range("key already exists");
$self->insert(std::pair< K, T >(key, val));
$self->insert(std::pair< K, T >(key, value));
}
bool Remove(const key_type& key) {
@ -251,7 +251,7 @@
if (iter != $self->end()) {
$self->erase(iter);
return true;
}
}
return false;
}
@ -285,12 +285,12 @@
%csmethodmodifiers std::map::destroy_iterator "private"
// Default implementation
namespace std {
namespace std {
template<class K, class T, class C = std::less<K> > class map {
SWIG_STD_MAP_INTERNAL(K, T, C)
};
}
// Legacy macros (deprecated)
%define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO)

View file

@ -5,9 +5,9 @@
* C# implementation
* The C# wrapper is made to look and feel like a C# System.Collections.Generic.List<> collection.
*
* Note that IEnumerable<> is implemented in the proxy class which is useful for using LINQ with
* Note that IEnumerable<> is implemented in the proxy class which is useful for using LINQ with
* C++ std::vector wrappers. The IList<> interface is also implemented to provide enhanced functionality
* whenever we are confident that the required C++ operator== is available. This is the case for when
* whenever we are confident that the required C++ operator== is available. This is the case for when
* T is a primitive type or a pointer. If T does define an operator==, then use the SWIG_STD_VECTOR_ENHANCED
* macro to obtain this enhanced functionality, for example:
*
@ -26,7 +26,15 @@
%define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CSINTERFACE, CONST_REFERENCE, CTYPE...)
%typemap(csinterfaces) std::vector< CTYPE > "global::System.IDisposable, global::System.Collections.IEnumerable\n , global::System.Collections.Generic.CSINTERFACE<$typemap(cstype, CTYPE)>\n";
%proxycode %{
public $csclassname(global::System.Collections.ICollection c) : this() {
public $csclassname(global::System.Collections.IEnumerable c) : this() {
if (c == null)
throw new global::System.ArgumentNullException("c");
foreach ($typemap(cstype, CTYPE) element in c) {
this.Add(element);
}
}
public $csclassname(global::System.Collections.Generic.IEnumerable<$typemap(cstype, CTYPE)> c) : this() {
if (c == null)
throw new global::System.ArgumentNullException("c");
foreach ($typemap(cstype, CTYPE) element in c) {
@ -62,7 +70,7 @@
set {
if (value < size())
throw new global::System.ArgumentOutOfRangeException("Capacity");
reserve((uint)value);
reserve(($typemap(cstype, size_t))value);
}
}
@ -223,9 +231,9 @@
else
throw std::out_of_range("index");
}
void setitem(int index, CTYPE const& val) throw (std::out_of_range) {
void setitem(int index, CTYPE const& value) throw (std::out_of_range) {
if (index>=0 && index<(int)$self->size())
(*$self)[index] = val;
(*$self)[index] = value;
else
throw std::out_of_range("index");
}
@ -324,7 +332,7 @@
std::vector< CTYPE >::iterator it = std::find($self->begin(), $self->end(), value);
if (it != $self->end()) {
$self->erase(it);
return true;
return true;
}
return false;
}