Commit de67390b authored by Adam Mercer's avatar Adam Mercer
Browse files

Merge branch 'swig-octave' into 'master'

Fixes for SWIG Octave wrappings

See merge request lscsoft/lalsuite!1318
parents 37618aba 5116f58b
......@@ -18,12 +18,12 @@ include $(top_srcdir)/gnuscripts/lalsuite_test.am
.PHONY: swig-octave-clean-local
.PHONY: swig-octave-install-hook
.PHONY: swig-octave-uninstall-hook
.PHONY: check-octave-manual
.PHONY: run-octave
.PHONY: swig-python-all-local
.PHONY: swig-python-clean-local
.PHONY: swig-python-install-hook
.PHONY: swig-python-uninstall-hook
.PHONY: check-python-manual
.PHONY: run-python
header-links: header-links-local
......@@ -193,8 +193,8 @@ swig-octave-uninstall-hook:
test_scripts += SWIGTest$(PACKAGE_NAME)Octave.m
check-octave-manual: $(octexec_LTLIBRARIES)
$(AM_V_at)$(TESTS_ENVIRONMENT)$(test_script_compiler) $(RUNTOOL) $(OCTAVE) $(srcdir)/SWIGTest$(PACKAGE_NAME)Octave.m
run-octave: $(octexec_LTLIBRARIES)
$(AM_V_at)$(TESTS_ENVIRONMENT)$(test_script_compiler) $(RUNTOOL) $(OCTAVE) $(RUNARGS)
endif # SWIG_BUILD_OCTAVE
......@@ -259,8 +259,8 @@ swig-python-uninstall-hook:
test_scripts += SWIGTest$(PACKAGE_NAME)Python.py
check-python-manual: $(pkgpyexec_LTLIBRARIES)
$(AM_V_at)$(TESTS_ENVIRONMENT)$(test_script_compiler) $(RUNTOOL) $(PYTHON) $(srcdir)/SWIGTest$(PACKAGE_NAME)Python.py
run-python: $(pkgpyexec_LTLIBRARIES)
$(AM_V_at)$(TESTS_ENVIRONMENT)$(test_script_compiler) $(RUNTOOL) $(PYTHON) $(RUNARGS)
endif # SWIG_BUILD_PYTHON
......
......@@ -2,7 +2,7 @@
# lalsuite_swig.m4 - SWIG configuration
# Author: Karl Wette, 2011--2017
#
# serial 104
# serial 107
AC_DEFUN([_LALSUITE_CHECK_SWIG_VERSION],[
# $0: check the version of $1, and store it in ${swig_version}
......@@ -145,7 +145,7 @@ AC_DEFUN([LALSUITE_USE_SWIG],[
# check for SWIG binary with version ${swig_min_version} or later;
# use ${SWIG} if set, otherwise check common SWIG binary names
AC_SUBST([SWIG])
AC_ARG_VAR([SWIG],[the SWIG tool])
AS_IF([test "x${SWIG}" != x],[
AC_MSG_CHECKING([if ${SWIG} version is at least ${swig_min_version}])
_LALSUITE_CHECK_SWIG_VERSION([${SWIG}])
......@@ -173,6 +173,11 @@ SWIG support can be disabled by using the --disable-swig configure option]])
])
SWIG="${ac_cv_path_SWIG}"
])
AS_IF([test "x${swig_min_recommend_version}" != x],[
LALSUITE_VERSION_COMPARE([${swig_version}],[<],[${swig_min_recommend_version}],[
AC_MSG_WARN([SWIG version ${swig_min_recommend_version} or later is recommended ${swig_min_version_info}])
])
])
# check if SWIG works with ccache
ccache_swig_env="CCACHE_CPP2=1"
......@@ -268,9 +273,20 @@ AC_DEFUN([LALSUITE_USE_SWIG_OCTAVE],[
AC_CHECK_HEADERS([gsl/gsl_complex.h],,[AC_MSG_ERROR([could not find the gsl/gsl_complex.h header])])
# check for Octave
AC_PATH_PROGS(OCTAVE,[octave-cli octave],[],[])
AS_IF([test "x${OCTAVE}" = x],[
AC_MSG_ERROR([could not find octave in PATH])
AC_ARG_VAR([OCTAVE],[the Octave interpreter])
AS_IF([test "x${OCTAVE}" != x],[
AC_MSG_CHECKING([${OCTAVE} is executable])
AS_IF([test -x "${OCTAVE}"],[
AC_MSG_RESULT([yes])
],[
AC_MSG_RESULT([no])
AC_MSG_ERROR([${OCTAVE} is not executable])
])
],[
AC_PATH_PROGS([OCTAVE],[octave-cli octave],[],[])
AS_IF([test "x${OCTAVE}" = x],[
AC_MSG_ERROR([could not find octave in PATH])
])
])
# check for Octave utilities octave-config and mkoctfile
......@@ -283,7 +299,6 @@ AC_DEFUN([LALSUITE_USE_SWIG_OCTAVE],[
AC_MSG_RESULT([not found])
AC_MSG_ERROR([could not find octave-config in ${octave_dir}])
])
octave_cfg="env - ${octave_cfg}"
AC_MSG_CHECKING([for mkoctfile])
mkoctfile="${octave_dir}/mkoctfile"
AS_IF([test -x "${mkoctfile}"],[
......@@ -292,12 +307,11 @@ AC_DEFUN([LALSUITE_USE_SWIG_OCTAVE],[
AC_MSG_RESULT([not found])
AC_MSG_ERROR([could not find mkoctfile in ${octave_dir}])
])
mkoctfile="env - ${mkoctfile}"
# check Octave version
octave_min_version=3.2.0
AC_MSG_CHECKING([${OCTAVE} version])
octave_version=[`${octave_cfg} -p VERSION 2>/dev/null`]
octave_version=[`env -u VERSION ${octave_cfg} -p VERSION 2>/dev/null`]
AS_IF([test "x${octave_version}" = x],[
AC_MSG_ERROR([could not determine ${OCTAVE} version])
])
......@@ -305,6 +319,8 @@ AC_DEFUN([LALSUITE_USE_SWIG_OCTAVE],[
LALSUITE_VERSION_COMPARE([${octave_version}],[<],[${octave_min_version}],[
AC_MSG_ERROR([Octave version ${octave_min_version} or later is required])
])
# set minimum SWIG version requirements based on Octave version
LALSUITE_VERSION_COMPARE([${octave_version}],[>=],[4.0.0],[
LALSUITE_VERSION_COMPARE([${swig_min_version}],[<],[3.0.7],[
swig_min_version=3.0.7
......@@ -317,16 +333,11 @@ AC_DEFUN([LALSUITE_USE_SWIG_OCTAVE],[
swig_min_version_info="for Octave version ${octave_version}"
])
])
# debian buster has patched swig-3.0.12-2 to support octave 4.4,
# so we ignore this requirement on that platform
cat /etc/issue | grep -Eiq "debian .*(10|buster|11|bullseye)"
AS_IF([test $? -ne 0],[
LALSUITE_VERSION_COMPARE([${octave_version}],[>=],[4.4.0],[
LALSUITE_VERSION_COMPARE([${swig_min_version}],[<],[4.0.0],[
swig_min_version=4.0.0
swig_min_version_info="for Octave version ${octave_version}"
])
LALSUITE_VERSION_COMPARE([${octave_version}],[>=],[4.4.0],[
LALSUITE_VERSION_COMPARE([${swig_min_version}],[<],[4.0.2],[
# TODO: once SWIG 4.0.2 is released and widely available, replace 'swig_min_recommend_version' with 'swig_min_version'
swig_min_recommend_version=4.0.2
swig_min_version_info="for Octave version ${octave_version}"
])
])
......@@ -335,13 +346,16 @@ AC_DEFUN([LALSUITE_USE_SWIG_OCTAVE],[
# is installed in the same directory as Octave, .oct files will be found by
# Octave without having to add to OCTAVE_PATH
AC_MSG_CHECKING([${OCTAVE} .oct installation directory])
# at least in Debian Buster, "HOME" has been dropped in favour of "OCTAVE_HOME"
octave_prefix=[`${octave_cfg} -p OCTAVE_HOME 2>/dev/null | ${SED} -e 's|/*$||'`]
# fallback if OCTAVE_HOME is yet unknown
for octave_prefix_variable in OCTAVE_HOME PREFIX; do
octave_prefix=[`env -u ${octave_prefix_variable} ${octave_cfg} -p ${octave_prefix_variable} 2>/dev/null | ${SED} -e 's|/*$||'`]
AS_IF([test "x${octave_prefix}" != x],[
break
])
done
AS_IF([test "x${octave_prefix}" = x],[
octave_prefix=[`${octave_cfg} -p PREFIX 2>/dev/null | ${SED} -e 's|/*$||'`]
])
octexecdir=[`${octave_cfg} -p LOCALVEROCTFILEDIR 2>/dev/null | ${SED} -e 's|/*$||'`]
AC_MSG_ERROR([could not determine ${OCTAVE} installation prefix])
])
octexecdir=[`env -u LOCALVEROCTFILEDIR ${octave_cfg} -p LOCALVEROCTFILEDIR 2>/dev/null | ${SED} -e 's|/*$||'`]
octexecdir=[`echo ${octexecdir} | ${SED} -e "s|^${octave_prefix}/||"`]
AS_IF([test "x`echo ${octexecdir} | ${SED} -n -e '\|^/|p'`" != x],[
AC_MSG_ERROR([could not build relative path from "${octexecdir}"])
......@@ -352,7 +366,10 @@ AC_DEFUN([LALSUITE_USE_SWIG_OCTAVE],[
# determine C++ compiler used to compile Octave itself
AC_MSG_CHECKING([C++ compiler used for building ${OCTAVE}])
octave_CXX=`${mkoctfile} -p CXX 2>/dev/null`
octave_CXX=`env -u CXX ${mkoctfile} -p CXX 2>/dev/null`
AS_IF([test "x${octave_CXX}" = x],[
AC_MSG_ERROR([could not determine C++ compiler used for building ${OCTAVE}])
])
AC_MSG_RESULT([${octave_CXX}])
# check that configured C++ compiler is compatible with C++ compiler used to
......@@ -398,7 +415,7 @@ int main() { std::string s = "a"; return 0; }
AC_SUBST([SWIG_OCTAVE_CPPFLAGS],[])
AC_SUBST([SWIG_OCTAVE_CPPFLAGS_IOCTAVE],[])
for arg in CPPFLAGS INCFLAGS; do
for flag in `${mkoctfile} -p ${arg} 2>/dev/null`; do
for flag in `env -u ${arg} ${mkoctfile} -p ${arg} 2>/dev/null`; do
AS_CASE([${flag}],
[-I*/octave],[SWIG_OCTAVE_CPPFLAGS_IOCTAVE="${flag}"],
[SWIG_OCTAVE_CPPFLAGS="${SWIG_OCTAVE_CPPFLAGS} ${flag}"]
......@@ -410,7 +427,7 @@ int main() { std::string s = "a"; return 0; }
AC_SUBST([SWIG_OCTAVE_CXXFLAGS],[])
swig_octave_cxxflags=
for arg in CXX CXXPICFLAG ALL_CXXFLAGS; do
for flag in `${mkoctfile} -p ${arg} 2>/dev/null`; do
for flag in `env -u ${arg} ${mkoctfile} -p ${arg} 2>/dev/null`; do
AS_CASE([${flag}],
[-*],[swig_octave_cxxflags="${swig_octave_cxxflags} ${flag}"]
)
......@@ -433,8 +450,16 @@ int main() { std::string s = "a"; return 0; }
# determine Octave linker flags
AC_SUBST([SWIG_OCTAVE_LDFLAGS],[])
swig_octave_ldflags=
for arg in LFLAGS LIBOCTINTERP LIBOCTAVE LIBCRUFT OCT_LINK_OPTS OCT_LINK_DEPS; do
for flag in `${mkoctfile} -p ${arg} 2>/dev/null`; do
for arg in OCTLIBDIR; do
for flag in `env -u ${arg} ${mkoctfile} -p ${arg} 2>/dev/null`; do
AS_CASE([${flag}],
[/*],[swig_octave_ldflags="${swig_octave_ldflags}-L${flag} "],
[:]
)
done
done
for arg in LDFLAGS LFLAGS LIBOCTINTERP LIBOCTAVE LIBCRUFT OCT_LINK_OPTS OCT_LINK_DEPS; do
for flag in `env -u ${arg} ${mkoctfile} -p ${arg} 2>/dev/null`; do
AS_CASE([${flag}],
[-L/usr/lib|-L/usr/lib64],[:],
[-Xlinker],[swig_octave_ldflags="${swig_octave_ldflags}-Wl,"],
......
......@@ -605,23 +605,23 @@ struct TAGNAME {
/// Type checkers for overloaded functions:
///
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE[ANY] {
$typemap(swiglal_fixarr_ltype, $1_type) temp[$1_dim0];
$typemap(swiglal_fixarr_ltype, $1_type) temp_array[$1_dim0];
const size_t dims[1] = {$1_dim0};
const size_t strides[1] = {1};
/* swiglal_array_typeid input type: $1_type */
int res = %swiglal_array_copyin($1_type)(swiglal_no_self(), $input, %as_voidptr(&temp[0]), NULL,
sizeof(temp[0]), 1, dims, strides,
int res = %swiglal_array_copyin($1_type)(swiglal_no_self(), $input, %as_voidptr(&temp_array[0]), NULL,
sizeof(temp_array[0]), 1, dims, strides,
$typemap(swiglal_fixarr_isptr, $1_type), $typemap(swiglal_fixarr_tinfo, $1_type),
%convertptr_flags);
$1 = SWIG_CheckState(res);
}
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE[ANY][ANY] {
$typemap(swiglal_fixarr_ltype, $1_type) temp[$1_dim0][$1_dim1];
$typemap(swiglal_fixarr_ltype, $1_type) temp_array[$1_dim0][$1_dim1];
const size_t dims[2] = {$1_dim0, $1_dim1};
const size_t strides[2] = {$1_dim1, 1};
/* swiglal_array_typeid input type: $1_type */
int res = %swiglal_array_copyin($1_type)(swiglal_no_self(), $input, %as_voidptr(&temp[0]), NULL,
sizeof(temp[0][0]), 2, dims, strides,
int res = %swiglal_array_copyin($1_type)(swiglal_no_self(), $input, %as_voidptr(&temp_array[0]), NULL,
sizeof(temp_array[0][0]), 2, dims, strides,
$typemap(swiglal_fixarr_isptr, $1_type), $typemap(swiglal_fixarr_tinfo, $1_type),
%convertptr_flags);
$1 = SWIG_CheckState(res);
......@@ -631,8 +631,8 @@ struct TAGNAME {
/// Input typemaps for functions and structs:
///
%typemap(in, noblock=1) SWIGTYPE[ANY] (size_t dims[1] = {0}, int elemalloc = 0), SWIGTYPE INOUT[ANY] (size_t dims[1] = {0}, int elemalloc = 0) {
$typemap(swiglal_fixarr_ltype, $1_type) temp$argnum[$1_dim0];
$1 = &temp$argnum[0];
$typemap(swiglal_fixarr_ltype, $1_type) temp_array$argnum[$1_dim0];
$1 = &temp_array$argnum[0];
{
dims[0] = $1_dim0;
const size_t strides[1] = {1};
......@@ -647,11 +647,11 @@ struct TAGNAME {
}
}
%typemap(freearg, match="in", noblock=1) SWIGTYPE[ANY], SWIGTYPE INOUT[ANY] {
swiglal_array_elemfree(%as_voidptr(&temp$argnum[0]), &elemalloc$argnum, sizeof(temp$argnum[0]), 1, dims$argnum);
swiglal_array_elemfree(arg$argnum, &elemalloc$argnum, sizeof($typemap(swiglal_fixarr_ltype, $1_type)), 1, dims$argnum);
}
%typemap(in, noblock=1) SWIGTYPE[ANY][ANY] (size_t dims[2] = {0, 0}, int elemalloc = 0), SWIGTYPE INOUT[ANY][ANY] (size_t dims[2] = {0, 0}, int elemalloc = 0) {
$typemap(swiglal_fixarr_ltype, $1_type) temp$argnum[$1_dim0][$1_dim1];
$1 = &temp$argnum[0];
$typemap(swiglal_fixarr_ltype, $1_type) temp_array$argnum[$1_dim0][$1_dim1];
$1 = &temp_array$argnum[0];
{
dims[0] = $1_dim0; dims[1] = $1_dim1;
const size_t strides[2] = {$1_dim1, 1};
......@@ -666,7 +666,7 @@ struct TAGNAME {
}
}
%typemap(freearg, match="in", noblock=1) SWIGTYPE[ANY][ANY], SWIGTYPE INOUT[ANY][ANY] {
swiglal_array_elemfree(%as_voidptr(&temp$argnum[0][0]), &elemalloc$argnum, sizeof(temp$argnum[0][0]), 2, dims$argnum);
swiglal_array_elemfree(arg$argnum, &elemalloc$argnum, sizeof($typemap(swiglal_fixarr_ltype, $1_type)), 2, dims$argnum);
}
///
......@@ -761,8 +761,8 @@ struct TAGNAME {
/// Argument-output typemaps for functions:
///
%typemap(in, noblock=1, numinputs=0) SWIGTYPE OUTPUT[ANY] {
$typemap(swiglal_fixarr_ltype, $1_type) temp$argnum[$1_dim0];
$1 = &temp$argnum[0];
$typemap(swiglal_fixarr_ltype, $1_type) temp_array$argnum[$1_dim0];
$1 = &temp_array$argnum[0];
}
%typemap(argout) SWIGTYPE OUTPUT[ANY], SWIGTYPE INOUT[ANY] {
const size_t dims[1] = {$1_dim0};
......@@ -774,8 +774,8 @@ struct TAGNAME {
SWIG_POINTER_OWN | %newpointer_flags));
}
%typemap(in, noblock=1, numinputs=0) SWIGTYPE OUTPUT[ANY][ANY] {
$typemap(swiglal_fixarr_ltype, $1_type) temp$argnum[$1_dim0][$1_dim1];
$1 = &temp$argnum[0];
$typemap(swiglal_fixarr_ltype, $1_type) temp_array$argnum[$1_dim0][$1_dim1];
$1 = &temp_array$argnum[0];
}
%typemap(argout) SWIGTYPE OUTPUT[ANY][ANY], SWIGTYPE INOUT[ANY][ANY] {
const size_t dims[2] = {$1_dim0, $1_dim1};
......@@ -1070,33 +1070,33 @@ if (strides[I-1] == 0) {
/// <ul><li>
/// Typemap which attempts to view pointers to <tt>const NAME*</tt>.
%typemap(in, noblock=1) const NAME* (void *argp = 0, int res = 0, NAME temp, void *temp_data = 0, size_t dims[1] = {0}, int elemalloc = 0) %{
%typemap(in, noblock=1) const NAME* (void *argp = 0, int res = 0, NAME temp_struct, void *temp_data = 0, size_t dims[1] = {0}, int elemalloc = 0) %{
res = SWIG_ConvertPtr($input, &argp, $descriptor, 0 /*$disown*/ | %convertptr_flags);
if (!SWIG_IsOK(res)) {
typedef struct { SIZET NI; TYPE* DATA; } sizchk_t;
if (!($disown) && sizeof(sizchk_t) == sizeof(NAME)) {
temp.DATA = NULL;
temp_struct.DATA = NULL;
/* swiglal_array_typeid input type: TYPE* */
res = %swiglal_array_viewin(TYPE*)(swiglal_no_self(), $input, %as_voidptrptr(&temp.DATA),
res = %swiglal_array_viewin(TYPE*)(swiglal_no_self(), $input, %as_voidptrptr(&temp_struct.DATA),
sizeof(TYPE), 1, dims,
$typemap(swiglal_dynarr_isptr, TYPE), $typemap(swiglal_dynarr_tinfo, TYPE),
$disown | %convertptr_flags);
if (!SWIG_IsOK(res)) {
temp_data = temp.DATA = %swiglal_new_array(dims[0], TYPE);
temp_data = temp_struct.DATA = %swiglal_new_array(dims[0], TYPE);
size_t strides[1] = {1};
res = %swiglal_array_copyin(TYPE*)(swiglal_no_self(), $input, %as_voidptr(temp.DATA), &elemalloc,
res = %swiglal_array_copyin(TYPE*)(swiglal_no_self(), $input, %as_voidptr(temp_struct.DATA), &elemalloc,
sizeof(TYPE), 1, dims, strides,
$typemap(swiglal_dynarr_isptr, TYPE), $typemap(swiglal_dynarr_tinfo, TYPE),
$disown | %convertptr_flags);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
} else {
temp.NI = %static_cast(dims[0], SIZET);
argp = &temp;
temp_struct.NI = %static_cast(dims[0], SIZET);
argp = &temp_struct;
}
} else {
temp.NI = %static_cast(dims[0], SIZET);
argp = &temp;
temp_struct.NI = %static_cast(dims[0], SIZET);
argp = &temp_struct;
}
} else {
%argument_fail(res, "$type", $symname, $argnum);
......@@ -1114,23 +1114,23 @@ if (strides[I-1] == 0) {
/// </li><li>
/// Typemap which attempts to view pointers to non-<tt>const</tt> \c NAME*.
%typemap(in, noblock=1) NAME* SWIGLAL_VIEWIN_ARRAY (void *argp = 0, int res = 0, NAME temp) %{
%typemap(in, noblock=1) NAME* SWIGLAL_VIEWIN_ARRAY (void *argp = 0, int res = 0, NAME temp_struct) %{
res = SWIG_ConvertPtr($input, &argp, $descriptor, 0 /*$disown*/ | %convertptr_flags);
if (!SWIG_IsOK(res)) {
typedef struct { SIZET NI; TYPE* DATA; } sizchk_t;
if (!($disown) && sizeof(sizchk_t) == sizeof(NAME)) {
size_t dims[1] = {0};
temp.DATA = NULL;
temp_struct.DATA = NULL;
/* swiglal_array_typeid input type: TYPE* */
res = %swiglal_array_viewin(TYPE*)(swiglal_no_self(), $input, %as_voidptrptr(&temp.DATA),
res = %swiglal_array_viewin(TYPE*)(swiglal_no_self(), $input, %as_voidptrptr(&temp_struct.DATA),
sizeof(TYPE), 1, dims,
$typemap(swiglal_dynarr_isptr, TYPE), $typemap(swiglal_dynarr_tinfo, TYPE),
$disown | %convertptr_flags);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
} else {
temp.NI = %static_cast(dims[0], SIZET);
argp = &temp;
temp_struct.NI = %static_cast(dims[0], SIZET);
argp = &temp_struct;
}
} else {
%argument_fail(res, "$type", $symname, $argnum);
......@@ -1146,7 +1146,7 @@ if (strides[I-1] == 0) {
/// - If the input argument is a SWIG-wrapped \c NAME*, just unwrap it and return a reference.
/// - If the input argument is a native scripting-language array, make an internal copy of it,
/// use the copy, and return a native scripting-language array copy of the internal copy.
%typemap(in, noblock=1) NAME* SWIGLAL_COPYINOUT_ARRAY (void *argp = 0, int res = 0, NAME temp, SWIG_Object input_ref, void *temp_data = 0, size_t dims[1] = {0}, int elemalloc = 0) %{
%typemap(in, noblock=1) NAME* SWIGLAL_COPYINOUT_ARRAY (void *argp = 0, int res = 0, NAME temp_struct, SWIG_Object input_ref, void *temp_data = 0, size_t dims[1] = {0}, int elemalloc = 0) %{
res = SWIG_ConvertPtr($input, &argp, $descriptor, 0 /*$disown*/ | %convertptr_flags);
if (!SWIG_IsOK(res)) {
typedef struct { SIZET NI; TYPE* DATA; } sizchk_t;
......@@ -1157,7 +1157,7 @@ if (strides[I-1] == 0) {
$typemap(swiglal_dynarr_isptr, TYPE), $typemap(swiglal_dynarr_tinfo, TYPE),
$disown | %convertptr_flags);
if (dims[0] > 0) {
temp_data = temp.DATA = %swiglal_new_array(dims[0], TYPE);
temp_data = temp_struct.DATA = %swiglal_new_array(dims[0], TYPE);
size_t strides[1] = {1};
res = %swiglal_array_copyin(TYPE*)(swiglal_no_self(), $input, %as_voidptr(temp_data), &elemalloc,
sizeof(TYPE), 1, dims, strides,
......@@ -1166,8 +1166,8 @@ if (strides[I-1] == 0) {
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
} else {
temp.NI = %static_cast(dims[0], SIZET);
argp = &temp;
temp_struct.NI = %static_cast(dims[0], SIZET);
argp = &temp_struct;
}
} else {
%argument_fail(res, "$type", $symname, $argnum);
......@@ -1182,7 +1182,7 @@ if (strides[I-1] == 0) {
%}
%typemap(argout, match="in", noblock=1) NAME* SWIGLAL_COPYINOUT_ARRAY %{
if (temp_data$argnum) {
const size_t dims[1] = {%static_cast(temp$argnum.NI, size_t)};
const size_t dims[1] = {%static_cast(temp_struct$argnum.NI, size_t)};
const size_t strides[1] = {1};
/* swiglal_array_typeid input type: TYPE* */
%append_output(%swiglal_array_copyout(TYPE*)(swiglal_no_self(), %as_voidptr(temp_data$argnum),
......@@ -1209,35 +1209,35 @@ if (strides[I-1] == 0) {
/// <ul><li>
/// Typemap which attempts to view pointers to <tt>const NAME*</tt>.
%typemap(in, noblock=1) const NAME* (void *argp = 0, int res = 0, NAME temp, void *temp_data = 0, size_t dims[2] = {0, 0}, int elemalloc = 0) %{
%typemap(in, noblock=1) const NAME* (void *argp = 0, int res = 0, NAME temp_struct, void *temp_data = 0, size_t dims[2] = {0, 0}, int elemalloc = 0) %{
res = SWIG_ConvertPtr($input, &argp, $descriptor, 0 /*$disown*/ | %convertptr_flags);
if (!SWIG_IsOK(res)) {
typedef struct { SIZET NI; SIZET NJ; TYPE* DATA; } sizchk_t;
if (!($disown) && sizeof(sizchk_t) == sizeof(NAME)) {
temp.DATA = NULL;
temp_struct.DATA = NULL;
/* swiglal_array_typeid input type: TYPE* */
res = %swiglal_array_viewin(TYPE*)(swiglal_no_self(), $input, %as_voidptrptr(&temp.DATA),
res = %swiglal_array_viewin(TYPE*)(swiglal_no_self(), $input, %as_voidptrptr(&temp_struct.DATA),
sizeof(TYPE), 2, dims,
$typemap(swiglal_dynarr_isptr, TYPE), $typemap(swiglal_dynarr_tinfo, TYPE),
$disown | %convertptr_flags);
if (!SWIG_IsOK(res)) {
temp_data = temp.DATA = %swiglal_new_array(dims[0] * dims[1], TYPE);
temp_data = temp_struct.DATA = %swiglal_new_array(dims[0] * dims[1], TYPE);
size_t strides[2] = {dims[1], 1};
res = %swiglal_array_copyin(TYPE*)(swiglal_no_self(), $input, %as_voidptr(temp.DATA), &elemalloc,
res = %swiglal_array_copyin(TYPE*)(swiglal_no_self(), $input, %as_voidptr(temp_struct.DATA), &elemalloc,
sizeof(TYPE), 2, dims, strides,
$typemap(swiglal_dynarr_isptr, TYPE), $typemap(swiglal_dynarr_tinfo, TYPE),
$disown | %convertptr_flags);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
} else {
temp.NI = %static_cast(dims[0], SIZET);
temp.NJ = %static_cast(dims[1], SIZET);
argp = &temp;
temp_struct.NI = %static_cast(dims[0], SIZET);
temp_struct.NJ = %static_cast(dims[1], SIZET);
argp = &temp_struct;
}
} else {
temp.NI = %static_cast(dims[0], SIZET);
temp.NJ = %static_cast(dims[1], SIZET);
argp = &temp;
temp_struct.NI = %static_cast(dims[0], SIZET);
temp_struct.NJ = %static_cast(dims[1], SIZET);
argp = &temp_struct;
}
} else {
%argument_fail(res, "$type", $symname, $argnum);
......@@ -1255,24 +1255,24 @@ if (strides[I-1] == 0) {
/// </li><li>
/// Typemap which attempts to view pointers to non-<tt>const</tt> \c NAME*.
%typemap(in, noblock=1) NAME* SWIGLAL_VIEWIN_ARRAY (void *argp = 0, int res = 0, NAME temp) %{
%typemap(in, noblock=1) NAME* SWIGLAL_VIEWIN_ARRAY (void *argp = 0, int res = 0, NAME temp_struct) %{
res = SWIG_ConvertPtr($input, &argp, $descriptor, 0 /*$disown*/ | %convertptr_flags);
if (!SWIG_IsOK(res)) {
typedef struct { SIZET NI; SIZET NJ; TYPE* DATA; } sizchk_t;
if (!($disown) && sizeof(sizchk_t) == sizeof(NAME)) {
size_t dims[2] = {0, 0};
temp.DATA = NULL;
temp_struct.DATA = NULL;
/* swiglal_array_typeid input type: TYPE* */
res = %swiglal_array_viewin(TYPE*)(swiglal_no_self(), $input, %as_voidptrptr(&temp.DATA),
res = %swiglal_array_viewin(TYPE*)(swiglal_no_self(), $input, %as_voidptrptr(&temp_struct.DATA),
sizeof(TYPE), 2, dims,
$typemap(swiglal_dynarr_isptr, TYPE), $typemap(swiglal_dynarr_tinfo, TYPE),
$disown | %convertptr_flags);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
} else {
temp.NI = %static_cast(dims[0], SIZET);
temp.NJ = %static_cast(dims[1], SIZET);
argp = &temp;
temp_struct.NI = %static_cast(dims[0], SIZET);
temp_struct.NJ = %static_cast(dims[1], SIZET);
argp = &temp_struct;
}
} else {
%argument_fail(res, "$type", $symname, $argnum);
......@@ -1288,7 +1288,7 @@ if (strides[I-1] == 0) {
/// - If the input argument is a SWIG-wrapped \c NAME*, just unwrap it and return a reference.
/// - If the input argument is a native scripting-language array, make an internal copy of it,
/// use the copy, and return a native scripting-language array copy of the internal copy.
%typemap(in, noblock=1) NAME* SWIGLAL_COPYINOUT_ARRAY (void *argp = 0, int res = 0, NAME temp, SWIG_Object input_ref, void *temp_data = 0, size_t dims[2] = {0, 0}, int elemalloc = 0) %{
%typemap(in, noblock=1) NAME* SWIGLAL_COPYINOUT_ARRAY (void *argp = 0, int res = 0, NAME temp_struct, SWIG_Object input_ref, void *temp_data = 0, size_t dims[2] = {0, 0}, int elemalloc = 0) %{
res = SWIG_ConvertPtr($input, &argp, $descriptor, 0 /*$disown*/ | %convertptr_flags);
if (!SWIG_IsOK(res)) {
typedef struct { SIZET NI; SIZET NJ; TYPE* DATA; } sizchk_t;
......@@ -1299,7 +1299,7 @@ if (strides[I-1] == 0) {
$typemap(swiglal_dynarr_isptr, TYPE), $typemap(swiglal_dynarr_tinfo, TYPE),
$disown | %convertptr_flags);
if (dims[0] * dims[1] > 0) {
temp_data = temp.DATA = %swiglal_new_array(dims[0] * dims[1], TYPE);
temp_data = temp_struct.DATA = %swiglal_new_array(dims[0] * dims[1], TYPE);
size_t strides[2] = {dims[1], 1};
res = %swiglal_array_copyin(TYPE*)(swiglal_no_self(), $input, %as_voidptr(temp_data), &elemalloc,
sizeof(TYPE), 2, dims, strides,
......@@ -1308,9 +1308,9 @@ if (strides[I-1] == 0) {
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
} else {
temp.NI = %static_cast(dims[0], SIZET);
temp.NJ = %static_cast(dims[1], SIZET);
argp = &temp;
temp_struct.NI = %static_cast(dims[0], SIZET);
temp_struct.NJ = %static_cast(dims[1], SIZET);
argp = &temp_struct;
}
} else {
%argument_fail(res, "$type", $symname, $argnum);
......@@ -1325,7 +1325,7 @@ if (strides[I-1] == 0) {
%}
%typemap(argout, match="in", noblock=1) NAME* SWIGLAL_COPYINOUT_ARRAY %{
if (temp_data$argnum) {
const size_t dims[2] = {%static_cast(temp$argnum.NI, size_t), %static_cast(temp$argnum.NJ, size_t)};
const size_t dims[2] = {%static_cast(temp_struct$argnum.NI, size_t), %static_cast(temp_struct$argnum.NJ, size_t)};
const size_t strides[2] = {dims[1], 1};
/* swiglal_array_typeid input type: TYPE* */
%append_output(%swiglal_array_copyout(TYPE*)(swiglal_no_self(), %as_voidptr(temp_data$argnum),
......@@ -1959,10 +1959,10 @@ if (strides[I-1] == 0) {
if (!argp) {
%argument_nullref("$type", $symname, $argnum);
} else {
$&ltype temp = %reinterpret_cast(argp, $&ltype);
$1 = *temp;
$&ltype temp_ptr = %reinterpret_cast(argp, $&ltype);
$1 = *temp_ptr;
if (SWIG_IsNewObj(res)) {
%delete(temp);
%delete(temp_ptr);
}
}
}
......
......@@ -587,9 +587,17 @@ SWIGINTERN bool swiglal_release_parent(void *ptr) {
SLOAV_OBV_METH_FROM_CLASS_0(is_bool_scalar, bool);
SLOAV_OBV_METH_FROM_CLASS_0(is_bool_type, bool);
SLOAV_OBV_METH_FROM_CLASS_0(is_builtin_function, bool);
%#if SWIG_OCTAVE_PREREQ(4,4,0)
SLOAV_OBV_METH_FROM_CLASS_0(iscell, bool);
SLOAV_OBV_METH_FROM_CLASS_0(iscellstr, bool);
%#else
SLOAV_OBV_METH_FROM_CLASS_0(is_cell, bool);
SLOAV_OBV_METH_FROM_CLASS_0(is_cellstr, bool);
%#endif
SLOAV_OBV_METH_FROM_CLASS_0(is_char_matrix, bool);
SLOAV_OBV_METH_FROM_CLASS_0(is_classdef_meta, bool);
SLOAV_OBV_METH_FROM_CLASS_0(is_classdef_object, bool);
SLOAV_OBV_METH_FROM_CLASS_0(is_classdef_superclass_ref, bool);
SLOAV_OBV_METH_FROM_CLASS_0(is_complex_matrix, bool);
SLOAV_OBV_METH_FROM_CLASS_0(is_complex_scalar, bool);
SLOAV_OBV_METH_FROM_CLASS_0(is_complex_type, bool);
......@@ -635,6 +643,9 @@ SWIGINTERN bool swiglal_release_parent(void *ptr) {
SLOAV_OBV_METH_FROM_CLASS_0(is_user_code, bool);
SLOAV_OBV_METH_FROM_CLASS_0(is_user_function, bool);
SLOAV_OBV_METH_FROM_CLASS_0(is_user_script, bool);
SLOAV_OBV_METH_FROM_CLASS_0(isjava, bool);
SLOAV_OBV_METH_FROM_CLASS_0(isobject, bool);
SLOAV_OBV_METH_FROM_CLASS_0(isstruct, bool);
#undef SLOAV_OBV_METH_FROM_CLASS_0
// The following methods override virtual const-methods in octave_base_value. These methods
......@@ -804,9 +815,26 @@ SWIGINTERN bool swiglal_release_parent(void *ptr) {
%define %swiglal_oct_array_frags(ACFTYPE, INFRAG, OUTFRAG, INCALL, OUTCALL, OVCLASS, OVTYPE, OVVALUE, ISOVTYPEEXPR)
// Register the ACFTYPE-specific array view class as an Octave type.
%fragment(%swiglal_oct_array_view_init_frag(ACFTYPE), "init") {
%fragment(%swiglal_oct_array_view_init_frag(ACFTYPE), "init") %{
#if SWIG_OCTAVE_PREREQ(4,4,0)
{
octave::type_info& typeinfo = octave::interpreter::the_interpreter()->get_type_info();
string_vector types = typeinfo.installed_type_names();
bool register_octave_array_view_class = true;
bool register_octave_swig_packed = true;
for (int i = 0; i < types.numel(); ++i) {
if (types(i) == %swiglal_oct_array_view_class(ACFTYPE)::static_type_name()) {
register_octave_array_view_class = false;
}
}
if (register_octave_array_view_class) {
%swiglal_oct_array_view_class(ACFTYPE)::register_type();
}
}
#else
%swiglal_oct_array_view_class(ACFTYPE)::register_type();
}
#endif
%}
// ACFTYPE-specific array view class fragment.
%fragment(%swiglal_oct_array_view_frag(ACFTYPE), "header",
......