fixes for directors + pointers
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7860 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
af0aab45d7
commit
f3c24eff33
16 changed files with 808 additions and 137 deletions
|
|
@ -82,7 +82,25 @@
|
|||
if (ores == SWIG_NEWOBJ) %delete(optr);
|
||||
}
|
||||
|
||||
%typemap(directorout,noblock=1,fragment=frag,warning=SWIG_WARN_TYPEMAP_THREAD_UNSAFE) const Type& {
|
||||
%typemap(directorout,noblock=1,fragment=frag,warning=SWIG_WARN_TYPEMAP_THREAD_UNSAFE) Type* {
|
||||
Type *optr = 0;
|
||||
int ores = asptr_meth($input, &optr);
|
||||
if (!ores) {
|
||||
%dirout_fail(SWIG_TypeError,"$type");
|
||||
}
|
||||
$result = optr;
|
||||
if (ores == SWIG_NEWOBJ) {
|
||||
swig_acquire_ownership(optr);
|
||||
}
|
||||
}
|
||||
%typemap(directorfree,noblock=1) Type*
|
||||
{
|
||||
if (director) {
|
||||
director->swig_release_ownership(%as_voidptr($input));
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(directorout,noblock=1,fragment=frag,warning=SWIG_WARN_TYPEMAP_THREAD_UNSAFE) Type& {
|
||||
Type *optr = 0;
|
||||
int ores = asptr_meth($input, &optr);
|
||||
if (!ores) {
|
||||
|
|
@ -92,15 +110,18 @@
|
|||
%dirout_nullref("$type");
|
||||
}
|
||||
}
|
||||
$result = optr;
|
||||
if (ores == SWIG_NEWOBJ) {
|
||||
/* Possible thread/reentrant problem here! */
|
||||
static $*ltype temp = *optr;
|
||||
$result = &temp;
|
||||
%delete(optr);
|
||||
} else {
|
||||
$result = optr;
|
||||
swig_acquire_ownership(optr);
|
||||
}
|
||||
}
|
||||
%typemap(directorfree,noblock=1) Type&
|
||||
{
|
||||
if (director) {
|
||||
director->swig_release_ownership(%as_voidptr($input));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
%typemap(directorout,fragment=frag) Type &DIRECTOROUT = Type
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
%typemap(in,noblock=1,fragment=#SWIG_AsCharPtr)
|
||||
Char * (Char *buf = 0, int alloc = 0),
|
||||
const Char * (Char *buf = 0, int alloc = SWIG_OLDOBJ) {
|
||||
const Char * (Char *buf = 0, int alloc = 0) {
|
||||
if (SWIG_AsCharPtr($input, &buf, &alloc) != SWIG_OK) {
|
||||
%argument_fail(SWIG_TypeError,"$type",$argnum);
|
||||
}
|
||||
|
|
@ -157,21 +157,41 @@
|
|||
|
||||
/* directorout */
|
||||
|
||||
%typemap(directorout,noblock=1,fragment=#SWIG_AsCharPtr)
|
||||
Char * (Char* buf = 0, int alloc = 0) {
|
||||
%typemap(directorout,noblock=1,fragment=#SWIG_AsCharPtr,warning=SWIG_WARN_TYPEMAP_THREAD_UNSAFE)
|
||||
Char * (Char* buf = 0, int alloc = SWIG_NEWOBJ) {
|
||||
if (SWIG_AsCharPtr($input, &buf, &alloc) != SWIG_OK) {
|
||||
%dirout_fail(SWIG_TypeError, "$type");
|
||||
}
|
||||
if (alloc == SWIG_NEWOBJ) {
|
||||
swig_acquire_ownership_array(buf);
|
||||
}
|
||||
$result = buf;
|
||||
}
|
||||
%typemap(directorfree,noblock=1) Char *
|
||||
{
|
||||
if (director) {
|
||||
director->swig_release_ownership(%as_voidptr($input));
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(directorout,noblock=1,fragment=#SWIG_AsCharPtr)
|
||||
Char * const& (Char* buf = 0, int alloc = 0),
|
||||
Char const* const& (Char* buf = 0, int alloc = 0) {
|
||||
|
||||
%typemap(directorout,noblock=1,fragment=#SWIG_AsCharPtr,warning=SWIG_WARN_TYPEMAP_THREAD_UNSAFE)
|
||||
Char * const& (Char* buf = 0, int alloc = SWIG_NEWOBJ),
|
||||
Char const* const& (Char* buf = 0, int alloc = SWIG_NEWOBJ) {
|
||||
if (SWIG_AsCharPtr($input, &buf, &alloc) != SWIG_OK) {
|
||||
%dirout_fail(SWIG_TypeError, "$type");
|
||||
}
|
||||
$result = ($1_ltype) &buf;
|
||||
static $*ltype tmp = buf;
|
||||
$result = &tmp;
|
||||
if (alloc == SWIG_NEWOBJ) {
|
||||
swig_acquire_ownership_array(buf);
|
||||
}
|
||||
}
|
||||
%typemap(directorfree,noblock=1)
|
||||
Char * const&, Char const* const& {
|
||||
if (director) {
|
||||
director->swig_release_ownership(%as_voidptr(*$input));
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SWIG_DIRECTOR_TYPEMAPS */
|
||||
|
|
@ -373,7 +393,7 @@
|
|||
/* Here len doesn't include the '0' terminator */
|
||||
%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize)
|
||||
(Char *STRING, size_t LENGTH) (Char *buf = 0, size_t size = 0, int alloc = 0),
|
||||
(const Char *STRING, size_t LENGTH) (Char *buf = 0, size_t size = 0, int alloc = SWIG_OLDOBJ)
|
||||
(const Char *STRING, size_t LENGTH) (Char *buf = 0, size_t size = 0, int alloc = 0)
|
||||
{
|
||||
if (SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc) != SWIG_OK) {
|
||||
%argument_fail(SWIG_TypeError,"$type",$argnum);
|
||||
|
|
@ -392,7 +412,7 @@
|
|||
/* Here size includes the '0' terminator */
|
||||
%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize)
|
||||
(Char *STRING, size_t SIZE) (Char *buf = 0, size_t size = 0, int alloc = 0),
|
||||
(const Char *STRING, size_t SIZE) (Char *buf = 0, size_t size = 0, int alloc = SWIG_OLDOBJ)
|
||||
(const Char *STRING, size_t SIZE) (Char *buf = 0, size_t size = 0, int alloc = 0)
|
||||
{
|
||||
if (SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc) != SWIG_OK) {
|
||||
%argument_fail(SWIG_TypeError,"$type",$argnum);
|
||||
|
|
@ -413,7 +433,7 @@
|
|||
/* Here len doesn't include the '0' terminator */
|
||||
%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize)
|
||||
(size_t LENGTH, Char *STRING) (Char *buf = 0, size_t size = 0, int alloc = 0),
|
||||
(size_t LENGHT, const Char *STRING) (Char *buf = 0, size_t size = 0, int alloc = SWIG_OLDOBJ)
|
||||
(size_t LENGHT, const Char *STRING) (Char *buf = 0, size_t size = 0, int alloc = 0)
|
||||
{
|
||||
if (SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc) != SWIG_OK) {
|
||||
%argument_fail(SWIG_TypeError,"$type",$argnum);
|
||||
|
|
@ -431,7 +451,7 @@
|
|||
/* Here size includes the '0' terminator */
|
||||
%typemap(in,noblock=1,fragment=#SWIG_AsCharPtrAndSize)
|
||||
(size_t SIZE, Char *STRING) (Char *buf = 0, size_t size = 0, int alloc = 0),
|
||||
(size_t SIZE, const Char *STRING) (Char *buf = 0, size_t size = 0, int alloc = SWIG_OLDOBJ)
|
||||
(size_t SIZE, const Char *STRING) (Char *buf = 0, size_t size = 0, int alloc = 0)
|
||||
{
|
||||
if (SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc) != SWIG_OK) {
|
||||
%argument_fail(SWIG_TypeError, "$type",$argnum);
|
||||
|
|
|
|||
|
|
@ -272,19 +272,35 @@
|
|||
}
|
||||
$result = *(%reinterpret_cast(argp, $<ype));
|
||||
}
|
||||
%typemap(directorout,noblock=1) SWIGTYPE *(void *argp), SWIGTYPE [](void *argp) {
|
||||
if (SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags) != SWIG_OK) {
|
||||
%typemap(directorout,noblock=1,warning=SWIG_WARN_TYPEMAP_THREAD_UNSAFE)
|
||||
SWIGTYPE *(void *argp, swig_owntype own), SWIGTYPE [](void *argp, swig_owntype own) {
|
||||
if (SWIG_ConvertPtrAndOwn($input, &argp, $descriptor, %convertptr_flags | SWIG_POINTER_DISOWN, &own) != SWIG_OK) {
|
||||
%dirout_fail(SWIG_TypeError,"$type");
|
||||
}
|
||||
$result = %reinterpret_cast(argp, $ltype);
|
||||
swig_acquire_ownership_obj(%as_voidptr($result), own);
|
||||
}
|
||||
%typemap(directorout,noblock=1) SWIGTYPE &(void *argp) {
|
||||
if (SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags) != SWIG_OK) {
|
||||
%typemap(directorfree,noblock=1) SWIGTYPE *, SWIGTYPE [] {
|
||||
if (director) {
|
||||
SWIG_AcquirePtr($result, director->swig_release_ownership(%as_voidptr($input)));
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(directorout,noblock=1,warning=SWIG_WARN_TYPEMAP_THREAD_UNSAFE)
|
||||
SWIGTYPE &(void *argp, swig_owntype own) {
|
||||
if (SWIG_ConvertPtrAndOwn($input, &argp, $descriptor, %convertptr_flags | SWIG_POINTER_DISOWN, &own) != SWIG_OK) {
|
||||
%dirout_fail(SWIG_TypeError,"$type");
|
||||
}
|
||||
if (!argp) { %dirout_nullref("$type"); }
|
||||
$result = %reinterpret_cast(argp, $ltype);
|
||||
swig_acquire_ownership_obj(%as_voidptr($result), own);
|
||||
}
|
||||
%typemap(directorfree,noblock=1) SWIGTYPE & {
|
||||
if (director) {
|
||||
SWIG_AcquirePtr($result, director->swig_release_ownership(%as_voidptr($input)));
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SWIG_DIRECTOR_TYPEMAPS */
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -129,8 +129,14 @@
|
|||
if (res != SWIG_OK) {
|
||||
%dirout_fail(res, "$type");
|
||||
}
|
||||
static $basetype temp = %static_cast(val, $basetype);
|
||||
$result = &temp;
|
||||
$basetype *temp = new $basetype(($basetype)val);
|
||||
swig_acquire_ownership(temp);
|
||||
$result = temp;
|
||||
}
|
||||
%typemap(directorfree,noblock=1) const Type & {
|
||||
if (director) {
|
||||
director->swig_release_ownership(%as_voidptr($input));
|
||||
}
|
||||
}
|
||||
%typemap(directorout,fragment=frag) Type &DIRECTOROUT = Type
|
||||
%enddef
|
||||
|
|
|
|||
|
|
@ -64,10 +64,11 @@
|
|||
$result = %reinterpret_cast(argp, $ltype);
|
||||
}
|
||||
|
||||
%typemap(directorout,noblock=1) void * const& ($*ltype temp) {
|
||||
if (SWIG_ConvertPtr($input, %as_voidptrptr(&temp), 0, $disown) != SWIG_OK) {
|
||||
%typemap(directorout,noblock=1,warning=SWIG_WARN_TYPEMAP_THREAD_UNSAFE) void * const& (void *argp) {
|
||||
if (SWIG_ConvertPtr($input, &argp, 0, $disown) != SWIG_OK) {
|
||||
%dirout_fail(SWIG_TypeError,"$type");
|
||||
}
|
||||
static $*ltype temp = %reinterpret_cast(argp, $*ltype);
|
||||
$result = &temp;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue