From f3e1293b6f121d7b9180e4f80ccad57baa29ffb3 Mon Sep 17 00:00:00 2001 From: Mark Rose Date: Mon, 11 Aug 2003 02:38:45 +0000 Subject: [PATCH] Director typemap cleanup and return by value git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@4989 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- SWIG/CHANGES.current | 4 ++++ SWIG/Lib/python/python.swg | 18 +++++++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/SWIG/CHANGES.current b/SWIG/CHANGES.current index dcf5c1836..557eaa872 100644 --- a/SWIG/CHANGES.current +++ b/SWIG/CHANGES.current @@ -1,5 +1,9 @@ Version 1.3.20 (In progress) ============================ +08/10/2003: mrose (Mark Rose) + Added a director typemap (outv) for return by value and cleaned up up a few + of the commented director typemaps. + 08/10/2003: mrose (Mark Rose) Fixed constructor generation for director classes to ignore private constructors. Protected constructors are also ignored for now, pending diff --git a/SWIG/Lib/python/python.swg b/SWIG/Lib/python/python.swg index 10db1b352..51d1fc163 100644 --- a/SWIG/Lib/python/python.swg +++ b/SWIG/Lib/python/python.swg @@ -453,12 +453,11 @@ %typemap(inv, parse="O") PyObject* ""; -/* -%typemap(inv, parse="s") SWIGTYPE { + +/* // this is rather dangerous +%typemap(inv) SWIGTYPE { { - $&1_ltype resultptr; - resultptr = new $1_ltype(($1_ltype &) $1); - $result = SWIG_NewPointerObj((void *) resultptr, $&1_descriptor, 1); + $input = SWIG_NewPointerObj((void *) &$1_name, $&1_descriptor, $owner); } } */ @@ -480,13 +479,11 @@ } */ -/* -%typemap(inv, parse="s") void "0"; -*/ -/* +/* // not currently needed, see python.cxx %typemap(inv) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] { $input = SWIG_NewPointerObj((void *) $1_name, $1_descriptor, $owner); } +%typemap(inv, parse="s") void "0"; */ @@ -518,6 +515,9 @@ OUTV_TYPEMAP(bool, PyInt_AsLong); OUTV_TYPEMAP(PyObject *, ); OUTV_TYPEMAP(char *, PyString_AsString); +/* Object returned by value. Convert from a pointer */ +%typemap(outv) SWIGTYPE ($<ype argp) + "if ((SWIG_ConvertPtr($input,(void **) &argp, $&descriptor,SWIG_POINTER_EXCEPTION | $disown )) == -1) throw SWIG_DIRECTOR_TYPE_MISMATCH(\"Pointer conversion failed.\"); $result = *argp;"; %typemap(outv) SWIGTYPE *, SWIGTYPE &,