summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/csharp/std_wstring.i12
-rw-r--r--Lib/exception.i7
-rw-r--r--Lib/go/argcargv.i64
-rw-r--r--Lib/ocaml/std_string.i50
-rw-r--r--Lib/php/const.i2
-rw-r--r--Lib/php/phpinterfaces.i6
-rw-r--r--Lib/php/phprun.swg67
-rw-r--r--Lib/php/std_string.i65
-rw-r--r--Lib/ruby/rubyrun.swg2
-rw-r--r--Lib/scilab/scidouble.swg14
-rw-r--r--Lib/scilab/sciint.swg5
-rw-r--r--Lib/scilab/scimatrixdouble.swg12
-rw-r--r--Lib/scilab/scimatrixint.swg12
-rw-r--r--Lib/scilab/scirun.swg33
-rw-r--r--Lib/typemaps/primtypes.swg8
15 files changed, 208 insertions, 151 deletions
diff --git a/Lib/csharp/std_wstring.i b/Lib/csharp/std_wstring.i
index 1d10ca808..c7fef41a5 100644
--- a/Lib/csharp/std_wstring.i
+++ b/Lib/csharp/std_wstring.i
@@ -63,7 +63,7 @@ class wstring;
return $null;
}
$1 = Swig_csharp_UTF16ToWString($input); %}
-%typemap(out) wstring %{ $result = SWIG_csharp_wstring_with_length_callback($1.c_str(), (int)$1.size()); %}
+%typemap(out) wstring %{ $result = SWIG_csharp_wstring_with_length_callback($1.data(), (int)$1.size()); %}
%typemap(directorout, canthrow=1) wstring
%{ if (!$input) {
@@ -72,7 +72,7 @@ class wstring;
}
$result = Swig_csharp_UTF16ToWString($input); %}
-%typemap(directorin) wstring %{ $input = SWIG_csharp_wstring_with_length_callback($1.c_str(), (int)$1.size()); %}
+%typemap(directorin) wstring %{ $input = SWIG_csharp_wstring_with_length_callback($1.data(), (int)$1.size()); %}
%typemap(csin) wstring "$csinput"
%typemap(csout, excode=SWIGEXCODE) wstring {
@@ -83,7 +83,7 @@ class wstring;
%typemap(typecheck) wstring = wchar_t *;
%typemap(throws, canthrow=1) wstring
-%{ SWIG_csharp_ApplicationException_callback($1.c_str(), (int)$1.size());
+%{ SWIG_csharp_ApplicationException_callback($1.data(), (int)$1.size());
return $null; %}
// const wstring &
@@ -106,7 +106,7 @@ class wstring;
}
std::wstring $1_str(Swig_csharp_UTF16ToWString($input));
$1 = &$1_str; %}
-%typemap(out) const wstring & %{ $result = SWIG_csharp_wstring_with_length_callback($1->c_str(), (int)$1->size()); %}
+%typemap(out) const wstring & %{ $result = SWIG_csharp_wstring_with_length_callback($1->data(), (int)$1->size()); %}
%typemap(csin) const wstring & "$csinput"
%typemap(csout, excode=SWIGEXCODE) const wstring & {
@@ -124,7 +124,7 @@ class wstring;
$1_str = Swig_csharp_UTF16ToWString($input);
$result = &$1_str; %}
-%typemap(directorin) const wstring & %{ $input = SWIG_csharp_wstring_with_length_callback($1.c_str(), (int)$1.size()); %}
+%typemap(directorin) const wstring & %{ $input = SWIG_csharp_wstring_with_length_callback($1.data(), (int)$1.size()); %}
%typemap(csvarin, excode=SWIGEXCODE2) const wstring & %{
set {
@@ -139,7 +139,7 @@ class wstring;
%typemap(typecheck) const wstring & = wchar_t *;
%typemap(throws, canthrow=1) const wstring &
-%{ SWIG_csharp_ApplicationException_callback($1.c_str(), (int)$1.size());
+%{ SWIG_csharp_ApplicationException_callback($1.data(), (int)$1.size());
return $null; %}
}
diff --git a/Lib/exception.i b/Lib/exception.i
index 5cdea58e8..665e24b7e 100644
--- a/Lib/exception.i
+++ b/Lib/exception.i
@@ -14,14 +14,9 @@
#ifdef SWIGPHP
%{
-#if PHP_MAJOR_VERSION >= 8
-# define SWIG_HANDLE_VALUE_ERROR_FOR_PHP8(code) code == SWIG_ValueError ? zend_ce_value_error :
-#else
-# define SWIG_HANDLE_VALUE_ERROR_FOR_PHP8(code)
-#endif
#define SWIG_exception(code, msg) do { zend_throw_exception( \
code == SWIG_TypeError ? zend_ce_type_error : \
- SWIG_HANDLE_VALUE_ERROR_FOR_PHP8(code) \
+ code == SWIG_ValueError ? zend_ce_value_error : \
code == SWIG_DivisionByZero ? zend_ce_division_by_zero_error : \
code == SWIG_SyntaxError ? zend_ce_parse_error : \
code == SWIG_OverflowError ? zend_ce_arithmetic_error : \
diff --git a/Lib/go/argcargv.i b/Lib/go/argcargv.i
new file mode 100644
index 000000000..437832bb2
--- /dev/null
+++ b/Lib/go/argcargv.i
@@ -0,0 +1,64 @@
+/* ------------------------------------------------------------
+ * SWIG library containing argc and argv multi-argument typemaps
+ * ------------------------------------------------------------ */
+
+%typemap(gotype) (int ARGC, char **ARGV) "[]string"
+
+%insert(go_wrapper) %{
+//export cgo_swig_get_string_slice_idx
+func cgo_swig_get_string_slice_idx(s []string, i C.swig_intgo) string {
+ return s[i]
+}
+%}
+
+%{
+extern
+#ifdef __cplusplus
+ "C"
+#endif
+_gostring_ cgo_swig_get_string_slice_idx(_goslice_ s, intgo i);
+%}
+
+%typemap(in) (int ARGC, char **ARGV) {
+ $1_ltype len = ($1_ltype)$input.len;
+ size_t aralloc = (size_t)((len + 1) * sizeof(char *));
+ if (len <= 0 || $input.array == NULL) {
+ _swig_gopanic("array must contain at least 1 element");
+ }
+ $2 = ($2_ltype) Swig_malloc((int)aralloc);
+ if ($2 == NULL) {
+ _swig_gopanic("fail allocating memory for array");
+ }
+ memset($2, 0, aralloc);
+ $1 = len;
+ {
+ $1_ltype i;
+ for (i = 0; i < len; i++) {
+ char *p;
+ _gostring_ st = cgo_swig_get_string_slice_idx($input, (intgo)i);
+ if (st.n <= 0) {
+ _swig_gopanic("string length must be positive");
+ }
+ p = (char *) Swig_malloc((int)(st.n + 1));
+ if (p == NULL) {
+ _swig_gopanic("fail allocating memory for a string");
+ }
+ memcpy(p, st.p, st.n);
+ p[st.n] = 0;
+ $2[i] = p;
+ }
+ $2[i] = NULL;
+ }
+}
+
+%typemap(freearg) (int ARGC, char **ARGV) {
+ if ($2 != NULL) {
+ $1_ltype i;
+ for (i = 0; i < $1; i++) {
+ if ($2[i] != NULL) {
+ Swig_free((void *)$2[i]);
+ }
+ }
+ Swig_free((void *)$2);
+ }
+}
diff --git a/Lib/ocaml/std_string.i b/Lib/ocaml/std_string.i
index 2564cfb38..6cf918c6f 100644
--- a/Lib/ocaml/std_string.i
+++ b/Lib/ocaml/std_string.i
@@ -4,18 +4,11 @@
* SWIG typemaps for std::string
* ----------------------------------------------------------------------------- */
-// ------------------------------------------------------------------------
-// std::string is typemapped by value
-// This can prevent exporting methods which return a string
-// in order for the user to modify it.
-// However, I think I'll wait until someone asks for it...
-// ------------------------------------------------------------------------
-
%{
#include <string>
#include <vector>
%}
-
+
%include <exception.i>
%include <std_vector.i>
@@ -23,10 +16,10 @@ namespace std {
%naturalvar string;
%naturalvar wstring;
-
+
class string;
class wstring;
-
+
/* Overloading check */
%typemap(in) string {
if (caml_ptr_check($input))
@@ -44,15 +37,6 @@ class wstring;
}
}
-%typemap(in) string & ($*1_ltype temp) {
- if (caml_ptr_check($input)) {
- temp.assign((char *)caml_ptr_val($input,0), caml_string_len($input));
- $1 = &temp;
- } else {
- SWIG_exception(SWIG_TypeError, "string expected");
- }
-}
-
%typemap(in) string * ($*1_ltype *temp) {
if (caml_ptr_check($input)) {
temp = new $*1_ltype((char *)caml_ptr_val($input,0), caml_string_len($input));
@@ -66,12 +50,12 @@ class wstring;
delete temp;
}
-%typemap(argout) string & {
- swig_result = caml_list_append(swig_result,caml_val_string_len((*$1).c_str(), (*$1).size()));
+%typemap(out) const string & {
+ $result = caml_val_string_len((*$1).data(), (*$1).size());
}
%typemap(directorin) string {
- swig_result = caml_val_string_len($1.c_str(), $1.size());
+ swig_result = caml_val_string_len($1.data(), $1.size());
args = caml_list_append(args, swig_result);
}
@@ -80,25 +64,39 @@ class wstring;
}
%typemap(out) string {
- $result = caml_val_string_len($1.c_str(),$1.size());
+ $result = caml_val_string_len($1.data(),$1.size());
}
%typemap(varout) string {
- $result = caml_val_string_len($1.c_str(),$1.size());
+ $result = caml_val_string_len($1.data(),$1.size());
}
%typemap(out) string * {
- $result = caml_val_string_len((*$1).c_str(),(*$1).size());
+ $result = caml_val_string_len((*$1).data(),(*$1).size());
}
%typemap(varout) string * {
- $result = caml_val_string_len((*$1).c_str(),(*$1).size());
+ $result = caml_val_string_len((*$1).data(),(*$1).size());
}
%typemap(typecheck) string, const string & = char *;
%typemap(throws) string, const string & "SWIG_OCamlThrowException(SWIG_OCamlRuntimeException, $1.c_str());"
+%typemap(in) string &INPUT = const string &;
+%typemap(in, numinputs=0) string &OUTPUT ($*1_ltype temp)
+%{ $1 = &temp; %}
+%typemap(argout) string &OUTPUT {
+ swig_result = caml_list_append(swig_result, caml_val_string_len((*$1).data(), (*$1).size()));
+}
+%typemap(in) string &INOUT = const string &;
+%typemap(argout) string &INOUT = string &OUTPUT;
+
+%typemap(typecheck) string, const string & = char *;
+
+%typemap(throws) string, const string & {
+ SWIG_OCamlThrowException(SWIG_OCamlRuntimeException, $1.c_str());
+}
}
#ifdef ENABLE_CHARPTR_ARRAY
diff --git a/Lib/php/const.i b/Lib/php/const.i
index a74af0d78..1e1fe9cad 100644
--- a/Lib/php/const.i
+++ b/Lib/php/const.i
@@ -95,7 +95,7 @@
SWIG_SetPointerZval(&c.value, (void*)($value), $1_descriptor, 0);
zval_copy_ctor(&c.value);
c.name = zend_string_init("$symname", sizeof("$symname") - 1, 0);
- SWIG_ZEND_CONSTANT_SET_FLAGS(&c, CONST_CS, module_number);
+ ZEND_CONSTANT_SET_FLAGS(&c, CONST_CS, module_number);
zend_register_constant(&c);
}
diff --git a/Lib/php/phpinterfaces.i b/Lib/php/phpinterfaces.i
index 5b1da8b79..e1029b645 100644
--- a/Lib/php/phpinterfaces.i
+++ b/Lib/php/phpinterfaces.i
@@ -54,9 +54,7 @@
#define SWIG_PHP_INTERFACE_JsonSerializable_HEADER "ext/json/php_json.h"
// New in PHP 8.0.
-#if PHP_MAJOR_VERSION >= 8
-# define SWIG_PHP_INTERFACE_Stringable_CE zend_ce_stringable
-# define SWIG_PHP_INTERFACE_Stringable_HEADER "zend_interfaces.h"
-#endif
+#define SWIG_PHP_INTERFACE_Stringable_CE zend_ce_stringable
+#define SWIG_PHP_INTERFACE_Stringable_HEADER "zend_interfaces.h"
%}
diff --git a/Lib/php/phprun.swg b/Lib/php/phprun.swg
index d3ad0d26a..588701f9b 100644
--- a/Lib/php/phprun.swg
+++ b/Lib/php/phprun.swg
@@ -10,35 +10,14 @@
extern "C" {
#endif
-#if PHP_MAJOR_VERSION < 7
-# error These bindings need PHP 7 or later - to generate PHP5 bindings use: SWIG < 4.0.0 and swig -php5
+#if PHP_MAJOR_VERSION < 8
+# error These bindings need PHP 8 or later - to generate PHP7 bindings use SWIG < 4.1.0; to generate PHP5 bindings use: SWIG < 4.0.0 and swig -php5
#endif
#include "zend_inheritance.h"
#include "zend_exceptions.h"
#include "zend_inheritance.h"
-#if PHP_MAJOR_VERSION == 7
-/* These macros were new in PHP 8.0. For PHP 7.x we define them to give the
- * same result except without any type declarations. PHP 7.x supports type
- * declarations, but not for the return type, and alternate types aren't
- * supported, so we don't try to support these.
- */
-# define ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(name, byref, num_req, classes, types) \
- ZEND_BEGIN_ARG_INFO_EX(name, 0, byref, num_req)
-# define ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(name, byref, num_req, types) \
- ZEND_BEGIN_ARG_INFO_EX(name, 0, byref, num_req)
-
-/* NB We can just ignore `default` here we currently always pass NULL for it
- * (this mechanism for specifying default parameter values was new in PHP 8.0
- * so it's not useful while we still want to support PHP7 too).
- */
-# define ZEND_ARG_OBJ_TYPE_MASK(byref, name, classes, types, default) \
- ZEND_ARG_INFO(byref, name)
-# define ZEND_ARG_TYPE_MASK(byref, name, types, default) \
- ZEND_ARG_INFO(byref, name)
-#endif
-
#include <stdlib.h> /* for abort(), used in generated code. */
#define SWIG_BOOL_CONSTANT(N, V) REGISTER_BOOL_CONSTANT(#N, V, CONST_CS | CONST_PERSISTENT)
@@ -50,27 +29,6 @@ extern "C" {
REGISTER_STRINGL_CONSTANT(#N, &swig_char, 1, CONST_CS | CONST_PERSISTENT);\
} while (0)
-/* ZEND_CONSTANT_SET_FLAGS was new in PHP 7.3. */
-#ifdef ZEND_CONSTANT_SET_FLAGS
-# define SWIG_ZEND_CONSTANT_SET_FLAGS ZEND_CONSTANT_SET_FLAGS
-#else
-# define SWIG_ZEND_CONSTANT_SET_FLAGS(C, F, N) do { (C)->flags = (F); (C)->module_number = (N); } while (0)
-#endif
-
-/* zend_object_alloc was new in PHP 7.3. */
-#if PHP_MAJOR_VERSION == 7 && PHP_MINOR_VERSION < 3
-static zend_always_inline void *zend_object_alloc(size_t obj_size, zend_class_entry *ce) {
- void *obj = emalloc(obj_size + zend_object_properties_size(ce));
- memset(obj, 0, obj_size - sizeof(zval));
- return obj;
-}
-#endif
-
-/* ZEND_THIS was new in PHP 7.4. */
-#ifndef ZEND_THIS
-# define ZEND_THIS &EX(This)
-#endif
-
#ifdef __cplusplus
}
#endif
@@ -93,27 +51,6 @@ static int default_error_code = E_ERROR;
static zend_class_entry SWIG_Php_swig_wrapped_interface_ce;
-#if PHP_MAJOR_VERSION == 7
-/* zend_class_implements_interface() was new in PHP 8.0.
- *
- * We could use instanceof_function_ex(C, I, 1) here for 7.4, but for 7.3
- * and earlier that doesn't work, so instead we just provide a compatibility
- * implementation which does what zend_class_implements_interface() does in 8.x
- * and use that for all 7.x so there are fewer variants to worry about testing.
- */
-static int zend_class_implements_interface(const zend_class_entry *class_ce, const zend_class_entry *interface_ce) {
- uint32_t i;
- if (class_ce->num_interfaces) {
- for (i = 0; i < class_ce->num_interfaces; i++) {
- if (class_ce->interfaces[i] == interface_ce) {
- return 1;
- }
- }
- }
- return 0;
-}
-#endif
-
/* used to wrap returned objects in so we know whether they are newobject
and need freeing, or not */
typedef struct {
diff --git a/Lib/php/std_string.i b/Lib/php/std_string.i
index b2039786c..5abbbbbef 100644
--- a/Lib/php/std_string.i
+++ b/Lib/php/std_string.i
@@ -4,19 +4,21 @@
* SWIG typemaps for std::string types
* ----------------------------------------------------------------------------- */
-// ------------------------------------------------------------------------
-// std::string is typemapped by value
-// This can prevent exporting methods which return a string
-// in order for the user to modify it.
-// However, I think I'll wait until someone asks for it...
-// ------------------------------------------------------------------------
-
-%include <exception.i>
-
%{
#include <string>
%}
+/* std::string and const std::string& are converted to/from PHP string
+ * automatically.
+ *
+ * A C++ std::string& parameter is wrapped as a pass-by-reference PHP
+ * string parameter by default, but the INPUT/INOUT/OUTPUT typemaps
+ * below provide other options (see below).
+ *
+ * std::string* is not wrapped by default, but INPUT/INOUT/OUTPUT typemaps
+ * are provided (see below).
+ */
+
namespace std {
%naturalvar string;
@@ -45,7 +47,7 @@ namespace std {
ZVAL_STRINGL($input, $1.data(), $1.size());
%}
- %typemap(out, phptype="string") const string & %{
+ %typemap(out, phptype="string") const string& %{
ZVAL_STRINGL($result, $1->data(), $1->size());
%}
@@ -54,15 +56,22 @@ namespace std {
goto fail;
%}
- %typemap(in, phptype="string") const string & ($*1_ltype temp) %{
+ %typemap(throws) string*, const string* %{
+ zend_throw_exception(NULL, $1->c_str(), 0);
+ goto fail;
+ %}
+
+ %typemap(in, phptype="string") const string& ($*1_ltype temp) %{
convert_to_string(&$input);
temp.assign(Z_STRVAL($input), Z_STRLEN($input));
$1 = &temp;
%}
- /* These next two handle a function which takes a non-const reference to
- * a std::string and modifies the string. */
- %typemap(in,byref=1, phptype="string") string & ($*1_ltype temp) %{
+ /*************************************************************************/
+
+ /* These next four typemaps handle a function which takes a non-const
+ * reference to a std::string and modifies the string. */
+ %typemap(in,byref=1, phptype="string") string& ($*1_ltype temp) %{
{
zval * p = Z_ISREF($input) ? Z_REFVAL($input) : &$input;
convert_to_string(p);
@@ -71,14 +80,14 @@ namespace std {
}
%}
- %typemap(directorout) string & ($*1_ltype *temp) %{
+ %typemap(directorout) string& ($*1_ltype *temp) %{
convert_to_string($input);
temp = new $*1_ltype(Z_STRVAL_P($input), Z_STRLEN_P($input));
swig_acquire_ownership(temp);
$result = temp;
%}
- %typemap(argout) string & %{
+ %typemap(argout) string& %{
if (Z_ISREF($input)) {
ZVAL_STRINGL(Z_REFVAL($input), $1->data(), $1->size());
}
@@ -86,5 +95,27 @@ namespace std {
/* SWIG will apply the non-const typemap above to const string& without
* this more specific typemap. */
- %typemap(argout) const string & ""
+ %typemap(argout) const string& ""
+
+ /*************************************************************************/
+
+ /* Alternative ways to handle string& - you can specify how to wrap based
+ * on the parameter name, e.g. this handles parameters named `str` as
+ * INOUT:
+ *
+ * %apply (std::string& INOUT) (std::string& str);
+ */
+
+ %typemap(in) string& INPUT = const string&;
+ %typemap(in, numinputs=0) string& OUTPUT ($*1_ltype temp)
+ %{ $1 = &temp; %}
+ %typemap(argout,fragment="t_output_helper") string& OUTPUT
+ {
+ zval o;
+ ZVAL_STRINGL(&o, $1->data(), $1->size());
+ t_output_helper($result, &o);
+ }
+ %typemap(in) string& INOUT = const string&;
+ %typemap(argout) string& INOUT = string& OUTPUT;
+
}
diff --git a/Lib/ruby/rubyrun.swg b/Lib/ruby/rubyrun.swg
index 6cac4626a..885292481 100644
--- a/Lib/ruby/rubyrun.swg
+++ b/Lib/ruby/rubyrun.swg
@@ -157,7 +157,7 @@ SWIG_Ruby_define_class(swig_type_info *type)
_cSWIG_Pointer = rb_define_class_under(_mSWIG, "Pointer", rb_cObject);
rb_undef_method(CLASS_OF(_cSWIG_Pointer), "new");
}
- rb_define_class_under(_mSWIG, klass_name, _cSWIG_Pointer);
+ rb_undef_alloc_func(rb_define_class_under(_mSWIG, klass_name, _cSWIG_Pointer));
free((void *) klass_name);
}
diff --git a/Lib/scilab/scidouble.swg b/Lib/scilab/scidouble.swg
index 1b8263306..e14c84647 100644
--- a/Lib/scilab/scidouble.swg
+++ b/Lib/scilab/scidouble.swg
@@ -56,6 +56,7 @@ SWIG_SciDouble_FromDouble(void *pvApiCtx, int iVarOut, double dblValue, char *fn
SWIGINTERN int
SWIG_SciDouble_AsDoubleArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, double **pdValue, char *fname) {
SciErr sciErr;
+ int iType = 0;
int *piAddrVar = NULL;
sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
@@ -64,13 +65,24 @@ SWIG_SciDouble_AsDoubleArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *i
return SWIG_ERROR;
}
- if (isDoubleType(pvApiCtx, piAddrVar) && !isVarComplex(pvApiCtx, piAddrVar)) {
+ sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (iType == sci_matrix && !isVarComplex(pvApiCtx, piAddrVar)) {
sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, iRows, iCols, pdValue);
if (sciErr.iErr) {
printError(&sciErr, 0);
return SWIG_ERROR;
}
}
+ else if (iType == sci_implicit_poly) {
+ *iRows = -1;
+ *iCols = 0;
+ *pdValue = NULL;
+ }
else {
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A real matrix expected.\n"), fname, iVar);
return SWIG_ERROR;
diff --git a/Lib/scilab/sciint.swg b/Lib/scilab/sciint.swg
index 2d6993569..b7b2563e8 100644
--- a/Lib/scilab/sciint.swg
+++ b/Lib/scilab/sciint.swg
@@ -157,6 +157,11 @@ SWIG_SciDoubleOrInt32_AsIntArrayAndSize(void *pvApiCtx, int iVar, int *iRows, in
return SWIG_ERROR;
}
}
+ else if (iType == sci_implicit_poly) {
+ *iRows = -1;
+ *iCols = 0;
+ *piValue = NULL;
+ }
else {
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 32-bit signed integer or a double matrix expected.\n"), fname, iVar);
return SWIG_ERROR;
diff --git a/Lib/scilab/scimatrixdouble.swg b/Lib/scilab/scimatrixdouble.swg
index 9444a8078..bb9403edd 100644
--- a/Lib/scilab/scimatrixdouble.swg
+++ b/Lib/scilab/scimatrixdouble.swg
@@ -28,7 +28,11 @@
%typemap(in, noblock=1, fragment="SWIG_SciDouble_AsDoubleArrayAndSize") (double *IN, int IN_SIZE) (int rowCount, int colCount)
{
if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$1, fname) == SWIG_OK) {
- $2 = rowCount * colCount;
+ if (rowCount < 0) {
+ $2 = rowCount;
+ } else {
+ $2 = rowCount * colCount;
+ }
}
else {
return SWIG_ERROR;
@@ -40,7 +44,11 @@
%typemap(in, noblock=1, fragment="SWIG_SciDouble_AsDoubleArrayAndSize") (int IN_SIZE, double *IN) (int rowCount, int colCount)
{
if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$2, fname) == SWIG_OK) {
- $1 = rowCount * colCount;
+ if (rowCount < 0) {
+ $1 = rowCount;
+ } else {
+ $1 = rowCount * colCount;
+ }
}
else {
return SWIG_ERROR;
diff --git a/Lib/scilab/scimatrixint.swg b/Lib/scilab/scimatrixint.swg
index e304d4f64..057710725 100644
--- a/Lib/scilab/scimatrixint.swg
+++ b/Lib/scilab/scimatrixint.swg
@@ -30,7 +30,11 @@
%typemap(in, noblock=1, fragment="SWIG_SciDoubleOrInt32_AsIntArrayAndSize") (int *IN, int IN_SIZE) (int rowCount, int colCount)
{
if (SWIG_SciDoubleOrInt32_AsIntArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$1, fname) == SWIG_OK) {
- $2 = rowCount * colCount;
+ if (rowCount < 0) {
+ $2 = rowCount;
+ } else {
+ $2 = rowCount * colCount;
+ }
}
else {
return SWIG_ERROR;
@@ -43,7 +47,11 @@
%typemap(in, noblock=1, fragment="SWIG_SciDoubleOrInt32_AsIntArrayAndSize") (int IN_SIZE, int *IN) (int rowCount, int colCount)
{
if (SWIG_SciDoubleOrInt32_AsIntArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$2, fname) == SWIG_OK) {
- $1 = rowCount * colCount;
+ if (rowCount < 0) {
+ $1 = rowCount;
+ } else {
+ $1 = rowCount * colCount;
+ }
}
else {
return SWIG_ERROR;
diff --git a/Lib/scilab/scirun.swg b/Lib/scilab/scirun.swg
index 586d5f16f..481aac7ac 100644
--- a/Lib/scilab/scirun.swg
+++ b/Lib/scilab/scirun.swg
@@ -5,7 +5,6 @@
/* Scilab version macro */
#include "version.h"
-#define SWIG_SCILAB_VERSION (SCI_VERSION_MAJOR * 100) + (SCI_VERSION_MINOR * 10) + SCI_VERSION_MAINTENANCE
/* Scilab standard headers */
@@ -13,11 +12,11 @@
extern "C" {
#endif
#include "api_scilab.h"
-#if SWIG_SCILAB_VERSION < 540
+#if SCI_VERSION_MAJOR < 5 || SCI_VERSION_MAJOR == 5 && SCI_VERSION_MINOR < 4
#define __USE_DEPRECATED_STACK_FUNCTIONS__
#include "stack-c.h"
#endif
-#if SWIG_SCILAB_VERSION < 600
+#if SCI_VERSION_MAJOR < 6
#include "MALLOC.h"
#endif
#include "Scierror.h"
@@ -31,12 +30,12 @@ extern "C" {
/* Gateway signature */
-#if SWIG_SCILAB_VERSION >= 600
-#define SWIG_GatewayParameters char* fname, void *pvApiCtx
-#define SWIG_GatewayArguments fname, pvApiCtx
-#else
+#if SCI_VERSION_MAJOR < 6
#define SWIG_GatewayParameters char* fname, unsigned long fname_len
#define SWIG_GatewayArguments fname, fname_len
+# else
+#define SWIG_GatewayParameters char* fname, void *pvApiCtx
+#define SWIG_GatewayArguments fname, pvApiCtx
#endif
/* Function name management functions */
@@ -58,29 +57,29 @@ static void SWIG_Scilab_SetFuncName(char *funcName) {
/* Api context management functions */
-#if SWIG_SCILAB_VERSION >= 600
+#if SCI_VERSION_MAJOR < 6
+#define SWIG_Scilab_SetApiContext(apiCtx)
+#else
static void *pvApiCtx = NULL;
static void SWIG_Scilab_SetApiContext(void *apiCtx) {
pvApiCtx = apiCtx;
}
-#else
-#define SWIG_Scilab_SetApiContext(apiCtx)
#endif
/* Argument management functions */
-#if SWIG_SCILAB_VERSION >= 540
-#define SWIG_CheckInputArgument(pvApiCtx, minInputArgument, maxInputArgument) CheckInputArgument(pvApiCtx, minInputArgument, maxInputArgument)
-#define SWIG_CheckInputArgumentAtLeast(pvApiCtx, minInputArgument) CheckInputArgumentAtLeast(pvApiCtx, minInputArgument)
-#define SWIG_CheckOutputArgument(pvApiCtx, minOutputArgument, maxOutputArgument) CheckOutputArgument(pvApiCtx, minOutputArgument, maxOutputArgument)
-#define SWIG_NbInputArgument(pvApiCtx) nbInputArgument(pvApiCtx)
-#define SWIG_AssignOutputArgument(pvApiCtx, outputArgumentPos, argumentPos) AssignOutputVariable(pvApiCtx, outputArgumentPos) = argumentPos
-#else
+#if SCI_VERSION_MAJOR < 5 || SCI_VERSION_MAJOR == 5 && SCI_VERSION_MINOR < 4
#define SWIG_CheckInputArgument(pvApiCtx, minInputArgument, maxInputArgument) CheckRhs(minInputArgument, maxInputArgument)
#define SWIG_CheckInputArgumentAtLeast(pvApiCtx, minInputArgument) CheckRhs(minInputArgument, 256)
#define SWIG_CheckOutputArgument(pvApiCtx, minOutputArgument, maxOutputArgument) CheckLhs(minOutputArgument, maxOutputArgument)
#define SWIG_NbInputArgument(pvApiCtx) Rhs
#define SWIG_AssignOutputArgument(pvApiCtx, outputArgumentPos, argumentPos) LhsVar(outputArgumentPos) = argumentPos
+#else
+#define SWIG_CheckInputArgument(pvApiCtx, minInputArgument, maxInputArgument) CheckInputArgument(pvApiCtx, minInputArgument, maxInputArgument)
+#define SWIG_CheckInputArgumentAtLeast(pvApiCtx, minInputArgument) CheckInputArgumentAtLeast(pvApiCtx, minInputArgument)
+#define SWIG_CheckOutputArgument(pvApiCtx, minOutputArgument, maxOutputArgument) CheckOutputArgument(pvApiCtx, minOutputArgument, maxOutputArgument)
+#define SWIG_NbInputArgument(pvApiCtx) nbInputArgument(pvApiCtx)
+#define SWIG_AssignOutputArgument(pvApiCtx, outputArgumentPos, argumentPos) AssignOutputVariable(pvApiCtx, outputArgumentPos) = argumentPos
#endif
typedef int SwigSciObject;
diff --git a/Lib/typemaps/primtypes.swg b/Lib/typemaps/primtypes.swg
index dd80eb775..85a0b8d9b 100644
--- a/Lib/typemaps/primtypes.swg
+++ b/Lib/typemaps/primtypes.swg
@@ -252,9 +252,11 @@ SWIGINTERNINLINE int
SWIG_CanCastAsInteger(double *d, double min, double max) {
double x = *d;
if ((min <= x && x <= max)) {
- double fx = floor(x);
- double cx = ceil(x);
- double rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */
+ double fx, cx, rd;
+ errno = 0;
+ fx = floor(x);
+ cx = ceil(x);
+ rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */
if ((errno == EDOM) || (errno == ERANGE)) {
errno = 0;
} else {