Re: [C++-sig] Re: The "return always existing pointer throws
dangling error" problem
by Niall Douglas other posts by this author
Oct 26 2003 4:26AM messages near this date
Re: [C++-sig] Re: The "return always existing pointer throws dangling
error" problem
|
[C++-sig] Re: The "return always existing pointer throws dangling
error" problem
--PGPMime-Boundary-99A2EFA0
Content-type: text/plain; charset=US-ASCII
Content-transfer-encoding: 7BIT
Content-description: Mail message body
On 22 Oct 2003 at 19:05, Niall Douglas wrote:
> I'm thinking the best short-term stop-gap solution is an alternate
> call_method which basically disables the dangling pointer check. Then
> you can mark off functions in pyste which would fall foul of this
> particular problem on a case-by-case basis.
Just for reference for anyone searching the archives for a solution
to this problem, mine was to add the following to call_method.hpp:
template <
class R
BOOST_PP_ENUM_TRAILING_PARAMS_Z(1, N, class A)
>
typename detail::returnable<R> ::type
call_method2(PyObject* self, char const* name
BOOST_PP_COMMA_IF(N) BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, A,
const& a)
, boost::type<R> * = 0
)
{
PyObject* const result =
PyEval_CallMethod(
self
, const_cast<char*> (name)
, const_cast<char*> ("(" BOOST_PP_REPEAT_1ST(N,
BOOST_PYTHON_FIXED, "O") ")")
BOOST_PP_REPEAT_1ST(N,
BOOST_PYTHON_FAST_ARG_TO_PYTHON_GET, nil)
);
object refincfix(handle<> (borrowed(result)));
converter::return_from_python<R> converter;
return converter(result);
}
Then you use call_method2<> instead of call_method when calling
virtual overridable methods in python.
Cheers,
Niall
--PGPMime-Boundary-99A2EFA0
Content-Type: application/pgp-signature
-----BEGIN PGP MESSAGE-----
Version: idw's PGP-Frontend 4.9.6.1 / 9-2003 + PGP 8.0.2
iQA/AwUBP5tM58EcvDLFGKbPEQLXdwCdHe6zMTJHOIo70s2GVFLsiGF2P/UAoPMw
aI+KGTFcDx17P8GEL067ruN9
=rWE/
-----END PGP MESSAGE-----
--PGPMime-Boundary-99A2EFA0--
Attachments:
unknown1
unknown1
unknown2
unknown3
unknown4
Thread:
Niall Douglas
David Abrahams
Niall Douglas
David Abrahams
Niall Douglas
David Abrahams
David Abrahams
Niall Douglas
Niall Douglas
David Abrahams
Niall Douglas
Nicolas LELONG
Nicolas LELONG
David Abrahams
|