global variables test and shared_ptr varin/varout typemaps
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10285 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
03ac417e7f
commit
1a560e3866
6 changed files with 337 additions and 22 deletions
|
|
@ -1,3 +1,5 @@
|
||||||
Version 1.3.35 (in progress)
|
Version 1.3.35 (in progress)
|
||||||
=================================
|
============================
|
||||||
|
|
||||||
|
02/29/2008: wsfulton
|
||||||
|
[Python] Add shared_ptr varin/varout typemaps for wrapping global variables.
|
||||||
|
|
|
||||||
|
|
@ -34,12 +34,10 @@ public class runme
|
||||||
System.Threading.Thread.Sleep(10);
|
System.Threading.Thread.Sleep(10);
|
||||||
if (--countdown == 0)
|
if (--countdown == 0)
|
||||||
break;
|
break;
|
||||||
if (Klass.getTotal_count() == 0)
|
if (Klass.getTotal_count() == 1) // Expect 1 instance - the one global variable (GlobalValue)
|
||||||
break;
|
break;
|
||||||
else
|
|
||||||
Console.WriteLine("Count: {0}", Klass.getTotal_count());
|
|
||||||
};
|
};
|
||||||
if (Klass.getTotal_count() != 0)
|
if (Klass.getTotal_count() != 1)
|
||||||
throw new ApplicationException("Klass.total_count=" + Klass.getTotal_count());
|
throw new ApplicationException("Klass.total_count=" + Klass.getTotal_count());
|
||||||
|
|
||||||
int wrapper_count = li_boost_shared_ptr.shared_ptr_wrapper_count();
|
int wrapper_count = li_boost_shared_ptr.shared_ptr_wrapper_count();
|
||||||
|
|
@ -490,7 +488,77 @@ public class runme
|
||||||
try { m.MemberValue = null; throw new ApplicationException("Failed to catch null pointer"); } catch (ArgumentNullException) {}
|
try { m.MemberValue = null; throw new ApplicationException("Failed to catch null pointer"); } catch (ArgumentNullException) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
// templates
|
////////////////////////////////// Global variables ////////////////////////////////////////
|
||||||
|
// smart pointer
|
||||||
|
{
|
||||||
|
Klass kglobal = li_boost_shared_ptr.GlobalSmartValue;
|
||||||
|
if (kglobal != null)
|
||||||
|
throw new ApplicationException("expected null");
|
||||||
|
|
||||||
|
Klass k = new Klass("smart global value");
|
||||||
|
li_boost_shared_ptr.GlobalSmartValue = k;
|
||||||
|
verifyCount(2, k);
|
||||||
|
|
||||||
|
kglobal = li_boost_shared_ptr.GlobalSmartValue;
|
||||||
|
String val = kglobal.getValue();
|
||||||
|
verifyValue("smart global value", val);
|
||||||
|
verifyCount(3, kglobal);
|
||||||
|
verifyCount(3, k);
|
||||||
|
verifyValue("smart global value", li_boost_shared_ptr.GlobalSmartValue.getValue());
|
||||||
|
li_boost_shared_ptr.GlobalSmartValue = null;
|
||||||
|
}
|
||||||
|
// plain value
|
||||||
|
{
|
||||||
|
Klass kglobal;
|
||||||
|
|
||||||
|
Klass k = new Klass("global value");
|
||||||
|
li_boost_shared_ptr.GlobalValue = k;
|
||||||
|
verifyCount(1, k);
|
||||||
|
|
||||||
|
kglobal = li_boost_shared_ptr.GlobalValue;
|
||||||
|
String val = kglobal.getValue();
|
||||||
|
verifyValue("global value", val);
|
||||||
|
verifyCount(1, kglobal);
|
||||||
|
verifyCount(1, k);
|
||||||
|
verifyValue("global value", li_boost_shared_ptr.GlobalValue.getValue());
|
||||||
|
|
||||||
|
try { li_boost_shared_ptr.GlobalValue = null; throw new ApplicationException("Failed to catch null pointer"); } catch (ArgumentNullException) {}
|
||||||
|
}
|
||||||
|
// plain pointer
|
||||||
|
{
|
||||||
|
Klass kglobal = li_boost_shared_ptr.GlobalPointer;
|
||||||
|
if (kglobal != null)
|
||||||
|
throw new ApplicationException("expected null");
|
||||||
|
|
||||||
|
Klass k = new Klass("global pointer");
|
||||||
|
li_boost_shared_ptr.GlobalPointer = k;
|
||||||
|
verifyCount(1, k);
|
||||||
|
|
||||||
|
kglobal = li_boost_shared_ptr.GlobalPointer;
|
||||||
|
String val = kglobal.getValue();
|
||||||
|
verifyValue("global pointer", val);
|
||||||
|
verifyCount(1, kglobal);
|
||||||
|
verifyCount(1, k);
|
||||||
|
li_boost_shared_ptr.GlobalPointer = null;
|
||||||
|
}
|
||||||
|
// plain reference
|
||||||
|
{
|
||||||
|
Klass kglobal;
|
||||||
|
|
||||||
|
Klass k = new Klass("global reference");
|
||||||
|
li_boost_shared_ptr.GlobalReference = k;
|
||||||
|
verifyCount(1, k);
|
||||||
|
|
||||||
|
kglobal = li_boost_shared_ptr.GlobalReference;
|
||||||
|
String val = kglobal.getValue();
|
||||||
|
verifyValue("global reference", val);
|
||||||
|
verifyCount(1, kglobal);
|
||||||
|
verifyCount(1, k);
|
||||||
|
|
||||||
|
try { li_boost_shared_ptr.GlobalReference = null; throw new ApplicationException("Failed to catch null pointer"); } catch (ArgumentNullException) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////// Templates ////////////////////////////////////////
|
||||||
{
|
{
|
||||||
PairIntDouble pid = new PairIntDouble(10, 20.2);
|
PairIntDouble pid = new PairIntDouble(10, 20.2);
|
||||||
if (pid.baseVal1 != 20 || pid.baseVal2 != 40.4)
|
if (pid.baseVal1 != 20 || pid.baseVal2 != 40.4)
|
||||||
|
|
|
||||||
|
|
@ -47,10 +47,10 @@ public class li_boost_shared_ptr_runme {
|
||||||
}
|
}
|
||||||
if (--countdown == 0)
|
if (--countdown == 0)
|
||||||
break;
|
break;
|
||||||
if (Klass.getTotal_count() == 0)
|
if (Klass.getTotal_count() == 1) // Expect 1 instance - the one global variable (GlobalValue)
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
if (Klass.getTotal_count() != 0)
|
if (Klass.getTotal_count() != 1)
|
||||||
throw new RuntimeException("Klass.total_count=" + Klass.getTotal_count());
|
throw new RuntimeException("Klass.total_count=" + Klass.getTotal_count());
|
||||||
|
|
||||||
int wrapper_count = li_boost_shared_ptr.shared_ptr_wrapper_count();
|
int wrapper_count = li_boost_shared_ptr.shared_ptr_wrapper_count();
|
||||||
|
|
@ -501,7 +501,78 @@ public class li_boost_shared_ptr_runme {
|
||||||
try { m.setMemberValue(null); throw new RuntimeException("Failed to catch null pointer"); } catch (NullPointerException e) {}
|
try { m.setMemberValue(null); throw new RuntimeException("Failed to catch null pointer"); } catch (NullPointerException e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
// templates
|
////////////////////////////////// Global variables ////////////////////////////////////////
|
||||||
|
// smart pointer
|
||||||
|
{
|
||||||
|
Klass kglobal = li_boost_shared_ptr.getGlobalSmartValue();
|
||||||
|
if (kglobal != null)
|
||||||
|
throw new RuntimeException("expected null");
|
||||||
|
|
||||||
|
Klass k = new Klass("smart global value");
|
||||||
|
li_boost_shared_ptr.setGlobalSmartValue(k);
|
||||||
|
verifyCount(2, k);
|
||||||
|
|
||||||
|
kglobal = li_boost_shared_ptr.getGlobalSmartValue();
|
||||||
|
String val = kglobal.getValue();
|
||||||
|
verifyValue("smart global value", val);
|
||||||
|
verifyCount(3, kglobal);
|
||||||
|
verifyCount(3, k);
|
||||||
|
verifyValue("smart global value", li_boost_shared_ptr.getGlobalSmartValue().getValue());
|
||||||
|
li_boost_shared_ptr.setGlobalSmartValue(null);
|
||||||
|
}
|
||||||
|
// plain value
|
||||||
|
{
|
||||||
|
Klass kglobal;
|
||||||
|
|
||||||
|
Klass k = new Klass("global value");
|
||||||
|
li_boost_shared_ptr.setGlobalValue(k);
|
||||||
|
verifyCount(1, k);
|
||||||
|
|
||||||
|
kglobal = li_boost_shared_ptr.getGlobalValue();
|
||||||
|
String val = kglobal.getValue();
|
||||||
|
verifyValue("global value", val);
|
||||||
|
verifyCount(1, kglobal);
|
||||||
|
verifyCount(1, k);
|
||||||
|
verifyValue("global value", li_boost_shared_ptr.getGlobalValue().getValue());
|
||||||
|
|
||||||
|
try { li_boost_shared_ptr.setGlobalValue(null); throw new RuntimeException("Failed to catch null pointer"); } catch (NullPointerException e) {}
|
||||||
|
}
|
||||||
|
// plain pointer
|
||||||
|
{
|
||||||
|
Klass kglobal = li_boost_shared_ptr.getGlobalPointer();
|
||||||
|
if (kglobal != null)
|
||||||
|
throw new RuntimeException("expected null");
|
||||||
|
|
||||||
|
Klass k = new Klass("global pointer");
|
||||||
|
li_boost_shared_ptr.setGlobalPointer(k);
|
||||||
|
verifyCount(1, k);
|
||||||
|
|
||||||
|
kglobal = li_boost_shared_ptr.getGlobalPointer();
|
||||||
|
String val = kglobal.getValue();
|
||||||
|
verifyValue("global pointer", val);
|
||||||
|
verifyCount(1, kglobal);
|
||||||
|
verifyCount(1, k);
|
||||||
|
li_boost_shared_ptr.setGlobalPointer(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
// plain reference
|
||||||
|
{
|
||||||
|
Klass kglobal;
|
||||||
|
|
||||||
|
Klass k = new Klass("global reference");
|
||||||
|
li_boost_shared_ptr.setGlobalReference(k);
|
||||||
|
verifyCount(1, k);
|
||||||
|
|
||||||
|
kglobal = li_boost_shared_ptr.getGlobalReference();
|
||||||
|
String val = kglobal.getValue();
|
||||||
|
verifyValue("global reference", val);
|
||||||
|
verifyCount(1, kglobal);
|
||||||
|
verifyCount(1, k);
|
||||||
|
|
||||||
|
try { li_boost_shared_ptr.setGlobalReference(null); throw new RuntimeException("Failed to catch null pointer"); } catch (NullPointerException e) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////// Templates ////////////////////////////////////////
|
||||||
{
|
{
|
||||||
PairIntDouble pid = new PairIntDouble(10, 20.2);
|
PairIntDouble pid = new PairIntDouble(10, 20.2);
|
||||||
if (pid.getBaseVal1() != 20 || pid.getBaseVal2() != 40.4)
|
if (pid.getBaseVal1() != 20 || pid.getBaseVal2() != 40.4)
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,6 @@ SWIG_SHARED_PTR_DERIVED(KlassDerived, Space::Klass, Space::KlassDerived)
|
||||||
// const shared_ptr
|
// const shared_ptr
|
||||||
// std::vector
|
// std::vector
|
||||||
// Add in generic %extend for the Upcast function for derived classes
|
// Add in generic %extend for the Upcast function for derived classes
|
||||||
// Can probably remove the pgcpp for shared_ptr, unless wrapping shared_ptr<>* shared_ptr<>& and use IntPtr instead of HandleRef for C# ???
|
|
||||||
// Remove proxy upcast method - implement %feature("shadow") ??? which replaces the proxy method
|
// Remove proxy upcast method - implement %feature("shadow") ??? which replaces the proxy method
|
||||||
|
|
||||||
%exception {
|
%exception {
|
||||||
|
|
@ -281,6 +280,13 @@ struct MemberVariables {
|
||||||
Space::Klass * MemberPointer;
|
Space::Klass * MemberPointer;
|
||||||
Space::Klass & MemberReference;
|
Space::Klass & MemberReference;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Global variables
|
||||||
|
SwigBoost::shared_ptr<Space::Klass> GlobalSmartValue;
|
||||||
|
Space::Klass GlobalValue;
|
||||||
|
Space::Klass * GlobalPointer = 0;
|
||||||
|
Space::Klass & GlobalReference = GlobalValue;
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
#if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED)
|
#if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED)
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,8 @@ class li_boost_shared_ptr_runme:
|
||||||
for i in range (0,loopCount):
|
for i in range (0,loopCount):
|
||||||
self.runtest()
|
self.runtest()
|
||||||
|
|
||||||
if (li_boost_shared_ptr.Klass.getTotal_count() != 0):
|
# Expect 1 instance - the one global variable (GlobalValue)
|
||||||
|
if (li_boost_shared_ptr.Klass.getTotal_count() != 1):
|
||||||
raise RuntimeError("Klass.total_count=", li_boost_shared_ptr.Klass.getTotal_count())
|
raise RuntimeError("Klass.total_count=", li_boost_shared_ptr.Klass.getTotal_count())
|
||||||
|
|
||||||
wrapper_count = li_boost_shared_ptr.shared_ptr_wrapper_count()
|
wrapper_count = li_boost_shared_ptr.shared_ptr_wrapper_count()
|
||||||
|
|
@ -440,7 +441,78 @@ class li_boost_shared_ptr_runme:
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# templates
|
# ////////////////////////////////// Global variables ////////////////////////////////////////
|
||||||
|
# smart pointer
|
||||||
|
kglobal = li_boost_shared_ptr.cvar.GlobalSmartValue
|
||||||
|
if (kglobal != None):
|
||||||
|
raise RuntimeError("expected null")
|
||||||
|
|
||||||
|
k = li_boost_shared_ptr.Klass("smart global value")
|
||||||
|
li_boost_shared_ptr.cvar.GlobalSmartValue = k
|
||||||
|
self.verifyCount(2, k)
|
||||||
|
|
||||||
|
kglobal = li_boost_shared_ptr.cvar.GlobalSmartValue
|
||||||
|
val = kglobal.getValue()
|
||||||
|
self.verifyValue("smart global value", val)
|
||||||
|
self.verifyCount(3, kglobal)
|
||||||
|
self.verifyCount(3, k)
|
||||||
|
self.verifyValue("smart global value", li_boost_shared_ptr.cvar.GlobalSmartValue.getValue())
|
||||||
|
li_boost_shared_ptr.cvar.GlobalSmartValue = None
|
||||||
|
|
||||||
|
# plain value
|
||||||
|
k = li_boost_shared_ptr.Klass("global value")
|
||||||
|
li_boost_shared_ptr.cvar.GlobalValue = k
|
||||||
|
self.verifyCount(1, k)
|
||||||
|
|
||||||
|
kglobal = li_boost_shared_ptr.cvar.GlobalValue
|
||||||
|
val = kglobal.getValue()
|
||||||
|
self.verifyValue("global value", val)
|
||||||
|
self.verifyCount(1, kglobal)
|
||||||
|
self.verifyCount(1, k)
|
||||||
|
self.verifyValue("global value", li_boost_shared_ptr.cvar.GlobalValue.getValue())
|
||||||
|
|
||||||
|
try:
|
||||||
|
li_boost_shared_ptr.cvar.GlobalValue = None
|
||||||
|
raise RuntimeError("Failed to catch null pointer")
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# plain pointer
|
||||||
|
kglobal = li_boost_shared_ptr.cvar.GlobalPointer
|
||||||
|
if (kglobal != None):
|
||||||
|
raise RuntimeError("expected null")
|
||||||
|
|
||||||
|
k = li_boost_shared_ptr.Klass("global pointer")
|
||||||
|
li_boost_shared_ptr.cvar.GlobalPointer = k
|
||||||
|
self.verifyCount(1, k)
|
||||||
|
|
||||||
|
kglobal = li_boost_shared_ptr.cvar.GlobalPointer
|
||||||
|
val = kglobal.getValue()
|
||||||
|
self.verifyValue("global pointer", val)
|
||||||
|
self.verifyCount(1, kglobal)
|
||||||
|
self.verifyCount(1, k)
|
||||||
|
li_boost_shared_ptr.cvar.GlobalPointer = None
|
||||||
|
|
||||||
|
# plain reference
|
||||||
|
kglobal
|
||||||
|
|
||||||
|
k = li_boost_shared_ptr.Klass("global reference")
|
||||||
|
li_boost_shared_ptr.cvar.GlobalReference = k
|
||||||
|
self.verifyCount(1, k)
|
||||||
|
|
||||||
|
kglobal = li_boost_shared_ptr.cvar.GlobalReference
|
||||||
|
val = kglobal.getValue()
|
||||||
|
self.verifyValue("global reference", val)
|
||||||
|
self.verifyCount(1, kglobal)
|
||||||
|
self.verifyCount(1, k)
|
||||||
|
|
||||||
|
try:
|
||||||
|
li_boost_shared_ptr.cvar.GlobalReference = None
|
||||||
|
raise RuntimeError("Failed to catch null pointer")
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# ////////////////////////////////// Templates ////////////////////////////////////////
|
||||||
pid = li_boost_shared_ptr.PairIntDouble(10, 20.2)
|
pid = li_boost_shared_ptr.PairIntDouble(10, 20.2)
|
||||||
if (pid.baseVal1 != 20 or pid.baseVal2 != 40.4):
|
if (pid.baseVal1 != 20 or pid.baseVal2 != 40.4):
|
||||||
raise RuntimeError("Base values wrong")
|
raise RuntimeError("Base values wrong")
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,6 @@
|
||||||
|
|
||||||
%feature("smartptr", noblock=1) TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > }
|
%feature("smartptr", noblock=1) TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > }
|
||||||
|
|
||||||
// TODO:
|
|
||||||
// varout varin typemaps
|
|
||||||
|
|
||||||
// plain value
|
// plain value
|
||||||
%typemap(in) CONST TYPE (void *argp, int res = 0) {
|
%typemap(in) CONST TYPE (void *argp, int res = 0) {
|
||||||
int newmem = 0;
|
int newmem = 0;
|
||||||
|
|
@ -33,6 +30,24 @@
|
||||||
%set_output(SWIG_NewPointerObj(new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
%set_output(SWIG_NewPointerObj(new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
%typemap(varin) CONST TYPE {
|
||||||
|
void *argp = 0;
|
||||||
|
int newmem = 0;
|
||||||
|
int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
|
||||||
|
if (!SWIG_IsOK(res)) {
|
||||||
|
%variable_fail(res, "$type", "$name");
|
||||||
|
}
|
||||||
|
if (!argp) {
|
||||||
|
%argument_nullref("$type", $symname, $argnum);
|
||||||
|
} else {
|
||||||
|
$1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get());
|
||||||
|
if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
%typemap(varout) CONST TYPE {
|
||||||
|
%set_varoutput(SWIG_NewPointerObj(new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||||
|
}
|
||||||
|
|
||||||
// plain pointer
|
// plain pointer
|
||||||
%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) {
|
%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) {
|
||||||
int newmem = 0;
|
int newmem = 0;
|
||||||
|
|
@ -49,12 +64,34 @@
|
||||||
$1 = %const_cast((smartarg ? smartarg->get() : 0), $1_ltype);
|
$1 = %const_cast((smartarg ? smartarg->get() : 0), $1_ltype);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
%typemap(out, fragment="SWIG_null_deleter") CONST TYPE * {
|
%typemap(out, fragment="SWIG_null_deleter") CONST TYPE * {
|
||||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >* smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0;
|
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >* smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0;
|
||||||
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
%typemap(varin) CONST TYPE * {
|
||||||
|
void *argp = 0;
|
||||||
|
int newmem = 0;
|
||||||
|
int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
|
||||||
|
if (!SWIG_IsOK(res)) {
|
||||||
|
%variable_fail(res, "$type", "$name");
|
||||||
|
}
|
||||||
|
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared;
|
||||||
|
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0;
|
||||||
|
if (newmem & SWIG_CAST_NEW_MEMORY) {
|
||||||
|
tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||||
|
delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||||
|
$1 = %const_cast(tempshared.get(), $1_ltype);
|
||||||
|
} else {
|
||||||
|
smartarg = %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||||
|
$1 = %const_cast((smartarg ? smartarg->get() : 0), $1_ltype);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
%typemap(varout, fragment="SWIG_null_deleter") CONST TYPE * {
|
||||||
|
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >* smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0;
|
||||||
|
%set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||||
|
}
|
||||||
|
|
||||||
// plain reference
|
// plain reference
|
||||||
%typemap(in) CONST TYPE & (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) {
|
%typemap(in) CONST TYPE & (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) {
|
||||||
int newmem = 0;
|
int newmem = 0;
|
||||||
|
|
@ -76,6 +113,28 @@
|
||||||
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
%typemap(varin) CONST TYPE & {
|
||||||
|
void *argp = 0;
|
||||||
|
int newmem = 0;
|
||||||
|
int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
|
||||||
|
if (!SWIG_IsOK(res)) {
|
||||||
|
%variable_fail(res, "$type", "$name");
|
||||||
|
}
|
||||||
|
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared;
|
||||||
|
if (!argp) { %argument_nullref("$type", $symname, $argnum); }
|
||||||
|
if (newmem & SWIG_CAST_NEW_MEMORY) {
|
||||||
|
tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||||
|
delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||||
|
$1 = *%const_cast(tempshared.get(), $1_ltype);
|
||||||
|
} else {
|
||||||
|
$1 = *%const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $1_ltype);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
%typemap(varout, fragment="SWIG_null_deleter") CONST TYPE & {
|
||||||
|
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >* smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(&$1 SWIG_NO_NULL_DELETER_0);
|
||||||
|
%set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||||
|
}
|
||||||
|
|
||||||
// plain pointer by reference
|
// plain pointer by reference
|
||||||
%typemap(in) CONST TYPE *& (void *argp = 0, int res = 0, $*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) {
|
%typemap(in) CONST TYPE *& (void *argp = 0, int res = 0, $*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) {
|
||||||
int newmem = 0;
|
int newmem = 0;
|
||||||
|
|
@ -97,6 +156,13 @@
|
||||||
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
%typemap(varin) CONST TYPE *& %{
|
||||||
|
#error "varin typemap not implemented"
|
||||||
|
%}
|
||||||
|
%typemap(varout) CONST TYPE *& %{
|
||||||
|
#error "varout typemap not implemented"
|
||||||
|
%}
|
||||||
|
|
||||||
// shared_ptr by value
|
// shared_ptr by value
|
||||||
%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > (void *argp, int res = 0) {
|
%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > (void *argp, int res = 0) {
|
||||||
int newmem = 0;
|
int newmem = 0;
|
||||||
|
|
@ -107,12 +173,26 @@
|
||||||
if (argp) $1 = *(%reinterpret_cast(argp, $<ype));
|
if (argp) $1 = *(%reinterpret_cast(argp, $<ype));
|
||||||
if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $<ype);
|
if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $<ype);
|
||||||
}
|
}
|
||||||
|
|
||||||
%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
|
%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
|
||||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >* smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0;
|
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >* smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0;
|
||||||
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
|
||||||
|
int newmem = 0;
|
||||||
|
void *argp = 0;
|
||||||
|
int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
|
||||||
|
if (!SWIG_IsOK(res)) {
|
||||||
|
%variable_fail(res, "$type", "$name");
|
||||||
|
}
|
||||||
|
$1 = argp ? *(%reinterpret_cast(argp, $<ype)) : SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE >();
|
||||||
|
if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $<ype);
|
||||||
|
}
|
||||||
|
%typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
|
||||||
|
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >* smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0;
|
||||||
|
%set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||||
|
}
|
||||||
|
|
||||||
// shared_ptr by reference
|
// shared_ptr by reference
|
||||||
%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & (void *argp, int res = 0, $*1_ltype tempshared) {
|
%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & (void *argp, int res = 0, $*1_ltype tempshared) {
|
||||||
int newmem = 0;
|
int newmem = 0;
|
||||||
|
|
@ -120,11 +200,6 @@
|
||||||
if (!SWIG_IsOK(res)) {
|
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);
|
|
||||||
$1 = &tempshared;
|
|
||||||
*/
|
|
||||||
if (newmem & SWIG_CAST_NEW_MEMORY) {
|
if (newmem & SWIG_CAST_NEW_MEMORY) {
|
||||||
if (argp) tempshared = *%reinterpret_cast(argp, $ltype);
|
if (argp) tempshared = *%reinterpret_cast(argp, $ltype);
|
||||||
delete %reinterpret_cast(argp, $ltype);
|
delete %reinterpret_cast(argp, $ltype);
|
||||||
|
|
@ -138,6 +213,13 @@
|
||||||
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{
|
||||||
|
#error "varin typemap not implemented"
|
||||||
|
%}
|
||||||
|
%typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{
|
||||||
|
#error "varout typemap not implemented"
|
||||||
|
%}
|
||||||
|
|
||||||
// shared_ptr by pointer
|
// shared_ptr by pointer
|
||||||
%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * (void *argp, int res = 0, $*1_ltype tempshared) {
|
%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * (void *argp, int res = 0, $*1_ltype tempshared) {
|
||||||
int newmem = 0;
|
int newmem = 0;
|
||||||
|
|
@ -159,6 +241,13 @@
|
||||||
if ($owner) delete $1;
|
if ($owner) delete $1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{
|
||||||
|
#error "varin typemap not implemented"
|
||||||
|
%}
|
||||||
|
%typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{
|
||||||
|
#error "varout typemap not implemented"
|
||||||
|
%}
|
||||||
|
|
||||||
// shared_ptr by pointer reference
|
// 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) {
|
%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) {
|
||||||
int newmem = 0;
|
int newmem = 0;
|
||||||
|
|
@ -176,6 +265,13 @@
|
||||||
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{
|
||||||
|
#error "varin typemap not implemented"
|
||||||
|
%}
|
||||||
|
%typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{
|
||||||
|
#error "varout typemap not implemented"
|
||||||
|
%}
|
||||||
|
|
||||||
// Typecheck typemaps
|
// 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.
|
// function is not called thereby avoiding a possible smart pointer copy constructor call when casting up the inheritance chain.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue