[C++-sig] new call policy - return_pointee_value
Roman Yakovenko
roman.yakovenko at gmail.com
Wed Nov 8 22:12:10 CET 2006
Good evening. I am working on some library that has a lot functions, that return
pointer to some fundamental type. For example:
float* get_value();
float* is actually a pointer to some instance of float and not to array.
AFAIK, today it is not possible to expose such function without creating small
wrapper. I created new call policy - return_pointee_value, that implements next
logic:
if return value is NULL pointer:
return None
else:
return object( * return value )
Usage example:
namespace bpl = boost::python;
def( "get_value"
, &get_value
, bpl::return_value_policy< bpl::return_pointee_value >() )
Source code is attached. I think, this call policy should be added to
the library.
Thoughts?
--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: return_pointee_value.hpp
Type: text/x-c++hdr
Size: 1220 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20061108/43437667/attachment.hpp>
More information about the Cplusplus-sig
mailing list