From 358345db9eb875cb6b2bd51c5ed10efb3816d4f3 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Thu, 10 May 2018 20:32:50 +1000 Subject: [PATCH] Lib/octave: replace is_cell() with iscell() for Octave >= 4.4 --- Lib/octave/octcontainer.swg | 4 ++++ Lib/octave/octprimtypes.swg | 8 +++++++- Lib/octave/octrun.swg | 20 ++++++++++++++++++-- Lib/octave/std_pair.i | 16 ++++++++++++++-- 4 files changed, 43 insertions(+), 5 deletions(-) diff --git a/Lib/octave/octcontainer.swg b/Lib/octave/octcontainer.swg index 9b6520739..269ff7544 100644 --- a/Lib/octave/octcontainer.swg +++ b/Lib/octave/octcontainer.swg @@ -567,7 +567,11 @@ namespace swig { if (seq) *seq = p; return SWIG_OLDOBJ; } +%#if SWIG_OCTAVE_PREREQ(4,4,0) + } else if (obj.iscell()) { +%#else } else if (obj.is_cell()) { +%#endif try { OctSequence_Cont octseq(obj); if (seq) { diff --git a/Lib/octave/octprimtypes.swg b/Lib/octave/octprimtypes.swg index 663d1fe10..308fe6499 100644 --- a/Lib/octave/octprimtypes.swg +++ b/Lib/octave/octprimtypes.swg @@ -214,7 +214,13 @@ SWIG_AsVal_dec(bool)(const octave_value& ov, bool *val) SWIGINTERN int SWIG_AsCharPtrAndSize(octave_value ov, char** cptr, size_t* psize, int *alloc) { - if (ov.is_cell() && ov.rows() == 1 && ov.columns() == 1) + if ( +%#if SWIG_OCTAVE_PREREQ(4,4,0) + ov.iscell() +%#else + ov.is_cell() +%#endif + && ov.rows() == 1 && ov.columns() == 1) ov = ov.cell_value()(0); if (!ov.is_string()) return SWIG_TypeError; diff --git a/Lib/octave/octrun.swg b/Lib/octave/octrun.swg index 57a888fb4..d6f75a7b5 100644 --- a/Lib/octave/octrun.swg +++ b/Lib/octave/octrun.swg @@ -383,7 +383,11 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own); return dim_vector(1,1); // Return value should be cell or matrix of integers +#if SWIG_OCTAVE_PREREQ(4,4,0) + if (out.iscell()) { +#else if (out.is_cell()) { +#endif const Cell & c=out.cell_value(); int ndim = c.rows(); if (ndim==1 && c.columns()!=1) ndim = c.columns(); @@ -1238,7 +1242,13 @@ namespace Swig { } SWIGRUNTIME octave_swig_type *swig_value_deref(octave_value ov) { - if (ov.is_cell() && ov.rows() == 1 && ov.columns() == 1) + if ( +#if SWIG_OCTAVE_PREREQ(4,4,0) + ov.iscell() +#else + ov.is_cell() +#endif + && ov.rows() == 1 && ov.columns() == 1) ov = ov.cell_value()(0); return swig_value_deref(*ov.internal_rep()); } @@ -1357,7 +1367,13 @@ SWIGRUNTIME octave_value SWIG_Octave_NewPointerObj(void *ptr, swig_type_info *ty } SWIGRUNTIME int SWIG_Octave_ConvertPtrAndOwn(octave_value ov, void **ptr, swig_type_info *type, int flags, int *own) { - if (ov.is_cell() && ov.rows() == 1 && ov.columns() == 1) + if ( +#if SWIG_OCTAVE_PREREQ(4,4,0) + ov.iscell() +#else + ov.is_cell() +#endif + && ov.rows() == 1 && ov.columns() == 1) ov = ov.cell_value()(0); if (!ov.is_defined() || (ov.is_matrix_type() && ov.rows() == 0 && ov.columns() == 0) ) { diff --git a/Lib/octave/std_pair.i b/Lib/octave/std_pair.i index 2f3d4dfa4..2f307380e 100644 --- a/Lib/octave/std_pair.i +++ b/Lib/octave/std_pair.i @@ -38,7 +38,13 @@ } static int asval(const octave_value& obj, std::pair *val) { - if (obj.is_cell()) { + if ( +%#if SWIG_OCTAVE_PREREQ(4,4,0) + obj.iscell() +%#else + obj.is_cell() +%#endif + ) { Cell c=obj.cell_value(); if (c.numel()<2) { error("pair from Cell array requires at least two elements"); @@ -96,7 +102,13 @@ } static int asptr(const octave_value& obj, std::pair **val) { - if (obj.is_cell()) { + if ( +%#if SWIG_OCTAVE_PREREQ(4,4,0) + obj.iscell() +%#else + obj.is_cell() +%#endif + ) { Cell c=obj.cell_value(); if (c.numel()<2) { error("pair from Cell array requires at least two elements");