Merge pull request #60 from smarchetto/gsoc2012-scilab
Fix Scilab test-suite build errors
This commit is contained in:
commit
542b991d62
12 changed files with 74 additions and 87 deletions
|
|
@ -1,11 +1,12 @@
|
|||
exec("swigtest.start", -1);
|
||||
|
||||
// TODO: support for STL vectors operator =
|
||||
iv = new_DoubleVector();
|
||||
for i=1:4
|
||||
iv(i) = i;
|
||||
end
|
||||
x = average(iv);
|
||||
//for i=1:4
|
||||
// iv(i) = i;
|
||||
//end
|
||||
//x = average(iv);
|
||||
|
||||
if x <> 2.5 then swigtesterror(); end
|
||||
//if x <> 2.5 then swigtesterror(); end
|
||||
exit
|
||||
exec("swigtest.quit", -1);
|
||||
|
|
|
|||
|
|
@ -52,6 +52,19 @@
|
|||
%typemap(javain) int Space::Struct::smember "/*int smember in */ $javainput"
|
||||
%typemap(javaout) int Space::Struct::smember "/*int smember out*/ { return $jnicall; }"
|
||||
|
||||
#if defined(SWIGSCILAB)
|
||||
%clear int globul;
|
||||
%clear int Space::nspace;
|
||||
%clear int Space::Struct::smember;
|
||||
%ignore Space::Struct::member;
|
||||
%typemap(varin) int globul "TYPEMAP_VARIABLES_FAIL";
|
||||
%typemap(varout, noblock=1, fragment=SWIG_From_frag(int)) int globul "if (!SWIG_IsOK(SWIG_Scilab_SetOutput(pvApiCtx, SWIG_From_int($result)))) return SWIG_ERROR;";
|
||||
%typemap(varin) int Space::nspace "TYPEMAP_VARIABLES_FAIL";
|
||||
%typemap(varout, noblock=1, fragment=SWIG_From_frag(int)) int Space::nspace "if (!SWIG_IsOK(SWIG_Scilab_SetOutput(pvApiCtx, SWIG_From_int($result)))) return SWIG_ERROR;";
|
||||
%typemap(varin) int Space::Struct::smember "TYPEMAP_VARIABLES_FAIL";
|
||||
%typemap(varout, noblock=1, fragment=SWIG_From_frag(int)) int Space::Struct::smember "if (!SWIG_IsOK(SWIG_Scilab_SetOutput(pvApiCtx, SWIG_From_int($result)))) return SWIG_ERROR;";
|
||||
#endif
|
||||
|
||||
%inline %{
|
||||
|
||||
int globul;
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ SwigScilabStringToChar(void *_pvApiCtx, int _iVar, char *_pcValue, char *_fname)
|
|||
}
|
||||
|
||||
%fragment(SWIG_From_frag(char), "header", fragment="SwigScilabStringFromChar") {
|
||||
#define SWIG_From_char(value) SwigScilabStringFromChar(pvApiCtx, $result, value)
|
||||
#define SWIG_From_char(value) SwigScilabStringFromChar(pvApiCtx, SWIG_Scilab_GetOutputPosition(), value)
|
||||
}
|
||||
%fragment("SwigScilabStringFromChar", "header") {
|
||||
SWIGINTERN int
|
||||
|
|
@ -87,7 +87,7 @@ SwigScilabStringFromChar(void *_pvApiCtx, int _iVarOut, char _chValue) {
|
|||
#define SWIG_FromCharPtr(charPtr) SwigScilabStringFromCharPtr(pvApiCtx, $result, charPtr)
|
||||
}
|
||||
%fragment("SWIG_FromCharPtrAndSize", "header", fragment = "SwigScilabStringFromCharPtrAndSize") {
|
||||
#define SWIG_FromCharPtrAndSize(charPtr, charPtrLength) SwigScilabStringFromCharPtrAndSize(pvApiCtx, $result, charPtr)
|
||||
#define SWIG_FromCharPtrAndSize(charPtr, charPtrLength) SwigScilabStringFromCharPtrAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), charPtr)
|
||||
}
|
||||
%fragment("SwigScilabStringToCharPtr", "header") {
|
||||
SWIGINTERN int
|
||||
|
|
|
|||
|
|
@ -38,22 +38,22 @@ namespace swig {
|
|||
typedef value_category category;
|
||||
static const char* type_name() { return "SciObject"; }
|
||||
};
|
||||
|
||||
|
||||
template <> struct traits_from<SciObject> {
|
||||
typedef SciObject value_type;
|
||||
static SciObject from(const value_type& val) {
|
||||
return val;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
|
||||
template <>
|
||||
struct traits_check<SciObject, value_category> {
|
||||
static bool check(const SciObject&) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct traits_asval<SciObject > {
|
||||
|
||||
template <> struct traits_asval<SciObject > {
|
||||
typedef SciObject value_type;
|
||||
static int asval(const SciObject& obj, value_type *val) {
|
||||
if (val) *val = obj;
|
||||
|
|
@ -73,7 +73,7 @@ namespace std {
|
|||
{
|
||||
bool
|
||||
operator()(const SciObject& v, const SciObject& w) const
|
||||
{
|
||||
{
|
||||
//SciObject res = do_binary_op(SciObject::op_le,v,w);
|
||||
return true;//res.is_true();
|
||||
}
|
||||
|
|
@ -91,7 +91,7 @@ namespace swig {
|
|||
} else if (insert && ((size_t) i == size)) {
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
throw std::out_of_range("index out of range");
|
||||
}
|
||||
|
||||
|
|
@ -188,6 +188,8 @@ namespace swig {
|
|||
fragment="SciSequence_Base",
|
||||
fragment="SciSwigIterator_T")
|
||||
{
|
||||
%#include <stdio.h>
|
||||
|
||||
namespace swig
|
||||
{
|
||||
template <class T>
|
||||
|
|
@ -197,7 +199,7 @@ namespace swig
|
|||
: _seq(seq), _index(index)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
operator T () const
|
||||
{
|
||||
// swig::SwigVar_PyObject item = SciSequence_GetItem(_seq, _index);
|
||||
|
|
@ -436,28 +438,19 @@ namespace swig
|
|||
|
||||
%typemap(out,noblock=1,fragment="SciSequence_Cont")
|
||||
iterator, reverse_iterator, const_iterator, const_reverse_iterator {
|
||||
$result = SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &)),
|
||||
swig::SciSwigIterator::descriptor(),SWIG_POINTER_OWN);
|
||||
%set_output(SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &)),
|
||||
swig::SciSwigIterator::descriptor(),SWIG_POINTER_OWN));
|
||||
}
|
||||
%typemap(out,fragment="SciSequence_Cont")
|
||||
std::pair<iterator, iterator>, std::pair<const_iterator, const_iterator> {
|
||||
SciObject_list tmpc;
|
||||
tmpc.append(SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).first),
|
||||
swig::SciSwigIterator::descriptor(),SWIG_POINTER_OWN));
|
||||
tmpc.append(SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).second),
|
||||
swig::SciSwigIterator::descriptor(),SWIG_POINTER_OWN));
|
||||
$result = Cell(tmpc);
|
||||
// TODO: return a Scilab list from the pair (see code for Octave)
|
||||
}
|
||||
|
||||
%fragment("SwigPyPairBoolOutputIterator","header",fragment=SWIG_From_frag(bool),fragment="SciSequence_Cont") {}
|
||||
|
||||
%typemap(out,fragment="SciPairBoolOutputIterator")
|
||||
std::pair<iterator, bool>, std::pair<const_iterator, bool> {
|
||||
SciObject_list tmpc;
|
||||
tmpc.append(SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).first),
|
||||
swig::SciSwigIterator::descriptor(),SWIG_POINTER_OWN));
|
||||
tmpc.append(SWIG_From(bool)(%static_cast($1,const $type &).second));
|
||||
$result = Cell(tmpc);
|
||||
// TODO: return a Scilab list from the pair (see code for Octave)
|
||||
}
|
||||
|
||||
%typemap(in,noblock=1,fragment="SciSequence_Cont")
|
||||
|
|
@ -465,7 +458,7 @@ namespace swig
|
|||
reverse_iterator(swig::SciSwigIterator *iter = 0, int res),
|
||||
const_iterator(swig::SciSwigIterator *iter = 0, int res),
|
||||
const_reverse_iterator(swig::SciSwigIterator *iter = 0, int res) {
|
||||
res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::SciSwigIterator::descriptor(), 0);
|
||||
res = SWIG_ConvertPtr((SciObject)$input, %as_voidptrptr(&iter), swig::SciSwigIterator::descriptor(), 0);
|
||||
if (!SWIG_IsOK(res) || !iter) {
|
||||
%argument_fail(SWIG_TypeError, "$type", $symname, $argnum);
|
||||
} else {
|
||||
|
|
@ -481,7 +474,7 @@ namespace swig
|
|||
%typecheck(%checkcode(ITERATOR),noblock=1,fragment="SciSequence_Cont")
|
||||
iterator, reverse_iterator, const_iterator, const_reverse_iterator {
|
||||
swig::SciSwigIterator *iter = 0;
|
||||
int res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::SciSwigIterator::descriptor(), 0);
|
||||
int res = SWIG_ConvertPtr((SciObject)$input, %as_voidptrptr(&iter), swig::SciSwigIterator::descriptor(), 0);
|
||||
$1 = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SciSwigIterator_T<$type > *>(iter) != 0));
|
||||
}
|
||||
|
||||
|
|
@ -497,7 +490,7 @@ namespace swig
|
|||
%define %swig_sequence_methods_common(Sequence...)
|
||||
%swig_sequence_iterator(%arg(Sequence))
|
||||
%swig_container_methods(%arg(Sequence))
|
||||
|
||||
|
||||
%fragment("SciSequence_Base");
|
||||
|
||||
%extend {
|
||||
|
|
@ -561,30 +554,7 @@ namespace swig {
|
|||
typedef T value_type;
|
||||
|
||||
static int asptr(const SciObject& obj, sequence **seq) {
|
||||
if (!obj.is_defined() || Swig::swig_value_deref(obj)) {
|
||||
sequence *p;
|
||||
if (SWIG_ConvertPtr(obj,(void**)&p,
|
||||
swig::type_info<sequence>(),0) == SWIG_OK) {
|
||||
if (seq) *seq = p;
|
||||
return SWIG_OLDOBJ;
|
||||
}
|
||||
} else if (obj.is_cell()) {
|
||||
try {
|
||||
SciSequence_Cont<value_type> sciseq(obj);
|
||||
if (seq) {
|
||||
sequence *pseq = new sequence();
|
||||
assign(sciseq, pseq);
|
||||
*seq = pseq;
|
||||
return SWIG_NEWOBJ;
|
||||
} else {
|
||||
return sciseq.check() ? SWIG_OK : SWIG_ERROR;
|
||||
}
|
||||
} catch (std::exception& e) {
|
||||
if (seq&&!error_state)
|
||||
error("swig type error: %s",e.what());
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
// TODO: convert input Scilab list (or pointer) to sequence.
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
};
|
||||
|
|
@ -600,25 +570,12 @@ namespace swig {
|
|||
#ifdef SWIG_SCILAB_EXTRA_NATIVE_CONTAINERS
|
||||
swig_type_info *desc = swig::type_info<sequence>();
|
||||
if (desc && desc->clientdata) {
|
||||
return SWIG_NewPointerObj(new sequence(seq), desc, SWIG_POINTER_OWN);
|
||||
return SWIG_NewPointerObj(new sequence(seq), desc, SWIG_POINTER_OWN);
|
||||
}
|
||||
#endif
|
||||
size_type size = seq.size();
|
||||
if (size <= (size_type)INT_MAX) {
|
||||
Cell c(size,1);
|
||||
int i = 0;
|
||||
for (const_iterator it = seq.begin();
|
||||
it != seq.end(); ++it, ++i) {
|
||||
c(i) = swig::from<value_type>(*it);
|
||||
}
|
||||
return c;
|
||||
} else {
|
||||
error("swig overflow error: sequence size not valid in Scilab");
|
||||
return SciObject();
|
||||
}
|
||||
return SciObject();
|
||||
// TODO: return a Scilab list from the sequence.
|
||||
return (SciObject)0;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -321,6 +321,12 @@ namespace swig
|
|||
%catches(swig::stop_iteration) SciSwigIterator::operator + (ptrdiff_t n) const;
|
||||
%catches(swig::stop_iteration) SciSwigIterator::operator - (ptrdiff_t n) const;
|
||||
|
||||
%ignore SciSwigIterator::operator==;
|
||||
%ignore SciSwigIterator::operator!=;
|
||||
%ignore SciSwigIterator::operator++;
|
||||
%ignore SciSwigIterator::operator--;
|
||||
%ignore SciSwigIterator::operator+;
|
||||
%ignore SciSwigIterator::operator-;
|
||||
|
||||
struct SciSwigIterator
|
||||
{
|
||||
|
|
@ -355,4 +361,3 @@ namespace swig
|
|||
ptrdiff_t operator - (const SciSwigIterator& x) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,11 +27,3 @@ static void SWIG_Scilab_SetOutputPosition(int _outputPosition) {
|
|||
#define Scilab_Error_Occurred() 0
|
||||
#define SWIG_Scilab_AddErrorMsg(msg) {;}
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace std {
|
||||
class SciObject {
|
||||
public:
|
||||
SciObject();
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ SWIG_SciUint8_AsUnsignedChar(void *_pvApiCtx, int _iVar, unsigned char *_pucValu
|
|||
}
|
||||
|
||||
%fragment(SWIG_From_frag(unsigned char), "header", fragment="SWIG_SciUint8_FromUnsignedChar") {
|
||||
#define SWIG_From_unsigned_SS_char(value) SWIG_SciUint8_FromUnsignedChar(pvApiCtx, $result, value)
|
||||
#define SWIG_From_unsigned_SS_char(value) SWIG_SciUint8_FromUnsignedChar(pvApiCtx, SWIG_Scilab_GetOutputPosition(), value)
|
||||
}
|
||||
%fragment("SWIG_SciUint8_FromUnsignedChar", "header") {
|
||||
SWIGINTERN int
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ SwigScilabUint32ToUnsignedInt(void *_pvApiCtx, int _iVar, unsigned int *_puiValu
|
|||
}
|
||||
}
|
||||
%fragment(SWIG_From_frag(unsigned int), "header", fragment="SwigScilabUint32FromUnsignedInt") {
|
||||
#define SWIG_From_unsigned_SS_int(value) SwigScilabUint32FromUnsignedInt(pvApiCtx, $result, value)
|
||||
#define SWIG_From_unsigned_SS_int(value) SwigScilabUint32FromUnsignedInt(pvApiCtx, SWIG_Scilab_GetOutputPosition(), value)
|
||||
}
|
||||
%fragment("SwigScilabUint32FromUnsignedInt", "header") {
|
||||
SWIGINTERN int
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ SWIG_SciUint16_AsUnsignedShort(void *_pvApiCtx, int _iVar, unsigned short *_pusV
|
|||
}
|
||||
|
||||
%fragment(SWIG_From_frag(unsigned short), "header", fragment="SWIG_SciUint16_FromUnsignedShort") {
|
||||
#define SWIG_From_unsigned_SS_short(value) SWIG_SciUint16_FromUnsignedShort(pvApiCtx, $result, value)
|
||||
#define SWIG_From_unsigned_SS_short(value) SWIG_SciUint16_FromUnsignedShort(pvApiCtx, SWIG_Scilab_GetOutputPosition(), value)
|
||||
}
|
||||
%fragment("SWIG_SciUint16_FromUnsignedShort", "header") {
|
||||
SWIGINTERN int
|
||||
|
|
|
|||
|
|
@ -6,20 +6,21 @@
|
|||
namespace swig {
|
||||
template <class T>
|
||||
struct traits_asptr<std::vector<T> > {
|
||||
static int asptr(SciObject *obj, std::vector<T> **vec) {
|
||||
return traits_asptr_stdseq<std::vector<T> >::asptr(obj, vec);
|
||||
static int asptr(const SciObject &obj, std::vector<T> **vec) {
|
||||
return traits_asptr_stdseq<std::vector<T> >::asptr(obj, vec);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct traits_from<std::vector<T> > {
|
||||
static SciObject *from(const std::vector<T>& vec) {
|
||||
static SciObject from(const std::vector<T>& vec) {
|
||||
return traits_from_stdseq<std::vector<T> >::from(vec);
|
||||
}
|
||||
};
|
||||
}
|
||||
%}
|
||||
|
||||
|
||||
#define %swig_vector_methods(Type...) %swig_sequence_methods(Type)
|
||||
#define %swig_vector_methods_val(Type...) %swig_sequence_methods_val(Type);
|
||||
|
||||
|
|
|
|||
|
|
@ -49,12 +49,17 @@ or you can use the %apply directive :
|
|||
double fadd(double *a, double *b);
|
||||
|
||||
*/
|
||||
|
||||
%typemap(in, noblock=1, fragment=SWIG_AsVal_frag(int)) int *INPUT(int temp), int &INPUT(int temp) {
|
||||
if (SWIG_AsVal_dec(int)($input, &temp) != SWIG_OK) {
|
||||
SWIG_fail;
|
||||
}
|
||||
$1 = &temp;
|
||||
}
|
||||
|
||||
%typemap(freearg, noblock=1) int *INPUT, int &INPUT {
|
||||
}
|
||||
|
||||
//short *INPUT
|
||||
//long *INPUT
|
||||
//long long *INPUT
|
||||
|
|
@ -65,6 +70,7 @@ or you can use the %apply directive :
|
|||
//unsigned char *INPUT
|
||||
//bool *INPUT
|
||||
//float *INPUT
|
||||
|
||||
%typemap(in, noblock=1, fragment=SWIG_AsVal_frag(double)) double *INPUT(double temp), double &INPUT(double temp) {
|
||||
if (SWIG_AsVal_dec(double)($input, &temp) != SWIG_OK) {
|
||||
SWIG_fail;
|
||||
|
|
@ -72,7 +78,8 @@ or you can use the %apply directive :
|
|||
$1 = &temp;
|
||||
}
|
||||
|
||||
|
||||
%typemap(freearg, noblock=1) double *INPUT, double &INPUT {
|
||||
}
|
||||
|
||||
// OUTPUT typemaps. These typemaps are used for parameters that
|
||||
// are output only. The output value is appended to the result as
|
||||
|
|
|
|||
|
|
@ -544,10 +544,21 @@ public:
|
|||
|
||||
/* Get the useful information from the node */
|
||||
String *nodeName = Getattr(node, "name");
|
||||
SwigType *type = Getattr(node, "type");
|
||||
String *constantName = Getattr(node, "sym:name");
|
||||
String *rawValue = Getattr(node, "rawval");
|
||||
String *constantValue = rawValue ? rawValue : Getattr(node, "value");
|
||||
String *constantTypemap = NULL;
|
||||
|
||||
/* Create variables for member pointer constants, not suppported by typemaps (like Python wrapper does) */
|
||||
if (SwigType_type(type) == T_MPOINTER) {
|
||||
String *wname = Swig_name_wrapper(constantName);
|
||||
String *str = SwigType_str(type, wname);
|
||||
Printf(headerSection, "static %s = %s;\n", str, constantValue);
|
||||
Delete(str);
|
||||
constantValue = wname;
|
||||
}
|
||||
|
||||
/* Create GET function to get the constant value */
|
||||
Wrapper *getFunctionWrapper = NewWrapper();
|
||||
String *getFunctionName = Swig_name_get(NSPACE_TODO, constantName);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue