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

@ -232,6 +232,8 @@ $body)"
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }
%apply SWIGTYPE (CLASS::*) { SWIGTYPE (CLASS::*const) }
%apply SWIGTYPE & { SWIGTYPE (CLASS::*const&) }
/* name conversion for overloaded operators. */
#ifdef __cplusplus

View file

@ -136,6 +136,8 @@
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }
%apply SWIGTYPE (CLASS::*) { SWIGTYPE (CLASS::*const) }
%apply SWIGTYPE & { SWIGTYPE (CLASS::*const&) }
%{

View file

@ -716,6 +716,8 @@ $result = C_SCHEME_UNDEFINED;
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }
%apply SWIGTYPE (CLASS::*) { SWIGTYPE (CLASS::*const) }
%apply SWIGTYPE & { SWIGTYPE (CLASS::*const&) }
/* ------------------------------------------------------------
* Overloaded operator support

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;
}

View file

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

View file

@ -43,6 +43,8 @@
return ret;
}
%apply SWIGTYPE (CLASS::*) { SWIGTYPE (CLASS::*const) }
%apply SWIGTYPE & { SWIGTYPE (CLASS::*const&) }
/*
* Helper functions to pack/unpack arbitrary binary data (member function

View file

@ -162,7 +162,7 @@
return ret;
}
// Treat references to arrays like like references to a single element.
// Treat references to arrays like references to a single element.
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }

View file

@ -16,44 +16,41 @@
#include <stdexcept>
%}
// exported class
namespace std {
template<class K, class T> class map {
// add typemaps here
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef K key_type;
typedef T mapped_type;
map();
map(const map<K,T> &);
template<class K, class T> class map {
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef K key_type;
typedef T mapped_type;
map();
map(const map<K,T> &);
unsigned int size() const;
bool empty() const;
void clear();
%extend {
const T& get(const K& key) throw (std::out_of_range) {
std::map<K,T >::iterator i = self->find(key);
if (i != self->end())
return i->second;
else
throw std::out_of_range("key not found");
}
void set(const K& key, const T& x) {
(*self)[key] = x;
}
void del(const K& key) throw (std::out_of_range) {
std::map<K,T >::iterator i = self->find(key);
if (i != self->end())
self->erase(i);
else
throw std::out_of_range("key not found");
}
bool has_key(const K& key) {
std::map<K,T >::iterator i = self->find(key);
return i != self->end();
}
unsigned int size() const;
bool empty() const;
void clear();
%extend {
const T& get(const K& key) throw (std::out_of_range) {
std::map<K,T >::iterator i = self->find(key);
if (i != self->end())
return i->second;
else
throw std::out_of_range("key not found");
}
};
void set(const K& key, const T& x) {
(*self)[key] = x;
}
void del(const K& key) throw (std::out_of_range) {
std::map<K,T >::iterator i = self->find(key);
if (i != self->end())
self->erase(i);
else
throw std::out_of_range("key not found");
}
bool has_key(const K& key) {
std::map<K,T >::iterator i = self->find(key);
return i != self->end();
}
}
};
}

View file

@ -165,11 +165,11 @@ public void capacity(size_t value) {
// generation issue when using const pointers as vector elements (like
// std::vector< const int* >).
%extend {
void setElement(size_type index, CTYPE const& val) throw (std::out_of_range) {
void setElement(size_type index, CTYPE const& value) throw (std::out_of_range) {
if ((index < 0) || ($self->size() <= index)) {
throw std::out_of_range("Tried to set value of element with invalid index.");
}
(*$self)[index] = val;
(*$self)[index] = value;
}
}
@ -517,11 +517,11 @@ int opApply(int delegate(ref size_t index, ref $typemap(dtype, CTYPE) value) dg)
// generation issue when using const pointers as vector elements (like
// std::vector< const int* >).
%extend {
void setElement(size_type index, CTYPE const& val) throw (std::out_of_range) {
void setElement(size_type index, CTYPE const& value) throw (std::out_of_range) {
if ((index < 0) || ($self->size() <= index)) {
throw std::out_of_range("Tried to set value of element with invalid index.");
}
(*$self)[index] = val;
(*$self)[index] = value;
}
}

View file

@ -341,8 +341,6 @@
%typemap(directorout) SWIGTYPE *
%{ $result = *($&1_ltype)&$input; %}
%apply SWIGTYPE * { SWIGTYPE *const }
/* Pointer references. */
%typemap(gotype) SWIGTYPE *const&
@ -692,6 +690,10 @@
SWIGTYPE (CLASS::*)
""
%apply SWIGTYPE * { SWIGTYPE *const }
%apply SWIGTYPE (CLASS::*) { SWIGTYPE (CLASS::*const) }
%apply SWIGTYPE & { SWIGTYPE (CLASS::*const&) }
/* Go keywords. */
%include <gokw.swg>

View file

@ -468,5 +468,7 @@ typedef unsigned long SCM;
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }
%apply SWIGTYPE (CLASS::*) { SWIGTYPE (CLASS::*const) }
%apply SWIGTYPE & { SWIGTYPE (CLASS::*const&) }
/* typemaps.i ends here */

View file

@ -29,26 +29,26 @@
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null $1_type");
return $null;
}
$1 = *argp;
$1 = *argp;
%}
%typemap(out, fragment="SWIG_intrusive_deleter") CONST TYPE %{
%typemap(out, fragment="SWIG_intrusive_deleter") CONST TYPE %{
//plain value(out)
$1_ltype* resultp = new $1_ltype(($1_ltype &)$1);
intrusive_ptr_add_ref(resultp);
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(resultp, SWIG_intrusive_deleter< CONST TYPE >());
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(resultp, SWIG_intrusive_deleter< CONST TYPE >());
%}
%typemap(in) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
// plain pointer
smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input;
$1 = (TYPE *)(smartarg ? smartarg->get() : 0);
$1 = (TYPE *)(smartarg ? smartarg->get() : 0);
%}
%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE * %{
//plain pointer(out)
#if ($owner)
if ($1) {
intrusive_ptr_add_ref($1);
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1, SWIG_intrusive_deleter< CONST TYPE >());
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1, SWIG_intrusive_deleter< CONST TYPE >());
} else {
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
}
@ -63,70 +63,70 @@
if(!$1) {
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null");
return $null;
}
}
%}
%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE & %{
%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE & %{
//plain reference(out)
#if ($owner)
if ($1) {
intrusive_ptr_add_ref($1);
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1, SWIG_intrusive_deleter< CONST TYPE >());
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1, SWIG_intrusive_deleter< CONST TYPE >());
} else {
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
}
}
#else
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0;
#endif
%}
%typemap(in) TYPE *CONST& ($*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
%typemap(in) TYPE *CONST& ($*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
// plain pointer by reference
temp = ($*1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0);
$1 = &temp;
$1 = &temp;
%}
%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") TYPE *CONST& %{
%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") TYPE *CONST& %{
// plain pointer by reference(out)
#if ($owner)
if (*$1) {
intrusive_ptr_add_ref(*$1);
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1, SWIG_intrusive_deleter< CONST TYPE >());
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1, SWIG_intrusive_deleter< CONST TYPE >());
} else {
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
}
}
#else
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_0);
#endif
%}
%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > ($&1_type argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > ($&1_type argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
// intrusive_ptr by value
smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
if (smartarg) {
$1 = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true);
$1 = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true);
}
%}
%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > %{
%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > %{
if ($1) {
intrusive_ptr_add_ref(result.get());
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(result.get(), SWIG_intrusive_deleter< CONST TYPE >());
} else {
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
}
%}
%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{
// shared_ptr by value
smartarg = *($&1_ltype*)&$input;
if (smartarg) $1 = *smartarg;
smartarg = *($&1_ltype*)&$input;
if (smartarg) $1 = *smartarg;
%}
%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ANY_TYPE_SWIGSharedPtrUpcast %{
*($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0;
%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ANY_TYPE_SWIGSharedPtrUpcast %{
*($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0;
%}
%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & ($*1_ltype tempnull, $*1_ltype temp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & ($*1_ltype tempnull, $*1_ltype temp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
// intrusive_ptr by reference
if ( $input ) {
smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true);
$1 = &temp;
} else {
@ -140,21 +140,21 @@
$1 = *temp;
}
%}
%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & %{
%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & %{
if (*$1) {
intrusive_ptr_add_ref($1->get());
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1->get(), SWIG_intrusive_deleter< CONST TYPE >());
} else {
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
}
%}
%}
%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * ($*1_ltype tempnull, $*1_ltype temp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * ($*1_ltype tempnull, $*1_ltype temp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
// intrusive_ptr by pointer
if ( $input ) {
smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true);
$1 = &temp;
$1 = &temp;
} else {
$1 = &tempnull;
}
@ -163,17 +163,17 @@
delete $1;
if ($self) $1 = new SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(*$input);
%}
%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * %{
%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * %{
if ($1 && *$1) {
intrusive_ptr_add_ref($1->get());
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1->get(), SWIG_intrusive_deleter< CONST TYPE >());
} else {
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
}
if ($owner) delete $1;
if ($owner) delete $1;
%}
%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& (SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > temp, $*1_ltype tempp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& (SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > temp, $*1_ltype tempp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
// intrusive_ptr by pointer reference
smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
if ($input) {
@ -185,14 +185,14 @@
%typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& %{
if ($self) $1 = *$input;
%}
%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& %{
%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& %{
if (*$1 && **$1) {
intrusive_ptr_add_ref((*$1)->get());
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >((*$1)->get(), SWIG_intrusive_deleter< CONST TYPE >());
} else {
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 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::*) %{
@ -208,7 +208,7 @@
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *,
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "jlong"
%typemap (jtype) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >,
%typemap (jtype) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >,
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *,
@ -341,7 +341,7 @@
return $null;
}
$1 = *argp; %}
%typemap(out) CONST TYPE
%typemap(out) CONST TYPE
%{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); %}
// plain pointer
@ -371,11 +371,11 @@
%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{
// shared_ptr by value
smartarg = *($&1_ltype*)&$input;
if (smartarg) $1 = *smartarg;
smartarg = *($&1_ltype*)&$input;
if (smartarg) $1 = *smartarg;
%}
%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ANY_TYPE_SWIGSharedPtrUpcast %{
*($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0;
%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ANY_TYPE_SWIGSharedPtrUpcast %{
*($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0;
%}
// various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug

View file

@ -14,7 +14,7 @@
%naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
// destructor wrapper customisation
%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
%{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); %}
// plain pointer
@ -58,7 +58,7 @@
// shared_ptr by value
%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ($&1_type argp)
%{ argp = *($&1_ltype*)&$input;
%{ argp = *($&1_ltype*)&$input;
if (argp) $1 = *argp; %}
%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >
%{ *($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0; %}
@ -67,7 +67,7 @@
%typemap(in) 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 > &
%{ *($&1_ltype)&$result = *$1 ? new $*1_ltype(*$1) : 0; %}
%{ *($&1_ltype)&$result = *$1 ? new $*1_ltype(*$1) : 0; %}
// shared_ptr by pointer
%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * ($*1_ltype tempnull)
@ -81,7 +81,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::*) %{
@ -92,20 +92,20 @@
%}
%typemap (jni) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
%typemap (jni) 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 > *& "jlong"
%typemap (jtype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
%typemap (jtype) 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 > *& "long"
%typemap (jstype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
%typemap (jstype) 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(jstype, TYPE)"
%typemap(javain) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
%typemap(javain) 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(jstype, TYPE).getCPtr($javainput)"
@ -156,6 +156,10 @@
CPTR_VISIBILITY static long getCPtr($javaclassname obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}
CPTR_VISIBILITY void swigSetCMemOwn(boolean own) {
swigCMemOwn = own;
}
%}
// Derived proxy classes
@ -172,6 +176,11 @@
CPTR_VISIBILITY static long getCPtr($javaclassname obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}
CPTR_VISIBILITY void swigSetCMemOwn(boolean own) {
swigCMemOwnDerived = own;
super.swigSetCMemOwn(own);
}
%}
%typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized") TYPE {
@ -195,6 +204,26 @@
super.delete();
}
%typemap(directordisconnect, methodname="swigDirectorDisconnect") TYPE %{
protected void $methodname() {
swigSetCMemOwn(false);
$jnicall;
}
%}
%typemap(directorowner_release, methodname="swigReleaseOwnership") TYPE %{
public void $methodname() {
swigSetCMemOwn(false);
$jnicall;
}
%}
%typemap(directorowner_take, methodname="swigTakeOwnership") TYPE %{
public void $methodname() {
swigSetCMemOwn(true);
$jnicall;
}
%}
%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
%enddef

View file

@ -356,6 +356,10 @@ namespace Swig {
}
}
static void raise(JNIEnv *jenv, jthrowable throwable) {
throw DirectorException(jenv, throwable);
}
private:
static char *copypath(const char *srcmsg) {
char *target = copystr(srcmsg);

View file

@ -54,6 +54,14 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
}
}
%fragment("SWIG_JavaIntFromSize_t", "header") {
/* Check for overflow converting to Java int (always signed 32-bit) from (unsigned variable-bit) size_t */
SWIGINTERN jint SWIG_JavaIntFromSize_t(size_t size) {
static const jint JINT_MAX = 0x7FFFFFFF;
return (size > (size_t)JINT_MAX) ? -1 : (jint)size;
}
}
/* Primitive types */
%typemap(jni) bool, const bool & "jboolean"
%typemap(jni) char, const char & "jchar"
@ -103,6 +111,21 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
%typemap(jstype) double, const double & "double"
%typemap(jstype) void "void"
%typemap(jboxtype) bool, const bool & "Boolean"
%typemap(jboxtype) char, const char & "Character"
%typemap(jboxtype) signed char, const signed char & "Byte"
%typemap(jboxtype) unsigned char, const unsigned char & "Short"
%typemap(jboxtype) short, const short & "Short"
%typemap(jboxtype) unsigned short, const unsigned short & "Integer"
%typemap(jboxtype) int, const int & "Integer"
%typemap(jboxtype) unsigned int, const unsigned int & "Long"
%typemap(jboxtype) long, const long & "Integer"
%typemap(jboxtype) unsigned long, const unsigned long & "Long"
%typemap(jboxtype) long long, const long long & "Long"
%typemap(jboxtype) unsigned long long, const unsigned long long & "java.math.BigInteger"
%typemap(jboxtype) float, const float & "Float"
%typemap(jboxtype) double, const double & "Double"
%typemap(jni) char *, char *&, char[ANY], char[] "jstring"
%typemap(jtype) char *, char *&, char[ANY], char[] "String"
%typemap(jstype) char *, char *&, char[ANY], char[] "String"
@ -172,6 +195,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
%typemap(jni) SWIGTYPE "jlong"
%typemap(jtype) SWIGTYPE "long"
%typemap(jstype) SWIGTYPE "$&javaclassname"
%typemap(jboxtype) SWIGTYPE "$typemap(jstype, $1_type)"
%typemap(jni) SWIGTYPE [] "jlong"
%typemap(jtype) SWIGTYPE [] "long"
@ -1260,7 +1284,7 @@ SWIG_JAVABODY_TYPEWRAPPER(protected, protected, protected, SWIGTYPE)
*/
%define SWIG_PROXY_CONSTRUCTOR(OWNERSHIP, WEAKREF, TYPENAME...)
%typemap(javaconstruct,directorconnect="\n $imclassname.$javaclazznamedirector_connect(this, swigCPtr, swigCMemOwn, WEAKREF);") TYPENAME {
%typemap(javaconstruct,directorconnect="\n $imclassname.$javaclazznamedirector_connect(this, swigCPtr, OWNERSHIP, WEAKREF);") TYPENAME {
this($imcall, OWNERSHIP);$directorconnect
}
%enddef
@ -1338,6 +1362,8 @@ SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE)
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }
%apply SWIGTYPE (CLASS::*) { SWIGTYPE (CLASS::*const) }
%apply SWIGTYPE & { SWIGTYPE (CLASS::*const&) }
/* String & length */
%typemap(jni) (char *STRING, size_t LENGTH) "jbyteArray"

View file

@ -8,13 +8,13 @@ namespace std {
template<class T, size_t N> class array {
public:
typedef T& reference;
typedef const T& const_reference;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T value_type;
typedef T* pointer;
typedef const T* const_pointer;
typedef T &reference;
typedef const T &const_reference;
typedef T *pointer;
typedef const T *const_pointer;
array();
array(const array& other);
size_type size() const;
@ -29,10 +29,10 @@ namespace std {
else
throw std::out_of_range("array index out of range");
}
void set(int i, const value_type& val) throw (std::out_of_range) {
void set(int i, const value_type& value) throw (std::out_of_range) {
int size = int(self->size());
if (i>=0 && i<size)
(*self)[i] = val;
(*self)[i] = value;
else
throw std::out_of_range("array index out of range");
}

225
Lib/java/std_list.i Normal file
View file

@ -0,0 +1,225 @@
/* -----------------------------------------------------------------------------
* std_list.i
*
* SWIG typemaps for std::list.
* The Java proxy class extends java.util.AbstractSequentialList. The std::list
* container looks and feels much like a java.util.LinkedList from Java.
* ----------------------------------------------------------------------------- */
%include <std_common.i>
%{
#include <list>
#include <stdexcept>
%}
%fragment("SWIG_ListSize", "header", fragment="SWIG_JavaIntFromSize_t") {
SWIGINTERN jint SWIG_ListSize(size_t size) {
jint sz = SWIG_JavaIntFromSize_t(size);
if (sz == -1)
throw std::out_of_range("list size is too large to fit into a Java int");
return sz;
}
}
%javamethodmodifiers std::list::begin "private";
%javamethodmodifiers std::list::insert "private";
%javamethodmodifiers std::list::doSize "private";
%javamethodmodifiers std::list::doPreviousIndex "private";
%javamethodmodifiers std::list::doNextIndex "private";
%javamethodmodifiers std::list::doHasNext "private";
// Match Java style better:
%rename(Iterator) std::list::iterator;
%nodefaultctor std::list::iterator;
namespace std {
template <typename T> class list {
%typemap(javabase) std::list<T> "java.util.AbstractSequentialList<$typemap(jboxtype, T)>"
%proxycode %{
public $javaclassname(java.util.Collection c) {
this();
java.util.ListIterator<$typemap(jboxtype, T)> it = listIterator(0);
// Special case the "copy constructor" here to avoid lots of cross-language calls
for (Object o : c) {
it.add(($typemap(jboxtype, T))o);
}
}
public int size() {
return doSize();
}
public boolean add($typemap(jboxtype, T) value) {
addLast(value);
return true;
}
public java.util.ListIterator<$typemap(jboxtype, T)> listIterator(int index) {
return new java.util.ListIterator<$typemap(jboxtype, T)>() {
private Iterator pos;
private Iterator last;
private java.util.ListIterator<$typemap(jboxtype, T)> init(int index) {
if (index < 0 || index > $javaclassname.this.size())
throw new IndexOutOfBoundsException("Index: " + index);
pos = $javaclassname.this.begin();
pos = pos.advance_unchecked(index);
return this;
}
public void add($typemap(jboxtype, T) v) {
// Technically we can invalidate last here, but this makes more sense
last = $javaclassname.this.insert(pos, v);
}
public void set($typemap(jboxtype, T) v) {
if (null == last) {
throw new IllegalStateException();
}
last.set_unchecked(v);
}
public void remove() {
if (null == last) {
throw new IllegalStateException();
}
$javaclassname.this.remove(last);
last = null;
}
public int previousIndex() {
return $javaclassname.this.doPreviousIndex(pos);
}
public int nextIndex() {
return $javaclassname.this.doNextIndex(pos);
}
public $typemap(jboxtype, T) previous() {
if (previousIndex() < 0) {
throw new java.util.NoSuchElementException();
}
last = pos;
pos = pos.previous_unchecked();
return last.deref_unchecked();
}
public $typemap(jboxtype, T) next() {
if (!hasNext()) {
throw new java.util.NoSuchElementException();
}
last = pos;
pos = pos.next_unchecked();
return last.deref_unchecked();
}
public boolean hasPrevious() {
// This call to previousIndex() will be much slower than the hasNext() implementation, but it's simpler like this with C++ forward iterators
return previousIndex() != -1;
}
public boolean hasNext() {
return $javaclassname.this.doHasNext(pos);
}
}.init(index);
}
%}
public:
typedef size_t size_type;
typedef T value_type;
typedef T &reference;
/*
* We'd actually be better off having the nested class *not* be static in the wrapper
* output, but this doesn't actually remove the $static from the nested class still.
* (This would allow us to somewhat simplify the implementation of the ListIterator
* interface and give "natural" semantics to Java users of the C++ iterator)
*/
//%typemap(javaclassmodifiers) iterator "public class"
//%typemap(javainterfaces) iterator "java.util.ListIterator<$typemap(jboxtype, T)>"
struct iterator {
%extend {
void set_unchecked(const T &v) {
**$self = v;
}
iterator next_unchecked() const {
std::list<T>::iterator ret = *$self;
++ret;
return ret;
}
iterator previous_unchecked() const {
std::list<T>::iterator ret = *$self;
--ret;
return ret;
}
T deref_unchecked() const {
return **$self;
}
iterator advance_unchecked(size_type index) const {
std::list<T>::iterator ret = *$self;
std::advance(ret, index);
return ret;
}
}
};
list();
list(const list &other);
%rename(isEmpty) empty;
bool empty() const;
void clear();
%rename(remove) erase;
iterator erase(iterator pos);
%rename(removeLast) pop_back;
void pop_back();
%rename(removeFirst) pop_front;
void pop_front();
%rename(addLast) push_back;
void push_back(const T &value);
%rename(addFirst) push_front;
void push_front(const T &value);
iterator begin();
iterator end();
iterator insert(iterator pos, const T &value);
%extend {
%fragment("SWIG_ListSize");
list(jint count) throw (std::out_of_range) {
if (count < 0)
throw std::out_of_range("list count must be positive");
return new std::list<T>(static_cast<std::list<T>::size_type>(count));
}
list(jint count, const T &value) throw (std::out_of_range) {
if (count < 0)
throw std::out_of_range("list count must be positive");
return new std::list<T>(static_cast<std::list<T>::size_type>(count), value);
}
jint doSize() const throw (std::out_of_range) {
return SWIG_ListSize(self->size());
}
jint doPreviousIndex(const iterator &pos) const throw (std::out_of_range) {
return pos == self->begin() ? -1 : SWIG_ListSize(std::distance(self->begin(), static_cast<std::list<T>::const_iterator>(pos)));
}
jint doNextIndex(const iterator &pos) const throw (std::out_of_range) {
return pos == self->end() ? SWIG_ListSize(self->size()) : SWIG_ListSize(std::distance(self->begin(), static_cast<std::list<T>::const_iterator>(pos)));
}
bool doHasNext(const iterator &pos) const {
return pos != $self->end();
}
}
};
}

View file

@ -16,47 +16,44 @@
#include <stdexcept>
%}
// exported class
namespace std {
template<class K, class T> class map {
// add typemaps here
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef K key_type;
typedef T mapped_type;
map();
map(const map<K,T> &);
unsigned int size() const;
bool empty() const;
void clear();
%extend {
const T& get(const K& key) throw (std::out_of_range) {
std::map<K,T >::iterator i = self->find(key);
if (i != self->end())
return i->second;
else
throw std::out_of_range("key not found");
}
void set(const K& key, const T& x) {
(*self)[key] = x;
}
void del(const K& key) throw (std::out_of_range) {
std::map<K,T >::iterator i = self->find(key);
if (i != self->end())
self->erase(i);
else
throw std::out_of_range("key not found");
}
bool has_key(const K& key) {
std::map<K,T >::iterator i = self->find(key);
return i != self->end();
}
template<class K, class T> class map {
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef K key_type;
typedef T mapped_type;
map();
map(const map<K,T> &);
unsigned int size() const;
bool empty() const;
void clear();
%extend {
const T& get(const K& key) throw (std::out_of_range) {
std::map<K,T >::iterator i = self->find(key);
if (i != self->end())
return i->second;
else
throw std::out_of_range("key not found");
}
};
void set(const K& key, const T& x) {
(*self)[key] = x;
}
void del(const K& key) throw (std::out_of_range) {
std::map<K,T >::iterator i = self->find(key);
if (i != self->end())
self->erase(i);
else
throw std::out_of_range("key not found");
}
bool has_key(const K& key) {
std::map<K,T >::iterator i = self->find(key);
return i != self->end();
}
}
};
// Legacy macros (deprecated)
%define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO)

View file

@ -1,5 +1,10 @@
/* -----------------------------------------------------------------------------
* std_vector.i
*
* SWIG typemaps for std::vector.
* The Java proxy class extends java.util.AbstractList and implements
* java.util.RandomAccess. The std::vector container looks and feels much like a
* java.util.ArrayList from Java.
* ----------------------------------------------------------------------------- */
%include <std_common.i>
@ -9,73 +14,171 @@
#include <stdexcept>
%}
namespace std {
template<class T> class vector {
public:
typedef size_t size_type;
typedef T value_type;
typedef const value_type& const_reference;
vector();
vector(size_type n);
size_type size() const;
size_type capacity() const;
void reserve(size_type n);
%rename(isEmpty) empty;
bool empty() const;
void clear();
%rename(add) push_back;
void push_back(const value_type& x);
%extend {
const_reference get(int i) throw (std::out_of_range) {
int size = int(self->size());
if (i>=0 && i<size)
return (*self)[i];
else
throw std::out_of_range("vector index out of range");
}
void set(int i, const value_type& val) throw (std::out_of_range) {
int size = int(self->size());
if (i>=0 && i<size)
(*self)[i] = val;
else
throw std::out_of_range("vector index out of range");
}
%fragment("SWIG_VectorSize", "header", fragment="SWIG_JavaIntFromSize_t") {
SWIGINTERN jint SWIG_VectorSize(size_t size) {
jint sz = SWIG_JavaIntFromSize_t(size);
if (sz == -1)
throw std::out_of_range("vector size is too large to fit into a Java int");
return sz;
}
}
%define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CTYPE, CREF_TYPE)
%typemap(javabase) std::vector< CTYPE > "java.util.AbstractList<$typemap(jboxtype, CTYPE)>"
%typemap(javainterfaces) std::vector< CTYPE > "java.util.RandomAccess"
%proxycode %{
public $javaclassname($typemap(jstype, CTYPE)[] initialElements) {
this();
for ($typemap(jstype, CTYPE) element : initialElements) {
add(element);
}
}
public $javaclassname(Iterable<$typemap(jboxtype, CTYPE)> initialElements) {
this();
for ($typemap(jstype, CTYPE) element : initialElements) {
add(element);
}
}
public $typemap(jboxtype, CTYPE) get(int index) {
return doGet(index);
}
public $typemap(jboxtype, CTYPE) set(int index, $typemap(jboxtype, CTYPE) e) {
return doSet(index, e);
}
public boolean add($typemap(jboxtype, CTYPE) e) {
modCount++;
doAdd(e);
return true;
}
public void add(int index, $typemap(jboxtype, CTYPE) e) {
modCount++;
doAdd(index, e);
}
public $typemap(jboxtype, CTYPE) remove(int index) {
modCount++;
return doRemove(index);
}
protected void removeRange(int fromIndex, int toIndex) {
modCount++;
doRemoveRange(fromIndex, toIndex);
}
public int size() {
return doSize();
}
%}
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef CTYPE value_type;
typedef CTYPE &reference;
typedef CREF_TYPE const_reference;
typedef CTYPE *pointer;
typedef CTYPE const *const_pointer;
vector();
vector(const vector &other);
size_type capacity() const;
void reserve(size_type n) throw (std::length_error);
%rename(isEmpty) empty;
bool empty() const;
void clear();
%extend {
%fragment("SWIG_VectorSize");
vector(jint count) throw (std::out_of_range) {
if (count < 0)
throw std::out_of_range("vector count must be positive");
return new std::vector< CTYPE >(static_cast<std::vector< CTYPE >::size_type>(count));
}
vector(jint count, const CTYPE &value) throw (std::out_of_range) {
if (count < 0)
throw std::out_of_range("vector count must be positive");
return new std::vector< CTYPE >(static_cast<std::vector< CTYPE >::size_type>(count), value);
}
jint doSize() const throw (std::out_of_range) {
return SWIG_VectorSize(self->size());
}
void doAdd(const value_type& value) {
self->push_back(value);
}
void doAdd(jint index, const value_type& value) throw (std::out_of_range) {
const jint size = static_cast<std::vector< CTYPE >::size_type>(self->size());
if (0 <= index && index <= size) {
self->insert(self->begin() + index, value);
} else {
throw std::out_of_range("vector index out of range");
}
}
value_type doRemove(jint index) throw (std::out_of_range) {
const jint size = static_cast<std::vector< CTYPE >::size_type>(self->size());
if (0 <= index && index < size) {
CTYPE const old_value = (*self)[index];
self->erase(self->begin() + index);
return old_value;
} else {
throw std::out_of_range("vector index out of range");
}
}
CREF_TYPE doGet(jint index) throw (std::out_of_range) {
const jint size = static_cast<std::vector< CTYPE >::size_type>(self->size());
if (index >= 0 && index < size)
return (*self)[index];
else
throw std::out_of_range("vector index out of range");
}
value_type doSet(jint index, const value_type& value) throw (std::out_of_range) {
const jint size = static_cast<std::vector< CTYPE >::size_type>(self->size());
if (index >= 0 && index < size) {
CTYPE const old_value = (*self)[index];
(*self)[index] = value;
return old_value;
}
else
throw std::out_of_range("vector index out of range");
}
void doRemoveRange(jint fromIndex, jint toIndex) throw (std::out_of_range) {
const jint size = static_cast<std::vector< CTYPE >::size_type>(self->size());
if (0 <= fromIndex && fromIndex <= toIndex && toIndex <= size) {
self->erase(self->begin() + fromIndex, self->begin() + toIndex);
} else {
throw std::out_of_range("vector index out of range");
}
}
}
%enddef
%javamethodmodifiers std::vector::doSize "private";
%javamethodmodifiers std::vector::doAdd "private";
%javamethodmodifiers std::vector::doGet "private";
%javamethodmodifiers std::vector::doSet "private";
%javamethodmodifiers std::vector::doRemove "private";
%javamethodmodifiers std::vector::doRemoveRange "private";
namespace std {
template<class T> class vector {
SWIG_STD_VECTOR_MINIMUM_INTERNAL(T, const T&)
};
// bool specialization
template<> class vector<bool> {
public:
typedef size_t size_type;
typedef bool value_type;
typedef bool const_reference;
vector();
vector(size_type n);
size_type size() const;
size_type capacity() const;
void reserve(size_type n);
%rename(isEmpty) empty;
bool empty() const;
void clear();
%rename(add) push_back;
void push_back(const value_type& x);
%extend {
bool get(int i) throw (std::out_of_range) {
int size = int(self->size());
if (i>=0 && i<size)
return (*self)[i];
else
throw std::out_of_range("vector index out of range");
}
void set(int i, const value_type& val) throw (std::out_of_range) {
int size = int(self->size());
if (i>=0 && i<size)
(*self)[i] = val;
else
throw std::out_of_range("vector index out of range");
}
}
SWIG_STD_VECTOR_MINIMUM_INTERNAL(bool, bool)
};
}

View file

@ -220,14 +220,14 @@ There are no char *OUTPUT typemaps, however you can apply the signed char * type
{
JNITYPE $1_jvalue;
JCALL4(Get##JAVATYPE##ArrayRegion, jenv, $input, 0, 1, &$1_jvalue);
$result = $1_jvalue;
$result = ($*1_ltype)$1_jvalue;
}
%typemap(directorargout, noblock=1) TYPE *OUTPUT
{
JNITYPE $1_jvalue;
JCALL4(Get##JAVATYPE##ArrayRegion, jenv, $input, 0, 1, &$1_jvalue);
*$result = $1_jvalue;
*$result = ($*1_ltype)$1_jvalue;
}
%typemap(typecheck) TYPE *OUTPUT = TYPECHECKTYPE;
@ -264,6 +264,21 @@ OUTPUT_TYPEMAP(double, jdouble, double, Double, "[D", jdoubleArray);
$1 = &temp;
}
%typemap(directorargout, noblock=1) bool &OUTPUT
{
jboolean $1_jvalue;
JCALL4(GetBooleanArrayRegion, jenv, $input, 0, 1, &$1_jvalue);
$result = $1_jvalue ? true : false;
}
%typemap(directorargout, noblock=1) bool *OUTPUT
{
jboolean $1_jvalue;
JCALL4(GetBooleanArrayRegion, jenv, $input, 0, 1, &$1_jvalue);
*$result = $1_jvalue ? true : false;
}
/* Convert to BigInteger - byte array holds number in 2's complement big endian format */
/* Use first element in BigInteger array for output */
/* Overrides the typemap in the OUTPUT_TYPEMAP macro */
@ -386,13 +401,13 @@ There are no char *INOUT typemaps, however you can apply the signed char * typem
%typemap(directorargout, noblock=1) TYPE &INOUT
{
JCALL4(Get##JAVATYPE##ArrayRegion, jenv, $input, 0, 1, &$1_jvalue);
$result = $1_jvalue;
$result = ($*1_ltype)$1_jvalue;
}
%typemap(directorargout, noblock=1) TYPE *INOUT
{
JCALL4(Get##JAVATYPE##ArrayRegion, jenv, $input, 0, 1, &$1_jvalue);
*$result = $1_jvalue;
*$result = ($*1_ltype)$1_jvalue;
}
%typemap(typecheck) TYPE *INOUT = TYPECHECKTYPE;
@ -436,6 +451,19 @@ INOUT_TYPEMAP(double, jdouble, double, Double, "[D", jdoubleArray);
JCALL3(ReleaseBooleanArrayElements, jenv, $input , (jboolean *)jbtemp$argnum, 0);
}
%typemap(directorargout, noblock=1) bool &INOUT
{
JCALL4(GetBooleanArrayRegion, jenv, $input, 0, 1, &$1_jvalue);
$result = $1_jvalue ? true : false;
}
%typemap(directorargout, noblock=1) bool *INOUT
{
JCALL4(GetBooleanArrayRegion, jenv, $input, 0, 1, &$1_jvalue);
*$result = $1_jvalue ? true : false;
}
/* Override the typemap in the INOUT_TYPEMAP macro for unsigned long long */
%typemap(in) unsigned long long *INOUT ($*1_ltype temp), unsigned long long &INOUT ($*1_ltype temp) {
jobject bigint;

View file

@ -180,7 +180,7 @@ typedef struct swig_elua_entry {
* -------------------------------------------------------------------------- */
/* Push the string STR on the Lua stack, like lua_pushstring, but
prefixed with the the location of the innermost Lua call-point
prefixed with the location of the innermost Lua call-point
(as formated by luaL_where). */
SWIGRUNTIME void
SWIG_Lua_pusherrstring (lua_State *L, const char *str)
@ -191,7 +191,7 @@ SWIG_Lua_pusherrstring (lua_State *L, const char *str)
}
/* Push a formatted string generated from FMT and following args on
the Lua stack, like lua_pushfstring, but prefixed with the the
the Lua stack, like lua_pushfstring, but prefixed with the
location of the innermost Lua call-point (as formated by luaL_where). */
SWIGRUNTIME void
SWIG_Lua_pushferrstring (lua_State *L, const char *fmt, ...)
@ -1860,7 +1860,7 @@ SWIG_Lua_InstallConstants(lua_State *L, swig_lua_const_info constants[]) {
switch(constants[i].type) {
case SWIG_LUA_INT:
lua_pushstring(L,constants[i].name);
lua_pushinteger(L,(lua_Number)constants[i].lvalue);
lua_pushinteger(L,(lua_Integer)constants[i].lvalue);
lua_rawset(L,-3);
break;
case SWIG_LUA_FLOAT:
@ -1871,7 +1871,7 @@ SWIG_Lua_InstallConstants(lua_State *L, swig_lua_const_info constants[]) {
case SWIG_LUA_CHAR:
lua_pushstring(L,constants[i].name);
{
char c = constants[i].lvalue;
char c = (char)constants[i].lvalue;
lua_pushlstring(L,&c,1);
}
lua_rawset(L,-3);

View file

@ -235,7 +235,6 @@ $1=($1_ltype)&temp;%}
// so the standard wrapping cannot be done
// nor can you cast a member function pointer to a void* (obviously)
// therefore a special wrapping functions SWIG_ConvertMember() & SWIG_NewMemberObj() were written
#ifdef __cplusplus
%typemap(in,checkfn="lua_isuserdata") SWIGTYPE (CLASS::*)
%{
if (!SWIG_IsOK(SWIG_ConvertMember(L,$input,(void*)(&$1),sizeof($type),$descriptor)))
@ -246,7 +245,6 @@ $1=($1_ltype)&temp;%}
%{
SWIG_NewMemberObj(L,(void*)(&$1),sizeof($type),$descriptor); SWIG_arg++;
%}
#endif
// void (must be empty without the SWIG_arg++)
@ -386,6 +384,8 @@ parameters match which function
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }
%apply SWIGTYPE (CLASS::*) { SWIGTYPE (CLASS::*const) }
%apply SWIGTYPE & { SWIGTYPE (CLASS::*const&) }
// size_t (which is just a unsigned long)
%apply unsigned long { size_t };

View file

@ -782,4 +782,6 @@ FROM BlaBla IMPORT Bla;
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }
%apply SWIGTYPE (CLASS::*) { SWIGTYPE (CLASS::*const) }
%apply SWIGTYPE & { SWIGTYPE (CLASS::*const&) }

View file

@ -156,4 +156,4 @@ let class_master_list = Hashtbl.create 20
let register_class_byname nm co =
Hashtbl.replace class_master_list nm (Obj.magic co)
let create_class nm arg =
try (Obj.magic (Hashtbl.find class_master_list nm)) arg with _ -> raise (NoSuchClass nm)
try (Obj.magic (Hashtbl.find class_master_list nm)) with _ -> raise (NoSuchClass nm)

View file

@ -368,4 +368,6 @@ SIMPLE_MAP(unsigned long long,caml_val_ulong,caml_long_val);
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }
%apply SWIGTYPE (CLASS::*) { SWIGTYPE (CLASS::*const) }
%apply SWIGTYPE & { SWIGTYPE (CLASS::*const&) }

View file

@ -8,7 +8,7 @@
%naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
// destructor wrapper customisation
%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;"
@ -19,7 +19,7 @@
int newmem = 0;
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
%argument_fail(res, "$type", $symname, $argnum);
}
if (!argp) {
%argument_nullref("$type", $symname, $argnum);
@ -58,7 +58,7 @@
int newmem = 0;
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
%argument_fail(res, "$type", $symname, $argnum);
}
if (newmem & SWIG_CAST_NEW_MEMORY) {
tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
@ -102,7 +102,7 @@
int newmem = 0;
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
%argument_fail(res, "$type", $symname, $argnum);
}
if (!argp) { %argument_nullref("$type", $symname, $argnum); }
if (newmem & SWIG_CAST_NEW_MEMORY) {
@ -148,7 +148,7 @@
int newmem = 0;
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
%argument_fail(res, "$type", $symname, $argnum);
}
if (newmem & SWIG_CAST_NEW_MEMORY) {
tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
@ -176,7 +176,7 @@
int newmem = 0;
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
%argument_fail(res, "$type", $symname, $argnum);
}
if (argp) $1 = *(%reinterpret_cast(argp, $&ltype));
if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $&ltype);
@ -206,7 +206,7 @@
int newmem = 0;
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
%argument_fail(res, "$type", $symname, $argnum);
}
if (newmem & SWIG_CAST_NEW_MEMORY) {
if (argp) tempshared = *%reinterpret_cast(argp, $ltype);
@ -233,7 +233,7 @@
int newmem = 0;
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
%argument_fail(res, "$type", $symname, $argnum);
}
if (newmem & SWIG_CAST_NEW_MEMORY) {
if (argp) tempshared = *%reinterpret_cast(argp, $ltype);
@ -261,7 +261,7 @@
int newmem = 0;
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
%argument_fail(res, "$type", $symname, $argnum);
}
if (argp) tempshared = *%reinterpret_cast(argp, $*ltype);
if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $*ltype);
@ -281,9 +281,9 @@
%}
// Typecheck typemaps
// Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting
// Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting
// function is not called thereby avoiding a possible smart pointer copy constructor call when casting up the inheritance chain.
%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1)
%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1)
TYPE CONST,
TYPE CONST &,
TYPE CONST *,

View file

@ -202,8 +202,8 @@ namespace swig
// swig::SwigVar_PyObject item = OctSequence_GetItem(_seq, _index);
octave_value item; // * todo
try {
return swig::as<T>(item, true);
} catch (std::exception& e) {
return swig::as<T>(item);
} catch (const std::exception& e) {
char msg[1024];
sprintf(msg, "in sequence element %d ", _index);
if (!Octave_Error_Occurred()) {

View file

@ -41,7 +41,7 @@ namespace swig {
template <class Type>
struct traits_asptr {
static int asptr(const octave_value& obj, Type **val) {
Type *p;
Type *p = 0;
swig_type_info *descriptor = type_info<Type>();
int res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
if (SWIG_IsOK(res)) {
@ -103,14 +103,14 @@ namespace swig {
template <class Type>
struct traits_as<Type, value_category> {
static Type as(const octave_value& obj, bool throw_error) {
static Type as(const octave_value& obj) {
Type v;
int res = asval(obj, &v);
if (!obj.is_defined() || !SWIG_IsOK(res)) {
if (!Octave_Error_Occurred()) {
%type_error(swig::type_name<Type>());
}
if (throw_error) throw std::invalid_argument("bad type");
throw std::invalid_argument("bad type");
}
return v;
}
@ -118,7 +118,7 @@ namespace swig {
template <class Type>
struct traits_as<Type, pointer_category> {
static Type as(const octave_value& obj, bool throw_error) {
static Type as(const octave_value& obj) {
Type *v = 0;
int res = traits_asptr<Type>::asptr(obj, &v);
if (SWIG_IsOK(res) && v) {
@ -130,21 +130,17 @@ namespace swig {
return *v;
}
} else {
// Uninitialized return value, no Type() constructor required.
static Type *v_def = (Type*) malloc(sizeof(Type));
if (!Octave_Error_Occurred()) {
%type_error(swig::type_name<Type>());
}
if (throw_error) throw std::invalid_argument("bad type");
memset(v_def,0,sizeof(Type));
return *v_def;
throw std::invalid_argument("bad type");
}
}
};
template <class Type>
struct traits_as<Type*, pointer_category> {
static Type* as(const octave_value& obj, bool throw_error) {
static Type* as(const octave_value& obj) {
Type *v = 0;
int res = traits_asptr<Type>::asptr(obj, &v);
if (SWIG_IsOK(res)) {
@ -153,15 +149,14 @@ namespace swig {
if (!Octave_Error_Occurred()) {
%type_error(swig::type_name<Type>());
}
if (throw_error) throw std::invalid_argument("bad type");
return 0;
throw std::invalid_argument("bad type");
}
}
};
template <class Type>
inline Type as(const octave_value& obj, bool te = false) {
return traits_as<Type, typename traits<Type>::category>::as(obj, te);
inline Type as(const octave_value& obj) {
return traits_as<Type, typename traits<Type>::category>::as(obj);
}
template <class Type>

View file

@ -392,7 +392,7 @@ SWIG_Perl_NewPackedObj(SWIG_MAYBE_PERL_OBJECT void *ptr, int sz, swig_type_info
return result;
}
/* Convert a packed value value */
/* Convert a packed pointer value */
SWIGRUNTIME int
SWIG_Perl_ConvertPacked(SWIG_MAYBE_PERL_OBJECT SV *obj, void *ptr, int sz, swig_type_info *ty) {
swig_cast_info *tc;

View file

@ -134,7 +134,7 @@
%typemap(in) SWIGTYPE *DISOWN
%{
if (SWIG_ConvertPtr(&$input, (void **) &$1, $1_descriptor, SWIG_POINTER_DISOWN ) < 0) {
SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $&1_descriptor");
SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $1_descriptor");
}
%}
@ -525,7 +525,8 @@
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }
%apply SWIGTYPE (CLASS::*) { SWIGTYPE (CLASS::*const) }
%apply SWIGTYPE & { SWIGTYPE (CLASS::*const&) }
/* php keywords */
%include <phpkw.swg>

View file

@ -134,7 +134,7 @@
%typemap(in) SWIGTYPE *DISOWN
{
if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor, SWIG_POINTER_DISOWN ) < 0) {
SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $&1_descriptor");
SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $1_descriptor");
}
}
@ -523,7 +523,8 @@
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }
%apply SWIGTYPE (CLASS::*) { SWIGTYPE (CLASS::*const) }
%apply SWIGTYPE & { SWIGTYPE (CLASS::*const&) }
/* php keywords */
%include <phpkw.swg>

View file

@ -273,6 +273,8 @@ extern "C" {
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }
%apply SWIGTYPE (CLASS::*) { SWIGTYPE (CLASS::*const) }
%apply SWIGTYPE & { SWIGTYPE (CLASS::*const&) }
/* ------------------------------------------------------------
* Overloaded operator support

View file

@ -18,7 +18,7 @@
%naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
// destructor wrapper customisation
%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;"
@ -29,7 +29,7 @@
int newmem = 0;
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
%argument_fail(res, "$type", $symname, $argnum);
}
if (!argp) {
%argument_nullref("$type", $symname, $argnum);
@ -68,7 +68,7 @@
int newmem = 0;
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
%argument_fail(res, "$type", $symname, $argnum);
}
if (newmem & SWIG_CAST_NEW_MEMORY) {
tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
@ -113,7 +113,7 @@
int newmem = 0;
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
%argument_fail(res, "$type", $symname, $argnum);
}
if (!argp) { %argument_nullref("$type", $symname, $argnum); }
if (newmem & SWIG_CAST_NEW_MEMORY) {
@ -159,7 +159,7 @@
int newmem = 0;
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
%argument_fail(res, "$type", $symname, $argnum);
}
if (newmem & SWIG_CAST_NEW_MEMORY) {
tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
@ -187,7 +187,7 @@
int newmem = 0;
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
%argument_fail(res, "$type", $symname, $argnum);
}
if (argp) $1 = *(%reinterpret_cast(argp, $&ltype));
if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $&ltype);
@ -217,7 +217,7 @@
int newmem = 0;
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
%argument_fail(res, "$type", $symname, $argnum);
}
if (newmem & SWIG_CAST_NEW_MEMORY) {
if (argp) tempshared = *%reinterpret_cast(argp, $ltype);
@ -244,7 +244,7 @@
int newmem = 0;
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
%argument_fail(res, "$type", $symname, $argnum);
}
if (newmem & SWIG_CAST_NEW_MEMORY) {
if (argp) tempshared = *%reinterpret_cast(argp, $ltype);
@ -272,7 +272,7 @@
int newmem = 0;
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
%argument_fail(res, "$type", $symname, $argnum);
}
if (argp) tempshared = *%reinterpret_cast(argp, $*ltype);
if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $*ltype);
@ -292,9 +292,9 @@
%}
// Typecheck typemaps
// Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting
// Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting
// function is not called thereby avoiding a possible smart pointer copy constructor call when casting up the inheritance chain.
%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1)
%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1)
TYPE CONST,
TYPE CONST &,
TYPE CONST *,
@ -324,4 +324,3 @@
%enddef

View file

@ -393,10 +393,10 @@ SwigPyStaticVar_new_getset(PyTypeObject *type, PyGetSetDef *getset) {
SWIGINTERN void
SwigPyBuiltin_InitBases (PyTypeObject *type, PyTypeObject **bases) {
int base_count = 0;
Py_ssize_t base_count = 0;
PyTypeObject **b;
PyObject *tuple;
int i;
Py_ssize_t i;
if (!bases[0]) {
bases[0] = SwigPyObject_type();

View file

@ -102,7 +102,7 @@ namespace swig {
}
}
%fragment("SwigPySequence_Base","header",fragment="<stddef.h>")
%fragment("SwigPySequence_Base","header",fragment="<stddef.h>",fragment="StdTraits")
{
%#include <functional>
@ -351,7 +351,7 @@ namespace swig {
typename Sequence::const_iterator isit = is.begin();
typename Sequence::iterator it = self->begin();
std::advance(it,ii);
for (size_t rc=0; rc<replacecount; ++rc) {
for (size_t rc=0; rc<replacecount && it != self->end(); ++rc) {
*it++ = *isit++;
for (Py_ssize_t c=0; c<(step-1) && it != self->end(); ++c)
it++;
@ -367,7 +367,7 @@ namespace swig {
typename Sequence::const_iterator isit = is.begin();
typename Sequence::reverse_iterator it = self->rbegin();
std::advance(it,size-ii-1);
for (size_t rc=0; rc<replacecount; ++rc) {
for (size_t rc=0; rc<replacecount && it != self->rend(); ++rc) {
*it++ = *isit++;
for (Py_ssize_t c=0; c<(-step-1) && it != self->rend(); ++c)
it++;
@ -434,8 +434,8 @@ namespace swig
{
swig::SwigVar_PyObject item = PySequence_GetItem(_seq, _index);
try {
return swig::as<T>(item, true);
} catch (std::exception& e) {
return swig::as<T>(item);
} catch (const std::invalid_argument& e) {
char msg[1024];
sprintf(msg, "in sequence element %d ", (int)_index);
if (!PyErr_Occurred()) {
@ -655,6 +655,14 @@ namespace swig
}
%define %swig_sequence_iterator(Sequence...)
%swig_sequence_iterator_with_making_function(swig::make_output_iterator,Sequence...)
%enddef
%define %swig_sequence_forward_iterator(Sequence...)
%swig_sequence_iterator_with_making_function(swig::make_output_forward_iterator,Sequence...)
%enddef
%define %swig_sequence_iterator_with_making_function(Make_output_iterator,Sequence...)
#if defined(SWIG_EXPORT_ITERATOR_METHODS)
class iterator;
class reverse_iterator;
@ -663,15 +671,15 @@ namespace swig
%typemap(out,noblock=1,fragment="SwigPySequence_Cont")
iterator, reverse_iterator, const_iterator, const_reverse_iterator {
$result = SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &)),
$result = SWIG_NewPointerObj(Make_output_iterator(%static_cast($1,const $type &)),
swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
}
%typemap(out,noblock=1,fragment="SwigPySequence_Cont")
std::pair<iterator, iterator>, std::pair<const_iterator, const_iterator> {
$result = PyTuple_New(2);
PyTuple_SetItem($result,0,SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).first),
PyTuple_SetItem($result,0,SWIG_NewPointerObj(Make_output_iterator(%static_cast($1,const $type &).first),
swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN));
PyTuple_SetItem($result,1,SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).second),
PyTuple_SetItem($result,1,SWIG_NewPointerObj(Make_output_iterator(%static_cast($1,const $type &).second),
swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN));
}
@ -680,7 +688,7 @@ namespace swig
%typemap(out,noblock=1,fragment="SwigPyPairBoolOutputIterator")
std::pair<iterator, bool>, std::pair<const_iterator, bool> {
$result = PyTuple_New(2);
PyTuple_SetItem($result,0,SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).first),
PyTuple_SetItem($result,0,SWIG_NewPointerObj(Make_output_iterator(%static_cast($1,const $type &).first),
swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN));
PyTuple_SetItem($result,1,SWIG_From(bool)(%static_cast($1,const $type &).second));
}
@ -715,7 +723,7 @@ namespace swig
%newobject iterator(PyObject **PYTHON_SELF);
%extend {
swig::SwigPyIterator* iterator(PyObject **PYTHON_SELF) {
return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
return Make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
}
#if defined(SWIGPYTHON_BUILTIN)

View file

@ -306,9 +306,9 @@ SWIG_Python_FixMethods(PyMethodDef *methods,
char *ndoc = (char*)malloc(ldoc + lptr + 10);
if (ndoc) {
char *buff = ndoc;
strncpy(buff, methods[i].ml_doc, ldoc);
memcpy(buff, methods[i].ml_doc, ldoc);
buff += ldoc;
strncpy(buff, "swig_ptr: ", 10);
memcpy(buff, "swig_ptr: ", 10);
buff += 10;
SWIG_PackVoidPtr(buff, ptr, ty->name, lptr);
methods[i].ml_doc = ndoc;

View file

@ -198,16 +198,16 @@ namespace swig {
template<typename OutIterator,
typename ValueType = typename std::iterator_traits<OutIterator>::value_type,
typename FromOper = from_oper<ValueType> >
class SwigPyIteratorOpen_T : public SwigPyIterator_T<OutIterator>
class SwigPyForwardIteratorOpen_T : public SwigPyIterator_T<OutIterator>
{
public:
FromOper from;
typedef OutIterator out_iterator;
typedef ValueType value_type;
typedef SwigPyIterator_T<out_iterator> base;
typedef SwigPyIteratorOpen_T<OutIterator, ValueType, FromOper> self_type;
typedef SwigPyForwardIteratorOpen_T<OutIterator, ValueType, FromOper> self_type;
SwigPyIteratorOpen_T(out_iterator curr, PyObject *seq)
SwigPyForwardIteratorOpen_T(out_iterator curr, PyObject *seq)
: SwigPyIterator_T<OutIterator>(curr, seq)
{
}
@ -229,6 +229,25 @@ namespace swig {
return this;
}
};
template<typename OutIterator,
typename ValueType = typename std::iterator_traits<OutIterator>::value_type,
typename FromOper = from_oper<ValueType> >
class SwigPyIteratorOpen_T : public SwigPyForwardIteratorOpen_T<OutIterator, ValueType, FromOper>
{
public:
FromOper from;
typedef OutIterator out_iterator;
typedef ValueType value_type;
typedef SwigPyIterator_T<out_iterator> base;
typedef SwigPyIteratorOpen_T<OutIterator, ValueType, FromOper> self_type;
SwigPyIteratorOpen_T(out_iterator curr, PyObject *seq)
: SwigPyForwardIteratorOpen_T<OutIterator>(curr, seq)
{
}
SwigPyIterator *decr(size_t n = 1)
{
while (n--) {
@ -241,16 +260,16 @@ namespace swig {
template<typename OutIterator,
typename ValueType = typename std::iterator_traits<OutIterator>::value_type,
typename FromOper = from_oper<ValueType> >
class SwigPyIteratorClosed_T : public SwigPyIterator_T<OutIterator>
class SwigPyForwardIteratorClosed_T : public SwigPyIterator_T<OutIterator>
{
public:
FromOper from;
typedef OutIterator out_iterator;
typedef ValueType value_type;
typedef SwigPyIterator_T<out_iterator> base;
typedef SwigPyIteratorClosed_T<OutIterator, ValueType, FromOper> self_type;
typedef SwigPyForwardIteratorClosed_T<OutIterator, ValueType, FromOper> self_type;
SwigPyIteratorClosed_T(out_iterator curr, out_iterator first, out_iterator last, PyObject *seq)
SwigPyForwardIteratorClosed_T(out_iterator curr, out_iterator first, out_iterator last, PyObject *seq)
: SwigPyIterator_T<OutIterator>(curr, seq), begin(first), end(last)
{
}
@ -280,10 +299,33 @@ namespace swig {
return this;
}
protected:
out_iterator begin;
out_iterator end;
};
template<typename OutIterator,
typename ValueType = typename std::iterator_traits<OutIterator>::value_type,
typename FromOper = from_oper<ValueType> >
class SwigPyIteratorClosed_T : public SwigPyForwardIteratorClosed_T<OutIterator,ValueType,FromOper>
{
public:
FromOper from;
typedef OutIterator out_iterator;
typedef ValueType value_type;
typedef SwigPyIterator_T<out_iterator> base;
typedef SwigPyForwardIteratorClosed_T<OutIterator, ValueType, FromOper> base0;
typedef SwigPyIteratorClosed_T<OutIterator, ValueType, FromOper> self_type;
SwigPyIteratorClosed_T(out_iterator curr, out_iterator first, out_iterator last, PyObject *seq)
: SwigPyForwardIteratorClosed_T<OutIterator,ValueType,FromOper>(curr, first, last, seq)
{
}
SwigPyIterator *decr(size_t n = 1)
{
while (n--) {
if (base::current == begin) {
if (base::current == base0::begin) {
throw stop_iteration();
} else {
--base::current;
@ -291,12 +333,16 @@ namespace swig {
}
return this;
}
private:
out_iterator begin;
out_iterator end;
};
template<typename OutIter>
inline SwigPyIterator*
make_output_forward_iterator(const OutIter& current, const OutIter& begin,const OutIter& end, PyObject *seq = 0)
{
return new SwigPyForwardIteratorClosed_T<OutIter>(current, begin, end, seq);
}
template<typename OutIter>
inline SwigPyIterator*
make_output_iterator(const OutIter& current, const OutIter& begin,const OutIter& end, PyObject *seq = 0)
@ -304,6 +350,13 @@ namespace swig {
return new SwigPyIteratorClosed_T<OutIter>(current, begin, end, seq);
}
template<typename OutIter>
inline SwigPyIterator*
make_output_forward_iterator(const OutIter& current, PyObject *seq = 0)
{
return new SwigPyForwardIteratorOpen_T<OutIter>(current, seq);
}
template<typename OutIter>
inline SwigPyIterator*
make_output_iterator(const OutIter& current, PyObject *seq = 0)

View file

@ -538,7 +538,7 @@ SwigPyObject_dealloc(PyObject *v)
PyObject *res;
/* PyObject_CallFunction() has the potential to silently drop
the active active exception. In cases of unnamed temporary
the active exception. In cases of unnamed temporary
variable or where we just finished iterating over a generator
StopIteration will be active right now, and this needs to
remain true upon return from SwigPyObject_dealloc. So save
@ -1287,31 +1287,28 @@ SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
return SWIG_ConvertPtr(obj, ptr, ty, 0);
} else {
void *vptr = 0;
swig_cast_info *tc;
/* here we get the method pointer for callbacks */
const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc);
const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0;
if (desc)
desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0;
if (!desc)
if (!desc)
return SWIG_ERROR;
if (ty) {
swig_cast_info *tc = SWIG_TypeCheck(desc,ty);
if (tc) {
int newmemory = 0;
*ptr = SWIG_TypeCast(tc,vptr,&newmemory);
assert(!newmemory); /* newmemory handling not yet implemented */
} else {
return SWIG_ERROR;
}
tc = SWIG_TypeCheck(desc,ty);
if (tc) {
int newmemory = 0;
*ptr = SWIG_TypeCast(tc,vptr,&newmemory);
assert(!newmemory); /* newmemory handling not yet implemented */
} else {
*ptr = vptr;
return SWIG_ERROR;
}
return SWIG_OK;
}
}
/* Convert a packed value value */
/* Convert a packed pointer value */
SWIGRUNTIME int
SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) {

View file

@ -3,7 +3,7 @@
/* Use debug wrappers with the Python release dll */
# undef _DEBUG
# include <Python.h>
# define _DEBUG
# define _DEBUG 1
#else
# include <Python.h>
#endif

View file

@ -45,7 +45,7 @@ namespace swig {
template <class Type>
struct traits_asptr {
static int asptr(PyObject *obj, Type **val) {
Type *p;
Type *p = 0;
swig_type_info *descriptor = type_info<Type>();
int res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
if (SWIG_IsOK(res)) {
@ -107,14 +107,14 @@ namespace swig {
template <class Type>
struct traits_as<Type, value_category> {
static Type as(PyObject *obj, bool throw_error) {
static Type as(PyObject *obj) {
Type v;
int res = asval(obj, &v);
if (!obj || !SWIG_IsOK(res)) {
if (!PyErr_Occurred()) {
::%type_error(swig::type_name<Type>());
}
if (throw_error) throw std::invalid_argument("bad type");
throw std::invalid_argument("bad type");
}
return v;
}
@ -122,7 +122,7 @@ namespace swig {
template <class Type>
struct traits_as<Type, pointer_category> {
static Type as(PyObject *obj, bool throw_error) {
static Type as(PyObject *obj) {
Type *v = 0;
int res = (obj ? traits_asptr<Type>::asptr(obj, &v) : SWIG_ERROR);
if (SWIG_IsOK(res) && v) {
@ -134,21 +134,17 @@ namespace swig {
return *v;
}
} else {
// Uninitialized return value, no Type() constructor required.
static Type *v_def = (Type*) malloc(sizeof(Type));
if (!PyErr_Occurred()) {
%type_error(swig::type_name<Type>());
}
if (throw_error) throw std::invalid_argument("bad type");
memset(v_def,0,sizeof(Type));
return *v_def;
throw std::invalid_argument("bad type");
}
}
};
template <class Type>
struct traits_as<Type*, pointer_category> {
static Type* as(PyObject *obj, bool throw_error) {
static Type* as(PyObject *obj) {
Type *v = 0;
int res = (obj ? traits_asptr<Type>::asptr(obj, &v) : SWIG_ERROR);
if (SWIG_IsOK(res)) {
@ -157,15 +153,14 @@ namespace swig {
if (!PyErr_Occurred()) {
%type_error(swig::type_name<Type>());
}
if (throw_error) throw std::invalid_argument("bad type");
return 0;
throw std::invalid_argument("bad type");
}
}
};
template <class Type>
inline Type as(PyObject *obj, bool te = false) {
return traits_as<Type, typename traits<Type>::category>::as(obj, te);
inline Type as(PyObject *obj) {
return traits_as<Type, typename traits<Type>::category>::as(obj);
}
template <class Type>

View file

@ -23,7 +23,11 @@
int res = SWIG_ERROR;
if (PyDict_Check(obj)) {
SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL);
return traits_asptr_stdseq<std::multimap<K,T>, std::pair<K, T> >::asptr(items, val);
%#if PY_VERSION_HEX >= 0x03000000
/* In Python 3.x the ".items()" method returns a dict_items object */
items = PySequence_Fast(items, ".items() didn't return a sequence!");
%#endif
res = traits_asptr_stdseq<std::multimap<K,T>, std::pair<K, T> >::asptr(items, val);
} else {
multimap_type *p;
swig_type_info *descriptor = swig::type_info<multimap_type>();
@ -68,7 +72,17 @@
%define %swig_multimap_methods(Type...)
%swig_map_common(Type);
#if defined(SWIGPYTHON_BUILTIN)
%feature("python:slot", "mp_ass_subscript", functype="objobjargproc") __setitem__;
#endif
%extend {
// This will be called through the mp_ass_subscript slot to delete an entry.
void __setitem__(const key_type& key) {
self->erase(key);
}
void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) {
self->insert(Type::value_type(key,x));
}

View file

@ -2,7 +2,7 @@
Unordered Maps
*/
%fragment("StdMapTraits","header",fragment="StdSequenceTraits")
%fragment("StdUnorderedMapTraits","header",fragment="StdSequenceTraits")
{
namespace swig {
template <class SwigPySeq, class K, class T >
@ -53,7 +53,7 @@
static PyObject *from(const unordered_map_type& unordered_map) {
swig_type_info *desc = swig::type_info<unordered_map_type>();
if (desc && desc->clientdata) {
return SWIG_NewPointerObj(new unordered_map_type(unordered_map), desc, SWIG_POINTER_OWN);
return SWIG_InternalNewPointerObj(new unordered_map_type(unordered_map), desc, SWIG_POINTER_OWN);
} else {
size_type size = unordered_map.size();
Py_ssize_t pysize = (size <= (size_type) INT_MAX) ? (Py_ssize_t) size : -1;
@ -74,33 +74,11 @@
}
};
template <class ValueType>
struct from_key_oper
{
typedef const ValueType& argument_type;
typedef PyObject *result_type;
result_type operator()(argument_type v) const
{
return swig::from(v.first);
}
};
template <class ValueType>
struct from_value_oper
{
typedef const ValueType& argument_type;
typedef PyObject *result_type;
result_type operator()(argument_type v) const
{
return swig::from(v.second);
}
};
template<class OutIterator, class FromOper, class ValueType = typename OutIterator::value_type>
struct SwigPyMapIterator_T : SwigPyIteratorClosed_T<OutIterator, ValueType, FromOper>
struct SwigPyMapForwardIterator_T : SwigPyForwardIteratorClosed_T<OutIterator, ValueType, FromOper>
{
SwigPyMapIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
: SwigPyIteratorClosed_T<OutIterator,ValueType,FromOper>(curr, first, last, seq)
SwigPyMapForwardIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
: SwigPyForwardIteratorClosed_T<OutIterator,ValueType,FromOper>(curr, first, last, seq)
{
}
};
@ -108,27 +86,27 @@
template<class OutIterator,
class FromOper = from_key_oper<typename OutIterator::value_type> >
struct SwigPyMapKeyIterator_T : SwigPyMapIterator_T<OutIterator, FromOper>
struct SwigPyMapKeyForwardIterator_T : SwigPyMapForwardIterator_T<OutIterator, FromOper>
{
SwigPyMapKeyIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
: SwigPyMapIterator_T<OutIterator, FromOper>(curr, first, last, seq)
SwigPyMapKeyForwardIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
: SwigPyMapForwardIterator_T<OutIterator, FromOper>(curr, first, last, seq)
{
}
};
template<typename OutIter>
inline SwigPyIterator*
make_output_key_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0)
make_output_key_forward_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0)
{
return new SwigPyMapKeyIterator_T<OutIter>(current, begin, end, seq);
return new SwigPyMapKeyForwardIterator_T<OutIter>(current, begin, end, seq);
}
template<class OutIterator,
class FromOper = from_value_oper<typename OutIterator::value_type> >
struct SwigPyMapValueITerator_T : SwigPyMapIterator_T<OutIterator, FromOper>
struct SwigPyMapValueForwardIterator_T : SwigPyMapForwardIterator_T<OutIterator, FromOper>
{
SwigPyMapValueITerator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
: SwigPyMapIterator_T<OutIterator, FromOper>(curr, first, last, seq)
SwigPyMapValueForwardIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
: SwigPyMapForwardIterator_T<OutIterator, FromOper>(curr, first, last, seq)
{
}
};
@ -136,15 +114,15 @@
template<typename OutIter>
inline SwigPyIterator*
make_output_value_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0)
make_output_value_forward_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0)
{
return new SwigPyMapValueITerator_T<OutIter>(current, begin, end, seq);
return new SwigPyMapValueForwardIterator_T<OutIter>(current, begin, end, seq);
}
}
}
%define %swig_unordered_map_common(Map...)
%swig_sequence_iterator(Map);
%swig_sequence_forward_iterator(Map);
%swig_container_methods(Map)
%extend {
@ -227,12 +205,12 @@
%newobject key_iterator(PyObject **PYTHON_SELF);
swig::SwigPyIterator* key_iterator(PyObject **PYTHON_SELF) {
return swig::make_output_key_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
return swig::make_output_key_forward_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
}
%newobject value_iterator(PyObject **PYTHON_SELF);
swig::SwigPyIterator* value_iterator(PyObject **PYTHON_SELF) {
return swig::make_output_value_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
return swig::make_output_value_forward_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
}
%pythoncode %{def __iter__(self):
@ -248,7 +226,17 @@
%define %swig_unordered_map_methods(Map...)
%swig_unordered_map_common(Map)
#if defined(SWIGPYTHON_BUILTIN)
%feature("python:slot", "mp_ass_subscript", functype="objobjargproc") __setitem__;
#endif
%extend {
// This will be called through the mp_ass_subscript slot to delete an entry.
void __setitem__(const key_type& key) {
self->erase(key);
}
void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) {
(*self)[key] = x;
}

View file

@ -30,7 +30,11 @@
int res = SWIG_ERROR;
if (PyDict_Check(obj)) {
SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL);
return traits_asptr_stdseq<std::unordered_multimap<K,T>, std::pair<K, T> >::asptr(items, val);
%#if PY_VERSION_HEX >= 0x03000000
/* In Python 3.x the ".items()" method returns a dict_items object */
items = PySequence_Fast(items, ".items() didn't return a sequence!");
%#endif
res = traits_asptr_stdseq<std::unordered_multimap<K,T>, std::pair<K, T> >::asptr(items, val);
} else {
unordered_multimap_type *p;
swig_type_info *descriptor = swig::type_info<unordered_multimap_type>();
@ -50,7 +54,7 @@
static PyObject *from(const unordered_multimap_type& unordered_multimap) {
swig_type_info *desc = swig::type_info<unordered_multimap_type>();
if (desc && desc->clientdata) {
return SWIG_NewPointerObj(new unordered_multimap_type(unordered_multimap), desc, SWIG_POINTER_OWN);
return SWIG_InternalNewPointerObj(new unordered_multimap_type(unordered_multimap), desc, SWIG_POINTER_OWN);
} else {
size_type size = unordered_multimap.size();
Py_ssize_t pysize = (size <= (size_type) INT_MAX) ? (Py_ssize_t) size : -1;
@ -74,8 +78,18 @@
}
%define %swig_unordered_multimap_methods(Type...)
%swig_map_common(Type);
%swig_unordered_map_common(Type);
#if defined(SWIGPYTHON_BUILTIN)
%feature("python:slot", "mp_ass_subscript", functype="objobjargproc") __setitem__;
#endif
%extend {
// This will be called through the mp_ass_subscript slot to delete an entry.
void __setitem__(const key_type& key) {
self->erase(key);
}
void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) {
self->insert(Type::value_type(key,x));
}

View file

@ -41,7 +41,7 @@
}
%}
#define %swig_unordered_multiset_methods(Set...) %swig_set_methods(Set)
#define %swig_unordered_multiset_methods(Set...) %swig_unordered_set_methods(Set)

View file

@ -40,7 +40,7 @@
%}
%define %swig_unordered_set_methods(unordered_set...)
%swig_sequence_iterator(unordered_set);
%swig_sequence_forward_iterator(unordered_set);
%swig_container_methods(unordered_set);
%extend {

View file

@ -8,7 +8,7 @@
%naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
// destructor wrapper customisation
%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;"
@ -19,7 +19,7 @@
int newmem = 0;
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
%argument_fail(res, "$type", $symname, $argnum);
}
if (!argp) {
%argument_nullref("$type", $symname, $argnum);
@ -56,7 +56,7 @@
int newmem = 0;
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
%argument_fail(res, "$type", $symname, $argnum);
}
if (newmem & SWIG_CAST_NEW_MEMORY) {
tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
@ -100,7 +100,7 @@
int newmem = 0;
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
%argument_fail(res, "$type", $symname, $argnum);
}
if (!argp) { %argument_nullref("$type", $symname, $argnum); }
if (newmem & SWIG_CAST_NEW_MEMORY) {
@ -146,7 +146,7 @@
int newmem = 0;
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
%argument_fail(res, "$type", $symname, $argnum);
}
if (newmem & SWIG_CAST_NEW_MEMORY) {
tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
@ -174,7 +174,7 @@
int newmem = 0;
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
%argument_fail(res, "$type", $symname, $argnum);
}
if (argp) $1 = *(%reinterpret_cast(argp, $&ltype));
if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $&ltype);
@ -204,7 +204,7 @@
int newmem = 0;
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
%argument_fail(res, "$type", $symname, $argnum);
}
if (newmem & SWIG_CAST_NEW_MEMORY) {
if (argp) tempshared = *%reinterpret_cast(argp, $ltype);
@ -231,7 +231,7 @@
int newmem = 0;
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
%argument_fail(res, "$type", $symname, $argnum);
}
if (newmem & SWIG_CAST_NEW_MEMORY) {
if (argp) tempshared = *%reinterpret_cast(argp, $ltype);
@ -259,7 +259,7 @@
int newmem = 0;
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
%argument_fail(res, "$type", $symname, $argnum);
}
if (argp) tempshared = *%reinterpret_cast(argp, $*ltype);
if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $*ltype);
@ -279,9 +279,9 @@
%}
// Typecheck typemaps
// Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting
// Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting
// function is not called thereby avoiding a possible smart pointer copy constructor call when casting up the inheritance chain.
%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1)
%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1)
TYPE CONST,
TYPE CONST &,
TYPE CONST *,

View file

@ -350,7 +350,7 @@ SWIG_R_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) {
return ptr ? RSwigPacked_New((void *) ptr, sz, type) : R_NilValue;
}
/* Convert a packed value value */
/* Convert a packed pointer value */
SWIGRUNTIME int
SWIG_R_ConvertPacked(SEXP obj, void *ptr, size_t sz, swig_type_info *ty) {

View file

@ -39,7 +39,7 @@ namespace swig {
template <class Type>
struct traits_asptr {
static int asptr(SWIG_Object obj, Type **val) {
Type *p;
Type *p = 0;
swig_type_info *descriptor = type_info<Type>();
int res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
if (SWIG_IsOK(res)) {
@ -101,12 +101,11 @@ namespace swig {
template <class Type>
struct traits_as<Type, value_category> {
static Type as(SWIG_Object obj, bool throw_error) {
static Type as(SWIG_Object obj) {
Type v;
int res = asval(obj, &v);
if (!obj || !SWIG_IsOK(res)) {
if (throw_error)
throw std::invalid_argument("bad type");
throw std::invalid_argument("bad type");
}
return v;
}
@ -114,7 +113,7 @@ namespace swig {
template <class Type>
struct traits_as<Type, pointer_category> {
static Type as(SWIG_Object obj, bool throw_error) {
static Type as(SWIG_Object obj) {
Type *v = 0;
int res = (obj ? traits_asptr<Type>::asptr(obj, &v) : SWIG_ERROR);
if (SWIG_IsOK(res) && v) {
@ -126,12 +125,7 @@ namespace swig {
return *v;
}
} else {
// Uninitialized return value, no Type() constructor required.
static Type *v_def = (Type*) malloc(sizeof(Type));
if (throw_error)
throw std::invalid_argument("bad type");
memset(v_def,0,sizeof(Type));
return *v_def;
}
}
};
@ -152,8 +146,8 @@ namespace swig {
};
template <class Type>
inline Type as(SWIG_Object obj, bool te = false) {
return traits_as<Type, typename traits<Type>::category>::as(obj, te);
inline Type as(SWIG_Object obj) {
return traits_as<Type, typename traits<Type>::category>::as(obj);
}
template <class Type>

View file

@ -7,7 +7,7 @@
# This could be provided as a separate run-time library but this
# approach allows the code to to be included directly into the
# approach allows the code to be included directly into the
# generated bindings and so removes the need to have and install an
# additional library. We may however end up with multiple copies of
# this and some confusion at run-time as to which class to use. This

View file

@ -62,6 +62,24 @@
%set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
}
%typemap(directorout,noblock=1) CONST TYPE (void *argp, int res = 0) {
swig_ruby_owntype newmem = {0, 0};
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
if (!SWIG_IsOK(res)) {
%dirout_fail(res, "$type");
}
if (!argp) {
%dirout_nullref("$type");
} else {
$result = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get());
if (newmem.own & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
}
}
%typemap(directorin,noblock=1) CONST TYPE {
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1));
$input = SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN | %newpointer_flags);
}
// plain pointer
// Note: $disown not implemented by default as it will lead to a memory leak of the shared_ptr instance
%typemap(in) CONST TYPE * (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) {
@ -108,6 +126,13 @@
%set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
}
%typemap(directorin,noblock=1) CONST TYPE * %{
#error "directorin typemap for plain pointer not implemented"
%}
%typemap(directorout,noblock=1) CONST TYPE * %{
#error "directorout typemap for plain pointer not implemented"
%}
// plain reference
%typemap(in) CONST TYPE & (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) {
swig_ruby_owntype newmem = {0, 0};
@ -153,6 +178,13 @@
%set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
}
%typemap(directorin,noblock=1) CONST TYPE & %{
#error "directorin typemap for plain reference not implemented"
%}
%typemap(directorout,noblock=1) CONST TYPE & %{
#error "directorout typemap for plain reference not implemented"
%}
// plain pointer by reference
// Note: $disown not implemented by default as it will lead to a memory leak of the shared_ptr instance
%typemap(in) TYPE *CONST& (void *argp = 0, int res = 0, $*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) {
@ -182,6 +214,13 @@
#error "varout typemap not implemented"
%}
%typemap(directorin,noblock=1) TYPE *CONST& %{
#error "directorin typemap for plain pointer by reference not implemented"
%}
%typemap(directorout,noblock=1) TYPE *CONST& %{
#error "directorout typemap for plain pointer by reference not implemented"
%}
// shared_ptr by value
%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > (void *argp, int res = 0) {
swig_ruby_owntype newmem = {0, 0};
@ -212,6 +251,26 @@
%set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
}
%typemap(directorin,noblock=1) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
if ($1) {
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1);
$input = SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN | %newpointer_flags);
} else {
$input = Qnil;
}
}
%typemap(directorout,noblock=1) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > (void * swig_argp, int swig_res = 0) {
if (NIL_P($input)) {
$result = $ltype();
} else {
swig_res = SWIG_ConvertPtr($input, &swig_argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags);
if (!SWIG_IsOK(swig_res)) {
%dirout_fail(swig_res,"$type");
}
$result = *(%reinterpret_cast(swig_argp, $&ltype));
}
}
// shared_ptr by reference
%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & (void *argp, int res = 0, $*1_ltype tempshared) {
swig_ruby_owntype newmem = {0, 0};
@ -239,6 +298,14 @@
#error "varout typemap not implemented"
%}
%typemap(directorin,noblock=1) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & {
if ($1) {
$input = SWIG_NewPointerObj(%as_voidptr(&$1), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %newpointer_flags);
} else {
$input = Qnil;
}
}
// shared_ptr by pointer
%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * (void *argp, int res = 0, $*1_ltype tempshared) {
swig_ruby_owntype newmem = {0, 0};
@ -267,6 +334,14 @@
#error "varout typemap not implemented"
%}
%typemap(directorin,noblock=1) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *const& {
if ($1 && *$1) {
$input = SWIG_NewPointerObj(%as_voidptr($1), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %newpointer_flags);
} else {
$input = Qnil;
}
}
// shared_ptr by pointer reference
%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& (void *argp, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, $*1_ltype temp = 0) {
swig_ruby_owntype newmem = {0, 0};

View file

@ -183,8 +183,8 @@ namespace swig
{
VALUE item = rb_ary_entry(_seq, _index );
try {
return swig::as<T>(item, true);
} catch (std::exception& e) {
return swig::as<T>(item);
} catch (const std::invalid_argument& e) {
char msg[1024];
sprintf(msg, "in sequence element %d ", _index);
VALUE lastErr = rb_gv_get("$!");
@ -926,7 +926,7 @@ namespace swig
VALUE elem = argv[0];
int idx = 0;
try {
Sequence::value_type val = swig::as<Sequence::value_type>( elem, true );
Sequence::value_type val = swig::as<Sequence::value_type>( elem );
if ( i >= len ) {
$self->resize(i-1, val);
return $self;
@ -943,7 +943,7 @@ namespace swig
}
}
catch( std::invalid_argument )
catch( const std::invalid_argument & )
{
rb_raise( rb_eArgError, "%s",
Ruby_Format_TypeError( "",
@ -967,10 +967,10 @@ namespace swig
Sequence::iterator start = $self->begin();
VALUE elem = argv[idx];
try {
Sequence::value_type val = swig::as<Sequence::value_type>( elem, true );
Sequence::value_type val = swig::as<Sequence::value_type>( elem );
$self->insert( start, val );
}
catch( std::invalid_argument )
catch( const std::invalid_argument & )
{
rb_raise( rb_eArgError, "%s",
Ruby_Format_TypeError( "",

View file

@ -171,10 +171,11 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags)
swig_class *sklass;
VALUE klass;
VALUE obj;
if (!ptr)
return Qnil;
assert(type);
if (type->clientdata) {
sklass = (swig_class *) type->clientdata;
@ -182,7 +183,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags)
track = sklass->trackObjects;
if (track) {
obj = SWIG_RubyInstanceFor(ptr);
/* Check the object's type and make sure it has the correct type.
It might not in cases where methods do things like
downcast methods. */
@ -214,7 +215,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags)
obj = Data_Wrap_Struct(klass, 0, 0, ptr);
}
rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name));
return obj;
}
@ -246,7 +247,7 @@ typedef struct {
SWIGRUNTIME swig_ruby_owntype
SWIG_Ruby_AcquirePtr(VALUE obj, swig_ruby_owntype own) {
swig_ruby_owntype oldown = {0, 0};
if (obj) {
if (TYPE(obj) == T_DATA) {
oldown.datafree = RDATA(obj)->dfree;
RDATA(obj)->dfree = own.datafree;
}
@ -362,7 +363,7 @@ SWIG_Ruby_NewPackedObj(void *ptr, int sz, swig_type_info *type) {
return rb_str_new2(result);
}
/* Convert a packed value value */
/* Convert a packed pointer value */
SWIGRUNTIME int
SWIG_Ruby_ConvertPacked(VALUE obj, void *ptr, int sz, swig_type_info *ty) {
swig_cast_info *tc;

View file

@ -3,8 +3,9 @@
* The Ruby classes, for C++
* ------------------------------------------------------------ */
%include <rubyclasses.swg>
%include <rubystdcommon_forward.swg>
%fragment("StdTraits","header",fragment="StdTraitsCommon")
%fragment("StdTraits","header",fragment="StdTraitsCommon",fragment="StdTraitsForwardDeclaration")
{
namespace swig {
@ -52,7 +53,7 @@ namespace swig {
template <class Type>
struct traits_asptr {
static int asptr(VALUE obj, Type **val) {
Type *p;
Type *p = 0;
swig_type_info *descriptor = type_info<Type>();
int res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
if (SWIG_IsOK(res)) {
@ -114,15 +115,15 @@ namespace swig {
template <class Type>
struct traits_as<Type, value_category> {
static Type as(VALUE obj, bool throw_error) {
static Type as(VALUE obj) {
Type v;
int res = asval(obj, &v);
if (!obj || !SWIG_IsOK(res)) {
if (throw_error) throw std::invalid_argument("bad type");
if (!SWIG_IsOK(res)) {
VALUE lastErr = rb_gv_get("$!");
if (lastErr == Qnil) {
%type_error(swig::type_name<Type>());
}
throw std::invalid_argument("bad type");
}
return v;
}
@ -130,9 +131,9 @@ namespace swig {
template <class Type>
struct traits_as<Type, pointer_category> {
static Type as(VALUE obj, bool throw_error) {
static Type as(VALUE obj) {
Type *v = 0;
int res = (obj ? traits_asptr<Type>::asptr(obj, &v) : SWIG_ERROR);
int res = traits_asptr<Type>::asptr(obj, &v);
if (SWIG_IsOK(res) && v) {
if (SWIG_IsNewObj(res)) {
Type r(*v);
@ -142,46 +143,41 @@ namespace swig {
return *v;
}
} else {
// Uninitialized return value, no Type() constructor required.
if (throw_error) throw std::invalid_argument("bad type");
VALUE lastErr = rb_gv_get("$!");
if (lastErr == Qnil) {
%type_error(swig::type_name<Type>());
}
static Type *v_def = (Type*) malloc(sizeof(Type));
memset(v_def,0,sizeof(Type));
return *v_def;
throw std::invalid_argument("bad type");
}
}
};
template <class Type>
struct traits_as<Type*, pointer_category> {
static Type* as(VALUE obj, bool throw_error) {
static Type* as(VALUE obj) {
Type *v = 0;
int res = (obj ? traits_asptr<Type>::asptr(obj, &v) : SWIG_ERROR);
int res = traits_asptr<Type>::asptr(obj, &v);
if (SWIG_IsOK(res)) {
return v;
} else {
if (throw_error) throw std::invalid_argument("bad type");
VALUE lastErr = rb_gv_get("$!");
if (lastErr == Qnil) {
%type_error(swig::type_name<Type>());
}
return 0;
throw std::invalid_argument("bad type");
}
}
};
template <class Type>
inline Type as(VALUE obj, bool te = false) {
return traits_as< Type, typename traits< Type >::category >::as(obj, te);
inline Type as(VALUE obj) {
return traits_as< Type, typename traits< Type >::category >::as(obj);
}
template <class Type>
struct traits_check<Type, value_category> {
static bool check(VALUE obj) {
int res = obj ? asval(obj, (Type *)(0)) : SWIG_ERROR;
int res = asval(obj, (Type *)(0));
return SWIG_IsOK(res) ? true : false;
}
};
@ -189,7 +185,7 @@ namespace swig {
template <class Type>
struct traits_check<Type, pointer_category> {
static bool check(VALUE obj) {
int res = obj ? asptr(obj, (Type **)(0)) : SWIG_ERROR;
int res = asptr(obj, (Type **)(0));
return SWIG_IsOK(res) ? true : false;
}
};

View file

@ -0,0 +1,15 @@
%fragment("StdTraitsForwardDeclaration","header")
{
namespace swig {
template <class Type> struct traits_asptr;
template <class Type> struct traits_asval;
struct pointer_category;
template <class Type, class Category> struct traits_as;
template <class Type> struct traits_from;
template <class Type> struct traits_from_ptr;
template <class Type> struct noconst_traits;
template <class Type> swig_type_info* type_info();
template <class Type> const char* type_name();
template <class Type> VALUE from(const Type& val);
}
}

View file

@ -1,71 +1,57 @@
/* -----------------------------------------------------------------------------
* rubywstrings.swg
*
* Currently, Ruby does not support Unicode or WChar properly, so these
* are still treated as char arrays for now.
* There are other libraries available that add support to this in
* ruby including WString, FXString, etc.
* ----------------------------------------------------------------------------- */
/* ------------------------------------------------------------
* utility methods for wchar_t strings
* ------------------------------------------------------------ */
%fragment("SWIG_AsWCharPtrAndSize","header",fragment="<wchar.h>",fragment="SWIG_pwchar_descriptor",fragment="SWIG_AsCharPtrAndSize") {
%fragment("SWIG_AsWCharPtrAndSize","header",fragment="<wchar.h>",fragment="SWIG_pwchar_descriptor",fragment="SWIG_AsCharPtrAndSize",fragment="SWIG_ruby_wstring_encoding_init") {
SWIGINTERN int
SWIG_AsWCharPtrAndSize(VALUE obj, wchar_t **cptr, size_t *psize, int *alloc)
{
return SWIG_AsCharPtrAndSize( obj, (char**)cptr, psize, alloc);
// VALUE tmp = 0;
// bool ok = false;
// if ( TYPE(obj) == T_STRING ) {
// if (cptr) {
// obj = tmp = SWIG_Unicode_FromObject(obj);
// ok = true;
// }
// }
// if (ok) {
// Py_ssize_t len = PyUnicode_GetSize(obj);
// rb_notimplement();
// if (cptr) {
// *cptr = %new_array(len + 1, wchar_t);
// SWIG_Unicode_AsWideChar((PyUnicodeObject *)obj, *cptr, len);
// (*cptr)[len] = 0;
// }
// if (psize) *psize = (size_t) len + 1;
// if (alloc) *alloc = cptr ? SWIG_NEWOBJ : 0;
// return SWIG_OK;
// } else {
// swig_type_info* pwchar_descriptor = SWIG_pwchar_descriptor();
// if (pwchar_descriptor) {
// void * vptr = 0;
// if (SWIG_ConvertPtr(obj, &vptr, pwchar_descriptor, 0) == SWIG_OK) {
// if (cptr) *cptr = (wchar_t *)vptr;
// if (psize) *psize = vptr ? (wcslen((wchar_t *)vptr) + 1) : 0;
// return SWIG_OK;
// }
// }
// }
// return SWIG_TypeError;
rb_encoding* wstr_enc = swig_ruby_wstring_encoding;
if (TYPE(obj) == T_STRING) {
VALUE rstr = rb_str_conv_enc(obj, rb_enc_get(obj), wstr_enc);
wchar_t* cstr = (wchar_t*) StringValuePtr(rstr);
size_t size = RSTRING_LEN(rstr) / sizeof(wchar_t) + 1;
if ( RSTRING_LEN(rstr) % sizeof(wchar_t) != 0 ) {
rb_raise(rb_eRuntimeError,
"The length of the byte sequence of converted string is not a multiplier of sizeof(wchar_t). Invalid byte sequence is given. Or invalid SWIG_RUBY_WSTRING_ENCODING is given when compiling this binding.");
}
if (cptr && alloc) {
*alloc = SWIG_NEWOBJ;
*cptr = %new_array(size, wchar_t);
memmove(*cptr, cstr, RSTRING_LEN(rstr));
}
if (psize) *psize = size;
return SWIG_OK;
} else {
return SWIG_TypeError;
}
}
}
%fragment("SWIG_FromWCharPtrAndSize","header",fragment="<wchar.h>",fragment="SWIG_pwchar_descriptor",fragment="SWIG_FromCharPtrAndSize") {
%fragment("SWIG_FromWCharPtrAndSize","header",fragment="<wchar.h>",fragment="SWIG_pwchar_descriptor",fragment="SWIG_FromCharPtrAndSize",fragment="SWIG_ruby_wstring_encoding_init") {
SWIGINTERNINLINE VALUE
SWIG_FromWCharPtrAndSize(const wchar_t * carray, size_t size)
{
return SWIG_FromCharPtrAndSize( (const char*)carray, size);
// if (carray) {
// if (size > INT_MAX) {
// swig_type_info* pwchar_descriptor = SWIG_pwchar_descriptor();
// return pwchar_descriptor ?
// SWIG_NewPointerObj(%const_cast(carray,wchar_t *), pwchar_descriptor, 0) : Qnil;
// } else {
// return SWIG_Unicode_FromWideChar(carray, %numeric_cast(size,int));
// }
// } else {
// return Qnil;
// }
rb_encoding* wstr_enc = swig_ruby_wstring_encoding;
rb_encoding* rb_enc = swig_ruby_internal_encoding;
if (carray && size <= LONG_MAX/sizeof(wchar_t)) {
VALUE rstr = rb_str_new( (const char*)carray, %numeric_cast(size*sizeof(wchar_t),long) );
rb_encoding* new_enc = rb_default_internal_encoding();
rb_enc_associate(rstr, wstr_enc);
if ( !new_enc ) {
new_enc = rb_enc;
}
return rb_str_conv_enc(rstr, wstr_enc, new_enc);
} else {
return Qnil;
}
}
}

View file

@ -55,6 +55,10 @@ SWIGINTERNINLINE VALUE
#if !defined(SWIG_STD_WSTRING)
%traits_swigtype(std::basic_string<wchar_t>);
%fragment(SWIG_Traits_frag(std::basic_string<wchar_t>));
%fragment(SWIG_AsPtr_frag(std::basic_string<wchar_t>),"header",
fragment="SWIG_AsWCharPtrAndSize") {
SWIGINTERN int

View file

@ -27,6 +27,7 @@
#define %swig_list_methods(Type...) %swig_sequence_methods(Type)
#define %swig_list_methods_val(Type...) %swig_sequence_methods_val(Type);
%mixin std::list "Enumerable";
%rename("delete") std::list::__delete__;
%rename("reject!") std::list::reject_bang;

View file

@ -90,12 +90,11 @@
%extend {
VALUE __getitem__(const key_type& key) const {
MultiMap::const_iterator i = self->find(key);
if ( i != self->end() )
std::pair<MultiMap::const_iterator, MultiMap::const_iterator > r = $self->equal_range(key);
if ( r.first != r.second )
{
MultiMap::const_iterator e = $self->upper_bound(key);
VALUE ary = rb_ary_new();
for ( ; i != e; ++i )
for (MultiMap::const_iterator i = r.first ; i != r.second; ++i )
{
rb_ary_push( ary, swig::from<MultiMap::mapped_type>( i->second ) );
}

View file

@ -36,7 +36,7 @@
#define %swig_multiset_methods(Set...) %swig_set_methods(Set)
%mixin std::multiset "Enumerable";
%rename("delete") std::multiset::__delete__;
%rename("reject!") std::multiset::reject_bang;

View file

@ -1,2 +1,141 @@
#define SWIG_SHARED_PTR_NAMESPACE std
%include <boost_shared_ptr.i>
%include <rubystdcommon_forward.swg>
%fragment("StdSharedPtrTraits","header",fragment="StdTraitsForwardDeclaration")
{
namespace swig {
/*
Template specialization for functions defined in rubystdcommon.swg. Special handling for shared_ptr
is required as, shared_ptr<T> * is used rather than the usual T *, see shared_ptr.i.
*/
template <class Type>
struct traits_asptr<std::shared_ptr<Type> > {
static int asptr(VALUE obj, std::shared_ptr<Type> **val) {
std::shared_ptr<Type> *p = 0;
swig_type_info *descriptor = type_info<std::shared_ptr<Type> >();
swig_ruby_owntype newmem = {0, 0};
int res = descriptor ? SWIG_ConvertPtrAndOwn(obj, (void **)&p, descriptor, 0, &newmem) : SWIG_ERROR;
if (SWIG_IsOK(res)) {
if (val) {
if (*val) {
**val = p ? *p : std::shared_ptr<Type>();
} else {
*val = p;
if (newmem.own & SWIG_CAST_NEW_MEMORY) {
// Upcast for pointers to shared_ptr in this generic framework has not been implemented
res = SWIG_ERROR;
}
}
}
if (newmem.own & SWIG_CAST_NEW_MEMORY)
delete p;
}
return res;
}
};
template <class Type>
struct traits_asval<std::shared_ptr<Type> > {
static int asval(VALUE obj, std::shared_ptr<Type> *val) {
if (val) {
std::shared_ptr<Type> ret;
std::shared_ptr<Type> *p = &ret;
int res = traits_asptr<std::shared_ptr<Type> >::asptr(obj, &p);
if (!SWIG_IsOK(res))
return res;
*val = ret;
return SWIG_OK;
} else {
return traits_asptr<std::shared_ptr<Type> >::asptr(obj, (std::shared_ptr<Type> **)(0));
}
}
};
template <class Type>
struct traits_asval<std::shared_ptr<Type> *> {
static int asval(VALUE obj, std::shared_ptr<Type> **val) {
if (val) {
typedef typename noconst_traits<std::shared_ptr<Type> >::noconst_type noconst_type;
if (*val) {
noconst_type ret;
noconst_type *p = &ret;
int res = traits_asptr<noconst_type>::asptr(obj, &p);
if (SWIG_IsOK(res))
**(const_cast<noconst_type**>(val)) = ret;
return res;
} else {
noconst_type *p = 0;
int res = traits_asptr<noconst_type>::asptr(obj, &p);
if (SWIG_IsOK(res))
*val = p;
return res;
}
} else {
return traits_asptr<std::shared_ptr<Type> >::asptr(obj, (std::shared_ptr<Type> **)(0));
}
}
};
template <class Type>
struct traits_as<std::shared_ptr<Type>, pointer_category> {
static std::shared_ptr<Type> as(VALUE obj) {
std::shared_ptr<Type> ret;
std::shared_ptr<Type> *v = &ret;
int res = traits_asptr<std::shared_ptr<Type> >::asptr(obj, &v);
if (SWIG_IsOK(res)) {
return ret;
} else {
VALUE lastErr = rb_gv_get("$!");
if (lastErr == Qnil)
SWIG_Error(SWIG_TypeError, swig::type_name<std::shared_ptr<Type> >());
throw std::invalid_argument("bad type");
}
}
};
template <class Type>
struct traits_as<std::shared_ptr<Type> *, pointer_category> {
static std::shared_ptr<Type> * as(VALUE obj) {
std::shared_ptr<Type> *p = 0;
int res = traits_asptr<std::shared_ptr<Type> >::asptr(obj, &p);
if (SWIG_IsOK(res)) {
return p;
} else {
VALUE lastErr = rb_gv_get("$!");
if (lastErr == Qnil)
SWIG_Error(SWIG_TypeError, swig::type_name<std::shared_ptr<Type> *>());
throw std::invalid_argument("bad type");
}
}
};
template <class Type>
struct traits_from_ptr<std::shared_ptr<Type> > {
static VALUE from(std::shared_ptr<Type> *val, int owner = 0) {
if (val && *val) {
return SWIG_NewPointerObj(val, type_info<std::shared_ptr<Type> >(), owner);
} else {
return Qnil;
}
}
};
/*
The descriptors in the shared_ptr typemaps remove the const qualifier for the SWIG type system.
Remove const likewise here, otherwise SWIG_TypeQuery("std::shared_ptr<const Type>") will return NULL.
*/
template<class Type>
struct traits_from<std::shared_ptr<const Type> > {
static VALUE from(const std::shared_ptr<const Type>& val) {
std::shared_ptr<Type> p = std::const_pointer_cast<Type>(val);
return swig::from(p);
}
};
}
}
%fragment("StdSharedPtrTraits");

View file

@ -0,0 +1,83 @@
//
// Maps
//
%include <std_map.i>
%fragment("StdUnorderedMapTraits","header",fragment="StdMapCommonTraits")
{
namespace swig {
template <class RubySeq, class K, class T >
inline void
assign(const RubySeq& rubyseq, std::unordered_map<K,T > *map) {
typedef typename std::unordered_map<K,T>::value_type value_type;
typename RubySeq::const_iterator it = rubyseq.begin();
for (;it != rubyseq.end(); ++it) {
map->insert(value_type(it->first, it->second));
}
}
template <class K, class T>
struct traits_asptr<std::unordered_map<K,T> > {
typedef std::unordered_map<K,T> map_type;
static int asptr(VALUE obj, map_type **val) {
int res = SWIG_ERROR;
if (TYPE(obj) == T_HASH) {
static ID id_to_a = rb_intern("to_a");
VALUE items = rb_funcall(obj, id_to_a, 0);
res = traits_asptr_stdseq<std::unordered_map<K,T>, std::pair<K, T> >::asptr(items, val);
} else {
map_type *p;
swig_type_info *descriptor = swig::type_info<map_type>();
res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
if (SWIG_IsOK(res) && val) *val = p;
}
return res;
}
};
template <class K, class T >
struct traits_from<std::unordered_map<K,T> > {
typedef std::unordered_map<K,T> map_type;
typedef typename map_type::const_iterator const_iterator;
typedef typename map_type::size_type size_type;
static VALUE from(const map_type& map) {
swig_type_info *desc = swig::type_info<map_type>();
if (desc && desc->clientdata) {
return SWIG_NewPointerObj(new map_type(map), desc, SWIG_POINTER_OWN);
} else {
size_type size = map.size();
int rubysize = (size <= (size_type) INT_MAX) ? (int) size : -1;
if (rubysize < 0) {
SWIG_RUBY_THREAD_BEGIN_BLOCK;
rb_raise(rb_eRuntimeError, "map size not valid in Ruby");
SWIG_RUBY_THREAD_END_BLOCK;
return Qnil;
}
VALUE obj = rb_hash_new();
for (const_iterator i= map.begin(); i!= map.end(); ++i) {
VALUE key = swig::from(i->first);
VALUE val = swig::from(i->second);
rb_hash_aset(obj, key, val);
}
return obj;
}
}
};
}
}
#define %swig_unordered_map_common(Map...) %swig_map_common(Map)
#define %swig_unordered_map_methods(Map...) %swig_map_methods(Map)
%rename("delete") std::unordered_map::__delete__;
%rename("reject!") std::unordered_map::reject_bang;
%rename("map!") std::unordered_map::map_bang;
%rename("empty?") std::unordered_map::empty;
%rename("include?") std::unordered_map::__contains__ const;
%rename("has_key?") std::unordered_map::has_key const;
%mixin std::unordered_map "Enumerable";
%alias std::unordered_map::push "<<";
%include <std/std_unordered_map.i>

View file

@ -0,0 +1,100 @@
/*
Multimaps
*/
%include <std_multimap.i>
%fragment("StdUnorderedMultimapTraits","header",fragment="StdMapCommonTraits")
{
namespace swig {
template <class RubySeq, class K, class T >
inline void
assign(const RubySeq& rubyseq, std::unordered_multimap<K,T > *multimap) {
typedef typename std::unordered_multimap<K,T>::value_type value_type;
typename RubySeq::const_iterator it = rubyseq.begin();
for (;it != rubyseq.end(); ++it) {
multimap->insert(value_type(it->first, it->second));
}
}
template <class K, class T>
struct traits_asptr<std::unordered_multimap<K,T> > {
typedef std::unordered_multimap<K,T> multimap_type;
static int asptr(VALUE obj, std::unordered_multimap<K,T> **val) {
int res = SWIG_ERROR;
if ( TYPE(obj) == T_HASH ) {
static ID id_to_a = rb_intern("to_a");
VALUE items = rb_funcall(obj, id_to_a, 0);
return traits_asptr_stdseq<std::unordered_multimap<K,T>, std::pair<K, T> >::asptr(items, val);
} else {
multimap_type *p;
res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<multimap_type>(),0);
if (SWIG_IsOK(res) && val) *val = p;
}
return res;
}
};
template <class K, class T >
struct traits_from<std::unordered_multimap<K,T> > {
typedef std::unordered_multimap<K,T> multimap_type;
typedef typename multimap_type::const_iterator const_iterator;
typedef typename multimap_type::size_type size_type;
static VALUE from(const multimap_type& multimap) {
swig_type_info *desc = swig::type_info<multimap_type>();
if (desc && desc->clientdata) {
return SWIG_NewPointerObj(new multimap_type(multimap), desc, SWIG_POINTER_OWN);
} else {
size_type size = multimap.size();
int rubysize = (size <= (size_type) INT_MAX) ? (int) size : -1;
if (rubysize < 0) {
SWIG_RUBY_THREAD_BEGIN_BLOCK;
rb_raise(rb_eRuntimeError,
"multimap_ size not valid in Ruby");
SWIG_RUBY_THREAD_END_BLOCK;
return Qnil;
}
VALUE obj = rb_hash_new();
for (const_iterator i= multimap.begin(); i!= multimap.end(); ++i) {
VALUE key = swig::from(i->first);
VALUE val = swig::from(i->second);
VALUE oldval = rb_hash_aref(obj, key);
if (oldval == Qnil) {
rb_hash_aset(obj, key, val);
} else {
// Multiple values for this key, create array if needed
// and add a new element to it.
VALUE ary;
if (TYPE(oldval) == T_ARRAY) {
ary = oldval;
} else {
ary = rb_ary_new2(2);
rb_ary_push(ary, oldval);
rb_hash_aset(obj, key, ary);
}
rb_ary_push(ary, val);
}
}
return obj;
}
}
};
}
}
#define %swig_unordered_multimap_methods(MultiMap...) %swig_multimap_methods(MultiMap)
%mixin std::unordered_multimap "Enumerable";
%rename("delete") std::unordered_multimap::__delete__;
%rename("reject!") std::unordered_multimap::reject_bang;
%rename("map!") std::unordered_multimap::map_bang;
%rename("empty?") std::unordered_multimap::empty;
%rename("include?" ) std::unordered_multimap::__contains__ const;
%rename("has_key?" ) std::unordered_multimap::has_key const;
%alias std::unordered_multimap::push "<<";
%include <std/std_unordered_multimap.i>

View file

@ -0,0 +1,50 @@
/*
Multisets
*/
%include <std_unordered_set.i>
%fragment("StdUnorderedMultisetTraits","header",fragment="StdUnorderedSetTraits")
%{
namespace swig {
template <class RubySeq, class T>
inline void
assign(const RubySeq& rubyseq, std::unordered_multiset<T>* seq) {
// seq->insert(rubyseq.begin(), rubyseq.end()); // not used as not always implemented
typedef typename RubySeq::value_type value_type;
typename RubySeq::const_iterator it = rubyseq.begin();
for (;it != rubyseq.end(); ++it) {
seq->insert(seq->end(),(value_type)(*it));
}
}
template <class T>
struct traits_asptr<std::unordered_multiset<T> > {
static int asptr(VALUE obj, std::unordered_multiset<T> **m) {
return traits_asptr_stdseq<std::unordered_multiset<T> >::asptr(obj, m);
}
};
template <class T>
struct traits_from<std::unordered_multiset<T> > {
static VALUE from(const std::unordered_multiset<T>& vec) {
return traits_from_stdseq<std::unordered_multiset<T> >::from(vec);
}
};
}
%}
#define %swig_unordered_multiset_methods(Set...) %swig_unordered_set_methods(Set)
%mixin std::unordered_multiset "Enumerable";
%rename("delete") std::unordered_multiset::__delete__;
%rename("reject!") std::unordered_multiset::reject_bang;
%rename("map!") std::unordered_multiset::map_bang;
%rename("empty?") std::unordered_multiset::empty;
%rename("include?") std::unordered_multiset::__contains__ const;
%rename("has_key?") std::unordered_multiset::has_key const;
%alias std::unordered_multiset::push "<<";
%include <std/std_unordered_multiset.i>

View file

@ -0,0 +1,50 @@
/*
Sets
*/
%include <std_set.i>
%fragment("StdUnorderedSetTraits","header",fragment="<stddef.h>",fragment="StdSetTraits")
%{
namespace swig {
template <class RubySeq, class T>
inline void
assign(const RubySeq& rubyseq, std::unordered_set<T>* seq) {
// seq->insert(rubyseq.begin(), rubyseq.end()); // not used as not always implemented
typedef typename RubySeq::value_type value_type;
typename RubySeq::const_iterator it = rubyseq.begin();
for (;it != rubyseq.end(); ++it) {
seq->insert(seq->end(),(value_type)(*it));
}
}
template <class T>
struct traits_asptr<std::unordered_set<T> > {
static int asptr(VALUE obj, std::unordered_set<T> **s) {
return traits_asptr_stdseq<std::unordered_set<T> >::asptr(obj, s);
}
};
template <class T>
struct traits_from<std::unordered_set<T> > {
static VALUE from(const std::unordered_set<T>& vec) {
return traits_from_stdseq<std::unordered_set<T> >::from(vec);
}
};
}
%}
#define %swig_unordered_set_methods(set...) %swig_set_methods(set)
%mixin std::unordered_set "Enumerable";
%rename("delete") std::unordered_set::__delete__;
%rename("reject!") std::unordered_set::reject_bang;
%rename("map!") std::unordered_set::map_bang;
%rename("empty?") std::unordered_set::empty;
%rename("include?" ) std::unordered_set::__contains__ const;
%rename("has_key?" ) std::unordered_set::has_key const;
%alias std::unordered_set::push "<<";
%include <std/std_unordered_set.i>

View file

@ -1,3 +1,50 @@
%{
#ifdef __cplusplus
extern "C" {
#endif
#ifdef HAVE_RUBY_ENCODING_H
#include "ruby/encoding.h"
#endif
/**
* The internal encoding of std::wstring is defined based on
* the size of wchar_t. If it is not appropriate for your library,
* SWIG_RUBY_WSTRING_ENCODING must be given when compiling.
*/
#ifndef SWIG_RUBY_WSTRING_ENCODING
#if WCHAR_MAX == 0x7fff || WCHAR_MAX == 0xffff
#define SWIG_RUBY_WSTRING_ENCODING "UTF-16LE"
#elif WCHAR_MAX == 0x7fffffff || WCHAR_MAX == 0xffffffff
#define SWIG_RUBY_WSTRING_ENCODING "UTF-32LE"
#else
#error unsupported wchar_t size. SWIG_RUBY_WSTRING_ENCODING must be given.
#endif
#endif
/**
* If Encoding.default_internal is nil, this encoding will be used
* when converting from std::wstring to String object in Ruby.
*/
#ifndef SWIG_RUBY_INTERNAL_ENCODING
#define SWIG_RUBY_INTERNAL_ENCODING "UTF-8"
#endif
static rb_encoding *swig_ruby_wstring_encoding;
static rb_encoding *swig_ruby_internal_encoding;
#ifdef __cplusplus
}
#endif
%}
%fragment("SWIG_ruby_wstring_encoding_init", "init") {
swig_ruby_wstring_encoding = rb_enc_find( SWIG_RUBY_WSTRING_ENCODING );
swig_ruby_internal_encoding = rb_enc_find( SWIG_RUBY_INTERNAL_ENCODING );
}
%include <rubywstrings.swg>
%include <typemaps/std_wstring.swg>

View file

@ -14,7 +14,7 @@
%naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
// destructor wrapper customisation
%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;"
@ -25,7 +25,7 @@
int newmem = 0;
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
%argument_fail(res, "$type", $symname, $argnum);
}
if (!argp) {
%argument_nullref("$type", $symname, $argnum);
@ -64,7 +64,7 @@
int newmem = 0;
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
%argument_fail(res, "$type", $symname, $argnum);
}
if (newmem & SWIG_CAST_NEW_MEMORY) {
tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
@ -109,7 +109,7 @@
int newmem = 0;
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
%argument_fail(res, "$type", $symname, $argnum);
}
if (!argp) { %argument_nullref("$type", $symname, $argnum); }
if (newmem & SWIG_CAST_NEW_MEMORY) {
@ -155,7 +155,7 @@
int newmem = 0;
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
%argument_fail(res, "$type", $symname, $argnum);
}
if (newmem & SWIG_CAST_NEW_MEMORY) {
tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
@ -183,7 +183,7 @@
int newmem = 0;
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
%argument_fail(res, "$type", $symname, $argnum);
}
if (argp) $1 = *(%reinterpret_cast(argp, $&ltype));
if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $&ltype);
@ -213,7 +213,7 @@
int newmem = 0;
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
%argument_fail(res, "$type", $symname, $argnum);
}
if (newmem & SWIG_CAST_NEW_MEMORY) {
if (argp) tempshared = *%reinterpret_cast(argp, $ltype);
@ -240,7 +240,7 @@
int newmem = 0;
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
%argument_fail(res, "$type", $symname, $argnum);
}
if (newmem & SWIG_CAST_NEW_MEMORY) {
if (argp) tempshared = *%reinterpret_cast(argp, $ltype);
@ -268,7 +268,7 @@
int newmem = 0;
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
%argument_fail(res, "$type", $symname, $argnum);
}
if (argp) tempshared = *%reinterpret_cast(argp, $*ltype);
if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $*ltype);
@ -288,9 +288,9 @@
%}
// Typecheck typemaps
// Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting
// Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting
// function is not called thereby avoiding a possible smart pointer copy constructor call when casting up the inheritance chain.
%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1)
%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1)
TYPE CONST,
TYPE CONST &,
TYPE CONST *,

View file

@ -42,7 +42,9 @@
%fragment("SciSequence_Cont", "header",
fragment="StdTraits",
fragment="SwigSciIterator_T")
fragment="SwigSciIterator_T",
fragment=SWIG_Traits_Sequence_frag(ptr),
fragment=SWIG_Traits_SequenceItem_frag(ptr))
{
namespace swig
{
@ -334,8 +336,7 @@ namespace swig
%fragment("StdSequenceTraits","header",
fragment="StdTraits",
fragment="SciSequence_Cont",
fragment=SWIG_Traits_SequenceItem_frag(ptr))
fragment="SciSequence_Cont")
{
namespace swig {
template <class SciSeq, class Seq>

View file

@ -41,7 +41,7 @@ namespace swig {
template <class Type>
struct traits_asptr {
static int asptr(const SwigSciObject& obj, Type **val) {
Type *p;
Type *p = 0;
swig_type_info *descriptor = type_info<Type>();
int res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR;
if (SWIG_IsOK(res)) {
@ -104,23 +104,21 @@ namespace swig {
template <class Type>
struct traits_as<Type, value_category> {
static Type as(const SwigSciObject& obj, bool throw_error) {
static Type as(const SwigSciObject& obj) {
Type v;
int res = asval(obj, &v);
if (SWIG_IsOK(res)) {
return v;
} else {
%type_error(swig::type_name<Type>());
if (throw_error)
throw std::invalid_argument("bad type");
return res;
%type_error(swig::type_name<Type>());
throw std::invalid_argument("bad type");
}
}
};
template <class Type>
struct traits_as<Type, pointer_category> {
static Type as(const SwigSciObject& obj, bool throw_error) {
static Type as(const SwigSciObject& obj) {
Type *v = 0;
int res = traits_asptr<Type>::asptr(obj, &v);
if (SWIG_IsOK(res) && v) {
@ -132,36 +130,29 @@ namespace swig {
return *v;
}
} else {
// Uninitialized return value, no Type() constructor required.
static Type *v_def = (Type*) malloc(sizeof(Type));
%type_error(swig::type_name<Type>());
if (throw_error)
throw std::invalid_argument("bad type");
memset(v_def,0,sizeof(Type));
return *v_def;
%type_error(swig::type_name<Type>());
throw std::invalid_argument("bad type");
}
}
};
template <class Type>
struct traits_as<Type*, pointer_category> {
static Type* as(const SwigSciObject& obj, bool throw_error) {
static Type* as(const SwigSciObject& obj) {
Type *v = 0;
int res = traits_asptr<Type>::asptr(obj, &v);
if (SWIG_IsOK(res)) {
return v;
} else {
%type_error(swig::type_name<Type>());
if (throw_error)
throw std::invalid_argument("bad type");
return SWIG_OK;
%type_error(swig::type_name<Type>());
throw std::invalid_argument("bad type");
}
}
};
template <class Type>
inline Type as(const SwigSciObject& obj, bool te = false) {
return traits_as<Type, typename traits<Type>::category>::as(obj, te);
inline Type as(const SwigSciObject& obj) {
return traits_as<Type, typename traits<Type>::category>::as(obj);
}
template <class Type>

View file

@ -7,7 +7,7 @@
#define SWIG_Object int
#define %append_output(obj) if (!SWIG_IsOK(SWIG_Scilab_SetOutput(pvApiCtx, obj))) return SWIG_ERROR
#define %set_constant(name, obj) if (!SWIG_IsOK(SWIG_Scilab_SetOutput(pvApiCtx, obj))) return SWIG_ERROR // Name is managed by the the function name
#define %set_constant(name, obj) if (!SWIG_IsOK(SWIG_Scilab_SetOutput(pvApiCtx, obj))) return SWIG_ERROR // Name is managed by the function name
#define %raise(obj, type, desc) SWIG_Scilab_Raise(obj, type, desc)
#define %set_output(obj) if (!SWIG_IsOK(SWIG_Scilab_SetOutput(pvApiCtx, obj))) return SWIG_ERROR
#define %set_varoutput(obj) if (!SWIG_IsOK(SWIG_Scilab_SetOutput(pvApiCtx, obj))) return SWIG_ERROR

View file

@ -1,15 +1,11 @@
//
// std::unordered_map
// Work in progress - the code is not compilable yet:
// operator--() and constructor(compare function) not available for unordered_
// types
//
%include <std_pair.i>
%include <std_container.i>
%define %std_unordered_map_methods_common(unordered_map...)
%std_container_methods(unordered_map);
%std_container_methods_without_reverse_iterators(unordered_map);
size_type erase(const key_type& x);
size_type count(const key_type& x) const;
@ -22,8 +18,6 @@
}
iterator find(const key_type& x);
iterator lower_bound(const key_type& x);
iterator upper_bound(const key_type& x);
#endif
%enddef
@ -68,7 +62,7 @@
namespace std {
template<class _Key, class _Tp, class _Compare = std::less< _Key >,
template<class _Key, class _Tp, class _Hash = std::hash< _Key >, class _Pred = std::equal_to< _Key >,
class _Alloc = allocator<std::pair< const _Key, _Tp > > >
class unordered_map {
public:
@ -101,26 +95,24 @@ namespace std {
}
}
%fragment(SWIG_Traits_frag(std::unordered_map< _Key, _Tp, _Compare, _Alloc >), "header",
%fragment(SWIG_Traits_frag(std::unordered_map< _Key, _Tp, _Hash, _Pred, _Alloc >), "header",
fragment=SWIG_Traits_frag(std::pair< _Key, _Tp >),
fragment="StdMapTraits") {
fragment="StdUnorderedMapTraits") {
namespace swig {
template <> struct traits<std::unordered_map< _Key, _Tp, _Compare, _Alloc > > {
template <> struct traits<std::unordered_map< _Key, _Tp, _Hash, _Pred, _Alloc > > {
typedef pointer_category category;
static const char* type_name() {
return "std::unordered_map<" #_Key "," #_Tp "," #_Compare "," #_Alloc " >";
return "std::unordered_map<" #_Key "," #_Tp "," #_Hash "," #_Pred "," #_Alloc " >";
}
};
}
}
%typemap_traits_ptr(SWIG_TYPECHECK_MAP, std::unordered_map< _Key, _Tp, _Compare, _Alloc >);
unordered_map( const _Compare& );
%typemap_traits_ptr(SWIG_TYPECHECK_MAP, std::unordered_map< _Key, _Tp, _Hash, _Pred, _Alloc >);
#ifdef %swig_unordered_map_methods
// Add swig/language extra methods
%swig_unordered_map_methods(std::unordered_map< _Key, _Tp, _Compare, _Alloc >);
%swig_unordered_map_methods(std::unordered_map< _Key, _Tp, _Hash, _Pred, _Alloc >);
#endif
%std_unordered_map_methods(unordered_map);

View file

@ -1,15 +1,11 @@
//
// std::unordered_multimap
// Work in progress - the code is not compilable yet:
// operator--() and constructor(compare function) not available for unordered_
// types
//
%include <std_unordered_map.i>
%define %std_unordered_multimap_methods(mmap...)
%std_map_methods_common(mmap);
%std_unordered_map_methods_common(mmap);
#ifdef SWIG_EXPORT_ITERATOR_METHODS
std::pair<iterator,iterator> equal_range(const key_type& x);
@ -44,7 +40,7 @@
namespace std {
template<class _Key, class _Tp, class _Compare = std::less< _Key >,
template<class _Key, class _Tp, class _Hash = std::hash< _Key >, class _Pred = std::equal_to< _Key >,
class _Alloc = allocator<std::pair< const _Key, _Tp > > >
class unordered_multimap {
public:
@ -63,26 +59,24 @@ namespace std {
%traits_swigtype(_Key);
%traits_swigtype(_Tp);
%fragment(SWIG_Traits_frag(std::unordered_multimap< _Key, _Tp, _Compare, _Alloc >), "header",
%fragment(SWIG_Traits_frag(std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >), "header",
fragment=SWIG_Traits_frag(std::pair< _Key, _Tp >),
fragment="StdMultimapTraits") {
fragment="StdUnorderedMultimapTraits") {
namespace swig {
template <> struct traits<std::unordered_multimap< _Key, _Tp, _Compare, _Alloc > > {
template <> struct traits<std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc > > {
typedef pointer_category category;
static const char* type_name() {
return "std::unordered_multimap<" #_Key "," #_Tp "," #_Compare "," #_Alloc " >";
return "std::unordered_multimap<" #_Key "," #_Tp "," #_Hash "," #_Pred "," #_Alloc " >";
}
};
}
}
%typemap_traits_ptr(SWIG_TYPECHECK_MULTIMAP, std::unordered_multimap< _Key, _Tp, _Compare, _Alloc >);
%typemap_traits_ptr(SWIG_TYPECHECK_MULTIMAP, std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >);
unordered_multimap( const _Compare& );
#ifdef %swig_unordered_multimap_methods
// Add swig/language extra methods
%swig_unordered_multimap_methods(std::unordered_multimap< _Key, _Tp, _Compare, _Alloc >);
%swig_unordered_multimap_methods(std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >);
#endif
%std_unordered_multimap_methods(unordered_multimap);

View file

@ -1,8 +1,5 @@
//
// std::unordered_multiset
// Work in progress - the code is not compilable yet:
// operator--() and constructor(compare function) not available for unordered_
// types
//
%include <std_unordered_set.i>
@ -43,7 +40,8 @@ namespace std {
//unordered_multiset
template <class _Key, class _Compare = std::less< _Key >,
template <class _Key, class _Hash = std::hash< _Key >,
class _Compare = std::equal_to< _Key >,
class _Alloc = allocator< _Key > >
class unordered_multiset {
public:
@ -59,26 +57,24 @@ namespace std {
%traits_swigtype(_Key);
%fragment(SWIG_Traits_frag(std::unordered_multiset< _Key, _Compare, _Alloc >), "header",
%fragment(SWIG_Traits_frag(std::unordered_multiset< _Key, _Hash, _Compare, _Alloc >), "header",
fragment=SWIG_Traits_frag(_Key),
fragment="StdMultisetTraits") {
fragment="StdUnorderedMultisetTraits") {
namespace swig {
template <> struct traits<std::unordered_multiset< _Key, _Compare, _Alloc > > {
template <> struct traits<std::unordered_multiset< _Key, _Hash, _Compare, _Alloc > > {
typedef pointer_category category;
static const char* type_name() {
return "std::unordered_multiset<" #_Key "," #_Compare "," #_Alloc " >";
return "std::unordered_multiset<" #_Key "," #_Hash "," #_Compare "," #_Alloc " >";
}
};
}
}
%typemap_traits_ptr(SWIG_TYPECHECK_MULTISET, std::unordered_multiset< _Key, _Compare, _Alloc >);
unordered_multiset( const _Compare& );
%typemap_traits_ptr(SWIG_TYPECHECK_MULTISET, std::unordered_multiset< _Key, _Hash, _Compare, _Alloc >);
#ifdef %swig_unordered_multiset_methods
// Add swig/language extra methods
%swig_unordered_multiset_methods(std::unordered_multiset< _Key, _Compare, _Alloc >);
%swig_unordered_multiset_methods(std::unordered_multiset< _Key, _Hash, _Compare, _Alloc >);
#endif
%std_unordered_multiset_methods(unordered_multiset);

View file

@ -1,8 +1,5 @@
//
// std::unordered_set
// Work in progress - the code is not compilable yet:
// operator--() and constructor(compare function) not available for unordered_
// types
//
%include <std_container.i>
@ -110,8 +107,6 @@ namespace std {
%typemap_traits_ptr(SWIG_TYPECHECK_SET, std::unordered_set< _Key, _Hash, _Compare, _Alloc >);
unordered_set( const _Compare& );
#ifdef %swig_unordered_set_methods
// Add swig/language extra methods
%swig_unordered_set_methods(std::unordered_set< _Key, _Hash, _Compare, _Alloc >);

View file

@ -309,11 +309,13 @@ static int NAME(TYPE x) {
%define %$classname %$ismember,"match$parentNode$name" %enddef
%define %$isnested "match$nested"="1" %enddef
/* -----------------------------------------------------------------------------
* Include all the warnings labels and macros
* Common includes for warning labels, macros, fragments etc
* ----------------------------------------------------------------------------- */
%include <swigwarnings.swg>
%include <swigfragments.swg>
/* -----------------------------------------------------------------------------
* Overloading support

86
Lib/swigfragments.swg Normal file
View file

@ -0,0 +1,86 @@
/* -----------------------------------------------------------------------------
* swigfragments.swg
*
* Common fragments
* ----------------------------------------------------------------------------- */
/* -----------------------------------------------------------------------------
* Fragments for C header files
* ----------------------------------------------------------------------------- */
%fragment("<float.h>", "header") %{
#include <float.h>
%}
/* Default compiler options for gcc allow long_long but not LLONG_MAX.
* Define SWIG_NO_LLONG_MAX if this added limits support is not wanted. */
%fragment("<limits.h>", "header") %{
#include <limits.h>
#if !defined(SWIG_NO_LLONG_MAX)
# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__)
# define LLONG_MAX __LONG_LONG_MAX__
# define LLONG_MIN (-LLONG_MAX - 1LL)
# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL)
# endif
#endif
%}
%fragment("<math.h>", "header") %{
#include <math.h>
%}
%fragment("<stddef.h>", "header") %{
#include <stddef.h>
%}
%fragment("<stdio.h>", "header") %{
#include <stdio.h>
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM)
# ifndef snprintf
# define snprintf _snprintf
# endif
#endif
%}
%fragment("<stdlib.h>", "header") %{
#include <stdlib.h>
#ifdef _MSC_VER
# ifndef strtoull
# define strtoull _strtoui64
# endif
# ifndef strtoll
# define strtoll _strtoi64
# endif
#endif
%}
%fragment("<wchar.h>", "header") %{
#include <wchar.h>
#include <limits.h>
#ifndef WCHAR_MIN
# define WCHAR_MIN 0
#endif
#ifndef WCHAR_MAX
# define WCHAR_MAX 65535
#endif
%}
/* -----------------------------------------------------------------------------
* Fragments for C++ header files
* ----------------------------------------------------------------------------- */
%fragment("<algorithm>", "header") %{
#include <algorithm>
%}
%fragment("<stdexcept>", "header") %{
#include <stdexcept>
%}
%fragment("<string>", "header") %{
#include <string>
%}
%fragment("<memory>", "header") %{
#include <memory>
%}

View file

@ -199,7 +199,7 @@ SWIG_Tcl_PointerTypeFromString(char *c) {
return c;
}
/* Convert a packed value value */
/* Convert a packed pointer value */
SWIGRUNTIME int
SWIG_Tcl_ConvertPacked(Tcl_Interp *SWIGUNUSEDPARM(interp) , Tcl_Obj *obj, void *ptr, int sz, swig_type_info *ty) {
swig_cast_info *tc;

View file

@ -96,75 +96,6 @@
* common fragments
* ------------------------------------------------------------ */
/* Default compiler options for gcc allow long_long but not LLONG_MAX.
* Define SWIG_NO_LLONG_MAX if this added limits support is not wanted. */
%fragment("<limits.h>","header") %{
#include <limits.h>
#if !defined(SWIG_NO_LLONG_MAX)
# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__)
# define LLONG_MAX __LONG_LONG_MAX__
# define LLONG_MIN (-LLONG_MAX - 1LL)
# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL)
# endif
#endif
%}
%fragment("<math.h>","header") %{
#include <math.h>
%}
%fragment("<wchar.h>","header") %{
#include <wchar.h>
#include <limits.h>
#ifndef WCHAR_MIN
# define WCHAR_MIN 0
#endif
#ifndef WCHAR_MAX
# define WCHAR_MAX 65535
#endif
%}
%fragment("<float.h>","header") %{
#include <float.h>
%}
%fragment("<stdio.h>","header") %{
#include <stdio.h>
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM)
# ifndef snprintf
# define snprintf _snprintf
# endif
#endif
%}
%fragment("<stdlib.h>","header") %{
#include <stdlib.h>
#ifdef _MSC_VER
# ifndef strtoull
# define strtoull _strtoui64
# endif
# ifndef strtoll
# define strtoll _strtoi64
# endif
#endif
%}
%fragment("<stddef.h>", "header") %{
#include <stddef.h>
%}
%fragment("<string>", "header") %{
#include <string>
%}
%fragment("<stdexcept>", "header") %{
#include <stdexcept>
%}
%fragment("<algorithm>", "header") %{
#include <algorithm>
%}
%fragment("SWIG_isfinite","header",fragment="<math.h>,<float.h>") %{
/* Getting isfinite working pre C99 across multiple platforms is non-trivial. Users can provide SWIG_isfinite on older platforms. */
#ifndef SWIG_isfinite

View file

@ -584,6 +584,9 @@
}
#endif
%apply SWIGTYPE (CLASS::*) { SWIGTYPE (CLASS::*const) }
%apply SWIGTYPE & { SWIGTYPE (CLASS::*const&) }
/* ------------------------------------------------------------
* --- function ptr typemaps ---
* ------------------------------------------------------------ */