> ---------------------------------------------------------------------
> ------------------------------------------------------------------------------
> All of the data generated in your IT infrastructure is seriously valuable.
> Why? It contains a definitive record of application performance, security
> threats, fraudulent activity, and more. Splunk takes this data and makes
> sense of it. IT sense. And common sense.
> http://p.sf.net/sfu/splunk-d2d-c2---------------------------------------------
> ------------------------
> _______________________________________________
> Swig-user mailing list
> Swig...@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/swig-user
I suggest you avoid std::auto_ptr if possible. It is deprecated because
copying transfers ownership, which is rarely useful.
If you have a really recent C++ compiler you can use std::shared_ptr
(allows multiple owners) or std::unique_ptr (cannot be copied). Older
compilers will support tr1::shared_ptr or boost::shared_ptr, but I don't
know of a good non-copyable smart pointer.
-- Russell
------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
Swig-user mailing list
Swig...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/swig-user
Here is my macro for auto_ptr and an example using them:
%define AUTO_PTR_TYPEMAPS(TYPE...)
#if defined(SWIGJAVA)
%typemap (jni) std::auto_ptr<TYPE > "jlong"
%typemap (jtype) std::auto_ptr<TYPE > "long"
%typemap (jstype) std::auto_ptr<TYPE > "$typemap(jstype, TYPE)"
%typemap (out) std::auto_ptr<TYPE > %{
jlong lpp = 0;
*(TYPE**) &lpp = $1.release();
$result = lpp;
%}
%typemap(javaout) std::auto_ptr<TYPE > {
long cPtr = $jnicall;
return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
}
#elif defined(SWIGCSHARP)
%typemap (ctype) std::auto_ptr<TYPE > "void *"
%typemap (imtype, out="IntPtr") std::auto_ptr<TYPE > "HandleRef"
%typemap (cstype) std::auto_ptr<TYPE > "$typemap(cstype, TYPE)"
%typemap (out) std::auto_ptr<TYPE > %{
$result = (void *)$1.release();
%}
%typemap(csout, excode=SWIGEXCODE) std::auto_ptr<TYPE > {
IntPtr cPtr = $imcall;
$typemap(cstype, TYPE) ret = (cPtr == IntPtr.Zero) ? null : new
$typemap(cstype, TYPE)(cPtr, true);$excode
return ret;
}
#elif defined(SWIGPYTHON)
%typemap (out) std::auto_ptr<TYPE > %{
%set_output(SWIG_NewPointerObj(%as_voidptr($1.release()),
$descriptor(TYPE *), SWIG_POINTER_OWN | %newpointer_flags));
%}
#endif
%template() std::auto_ptr<TYPE >;
%enddef
namespace std {
template <class T> class auto_ptr {};
}
AUTO_PTR_TYPEMAPS(MyStruct)
%inline %{
#include <memory>
struct MyStruct {};
std::auto_ptr<MyStruct> factory_function() {
return std::auto_ptr<MyStruct>(new MyStruct());
}
%}
It only provides return values from functions. If you have functions
taking auto_ptr as an input, you'll have to think of something else.
SWIG provides support for shared_ptr for Python, so that is a good option.
William
------------------------------------------------------------------------------
BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts.
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1