aboutsummaryrefslogtreecommitdiff
path: root/Lib/octave
diff options
context:
space:
mode:
authorAlistair Delva <adelva@google.com>2024-04-10 14:15:29 -0700
committerAlistair Delva <adelva@google.com>2024-04-11 12:58:28 -0700
commitd0f0f90be16c2ac553b5fa08512045273135147a (patch)
tree5d9ebb7a04807ea8a609ddd18b0162bc87530e4b /Lib/octave
parent6ffc1dbf29ba98c4d8aa71ebc9b484e973fe1030 (diff)
downloadswig-master.tar.gz
Update to v4.2.1HEADmastermain
Change-Id: I47cef2be94299220d80265d949a95b58eee2c23b
Diffstat (limited to 'Lib/octave')
-rw-r--r--Lib/octave/argcargv.i52
-rw-r--r--Lib/octave/boost_shared_ptr.i6
-rw-r--r--Lib/octave/director.swg2
-rw-r--r--Lib/octave/extra-install.list2
-rw-r--r--Lib/octave/octcomplex.swg4
-rw-r--r--Lib/octave/octcontainer.swg42
-rw-r--r--Lib/octave/octheaders.hpp130
-rw-r--r--Lib/octave/octrun.swg236
-rw-r--r--Lib/octave/octruntime.swg165
-rw-r--r--Lib/octave/octtypemaps.swg11
-rw-r--r--Lib/octave/std_auto_ptr.i39
-rw-r--r--Lib/octave/std_carray.i0
-rw-r--r--Lib/octave/std_complex.i4
-rw-r--r--Lib/octave/std_unique_ptr.i39
-rw-r--r--Lib/octave/swigmove.i1
15 files changed, 542 insertions, 191 deletions
diff --git a/Lib/octave/argcargv.i b/Lib/octave/argcargv.i
new file mode 100644
index 000000000..8ddca59a4
--- /dev/null
+++ b/Lib/octave/argcargv.i
@@ -0,0 +1,52 @@
+/* -------------------------------------------------------------
+ * SWIG library containing argc and argv multi-argument typemaps
+ * ------------------------------------------------------------- */
+
+%typemap(in) (int ARGC, char **ARGV) {
+ if ($input.is_scalar_type()) {
+ $1 = 0; $2 = NULL;
+ %argument_fail(SWIG_TypeError, "'int ARGC, char **ARGV' is not a list", $symname, $argnum);
+ }
+ octave_value_list list = $input.list_value();
+ int i, len = list.length();
+ $1 = ($1_ltype) len;
+ $2 = (char **) malloc((len+1)*sizeof(char *));
+ for (i = 0; i < len; i++) {
+ if (!list(i).is_string()) {
+ $1 = 0;
+ %argument_fail(SWIG_TypeError, "'int ARGC, char **ARGV' use a non-string", $symname, $argnum);
+ }
+ const std::string & s = list(i).string_value();
+ size_t slen = s.size() + 1;
+ char * p = (char*)malloc(slen);
+ $2[i] = p;
+ memcpy(p, s.c_str(), slen);
+ }
+ $2[i] = NULL;
+}
+
+%typemap(typecheck, precedence=SWIG_TYPECHECK_STRING_ARRAY) (int ARGC, char **ARGV) {
+ $1 = 0;
+ const octave_value& ov = $input;
+ if (!ov.is_scalar_type()) {
+ octave_value_list list = ov.list_value();
+ int i, len = list.length();
+ $1 = 1;
+ for (i = 0; i < len; i++) {
+ if (!list(i).is_string()) {
+ $1 = 0;
+ break;
+ }
+ }
+ }
+}
+
+%typemap(freearg) (int ARGC, char **ARGV) {
+ if ($2 != NULL) {
+ $1_ltype i;
+ for (i = 0; i < $1; i++) {
+ free((void *)$2[i]);
+ }
+ free((void *)$2);
+ }
+}
diff --git a/Lib/octave/boost_shared_ptr.i b/Lib/octave/boost_shared_ptr.i
index 668bf4354..87c89b5f9 100644
--- a/Lib/octave/boost_shared_ptr.i
+++ b/Lib/octave/boost_shared_ptr.i
@@ -35,7 +35,7 @@
}
}
%typemap(out) CONST TYPE {
- SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1));
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype($1));
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
}
@@ -54,12 +54,12 @@
}
}
%typemap(varout) CONST TYPE {
- SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1));
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype($1));
%set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
}
%typemap(directorin,noblock=1) CONST TYPE (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
- smartarg = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1));
+ smartarg = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(SWIG_STD_MOVE($1)));
$input = SWIG_NewPointerObj(%as_voidptr(smartarg), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN | %newpointer_flags);
%}
%typemap(directorout,noblock=1) CONST TYPE (void *swig_argp, int swig_res = 0) {
diff --git a/Lib/octave/director.swg b/Lib/octave/director.swg
index bf71d18e8..5b9cd86e0 100644
--- a/Lib/octave/director.swg
+++ b/Lib/octave/director.swg
@@ -7,8 +7,6 @@
# define SWIG_DIRECTOR_CAST(ARG) dynamic_cast<Swig::Director *>(ARG)
-#include <exception>
-
namespace Swig {
class Director {
diff --git a/Lib/octave/extra-install.list b/Lib/octave/extra-install.list
new file mode 100644
index 000000000..41ef94778
--- /dev/null
+++ b/Lib/octave/extra-install.list
@@ -0,0 +1,2 @@
+# see top-level Makefile.in
+octheaders.hpp
diff --git a/Lib/octave/octcomplex.swg b/Lib/octave/octcomplex.swg
index a3e9ebf77..553c25a3d 100644
--- a/Lib/octave/octcomplex.swg
+++ b/Lib/octave/octcomplex.swg
@@ -2,7 +2,7 @@
Defines the As/From conversors for double/float complex, you need to
provide complex Type, the Name you want to use in the conversors,
the complex Constructor method, and the Real and Imag complex
- accesor methods.
+ accessor methods.
See the std_complex.i and ccomplex.i for concrete examples.
*/
@@ -73,7 +73,7 @@
int res = SWIG_AddCast(SWIG_AsVal(float)(ov, &d));
if (SWIG_IsOK(res)) {
if (val)
- *val = Constructor(d, 0.0);
+ *val = Constructor(d, 0.0f);
return res;
}
}
diff --git a/Lib/octave/octcontainer.swg b/Lib/octave/octcontainer.swg
index 310a849d9..97a345eba 100644
--- a/Lib/octave/octcontainer.swg
+++ b/Lib/octave/octcontainer.swg
@@ -11,12 +11,6 @@
* be the case.
* ----------------------------------------------------------------------------- */
-%{
-#include <climits>
-#include <iostream>
-%}
-
-
#if !defined(SWIG_NO_EXPORT_ITERATOR_METHODS)
# if !defined(SWIG_EXPORT_ITERATOR_METHODS)
# define SWIG_EXPORT_ITERATOR_METHODS SWIG_EXPORT_ITERATOR_METHODS
@@ -64,7 +58,6 @@ namespace swig {
%fragment("OctSequence_Base","header",fragment="<stddef.h>")
{
-%#include <functional>
namespace std {
template <>
@@ -73,7 +66,11 @@ namespace std {
bool
operator()(const octave_value& v, const octave_value& w) const
{
+%#if SWIG_OCTAVE_PREREQ(7,0,0)
+ octave_value res = octave::binary_op(octave_value::op_le,v,w);
+%#else
octave_value res = do_binary_op(octave_value::op_le,v,w);
+%#endif
return res.is_true();
}
};
@@ -109,7 +106,7 @@ namespace swig {
template <class Sequence, class Difference>
inline typename Sequence::iterator
- getpos(Sequence* self, Difference i) {
+ getpos(Sequence* self, Difference i) {
typename Sequence::iterator pos = self->begin();
std::advance(pos, check_index(i,self->size()));
return pos;
@@ -117,7 +114,7 @@ namespace swig {
template <class Sequence, class Difference>
inline typename Sequence::const_iterator
- cgetpos(const Sequence* self, Difference i) {
+ cgetpos(const Sequence* self, Difference i) {
typename Sequence::const_iterator pos = self->begin();
std::advance(pos, check_index(i,self->size()));
return pos;
@@ -143,25 +140,29 @@ namespace swig {
template <class Sequence, class Difference, class InputSeq>
inline void
- setslice(Sequence* self, Difference i, Difference j, const InputSeq& v) {
+ setslice(Sequence* self, Difference i, Difference j, const InputSeq& is) {
typename Sequence::size_type size = self->size();
typename Sequence::size_type ii = swig::check_index(i, size, true);
typename Sequence::size_type jj = swig::slice_index(j, size);
if (jj < ii) jj = ii;
size_t ssize = jj - ii;
- if (ssize <= v.size()) {
+ if (ssize <= is.size()) {
+ // expanding/staying the same size
typename Sequence::iterator sb = self->begin();
- typename InputSeq::const_iterator vmid = v.begin();
+ typename InputSeq::const_iterator vmid = is.begin();
std::advance(sb,ii);
std::advance(vmid, jj - ii);
- self->insert(std::copy(v.begin(), vmid, sb), vmid, v.end());
+ self->insert(std::copy(is.begin(), vmid, sb), vmid, is.end());
} else {
+ // shrinking
typename Sequence::iterator sb = self->begin();
typename Sequence::iterator se = self->begin();
std::advance(sb,ii);
std::advance(se,jj);
self->erase(sb,se);
- self->insert(sb, v.begin(), v.end());
+ sb = self->begin();
+ std::advance(sb,ii);
+ self->insert(sb, is.begin(), is.end());
}
}
@@ -205,7 +206,7 @@ namespace swig
return swig::as<T>(item);
} catch (const std::exception& e) {
char msg[1024];
- sprintf(msg, "in sequence element %d ", _index);
+ SWIG_snprintf(msg, sizeof(msg), "in sequence element %d ", _index);
if (!Octave_Error_Occurred()) {
%type_error(swig::type_name<T>());
}
@@ -576,8 +577,17 @@ namespace swig {
} else {
return octseq.check() ? SWIG_OK : SWIG_ERROR;
}
- } catch (std::exception& e) {
+ }
+%#if SWIG_OCTAVE_PREREQ(6,0,0)
+ catch (octave::execution_exception& exec) {
+ }
+%#endif
+ catch (std::exception& e) {
+%#if SWIG_OCTAVE_PREREQ(6,0,0)
+ if (seq) // Know that octave is not in an error state
+%#else
if (seq&&!error_state)
+%#endif
error("swig type error: %s",e.what());
return SWIG_ERROR;
}
diff --git a/Lib/octave/octheaders.hpp b/Lib/octave/octheaders.hpp
new file mode 100644
index 000000000..26e5564d4
--- /dev/null
+++ b/Lib/octave/octheaders.hpp
@@ -0,0 +1,130 @@
+//
+// This header includes all C++ headers required for generated Octave wrapper code.
+// Using a single header file allows pre-compilation of Octave headers, as follows:
+// * Check out this header file:
+// swig -octave -co octheaders.hpp
+// * Pre-compile header file into octheaders.hpp.gch:
+// g++ -c ... octheaders.hpp
+// * Use pre-compiled header file:
+// g++ -c -include octheaders.hpp ...
+//
+
+#if !defined(SWIG_OCTAVE_OCTHEADERS_HPP)
+#define SWIG_OCTAVE_OCTHEADERS_HPP
+
+// Required C++ headers
+#include <cstdlib>
+#include <climits>
+#include <iostream>
+#include <exception>
+#include <functional>
+#include <complex>
+#include <string>
+#include <vector>
+#include <map>
+
+// Minimal headers to define Octave version
+#include <octave/oct.h>
+#include <octave/version.h>
+
+// Macro for enabling features which require Octave version >= major.minor.patch
+// - Use (OCTAVE_PATCH_VERSION + 0) to handle both '<digit>' (released) and '<digit>+' (in development) patch numbers
+#define SWIG_OCTAVE_PREREQ(major, minor, patch) \
+ ( (OCTAVE_MAJOR_VERSION<<16) + (OCTAVE_MINOR_VERSION<<8) + (OCTAVE_PATCH_VERSION + 0) >= ((major)<<16) + ((minor)<<8) + (patch) )
+
+// Reconstruct Octave major, minor, and patch versions for releases prior to 3.8.1
+#if !defined(OCTAVE_MAJOR_VERSION)
+
+# if !defined(OCTAVE_API_VERSION_NUMBER)
+
+// Hack to distinguish between Octave 3.8.0, which removed OCTAVE_API_VERSION_NUMBER but did not yet
+// introduce OCTAVE_MAJOR_VERSION, and Octave <= 3.2, which did not define OCTAVE_API_VERSION_NUMBER
+# include <octave/ov.h>
+# if defined(octave_ov_h)
+# define OCTAVE_MAJOR_VERSION 3
+# define OCTAVE_MINOR_VERSION 8
+# define OCTAVE_PATCH_VERSION 0
+# else
+
+// Hack to distinguish between Octave 3.2 and earlier versions, before OCTAVE_API_VERSION_NUMBER existed
+# define ComplexLU __ignore
+# include <octave/CmplxLU.h>
+# undef ComplexLU
+# if defined(octave_Complex_LU_h)
+
+// We know only that this version is prior to Octave 3.2, i.e. OCTAVE_API_VERSION_NUMBER < 37
+# define OCTAVE_MAJOR_VERSION 3
+# define OCTAVE_MINOR_VERSION 1
+# define OCTAVE_PATCH_VERSION 99
+
+# else
+
+// OCTAVE_API_VERSION_NUMBER == 37
+# define OCTAVE_MAJOR_VERSION 3
+# define OCTAVE_MINOR_VERSION 2
+# define OCTAVE_PATCH_VERSION 0
+
+# endif // defined(octave_Complex_LU_h)
+
+# endif // defined(octave_ov_h)
+
+// Correlation between Octave API and version numbers extracted from Octave's
+// ChangeLogs; version is the *earliest* released Octave with that API number
+# elif OCTAVE_API_VERSION_NUMBER >= 48
+# define OCTAVE_MAJOR_VERSION 3
+# define OCTAVE_MINOR_VERSION 6
+# define OCTAVE_PATCH_VERSION 0
+
+# elif OCTAVE_API_VERSION_NUMBER >= 45
+# define OCTAVE_MAJOR_VERSION 3
+# define OCTAVE_MINOR_VERSION 4
+# define OCTAVE_PATCH_VERSION 1
+
+# elif OCTAVE_API_VERSION_NUMBER >= 42
+# define OCTAVE_MAJOR_VERSION 3
+# define OCTAVE_MINOR_VERSION 3
+# define OCTAVE_PATCH_VERSION 54
+
+# elif OCTAVE_API_VERSION_NUMBER >= 41
+# define OCTAVE_MAJOR_VERSION 3
+# define OCTAVE_MINOR_VERSION 3
+# define OCTAVE_PATCH_VERSION 53
+
+# elif OCTAVE_API_VERSION_NUMBER >= 40
+# define OCTAVE_MAJOR_VERSION 3
+# define OCTAVE_MINOR_VERSION 3
+# define OCTAVE_PATCH_VERSION 52
+
+# elif OCTAVE_API_VERSION_NUMBER >= 39
+# define OCTAVE_MAJOR_VERSION 3
+# define OCTAVE_MINOR_VERSION 3
+# define OCTAVE_PATCH_VERSION 51
+
+# else // OCTAVE_API_VERSION_NUMBER == 38
+# define OCTAVE_MAJOR_VERSION 3
+# define OCTAVE_MINOR_VERSION 3
+# define OCTAVE_PATCH_VERSION 50
+
+# endif // !defined(OCTAVE_API_VERSION_NUMBER)
+
+#endif // !defined(OCTAVE_MAJOR_VERSION)
+
+// Required Octave headers
+#include <octave/Cell.h>
+#include <octave/dynamic-ld.h>
+#include <octave/oct-env.h>
+#include <octave/oct-map.h>
+#include <octave/ov-scalar.h>
+#include <octave/ov-fcn-handle.h>
+#include <octave/parse.h>
+#if SWIG_OCTAVE_PREREQ(4,2,0)
+#include <octave/interpreter.h>
+#else
+#include <octave/toplev.h>
+#endif
+#include <octave/unwind-prot.h>
+#if SWIG_OCTAVE_PREREQ(4,2,0)
+#include <octave/call-stack.h>
+#endif
+
+#endif // !defined(SWIG_OCTAVE_OCTHEADERS_HPP)
diff --git a/Lib/octave/octrun.swg b/Lib/octave/octrun.swg
index ff614e681..5865c921b 100644
--- a/Lib/octave/octrun.swg
+++ b/Lib/octave/octrun.swg
@@ -89,10 +89,6 @@ SWIGRUNTIME void SWIG_Octave_SetModule(void *clientdata, swig_module_info *point
// Runtime API implementation
-#include <map>
-#include <vector>
-#include <string>
-
typedef octave_value_list(*octave_func) (const octave_value_list &, int);
class octave_swig_type;
@@ -175,7 +171,16 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
octave_function* function_value(bool = false) { return this; }
+#if SWIG_OCTAVE_PREREQ(6,0,0)
+ octave_value_list call(octave::tree_evaluator& tw, int nargout = 0, const octave_value_list& args = octave_value_list()) {
+ return execute(tw,nargout,args);
+ }
+#endif
+#if SWIG_OCTAVE_PREREQ(6,0,0)
+ octave_value_list execute(octave::tree_evaluator& tw, int nargout = 0, const octave_value_list& args = octave_value_list()) {
+#else
octave_value_list call(octave::tree_evaluator& tw, int nargout = 0, const octave_value_list& args = octave_value_list()) {
+#endif
octave_value_list all_args;
all_args.append(first_args);
all_args.append(args);
@@ -203,11 +208,7 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
std::set<std::string> dispatch_classes;
- private:
-
- DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
};
- DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(octave_swig_bound_func, "octave_swig_bound_func", "octave_swig_bound_func");
#else
#define SWIG_OCTAVE_BOUND_FUNC(func, args) octave_value(func)
#endif
@@ -231,7 +232,7 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
const swig_type_info *construct_type; // type of special type object
std::vector < type_ptr_pair > types; // our c++ base classes
- int own; // whether we call c++ destructors when we die
+ int thisown; // whether we call c++ destructors when we die
typedef std::pair < const swig_octave_member *, octave_value > member_value_pair;
typedef std::map < std::string, member_value_pair > member_map;
@@ -401,7 +402,11 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
}
static octave_value make_value_hack(const octave_base_value &x) {
+#if SWIG_OCTAVE_PREREQ(9,0,0)
+ ((octave_swig_type &) x).m_count++;
+#else
((octave_swig_type &) x).count++;
+#endif
return octave_value((octave_base_value *) &x);
}
@@ -411,7 +416,7 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
octave_swig_type(void *_ptr = 0, const swig_type_info *_type = 0, int _own = 0,
bool _always_static = false)
- : module(0), construct_type(_ptr ? 0 : _type), own(_own),
+ : module(0), construct_type(_ptr ? 0 : _type), thisown(_own),
always_static(_always_static) {
if (_type || _ptr)
types.push_back(std::make_pair(_type, _ptr));
@@ -425,8 +430,12 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
}
~octave_swig_type() {
- if (own) {
+ if (thisown) {
+#if SWIG_OCTAVE_PREREQ(9,0,0)
+ ++m_count;
+#else
++count;
+#endif
for (unsigned int j = 0; j < types.size(); ++j) {
if (!types[j].first || !types[j].first->clientdata)
continue;
@@ -464,10 +473,20 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
// Fill in dim_vector
for (int k=0;k<ndim;k++) {
const octave_value& obj = c(k);
+#if SWIG_OCTAVE_PREREQ(6,0,0)
+ try {
+ d.elem(k) = obj.int_value();
+ }
+ catch (octave::execution_exception& oee) {
+ // __dims__ should return a cell filled with integers
+ return dim_vector(1,1);
+ }
+#else
d.elem(k) = obj.int_value();
// __dims__ should return a cell filled with integers
if (error_state) return dim_vector(1,1);
+#endif
}
return d;
#if SWIG_OCTAVE_PREREQ(4,4,0)
@@ -476,8 +495,18 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
} else if (out.is_matrix_type() || out.is_numeric_type() ) {
#endif
if (out.rows()==1 || out.columns()==1) {
+#if SWIG_OCTAVE_PREREQ(6,0,0)
+ Array<int> a;
+ try {
+ a = out.int_vector_value();
+ }
+ catch (octave::execution_exception& oee) {
+ return dim_vector(1,1);
+ }
+#else
Array<int> a = out.int_vector_value();
if (error_state) return dim_vector(1,1);
+#endif
dim_vector d;
d.resize(a.numel() < 2 ? 2 : a.numel());
d(0) = d(1) = 1;
@@ -494,23 +523,35 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
}
octave_value as_value() {
+#if SWIG_OCTAVE_PREREQ(9,0,0)
+ ++m_count;
+#else
++count;
+#endif
return Swig::swig_value_ref(this);
}
void incref() {
+#if SWIG_OCTAVE_PREREQ(9,0,0)
+ ++m_count;
+#else
++count;
+#endif
}
void decref() {
+#if SWIG_OCTAVE_PREREQ(9,0,0)
+ if (!--m_count)
+#else
if (!--count)
+#endif
delete this;
}
- long swig_this() const {
+ size_t swig_this() const {
if (!types.size())
- return (long) this;
- return (long) types[0].second.ptr;
+ return (size_t) this;
+ return (size_t) types[0].second.ptr;
}
const char* help_text() const {
if (!types.size())
@@ -538,7 +579,7 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
}
void merge(octave_swig_type &rhs) {
- rhs.own = 0;
+ rhs.thisown = 0;
for (unsigned int j = 0; j < rhs.types.size(); ++j) {
assert(!rhs.types[j].second.destroyed);
#ifdef SWIG_DIRECTORS
@@ -561,35 +602,56 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
swig_member_const_iterator swig_members_begin() { return members.begin(); }
swig_member_const_iterator swig_members_end() { return members.end(); }
- int cast(void **vptr, swig_type_info *type, int *_own, int flags) {
+ int cast(void **vptr, swig_type_info *type, int *own, int flags) {
int res = SWIG_ERROR;
- if (_own)
- *_own = own;
- if (flags &SWIG_POINTER_DISOWN)
- own = 0;
+ int clear_pointer = 0;
+
+ if (own)
+ *own = 0;
+ if (((flags & SWIG_POINTER_RELEASE) == SWIG_POINTER_RELEASE) && !thisown) {
+ return SWIG_ERROR_RELEASE_NOT_OWNED;
+ } else {
+ if (own)
+ *own = *own | thisown;
+ if (flags & SWIG_POINTER_DISOWN) {
+ thisown = 0;
+ }
+ if (flags & SWIG_POINTER_CLEAR) {
+ clear_pointer = 1;
+ }
+ }
+
if (!type && types.size()) {
- if(vptr)
+ if (vptr) {
*vptr = types[0].second.ptr;
+ if (clear_pointer)
+ types[0].second.ptr = 0;
+ }
return SWIG_OK;
}
for (unsigned int j = 0; j < types.size(); ++j)
if (type == types[j].first) {
- if(vptr)
+ if (vptr) {
*vptr = types[j].second.ptr;
+ if (clear_pointer)
+ types[j].second.ptr = 0;
+ }
return SWIG_OK;
}
for (unsigned int j = 0; j < types.size(); ++j) {
swig_cast_info *tc = SWIG_TypeCheck(types[j].first->name, type);
if (!tc)
continue;
- if(vptr) {
+ if (vptr) {
int newmemory = 0;
*vptr = SWIG_TypeCast(tc, types[j].second.ptr, &newmemory);
- if (newmemory == SWIG_CAST_NEW_MEMORY) {
- assert(_own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */
- if (_own)
- *_own = *_own | SWIG_CAST_NEW_MEMORY;
- }
+ if (newmemory == SWIG_CAST_NEW_MEMORY) {
+ assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */
+ if (own)
+ *own = *own | SWIG_CAST_NEW_MEMORY;
+ }
+ if (clear_pointer)
+ types[j].second.ptr = 0;
}
res = SWIG_OK;
break;
@@ -598,7 +660,7 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
}
bool is_owned() const {
- return own;
+ return thisown;
}
#ifdef SWIG_DIRECTORS
@@ -639,7 +701,11 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
return true;
}
+#if SWIG_OCTAVE_PREREQ(6,0,0)
+ virtual bool isstruct() const {
+#else
virtual bool is_map() const {
+#endif
return true;
}
@@ -787,7 +853,11 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
return as_value();
}
+#if SWIG_OCTAVE_PREREQ(4,4,0)
+ virtual bool isobject() const {
+#else
virtual bool is_object() const {
+#endif
return true;
}
@@ -882,7 +952,11 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
}
virtual bool load_binary (std::istream& is, bool swap,
- oct_mach_info::float_format fmt) {
+#if SWIG_OCTAVE_PREREQ(6,0,0)
+ octave::mach_info::float_format fmt) {
+#else
+ oct_mach_info::float_format fmt) {
+#endif
return true;
}
@@ -1066,7 +1140,18 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
octave_swig_type *ptr;
public:
octave_swig_ref(octave_swig_type *_ptr = 0)
- :ptr(_ptr) { }
+ :ptr(_ptr)
+ {
+ // Ensure type_id() is set correctly
+#if SWIG_OCTAVE_PREREQ(9,0,0)
+ if (s_t_id == -1) {
+ s_t_id = octave_swig_ref::static_type_id();
+#else
+ if (t_id == -1) {
+ t_id = octave_swig_ref::static_type_id();
+#endif
+ }
+ }
~octave_swig_ref()
{ if (ptr) ptr->decref(); }
@@ -1086,8 +1171,13 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
bool is_defined() const
{ return ptr->is_defined(); }
+#if SWIG_OCTAVE_PREREQ(6,0,0)
+ virtual bool isstruct() const
+ { return ptr->isstruct(); }
+#else
virtual bool is_map() const
{ return ptr->is_map(); }
+#endif
virtual octave_value subsref(const std::string &ops, const std::list < octave_value_list > &idx)
{ return ptr->subsref(ops, idx); }
@@ -1098,8 +1188,13 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
octave_value subsasgn(const std::string &ops, const std::list < octave_value_list > &idx, const octave_value &rhs)
{ return ptr->subsasgn(ops, idx, rhs); }
+#if SWIG_OCTAVE_PREREQ(4,4,0)
+ virtual bool isobject() const
+ { return ptr->isobject(); }
+#else
virtual bool is_object() const
{ return ptr->is_object(); }
+#endif
virtual bool is_string() const
{ return ptr->is_string(); }
@@ -1144,7 +1239,11 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
{ return ptr->save_binary(os, save_as_floats); }
virtual bool load_binary (std::istream& is, bool swap,
- oct_mach_info::float_format fmt)
+#if SWIG_OCTAVE_PREREQ(6,0,0)
+ octave::mach_info::float_format fmt)
+#else
+ oct_mach_info::float_format fmt)
+#endif
{ return ptr->load_binary(is, swap, fmt); }
#if defined (HAVE_HDF5)
@@ -1180,6 +1279,14 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
#endif
{ return ptr->print(os, pr_as_read_syntax); }
+#if SWIG_OCTAVE_PREREQ(9,0,0)
+ static void set_type_id(int type_id) { s_t_id=type_id; }
+#else
+# if SWIG_OCTAVE_PREREQ(4,4,0)
+ static void set_type_id(int type_id) { t_id=type_id; }
+# endif
+#endif
+
virtual type_conv_info numeric_conversion_function(void) const {
return octave_base_value::type_conv_info (default_numeric_conversion_function,
octave_scalar::static_type_id ());
@@ -1207,8 +1314,18 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
public:
octave_swig_packed(swig_type_info *_type = 0, const void *_buf = 0, size_t _buf_len = 0)
- : type(_type), buf((const char*)_buf, (const char*)_buf + _buf_len) {
- }
+ : type(_type), buf((const char*)_buf, (const char*)_buf + _buf_len)
+ {
+ // Ensure type_id() is set correctly
+#if SWIG_OCTAVE_PREREQ(9,0,0)
+ if (s_t_id == -1) {
+ s_t_id = octave_swig_packed::static_type_id();
+#else
+ if (t_id == -1) {
+ t_id = octave_swig_packed::static_type_id();
+#endif
+ }
+ }
bool copy(swig_type_info *outtype, void *ptr, size_t sz) const {
if (outtype && outtype != type)
@@ -1254,7 +1371,11 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
}
virtual bool load_binary (std::istream& is, bool swap,
- oct_mach_info::float_format fmt) {
+#if SWIG_OCTAVE_PREREQ(6,0,0)
+ octave::mach_info::float_format fmt) {
+#else
+ oct_mach_info::float_format fmt) {
+#endif
return true;
}
@@ -1282,6 +1403,14 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
# endif
#endif
+#if SWIG_OCTAVE_PREREQ(9,0,0)
+ static void set_type_id(int type_id) { s_t_id=type_id; }
+#else
+# if SWIG_OCTAVE_PREREQ(4,4,0)
+ static void set_type_id(int type_id) { t_id=type_id; }
+# endif
+#endif
+
private:
#if !SWIG_OCTAVE_PREREQ(4,0,0)
DECLARE_OCTAVE_ALLOCATOR;
@@ -1456,12 +1585,15 @@ octave_value_typeinfo::register_binary_op(octave_value::op_##name,tid1,tid2,swig
SWIGRUNTIME octave_value SWIG_Octave_NewPointerObj(void *ptr, swig_type_info *type, int flags) {
int own = (flags &SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0;
+ if (ptr) {
#ifdef SWIG_DIRECTORS
- Swig::Director *d = Swig::get_rtdir(ptr);
- if (d && Swig::swig_director_get_self(d))
- return Swig::swig_director_get_self(d)->as_value();
+ Swig::Director *d = Swig::get_rtdir(ptr);
+ if (d && Swig::swig_director_get_self(d))
+ return Swig::swig_director_get_self(d)->as_value();
#endif
- return Swig::swig_value_ref(new octave_swig_type(ptr, type, own));
+ return Swig::swig_value_ref(new octave_swig_type(ptr, type, own));
+ }
+ return octave_value(Matrix()); // null matrix
}
SWIGRUNTIME int SWIG_Octave_ConvertPtrAndOwn(octave_value ov, void **ptr, swig_type_info *type, int flags, int *own) {
@@ -1504,16 +1636,24 @@ SWIGRUNTIMEINLINE void SWIG_Octave_SetConstant(octave_swig_type *module_ns, cons
}
SWIGRUNTIMEINLINE octave_value SWIG_Octave_GetGlobalValue(std::string name) {
+#if SWIG_OCTAVE_PREREQ(6,0,0)
+ octave::interpreter *interp = octave::interpreter::the_interpreter ();
+ return interp->global_varval(name);
+#else
#if SWIG_OCTAVE_PREREQ(4,4,0)
octave::symbol_table& symtab = octave::interpreter::the_interpreter()->get_symbol_table();
return symtab.global_varval(name);
#else
return get_global_value(name, true);
#endif
+#endif
}
SWIGRUNTIME void SWIG_Octave_SetGlobalValue(std::string name, const octave_value& value) {
-#if SWIG_OCTAVE_PREREQ(4,4,0)
+#if SWIG_OCTAVE_PREREQ(6,0,0)
+ octave::interpreter *interp = octave::interpreter::the_interpreter ();
+ interp->global_assign(name, value);
+#elif SWIG_OCTAVE_PREREQ(4,4,0)
octave::symbol_table& symtab = octave::interpreter::the_interpreter()->get_symbol_table();
symtab.global_assign(name, value);
#else
@@ -1523,10 +1663,24 @@ SWIGRUNTIME void SWIG_Octave_SetGlobalValue(std::string name, const octave_value
SWIGRUNTIME void SWIG_Octave_LinkGlobalValue(std::string name) {
#if SWIG_OCTAVE_PREREQ(4,4,0)
- octave::symbol_table& symtab = octave::interpreter::the_interpreter()->get_symbol_table();
octave::symbol_scope symscope = octave::interpreter::the_interpreter()->get_current_scope();
+#if SWIG_OCTAVE_PREREQ(6,0,0)
+ octave::interpreter *interp = octave::interpreter::the_interpreter ();
+ interp->assign(name, interp->global_varval(name));
+ octave::tree_evaluator& tree_eval = interp->get_evaluator();
+#if SWIG_OCTAVE_PREREQ(8,0,0)
+ std::shared_ptr<octave::stack_frame> stackFrame = tree_eval.get_current_stack_frame();
+#else
+ octave::call_stack& callStack = tree_eval.get_call_stack();
+ std::shared_ptr<octave::stack_frame> stackFrame = tree_eval.get_current_stack_frame();
+#endif
+ octave::symbol_record sym=symscope.lookup_symbol(name);
+ stackFrame->mark_global(sym);
+#else
+ octave::symbol_table& symtab = octave::interpreter::the_interpreter()->get_symbol_table();
symscope.assign(name, symtab.global_varval(name));
symscope.mark_global(name);
+#endif
#else
#if !SWIG_OCTAVE_PREREQ(3,2,0)
link_to_global_variable(curr_sym_tab->lookup(name, true));
diff --git a/Lib/octave/octruntime.swg b/Lib/octave/octruntime.swg
index f98bf4fe4..94e2ca4fb 100644
--- a/Lib/octave/octruntime.swg
+++ b/Lib/octave/octruntime.swg
@@ -1,111 +1,10 @@
+#ifdef SWIG_OCTAVE_EXTERNAL_OCTHEADERS
%insert(runtime) %{
-
-#include <cstdlib>
-#include <iostream>
-
-#include <octave/oct.h>
-#include <octave/version.h>
-
-// Macro for enabling features which require Octave version >= major.minor.patch
-// - Use (OCTAVE_PATCH_VERSION + 0) to handle both '<digit>' (released) and '<digit>+' (in development) patch numbers
-#define SWIG_OCTAVE_PREREQ(major, minor, patch) \
- ( (OCTAVE_MAJOR_VERSION<<16) + (OCTAVE_MINOR_VERSION<<8) + (OCTAVE_PATCH_VERSION + 0) >= ((major)<<16) + ((minor)<<8) + (patch) )
-
-// Reconstruct Octave major, minor, and patch versions for releases prior to 3.8.1
-#if !defined(OCTAVE_MAJOR_VERSION)
-
-# if !defined(OCTAVE_API_VERSION_NUMBER)
-
-// Hack to distinguish between Octave 3.8.0, which removed OCTAVE_API_VERSION_NUMBER but did not yet
-// introduce OCTAVE_MAJOR_VERSION, and Octave <= 3.2, which did not define OCTAVE_API_VERSION_NUMBER
-# include <octave/ov.h>
-# if defined(octave_ov_h)
-# define OCTAVE_MAJOR_VERSION 3
-# define OCTAVE_MINOR_VERSION 8
-# define OCTAVE_PATCH_VERSION 0
-# else
-
-// Hack to distinguish between Octave 3.2 and earlier versions, before OCTAVE_API_VERSION_NUMBER existed
-# define ComplexLU __ignore
-# include <octave/CmplxLU.h>
-# undef ComplexLU
-# if defined(octave_Complex_LU_h)
-
-// We know only that this version is prior to Octave 3.2, i.e. OCTAVE_API_VERSION_NUMBER < 37
-# define OCTAVE_MAJOR_VERSION 3
-# define OCTAVE_MINOR_VERSION 1
-# define OCTAVE_PATCH_VERSION 99
-
-# else
-
-// OCTAVE_API_VERSION_NUMBER == 37
-# define OCTAVE_MAJOR_VERSION 3
-# define OCTAVE_MINOR_VERSION 2
-# define OCTAVE_PATCH_VERSION 0
-
-# endif // defined(octave_Complex_LU_h)
-
-# endif // defined(octave_ov_h)
-
-// Correlation between Octave API and version numbers extracted from Octave's
-// ChangeLogs; version is the *earliest* released Octave with that API number
-# elif OCTAVE_API_VERSION_NUMBER >= 48
-# define OCTAVE_MAJOR_VERSION 3
-# define OCTAVE_MINOR_VERSION 6
-# define OCTAVE_PATCH_VERSION 0
-
-# elif OCTAVE_API_VERSION_NUMBER >= 45
-# define OCTAVE_MAJOR_VERSION 3
-# define OCTAVE_MINOR_VERSION 4
-# define OCTAVE_PATCH_VERSION 1
-
-# elif OCTAVE_API_VERSION_NUMBER >= 42
-# define OCTAVE_MAJOR_VERSION 3
-# define OCTAVE_MINOR_VERSION 3
-# define OCTAVE_PATCH_VERSION 54
-
-# elif OCTAVE_API_VERSION_NUMBER >= 41
-# define OCTAVE_MAJOR_VERSION 3
-# define OCTAVE_MINOR_VERSION 3
-# define OCTAVE_PATCH_VERSION 53
-
-# elif OCTAVE_API_VERSION_NUMBER >= 40
-# define OCTAVE_MAJOR_VERSION 3
-# define OCTAVE_MINOR_VERSION 3
-# define OCTAVE_PATCH_VERSION 52
-
-# elif OCTAVE_API_VERSION_NUMBER >= 39
-# define OCTAVE_MAJOR_VERSION 3
-# define OCTAVE_MINOR_VERSION 3
-# define OCTAVE_PATCH_VERSION 51
-
-# else // OCTAVE_API_VERSION_NUMBER == 38
-# define OCTAVE_MAJOR_VERSION 3
-# define OCTAVE_MINOR_VERSION 3
-# define OCTAVE_PATCH_VERSION 50
-
-# endif // !defined(OCTAVE_API_VERSION_NUMBER)
-
-#endif // !defined(OCTAVE_MAJOR_VERSION)
-
-#include <octave/Cell.h>
-#include <octave/dynamic-ld.h>
-#include <octave/oct-env.h>
-#include <octave/oct-map.h>
-#include <octave/ov-scalar.h>
-#include <octave/ov-fcn-handle.h>
-#include <octave/parse.h>
-#if SWIG_OCTAVE_PREREQ(4,2,0)
-#include <octave/interpreter.h>
+#include "octheaders.hpp"
+%}
#else
-#include <octave/toplev.h>
+%insert(runtime) "octheaders.hpp";
#endif
-#include <octave/unwind-prot.h>
-#if SWIG_OCTAVE_PREREQ(4,2,0)
-#include <octave/call-stack.h>
-#endif
-
-%}
%insert(runtime) "swigrun.swg";
%insert(runtime) "swigerrors.swg";
@@ -120,7 +19,8 @@ static bool SWIG_init_user(octave_swig_type* module_ns);
SWIGINTERN bool SWIG_Octave_LoadModule(std::string name) {
bool retn = false;
{
-#if SWIG_OCTAVE_PREREQ(4,2,0)
+#if SWIG_OCTAVE_PREREQ(6,0,0)
+#elif SWIG_OCTAVE_PREREQ(4,2,0)
octave::unwind_protect frame;
frame.protect_var(discard_error_messages); discard_error_messages = true;
frame.protect_var(discard_warning_messages); discard_warning_messages = true;
@@ -163,7 +63,8 @@ SWIGINTERN bool SWIG_Octave_LoadModule(std::string name) {
SWIGINTERN bool SWIG_Octave_InstallFunction(octave_function *octloadfcn, std::string name) {
bool retn = false;
{
-#if SWIG_OCTAVE_PREREQ(4,2,0)
+#if SWIG_OCTAVE_PREREQ(6,0,0)
+#elif SWIG_OCTAVE_PREREQ(4,2,0)
octave::unwind_protect frame;
frame.protect_var(discard_error_messages); discard_error_messages = true;
frame.protect_var(discard_warning_messages); discard_warning_messages = true;
@@ -315,13 +216,29 @@ DEFUN_DLD( swig_octave_prereq, args, nargout, swig_octave_prereq_usage ) {
return octave_value(prereq);
}
+static const char *const swig_exit_usage = "-*- texinfo -*- \n\
+@deftypefn {Loadable Function} {} swig_exit([@var{exit_status}])\n\
+Exit Octave without performing any memory cleanup.\n\
+@end deftypefn";
+
+DEFUN_DLD( swig_exit, args, nargout, swig_exit_usage ) {
+ if (args.length() > 1) {
+ error("swig_exit: must be called with at most one arguments");
+ return octave_value_list();
+ }
+ int exit_status = 0;
+ if (args.length() == 1) {
+ exit_status = args(0).int_value();
+ }
+ ::_Exit(exit_status);
+ return octave_value();
+}
+
static const char *const SWIG_name_usage = "-*- texinfo -*- \n\
@deftypefn {Loadable Module} {} " SWIG_name_d "\n\
Loads the SWIG-generated module `" SWIG_name_d "'.\n\
@end deftypefn";
-void __swig_atexit__(void) { ::_Exit(0); }
-
DEFUN_DLD( SWIG_name, args, nargout, SWIG_name_usage ) {
static octave_swig_type* module_ns = 0;
@@ -329,15 +246,16 @@ DEFUN_DLD( SWIG_name, args, nargout, SWIG_name_usage ) {
// workaround to prevent octave seg-faulting on exit: set Octave exit function
// octave_exit to _Exit, which exits immediately without trying to cleanup memory.
// definitely affected version 3.2.*, not sure about 3.3.*, seems to be fixed in
- // version 3.4.*, but reappeared in 4.2.*, so turn on for all versions after 3.2.*.
+ // version 3.4.*, reappeared in 4.2.*, hack not possible in 4.4.* or later due to
+ // removal of octave_exit, so turn on for all versions between 3.2.*. and 4.4.*.
// can be turned off with macro definition.
#ifndef SWIG_OCTAVE_NO_SEGFAULT_HACK
-#if SWIG_OCTAVE_PREREQ(4,4,0)
- atexit(__swig_atexit__);
-#elif SWIG_OCTAVE_PREREQ(3,2,0)
+#if !SWIG_OCTAVE_PREREQ(4,4,0)
+#if SWIG_OCTAVE_PREREQ(3,2,0)
octave_exit = ::_Exit;
#endif
#endif
+#endif
// check for no input and output args
if (args.length() != 0 || nargout != 0) {
@@ -376,16 +294,14 @@ DEFUN_DLD( SWIG_name, args, nargout, SWIG_name_usage ) {
string_vector types = typeinfo.installed_type_names();
bool register_octave_swig_ref = true;
bool register_octave_swig_packed = true;
- bool register_octave_swig_bound_func = true;
for (int i = 0; i < types.numel(); ++i) {
if (types(i) == octave_swig_ref::static_type_name()) {
register_octave_swig_ref = false;
+ octave_swig_ref::set_type_id(i);
}
if (types(i) == octave_swig_packed::static_type_name()) {
register_octave_swig_packed = false;
- }
- if (types(i) == octave_swig_bound_func::static_type_name()) {
- register_octave_swig_bound_func = false;
+ octave_swig_packed::set_type_id(i);
}
}
if (register_octave_swig_ref) {
@@ -394,9 +310,6 @@ DEFUN_DLD( SWIG_name, args, nargout, SWIG_name_usage ) {
if (register_octave_swig_packed) {
octave_swig_packed::register_type();
}
- if (register_octave_swig_bound_func) {
- octave_swig_bound_func::register_type();
- }
}
#else
octave_swig_ref::register_type();
@@ -405,7 +318,14 @@ DEFUN_DLD( SWIG_name, args, nargout, SWIG_name_usage ) {
SWIG_InitializeModule(0);
SWIG_PropagateClientData();
-#if SWIG_OCTAVE_PREREQ(4,4,0)
+#if SWIG_OCTAVE_PREREQ(8,0,0)
+ octave::tree_evaluator& tree_eval = octave::interpreter::the_interpreter()->get_evaluator();
+ octave_function *me = tree_eval.current_function();
+#elif SWIG_OCTAVE_PREREQ(6,0,0)
+ octave::tree_evaluator& tree_eval = octave::interpreter::the_interpreter()->get_evaluator();
+ octave::call_stack& stack = tree_eval.get_call_stack();
+ octave_function *me = stack.current_function();
+#elif SWIG_OCTAVE_PREREQ(4,4,0)
octave::call_stack& stack = octave::interpreter::the_interpreter()->get_call_stack();
octave_function *me = stack.current();
#else
@@ -427,6 +347,9 @@ DEFUN_DLD( SWIG_name, args, nargout, SWIG_name_usage ) {
if (!SWIG_Octave_InstallFunction(me, "swig_octave_prereq")) {
return octave_value_list();
}
+ if (!SWIG_Octave_InstallFunction(me, "swig_exit")) {
+ return octave_value_list();
+ }
octave_swig_type* cvar_ns=0;
if (std::string(SWIG_global_name) != ".") {
diff --git a/Lib/octave/octtypemaps.swg b/Lib/octave/octtypemaps.swg
index 4acf8e076..4984fddf7 100644
--- a/Lib/octave/octtypemaps.swg
+++ b/Lib/octave/octtypemaps.swg
@@ -32,8 +32,15 @@
#define SWIG_SetConstant(name, obj) SWIG_Octave_SetConstant(module_ns,name,obj)
// raise
-#define SWIG_Octave_Raise(OBJ, TYPE, DESC) error("C++ side threw an exception of type " TYPE)
-#define SWIG_Raise(obj, type, desc) SWIG_Octave_Raise(obj, type, desc)
+%runtime %{
+SWIGINTERN void SWIG_Octave_Raise(const octave_value &obj, const char *type) {
+ if (obj.is_string())
+ error("%s", obj.string_value().c_str());
+ else
+ error("C++ side threw an exception of type %s", type);
+}
+%}
+#define SWIG_Raise(obj, type, desc) SWIG_Octave_Raise(obj, type)
// Include the unified typemap library
%include <typemaps/swigtypemaps.swg>
diff --git a/Lib/octave/std_auto_ptr.i b/Lib/octave/std_auto_ptr.i
new file mode 100644
index 000000000..3d7ae8ba1
--- /dev/null
+++ b/Lib/octave/std_auto_ptr.i
@@ -0,0 +1,39 @@
+/* -----------------------------------------------------------------------------
+ * std_auto_ptr.i
+ *
+ * SWIG library file for handling std::auto_ptr.
+ * Memory ownership is passed from the std::auto_ptr C++ layer to the proxy
+ * class when returning a std::auto_ptr from a function.
+ * Memory ownership is passed from the proxy class to the std::auto_ptr in the
+ * C++ layer when passed as a parameter to a wrapped function.
+ * ----------------------------------------------------------------------------- */
+
+%define %auto_ptr(TYPE)
+%typemap(in, noblock=1) std::auto_ptr< TYPE > (void *argp = 0, int res = 0) {
+ res = SWIG_ConvertPtr($input, &argp, $descriptor(TYPE *), SWIG_POINTER_RELEASE | %convertptr_flags);
+ if (!SWIG_IsOK(res)) {
+ if (res == SWIG_ERROR_RELEASE_NOT_OWNED) {
+ %releasenotowned_fail(res, "TYPE *", $symname, $argnum);
+ } else {
+ %argument_fail(res, "TYPE *", $symname, $argnum);
+ }
+ }
+ $1.reset((TYPE *)argp);
+}
+
+%typemap (out) std::auto_ptr< TYPE > %{
+ %set_output(SWIG_NewPointerObj($1.release(), $descriptor(TYPE *), SWIG_POINTER_OWN | %newpointer_flags));
+%}
+
+%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::auto_ptr< TYPE > {
+ void *vptr = 0;
+ int res = SWIG_ConvertPtr($input, &vptr, $descriptor(TYPE *), 0);
+ $1 = SWIG_CheckState(res);
+}
+
+%template() std::auto_ptr< TYPE >;
+%enddef
+
+namespace std {
+ template <class T> class auto_ptr {};
+}
diff --git a/Lib/octave/std_carray.i b/Lib/octave/std_carray.i
deleted file mode 100644
index e69de29bb..000000000
--- a/Lib/octave/std_carray.i
+++ /dev/null
diff --git a/Lib/octave/std_complex.i b/Lib/octave/std_complex.i
index 30c188244..461e2fdfc 100644
--- a/Lib/octave/std_complex.i
+++ b/Lib/octave/std_complex.i
@@ -4,10 +4,6 @@
%include <octcomplex.swg>
-%{
-#include <complex>
-%}
-
namespace std {
%naturalvar complex;
template<typename T> class complex;
diff --git a/Lib/octave/std_unique_ptr.i b/Lib/octave/std_unique_ptr.i
new file mode 100644
index 000000000..f988714df
--- /dev/null
+++ b/Lib/octave/std_unique_ptr.i
@@ -0,0 +1,39 @@
+/* -----------------------------------------------------------------------------
+ * std_unique_ptr.i
+ *
+ * SWIG library file for handling std::unique_ptr.
+ * Memory ownership is passed from the std::unique_ptr C++ layer to the proxy
+ * class when returning a std::unique_ptr from a function.
+ * Memory ownership is passed from the proxy class to the std::unique_ptr in the
+ * C++ layer when passed as a parameter to a wrapped function.
+ * ----------------------------------------------------------------------------- */
+
+%define %unique_ptr(TYPE)
+%typemap(in, noblock=1) std::unique_ptr< TYPE > (void *argp = 0, int res = 0) {
+ res = SWIG_ConvertPtr($input, &argp, $descriptor(TYPE *), SWIG_POINTER_RELEASE | %convertptr_flags);
+ if (!SWIG_IsOK(res)) {
+ if (res == SWIG_ERROR_RELEASE_NOT_OWNED) {
+ %releasenotowned_fail(res, "TYPE *", $symname, $argnum);
+ } else {
+ %argument_fail(res, "TYPE *", $symname, $argnum);
+ }
+ }
+ $1.reset((TYPE *)argp);
+}
+
+%typemap (out) std::unique_ptr< TYPE > %{
+ %set_output(SWIG_NewPointerObj($1.release(), $descriptor(TYPE *), SWIG_POINTER_OWN | %newpointer_flags));
+%}
+
+%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE > {
+ void *vptr = 0;
+ int res = SWIG_ConvertPtr($input, &vptr, $descriptor(TYPE *), 0);
+ $1 = SWIG_CheckState(res);
+}
+
+%template() std::unique_ptr< TYPE >;
+%enddef
+
+namespace std {
+ template <class T> class unique_ptr {};
+}
diff --git a/Lib/octave/swigmove.i b/Lib/octave/swigmove.i
new file mode 100644
index 000000000..62ecca768
--- /dev/null
+++ b/Lib/octave/swigmove.i
@@ -0,0 +1 @@
+%include <typemaps/swigmove.swg>