Merge branch 'octave-4-4-bugfix' of https://github.com/friedrichatgc/swig

Fixes #1672
This commit is contained in:
Olly Betts 2022-02-04 16:36:05 +13:00
commit a60655a86b
4 changed files with 39 additions and 6 deletions

View file

@ -19,7 +19,12 @@ clear all
# load module in a function globally before base context
clear all;
function testme_1
assert(exist("swigexample") == 3);
if compare_versions(version(), '4.4', '>=') && compare_versions(version(), '6', '<')
% in octave >= 4.4 < 6 'swigexample' is recognized as variable (1) instead of a .oct file (3) on the second call of 'swigexample'
assert(exist("swigexample") == 3 || exist("swigexample") == 1);
else
assert(exist("swigexample") == 3);
end
swigexample;
assert(isglobal("swigexample"));
assert(cvar.ivar == ifunc);
@ -32,7 +37,12 @@ assert(isglobal("swigexample"));
assert(cvar.ivar == ifunc);
clear all
function testme_2
assert(exist("swigexample") == 3);
if compare_versions(version(), '4.4', '>=') && compare_versions(version(), '6', '<')
% in octave >= 4.4 < 6 'swigexample' is recognized as variable (1) instead of a .oct file (3) on the second call of 'swigexample'
assert(exist("swigexample") == 3 || exist("swigexample") == 1);
else
assert(exist("swigexample") == 3);
end
swigexample;
assert(isglobal("swigexample"));
assert(cvar.ivar == ifunc);
@ -52,7 +62,12 @@ swigexample;
assert(isglobal("swigexample"));
assert(cvar.ivar == ifunc);
function testme_3
assert(exist("swigexample") == 3);
if compare_versions(version(), '4.4', '>=') && compare_versions(version(), '6', '<')
% in octave >= 4.4 < 6 'swigexample' is recognized as variable (1) instead of a .oct file (3) on the second call of 'swigexample'
assert(exist("swigexample") == 3 || exist("swigexample") == 1);
else
assert(exist("swigexample") == 3);
end
swigexample;
assert(isglobal("swigexample"));
assert(cvar.ivar == ifunc);
@ -65,7 +80,12 @@ swigexample;
assert(isglobal("swigexample"));
assert(cvar.ivar == ifunc);
function testme_4
assert(exist("swigexample") == 3);
if compare_versions(version(), '4.4', '>=') && compare_versions(version(), '6', '<')
% in octave >= 4.4 < 6 'swigexample' is recognized as variable (1) instead of a .oct file (3) on the second call of 'swigexample'
assert(exist("swigexample") == 3 || exist("swigexample") == 1);
else
assert(exist("swigexample") == 3);
end
swigexample;
assert(isglobal("swigexample"));
assert(cvar.ivar == ifunc);

View file

@ -0,0 +1,6 @@
% test octaves concatenation operator
function ret=horzcat(a, b)
% return the concatenation of two ComplexVal values as a cell array.
% (not really useful but it tests the concatenation of swig_ref objects)
ret={a, b};
end

View file

@ -3,6 +3,9 @@ if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
scriptDir = fileparts(mfilename('fullpath'));
addpath(scriptDir);
# Operator overloading example
swigexample
@ -42,3 +45,7 @@ if swig_octave_prereq(3,8,0)
printf("conj(a) = %s\n", disp(conj(a)));
printf("exp(a) = %s\n", disp(exp(a)));
endif
# concatenation operator
g = [a, b, c];
printf("g = %s\n",disp(g));

View file

@ -812,7 +812,7 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
return as_value();
}
#if SWIG_OCTAVE_PREREQ(6,0,0)
#if SWIG_OCTAVE_PREREQ(4,4,0)
virtual bool isobject() const {
#else
virtual bool is_object() const {
@ -1142,7 +1142,7 @@ 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(6,0,0)
#if SWIG_OCTAVE_PREREQ(4,4,0)
virtual bool isobject() const
{ return ptr->isobject(); }
#else