Merge branch 'master' into gsoc2017-php7-classes-via-c-api

This commit is contained in:
Olly Betts 2017-09-14 09:01:37 +12:00
commit f72d9c1f21
103 changed files with 2332 additions and 853 deletions

View file

@ -162,7 +162,7 @@
return ret;
}
// Treat references to arrays like like references to a single element.
// Treat references to arrays like references to a single element.
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }

View file

@ -180,7 +180,7 @@ typedef struct swig_elua_entry {
* -------------------------------------------------------------------------- */
/* Push the string STR on the Lua stack, like lua_pushstring, but
prefixed with the the location of the innermost Lua call-point
prefixed with the location of the innermost Lua call-point
(as formated by luaL_where). */
SWIGRUNTIME void
SWIG_Lua_pusherrstring (lua_State *L, const char *str)
@ -191,7 +191,7 @@ SWIG_Lua_pusherrstring (lua_State *L, const char *str)
}
/* Push a formatted string generated from FMT and following args on
the Lua stack, like lua_pushfstring, but prefixed with the the
the Lua stack, like lua_pushfstring, but prefixed with the
location of the innermost Lua call-point (as formated by luaL_where). */
SWIGRUNTIME void
SWIG_Lua_pushferrstring (lua_State *L, const char *fmt, ...)

View file

@ -202,8 +202,8 @@ namespace swig
// swig::SwigVar_PyObject item = OctSequence_GetItem(_seq, _index);
octave_value item; // * todo
try {
return swig::as<T>(item, true);
} catch (std::exception& e) {
return swig::as<T>(item);
} catch (const std::exception& e) {
char msg[1024];
sprintf(msg, "in sequence element %d ", _index);
if (!Octave_Error_Occurred()) {

View file

@ -103,14 +103,14 @@ namespace swig {
template <class Type>
struct traits_as<Type, value_category> {
static Type as(const octave_value& obj, bool throw_error) {
static Type as(const octave_value& obj) {
Type v;
int res = asval(obj, &v);
if (!obj.is_defined() || !SWIG_IsOK(res)) {
if (!Octave_Error_Occurred()) {
%type_error(swig::type_name<Type>());
}
if (throw_error) throw std::invalid_argument("bad type");
throw std::invalid_argument("bad type");
}
return v;
}
@ -118,7 +118,7 @@ namespace swig {
template <class Type>
struct traits_as<Type, pointer_category> {
static Type as(const octave_value& obj, bool throw_error) {
static Type as(const octave_value& obj) {
Type *v = 0;
int res = traits_asptr<Type>::asptr(obj, &v);
if (SWIG_IsOK(res) && v) {
@ -130,21 +130,17 @@ namespace swig {
return *v;
}
} else {
// Uninitialized return value, no Type() constructor required.
static Type *v_def = (Type*) malloc(sizeof(Type));
if (!Octave_Error_Occurred()) {
%type_error(swig::type_name<Type>());
}
if (throw_error) throw std::invalid_argument("bad type");
memset(v_def,0,sizeof(Type));
return *v_def;
throw std::invalid_argument("bad type");
}
}
};
template <class Type>
struct traits_as<Type*, pointer_category> {
static Type* as(const octave_value& obj, bool throw_error) {
static Type* as(const octave_value& obj) {
Type *v = 0;
int res = traits_asptr<Type>::asptr(obj, &v);
if (SWIG_IsOK(res)) {
@ -153,15 +149,14 @@ namespace swig {
if (!Octave_Error_Occurred()) {
%type_error(swig::type_name<Type>());
}
if (throw_error) throw std::invalid_argument("bad type");
return 0;
throw std::invalid_argument("bad type");
}
}
};
template <class Type>
inline Type as(const octave_value& obj, bool te = false) {
return traits_as<Type, typename traits<Type>::category>::as(obj, te);
inline Type as(const octave_value& obj) {
return traits_as<Type, typename traits<Type>::category>::as(obj);
}
template <class Type>

View file

@ -392,7 +392,7 @@ SWIG_Perl_NewPackedObj(SWIG_MAYBE_PERL_OBJECT void *ptr, int sz, swig_type_info
return result;
}
/* Convert a packed value value */
/* Convert a packed pointer value */
SWIGRUNTIME int
SWIG_Perl_ConvertPacked(SWIG_MAYBE_PERL_OBJECT SV *obj, void *ptr, int sz, swig_type_info *ty) {
swig_cast_info *tc;

View file

@ -134,7 +134,7 @@
%typemap(in) SWIGTYPE *DISOWN
{
if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor, SWIG_POINTER_DISOWN ) < 0) {
SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $&1_descriptor");
SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $1_descriptor");
}
}

View file

@ -434,8 +434,8 @@ namespace swig
{
swig::SwigVar_PyObject item = PySequence_GetItem(_seq, _index);
try {
return swig::as<T>(item, true);
} catch (std::exception& e) {
return swig::as<T>(item);
} catch (const std::invalid_argument& e) {
char msg[1024];
sprintf(msg, "in sequence element %d ", (int)_index);
if (!PyErr_Occurred()) {

View file

@ -538,7 +538,7 @@ SwigPyObject_dealloc(PyObject *v)
PyObject *res;
/* PyObject_CallFunction() has the potential to silently drop
the active active exception. In cases of unnamed temporary
the active exception. In cases of unnamed temporary
variable or where we just finished iterating over a generator
StopIteration will be active right now, and this needs to
remain true upon return from SwigPyObject_dealloc. So save
@ -1308,7 +1308,7 @@ SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
}
}
/* Convert a packed value value */
/* Convert a packed pointer value */
SWIGRUNTIME int
SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) {

View file

@ -107,14 +107,14 @@ namespace swig {
template <class Type>
struct traits_as<Type, value_category> {
static Type as(PyObject *obj, bool throw_error) {
static Type as(PyObject *obj) {
Type v;
int res = asval(obj, &v);
if (!obj || !SWIG_IsOK(res)) {
if (!PyErr_Occurred()) {
::%type_error(swig::type_name<Type>());
}
if (throw_error) throw std::invalid_argument("bad type");
throw std::invalid_argument("bad type");
}
return v;
}
@ -122,7 +122,7 @@ namespace swig {
template <class Type>
struct traits_as<Type, pointer_category> {
static Type as(PyObject *obj, bool throw_error) {
static Type as(PyObject *obj) {
Type *v = 0;
int res = (obj ? traits_asptr<Type>::asptr(obj, &v) : SWIG_ERROR);
if (SWIG_IsOK(res) && v) {
@ -134,21 +134,17 @@ namespace swig {
return *v;
}
} else {
// Uninitialized return value, no Type() constructor required.
static Type *v_def = (Type*) malloc(sizeof(Type));
if (!PyErr_Occurred()) {
%type_error(swig::type_name<Type>());
}
if (throw_error) throw std::invalid_argument("bad type");
memset(v_def,0,sizeof(Type));
return *v_def;
throw std::invalid_argument("bad type");
}
}
};
template <class Type>
struct traits_as<Type*, pointer_category> {
static Type* as(PyObject *obj, bool throw_error) {
static Type* as(PyObject *obj) {
Type *v = 0;
int res = (obj ? traits_asptr<Type>::asptr(obj, &v) : SWIG_ERROR);
if (SWIG_IsOK(res)) {
@ -157,15 +153,14 @@ namespace swig {
if (!PyErr_Occurred()) {
%type_error(swig::type_name<Type>());
}
if (throw_error) throw std::invalid_argument("bad type");
return 0;
throw std::invalid_argument("bad type");
}
}
};
template <class Type>
inline Type as(PyObject *obj, bool te = false) {
return traits_as<Type, typename traits<Type>::category>::as(obj, te);
inline Type as(PyObject *obj) {
return traits_as<Type, typename traits<Type>::category>::as(obj);
}
template <class Type>

View file

@ -350,7 +350,7 @@ SWIG_R_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) {
return ptr ? RSwigPacked_New((void *) ptr, sz, type) : R_NilValue;
}
/* Convert a packed value value */
/* Convert a packed pointer value */
SWIGRUNTIME int
SWIG_R_ConvertPacked(SEXP obj, void *ptr, size_t sz, swig_type_info *ty) {

View file

@ -101,12 +101,11 @@ namespace swig {
template <class Type>
struct traits_as<Type, value_category> {
static Type as(SWIG_Object obj, bool throw_error) {
static Type as(SWIG_Object obj) {
Type v;
int res = asval(obj, &v);
if (!obj || !SWIG_IsOK(res)) {
if (throw_error)
throw std::invalid_argument("bad type");
throw std::invalid_argument("bad type");
}
return v;
}
@ -114,7 +113,7 @@ namespace swig {
template <class Type>
struct traits_as<Type, pointer_category> {
static Type as(SWIG_Object obj, bool throw_error) {
static Type as(SWIG_Object obj) {
Type *v = 0;
int res = (obj ? traits_asptr<Type>::asptr(obj, &v) : SWIG_ERROR);
if (SWIG_IsOK(res) && v) {
@ -126,12 +125,7 @@ namespace swig {
return *v;
}
} else {
// Uninitialized return value, no Type() constructor required.
static Type *v_def = (Type*) malloc(sizeof(Type));
if (throw_error)
throw std::invalid_argument("bad type");
memset(v_def,0,sizeof(Type));
return *v_def;
}
}
};
@ -152,8 +146,8 @@ namespace swig {
};
template <class Type>
inline Type as(SWIG_Object obj, bool te = false) {
return traits_as<Type, typename traits<Type>::category>::as(obj, te);
inline Type as(SWIG_Object obj) {
return traits_as<Type, typename traits<Type>::category>::as(obj);
}
template <class Type>

View file

@ -7,7 +7,7 @@
# This could be provided as a separate run-time library but this
# approach allows the code to to be included directly into the
# approach allows the code to be included directly into the
# generated bindings and so removes the need to have and install an
# additional library. We may however end up with multiple copies of
# this and some confusion at run-time as to which class to use. This

View file

@ -183,8 +183,8 @@ namespace swig
{
VALUE item = rb_ary_entry(_seq, _index );
try {
return swig::as<T>(item, true);
} catch (std::exception& e) {
return swig::as<T>(item);
} catch (const std::invalid_argument& e) {
char msg[1024];
sprintf(msg, "in sequence element %d ", _index);
VALUE lastErr = rb_gv_get("$!");
@ -926,7 +926,7 @@ namespace swig
VALUE elem = argv[0];
int idx = 0;
try {
Sequence::value_type val = swig::as<Sequence::value_type>( elem, true );
Sequence::value_type val = swig::as<Sequence::value_type>( elem );
if ( i >= len ) {
$self->resize(i-1, val);
return $self;
@ -943,7 +943,7 @@ namespace swig
}
}
catch( std::invalid_argument )
catch( const std::invalid_argument & )
{
rb_raise( rb_eArgError, "%s",
Ruby_Format_TypeError( "",
@ -967,10 +967,10 @@ namespace swig
Sequence::iterator start = $self->begin();
VALUE elem = argv[idx];
try {
Sequence::value_type val = swig::as<Sequence::value_type>( elem, true );
Sequence::value_type val = swig::as<Sequence::value_type>( elem );
$self->insert( start, val );
}
catch( std::invalid_argument )
catch( const std::invalid_argument & )
{
rb_raise( rb_eArgError, "%s",
Ruby_Format_TypeError( "",

View file

@ -363,7 +363,7 @@ SWIG_Ruby_NewPackedObj(void *ptr, int sz, swig_type_info *type) {
return rb_str_new2(result);
}
/* Convert a packed value value */
/* Convert a packed pointer value */
SWIGRUNTIME int
SWIG_Ruby_ConvertPacked(VALUE obj, void *ptr, int sz, swig_type_info *ty) {
swig_cast_info *tc;

View file

@ -115,15 +115,15 @@ namespace swig {
template <class Type>
struct traits_as<Type, value_category> {
static Type as(VALUE obj, bool throw_error) {
static Type as(VALUE obj) {
Type v;
int res = asval(obj, &v);
if (!SWIG_IsOK(res)) {
if (throw_error) throw std::invalid_argument("bad type");
VALUE lastErr = rb_gv_get("$!");
if (lastErr == Qnil) {
%type_error(swig::type_name<Type>());
}
throw std::invalid_argument("bad type");
}
return v;
}
@ -131,7 +131,7 @@ namespace swig {
template <class Type>
struct traits_as<Type, pointer_category> {
static Type as(VALUE obj, bool throw_error) {
static Type as(VALUE obj) {
Type *v = 0;
int res = traits_asptr<Type>::asptr(obj, &v);
if (SWIG_IsOK(res) && v) {
@ -143,40 +143,35 @@ namespace swig {
return *v;
}
} else {
// Uninitialized return value, no Type() constructor required.
if (throw_error) throw std::invalid_argument("bad type");
VALUE lastErr = rb_gv_get("$!");
if (lastErr == Qnil) {
%type_error(swig::type_name<Type>());
}
static Type *v_def = (Type*) malloc(sizeof(Type));
memset(v_def,0,sizeof(Type));
return *v_def;
throw std::invalid_argument("bad type");
}
}
};
template <class Type>
struct traits_as<Type*, pointer_category> {
static Type* as(VALUE obj, bool throw_error) {
static Type* as(VALUE obj) {
Type *v = 0;
int res = traits_asptr<Type>::asptr(obj, &v);
if (SWIG_IsOK(res)) {
return v;
} else {
if (throw_error) throw std::invalid_argument("bad type");
VALUE lastErr = rb_gv_get("$!");
if (lastErr == Qnil) {
%type_error(swig::type_name<Type>());
}
return 0;
throw std::invalid_argument("bad type");
}
}
};
template <class Type>
inline Type as(VALUE obj, bool te = false) {
return traits_as< Type, typename traits< Type >::category >::as(obj, te);
inline Type as(VALUE obj) {
return traits_as< Type, typename traits< Type >::category >::as(obj);
}
template <class Type>

View file

@ -80,35 +80,35 @@ namespace swig {
template <class Type>
struct traits_as<std::shared_ptr<Type>, pointer_category> {
static std::shared_ptr<Type> as(VALUE obj, bool throw_error) {
static std::shared_ptr<Type> as(VALUE obj) {
std::shared_ptr<Type> ret;
std::shared_ptr<Type> *v = &ret;
int res = traits_asptr<std::shared_ptr<Type> >::asptr(obj, &v);
if (SWIG_IsOK(res)) {
return ret;
} else {
if (throw_error) throw std::invalid_argument("bad type");
VALUE lastErr = rb_gv_get("$!");
if (lastErr == Qnil)
SWIG_Error(SWIG_TypeError, swig::type_name<std::shared_ptr<Type> >());
return std::shared_ptr<Type>();
throw std::invalid_argument("bad type");
}
}
};
template <class Type>
struct traits_as<std::shared_ptr<Type> *, pointer_category> {
static std::shared_ptr<Type> * as(VALUE obj, bool throw_error) {
static std::shared_ptr<Type> * as(VALUE obj) {
std::shared_ptr<Type> *p = 0;
int res = traits_asptr<std::shared_ptr<Type> >::asptr(obj, &p);
if (SWIG_IsOK(res)) {
return p;
} else {
if (throw_error) throw std::invalid_argument("bad type");
VALUE lastErr = rb_gv_get("$!");
if (lastErr == Qnil)
SWIG_Error(SWIG_TypeError, swig::type_name<std::shared_ptr<Type> *>());
return 0;
throw std::invalid_argument("bad type");
}
}
};

View file

@ -104,23 +104,21 @@ namespace swig {
template <class Type>
struct traits_as<Type, value_category> {
static Type as(const SwigSciObject& obj, bool throw_error) {
static Type as(const SwigSciObject& obj) {
Type v;
int res = asval(obj, &v);
if (SWIG_IsOK(res)) {
return v;
} else {
%type_error(swig::type_name<Type>());
if (throw_error)
throw std::invalid_argument("bad type");
return res;
%type_error(swig::type_name<Type>());
throw std::invalid_argument("bad type");
}
}
};
template <class Type>
struct traits_as<Type, pointer_category> {
static Type as(const SwigSciObject& obj, bool throw_error) {
static Type as(const SwigSciObject& obj) {
Type *v = 0;
int res = traits_asptr<Type>::asptr(obj, &v);
if (SWIG_IsOK(res) && v) {
@ -132,36 +130,29 @@ namespace swig {
return *v;
}
} else {
// Uninitialized return value, no Type() constructor required.
static Type *v_def = (Type*) malloc(sizeof(Type));
%type_error(swig::type_name<Type>());
if (throw_error)
throw std::invalid_argument("bad type");
memset(v_def,0,sizeof(Type));
return *v_def;
%type_error(swig::type_name<Type>());
throw std::invalid_argument("bad type");
}
}
};
template <class Type>
struct traits_as<Type*, pointer_category> {
static Type* as(const SwigSciObject& obj, bool throw_error) {
static Type* as(const SwigSciObject& obj) {
Type *v = 0;
int res = traits_asptr<Type>::asptr(obj, &v);
if (SWIG_IsOK(res)) {
return v;
} else {
%type_error(swig::type_name<Type>());
if (throw_error)
throw std::invalid_argument("bad type");
return SWIG_OK;
%type_error(swig::type_name<Type>());
throw std::invalid_argument("bad type");
}
}
};
template <class Type>
inline Type as(const SwigSciObject& obj, bool te = false) {
return traits_as<Type, typename traits<Type>::category>::as(obj, te);
inline Type as(const SwigSciObject& obj) {
return traits_as<Type, typename traits<Type>::category>::as(obj);
}
template <class Type>

View file

@ -7,7 +7,7 @@
#define SWIG_Object int
#define %append_output(obj) if (!SWIG_IsOK(SWIG_Scilab_SetOutput(pvApiCtx, obj))) return SWIG_ERROR
#define %set_constant(name, obj) if (!SWIG_IsOK(SWIG_Scilab_SetOutput(pvApiCtx, obj))) return SWIG_ERROR // Name is managed by the the function name
#define %set_constant(name, obj) if (!SWIG_IsOK(SWIG_Scilab_SetOutput(pvApiCtx, obj))) return SWIG_ERROR // Name is managed by the function name
#define %raise(obj, type, desc) SWIG_Scilab_Raise(obj, type, desc)
#define %set_output(obj) if (!SWIG_IsOK(SWIG_Scilab_SetOutput(pvApiCtx, obj))) return SWIG_ERROR
#define %set_varoutput(obj) if (!SWIG_IsOK(SWIG_Scilab_SetOutput(pvApiCtx, obj))) return SWIG_ERROR

View file

@ -199,7 +199,7 @@ SWIG_Tcl_PointerTypeFromString(char *c) {
return c;
}
/* Convert a packed value value */
/* Convert a packed pointer value */
SWIGRUNTIME int
SWIG_Tcl_ConvertPacked(Tcl_Interp *SWIGUNUSEDPARM(interp) , Tcl_Obj *obj, void *ptr, int sz, swig_type_info *ty) {
swig_cast_info *tc;