summaryrefslogtreecommitdiff
path: root/Lib/perl5
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2022-07-12 09:41:56 +0100
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2022-07-12 09:41:56 +0100
commit2bba78f7571f414e7d673073e72041b03145ea69 (patch)
tree705ccdb5231c7aed6a208de655b6d07ed4111724 /Lib/perl5
parent3cbcdbf681510a3dd4faac54736951d176f80ee2 (diff)
downloadswig-2bba78f7571f414e7d673073e72041b03145ea69.tar.gz
Add std::auto_ptr support for Perl based on std::unique_ptr
Diffstat (limited to 'Lib/perl5')
-rw-r--r--Lib/perl5/std_auto_ptr.i19
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/perl5/std_auto_ptr.i b/Lib/perl5/std_auto_ptr.i
new file mode 100644
index 000000000..ecaea2b0f
--- /dev/null
+++ b/Lib/perl5/std_auto_ptr.i
@@ -0,0 +1,19 @@
+/* -----------------------------------------------------------------------------
+ * std_auto_ptr.i
+ *
+ * The typemaps here allow handling functions returning std::auto_ptr<>,
+ * which is the most common use of this type. If you have functions taking it
+ * as parameter, these typemaps can't be used for them and you need to do
+ * something else (e.g. use shared_ptr<> which SWIG supports fully).
+ * ----------------------------------------------------------------------------- */
+
+%define %auto_ptr(TYPE)
+%typemap (out) std::auto_ptr< TYPE > %{
+ %set_output(SWIG_NewPointerObj($1.release(), $descriptor(TYPE *), SWIG_POINTER_OWN | %newpointer_flags));
+%}
+%template() std::auto_ptr< TYPE >;
+%enddef
+
+namespace std {
+ template <class T> class auto_ptr {};
+}