Another merge with master.
Change Doxygen error codes to start at 740 instead of at 720 as the latter was taken by Scilab in the meanwhile. Resolve conflicts in autodoc_runme.py once again.
This commit is contained in:
commit
300ccce46c
419 changed files with 18675 additions and 1315 deletions
|
|
@ -18,7 +18,7 @@
|
|||
%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE &
|
||||
%{ static $*1_ltype temp = ($*1_ltype)$input;
|
||||
$result = &temp; %}
|
||||
%typemap(directorin) const enum SWIGTYPE & "$input = $1;"
|
||||
%typemap(directorin) const enum SWIGTYPE & "$input = (int)$1;"
|
||||
%typemap(csdirectorin) const enum SWIGTYPE & "($*csclassname)$iminput"
|
||||
%typemap(csdirectorout) const enum SWIGTYPE & "(int)$cscall"
|
||||
|
||||
|
|
@ -51,7 +51,7 @@
|
|||
%typemap(out) enum SWIGTYPE %{ $result = (int)$1; %}
|
||||
|
||||
%typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %}
|
||||
%typemap(directorin) enum SWIGTYPE "$input = $1;"
|
||||
%typemap(directorin) enum SWIGTYPE "$input = (int)$1;"
|
||||
%typemap(csdirectorin) enum SWIGTYPE "($csclassname)$iminput"
|
||||
%typemap(csdirectorout) enum SWIGTYPE "(int)$cscall"
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE &
|
||||
%{ static $*1_ltype temp = ($*1_ltype)$input;
|
||||
$result = &temp; %}
|
||||
%typemap(directorin) const enum SWIGTYPE & "$input = $1;"
|
||||
%typemap(directorin) const enum SWIGTYPE & "$input = (int)$1;"
|
||||
%typemap(csdirectorin) const enum SWIGTYPE & "$iminput"
|
||||
%typemap(csdirectorout) const enum SWIGTYPE & "$cscall"
|
||||
|
||||
|
|
@ -53,7 +53,7 @@
|
|||
%typemap(out) enum SWIGTYPE %{ $result = (int)$1; %}
|
||||
|
||||
%typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %}
|
||||
%typemap(directorin) enum SWIGTYPE "$input = $1;"
|
||||
%typemap(directorin) enum SWIGTYPE "$input = (int)$1;"
|
||||
%typemap(csdirectorin) enum SWIGTYPE "$iminput"
|
||||
%typemap(csdirectorout) enum SWIGTYPE "$cscall"
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE &
|
||||
%{ static $*1_ltype temp = ($*1_ltype)$input;
|
||||
$result = &temp; %}
|
||||
%typemap(directorin) const enum SWIGTYPE & "$input = $1;"
|
||||
%typemap(directorin) const enum SWIGTYPE & "$input = (int)$1;"
|
||||
%typemap(csdirectorin) const enum SWIGTYPE & "$*csclassname.swigToEnum($iminput)"
|
||||
%typemap(csdirectorout) const enum SWIGTYPE & "$cscall.swigValue"
|
||||
|
||||
|
|
@ -52,7 +52,7 @@
|
|||
%typemap(out) enum SWIGTYPE %{ $result = (int)$1; %}
|
||||
|
||||
%typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %}
|
||||
%typemap(directorin) enum SWIGTYPE "$input = $1;"
|
||||
%typemap(directorin) enum SWIGTYPE "$input = (int)$1;"
|
||||
%typemap(csdirectorin) enum SWIGTYPE "$csclassname.swigToEnum($iminput)"
|
||||
%typemap(csdirectorout) enum SWIGTYPE "$cscall.swigValue"
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ typedef enum {
|
|||
SWIG_DIllegalArgumentException,
|
||||
SWIG_DIllegalElementException,
|
||||
SWIG_DIOException,
|
||||
SWIG_DNoSuchElementException,
|
||||
SWIG_DNoSuchElementException
|
||||
} SWIG_DExceptionCodes;
|
||||
|
||||
typedef void (* SWIG_DExceptionCallback_t)(const char *);
|
||||
|
|
|
|||
|
|
@ -8,16 +8,47 @@
|
|||
typedef struct SWIGCDATA {
|
||||
char *data;
|
||||
intgo len;
|
||||
intgo cap;
|
||||
} SWIGCDATA;
|
||||
%}
|
||||
|
||||
%typemap(gotype) SWIGCDATA %{ []byte %}
|
||||
%typemap(out) SWIGCDATA %{
|
||||
$result.data = (char*)_swig_goallocate($1.len);
|
||||
memcpy($result.data, $1.data, $1.len);
|
||||
$result.len = (intgo)$1.len;
|
||||
$result.cap = $result.len;
|
||||
%fragment("cdata", "header") %{
|
||||
struct swigcdata {
|
||||
intgo size;
|
||||
void *data;
|
||||
};
|
||||
%}
|
||||
|
||||
%typemap(gotype) SWIGCDATA "[]byte"
|
||||
|
||||
%typemap(imtype) SWIGCDATA "uint64"
|
||||
|
||||
%typemap(out, fragment="cdata") SWIGCDATA(struct swigcdata *swig_out) %{
|
||||
swig_out = (struct swigcdata *)malloc(sizeof(*swig_out));
|
||||
if (swig_out) {
|
||||
swig_out->size = $1.len;
|
||||
swig_out->data = malloc(swig_out->size);
|
||||
if (swig_out->data) {
|
||||
memcpy(swig_out->data, $1.data, swig_out->size);
|
||||
}
|
||||
}
|
||||
$result = *(long long *)(void **)&swig_out;
|
||||
%}
|
||||
|
||||
%typemap(goout) SWIGCDATA %{
|
||||
{
|
||||
type swigcdata struct { size int; data uintptr }
|
||||
p := (*swigcdata)(unsafe.Pointer(uintptr($1)))
|
||||
if p == nil || p.data == 0 {
|
||||
$result = nil
|
||||
} else {
|
||||
b := make([]byte, p.size)
|
||||
a := (*[0x7fffffff]byte)(unsafe.Pointer(p.data))[:p.size]
|
||||
copy(b, a)
|
||||
Swig_free(p.data)
|
||||
Swig_free(uintptr(unsafe.Pointer(p)))
|
||||
$result = b
|
||||
}
|
||||
}
|
||||
%}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
|
|||
190
Lib/go/go.swg
190
Lib/go/go.swg
|
|
@ -4,6 +4,8 @@
|
|||
* Go configuration module.
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
%include <gostring.swg>
|
||||
|
||||
/* Code insertion directives */
|
||||
#define %go_import(...) %insert(go_imports) %{__VA_ARGS__%}
|
||||
|
||||
|
|
@ -75,6 +77,22 @@
|
|||
double
|
||||
%{ $result = $1; %}
|
||||
|
||||
%typemap(goout) bool,
|
||||
char,
|
||||
signed char,
|
||||
unsigned char,
|
||||
short,
|
||||
unsigned short,
|
||||
int,
|
||||
unsigned int,
|
||||
long,
|
||||
unsigned long,
|
||||
long long,
|
||||
unsigned long long,
|
||||
float,
|
||||
double
|
||||
""
|
||||
|
||||
%typemap(out) const bool &,
|
||||
const char &,
|
||||
const signed char &,
|
||||
|
|
@ -91,8 +109,26 @@
|
|||
const double &
|
||||
%{ $result = ($*1_ltype)*$1; %}
|
||||
|
||||
%typemap(goout) const bool &,
|
||||
const char &,
|
||||
const signed char &,
|
||||
const unsigned char &,
|
||||
const short &,
|
||||
const unsigned short &,
|
||||
const int &,
|
||||
const unsigned int &,
|
||||
const long &,
|
||||
const unsigned long &,
|
||||
const long long &,
|
||||
const unsigned long long &,
|
||||
const float &,
|
||||
const double &
|
||||
""
|
||||
|
||||
%typemap(out) void ""
|
||||
|
||||
%typemap(goout) void ""
|
||||
|
||||
%typemap(directorin) bool,
|
||||
char,
|
||||
signed char,
|
||||
|
|
@ -109,6 +145,22 @@
|
|||
double
|
||||
%{ $input = ($1_ltype)$1; %}
|
||||
|
||||
%typemap(godirectorin) bool,
|
||||
char,
|
||||
signed char,
|
||||
unsigned char,
|
||||
short,
|
||||
unsigned short,
|
||||
int,
|
||||
unsigned int,
|
||||
long,
|
||||
unsigned long,
|
||||
long long,
|
||||
unsigned long long,
|
||||
float,
|
||||
double
|
||||
""
|
||||
|
||||
%typemap(directorin) const bool &,
|
||||
const char &,
|
||||
const signed char &,
|
||||
|
|
@ -125,6 +177,22 @@
|
|||
const double &
|
||||
%{ $input = ($*1_ltype)$1; %}
|
||||
|
||||
%typemap(godirectorin) const bool &,
|
||||
const char &,
|
||||
const signed char &,
|
||||
const unsigned char &,
|
||||
const short &,
|
||||
const unsigned short &,
|
||||
const int &,
|
||||
const unsigned int &,
|
||||
const long &,
|
||||
const unsigned long &,
|
||||
const long long &,
|
||||
const unsigned long long &,
|
||||
const float &,
|
||||
const double &
|
||||
""
|
||||
|
||||
%typemap(directorout) bool,
|
||||
char,
|
||||
signed char,
|
||||
|
|
@ -141,7 +209,7 @@
|
|||
double
|
||||
%{ $result = ($1_ltype)$input; %}
|
||||
|
||||
%typemap(directorout) const bool &,
|
||||
%typemap(directorout,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) const bool &,
|
||||
const char &,
|
||||
const signed char &,
|
||||
const unsigned char &,
|
||||
|
|
@ -156,8 +224,8 @@
|
|||
const float &,
|
||||
const double &
|
||||
%{
|
||||
$result = ($1_ltype)_swig_goallocate(sizeof($*1_ltype));
|
||||
*$result = *($1_ltype)&$input;
|
||||
$result = new $*1_ltype($input);
|
||||
swig_acquire_pointer(&swig_mem, $result);
|
||||
%}
|
||||
|
||||
/* The size_t type. */
|
||||
|
|
@ -173,22 +241,30 @@
|
|||
%typemap(out) size_t
|
||||
%{ $result = $1; %}
|
||||
|
||||
%typemap(goout) size_t ""
|
||||
|
||||
%typemap(out) const size_t &
|
||||
%{ $result = ($*1_ltype)*$1; %}
|
||||
|
||||
%typemap(goout) const size_t & ""
|
||||
|
||||
%typemap(directorin) size_t
|
||||
%{ $input = (size_t)$1; %}
|
||||
|
||||
%typemap(godirectorin) size_t ""
|
||||
|
||||
%typemap(directorin) const size_t &
|
||||
%{ $input = ($*1_ltype)$1; %}
|
||||
|
||||
%typemap(godirectorin) const size_t & ""
|
||||
|
||||
%typemap(directorout) size_t
|
||||
%{ $result = ($1_ltype)$input; %}
|
||||
|
||||
%typemap(directorout) const size_t &
|
||||
%typemap(directorout,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) const size_t &
|
||||
%{
|
||||
$result = ($1_ltype)_swig_goallocate(sizeof($*1_ltype));
|
||||
*$result = *($1_ltype)$input;
|
||||
$result = new $*1_ltype($input);
|
||||
swig_acquire_pointer(&swig_mem, $result);
|
||||
%}
|
||||
|
||||
/* Member pointers. */
|
||||
|
|
@ -201,17 +277,45 @@
|
|||
|
||||
%typemap(out) SWIGTYPE (CLASS::*)
|
||||
%{
|
||||
$result = _swig_goallocate(sizeof($1_ltype));
|
||||
*($&1_ltype)$result = $1;
|
||||
struct swig_out_type { intgo size; void* val; } *swig_out;
|
||||
swig_out = (struct swig_out_type*)malloc(sizeof(*swig_out));
|
||||
if (swig_out) {
|
||||
swig_out->size = sizeof($1_ltype);
|
||||
swig_out->val = malloc(swig_out->size);
|
||||
if (swig_out->val) {
|
||||
*($&1_ltype)(swig_out->val) = $1;
|
||||
}
|
||||
}
|
||||
$result = swig_out;
|
||||
%}
|
||||
|
||||
%typemap(goout) SWIGTYPE (CLASS::*)
|
||||
%{
|
||||
{
|
||||
type swig_out_type struct { size int; val uintptr }
|
||||
p := (*swig_out_type)(unsafe.Pointer($1))
|
||||
if p == nil || p.val == 0 {
|
||||
$result = nil
|
||||
} else {
|
||||
m := make([]byte, p.size)
|
||||
a := (*[1024]byte)(unsafe.Pointer(p.val))[:p.size]
|
||||
copy(m, a)
|
||||
Swig_free(p.val)
|
||||
Swig_free(uintptr(unsafe.Pointer(p)))
|
||||
$result = &m[0]
|
||||
}
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(directorin) SWIGTYPE (CLASS::*)
|
||||
%{ $input = *($&1_ltype)$1; %}
|
||||
|
||||
%typemap(godirectorin) SWIGTYPE (CLASS::*) ""
|
||||
|
||||
%typemap(directorout) SWIGTYPE (CLASS::*)
|
||||
%{
|
||||
$result = _swig_goallocate(sizeof($1_ltype));
|
||||
*($&1_ltype)$result = $input;
|
||||
$result = new $1_ltype($input);
|
||||
swig_acquire_pointer(&swig_mem, $result);
|
||||
%}
|
||||
|
||||
/* Pointers. */
|
||||
|
|
@ -227,9 +331,13 @@
|
|||
%typemap(out) SWIGTYPE *
|
||||
%{ *($&1_ltype)&$result = ($1_ltype)$1; %}
|
||||
|
||||
%typemap(goout) SWIGTYPE * ""
|
||||
|
||||
%typemap(directorin) SWIGTYPE *
|
||||
%{ *($&1_ltype)&$input = ($1_ltype)$1; %}
|
||||
|
||||
%typemap(godirectorin) SWIGTYPE * ""
|
||||
|
||||
%typemap(directorout) SWIGTYPE *
|
||||
%{ $result = *($&1_ltype)&$input; %}
|
||||
|
||||
|
|
@ -249,6 +357,8 @@
|
|||
%typemap(out) SWIGTYPE *const&
|
||||
%{ *($1_ltype)&$result = *$1; %}
|
||||
|
||||
%typemap(goout) SWIGTYPE *const& ""
|
||||
|
||||
/* References. */
|
||||
|
||||
/* Converting a C++ reference to Go has to be handled in the C++
|
||||
|
|
@ -262,9 +372,13 @@
|
|||
%typemap(out) SWIGTYPE &
|
||||
%{ *($&1_ltype)&$result = $1; %}
|
||||
|
||||
%typemap(goout) SWIGTYPE & ""
|
||||
|
||||
%typemap(directorin) SWIGTYPE &
|
||||
%{ $input = ($1_ltype)&$1; %}
|
||||
|
||||
%typemap(godirectorin) SWIGTYPE & ""
|
||||
|
||||
%typemap(directorout) SWIGTYPE &
|
||||
%{ *($&1_ltype)&$result = $input; %}
|
||||
|
||||
|
|
@ -277,9 +391,13 @@
|
|||
%typemap(out) SWIGTYPE &&
|
||||
%{ *($&1_ltype)&$result = $1; %}
|
||||
|
||||
%typemap(goout) SWIGTYPE && ""
|
||||
|
||||
%typemap(directorin) SWIGTYPE &&
|
||||
%{ $input = ($1_ltype)&$1_name; %}
|
||||
|
||||
%typemap(godirectorin) SWIGTYPE && ""
|
||||
|
||||
%typemap(directorout) SWIGTYPE &&
|
||||
%{ *($&1_ltype)&$result = $input; %}
|
||||
|
||||
|
|
@ -295,9 +413,13 @@
|
|||
%typemap(out) SWIGTYPE []
|
||||
%{ *($&1_ltype)&$result = $1; %}
|
||||
|
||||
%typemap(goout) SWIGTYPE [] ""
|
||||
|
||||
%typemap(directorin) SWIGTYPE []
|
||||
%{ $input = *($1_ltype)&$1; %}
|
||||
|
||||
%typemap(godirectorin) SWIGTYPE [] ""
|
||||
|
||||
%typemap(directorout) SWIGTYPE []
|
||||
%{ *($&1_ltype)&$result = $input; %}
|
||||
|
||||
|
|
@ -323,18 +445,32 @@
|
|||
%typemap(in) char *&, signed char *&, unsigned char *&
|
||||
%{ $1 = ($1_ltype)$input.p; %}
|
||||
|
||||
%typemap(out)
|
||||
%typemap(out,fragment="AllocateString")
|
||||
char *, char *&, char[ANY], char[],
|
||||
signed char *, signed char *&, signed char[ANY], signed char[],
|
||||
unsigned char *, unsigned char *&, unsigned char[ANY], unsigned char[]
|
||||
%{ $result = _swig_makegostring((char*)$1, $1 ? strlen((char*)$1) : 0); %}
|
||||
%{ $result = Swig_AllocateString((char*)$1, $1 ? strlen((char*)$1) : 0); %}
|
||||
|
||||
%typemap(directorin)
|
||||
%typemap(goout,fragment="CopyString")
|
||||
char *, char *&, char[ANY], char[],
|
||||
signed char *, signed char *&, signed char[ANY], signed char[],
|
||||
unsigned char *, unsigned char *&, unsigned char[ANY], unsigned char[]
|
||||
%{ $result = swigCopyString($1) %}
|
||||
|
||||
%typemap(directorin,fragment="AllocateString")
|
||||
char *, char *&, char[ANY], char[],
|
||||
signed char *, signed char *&, signed char[ANY], signed char[],
|
||||
unsigned char *, unsigned char *&, unsigned char[ANY], unsigned char[]
|
||||
%{
|
||||
$input = _swig_makegostring((char*)$1, $1 ? strlen((char*)$1) : 0);
|
||||
$input = Swig_AllocateString((char*)$1, $1 ? strlen((char*)$1) : 0);
|
||||
%}
|
||||
|
||||
%typemap(godirectorin,fragment="CopyString")
|
||||
char *, char *&, char[ANY], char[],
|
||||
signed char *, signed char *&, signed char[ANY], signed char[],
|
||||
unsigned char *, unsigned char *&, unsigned char[ANY], unsigned char[]
|
||||
%{
|
||||
$result = swigCopyString($input)
|
||||
%}
|
||||
|
||||
%typemap(directorout)
|
||||
|
|
@ -353,11 +489,17 @@
|
|||
$2 = ($2_ltype)$input.n;
|
||||
%}
|
||||
|
||||
%typemap(out) (char *STRING, size_t LENGTH)
|
||||
%{ $result = _swig_makegostring((char*)$1, (size_t)$2); %}
|
||||
%typemap(out,fragment="AllocateString") (char *STRING, size_t LENGTH)
|
||||
%{ $result = Swig_AllocateString((char*)$1, (size_t)$2); %}
|
||||
|
||||
%typemap(directorin) (char *STRING, size_t LENGTH)
|
||||
%{ $input = _swig_makegostring((char*)$1, $2); %}
|
||||
%typemap(goout,fragment="CopyString") (char *STRING, size_t LENGTH)
|
||||
%{ $result = swigCopyString($1) %}
|
||||
|
||||
%typemap(directorin,fragment="AllocateString") (char *STRING, size_t LENGTH)
|
||||
%{ $input = Swig_AllocateString((char*)$1, $2); %}
|
||||
|
||||
%typemap(godirectorin,fragment="CopyString") (char *STRING, size_t LENGTH)
|
||||
%{ $result = swigCopyString($input) %}
|
||||
|
||||
%typemap(directorout) (char *STRING, size_t LENGTH)
|
||||
%{
|
||||
|
|
@ -378,8 +520,12 @@
|
|||
%typemap(out) enum SWIGTYPE
|
||||
%{ $result = (intgo)$1; %}
|
||||
|
||||
%typemap(goout) enum SWIGTYPE ""
|
||||
|
||||
%typemap(directorin) enum SWIGTYPE
|
||||
%{ $input = ($1_ltype)$1; %}
|
||||
%{ $input = (intgo)$1; %}
|
||||
|
||||
%typemap(godirectorin) enum SWIGTYPE ""
|
||||
|
||||
%typemap(directorout) enum SWIGTYPE
|
||||
%{ $result = ($1_ltype)$input; %}
|
||||
|
|
@ -390,6 +536,8 @@
|
|||
$input = &e;
|
||||
%}
|
||||
|
||||
%typemap(godirectorin) enum SWIGTYPE & ""
|
||||
|
||||
%typemap(directorout) enum SWIGTYPE &
|
||||
%{
|
||||
$*1_ltype f = ($*1_ltype)*$input;
|
||||
|
|
@ -423,9 +571,13 @@
|
|||
}
|
||||
#endif
|
||||
|
||||
%typemap(goout) SWIGTYPE ""
|
||||
|
||||
%typemap(directorin) SWIGTYPE
|
||||
%{ $input = ($&1_ltype)&$1; %}
|
||||
|
||||
%typemap(godirectorin) SWIGTYPE ""
|
||||
|
||||
%typemap(directorout) SWIGTYPE
|
||||
%{ $result = *($&1_ltype)$input; %}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,12 @@
|
|||
* Go runtime code for the various generated files.
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
%inline %{
|
||||
static void Swig_free(void* p) {
|
||||
free(p);
|
||||
}
|
||||
%}
|
||||
|
||||
%insert(runtime) %{
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
|
@ -242,3 +248,72 @@ var Swig_escape_val interface{}
|
|||
type _swig_fnptr *byte
|
||||
type _swig_memberptr *byte
|
||||
%}
|
||||
|
||||
/* Handle memory management for directors. */
|
||||
|
||||
%insert(director) %{
|
||||
#include <map>
|
||||
|
||||
namespace {
|
||||
struct GCItem {
|
||||
virtual ~GCItem() {}
|
||||
};
|
||||
|
||||
struct GCItem_var {
|
||||
GCItem_var(GCItem *item = 0) : _item(item) {
|
||||
}
|
||||
|
||||
GCItem_var& operator=(GCItem *item) {
|
||||
GCItem *tmp = _item;
|
||||
_item = item;
|
||||
delete tmp;
|
||||
return *this;
|
||||
}
|
||||
|
||||
~GCItem_var() {
|
||||
delete _item;
|
||||
}
|
||||
|
||||
GCItem* operator->() {
|
||||
return _item;
|
||||
}
|
||||
|
||||
private:
|
||||
GCItem *_item;
|
||||
};
|
||||
|
||||
template <typename Type>
|
||||
struct GCItem_T : GCItem {
|
||||
GCItem_T(Type *ptr) : _ptr(ptr) {
|
||||
}
|
||||
|
||||
virtual ~GCItem_T() {
|
||||
delete _ptr;
|
||||
}
|
||||
|
||||
private:
|
||||
Type *_ptr;
|
||||
};
|
||||
}
|
||||
|
||||
class Swig_memory {
|
||||
public:
|
||||
template <typename Type>
|
||||
void swig_acquire_pointer(Type* vptr) {
|
||||
if (vptr) {
|
||||
swig_owner[vptr] = new GCItem_T<Type>(vptr);
|
||||
}
|
||||
}
|
||||
private:
|
||||
typedef std::map<void *, GCItem_var> swig_ownership_map;
|
||||
swig_ownership_map swig_owner;
|
||||
};
|
||||
|
||||
template <typename Type>
|
||||
static void swig_acquire_pointer(Swig_memory** pmem, Type* ptr) {
|
||||
if (!pmem) {
|
||||
*pmem = new Swig_memory;
|
||||
}
|
||||
(*pmem)->swig_acquire_pointer(ptr);
|
||||
}
|
||||
%}
|
||||
|
|
|
|||
29
Lib/go/gostring.swg
Normal file
29
Lib/go/gostring.swg
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* ------------------------------------------------------------
|
||||
* gostring.swg
|
||||
*
|
||||
* Support for returning strings from C to Go.
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
// C/C++ code to convert a memory buffer into a Go string allocated in
|
||||
// C/C++ memory.
|
||||
%fragment("AllocateString", "runtime") %{
|
||||
static _gostring_ Swig_AllocateString(const char *p, size_t l) {
|
||||
_gostring_ ret;
|
||||
ret.p = (char*)malloc(l);
|
||||
memcpy(ret.p, p, l);
|
||||
ret.n = l;
|
||||
return ret;
|
||||
}
|
||||
%}
|
||||
|
||||
// Go code to convert a string allocated in C++ memory to one
|
||||
// allocated in Go memory.
|
||||
%fragment("CopyString", "go_runtime") %{
|
||||
type swig_gostring struct { p uintptr; n int }
|
||||
func swigCopyString(s string) string {
|
||||
p := *(*swig_gostring)(unsafe.Pointer(&s))
|
||||
r := string((*[0x7fffffff]byte)(unsafe.Pointer(p.p))[:p.n])
|
||||
Swig_free(p.p)
|
||||
return r
|
||||
}
|
||||
%}
|
||||
|
|
@ -27,11 +27,17 @@ class string;
|
|||
%typemap(directorout) string
|
||||
%{ $result.assign($input.p, $input.n); %}
|
||||
|
||||
%typemap(out) string
|
||||
%{ $result = _swig_makegostring($1.data(), $1.length()); %}
|
||||
%typemap(out,fragment="AllocateString") string
|
||||
%{ $result = Swig_AllocateString($1.data(), $1.length()); %}
|
||||
|
||||
%typemap(directorin) string
|
||||
%{ $input = _swig_makegostring($1.data(), $1.length()); %}
|
||||
%typemap(goout,fragment="CopyString") string
|
||||
%{ $result = swigCopyString($1) %}
|
||||
|
||||
%typemap(directorin,fragment="AllocateString") string
|
||||
%{ $input = Swig_AllocateString($1.data(), $1.length()); %}
|
||||
|
||||
%typemap(godirectorin,fragment="CopyString") string
|
||||
%{ $result = swigCopyString($input) %}
|
||||
|
||||
%typemap(in) const string &
|
||||
%{
|
||||
|
|
@ -46,10 +52,16 @@ class string;
|
|||
$result = &$1_str;
|
||||
%}
|
||||
|
||||
%typemap(out) const string &
|
||||
%{ $result = _swig_makegostring((*$1).data(), (*$1).length()); %}
|
||||
%typemap(out,fragment="AllocateString") const string &
|
||||
%{ $result = Swig_AllocateString((*$1).data(), (*$1).length()); %}
|
||||
|
||||
%typemap(directorin) const string &
|
||||
%{ $input = _swig_makegostring($1.data(), $1.length()); %}
|
||||
%typemap(goout,fragment="CopyString") const string &
|
||||
%{ $result = swigCopyString($1) %}
|
||||
|
||||
%typemap(directorin,fragment="AllocateString") const string &
|
||||
%{ $input = Swig_AllocateString($1.data(), $1.length()); %}
|
||||
|
||||
%typemap(godirectorin,fragment="CopyString") const string &
|
||||
%{ $result = swigCopyString($input) %}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,6 +67,8 @@ char * typemaps instead:
|
|||
|
||||
%typemap(out) TYPE *INPUT, TYPE &INPUT ""
|
||||
|
||||
%typemap(goout) TYPE *INPUT, TYPE &INPUT ""
|
||||
|
||||
%typemap(freearg) TYPE *INPUT, TYPE &INPUT ""
|
||||
|
||||
%typemap(argout) TYPE *INPUT, TYPE &INPUT ""
|
||||
|
|
@ -167,6 +169,8 @@ char * typemaps instead:
|
|||
|
||||
%typemap(out) TYPE *OUTPUT, TYPE &OUTPUT ""
|
||||
|
||||
%typemap(goout) TYPE *INPUT, TYPE &INPUT ""
|
||||
|
||||
%typemap(freearg) TYPE *OUTPUT, TYPE &OUTPUT ""
|
||||
|
||||
%typemap(argout) TYPE *OUTPUT, TYPE &OUTPUT
|
||||
|
|
@ -268,6 +272,8 @@ char * typemaps instead:
|
|||
|
||||
%typemap(out) TYPE *INOUT, TYPE &INOUT ""
|
||||
|
||||
%typemap(goout) TYPE *INOUT, TYPE &INOUT ""
|
||||
|
||||
%typemap(freearg) TYPE *INOUT, TYPE &INOUT ""
|
||||
|
||||
%typemap(argout) TYPE *INOUT, TYPE &INOUT ""
|
||||
|
|
|
|||
|
|
@ -1181,7 +1181,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
|
|||
%typemap(javabody) TYPE *, TYPE &, TYPE &&, TYPE [] %{
|
||||
private long swigCPtr;
|
||||
|
||||
PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean futureUse) {
|
||||
PTRCTOR_VISIBILITY $javaclassname(long cPtr, @SuppressWarnings("unused") boolean futureUse) {
|
||||
swigCPtr = cPtr;
|
||||
}
|
||||
|
||||
|
|
@ -1197,7 +1197,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
|
|||
%typemap(javabody) TYPE (CLASS::*) %{
|
||||
private String swigCMemberPtr;
|
||||
|
||||
PTRCTOR_VISIBILITY $javaclassname(String cMemberPtr, boolean futureUse) {
|
||||
PTRCTOR_VISIBILITY $javaclassname(String cMemberPtr, @SuppressWarnings("unused") boolean futureUse) {
|
||||
swigCMemberPtr = cMemberPtr;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -402,6 +402,7 @@ static JSStaticFunction $jsnspace_functions[] = {
|
|||
};
|
||||
|
||||
static JSClassDefinition $jsnspace_classDefinition;
|
||||
static JSObjectRef $jsmangledname_object;
|
||||
%}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -412,7 +413,7 @@ static JSClassDefinition $jsnspace_classDefinition;
|
|||
%{
|
||||
$jsmangledname_classDefinition.staticFunctions = $jsmangledname_functions;
|
||||
$jsmangledname_classDefinition.staticValues = $jsmangledname_values;
|
||||
JSObjectRef $jsmangledname_object = JSObjectMake(context, JSClassCreate(&$jsmangledname_classDefinition), NULL);
|
||||
$jsmangledname_object = JSObjectMake(context, JSClassCreate(&$jsmangledname_classDefinition), NULL);
|
||||
%}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -76,11 +76,12 @@ SWIG_From_dec(unsigned long)(unsigned long value)
|
|||
SWIGINTERN int
|
||||
SWIG_AsVal_dec(unsigned long)(JSValueRef obj, unsigned long *val)
|
||||
{
|
||||
long longVal;
|
||||
if(!JSValueIsNumber(context, obj)) {
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
|
||||
long longVal = (long) JSValueToNumber(context, obj, NULL);
|
||||
longVal = (long) JSValueToNumber(context, obj, NULL);
|
||||
|
||||
if(longVal < 0) {
|
||||
return SWIG_OverflowError;
|
||||
|
|
@ -142,11 +143,12 @@ SWIG_From_dec(unsigned long long)(unsigned long long value)
|
|||
SWIGINTERN int
|
||||
SWIG_AsVal_dec(unsigned long long)(JSValueRef obj, unsigned long long *val)
|
||||
{
|
||||
long long longVal;
|
||||
if(!JSValueIsNumber(context, obj)) {
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
|
||||
long long longVal = (unsigned long long) JSValueToNumber(context, obj, NULL);
|
||||
longVal = (unsigned long long) JSValueToNumber(context, obj, NULL);
|
||||
|
||||
if(longVal < 0) {
|
||||
return SWIG_OverflowError;
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ SWIG_JSC_FromCharPtrAndSize(JSContextRef context, const char* carray, size_t siz
|
|||
return JSValueMakeUndefined(context);
|
||||
} else {
|
||||
JSStringRef jsstring;
|
||||
JSValueRef result;
|
||||
if(size < 2) {
|
||||
char c[2];
|
||||
int i;
|
||||
|
|
@ -63,7 +64,7 @@ SWIG_JSC_FromCharPtrAndSize(JSContextRef context, const char* carray, size_t siz
|
|||
} else {
|
||||
jsstring = JSStringCreateWithUTF8CString(carray);
|
||||
}
|
||||
JSValueRef result = JSValueMakeString(context, jsstring);
|
||||
result = JSValueMakeString(context, jsstring);
|
||||
JSStringRelease(jsstring);
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,9 @@
|
|||
%typemap(consttab) SWIGTYPE *, SWIGTYPE *const, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE []
|
||||
{ SWIG_LUA_CONSTTAB_POINTER("$symname",$value, $1_descriptor) }
|
||||
|
||||
%typemap(consttab) SWIGTYPE
|
||||
{ SWIG_LUA_CONSTTAB_POINTER("$symname",&$value, $&1_descriptor) }
|
||||
|
||||
// member function pointers
|
||||
%typemap(consttab) SWIGTYPE (CLASS::*)
|
||||
{ SWIG_LUA_CONSTTAB_BINARY("$symname", sizeof($type),&$value, $1_descriptor) }
|
||||
|
|
|
|||
|
|
@ -1161,7 +1161,7 @@ SWIGINTERN void SWIG_Lua_init_base_class(lua_State *L,swig_lua_class *clss)
|
|||
|
||||
#if defined(SWIG_LUA_SQUASH_BASES) && (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA)
|
||||
/* Merges two tables */
|
||||
SWIGINTERN int SWIG_Lua_merge_tables_by_index(lua_State *L, int target, int source)
|
||||
SWIGINTERN void SWIG_Lua_merge_tables_by_index(lua_State *L, int target, int source)
|
||||
{
|
||||
/* iterating */
|
||||
lua_pushnil(L);
|
||||
|
|
@ -1177,7 +1177,7 @@ SWIGINTERN int SWIG_Lua_merge_tables_by_index(lua_State *L, int target, int sour
|
|||
}
|
||||
|
||||
/* Merges two tables with given name. original - index of target metatable, base - index of source metatable */
|
||||
SWIGINTERN int SWIG_Lua_merge_tables(lua_State *L, const char* name, int original, int base)
|
||||
SWIGINTERN void SWIG_Lua_merge_tables(lua_State *L, const char* name, int original, int base)
|
||||
{
|
||||
/* push original[name], then base[name] */
|
||||
lua_pushstring(L,name);
|
||||
|
|
@ -1192,7 +1192,7 @@ SWIGINTERN int SWIG_Lua_merge_tables(lua_State *L, const char* name, int origina
|
|||
}
|
||||
|
||||
/* Function takes all symbols from base and adds it to derived class. It's just a helper. */
|
||||
SWIGINTERN int SWIG_Lua_class_squash_base(lua_State *L, swig_lua_class *base_cls)
|
||||
SWIGINTERN void SWIG_Lua_class_squash_base(lua_State *L, swig_lua_class *base_cls)
|
||||
{
|
||||
/* There is one parameter - original, i.e. 'derived' class metatable */
|
||||
assert(lua_istable(L,-1));
|
||||
|
|
@ -1206,7 +1206,7 @@ SWIGINTERN int SWIG_Lua_class_squash_base(lua_State *L, swig_lua_class *base_cls
|
|||
}
|
||||
|
||||
/* Function squashes all symbols from 'clss' bases into itself */
|
||||
SWIGINTERN int SWIG_Lua_class_squash_bases(lua_State *L, swig_lua_class *clss)
|
||||
SWIGINTERN void SWIG_Lua_class_squash_bases(lua_State *L, swig_lua_class *clss)
|
||||
{
|
||||
int i;
|
||||
SWIG_Lua_get_class_metatable(L,clss->fqname);
|
||||
|
|
|
|||
|
|
@ -29,7 +29,8 @@
|
|||
}
|
||||
}
|
||||
%typemap(out) CONST TYPE {
|
||||
%set_output(SWIG_NewPointerObj(new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1));
|
||||
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
%typemap(varin) CONST TYPE {
|
||||
|
|
@ -47,7 +48,8 @@
|
|||
}
|
||||
}
|
||||
%typemap(varout) CONST TYPE {
|
||||
%set_varoutput(SWIG_NewPointerObj(new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1));
|
||||
%set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
// plain pointer
|
||||
|
|
|
|||
|
|
@ -578,26 +578,40 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
|
|||
swig_member_const_iterator swig_members_begin() { return members.begin(); }
|
||||
swig_member_const_iterator swig_members_end() { return members.end(); }
|
||||
|
||||
void *cast(swig_type_info *type, int *_own, int flags) {
|
||||
int cast(void **vptr, swig_type_info *type, int *_own, int flags) {
|
||||
int res = SWIG_ERROR;
|
||||
if (_own)
|
||||
*_own = own;
|
||||
if (flags &SWIG_POINTER_DISOWN)
|
||||
own = 0;
|
||||
if (!type && types.size())
|
||||
return types[0].second.ptr;
|
||||
if (!type && types.size()) {
|
||||
if(vptr)
|
||||
*vptr = types[0].second.ptr;
|
||||
return SWIG_OK;
|
||||
}
|
||||
for (unsigned int j = 0; j < types.size(); ++j)
|
||||
if (type == types[j].first)
|
||||
return types[j].second.ptr;
|
||||
if (type == types[j].first) {
|
||||
if(vptr)
|
||||
*vptr = types[j].second.ptr;
|
||||
return SWIG_OK;
|
||||
}
|
||||
for (unsigned int j = 0; j < types.size(); ++j) {
|
||||
swig_cast_info *tc = SWIG_TypeCheck(types[j].first->name, type);
|
||||
if (!tc)
|
||||
continue;
|
||||
int newmemory = 0;
|
||||
void *vptr = SWIG_TypeCast(tc, types[j].second.ptr, &newmemory);
|
||||
assert(!newmemory); // newmemory handling not yet implemented
|
||||
return vptr;
|
||||
if(vptr) {
|
||||
int newmemory = 0;
|
||||
*vptr = SWIG_TypeCast(tc, types[j].second.ptr, &newmemory);
|
||||
if (newmemory == SWIG_CAST_NEW_MEMORY) {
|
||||
assert(_own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */
|
||||
if (_own)
|
||||
*_own = *_own | SWIG_CAST_NEW_MEMORY;
|
||||
}
|
||||
}
|
||||
res = SWIG_OK;
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
return res;
|
||||
}
|
||||
|
||||
bool is_owned() const {
|
||||
|
|
@ -1327,12 +1341,7 @@ SWIGRUNTIME int SWIG_Octave_ConvertPtrAndOwn(octave_value ov, void **ptr, swig_t
|
|||
return SWIG_ERROR;
|
||||
octave_swig_ref *osr = static_cast < octave_swig_ref *>(ov.internal_rep());
|
||||
octave_swig_type *ost = osr->get_ptr();
|
||||
void *vptr = ost->cast(type, own, flags);
|
||||
if (!vptr)
|
||||
return SWIG_ERROR;
|
||||
if (ptr)
|
||||
*ptr = vptr;
|
||||
return SWIG_OK;
|
||||
return ost->cast(ptr, type, own, flags);
|
||||
}
|
||||
|
||||
SWIGRUNTIME octave_value SWIG_Octave_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) {
|
||||
|
|
|
|||
2
Lib/octave/std_shared_ptr.i
Normal file
2
Lib/octave/std_shared_ptr.i
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#define SWIG_SHARED_PTR_NAMESPACE std
|
||||
%include <boost_shared_ptr.i>
|
||||
|
|
@ -21,7 +21,7 @@ SWIGEXPORT void SWIG_init (CV *cv, CPerlObj *);
|
|||
|
||||
%init %{
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if defined(__cplusplus) && ! defined(XSPROTO)
|
||||
extern "C"
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -101,8 +101,7 @@ namespace Swig {
|
|||
TSRMLS_SET_CTX(swig_zts_ctx);
|
||||
}
|
||||
|
||||
bool swig_is_overridden_method(char *cname, char *lc_fname) {
|
||||
TSRMLS_FETCH_FROM_CTX(swig_zts_ctx);
|
||||
static bool swig_is_overridden_method(char *cname, char *lc_fname TSRMLS_DC) {
|
||||
zend_class_entry **ce;
|
||||
zend_function *mptr;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
|
||||
%echo "pointer.i is deprecated. Use cpointer.i instead."
|
||||
%echo "See http://www.swig.org/Doc1.3/Library.html"
|
||||
%echo "See http://www.swig.org/Doc3.0/Library.html"
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -375,6 +375,7 @@ SWIG_init(void) {
|
|||
PyObject *public_interface, *public_symbol;
|
||||
PyObject *this_descr;
|
||||
PyObject *thisown_descr;
|
||||
PyObject *self = 0;
|
||||
int i;
|
||||
|
||||
(void)builtin_pytype;
|
||||
|
|
@ -382,6 +383,7 @@ SWIG_init(void) {
|
|||
(void)builtin_basetype;
|
||||
(void)tuple;
|
||||
(void)static_getset;
|
||||
(void)self;
|
||||
|
||||
/* metatype is used to implement static member variables. */
|
||||
metatype_args = Py_BuildValue("(s(O){})", "SwigPyObjectType", &PyType_Type);
|
||||
|
|
@ -401,6 +403,7 @@ SWIG_init(void) {
|
|||
#else
|
||||
m = Py_InitModule((char *) SWIG_name, SwigMethods);
|
||||
#endif
|
||||
|
||||
md = d = PyModule_GetDict(m);
|
||||
(void)md;
|
||||
|
||||
|
|
|
|||
|
|
@ -185,7 +185,6 @@ These methods "may be called" if needed.
|
|||
#define %clearpythonappend %feature("pythonappend","")
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/*
|
||||
%extend_smart_pointer extend the smart pointer support.
|
||||
|
|
|
|||
318
Lib/scilab/boost_shared_ptr.i
Normal file
318
Lib/scilab/boost_shared_ptr.i
Normal file
|
|
@ -0,0 +1,318 @@
|
|||
%include <shared_ptr.i>
|
||||
|
||||
// Set SHARED_PTR_DISOWN to $disown if required, for example
|
||||
// #define SHARED_PTR_DISOWN $disown
|
||||
#if !defined(SHARED_PTR_DISOWN)
|
||||
#define SHARED_PTR_DISOWN 0
|
||||
#endif
|
||||
|
||||
// Language specific macro implementing all the customisations for handling the smart pointer
|
||||
%define SWIG_SHARED_PTR_TYPEMAPS(CONST, TYPE...)
|
||||
|
||||
// %naturalvar is as documented for member variables
|
||||
%naturalvar TYPE;
|
||||
%naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
|
||||
|
||||
// destructor wrapper customisation
|
||||
%feature("unref") TYPE
|
||||
//"if (debug_shared) { cout << \"deleting use_count: \" << (*smartarg1).use_count() << \" [\" << (boost::get_deleter<SWIG_null_deleter>(*smartarg1) ? std::string(\"CANNOT BE DETERMINED SAFELY\") : ( (*smartarg1).get() ? (*smartarg1)->getValue() : std::string(\"NULL PTR\") )) << \"]\" << endl << flush; }\n"
|
||||
"(void)arg1; delete smartarg1;"
|
||||
|
||||
// Typemap customisations...
|
||||
|
||||
// plain value
|
||||
%typemap(in) CONST TYPE (void *argp, int res = 0) {
|
||||
int newmem = 0;
|
||||
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
%argument_fail(res, "$type", $symname, $argnum);
|
||||
}
|
||||
if (!argp) {
|
||||
%argument_nullref("$type", $symname, $argnum);
|
||||
} else {
|
||||
$1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get());
|
||||
if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
}
|
||||
}
|
||||
%typemap(out) CONST TYPE {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1));
|
||||
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
%typemap(varin) CONST TYPE {
|
||||
void *argp = 0;
|
||||
int newmem = 0;
|
||||
int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
%variable_fail(res, "$type", "$name");
|
||||
}
|
||||
if (!argp) {
|
||||
%argument_nullref("$type", $symname, $argnum);
|
||||
} else {
|
||||
$1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get());
|
||||
if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
}
|
||||
}
|
||||
%typemap(varout) CONST TYPE {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1));
|
||||
%set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
// plain pointer
|
||||
// Note: $disown not implemented by default as it will lead to a memory leak of the shared_ptr instance
|
||||
%typemap(in) CONST TYPE * (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) {
|
||||
int newmem = 0;
|
||||
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
%argument_fail(res, "$type", $symname, $argnum);
|
||||
}
|
||||
if (newmem & SWIG_CAST_NEW_MEMORY) {
|
||||
tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
$1 = %const_cast(tempshared.get(), $1_ltype);
|
||||
} else {
|
||||
smartarg = %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
$1 = %const_cast((smartarg ? smartarg->get() : 0), $1_ltype);
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(out, fragment="SWIG_null_deleter_python") CONST TYPE * {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0;
|
||||
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), $owner | SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
%typemap(varin) CONST TYPE * {
|
||||
void *argp = 0;
|
||||
int newmem = 0;
|
||||
int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
%variable_fail(res, "$type", "$name");
|
||||
}
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared;
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0;
|
||||
if (newmem & SWIG_CAST_NEW_MEMORY) {
|
||||
tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
$1 = %const_cast(tempshared.get(), $1_ltype);
|
||||
} else {
|
||||
smartarg = %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
$1 = %const_cast((smartarg ? smartarg->get() : 0), $1_ltype);
|
||||
}
|
||||
}
|
||||
%typemap(varout, fragment="SWIG_null_deleter_python") CONST TYPE * {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0;
|
||||
%set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
// plain reference
|
||||
%typemap(in) CONST TYPE & (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) {
|
||||
int newmem = 0;
|
||||
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
%argument_fail(res, "$type", $symname, $argnum);
|
||||
}
|
||||
if (!argp) { %argument_nullref("$type", $symname, $argnum); }
|
||||
if (newmem & SWIG_CAST_NEW_MEMORY) {
|
||||
tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
$1 = %const_cast(tempshared.get(), $1_ltype);
|
||||
} else {
|
||||
$1 = %const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $1_ltype);
|
||||
}
|
||||
}
|
||||
%typemap(out, fragment="SWIG_null_deleter_python") CONST TYPE & {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner);
|
||||
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
%typemap(varin) CONST TYPE & {
|
||||
void *argp = 0;
|
||||
int newmem = 0;
|
||||
int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
%variable_fail(res, "$type", "$name");
|
||||
}
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared;
|
||||
if (!argp) { %argument_nullref("$type", $symname, $argnum); }
|
||||
if (newmem & SWIG_CAST_NEW_MEMORY) {
|
||||
tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
$1 = *%const_cast(tempshared.get(), $1_ltype);
|
||||
} else {
|
||||
$1 = *%const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $1_ltype);
|
||||
}
|
||||
}
|
||||
%typemap(varout, fragment="SWIG_null_deleter_python") CONST TYPE & {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(&$1 SWIG_NO_NULL_DELETER_0);
|
||||
%set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
// plain pointer by reference
|
||||
// Note: $disown not implemented by default as it will lead to a memory leak of the shared_ptr instance
|
||||
%typemap(in) TYPE *CONST& (void *argp = 0, int res = 0, $*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) {
|
||||
int newmem = 0;
|
||||
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
%argument_fail(res, "$type", $symname, $argnum);
|
||||
}
|
||||
if (newmem & SWIG_CAST_NEW_MEMORY) {
|
||||
tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
temp = %const_cast(tempshared.get(), $*1_ltype);
|
||||
} else {
|
||||
temp = %const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $*1_ltype);
|
||||
}
|
||||
$1 = &temp;
|
||||
}
|
||||
%typemap(out, fragment="SWIG_null_deleter_python") TYPE *CONST& {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner);
|
||||
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
%typemap(varin) TYPE *CONST& %{
|
||||
#error "varin typemap not implemented"
|
||||
%}
|
||||
%typemap(varout) TYPE *CONST& %{
|
||||
#error "varout typemap not implemented"
|
||||
%}
|
||||
|
||||
// shared_ptr by value
|
||||
%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > (void *argp, int res = 0) {
|
||||
int newmem = 0;
|
||||
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
%argument_fail(res, "$type", $symname, $argnum);
|
||||
}
|
||||
if (argp) $1 = *(%reinterpret_cast(argp, $<ype));
|
||||
if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $<ype);
|
||||
}
|
||||
%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0;
|
||||
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
|
||||
int newmem = 0;
|
||||
void *argp = 0;
|
||||
int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
%variable_fail(res, "$type", "$name");
|
||||
}
|
||||
$1 = argp ? *(%reinterpret_cast(argp, $<ype)) : SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE >();
|
||||
if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $<ype);
|
||||
}
|
||||
%typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0;
|
||||
%set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
// shared_ptr by reference
|
||||
%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & (void *argp, int res = 0, $*1_ltype tempshared) {
|
||||
int newmem = 0;
|
||||
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
%argument_fail(res, "$type", $symname, $argnum);
|
||||
}
|
||||
if (newmem & SWIG_CAST_NEW_MEMORY) {
|
||||
if (argp) tempshared = *%reinterpret_cast(argp, $ltype);
|
||||
delete %reinterpret_cast(argp, $ltype);
|
||||
$1 = &tempshared;
|
||||
} else {
|
||||
$1 = (argp) ? %reinterpret_cast(argp, $ltype) : &tempshared;
|
||||
}
|
||||
}
|
||||
%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = *$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0;
|
||||
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{
|
||||
#error "varin typemap not implemented"
|
||||
%}
|
||||
%typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{
|
||||
#error "varout typemap not implemented"
|
||||
%}
|
||||
|
||||
// shared_ptr by pointer
|
||||
%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * (void *argp, int res = 0, $*1_ltype tempshared) {
|
||||
int newmem = 0;
|
||||
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
%argument_fail(res, "$type", $symname, $argnum);
|
||||
}
|
||||
if (newmem & SWIG_CAST_NEW_MEMORY) {
|
||||
if (argp) tempshared = *%reinterpret_cast(argp, $ltype);
|
||||
delete %reinterpret_cast(argp, $ltype);
|
||||
$1 = &tempshared;
|
||||
} else {
|
||||
$1 = (argp) ? %reinterpret_cast(argp, $ltype) : &tempshared;
|
||||
}
|
||||
}
|
||||
%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 && *$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0;
|
||||
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
if ($owner) delete $1;
|
||||
}
|
||||
|
||||
%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{
|
||||
#error "varin typemap not implemented"
|
||||
%}
|
||||
%typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{
|
||||
#error "varout typemap not implemented"
|
||||
%}
|
||||
|
||||
// shared_ptr by pointer reference
|
||||
%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& (void *argp, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, $*1_ltype temp = 0) {
|
||||
int newmem = 0;
|
||||
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
%argument_fail(res, "$type", $symname, $argnum);
|
||||
}
|
||||
if (argp) tempshared = *%reinterpret_cast(argp, $*ltype);
|
||||
if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $*ltype);
|
||||
temp = &tempshared;
|
||||
$1 = &temp;
|
||||
}
|
||||
%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = *$1 && **$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(**$1) : 0;
|
||||
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{
|
||||
#error "varin typemap not implemented"
|
||||
%}
|
||||
%typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{
|
||||
#error "varout typemap not implemented"
|
||||
%}
|
||||
|
||||
// Typecheck typemaps
|
||||
// Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting
|
||||
// function is not called thereby avoiding a possible smart pointer copy constructor call when casting up the inheritance chain.
|
||||
%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1)
|
||||
TYPE CONST,
|
||||
TYPE CONST &,
|
||||
TYPE CONST *,
|
||||
TYPE *CONST&,
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &,
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *,
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& {
|
||||
int res = SWIG_ConvertPtr($input, 0, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), 0);
|
||||
$1 = SWIG_CheckState(res);
|
||||
}
|
||||
|
||||
|
||||
// various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug
|
||||
%typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
|
||||
#error "typemaps for $1_type not available"
|
||||
%}
|
||||
%typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
|
||||
#error "typemaps for $1_type not available"
|
||||
%}
|
||||
|
||||
|
||||
%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
|
||||
|
||||
|
||||
%enddef
|
||||
|
||||
5
Lib/scilab/carrays.i
Normal file
5
Lib/scilab/carrays.i
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
%define %array_class(TYPE,NAME)
|
||||
%array_class_wrap(TYPE,NAME,__paren__,__paren_asgn__)
|
||||
%enddef
|
||||
|
||||
%include <typemaps/carrays.swg>
|
||||
1
Lib/scilab/cmalloc.i
Normal file
1
Lib/scilab/cmalloc.i
Normal file
|
|
@ -0,0 +1 @@
|
|||
%include <typemaps/cmalloc.swg>
|
||||
1
Lib/scilab/cpointer.i
Normal file
1
Lib/scilab/cpointer.i
Normal file
|
|
@ -0,0 +1 @@
|
|||
%include <typemaps/cpointer.swg>
|
||||
6
Lib/scilab/exception.i
Normal file
6
Lib/scilab/exception.i
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
%include <typemaps/exception.swg>
|
||||
|
||||
|
||||
%insert("runtime") {
|
||||
%define_as(SWIG_exception(code, msg), SWIG_Scilab_Error(code, msg);)
|
||||
}
|
||||
11
Lib/scilab/matrix.i
Normal file
11
Lib/scilab/matrix.i
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* Matrix typemaps
|
||||
*
|
||||
*/
|
||||
|
||||
%include <scimatrixdouble.swg>
|
||||
%include <scimatrixint.swg>
|
||||
%include <scimatrixchar.swg>
|
||||
%include <scimatrixbool.swg>
|
||||
|
||||
|
||||
115
Lib/scilab/sciarray.swg
Normal file
115
Lib/scilab/sciarray.swg
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
/* --------------------------------------------------------------------------
|
||||
*
|
||||
* Arrays typemaps
|
||||
*
|
||||
* --------------------------------------------------------------------------*/
|
||||
|
||||
%{
|
||||
#include <stdio.h>
|
||||
%}
|
||||
|
||||
%define %scilab_asarray_withallocatecopy(TYPEMAPTYPE, FRAGMENTNAME, CTYPE, TEMPDATATYPE)
|
||||
%typemap(TYPEMAPTYPE, fragment="FRAGMENTNAME") CTYPE {
|
||||
size_t i = 0;
|
||||
int iRows = 0;
|
||||
int iCols = 0;
|
||||
TEMPDATATYPE *pTempData = NULL;
|
||||
if (FRAGMENTNAME(pvApiCtx, $input, &iRows, &iCols, &pTempData, fname)) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
$1 = ($1_ltype)MALLOC(sizeof($*1_ltype) * iRows * iCols);
|
||||
for (i = 0; i < iRows * iCols; i++) {
|
||||
$1[i] = ($*1_ltype) pTempData[i];
|
||||
}
|
||||
}
|
||||
%enddef
|
||||
|
||||
%define %scilab_asarrayandsize_withcopy(TYPEMAPTYPE, FRAGMENTNAME, CTYPE, TEMPDATATYPE)
|
||||
%typemap(TYPEMAPTYPE, fragment="FRAGMENTNAME") CTYPE {
|
||||
int iRows = 0;
|
||||
int iCols = 0;
|
||||
TEMPDATATYPE *pTempData = NULL;
|
||||
if (FRAGMENTNAME(pvApiCtx, $input, &iRows, &iCols, &pTempData, fname)) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iRows*iCols <= $1_dim0) {
|
||||
size_t i;
|
||||
for (i = 0; i < $1_dim0; i++) {
|
||||
$1[i] = ($*1_ltype) pTempData[i];
|
||||
}
|
||||
}
|
||||
else {
|
||||
char errmsg[100];
|
||||
sprintf(errmsg, "Size of input data (%d) is too big (maximum is %d)",
|
||||
iRows*iCols, $1_dim0);
|
||||
SWIG_exception_fail(SWIG_OverflowError, errmsg);
|
||||
}
|
||||
}
|
||||
%enddef
|
||||
|
||||
%define %scilab_fromarrayandsize(TYPEMAPTYPE, FRAGMENTNAME, CTYPE)
|
||||
%typemap(TYPEMAPTYPE, noblock=1, fragment="FRAGMENTNAME") CTYPE {
|
||||
%set_output(FRAGMENTNAME(pvApiCtx, $result, 1, $1_dim0, $1));
|
||||
}
|
||||
%enddef
|
||||
|
||||
%define %scilab_array_typemaps(CTYPE, ASARRAY_FRAGMENT, FROMARRAY_FRAGMENT, TEMPDATATYPE)
|
||||
%scilab_asarrayandsize_withcopy(varin, ASARRAY_FRAGMENT, CTYPE[ANY], TEMPDATATYPE);
|
||||
%scilab_asarray_withallocatecopy(in, ASARRAY_FRAGMENT, CTYPE[ANY], TEMPDATATYPE);
|
||||
%scilab_fromarrayandsize(varout, FROMARRAY_FRAGMENT, CTYPE[ANY]);
|
||||
%scilab_fromarrayandsize(out, FROMARRAY_FRAGMENT, CTYPE[ANY]);
|
||||
|
||||
%apply SWIGTYPE[] { CTYPE[] };
|
||||
%scilab_asarray_withallocatecopy(in, ASARRAY_FRAGMENT, CTYPE[], TEMPDATATYPE);
|
||||
%enddef
|
||||
|
||||
|
||||
// Double
|
||||
%scilab_array_typemaps(double, SWIG_SciDouble_AsDoubleArrayAndSize,
|
||||
SWIG_SciDouble_FromDoubleArrayAndSize, double);
|
||||
|
||||
// Signed char
|
||||
|
||||
%scilab_array_typemaps(signed char, SWIG_SciDoubleOrInt8_AsSignedCharArrayAndSize,
|
||||
SWIG_SciDouble_FromSignedCharArrayAndSize, signed char);
|
||||
|
||||
// Unsigned char
|
||||
%scilab_array_typemaps(unsigned char, SWIG_SciDoubleOrUint8_AsUnsignedCharArrayAndSize,
|
||||
SWIG_SciDouble_FromUnsignedCharArrayAndSize, unsigned char);
|
||||
|
||||
// Short
|
||||
%scilab_array_typemaps(short, SWIG_SciDoubleOrInt16_AsShortArrayAndSize,
|
||||
SWIG_SciDouble_FromShortArrayAndSize, short);
|
||||
|
||||
// Unsigned short
|
||||
%scilab_array_typemaps(unsigned short, SWIG_SciDoubleOrUint16_AsUnsignedShortArrayAndSize,
|
||||
SWIG_SciDouble_FromUnsignedShortArrayAndSize, unsigned short);
|
||||
|
||||
// Int
|
||||
%scilab_array_typemaps(int, SWIG_SciDoubleOrInt32_AsIntArrayAndSize,
|
||||
SWIG_SciDouble_FromIntArrayAndSize, int);
|
||||
|
||||
// Unsigned int
|
||||
%scilab_array_typemaps(unsigned int, SWIG_SciDoubleOrUint32_AsUnsignedIntArrayAndSize,
|
||||
SWIG_SciDouble_FromUnsignedIntArrayAndSize, unsigned int);
|
||||
|
||||
// Long
|
||||
%scilab_array_typemaps(long, SWIG_SciDoubleOrInt32_AsIntArrayAndSize,
|
||||
SWIG_SciDouble_FromLongArrayAndSize, int);
|
||||
|
||||
// Unsigned long
|
||||
%scilab_array_typemaps(unsigned long, SWIG_SciDoubleOrUint32_AsUnsignedIntArrayAndSize,
|
||||
SWIG_SciDouble_FromUnsignedLongArrayAndSize, unsigned int);
|
||||
|
||||
// Float
|
||||
%scilab_array_typemaps(float, SWIG_SciDouble_AsFloatArrayAndSize,
|
||||
SWIG_SciDouble_FromFloatArrayAndSize, float);
|
||||
|
||||
// Bool
|
||||
%scilab_array_typemaps(bool, SWIG_SciBoolean_AsIntArrayAndSize,
|
||||
SWIG_SciBoolean_FromBoolArrayAndSize, int);
|
||||
|
||||
// Char *
|
||||
%scilab_array_typemaps(char *, SWIG_SciString_AsCharPtrArrayAndSize,
|
||||
SWIG_SciString_FromCharPtrArrayAndSize, char *);
|
||||
|
||||
157
Lib/scilab/scibool.swg
Normal file
157
Lib/scilab/scibool.swg
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
/*
|
||||
* C-type: bool
|
||||
* Scilab type: boolean scalar
|
||||
*/
|
||||
%fragment(SWIG_AsVal_frag(bool), "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_AsVal_dec(bool)(SwigSciObject iVar, bool *pbValue) {
|
||||
SciErr sciErr;
|
||||
int iRet = 0;
|
||||
int *piAddrVar = NULL;
|
||||
int iTempValue = 0;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (!isBooleanType(pvApiCtx, piAddrVar)) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A boolean expected.\n"), SWIG_Scilab_GetFuncName(), iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (!isScalar(pvApiCtx, piAddrVar)) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A boolean expected.\n"), SWIG_Scilab_GetFuncName(), iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
iRet = getScalarBoolean(pvApiCtx, piAddrVar, &iTempValue);
|
||||
if (iRet) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
*pbValue = iTempValue;
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_frag(bool), "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_From_dec(bool)(bool bValue) {
|
||||
if (createScalarBoolean(pvApiCtx, SWIG_NbInputArgument(pvApiCtx)
|
||||
+ SWIG_Scilab_GetOutputPosition(), bValue))
|
||||
return SWIG_ERROR;
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* C-type: bool[]
|
||||
* Scilab type: boolean matrix
|
||||
*/
|
||||
%fragment("SWIG_SciBoolean_AsBoolArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciBoolean_AsBoolArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, bool **pbValue, char *fname) {
|
||||
SciErr sciErr;
|
||||
int *piAddrVar = NULL;
|
||||
int *piValue = NULL;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (isBooleanType(pvApiCtx, piAddrVar)) {
|
||||
int i;
|
||||
sciErr = getMatrixOfBoolean(pvApiCtx, piAddrVar, iRows, iCols, &piValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
*pbValue = (bool*) malloc((*iRows) * (*iCols) * sizeof(bool));
|
||||
for (i = 0; i < (*iRows) * (*iCols); i++)
|
||||
(*pbValue)[i] = piValue[i] != 0;
|
||||
}
|
||||
else {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A boolean matrix expected.\n"), fname, iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment("SWIG_SciBoolean_FromBoolArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciBoolean_FromBoolArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, bool *pbValue) {
|
||||
SciErr sciErr;
|
||||
int *piValue = NULL;
|
||||
int i;
|
||||
|
||||
piValue = (int*) malloc(iRows * iCols * sizeof(int));
|
||||
for (i = 0; i < iRows * iCols; i++)
|
||||
piValue[i] = pbValue[i];
|
||||
|
||||
sciErr = createMatrixOfBoolean(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, iRows, iCols, piValue);
|
||||
if(sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
free(piValue);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
free(piValue);
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* C-type: int[]
|
||||
* Scilab type: boolean matrix
|
||||
*/
|
||||
%fragment("SWIG_SciBoolean_AsIntArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciBoolean_AsIntArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, int **piValue, char *fname) {
|
||||
SciErr sciErr;
|
||||
int *piAddrVar = NULL;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (isBooleanType(pvApiCtx, piAddrVar)) {
|
||||
int i;
|
||||
sciErr = getMatrixOfBoolean(pvApiCtx, piAddrVar, iRows, iCols, piValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A boolean matrix expected.\n"), fname, iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment("SWIG_SciBoolean_FromIntArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciBoolean_FromIntArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, int *piValue) {
|
||||
SciErr sciErr;
|
||||
|
||||
sciErr = createMatrixOfBoolean(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, iRows, iCols, piValue);
|
||||
if(sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
285
Lib/scilab/scichar.swg
Normal file
285
Lib/scilab/scichar.swg
Normal file
|
|
@ -0,0 +1,285 @@
|
|||
/*
|
||||
* C-type: char or char*
|
||||
* Scilab type: string
|
||||
*/
|
||||
|
||||
/*
|
||||
* CHAR
|
||||
*/
|
||||
|
||||
%fragment(SWIG_AsVal_frag(char), "header", fragment="SWIG_SciString_AsChar") {
|
||||
#define SWIG_AsVal_char(scilabValue, valuePointer) SWIG_SciString_AsChar(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName())
|
||||
}
|
||||
%fragment("SWIG_SciString_AsChar", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciString_AsChar(void *pvApiCtx, int iVar, char *pcValue, char *fname) {
|
||||
SciErr sciErr;
|
||||
int iType = 0;
|
||||
int iRows = 0;
|
||||
int iCols = 0;
|
||||
int *piAddrVar = NULL;
|
||||
char *pstStrings = NULL;
|
||||
int piLength = 0;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iType != sci_strings) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A string expected.\n"), fname, iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
pstStrings = (char *)malloc(sizeof(char));
|
||||
sciErr = getMatrixOfString(pvApiCtx, piAddrVar, &iRows, &iCols, &piLength, (char **)&pstStrings);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iRows * iCols != 1) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A string expected.\n"), fname, iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
*pcValue = pstStrings[0];
|
||||
|
||||
free(pstStrings);
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_frag(char), "header", fragment="SWIG_SciString_FromChar") {
|
||||
#define SWIG_From_char(value) SWIG_SciString_FromChar(pvApiCtx, SWIG_Scilab_GetOutputPosition(), value)
|
||||
}
|
||||
%fragment("SWIG_SciString_FromChar", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciString_FromChar(void *pvApiCtx, int iVarOut, char chValue) {
|
||||
char *pchValue = (char*)malloc(sizeof(char) * 2);
|
||||
pchValue[0] = chValue;
|
||||
pchValue[1] = '\0';
|
||||
|
||||
if (createSingleString(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, pchValue))
|
||||
return SWIG_ERROR;
|
||||
|
||||
free(pchValue);
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* CHAR *
|
||||
*/
|
||||
|
||||
%fragment("SWIG_AsCharArray", "header", fragment = "SWIG_SciString_AsCharPtr") {
|
||||
#define SWIG_AsCharArray(scilabValue, charPtrPointer, charPtrLength) SWIG_SciString_AsCharPtr(pvApiCtx, scilabValue, charPtrPointer, charPtrLength, SWIG_Scilab_GetFuncName())
|
||||
}
|
||||
%fragment("SWIG_SciString_AsCharPtr", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciString_AsCharPtr(void *pvApiCtx, int iVar, char *pcValue, int iLength, char *fname) {
|
||||
SciErr sciErr;
|
||||
int *piAddrVar = NULL;
|
||||
char* pcTmpValue = NULL;
|
||||
int iRet;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
iRet = getAllocatedSingleString(pvApiCtx, piAddrVar, &pcTmpValue);
|
||||
if (iRet) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (pcValue != NULL) {
|
||||
strncpy(pcValue, pcTmpValue, iLength);
|
||||
}
|
||||
|
||||
free(pcTmpValue);
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment("SWIG_AsCharPtrAndSize", "header", fragment = "SWIG_SciString_AsCharPtrAndSize") {
|
||||
#define SWIG_AsCharPtrAndSize(scilabValue, charPtrPointer, charPtrLength, allocMemory) SWIG_SciString_AsCharPtrAndSize(pvApiCtx, scilabValue, charPtrPointer, charPtrLength, allocMemory, SWIG_Scilab_GetFuncName())
|
||||
}
|
||||
%fragment("SWIG_SciString_AsCharPtrAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciString_AsCharPtrAndSize(void *pvApiCtx, int iVar, char **pcValue, size_t *piLength, int *alloc, char *fname) {
|
||||
SciErr sciErr;
|
||||
int *piAddrVar = NULL;
|
||||
int iRet;
|
||||
char *pstStrings = NULL;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
iRet = getAllocatedSingleString(pvApiCtx, piAddrVar, &pstStrings);
|
||||
if (iRet) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
// TODO: return SWIG_ERROR if pcValue NULL (now returning SWIG_ERROR fails some typechecks)
|
||||
if (pcValue) {
|
||||
*pcValue = pstStrings;
|
||||
}
|
||||
|
||||
if (alloc != NULL) {
|
||||
*alloc = SWIG_NEWOBJ;
|
||||
}
|
||||
|
||||
if (piLength != NULL) {
|
||||
*piLength = strlen(*pcValue);
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment("SWIG_FromCharPtr", "header", fragment = "SWIG_SciString_FromCharPtr") {
|
||||
#define SWIG_FromCharPtr(charPtr) SWIG_SciString_FromCharPtr(pvApiCtx, SWIG_Scilab_GetOutputPosition(), charPtr)
|
||||
}
|
||||
%fragment("SWIG_SciString_FromCharPtr", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciString_FromCharPtr(void *pvApiCtx, int iVarOut, const char *pchValue) {
|
||||
if (pchValue) {
|
||||
SciErr sciErr;
|
||||
const char* pstStrings[1];
|
||||
pstStrings[0] = pchValue;
|
||||
|
||||
sciErr = createMatrixOfString(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, 1, 1, pstStrings);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
else {
|
||||
int iRet = createEmptyMatrix(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut);
|
||||
if (iRet) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* CHAR * ARRAY
|
||||
*/
|
||||
|
||||
%fragment("SWIG_SciString_AsCharPtrArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciString_AsCharPtrArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, char ***charPtrArray, char *fname) {
|
||||
SciErr sciErr;
|
||||
int i = 0;
|
||||
int *piAddrVar = NULL;
|
||||
int* piLength = NULL;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getMatrixOfString(pvApiCtx, piAddrVar, iRows, iCols, NULL, NULL);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
piLength = (int*) malloc((*iRows) * (*iCols) * sizeof(int));
|
||||
|
||||
sciErr = getMatrixOfString(pvApiCtx, piAddrVar, iRows, iCols, piLength, NULL);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
*charPtrArray = (char**) malloc((*iRows) * (*iCols) * sizeof(char*));
|
||||
for(i = 0 ; i < (*iRows) * (*iCols); i++) {
|
||||
(*charPtrArray)[i] = (char*) malloc(sizeof(char) * (piLength[i] + 1));
|
||||
}
|
||||
|
||||
sciErr = getMatrixOfString(pvApiCtx, piAddrVar, iRows, iCols, piLength, *charPtrArray);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
free(piLength);
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment("SWIG_SciString_FromCharPtrArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciString_FromCharPtrArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, char **charPtrArray) {
|
||||
SciErr sciErr;
|
||||
|
||||
sciErr = createMatrixOfString(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, iRows, iCols, (const char* const*) charPtrArray);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment("SWIG_FromCharPtrAndSize", "header", fragment = "SWIG_SciString_FromCharPtr") {
|
||||
#define SWIG_FromCharPtrAndSize(charPtr, charPtrLength) SWIG_SciString_FromCharPtr(pvApiCtx, SWIG_Scilab_GetOutputPosition(), charPtr)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Char* Scilab variable
|
||||
*/
|
||||
|
||||
%fragment(SWIG_CreateScilabVariable_frag(char), "wrapper") {
|
||||
SWIGINTERN int
|
||||
SWIG_CreateScilabVariable_dec(char)(void *pvApiCtx, const char* psVariableName, const char cVariableValue) {
|
||||
SciErr sciErr;
|
||||
char sValue[2];
|
||||
const char* psStrings[1];
|
||||
|
||||
sValue[0] = cVariableValue;
|
||||
sValue[1] = '\0';
|
||||
psStrings[0] = sValue;
|
||||
|
||||
sciErr = createNamedMatrixOfString(pvApiCtx, psVariableName, 1, 1, psStrings);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_CreateScilabVariable_frag(charptr), "wrapper") {
|
||||
SWIGINTERN int
|
||||
SWIG_CreateScilabVariable_dec(charptr)(void *pvApiCtx, const char* psVariableName, const char* psVariableValue) {
|
||||
SciErr sciErr;
|
||||
const char* psStrings[1];
|
||||
psStrings[0] = psVariableValue;
|
||||
|
||||
sciErr = createNamedMatrixOfString(pvApiCtx, psVariableName, 1, 1, psStrings);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
445
Lib/scilab/scicontainer.swg
Normal file
445
Lib/scilab/scicontainer.swg
Normal file
|
|
@ -0,0 +1,445 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* scicontainer.swg
|
||||
*
|
||||
* Scilab list <-> C++ container wrapper
|
||||
*
|
||||
* This wrapper, and its iterator, allows a general use (and reuse) of
|
||||
* the mapping between C++ and Scilab, thanks to the C++ templates.
|
||||
*
|
||||
* Of course, it needs the C++ compiler to support templates, but
|
||||
* since we will use this wrapper with the STL containers, that should
|
||||
* be the case.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%{
|
||||
#include <iostream>
|
||||
%}
|
||||
|
||||
#if !defined(SWIG_NO_EXPORT_ITERATOR_METHODS)
|
||||
# if !defined(SWIG_EXPORT_ITERATOR_METHODS)
|
||||
# define SWIG_EXPORT_ITERATOR_METHODS SWIG_EXPORT_ITERATOR_METHODS
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
// #define (SWIG_SCILAB_EXTRA_NATIVE_CONTAINERS)
|
||||
// if defined: sequences in return are converted from/to Scilab lists or matrices
|
||||
// if not defined: sequences are passed from/to Scilab as pointers
|
||||
|
||||
%{
|
||||
#define SWIG_STD_NOASSIGN_STL
|
||||
%}
|
||||
|
||||
%include <sciiterators.swg>
|
||||
%include <scisequence.swg>
|
||||
|
||||
%{
|
||||
#include <stdexcept>
|
||||
%}
|
||||
|
||||
%include <exception.i>
|
||||
%include <std_except.i>
|
||||
|
||||
%fragment("SciSequence_Cont", "header",
|
||||
fragment="StdTraits",
|
||||
fragment="SwigSciIterator_T")
|
||||
{
|
||||
namespace swig
|
||||
{
|
||||
template <class T>
|
||||
struct SciSequence_Ref
|
||||
{
|
||||
SciSequence_Ref(const SwigSciObject& seq, int index)
|
||||
: _seq(seq), _index(index)
|
||||
{
|
||||
if (traits_as_sequence<T>::get(_seq, &piSeqAddr) != SWIG_OK)
|
||||
{
|
||||
throw std::invalid_argument("Cannot get sequence data.");
|
||||
}
|
||||
}
|
||||
|
||||
operator T () const
|
||||
{
|
||||
try
|
||||
{
|
||||
return traits_asval_sequenceitem<T>::asval(_seq, piSeqAddr, _index);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
SWIG_exception(SWIG_RuntimeError, e.what());
|
||||
}
|
||||
}
|
||||
|
||||
SciSequence_Ref& operator=(const T& v)
|
||||
{
|
||||
// TODO
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
SwigSciObject _seq;
|
||||
int _index;
|
||||
void *piSeqAddr;
|
||||
};
|
||||
|
||||
|
||||
template <class T>
|
||||
struct SciSequence_ArrowProxy
|
||||
{
|
||||
SciSequence_ArrowProxy(const T& x): m_value(x) {}
|
||||
const T* operator->() const { return &m_value; }
|
||||
operator const T*() const { return &m_value; }
|
||||
T m_value;
|
||||
};
|
||||
|
||||
template <class T, class Reference >
|
||||
struct SwigSciSequence_InputIterator
|
||||
{
|
||||
typedef SwigSciSequence_InputIterator<T, Reference > self;
|
||||
|
||||
typedef std::random_access_iterator_tag iterator_category;
|
||||
typedef Reference reference;
|
||||
typedef T value_type;
|
||||
typedef T* pointer;
|
||||
typedef int difference_type;
|
||||
|
||||
SwigSciSequence_InputIterator()
|
||||
{
|
||||
}
|
||||
|
||||
SwigSciSequence_InputIterator(const SwigSciObject& seq, int index)
|
||||
: _seq(seq), _index(index)
|
||||
{
|
||||
}
|
||||
|
||||
reference operator*() const
|
||||
{
|
||||
return reference(_seq, _index);
|
||||
}
|
||||
|
||||
SciSequence_ArrowProxy<T>
|
||||
operator->() const {
|
||||
return SciSequence_ArrowProxy<T>(operator*());
|
||||
}
|
||||
|
||||
bool operator==(const self& ri) const
|
||||
{
|
||||
return (_index == ri._index);
|
||||
}
|
||||
|
||||
bool operator!=(const self& ri) const
|
||||
{
|
||||
return !(operator==(ri));
|
||||
}
|
||||
|
||||
self& operator ++ ()
|
||||
{
|
||||
++_index;
|
||||
return *this;
|
||||
}
|
||||
|
||||
self& operator -- ()
|
||||
{
|
||||
--_index;
|
||||
return *this;
|
||||
}
|
||||
|
||||
self& operator += (difference_type n)
|
||||
{
|
||||
_index += n;
|
||||
return *this;
|
||||
}
|
||||
|
||||
self operator +(difference_type n) const
|
||||
{
|
||||
return self(_seq, _index + n);
|
||||
}
|
||||
|
||||
self& operator -= (difference_type n)
|
||||
{
|
||||
_index -= n;
|
||||
return *this;
|
||||
}
|
||||
|
||||
self operator -(difference_type n) const
|
||||
{
|
||||
return self(_seq, _index - n);
|
||||
}
|
||||
|
||||
difference_type operator - (const self& ri) const
|
||||
{
|
||||
return _index - ri._index;
|
||||
}
|
||||
|
||||
bool operator < (const self& ri) const
|
||||
{
|
||||
return _index < ri._index;
|
||||
}
|
||||
|
||||
reference
|
||||
operator[](difference_type n) const
|
||||
{
|
||||
return reference(_seq, _index + n);
|
||||
}
|
||||
|
||||
private:
|
||||
SwigSciObject _seq;
|
||||
difference_type _index;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct SciSequence_Cont
|
||||
{
|
||||
typedef SciSequence_Ref<T> reference;
|
||||
typedef const SciSequence_Ref<T> const_reference;
|
||||
typedef T value_type;
|
||||
typedef T* pointer;
|
||||
typedef int difference_type;
|
||||
typedef int size_type;
|
||||
typedef const pointer const_pointer;
|
||||
typedef SwigSciSequence_InputIterator<T, reference> iterator;
|
||||
typedef SwigSciSequence_InputIterator<T, const_reference> const_iterator;
|
||||
|
||||
SciSequence_Cont(const SwigSciObject& seq) : _seq(seq)
|
||||
{
|
||||
}
|
||||
|
||||
~SciSequence_Cont()
|
||||
{
|
||||
}
|
||||
|
||||
size_type size() const
|
||||
{
|
||||
int iSeqSize;
|
||||
if (traits_as_sequence<value_type>::size(_seq, &iSeqSize) == SWIG_OK)
|
||||
{
|
||||
return iSeqSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
bool empty() const
|
||||
{
|
||||
return size() == 0;
|
||||
}
|
||||
|
||||
iterator begin()
|
||||
{
|
||||
return iterator(_seq, 0);
|
||||
}
|
||||
|
||||
const_iterator begin() const
|
||||
{
|
||||
return const_iterator(_seq, 0);
|
||||
}
|
||||
|
||||
iterator end()
|
||||
{
|
||||
return iterator(_seq, size());
|
||||
}
|
||||
|
||||
const_iterator end() const
|
||||
{
|
||||
return const_iterator(_seq, size());
|
||||
}
|
||||
|
||||
reference operator[](difference_type n)
|
||||
{
|
||||
return reference(_seq, n);
|
||||
}
|
||||
|
||||
const_reference operator[](difference_type n) const
|
||||
{
|
||||
return const_reference(_seq, n);
|
||||
}
|
||||
|
||||
private:
|
||||
SwigSciObject _seq;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%define %swig_sequence_iterator(Sequence...)
|
||||
#if defined(SWIG_EXPORT_ITERATOR_METHODS)
|
||||
class iterator;
|
||||
class reverse_iterator;
|
||||
class const_iterator;
|
||||
class const_reverse_iterator;
|
||||
|
||||
%typemap(out,noblock=1,fragment="SciSequence_Cont")
|
||||
iterator, reverse_iterator, const_iterator, const_reverse_iterator {
|
||||
%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> {
|
||||
// TODO: return a Scilab list from the pair (see code for Octave)
|
||||
}
|
||||
|
||||
%fragment("SciSwigPairBoolOutputIterator", "header",
|
||||
fragment=SWIG_From_frag(bool), fragment="SciSequence_Cont") {}
|
||||
|
||||
%typemap(out,fragment="SciSwigPairBoolOutputIterator")
|
||||
std::pair<iterator, bool>, std::pair<const_iterator, bool> {
|
||||
// TODO: return a Scilab list from the pair (see code for Octave)
|
||||
}
|
||||
|
||||
%typemap(in,noblock=1,fragment="SciSequence_Cont")
|
||||
iterator(swig::SciSwigIterator *iter = 0, int res),
|
||||
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((SwigSciObject)$input, %as_voidptrptr(&iter), swig::SciSwigIterator::descriptor(), 0);
|
||||
if (!SWIG_IsOK(res) || !iter) {
|
||||
%argument_fail(SWIG_TypeError, "$type", $symname, $argnum);
|
||||
} else {
|
||||
swig::SwigSciIterator_T<$type > *iter_t = dynamic_cast<swig::SwigSciIterator_T<$type > *>(iter);
|
||||
if (iter_t) {
|
||||
$1 = iter_t->get_current();
|
||||
} else {
|
||||
%argument_fail(SWIG_TypeError, "$type", $symname, $argnum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%typecheck(%checkcode(ITERATOR),noblock=1,fragment="SciSequence_Cont")
|
||||
iterator, reverse_iterator, const_iterator, const_reverse_iterator {
|
||||
swig::SciSwigIterator *iter = 0;
|
||||
int res = SWIG_ConvertPtr((SwigSciObject)$input, %as_voidptrptr(&iter), swig::SciSwigIterator::descriptor(), 0);
|
||||
$1 = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigSciIterator_T<$type > *>(iter) != 0));
|
||||
}
|
||||
|
||||
%fragment("SciSequence_Cont");
|
||||
#endif //SWIG_EXPORT_ITERATOR_METHODS
|
||||
%enddef
|
||||
|
||||
// The Scilab container methods
|
||||
|
||||
%define %swig_container_methods(Container...)
|
||||
%enddef
|
||||
|
||||
%define %swig_sequence_methods_common(Sequence...)
|
||||
%swig_sequence_iterator(%arg(Sequence))
|
||||
%swig_container_methods(%arg(Sequence))
|
||||
|
||||
%enddef
|
||||
|
||||
%define %swig_sequence_methods(Sequence...)
|
||||
%swig_sequence_methods_common(%arg(Sequence))
|
||||
%enddef
|
||||
|
||||
%define %swig_sequence_methods_val(Sequence...)
|
||||
%swig_sequence_methods_common(%arg(Sequence))
|
||||
%enddef
|
||||
|
||||
//
|
||||
// Common fragments
|
||||
//
|
||||
|
||||
%fragment("StdSequenceTraits","header",
|
||||
fragment="StdTraits",
|
||||
fragment="SciSequence_Cont",
|
||||
fragment=SWIG_Traits_SequenceItem_frag(ptr))
|
||||
{
|
||||
namespace swig {
|
||||
template <class SciSeq, class Seq>
|
||||
inline void
|
||||
assign(const SciSeq& sciSeq, Seq* seq) {
|
||||
%#ifdef SWIG_STD_NOASSIGN_STL
|
||||
typedef typename SciSeq::value_type value_type;
|
||||
typename SciSeq::const_iterator it = sciSeq.begin();
|
||||
for (;it != sciSeq.end(); ++it) {
|
||||
seq->insert(seq->end(),(value_type)(*it));
|
||||
}
|
||||
%#else
|
||||
seq->assign(sciSeq.begin(), sciSeq.end());
|
||||
%#endif
|
||||
}
|
||||
|
||||
template <class Seq, class T = typename Seq::value_type >
|
||||
struct traits_asptr_stdseq {
|
||||
typedef Seq sequence;
|
||||
typedef T value_type;
|
||||
|
||||
static int asptr(const SwigSciObject& obj, sequence **seq)
|
||||
{
|
||||
swig_type_info *typeInfo = swig::type_info<sequence>();
|
||||
if (typeInfo)
|
||||
{
|
||||
sequence *p;
|
||||
if (SWIG_ConvertPtr(obj, (void**)&p, typeInfo, 0) == SWIG_OK)
|
||||
{
|
||||
if (seq)
|
||||
*seq = p;
|
||||
return SWIG_OLDOBJ;
|
||||
}
|
||||
}
|
||||
|
||||
if (traits_as_sequence<value_type>::check(obj) == SWIG_OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
SciSequence_Cont<value_type> sciSeq(obj);
|
||||
if (seq)
|
||||
{
|
||||
*seq = new sequence();
|
||||
assign(sciSeq, *seq);
|
||||
return SWIG_NEWOBJ;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
SWIG_exception(SWIG_RuntimeError, e.what());
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <class Seq, class T = typename Seq::value_type >
|
||||
struct traits_from_stdseq {
|
||||
typedef Seq sequence;
|
||||
typedef T value_type;
|
||||
typedef typename Seq::size_type size_type;
|
||||
typedef typename sequence::const_iterator const_iterator;
|
||||
|
||||
static SwigSciObject from(const sequence& seq)
|
||||
{
|
||||
%#ifdef SWIG_SCILAB_EXTRA_NATIVE_CONTAINERS
|
||||
swig_type_info *typeInfo = swig::type_info<sequence>();
|
||||
if (typeInfo)
|
||||
{
|
||||
return SWIG_NewPointerObj(new sequence(seq), typeInfo, SWIG_POINTER_OWN);
|
||||
}
|
||||
%#endif
|
||||
|
||||
try
|
||||
{
|
||||
void *data;
|
||||
size_type size = seq.size();
|
||||
if (traits_from_sequence<value_type>::create(size, &data) == SWIG_OK) {
|
||||
const_iterator it;
|
||||
int index = 0;
|
||||
for (it = seq.begin(); it != seq.end(); ++it)
|
||||
{
|
||||
traits_from_sequenceitem<value_type>::from(data, index, *it);
|
||||
index++;
|
||||
}
|
||||
return traits_from_sequence<value_type>::set(size, data);
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
SWIG_exception(SWIG_RuntimeError, e.what());
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
108
Lib/scilab/scidouble.swg
Normal file
108
Lib/scilab/scidouble.swg
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
* DOUBLE SCALAR
|
||||
*/
|
||||
%fragment(SWIG_AsVal_frag(double), "header", fragment="SWIG_SciDouble_AsDouble") {
|
||||
%#define SWIG_AsVal_double(scilabValue, valuePointer) SWIG_SciDouble_AsDouble(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName())
|
||||
}
|
||||
%fragment("SWIG_SciDouble_AsDouble", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciDouble_AsDouble(void *pvApiCtx, SwigSciObject iVar, double *pdblValue, char *fname) {
|
||||
SciErr sciErr;
|
||||
int iRet = 0;
|
||||
int *piAddrVar = NULL;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (!isDoubleType(pvApiCtx, piAddrVar) || isVarComplex(pvApiCtx, piAddrVar)) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A real expected.\n"), fname, iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (!isScalar(pvApiCtx, piAddrVar)) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A real expected.\n"), fname, iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
iRet = getScalarDouble(pvApiCtx, piAddrVar, pdblValue);
|
||||
if (iRet) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_frag(double), "header", fragment="SWIG_SciDouble_FromDouble") {
|
||||
%#define SWIG_From_double(scilabValue) SWIG_SciDouble_FromDouble(pvApiCtx, SWIG_Scilab_GetOutputPosition(), scilabValue, SWIG_Scilab_GetFuncName())
|
||||
}
|
||||
%fragment("SWIG_SciDouble_FromDouble", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciDouble_FromDouble(void *pvApiCtx, int iVarOut, double dblValue, char *fname) {
|
||||
if (createScalarDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, dblValue))
|
||||
return SWIG_ERROR;
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* DOUBLE ARRAY
|
||||
*/
|
||||
|
||||
%fragment("SWIG_SciDouble_AsDoubleArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciDouble_AsDoubleArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, double **pdValue, char *fname) {
|
||||
SciErr sciErr;
|
||||
int *piAddrVar = NULL;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (isDoubleType(pvApiCtx, piAddrVar) && !isVarComplex(pvApiCtx, piAddrVar)) {
|
||||
sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, iRows, iCols, pdValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A real matrix expected.\n"), fname, iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment("SWIG_SciDouble_FromDoubleArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciDouble_FromDoubleArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, double *pdblValue) {
|
||||
SciErr sciErr;
|
||||
sciErr = createMatrixOfDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, iRows, iCols, pdblValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_CreateScilabVariable_frag(double), "wrapper") {
|
||||
SWIGINTERN int
|
||||
SWIG_CreateScilabVariable_dec(double)(void *pvApiCtx, const char* psVariableName, const double dVariableValue) {
|
||||
SciErr sciErr;
|
||||
sciErr = createNamedMatrixOfDouble(pvApiCtx, psVariableName, 1, 1, &dVariableValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
31
Lib/scilab/scienum.swg
Normal file
31
Lib/scilab/scienum.swg
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* C-type: enum
|
||||
* Scilab type: double or int32
|
||||
*/
|
||||
|
||||
%fragment(SWIG_AsVal_frag(Enum), "header", fragment="SWIG_Int_AsEnum") {
|
||||
%#define SWIG_AsVal_Enum(scilabValue, valuePointer) SWIG_Int_AsEnum(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName())
|
||||
}
|
||||
%fragment("SWIG_Int_AsEnum", "header", fragment="SWIG_SciDoubleOrInt32_AsInt") {
|
||||
SWIGINTERN int
|
||||
SWIG_Int_AsEnum(void *pvApiCtx, int iVar, int *enumValue, char *fname) {
|
||||
int iValue = 0;
|
||||
if (SWIG_SciDoubleOrInt32_AsInt(pvApiCtx, iVar, &iValue, fname) != SWIG_OK)
|
||||
return SWIG_ERROR;
|
||||
*enumValue = iValue;
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_frag(Enum), "header", fragment="SWIG_Int_FromEnum") {
|
||||
%#define SWIG_From_Enum(scilabValue) SWIG_Int_FromEnum(pvApiCtx, SWIG_Scilab_GetOutputPosition(), scilabValue, SWIG_Scilab_GetFuncName())
|
||||
}
|
||||
%fragment("SWIG_Int_FromEnum", "header", fragment="SWIG_SciDouble_FromInt") {
|
||||
SWIGINTERN int
|
||||
SWIG_Int_FromEnum(void *pvApiCtx, int iVarOut, int enumValue, char *fname) {
|
||||
if (SWIG_SciDouble_FromInt(pvApiCtx, iVarOut, enumValue, fname) != SWIG_OK)
|
||||
return SWIG_ERROR;
|
||||
SWIG_Scilab_SetOutput(pvApiCtx, iVarOut);
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
60
Lib/scilab/sciexception.swg
Normal file
60
Lib/scilab/sciexception.swg
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* Exception typemaps (throws)
|
||||
*/
|
||||
|
||||
%include <exception.i>
|
||||
|
||||
%typemap(throws, noblock=1) int, unsigned int, signed int,
|
||||
int&,unsigned int&, signed int&,
|
||||
long, unsigned long, signed long,
|
||||
short, unsigned short,signed short,
|
||||
long long, unsigned long long,
|
||||
unsigned char, signed char,
|
||||
long&, unsigned long&, signed long&,
|
||||
short&, unsigned short&, signed short&,
|
||||
long long&, unsigned long long&,
|
||||
unsigned char&, signed char&,
|
||||
size_t, size_t&,
|
||||
ptrdiff_t, ptrdiff_t& {
|
||||
char obj[20];
|
||||
sprintf(obj, "%d", (int)$1);
|
||||
SWIG_Scilab_Raise_Ex(obj, "$type", $descriptor);
|
||||
}
|
||||
|
||||
%typemap(throws, noblock=1) enum SWIGTYPE {
|
||||
char obj[20];
|
||||
sprintf(obj, "%d", (int)$1);
|
||||
SWIG_Scilab_Raise_Ex(obj, "$type", $descriptor);
|
||||
}
|
||||
|
||||
%typemap(throws, noblock=1) float, double,
|
||||
float&, double& {
|
||||
char obj[20];
|
||||
sprintf(obj, "%5.3f", (double)$1);
|
||||
SWIG_Scilab_Raise_Ex(obj, "$type", $descriptor);
|
||||
}
|
||||
|
||||
%typemap(throws, noblock=1) bool, bool& {
|
||||
SWIG_Scilab_Raise_Ex($1 ? "true" : "false", "$type", $descriptor);
|
||||
}
|
||||
|
||||
%typemap(throws, noblock=1) char*, char[ANY] {
|
||||
SWIG_Scilab_Raise_Ex($1, "$type", $descriptor);
|
||||
}
|
||||
|
||||
%typemap(throws, noblock=1) char, char& {
|
||||
char obj[1];
|
||||
sprintf(obj, "%c", (char)$1);
|
||||
SWIG_Scilab_Raise_Ex(obj, "$type", $descriptor);
|
||||
}
|
||||
|
||||
%typemap(throws, noblock=1) SWIGTYPE,
|
||||
SWIGTYPE*,
|
||||
SWIGTYPE [ANY],
|
||||
SWIGTYPE & {
|
||||
SWIG_Scilab_Raise_Ex((char*)NULL, "$type", $descriptor);
|
||||
}
|
||||
|
||||
%typemap(throws, noblock=1) (...) {
|
||||
SWIG_exception(SWIG_RuntimeError, "unknown exception");
|
||||
}
|
||||
83
Lib/scilab/scifloat.swg
Normal file
83
Lib/scilab/scifloat.swg
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* FLOAT SCALAR
|
||||
*/
|
||||
|
||||
%fragment(SWIG_AsVal_frag(float), "header", fragment=SWIG_AsVal_frag(double)) {
|
||||
SWIGINTERN int
|
||||
SWIG_AsVal_dec(float)(SwigSciObject iVar, float *pfValue) {
|
||||
double dblValue = 0.0;
|
||||
if(SWIG_AsVal_dec(double)(iVar, &dblValue) != SWIG_OK) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (pfValue)
|
||||
*pfValue = (float) dblValue;
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_frag(float), "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_From_dec(float)(float flValue) {
|
||||
if (createScalarDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx)
|
||||
+ SWIG_Scilab_GetOutputPosition(), (double)flValue))
|
||||
return SWIG_ERROR;
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment("SWIG_SciDouble_AsFloatArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciDouble_AsFloatArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, float **pfValue, char *fname) {
|
||||
SciErr sciErr;
|
||||
int *piAddrVar = NULL;
|
||||
double *pdValue = NULL;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (isDoubleType(pvApiCtx, piAddrVar) && !isVarComplex(pvApiCtx, piAddrVar)) {
|
||||
int i;
|
||||
|
||||
sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, iRows, iCols, &pdValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
*pfValue = (float *) malloc((*iRows) * (*iCols) * sizeof(float));
|
||||
for (i=0; i < (*iRows) * (*iCols); i++)
|
||||
(*pfValue)[i] = (float) pdValue[i];
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
else {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A real matrix expected.\n"), fname, iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%fragment("SWIG_SciDouble_FromFloatArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciDouble_FromFloatArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, float *pfValue) {
|
||||
SciErr sciErr;
|
||||
double *pdValue;
|
||||
int i;
|
||||
|
||||
pdValue = (double *) malloc(iRows * iCols * sizeof(double));
|
||||
for (i = 0; i < iRows * iCols; i++)
|
||||
pdValue[i] = pfValue[i];
|
||||
|
||||
sciErr = createMatrixOfDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, iRows, iCols, pdValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
free(pdValue);
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
202
Lib/scilab/sciint.swg
Normal file
202
Lib/scilab/sciint.swg
Normal file
|
|
@ -0,0 +1,202 @@
|
|||
/*
|
||||
* C-type: int
|
||||
* Scilab type: double or int32
|
||||
*/
|
||||
|
||||
%fragment(SWIG_AsVal_frag(int), "header", fragment="SWIG_SciDoubleOrInt32_AsInt", fragment="<limits.h>") {
|
||||
%#define SWIG_AsVal_int(scilabValue, valuePointer) SWIG_SciDoubleOrInt32_AsInt(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName())
|
||||
}
|
||||
%fragment("SWIG_SciDoubleOrInt32_AsInt", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciDoubleOrInt32_AsInt(void *pvApiCtx, SwigSciObject iVar, int *piValue, char *fname)
|
||||
{
|
||||
SciErr sciErr;
|
||||
int iType = 0;
|
||||
int iRows = 0;
|
||||
int iCols = 0;
|
||||
int *piAddrVar = NULL;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (iType == sci_ints) {
|
||||
if (piValue) {
|
||||
int iPrec = 0;
|
||||
int *piData = NULL;
|
||||
|
||||
sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iPrec != SCI_INT32) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 32-bit signed integer or a double expected.\n"), fname, iVar);
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
sciErr = getMatrixOfInteger32(pvApiCtx, piAddrVar, &iRows, &iCols, &piData);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iRows * iCols != 1) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 32-bit signed integer or a double expected.\n"), fname, iVar);
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
*piValue = *piData;
|
||||
}
|
||||
}
|
||||
else if (iType == sci_matrix) {
|
||||
if (piValue) {
|
||||
double *pdData = NULL;
|
||||
double dValue = 0.0f;
|
||||
sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, &iRows, &iCols, &pdData);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iRows * iCols != 1) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 32-bit signed integer or a double expected.\n"), fname, iVar);
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
dValue = *pdData;
|
||||
if (dValue != floor(dValue)) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Incorrect value for input argument #%d: The double value cannot be converted to a 32-bit signed integer.\n"), fname, iVar);
|
||||
return SWIG_ValueError;
|
||||
}
|
||||
if ((dValue < INT_MIN) || (dValue > INT_MAX)) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Overflow error for input argument #%d: The double value cannot be converted to a 32-bit signed integer.\n"), fname, iVar);
|
||||
return SWIG_OverflowError;
|
||||
}
|
||||
*piValue = (int) dValue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 32-bit signed integer or a double expected.\n"), fname, iVar);
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_frag(int), "header", fragment="SWIG_SciDouble_FromInt") {
|
||||
%#define SWIG_From_int(scilabValue) SWIG_SciDouble_FromInt(pvApiCtx, SWIG_Scilab_GetOutputPosition(), scilabValue, SWIG_Scilab_GetFuncName())
|
||||
}
|
||||
%fragment("SWIG_SciDouble_FromInt", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciDouble_FromInt(void *pvApiCtx, int iVarOut, int iValue, char *fname){
|
||||
if (createScalarDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx)
|
||||
+ iVarOut, (double) iValue))
|
||||
return SWIG_ERROR;
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* C-type: int[]
|
||||
* Scilab type: double or int32 matrix
|
||||
*/
|
||||
%fragment("SWIG_SciDoubleOrInt32_AsIntArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciDoubleOrInt32_AsIntArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, int **piValue, char *fname) {
|
||||
SciErr sciErr;
|
||||
int iType = 0;
|
||||
int *piAddrVar = NULL;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (iType == sci_matrix) {
|
||||
double *pdData = NULL;
|
||||
int size = 0;
|
||||
int i;
|
||||
|
||||
sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, iRows, iCols, &pdData);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
size = (*iRows) * (*iCols);
|
||||
*piValue = (int*) malloc(size * sizeof(int*));
|
||||
for (i = 0; i < size; i++)
|
||||
(*piValue)[i] = (int) pdData[i];
|
||||
}
|
||||
else if (iType == sci_ints) {
|
||||
int iPrec = 0;
|
||||
sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iPrec != SCI_INT32) {
|
||||
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;
|
||||
}
|
||||
sciErr = getMatrixOfInteger32(pvApiCtx, piAddrVar, iRows, iCols, piValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment("SWIG_SciDouble_FromIntArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciDouble_FromIntArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, const int *piData) {
|
||||
SciErr sciErr;
|
||||
double *pdValues = NULL;
|
||||
int i;
|
||||
|
||||
pdValues = (double*) malloc(iRows * iCols * sizeof(double));
|
||||
for (i=0; i<iRows * iCols; i++)
|
||||
pdValues[i] = piData[i];
|
||||
|
||||
sciErr = createMatrixOfDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, iRows, iCols, pdValues);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
free(pdValues);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
free(pdValues);
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_CreateScilabVariable_frag(int), "wrapper") {
|
||||
SWIGINTERN int
|
||||
SWIG_CreateScilabVariable_dec(int)(void *pvApiCtx, const char* psVariableName, const int iVariableValue) {
|
||||
SciErr sciErr;
|
||||
sciErr = createNamedMatrixOfInteger32(pvApiCtx, psVariableName, 1, 1, &iVariableValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
363
Lib/scilab/sciiterators.swg
Normal file
363
Lib/scilab/sciiterators.swg
Normal file
|
|
@ -0,0 +1,363 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* sciiterators.swg
|
||||
*
|
||||
* Users can derive form the SciSwigIterator to implemet their
|
||||
* own iterators. As an example (real one since we use it for STL/STD
|
||||
* containers), the template SwigSciIterator_T does the
|
||||
* implementation for generic C++ iterators.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include <std_common.i>
|
||||
|
||||
%fragment("SciSwigIterator","header",fragment="<stddef.h>") {
|
||||
namespace swig {
|
||||
struct stop_iteration {
|
||||
};
|
||||
|
||||
struct SciSwigIterator {
|
||||
private:
|
||||
SwigSciObject _seq;
|
||||
|
||||
protected:
|
||||
SciSwigIterator(SwigSciObject seq) : _seq(seq)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
virtual ~SciSwigIterator() {}
|
||||
|
||||
virtual SwigSciObject value() const = 0;
|
||||
|
||||
virtual SciSwigIterator *incr(size_t n = 1) = 0;
|
||||
|
||||
virtual SciSwigIterator *decr(size_t n = 1)
|
||||
{
|
||||
throw stop_iteration();
|
||||
}
|
||||
|
||||
virtual ptrdiff_t distance(const SciSwigIterator &x) const
|
||||
{
|
||||
throw std::invalid_argument("operation not supported");
|
||||
}
|
||||
|
||||
virtual bool equal (const SciSwigIterator &x) const
|
||||
{
|
||||
throw std::invalid_argument("operation not supported");
|
||||
}
|
||||
|
||||
virtual SciSwigIterator *copy() const = 0;
|
||||
|
||||
SwigSciObject next()
|
||||
{
|
||||
SwigSciObject obj = value();
|
||||
incr();
|
||||
return obj;
|
||||
}
|
||||
|
||||
SwigSciObject previous()
|
||||
{
|
||||
decr();
|
||||
return value();
|
||||
}
|
||||
|
||||
SciSwigIterator *advance(ptrdiff_t n)
|
||||
{
|
||||
return (n > 0) ? incr(n) : decr(-n);
|
||||
}
|
||||
|
||||
bool operator == (const SciSwigIterator& x) const
|
||||
{
|
||||
return equal(x);
|
||||
}
|
||||
|
||||
bool operator != (const SciSwigIterator& x) const
|
||||
{
|
||||
return ! operator==(x);
|
||||
}
|
||||
|
||||
SciSwigIterator* operator ++ () {
|
||||
incr();
|
||||
return this;
|
||||
}
|
||||
|
||||
SciSwigIterator* operator -- () {
|
||||
decr();
|
||||
return this;
|
||||
}
|
||||
|
||||
SciSwigIterator* operator + (ptrdiff_t n) const
|
||||
{
|
||||
return copy()->advance(n);
|
||||
}
|
||||
|
||||
SciSwigIterator* operator - (ptrdiff_t n) const
|
||||
{
|
||||
return copy()->advance(-n);
|
||||
}
|
||||
|
||||
ptrdiff_t operator - (const SciSwigIterator& x) const
|
||||
{
|
||||
return x.distance(*this);
|
||||
}
|
||||
|
||||
static swig_type_info* descriptor() {
|
||||
static int init = 0;
|
||||
static swig_type_info* desc = 0;
|
||||
if (!init) {
|
||||
desc = SWIG_TypeQuery("swig::SciSwigIterator *");
|
||||
init = 1;
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%fragment("SwigSciIterator_T","header",fragment="<stddef.h>",fragment="SciSwigIterator",fragment="StdTraits",fragment="StdIteratorTraits") {
|
||||
namespace swig {
|
||||
template<typename OutIterator>
|
||||
class SwigSciIterator_T : public SciSwigIterator
|
||||
{
|
||||
public:
|
||||
typedef OutIterator out_iterator;
|
||||
typedef typename std::iterator_traits<out_iterator>::value_type value_type;
|
||||
typedef SwigSciIterator_T<out_iterator> self_type;
|
||||
|
||||
SwigSciIterator_T(out_iterator curr, SwigSciObject seq)
|
||||
: SciSwigIterator(seq), current(curr)
|
||||
{
|
||||
}
|
||||
|
||||
const out_iterator& get_current() const
|
||||
{
|
||||
return current;
|
||||
}
|
||||
|
||||
|
||||
bool equal (const SciSwigIterator &iter) const
|
||||
{
|
||||
const self_type *iters = dynamic_cast<const self_type *>(&iter);
|
||||
if (iters) {
|
||||
return (current == iters->get_current());
|
||||
} else {
|
||||
throw std::invalid_argument("bad iterator type");
|
||||
}
|
||||
}
|
||||
|
||||
ptrdiff_t distance(const SciSwigIterator &iter) const
|
||||
{
|
||||
const self_type *iters = dynamic_cast<const self_type *>(&iter);
|
||||
if (iters) {
|
||||
return std::distance(current, iters->get_current());
|
||||
} else {
|
||||
throw std::invalid_argument("bad iterator type");
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
out_iterator current;
|
||||
};
|
||||
|
||||
template <class ValueType>
|
||||
struct from_oper
|
||||
{
|
||||
typedef const ValueType& argument_type;
|
||||
typedef SwigSciObject result_type;
|
||||
result_type operator()(argument_type v) const
|
||||
{
|
||||
return swig::from(v);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename OutIterator,
|
||||
typename ValueType = typename std::iterator_traits<OutIterator>::value_type,
|
||||
typename FromOper = from_oper<ValueType> >
|
||||
class SciSwigIteratorOpen_T : public SwigSciIterator_T<OutIterator>
|
||||
{
|
||||
public:
|
||||
FromOper from;
|
||||
typedef OutIterator out_iterator;
|
||||
typedef ValueType value_type;
|
||||
typedef SwigSciIterator_T<out_iterator> base;
|
||||
typedef SciSwigIteratorOpen_T<OutIterator, ValueType, FromOper> self_type;
|
||||
|
||||
SciSwigIteratorOpen_T(out_iterator curr, SwigSciObject seq)
|
||||
: SwigSciIterator_T<OutIterator>(curr, seq)
|
||||
{
|
||||
}
|
||||
|
||||
SwigSciObject value() const {
|
||||
return from(static_cast<const value_type&>(*(base::current)));
|
||||
}
|
||||
|
||||
SciSwigIterator *copy() const
|
||||
{
|
||||
return new self_type(*this);
|
||||
}
|
||||
|
||||
SciSwigIterator *incr(size_t n = 1)
|
||||
{
|
||||
while (n--) {
|
||||
++base::current;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
SciSwigIterator *decr(size_t n = 1)
|
||||
{
|
||||
while (n--) {
|
||||
--base::current;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename OutIterator,
|
||||
typename ValueType = typename std::iterator_traits<OutIterator>::value_type,
|
||||
typename FromOper = from_oper<ValueType> >
|
||||
class SciSwigIteratorClosed_T : public SwigSciIterator_T<OutIterator>
|
||||
{
|
||||
public:
|
||||
FromOper from;
|
||||
typedef OutIterator out_iterator;
|
||||
typedef ValueType value_type;
|
||||
typedef SwigSciIterator_T<out_iterator> base;
|
||||
typedef SciSwigIteratorClosed_T<OutIterator, ValueType, FromOper> self_type;
|
||||
|
||||
SciSwigIteratorClosed_T(out_iterator curr, out_iterator first, out_iterator last, SwigSciObject seq)
|
||||
: SwigSciIterator_T<OutIterator>(curr, seq), begin(first), end(last)
|
||||
{
|
||||
}
|
||||
|
||||
SwigSciObject value() const {
|
||||
if (base::current == end) {
|
||||
throw stop_iteration();
|
||||
} else {
|
||||
return from(static_cast<const value_type&>(*(base::current)));
|
||||
}
|
||||
}
|
||||
|
||||
SciSwigIterator *copy() const
|
||||
{
|
||||
return new self_type(*this);
|
||||
}
|
||||
|
||||
SciSwigIterator *incr(size_t n = 1)
|
||||
{
|
||||
while (n--) {
|
||||
if (base::current == end) {
|
||||
throw stop_iteration();
|
||||
} else {
|
||||
++base::current;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
SciSwigIterator *decr(size_t n = 1)
|
||||
{
|
||||
while (n--) {
|
||||
if (base::current == begin) {
|
||||
throw stop_iteration();
|
||||
} else {
|
||||
--base::current;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
private:
|
||||
out_iterator begin;
|
||||
out_iterator end;
|
||||
};
|
||||
|
||||
template<typename OutIter>
|
||||
inline SciSwigIterator*
|
||||
make_output_iterator(const OutIter& current, const OutIter& begin,const OutIter& end, SwigSciObject seq = SwigSciObject())
|
||||
{
|
||||
return new SciSwigIteratorClosed_T<OutIter>(current, begin, end, seq);
|
||||
}
|
||||
|
||||
template<typename OutIter>
|
||||
inline SciSwigIterator*
|
||||
make_output_iterator(const OutIter& current, SwigSciObject seq = SwigSciObject())
|
||||
{
|
||||
return new SciSwigIteratorOpen_T<OutIter>(current, seq);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
%fragment("SciSwigIterator");
|
||||
namespace swig
|
||||
{
|
||||
// Throw a StopIteration exception
|
||||
%ignore stop_iteration;
|
||||
struct stop_iteration {};
|
||||
|
||||
%typemap(throws, noblock=1) stop_iteration
|
||||
{
|
||||
SWIG_Scilab_Raise(0, "stop_iteration", NULL);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
// Mark methods that return new objects
|
||||
%newobject SciSwigIterator::copy;
|
||||
%newobject SciSwigIterator::operator + (ptrdiff_t n) const;
|
||||
%newobject SciSwigIterator::operator - (ptrdiff_t n) const;
|
||||
|
||||
%nodirector SciSwigIterator;
|
||||
|
||||
%catches(swig::stop_iteration) SciSwigIterator::value() const;
|
||||
%catches(swig::stop_iteration) SciSwigIterator::incr(size_t n = 1);
|
||||
%catches(swig::stop_iteration) SciSwigIterator::decr(size_t n = 1);
|
||||
%catches(std::invalid_argument) SciSwigIterator::distance(const SciSwigIterator &x) const;
|
||||
%catches(std::invalid_argument) SciSwigIterator::equal (const SciSwigIterator &x) const;
|
||||
%catches(swig::stop_iteration) SciSwigIterator::next();
|
||||
%catches(swig::stop_iteration) SciSwigIterator::previous();
|
||||
%catches(swig::stop_iteration) SciSwigIterator::advance(ptrdiff_t n);
|
||||
%catches(swig::stop_iteration) SciSwigIterator::operator += (ptrdiff_t n);
|
||||
%catches(swig::stop_iteration) SciSwigIterator::operator -= (ptrdiff_t n);
|
||||
%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
|
||||
{
|
||||
protected:
|
||||
SciSwigIterator(SwigSciObject seq);
|
||||
|
||||
public:
|
||||
virtual ~SciSwigIterator();
|
||||
|
||||
virtual SwigSciObject value() const = 0;
|
||||
|
||||
virtual SciSwigIterator *incr(size_t n = 1) = 0;
|
||||
|
||||
virtual SciSwigIterator *decr(size_t n = 1);
|
||||
|
||||
virtual ptrdiff_t distance(const SciSwigIterator &x) const;
|
||||
|
||||
virtual bool equal (const SciSwigIterator &x) const;
|
||||
|
||||
virtual SciSwigIterator *copy() const = 0;
|
||||
|
||||
SwigSciObject next();
|
||||
SwigSciObject previous();
|
||||
SciSwigIterator *advance(ptrdiff_t n);
|
||||
|
||||
bool operator == (const SciSwigIterator& x) const;
|
||||
bool operator != (const SciSwigIterator& x) const;
|
||||
SciSwigIterator* operator ++ ();
|
||||
SciSwigIterator* operator -- ();
|
||||
SciSwigIterator* operator + (ptrdiff_t n) const;
|
||||
SciSwigIterator* operator - (ptrdiff_t n) const;
|
||||
ptrdiff_t operator - (const SciSwigIterator& x) const;
|
||||
};
|
||||
}
|
||||
6
Lib/scilab/scilab.swg
Normal file
6
Lib/scilab/scilab.swg
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
%include <typemaps/swigmacros.swg>
|
||||
%include <typemaps/fragments.swg>
|
||||
%include <scimacros.swg>
|
||||
%include <sciruntime.swg>
|
||||
%include <scitypemaps.swg>
|
||||
|
||||
91
Lib/scilab/scilist.swg
Normal file
91
Lib/scilab/scilist.swg
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* Scilab list related functions
|
||||
*
|
||||
*/
|
||||
|
||||
%fragment("SWIG_ScilabList", "header")
|
||||
{
|
||||
SWIGINTERN int
|
||||
SWIG_GetScilabList(SwigSciObject obj, int **piListAddr)
|
||||
{
|
||||
SciErr sciErr;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, obj, piListAddr);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_GetScilabListSize(SwigSciObject obj, int *piListSize)
|
||||
{
|
||||
SciErr sciErr;
|
||||
int *piListAddr;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, obj, &piListAddr);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getListItemNumber(pvApiCtx, piListAddr, piListSize);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_GetScilabListAndSize(SwigSciObject obj, int **piListAddr, int *piListSize)
|
||||
{
|
||||
SciErr sciErr;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, obj, piListAddr);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getListItemNumber(pvApiCtx, *piListAddr, piListSize);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_CheckScilabList(SwigSciObject obj)
|
||||
{
|
||||
SciErr sciErr;
|
||||
int *piListAddr;
|
||||
int iType;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, obj, &piListAddr);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getVarType(pvApiCtx, piListAddr, &iType);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if ((iType != sci_list) && (iType != sci_tlist) && (iType != sci_mlist)) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A list is expected.\n"), SWIG_Scilab_GetFuncName(), obj);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
123
Lib/scilab/scilong.swg
Normal file
123
Lib/scilab/scilong.swg
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
/*
|
||||
* C-type: long
|
||||
* Scilab type: double or int32
|
||||
*/
|
||||
|
||||
%fragment(SWIG_AsVal_frag(long), "header", fragment="SWIG_SciDoubleOrInt32_AsLong", fragment="<limits.h>") {
|
||||
%#define SWIG_AsVal_long(scilabValue, valuePointer) SWIG_SciDoubleOrInt32_AsLong(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName());
|
||||
}
|
||||
%fragment("SWIG_SciDoubleOrInt32_AsLong", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciDoubleOrInt32_AsLong(void *pvApiCtx, SwigSciObject iVar, long *plValue, char *fname) {
|
||||
SciErr sciErr;
|
||||
int iType = 0;
|
||||
int iRows = 0;
|
||||
int iCols = 0;
|
||||
int *piAddrVar = NULL;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (iType == sci_ints) {
|
||||
int iPrec = 0;
|
||||
int *piData = NULL;
|
||||
|
||||
sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iPrec != SCI_INT32) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 32-bit signed integer or a double expected.\n"), fname, iVar);
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
sciErr = getMatrixOfInteger32(pvApiCtx, piAddrVar, &iRows, &iCols, &piData);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iRows * iCols != 1) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 32-bit signed integer or a double expected.\n"), fname, iVar);
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
*plValue = (long) *piData;
|
||||
}
|
||||
else if (iType == sci_matrix) {
|
||||
double *pdData = NULL;
|
||||
double dValue = 0.0f;
|
||||
|
||||
sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, &iRows, &iCols, &pdData);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iRows * iCols != 1) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 32-bit signed integer or a double expected.\n"), fname, iVar);
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
dValue = *pdData;
|
||||
if (dValue != floor(dValue)) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Incorrect value for input argument #%d: The double value cannot be converted to a 32-bit signed integer.\n"), fname, iVar);
|
||||
return SWIG_ValueError;
|
||||
}
|
||||
if ((dValue < LONG_MIN) || (dValue > LONG_MAX)) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Overflow error for input argument #%d: The double value cannot be converted to a 32-bit signed integer.\n"), fname, iVar);
|
||||
return SWIG_OverflowError;
|
||||
}
|
||||
*plValue = (long) dValue;
|
||||
}
|
||||
else {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 32-bit signed integer or a double expected.\n"), fname, iVar);
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_frag(long), "header", fragment="SWIG_SciDouble_FromLong") {
|
||||
%#define SWIG_From_long(scilabValue) SWIG_SciDouble_FromLong(pvApiCtx, SWIG_Scilab_GetOutputPosition(), scilabValue, SWIG_Scilab_GetFuncName())
|
||||
}
|
||||
%fragment("SWIG_SciDouble_FromLong", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciDouble_FromLong(void *pvApiCtx, int iVarOut, long lValue, char *fname) {
|
||||
if (createScalarDouble(pvApiCtx,
|
||||
SWIG_NbInputArgument(pvApiCtx) + iVarOut, (double) lValue))
|
||||
return SWIG_ERROR;
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
%fragment("SWIG_SciDouble_FromLongArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciDouble_FromLongArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, const long *plData) {
|
||||
SciErr sciErr;
|
||||
int i;
|
||||
double *pdValues = NULL;
|
||||
|
||||
pdValues = (double*) malloc(iRows * iCols * sizeof(double));
|
||||
for (i=0; i<iRows * iCols; i++) {
|
||||
pdValues[i] = plData[i];
|
||||
}
|
||||
|
||||
sciErr = createMatrixOfDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, iRows, iCols, pdValues);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
free(pdValues);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
free(pdValues);
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
54
Lib/scilab/scilonglong.swg
Normal file
54
Lib/scilab/scilonglong.swg
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* C-type: long long
|
||||
* Scilab 5 type: NONE
|
||||
* Scilab 6 type: int64
|
||||
*/
|
||||
%fragment(SWIG_AsVal_frag(long long), "header", fragment="SWIG_SciInt64_ToLongLong") {
|
||||
%#define SWIG_AsVal_long_SS_long(scilabValue, valuePointer) SWIG_SciInt64_ToLongLong(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName())
|
||||
}
|
||||
%fragment("SWIG_SciInt64_ToLongLong", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciInt64_ToLongLong(void *pvApiCtx, int iVar, long long *pllValue, char *fname) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Scilab 5.X does not manage '%s' data type.\n"), "SWIG_SciInt64_ToLongLong", "int64");
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_frag(long long), "header", fragment="SWIG_SciInt64_FromLongLong") {
|
||||
#define SWIG_From_long_SS_long(value) SWIG_SciInt64_FromLongLong(pvApiCtx, $result, value)
|
||||
}
|
||||
%fragment("SWIG_SciInt64_FromLongLong", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciInt64_FromLongLong(void *pvApiCtx, int iVarOut, long long llValue) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Scilab 5.X does not manage '%s' data type.\n"), "SWIG_SciInt64_ToLongLong", "int64");
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* C-type: unsigned long long
|
||||
* Scilab 5 type: NONE
|
||||
* Scilab 6 type: uint64
|
||||
*/
|
||||
%fragment(SWIG_AsVal_frag(unsigned long long), "header", fragment="SWIG_SciUint64_ToUnsignedLongLong") {
|
||||
#define SWIG_AsVal_unsigned_SS_long_SS_long(scilabValue, valuePointer) SWIG_SciUint64_ToUnsignedLongLong(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName())
|
||||
}
|
||||
%fragment("SWIG_SciUint64_ToUnsignedLongLong", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciUint64_ToUnsignedLongLong(void *pvApiCtx, int iVar, unsigned long long *pullValue, char *fname) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Scilab 5.X does not manage '%s' data type.\n"), "SWIG_SciUint64_ToLongLong", "uint64");
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_frag(unsigned long long), "header", fragment="SWIG_SciUint64_FromUnsignedLongLong") {
|
||||
#define SWIG_From_unsigned_SS_long_SS_long(value) SWIG_SciUint64_FromUnsignedLongLong(pvApiCtx, $result, value)
|
||||
}
|
||||
%fragment("SWIG_SciUint64_FromUnsignedLongLong", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciUint64_FromUnsignedLongLong(void *pvApiCtx, int iVarOut, unsigned long long llValue) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Scilab 5.X does not manage '%s' data type.\n"), "SWIG_SciUint64_ToLongLong", "uint64");
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
5
Lib/scilab/scimacros.swg
Normal file
5
Lib/scilab/scimacros.swg
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#define %scilabconst(flag) %feature("scilab:const","flag")
|
||||
|
||||
// Create Scilab variable
|
||||
#define SWIG_CreateScilabVariable_frag(Type...) %fragment_name(CreateScilabVariable, Type)
|
||||
#define SWIG_CreateScilabVariable_dec(Type...) %symbol_name(CreateScilabVariable, Type)
|
||||
170
Lib/scilab/scimatrixbool.swg
Normal file
170
Lib/scilab/scimatrixbool.swg
Normal file
|
|
@ -0,0 +1,170 @@
|
|||
/*
|
||||
* C-type: bool array
|
||||
* Scilab type: bool matrix
|
||||
*/
|
||||
|
||||
%include <scibool.swg>
|
||||
|
||||
// in (bool *IN, int IN_ROWCOUNT, int IN_COLCOUNT)
|
||||
|
||||
%typemap(in, noblock=1, fragment="SWIG_SciBoolean_AsBoolArrayAndSize") (bool *IN, int IN_ROWCOUNT, int IN_COLCOUNT)
|
||||
{
|
||||
if (SWIG_SciBoolean_AsBoolArrayAndSize(pvApiCtx, $input, &$2, &$3, &$1, fname) != SWIG_OK) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
// in (int IN_ROWCOUNT, int IN_COLCOUNT, bool *IN)
|
||||
|
||||
%typemap(in, noblock=1, fragment="SWIG_SciBoolean_AsBoolArrayAndSize") (int IN_ROWCOUNT, int IN_COLCOUNT, bool *IN)
|
||||
{
|
||||
if (SWIG_SciBoolean_AsBoolArrayAndSize(pvApiCtx, $input, &$1, &$2, &$3, fname) != SWIG_OK) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
// in (bool *IN, int IN_SIZE)
|
||||
|
||||
%typemap(in, noblock=1, fragment="SWIG_SciBoolean_AsBoolArrayAndSize") (bool *IN, int IN_SIZE) (int rowCount, int colCount)
|
||||
{
|
||||
if (SWIG_SciBoolean_AsBoolArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$1, fname) == SWIG_OK) {
|
||||
$2 = rowCount * colCount;
|
||||
}
|
||||
else {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
// in (int IN_SIZE, bool *IN)
|
||||
|
||||
%typemap(in, noblock=1) (int IN_SIZE, bool *IN) (int rowCount, int colCount)
|
||||
{
|
||||
if (SWIG_SciBoolean_AsBoolArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$2, fname) == SWIG_OK) {
|
||||
$1 = rowCount * colCount;
|
||||
}
|
||||
else {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
// out (bool **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
|
||||
|
||||
%typemap(in, noblock=1, numinputs=0) (bool **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
|
||||
{
|
||||
}
|
||||
|
||||
%typemap(arginit, noblock=1) (bool **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
|
||||
{
|
||||
$1 = (bool**) malloc(sizeof(bool*));
|
||||
$2 = (int*) malloc(sizeof(int));
|
||||
$3 = (int*) malloc(sizeof(int));
|
||||
}
|
||||
|
||||
%typemap(freearg, noblock=1) (bool **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
|
||||
{
|
||||
free(*$1);
|
||||
free($1);
|
||||
free($2);
|
||||
free($3);
|
||||
}
|
||||
|
||||
%typemap(argout, noblock=1, fragment="SWIG_SciBoolean_FromBoolArrayAndSize") (bool **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
|
||||
{
|
||||
if (SWIG_SciBoolean_FromBoolArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$2, *$3, *$1) == SWIG_OK) {
|
||||
SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
|
||||
}
|
||||
else {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
// out (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, bool **OUT)
|
||||
|
||||
%typemap(in, noblock=1, numinputs=0) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, bool **OUT)
|
||||
{
|
||||
}
|
||||
|
||||
%typemap(arginit, noblock=1) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, bool **OUT)
|
||||
{
|
||||
$1 = (int*) malloc(sizeof(int));
|
||||
$2 = (int*) malloc(sizeof(int));
|
||||
$3 = (bool**) malloc(sizeof(bool*));
|
||||
}
|
||||
|
||||
%typemap(argout, noblock=1, fragment="SWIG_SciBoolean_FromBoolArrayAndSize") (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, bool **OUT)
|
||||
{
|
||||
if (SWIG_SciBoolean_FromBoolArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$1, *$2, *$3) == SWIG_OK) {
|
||||
SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
|
||||
}
|
||||
else {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(freearg, noblock=1) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, bool **OUT)
|
||||
{
|
||||
free($1);
|
||||
free($2);
|
||||
free(*$3);
|
||||
free($3);
|
||||
}
|
||||
|
||||
|
||||
// out (bool **OUT, int *OUT_SIZE)
|
||||
|
||||
%typemap(in, noblock=1, numinputs=0) (bool **OUT, int *OUT_SIZE)
|
||||
{
|
||||
}
|
||||
|
||||
%typemap(arginit, noblock=1) (bool **OUT, int *OUT_SIZE)
|
||||
{
|
||||
$1 = (bool**) malloc(sizeof(bool*));
|
||||
$2 = (int*) malloc(sizeof(int));
|
||||
}
|
||||
|
||||
%typemap(argout, noblock=1, fragment="SWIG_SciBoolean_FromBoolArrayAndSize") (bool **OUT, int *OUT_SIZE)
|
||||
{
|
||||
if (SWIG_SciBoolean_FromBoolArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$2, *$1) == SWIG_OK) {
|
||||
SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
|
||||
}
|
||||
else {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(freearg, noblock=1) (bool **OUT, int *OUT_SIZE)
|
||||
{
|
||||
free(*$1);
|
||||
free($1);
|
||||
free($2);
|
||||
}
|
||||
|
||||
|
||||
// out (int *OUT_SIZE, bool **OUT)
|
||||
|
||||
%typemap(in, noblock=1, numinputs=0) (int *OUT_SIZE, bool **OUT)
|
||||
{
|
||||
}
|
||||
|
||||
%typemap(arginit, noblock=1) (int *OUT_SIZE, bool **OUT)
|
||||
{
|
||||
$1 = (int*) malloc(sizeof(int));
|
||||
$2 = (bool**) malloc(sizeof(bool*));
|
||||
}
|
||||
|
||||
%typemap(argout, noblock=1, fragment="SWIG_SciBoolean_FromBoolArrayAndSize") (int *OUT_SIZE, bool **OUT)
|
||||
{
|
||||
if (SWIG_SciBoolean_FromBoolArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$1, *$2) == SWIG_OK) {
|
||||
SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
|
||||
}
|
||||
else {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(freearg, noblock=1) (int *OUT_SIZE, bool **OUT)
|
||||
{
|
||||
free($1);
|
||||
free(*$2);
|
||||
free($2);
|
||||
}
|
||||
199
Lib/scilab/scimatrixchar.swg
Normal file
199
Lib/scilab/scimatrixchar.swg
Normal file
|
|
@ -0,0 +1,199 @@
|
|||
/*
|
||||
* C-type: char*
|
||||
* Scilab type: string matrix
|
||||
*/
|
||||
|
||||
%include <scichar.swg>
|
||||
|
||||
// in (char **IN, int IN_ROWCOUNT, int IN_COLCOUNT)
|
||||
|
||||
%typemap(in, noblock=1, fragment="SWIG_SciString_AsCharPtrArrayAndSize") (char **IN, int IN_ROWCOUNT, int IN_COLCOUNT)
|
||||
{
|
||||
if (SWIG_SciString_AsCharPtrArrayAndSize(pvApiCtx, $input, &$2, &$3, &$1, fname) != SWIG_OK) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
// in (int IN_ROWCOUNT, int IN_COLCOUNT, char **IN)
|
||||
|
||||
%typemap(in, noblock=1, fragment="SWIG_SciString_AsCharPtrArrayAndSize") (int IN_ROWCOUNT, int IN_COLCOUNT, char **IN)
|
||||
{
|
||||
if (SWIG_SciString_AsCharPtrArrayAndSize(pvApiCtx, $input, &$1, &$2, &$3, fname) != SWIG_OK) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
// in (char **IN, int IN_SIZE)
|
||||
|
||||
%typemap(in, noblock=1, fragment="SWIG_SciString_AsCharPtrArrayAndSize") (char **IN, int IN_SIZE) (int rowCount, int colCount)
|
||||
{
|
||||
if (SWIG_SciString_AsCharPtrArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$1, fname) == SWIG_OK) {
|
||||
$2 = rowCount * colCount;
|
||||
}
|
||||
else {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
// in (int IN_SIZE, char **IN)
|
||||
|
||||
%typemap(in, noblock=1, fragment="SWIG_SciString_AsCharPtrArrayAndSize") (int IN_SIZE, char **IN) (int rowCount, int colCount)
|
||||
{
|
||||
if (SWIG_SciString_AsCharPtrArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$2, fname) == SWIG_OK) {
|
||||
$1 = rowCount * colCount;
|
||||
}
|
||||
else {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
// out (char ***OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
|
||||
|
||||
%typemap(in, noblock=1, numinputs=0) (char ***OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
|
||||
{
|
||||
}
|
||||
|
||||
%typemap(arginit, noblock=1) (char ***OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
|
||||
{
|
||||
$1 = (char***) malloc(sizeof(char**));
|
||||
$2 = (int*) malloc(sizeof(int));
|
||||
$3 = (int*) malloc(sizeof(int));
|
||||
}
|
||||
|
||||
%typemap(argout, noblock=1, fragment="SWIG_SciString_FromCharPtrArrayAndSize") (char ***OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
|
||||
{
|
||||
if (SWIG_SciString_FromCharPtrArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$2, *$3, *$1) == SWIG_OK) {
|
||||
SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
|
||||
}
|
||||
else {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(freearg, noblock=1) (char ***OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
|
||||
{
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < (*$2) * (*$3); i++)
|
||||
free((*$1)[i]);
|
||||
}
|
||||
free(*$1);
|
||||
free($1);
|
||||
free($2);
|
||||
free($3);
|
||||
}
|
||||
|
||||
// out (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, char ***OUT)
|
||||
|
||||
%typemap(in, noblock=1, numinputs=0) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, char ***OUT)
|
||||
{
|
||||
}
|
||||
|
||||
%typemap(arginit, noblock=1) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, char ***OUT)
|
||||
{
|
||||
$1 = (char***) malloc(sizeof(char**));
|
||||
$2 = (int*) malloc(sizeof(int));
|
||||
$3 = (int**) malloc(sizeof(int*));
|
||||
}
|
||||
|
||||
%typemap(argout, noblock=1, fragment="SWIG_SciString_FromCharPtrArrayAndSize") (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, char ***OUT)
|
||||
{
|
||||
if (SWIG_SciString_FromCharPtrArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$1, *$2, *$3) == SWIG_OK) {
|
||||
SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
|
||||
}
|
||||
else {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(freearg, noblock=1) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, char ***OUT)
|
||||
{
|
||||
free($1);
|
||||
free($2);
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < (*$1) * (*$2); i++)
|
||||
free((*$3)[i]);
|
||||
}
|
||||
free(*$3);
|
||||
free($3);
|
||||
}
|
||||
|
||||
|
||||
// out (char ***OUT, int *OUT_SIZE)
|
||||
|
||||
%typemap(in, noblock=1, numinputs=0) (char ***OUT, int *OUT_SIZE)
|
||||
{
|
||||
}
|
||||
|
||||
%typemap(arginit, noblock=1) (char ***OUT, int *OUT_SIZE)
|
||||
{
|
||||
$1 = (char***) malloc(sizeof(char**));
|
||||
$2 = (int*) malloc(sizeof(int));
|
||||
}
|
||||
|
||||
%typemap(freearg, noblock=1) (char ***OUT, int *OUT_SIZE)
|
||||
{
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < *$2; i++)
|
||||
free((*$1)[i]);
|
||||
}
|
||||
free(*$1);
|
||||
free($1);
|
||||
free($2);
|
||||
}
|
||||
|
||||
%typemap(argout, noblock=1, fragment="SWIG_SciString_FromCharPtrArrayAndSize") (char ***OUT, int *OUT_SIZE)
|
||||
{
|
||||
if (SWIG_SciString_FromCharPtrArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$2, *$1) == SWIG_OK) {
|
||||
SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
|
||||
}
|
||||
else {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
// in (int IN_SIZE, char **IN)
|
||||
|
||||
%typemap(in, noblock=1, fragment="SWIG_SciString_AsCharPtrArrayAndSize") (int IN_SIZE, char **IN)
|
||||
{
|
||||
if (SWIG_SciString_AsCharPtrArrayAndSize(pvApiCtx, $input, 1, &$1, &$2, fname) != SWIG_OK) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
// out (int *OUT_SIZE, char ***OUT)
|
||||
|
||||
%typemap(in, noblock=1, numinputs=0) (int *OUT_SIZE, char ***OUT)
|
||||
{
|
||||
}
|
||||
|
||||
%typemap(arginit, noblock=1) (int *OUT_SIZE, char ***OUT)
|
||||
{
|
||||
$1 = (int*) malloc(sizeof(int));
|
||||
$2 = (char***) malloc(sizeof(char**));
|
||||
}
|
||||
|
||||
%typemap(argout, noblock=1, fragment="SWIG_SciString_FromCharPtrArrayAndSize") (int *OUT_SIZE, char ***OUT)
|
||||
{
|
||||
if (SWIG_SciString_FromCharPtrArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$1, *$2) == SWIG_OK) {
|
||||
SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
|
||||
}
|
||||
else {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(freearg, noblock=1) (int *OUT_SIZE, char ***OUT)
|
||||
{
|
||||
free($1);
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < *$1; i++)
|
||||
free((*$2)[i]);
|
||||
}
|
||||
free(*$2);
|
||||
free($2);
|
||||
}
|
||||
|
||||
170
Lib/scilab/scimatrixdouble.swg
Normal file
170
Lib/scilab/scimatrixdouble.swg
Normal file
|
|
@ -0,0 +1,170 @@
|
|||
/*
|
||||
* C-type: double array
|
||||
* Scilab type: double matrix
|
||||
*/
|
||||
|
||||
%include <scidouble.swg>
|
||||
|
||||
// in (double *IN, int IN_ROWCOUNT, int IN_COLCOUNT)
|
||||
|
||||
%typemap(in, noblock=1, fragment="SWIG_SciDouble_AsDoubleArrayAndSize") (double *IN, int IN_ROWCOUNT, int IN_COLCOUNT)
|
||||
{
|
||||
if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &$2, &$3, &$1, fname) != SWIG_OK) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
// in (int IN_ROWCOUNT, int IN_COLCOUNT, double *IN)
|
||||
|
||||
%typemap(in, noblock=1, fragment="SWIG_SciDouble_AsDoubleArrayAndSize") (int IN_ROWCOUNT, int IN_COLCOUNT, double *IN)
|
||||
{
|
||||
if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &$1, &$2, &$3, fname) != SWIG_OK) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
// in (double *IN, int IN_SIZE)
|
||||
|
||||
%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;
|
||||
}
|
||||
else {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
// in (int IN_SIZE, double *IN)
|
||||
|
||||
%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;
|
||||
}
|
||||
else {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
// out (double **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
|
||||
|
||||
%typemap(in, noblock=1, numinputs=0) (double **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
|
||||
{
|
||||
}
|
||||
|
||||
%typemap(arginit, noblock=1) (double **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
|
||||
{
|
||||
$1 = (double**) malloc(sizeof(double*));
|
||||
$2 = (int*) malloc(sizeof(int));
|
||||
$3 = (int*) malloc(sizeof(int));
|
||||
}
|
||||
|
||||
%typemap(freearg, noblock=1) (double **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
|
||||
{
|
||||
free(*$1);
|
||||
free($1);
|
||||
free($2);
|
||||
free($3);
|
||||
}
|
||||
|
||||
%typemap(argout, noblock=1, fragment="SWIG_SciDouble_FromDoubleArrayAndSize") (double **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
|
||||
{
|
||||
if (SWIG_SciDouble_FromDoubleArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$2, *$3, *$1) == SWIG_OK) {
|
||||
SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
|
||||
}
|
||||
else {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
// out (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, double **OUT)
|
||||
|
||||
%typemap(in, noblock=1, numinputs=0) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, double **OUT)
|
||||
{
|
||||
}
|
||||
|
||||
%typemap(arginit, noblock=1) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, double **OUT)
|
||||
{
|
||||
$1 = (int*) malloc(sizeof(int));
|
||||
$2 = (int*) malloc(sizeof(int));
|
||||
$3 = (double**) malloc(sizeof(double*));
|
||||
}
|
||||
|
||||
%typemap(argout, noblock=1, fragment="SWIG_SciDouble_FromDoubleArrayAndSize") (int *IN_ROWCOUNT, int *IN_COLCOUNT, double **OUT)
|
||||
{
|
||||
if (SWIG_SciDouble_FromDoubleArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$1, *$2, *$3) == SWIG_OK) {
|
||||
SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
|
||||
}
|
||||
else {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(freearg, noblock=1) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, double **OUT)
|
||||
{
|
||||
free($1);
|
||||
free($2);
|
||||
free(*$3);
|
||||
free($3);
|
||||
}
|
||||
|
||||
|
||||
// out (double **OUT, int *OUT_SIZE)
|
||||
|
||||
%typemap(in, noblock=1, numinputs=0) (double **OUT, int *OUT_SIZE)
|
||||
{
|
||||
}
|
||||
|
||||
%typemap(arginit, noblock=1) (double **OUT, int *OUT_SIZE)
|
||||
{
|
||||
$1 = (double**) malloc(sizeof(double*));
|
||||
$2 = (int*) malloc(sizeof(int));
|
||||
}
|
||||
|
||||
%typemap(argout, noblock=1, fragment="SWIG_SciDouble_FromDoubleArrayAndSize") (double **OUT, int *OUT_SIZE)
|
||||
{
|
||||
if (SWIG_SciDouble_FromDoubleArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$2, *$1) == SWIG_OK) {
|
||||
SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
|
||||
}
|
||||
else {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(freearg, noblock=1) (double **OUT, int *OUT_SIZE)
|
||||
{
|
||||
free(*$1);
|
||||
free($1);
|
||||
free($2);
|
||||
}
|
||||
|
||||
|
||||
// out (int *OUT_SIZE, double **OUT)
|
||||
|
||||
%typemap(in, noblock=1, numinputs=0) (int *OUT_SIZE, double **OUT)
|
||||
{
|
||||
}
|
||||
|
||||
%typemap(arginit, noblock=1) (int *OUT_SIZE, double **OUT)
|
||||
{
|
||||
$1 = (int*) malloc(sizeof(int));
|
||||
$2 = (double**) malloc(sizeof(double*));
|
||||
}
|
||||
|
||||
%typemap(argout, noblock=1, fragment="SWIG_SciDouble_FromDoubleArrayAndSize") (int *OUT_SIZE, double **OUT)
|
||||
{
|
||||
if (SWIG_SciDouble_FromDoubleArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$1, *$2) == SWIG_OK) {
|
||||
SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
|
||||
}
|
||||
else {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(freearg, noblock=1) (int *OUT_SIZE, double **OUT)
|
||||
{
|
||||
free($1);
|
||||
free(*$2);
|
||||
free($2);
|
||||
}
|
||||
175
Lib/scilab/scimatrixint.swg
Normal file
175
Lib/scilab/scimatrixint.swg
Normal file
|
|
@ -0,0 +1,175 @@
|
|||
/*
|
||||
* C-type: int array
|
||||
* Scilab type: 32-bit integer matrix
|
||||
*/
|
||||
|
||||
%include <sciint.swg>
|
||||
|
||||
// in (int *IN, int IN_ROWCOUNT, int IN_COLCOUNT)
|
||||
|
||||
%typemap(in, noblock=1, fragment="SWIG_SciDoubleOrInt32_AsIntArrayAndSize") (int *IN, int IN_ROWCOUNT, int IN_COLCOUNT)
|
||||
{
|
||||
if (SWIG_SciDoubleOrInt32_AsIntArrayAndSize(pvApiCtx, $input, &$2, &$3, &$1, fname) != SWIG_OK) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// in (int IN_ROWCOUNT, int IN_COLCOUNT, int *IN)
|
||||
|
||||
%typemap(in, noblock=1, fragment="SWIG_SciDoubleOrInt32_AsIntArrayAndSize") (int IN_ROWCOUNT, int IN_COLCOUNT, int *IN)
|
||||
{
|
||||
if (SWIG_SciDoubleOrInt32_AsIntArrayAndSize(pvApiCtx, $input, &$1, &$2, &$3, fname) != SWIG_OK) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// in (int *IN, int IN_SIZE)
|
||||
|
||||
%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;
|
||||
}
|
||||
else {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// in (int IN_SIZE, int *IN)
|
||||
|
||||
%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;
|
||||
}
|
||||
else {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
// out (int **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
|
||||
|
||||
%typemap(in, noblock=1, numinputs=0) (int **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
|
||||
{
|
||||
}
|
||||
|
||||
%typemap(arginit, noblock=1) (int **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
|
||||
{
|
||||
$1 = (int**) malloc(sizeof(int*));
|
||||
$2 = (int*) malloc(sizeof(int));
|
||||
$3 = (int*) malloc(sizeof(int));
|
||||
}
|
||||
|
||||
%typemap(argout, noblock=1, fragment="SWIG_SciDouble_FromIntArrayAndSize") (int **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
|
||||
{
|
||||
if (SWIG_SciDouble_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$2, *$3, *$1) == SWIG_OK) {
|
||||
SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
|
||||
}
|
||||
else {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(freearg, noblock=1) (int **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
|
||||
{
|
||||
free(*$1);
|
||||
free($1);
|
||||
free($2);
|
||||
free($3);
|
||||
}
|
||||
|
||||
|
||||
// out (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, int **OUT)
|
||||
|
||||
%typemap(in, noblock=1, numinputs=0) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, int **OUT)
|
||||
{
|
||||
}
|
||||
|
||||
%typemap(arginit, noblock=1) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, int **OUT)
|
||||
{
|
||||
$1 = (int*) malloc(sizeof(int));
|
||||
$2 = (int*) malloc(sizeof(int));
|
||||
$3 = (int**) malloc(sizeof(int*));
|
||||
}
|
||||
|
||||
%typemap(argout, noblock=1, fragment="SWIG_SciDouble_FromIntArrayAndSize") (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, int **OUT)
|
||||
{
|
||||
if (SWIG_SciDouble_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$1, *$2, *$3) == SWIG_OK) {
|
||||
SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
|
||||
}
|
||||
else {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(freearg, noblock=1) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, int **OUT)
|
||||
{
|
||||
free($1);
|
||||
free($2);
|
||||
free(*$3);
|
||||
free($3);
|
||||
}
|
||||
|
||||
|
||||
// out (int **OUT, int *OUT_SIZE)
|
||||
|
||||
%typemap(in, noblock=1, numinputs=0) (int **OUT, int *OUT_SIZE)
|
||||
{
|
||||
}
|
||||
|
||||
%typemap(arginit) (int **OUT, int *OUT_SIZE)
|
||||
{
|
||||
$1 = (int**) malloc(sizeof(int*));
|
||||
$2 = (int*) malloc(sizeof(int));
|
||||
}
|
||||
|
||||
%typemap(argout, noblock=1, fragment="SWIG_SciDouble_FromIntArrayAndSize") (int **OUT, int *OUT_SIZE)
|
||||
{
|
||||
if (SWIG_SciDouble_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$2, *$1) == SWIG_OK) {
|
||||
SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
|
||||
}
|
||||
else {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(freearg, noblock=1) (int **OUT, int *OUT_SIZE)
|
||||
{
|
||||
free(*$1);
|
||||
free($1);
|
||||
free($2);
|
||||
}
|
||||
|
||||
|
||||
// out (int *OUT_SIZE, int **OUT)
|
||||
|
||||
%typemap(in, noblock=1, numinputs=0) (int *OUT_SIZE, int **OUT)
|
||||
{
|
||||
}
|
||||
|
||||
%typemap(arginit, noblock=1) (int *OUT_SIZE, int **OUT)
|
||||
{
|
||||
$1 = (int*) malloc(sizeof(int));
|
||||
$2 = (int**) malloc(sizeof(int*));
|
||||
}
|
||||
|
||||
%typemap(argout, noblock=1, fragment="SWIG_SciDouble_FromIntArrayAndSize") (int *OUT_SIZE, int **OUT)
|
||||
{
|
||||
if (SWIG_SciDouble_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$1, *$2) == SWIG_OK) {
|
||||
SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
|
||||
}
|
||||
else {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(freearg, noblock=1) (int *IN_SIZE, int **OUT)
|
||||
{
|
||||
free($1);
|
||||
free(*$2);
|
||||
free($2);
|
||||
}
|
||||
|
||||
69
Lib/scilab/scimisctypes.swg
Normal file
69
Lib/scilab/scimisctypes.swg
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
// Other primitive such as size_t and ptrdiff_t
|
||||
|
||||
/*
|
||||
* C-type: size_t
|
||||
* Scilab type: double or int32
|
||||
*/
|
||||
|
||||
%fragment(SWIG_AsVal_frag(size_t), "header", fragment="SWIG_Int_AsSize") {
|
||||
%#define SWIG_AsVal_size_t(scilabValue, valuePointer) SWIG_Int_AsSize(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName())
|
||||
}
|
||||
%fragment("SWIG_Int_AsSize", "header", fragment=SWIG_AsVal_frag(int))
|
||||
{
|
||||
SWIGINTERN int
|
||||
SWIG_Int_AsSize(void *pvApiCtx, SwigSciObject iVar, size_t *piValue, char *fname) {
|
||||
int iValue = 0;
|
||||
if (SWIG_AsVal_dec(int)(iVar, &iValue) != SWIG_OK)
|
||||
return SWIG_ERROR;
|
||||
|
||||
if (piValue)
|
||||
*piValue = (size_t) iValue;
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_frag(size_t), "header", fragment="SWIG_Int_FromSize") {
|
||||
%#define SWIG_From_size_t(scilabValue) SWIG_Int_FromSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), scilabValue, SWIG_Scilab_GetFuncName())
|
||||
}
|
||||
%fragment("SWIG_Int_FromSize", "header", fragment=SWIG_From_frag(int))
|
||||
{
|
||||
SWIGINTERN int
|
||||
SWIG_Int_FromSize(void *pvApiCtx, int iVarOut, size_t iValue, char *fname) {
|
||||
return SWIG_From_dec(int)((int)iValue);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* C-type: ptrdiff_t
|
||||
* Scilab type: double or int32
|
||||
*/
|
||||
|
||||
%fragment(SWIG_AsVal_frag(ptrdiff_t), "header", fragment="SWIG_Int_AsPtrDiff") {
|
||||
%#define SWIG_AsVal_ptrdiff_t(scilabValue, valuePointer) SWIG_Int_AsPtrDiff(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName())
|
||||
}
|
||||
%fragment("SWIG_Int_AsPtrDiff", "header", fragment=SWIG_AsVal_frag(int))
|
||||
{
|
||||
SWIGINTERN int
|
||||
SWIG_Int_AsPtrDiff(void *pvApiCtx, SwigSciObject iVar, ptrdiff_t *piValue, char *fname) {
|
||||
int iValue = 0;
|
||||
if (SWIG_AsVal_dec(int)(iVar, &iValue) != SWIG_OK)
|
||||
return SWIG_ERROR;
|
||||
|
||||
if (piValue)
|
||||
*piValue = (ptrdiff_t) iValue;
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_frag(ptrdiff_t), "header", fragment="SWIG_Int_FromPtrDiff") {
|
||||
%#define SWIG_From_ptrdiff_t(scilabValue) SWIG_Int_FromPtrDiff(pvApiCtx, SWIG_Scilab_GetOutputPosition(), scilabValue, SWIG_Scilab_GetFuncName())
|
||||
}
|
||||
%fragment("SWIG_Int_FromPtrDiff", "header", fragment=SWIG_From_frag(int)) {
|
||||
SWIGINTERN int
|
||||
SWIG_Int_FromPtrDiff(void *pvApiCtx, int iVarOut, ptrdiff_t iValue, char *fname) {
|
||||
return SWIG_From_dec(int)((int)iValue);
|
||||
}
|
||||
}
|
||||
|
||||
32
Lib/scilab/scipointer.swg
Normal file
32
Lib/scilab/scipointer.swg
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* POINTER
|
||||
*/
|
||||
%fragment("SWIG_ConvertPtr", "header") {
|
||||
#define SWIG_ConvertPtr(scilabValue, voidPointer, pointerDescriptor, flags) SwigScilabPtrToObject(pvApiCtx, scilabValue, voidPointer, pointerDescriptor, flags, SWIG_Scilab_GetFuncName())
|
||||
}
|
||||
|
||||
%fragment("SWIG_NewPointerObj", "header") {
|
||||
#define SWIG_NewPointerObj(pointer, pointerDescriptor, flags) SwigScilabPtrFromObject(pvApiCtx, SWIG_Scilab_GetOutputPosition(), pointer, pointerDescriptor, flags)
|
||||
}
|
||||
|
||||
/*
|
||||
* FUNCTION POINTER
|
||||
*/
|
||||
%fragment("SWIG_ConvertFunctionPtr", "header") {
|
||||
#define SWIG_ConvertFunctionPtr(scilabValue, voidPointer, pointerDescriptor) SwigScilabPtrToObject(pvApiCtx, scilabValue, voidPointer, pointerDescriptor, 0, SWIG_Scilab_GetFuncName())
|
||||
}
|
||||
|
||||
%fragment("SWIG_NewFunctionPtrObj", "header") {
|
||||
#define SWIG_NewFunctionPtrObj(pointer, pointerDescriptor) SwigScilabPtrFromObject(pvApiCtx, SWIG_Scilab_GetOutputPosition(), pointer, pointerDescriptor, 0)
|
||||
}
|
||||
// No fragment used here, the functions "SwigScilabPtrToObject" and "SwigScilabPtrFromObject" are defined in sciruntime.swg
|
||||
|
||||
/*
|
||||
* C++ member pointers, ie, member methods
|
||||
*/
|
||||
%fragment("SWIG_NewMemberObj", "header") {
|
||||
#define SWIG_NewMemberObj(ptr, sz, tp) SWIG_Scilab_NewMemberObj(pvApiCtx, $result, ptr, sz, tp)
|
||||
}
|
||||
%fragment("SWIG_ConvertMember", "header") {
|
||||
#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Scilab_ConvertPacked(pvApiCtx, obj, ptr, sz, ty, SWIG_Scilab_GetFuncName())
|
||||
}
|
||||
23
Lib/scilab/sciprimtypes.swg
Normal file
23
Lib/scilab/sciprimtypes.swg
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
%include <scidouble.swg>
|
||||
%include <scifloat.swg>
|
||||
|
||||
%include <scilonglong.swg>
|
||||
|
||||
%include <sciint.swg>
|
||||
%include <sciunsignedint.swg>
|
||||
|
||||
%include <scilong.swg>
|
||||
%include <sciunsignedlong.swg>
|
||||
|
||||
%include <scishort.swg>
|
||||
%include <sciunsignedshort.swg>
|
||||
|
||||
%include <scichar.swg>
|
||||
%include <scisignedchar.swg>
|
||||
%include <sciunsignedchar.swg>
|
||||
|
||||
%include <scimisctypes.swg>
|
||||
|
||||
%include <scipointer.swg>
|
||||
%include <scibool.swg>
|
||||
|
||||
318
Lib/scilab/scirun.swg
Normal file
318
Lib/scilab/scirun.swg
Normal file
|
|
@ -0,0 +1,318 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* Scilab support runtime
|
||||
* -----------------------------------------------------------------------------*/
|
||||
|
||||
/* Scilab version macro */
|
||||
|
||||
#include "version.h"
|
||||
#define SWIG_SCILAB_VERSION (SCI_VERSION_MAJOR * 100) + (SCI_VERSION_MINOR * 10) + SCI_VERSION_MAINTENANCE
|
||||
|
||||
/* Scilab standard headers */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include "api_scilab.h"
|
||||
#if SWIG_SCILAB_VERSION < 540
|
||||
#define __USE_DEPRECATED_STACK_FUNCTIONS__
|
||||
#include "stack-c.h"
|
||||
#endif
|
||||
#include "MALLOC.h"
|
||||
#include "Scierror.h"
|
||||
#include "localization.h"
|
||||
#include "freeArrayOfString.h"
|
||||
#include <sci_gateway.h>
|
||||
#include <mex.h>
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Gateway signature */
|
||||
|
||||
#if SWIG_SCILAB_VERSION >= 600
|
||||
#define SWIG_GatewayParameters char* fname, void *pvApiCtx
|
||||
#define SWIG_GatewayArguments fname, pvApiCtx
|
||||
#else
|
||||
#define SWIG_GatewayParameters char* fname, unsigned long fname_len
|
||||
#define SWIG_GatewayArguments fname, fname_len
|
||||
#endif
|
||||
|
||||
/* Function name management functions */
|
||||
|
||||
#include <stdlib.h>
|
||||
static char *SwigFuncName = NULL;
|
||||
static char *SWIG_Scilab_GetFuncName(void) {
|
||||
return SwigFuncName;
|
||||
}
|
||||
static void SWIG_Scilab_SetFuncName(char *funcName) {
|
||||
if (SwigFuncName != NULL) {
|
||||
free(SwigFuncName);
|
||||
}
|
||||
SwigFuncName = strdup(funcName);
|
||||
}
|
||||
|
||||
/* Api context management functions */
|
||||
|
||||
#if SWIG_SCILAB_VERSION >= 600
|
||||
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_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
|
||||
#define SWIG_CheckInputArgument(pvApiCtx, minInputArgument, maxInputArgument) CheckRhs(minInputArgument, maxInputArgument)
|
||||
#define SWIG_CheckOutputArgument(pvApiCtx, minOutputArgument, maxOutputArgument) CheckLhs(minOutputArgument, maxOutputArgument)
|
||||
#define SWIG_NbInputArgument(pvApiCtx) Rhs
|
||||
#define SWIG_AssignOutputArgument(pvApiCtx, outputArgumentPos, argumentPos) LhsVar(outputArgumentPos) = argumentPos
|
||||
#endif
|
||||
|
||||
typedef int SwigSciObject;
|
||||
|
||||
static int SwigOutputPosition = -1;
|
||||
static int SWIG_Scilab_GetOutputPosition(void) {
|
||||
return SwigOutputPosition;
|
||||
}
|
||||
static void SWIG_Scilab_SetOutputPosition(int outputPosition) {
|
||||
SwigOutputPosition = outputPosition;
|
||||
}
|
||||
|
||||
SWIGRUNTIME int
|
||||
SWIG_Scilab_SetOutput(void *pvApiCtx, SwigSciObject output) {
|
||||
int outputPosition = SWIG_Scilab_GetOutputPosition();
|
||||
if (outputPosition < 0)
|
||||
return SWIG_ERROR;
|
||||
SWIG_AssignOutputArgument(pvApiCtx, outputPosition,
|
||||
SWIG_NbInputArgument(pvApiCtx) + outputPosition);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
||||
/* Pointer conversion functions */
|
||||
|
||||
SWIGINTERN int
|
||||
SwigScilabPtrToObject(void *pvApiCtx, int iVar, void **pObjValue, swig_type_info *descriptor, int flags, char *fname) {
|
||||
SciErr sciErr;
|
||||
int iType = 0;
|
||||
int *piAddrVar = NULL;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (iType == sci_pointer) {
|
||||
sciErr = getPointer(pvApiCtx, piAddrVar, pObjValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
SWIGRUNTIMEINLINE int
|
||||
SwigScilabPtrFromObject(void *pvApiCtx, int iVarOut, void *obj, swig_type_info *descriptor, int flags) {
|
||||
SciErr sciErr;
|
||||
|
||||
sciErr = createPointer(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, (void *)obj);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
SWIGRUNTIME int
|
||||
SWIG_Scilab_ConvertPacked(void *pvApiCtx, int iVar, void *ptr, int sz, swig_type_info *ty, char *fname) {
|
||||
swig_cast_info *tc;
|
||||
int *piAddrVar = NULL;
|
||||
char *pstStrings = NULL;
|
||||
SciErr sciErr;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (getAllocatedSingleString(pvApiCtx, piAddrVar, &pstStrings)) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
/* Pointer values must start with leading underscore */
|
||||
if (*pstStrings != '_') {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
pstStrings++;
|
||||
pstStrings = (char*)SWIG_UnpackData(pstStrings, ptr, sz);
|
||||
|
||||
if (ty) {
|
||||
if (!pstStrings) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
tc = SWIG_TypeCheck(pstStrings, ty);
|
||||
if (!tc) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
SWIGRUNTIME int
|
||||
SWIG_Scilab_NewMemberObj(void *pvApiCtx, int iVarOut, void *ptr, int sz, swig_type_info *type) {
|
||||
char result[1024];
|
||||
char *r = result;
|
||||
|
||||
if ((2*sz + 1 + strlen(type->name)) > 1000) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
*(r++) = '_';
|
||||
r = SWIG_PackData(r, ptr, sz);
|
||||
strcpy(r, type->name);
|
||||
|
||||
if (createSingleString(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, &result[0]))
|
||||
return SWIG_ERROR;
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
||||
/* Error functions */
|
||||
|
||||
#define SCILAB_API_ARGUMENT_ERROR 999
|
||||
|
||||
SWIGINTERN const char*
|
||||
SWIG_Scilab_ErrorType(int code) {
|
||||
switch(code) {
|
||||
case SWIG_MemoryError:
|
||||
return "MemoryError";
|
||||
case SWIG_IOError:
|
||||
return "IOError";
|
||||
case SWIG_RuntimeError:
|
||||
return "RuntimeError";
|
||||
case SWIG_IndexError:
|
||||
return "IndexError";
|
||||
case SWIG_TypeError:
|
||||
return "TypeError";
|
||||
case SWIG_DivisionByZero:
|
||||
return "ZeroDivisionError";
|
||||
case SWIG_OverflowError:
|
||||
return "OverflowError";
|
||||
case SWIG_SyntaxError:
|
||||
return "SyntaxError";
|
||||
case SWIG_ValueError:
|
||||
return "ValueError";
|
||||
case SWIG_SystemError:
|
||||
return "SystemError";
|
||||
case SWIG_AttributeError:
|
||||
return "AttributeError";
|
||||
default:
|
||||
return "RuntimeError";
|
||||
}
|
||||
}
|
||||
#define SWIG_ErrorType(code) SWIG_Scilab_ErrorType(code)
|
||||
|
||||
#ifndef SWIG_SCILAB_ERROR
|
||||
#define SWIG_SCILAB_ERROR 20000
|
||||
#endif
|
||||
|
||||
SWIGINTERN void
|
||||
SWIG_Scilab_Error(int code, const char *msg)
|
||||
{
|
||||
Scierror(SWIG_SCILAB_ERROR - code, _("SWIG/Scilab: %s: %s\n"), SWIG_Scilab_ErrorType(code), msg);
|
||||
}
|
||||
|
||||
#define SWIG_Error(code, msg) SWIG_Scilab_Error(code, msg)
|
||||
|
||||
#define SWIG_fail return SWIG_ERROR;
|
||||
|
||||
SWIGRUNTIME void
|
||||
SWIG_Scilab_Raise_Ex(const char *obj, const char *type, swig_type_info *descriptor) {
|
||||
if (type) {
|
||||
if (obj)
|
||||
Scierror(SWIG_SCILAB_ERROR, "SWIG/Scilab: Exception (%s) occured: %s\n", type, obj);
|
||||
else
|
||||
Scierror(SWIG_SCILAB_ERROR, "SWIG/Scilab: Exception (%s) occured.\n", type);
|
||||
}
|
||||
}
|
||||
|
||||
SWIGRUNTIME void
|
||||
SWIG_Scilab_Raise(const int obj, const char *type, swig_type_info *descriptor) {
|
||||
Scierror(SWIG_SCILAB_ERROR, "SWIG/Scilab: Exception (%s) occured.\n", type);
|
||||
}
|
||||
|
||||
/*
|
||||
* Pointer utility functions
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
int SWIG_this(SWIG_GatewayParameters) {
|
||||
void *ptrValue = NULL;
|
||||
if (SwigScilabPtrToObject(pvApiCtx, 1, &ptrValue, NULL, 0, fname) == SWIG_OK) {
|
||||
SWIG_Scilab_SetOutputPosition(1);
|
||||
return SWIG_Scilab_SetOutput(pvApiCtx,
|
||||
createScalarDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + 1,
|
||||
(double)(uintptr_t)ptrValue));
|
||||
}
|
||||
else {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Incorrect value for input argument #%d: The value is not a pointer.\n"), fname, 1);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
int SWIG_ptr(SWIG_GatewayParameters) {
|
||||
double dValue = 0;
|
||||
int *piAddr;
|
||||
SciErr sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
|
||||
if(sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (getScalarDouble(pvApiCtx, piAddr, &dValue) == 0) {
|
||||
if (dValue != (uintptr_t)dValue) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Incorrect value for input argument #%d: The double value cannot be converted to a pointer.\n"), fname, 1);
|
||||
return SWIG_ValueError;
|
||||
}
|
||||
if ((dValue < 0) || (dValue > ULONG_MAX)) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Overflow error for input argument #%d: The double value cannot be converted to a pointer.\n"), fname, 1);
|
||||
return SWIG_OverflowError;
|
||||
}
|
||||
SWIG_Scilab_SetOutputPosition(1);
|
||||
return SWIG_Scilab_SetOutput(pvApiCtx,
|
||||
SwigScilabPtrFromObject(pvApiCtx, 1, (void *) (uintptr_t)dValue, NULL, 0));
|
||||
}
|
||||
else {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
33
Lib/scilab/sciruntime.swg
Normal file
33
Lib/scilab/sciruntime.swg
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
%insert(runtime) "swigrun.swg";
|
||||
%insert(runtime) "swigerrors.swg";
|
||||
|
||||
#define %scilabcode %insert("scilab")
|
||||
|
||||
%insert(runtime) "scirun.swg";
|
||||
|
||||
%init %{
|
||||
#define SWIG_GetModule(clientdata) SWIG_Scilab_GetModule()
|
||||
#define SWIG_SetModule(clientdata, pointer) SWIG_Scilab_SetModule(pointer)
|
||||
|
||||
SWIGRUNTIME swig_module_info*
|
||||
SWIG_Scilab_GetModule(void)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SWIGRUNTIME void
|
||||
SWIG_Scilab_SetModule(swig_module_info *swig_module)
|
||||
{
|
||||
}
|
||||
%}
|
||||
|
||||
%insert(init) "swiginit.swg"
|
||||
|
||||
%init %{
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
int <module>_Init(SWIG_GatewayParameters) {
|
||||
SWIG_InitializeModule(NULL);
|
||||
SWIG_CreateScilabVariables(pvApiCtx);
|
||||
%}
|
||||
195
Lib/scilab/scisequence.swg
Normal file
195
Lib/scilab/scisequence.swg
Normal file
|
|
@ -0,0 +1,195 @@
|
|||
/*
|
||||
*
|
||||
* Scilab sequence conversions
|
||||
*
|
||||
*/
|
||||
|
||||
#define SWIG_Traits_Sequence_frag(Type) %fragment_name(AsVal_Traits_Sequence, Type)
|
||||
|
||||
#define SWIG_AsCheck_Sequence_frag(Type...) %fragment_name(AsCheck_Sequence, Type)
|
||||
#define SWIG_AsCheck_Sequence_dec(Type...) %symbol_name(AsCheck_Sequence, Type)
|
||||
#define SWIG_AsGet_Sequence_frag(Type...) %fragment_name(AsGet_Sequence, Type)
|
||||
#define SWIG_AsGet_Sequence_dec(Type...) %symbol_name(AsGet_Sequence, Type)
|
||||
#define SWIG_AsSize_Sequence_frag(Type...) %fragment_name(AsSize_Sequence, Type)
|
||||
#define SWIG_AsSize_Sequence_dec(Type...) %symbol_name(AsSize_Sequence, Type)
|
||||
#define SWIG_FromCreate_Sequence_frag(Type...) %fragment_name(FromCreate_Sequence, Type)
|
||||
#define SWIG_FromCreate_Sequence_dec(Type...) %symbol_name(FromCreate_Sequence, Type)
|
||||
#define SWIG_FromSet_Sequence_frag(Type...) %fragment_name(FromSet_Sequence, Type)
|
||||
#define SWIG_FromSet_Sequence_dec(Type...) %symbol_name(FromSet_Sequence, Type)
|
||||
|
||||
#define SWIG_Traits_SequenceItem_frag(Type) %fragment_name(AsVal_Traits_SequenceItem, Type)
|
||||
#define SWIG_AsVal_SequenceItem_frag(Type...) %fragment_name(AsVal_SequenceItem, Type)
|
||||
#define SWIG_AsVal_SequenceItem_dec(Type...) %symbol_name(AsVal_SequenceItem, Type)
|
||||
#define SWIG_From_SequenceItem_frag(Type...) %fragment_name(From_SequenceItem, Type)
|
||||
#define SWIG_From_SequenceItem_dec(Type...) %symbol_name(From_SequenceItem, Type)
|
||||
|
||||
%include <scisequencepointer.swg>
|
||||
%include <scisequenceint.swg>
|
||||
%include <scisequencedouble.swg>
|
||||
%include <scisequencefloat.swg>
|
||||
%include <scisequencestring.swg>
|
||||
%include <scisequencebool.swg>
|
||||
|
||||
//
|
||||
// Sequence conversion
|
||||
//
|
||||
|
||||
%fragment(SWIG_Traits_Sequence_frag(ptr), "header",
|
||||
fragment=SWIG_AsCheck_Sequence_frag(ptr),
|
||||
fragment=SWIG_AsGet_Sequence_frag(ptr),
|
||||
fragment=SWIG_AsSize_Sequence_frag(ptr),
|
||||
fragment=SWIG_FromCreate_Sequence_frag(ptr),
|
||||
fragment=SWIG_FromSet_Sequence_frag(ptr),
|
||||
fragment="StdTraits",
|
||||
fragment="<stdint.h>") {
|
||||
|
||||
namespace swig {
|
||||
// Error returned for sequence containers of default item type
|
||||
template <typename T> struct traits_as_sequence {
|
||||
static int check(SwigSciObject obj) {
|
||||
SWIG_Error(SWIG_TypeError, type_name<T>());
|
||||
}
|
||||
static int get(SwigSciObject obj, void **sequence) {
|
||||
SWIG_Error(SWIG_TypeError, type_name<T>());
|
||||
}
|
||||
static int size(SwigSciObject obj, int *size) {
|
||||
SWIG_Error(SWIG_TypeError, type_name<T>());
|
||||
}
|
||||
};
|
||||
template <typename T> struct traits_from_sequence {
|
||||
static int create(int size, void **sequence) {
|
||||
SWIG_Error(SWIG_TypeError, type_name<T>());
|
||||
}
|
||||
static SwigSciObject set(int size, void *sequence) {
|
||||
SWIG_Error(SWIG_TypeError, type_name<T>());
|
||||
}
|
||||
};
|
||||
|
||||
// Support sequence containers of pointers
|
||||
template <typename T> struct traits_as_sequence<T*> {
|
||||
static int check(SwigSciObject obj) {
|
||||
return SWIG_AsCheck_Sequence_dec(ptr)(obj);
|
||||
}
|
||||
static int get(SwigSciObject obj, void **sequence) {
|
||||
return SWIG_AsGet_Sequence_dec(ptr)(obj, (int **)sequence);
|
||||
}
|
||||
static int size(SwigSciObject obj, int *size) {
|
||||
return SWIG_AsSize_Sequence_dec(ptr)(obj, size);
|
||||
}
|
||||
};
|
||||
template <typename T> struct traits_from_sequence<T*> {
|
||||
static int create(int size, void **sequence) {
|
||||
return SWIG_FromCreate_Sequence_dec(ptr)(size, (uintptr_t **)sequence);
|
||||
}
|
||||
static SwigSciObject set(int size, void *sequence) {
|
||||
return SWIG_FromSet_Sequence_dec(ptr)(size, (uintptr_t *)sequence);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%define %traits_sequence(CppType, ScilabType)
|
||||
%fragment(SWIG_Traits_Sequence_frag(CppType), "header",
|
||||
fragment=SWIG_Traits_Sequence_frag(ptr),
|
||||
fragment=SWIG_AsCheck_Sequence_frag(CppType),
|
||||
fragment=SWIG_AsGet_Sequence_frag(CppType),
|
||||
fragment=SWIG_AsSize_Sequence_frag(CppType),
|
||||
fragment=SWIG_FromCreate_Sequence_frag(CppType),
|
||||
fragment=SWIG_FromSet_Sequence_frag(CppType)) {
|
||||
|
||||
namespace swig {
|
||||
template <> struct traits_as_sequence<CppType > {
|
||||
static int check(SwigSciObject obj) {
|
||||
return SWIG_AsCheck_Sequence_dec(CppType)(obj);
|
||||
}
|
||||
static int get(SwigSciObject obj, void **sequence) {
|
||||
return SWIG_AsGet_Sequence_dec(CppType)(obj, (ScilabType **)sequence);
|
||||
}
|
||||
static int size(SwigSciObject obj, int *size) {
|
||||
return SWIG_AsSize_Sequence_dec(CppType)(obj, size);
|
||||
}
|
||||
};
|
||||
template <> struct traits_from_sequence<CppType > {
|
||||
static int create(int size, void **sequence) {
|
||||
return SWIG_FromCreate_Sequence_dec(CppType)(size, (ScilabType **)sequence);
|
||||
}
|
||||
static SwigSciObject set(int size, void *sequence) {
|
||||
return SWIG_FromSet_Sequence_dec(CppType)(size, (ScilabType *)sequence);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
%enddef
|
||||
|
||||
|
||||
//
|
||||
// Sequence item conversion
|
||||
//
|
||||
|
||||
%fragment(SWIG_Traits_SequenceItem_frag(ptr), "header",
|
||||
fragment=SWIG_AsVal_SequenceItem_frag(ptr),
|
||||
fragment=SWIG_From_SequenceItem_frag(ptr),
|
||||
fragment="StdTraits",
|
||||
fragment="<stdint.h>") {
|
||||
|
||||
namespace swig {
|
||||
// Error returned for sequence containers of default item type
|
||||
template <typename T> struct traits_asval_sequenceitem {
|
||||
static T asval(SwigSciObject obj, void *pSequence, int iItemIndex) {
|
||||
SWIG_Error(SWIG_TypeError, type_name<T>());
|
||||
}
|
||||
};
|
||||
template <typename T> struct traits_from_sequenceitem {
|
||||
static int from(void *pSequence, int iItemIndex, T itemValue) {
|
||||
SWIG_Error(SWIG_TypeError, type_name<T>());
|
||||
}
|
||||
};
|
||||
|
||||
// Support sequence containers of pointers
|
||||
template <typename T> struct traits_asval_sequenceitem<T*> {
|
||||
static T* asval(SwigSciObject obj, void *pSequence, int iItemIndex) {
|
||||
return static_cast<T*>(SWIG_AsVal_SequenceItem_dec(ptr)(obj, (int *)pSequence, iItemIndex));
|
||||
}
|
||||
};
|
||||
template <typename T> struct traits_from_sequenceitem<T*> {
|
||||
static int from(void *pSequence, int iItemIndex, T *itemValue) {
|
||||
return SWIG_From_SequenceItem_dec(ptr)((uintptr_t *)pSequence, iItemIndex, (uintptr_t) itemValue);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%define %traits_sequenceitem(CppType, ScilabType)
|
||||
%fragment(SWIG_Traits_SequenceItem_frag(CppType), "header",
|
||||
fragment=SWIG_Traits_SequenceItem_frag(ptr),
|
||||
fragment=SWIG_AsVal_SequenceItem_frag(CppType),
|
||||
fragment=SWIG_From_SequenceItem_frag(CppType)) {
|
||||
|
||||
namespace swig {
|
||||
template <> struct traits_asval_sequenceitem<CppType > {
|
||||
static CppType asval(SwigSciObject obj, void *pSequence, int iItemIndex) {
|
||||
return SWIG_AsVal_SequenceItem_dec(CppType)(obj, (ScilabType *)pSequence, iItemIndex);
|
||||
}
|
||||
};
|
||||
template <> struct traits_from_sequenceitem<CppType > {
|
||||
static int from(void *pSequence, int iItemIndex, CppType itemValue) {
|
||||
return SWIG_From_SequenceItem_dec(CppType)((ScilabType *)pSequence, iItemIndex, itemValue);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
%enddef
|
||||
|
||||
%define %add_traits_sequence(CppType, ScilabType)
|
||||
%traits_sequence(CppType, ScilabType);
|
||||
%fragment(SWIG_Traits_Sequence_frag(CppType));
|
||||
%traits_sequenceitem(CppType, ScilabType);
|
||||
%fragment(SWIG_Traits_SequenceItem_frag(CppType));
|
||||
%enddef
|
||||
|
||||
%add_traits_sequence(int, int);
|
||||
%add_traits_sequence(double, double);
|
||||
%add_traits_sequence(float, float);
|
||||
%add_traits_sequence(std::string, char*);
|
||||
%add_traits_sequence(bool, int);
|
||||
|
||||
98
Lib/scilab/scisequencebool.swg
Normal file
98
Lib/scilab/scisequencebool.swg
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
*
|
||||
* Scilab matrix of bool <-> C++ bool container
|
||||
*
|
||||
*/
|
||||
|
||||
%include <scibool.swg>
|
||||
|
||||
%fragment(SWIG_AsCheck_Sequence_frag(bool), "header") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsCheck_Sequence_dec(bool)(SwigSciObject obj) {
|
||||
SciErr sciErr;
|
||||
int *piAddrVar;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, obj, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (isBooleanType(pvApiCtx, piAddrVar)) {
|
||||
return SWIG_OK;
|
||||
}
|
||||
else {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A boolean is expected.\n"), SWIG_Scilab_GetFuncName(), obj);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsGet_Sequence_frag(bool), "header",
|
||||
fragment="SWIG_SciBoolean_AsIntArrayAndSize") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsGet_Sequence_dec(bool)(SwigSciObject obj, int **pSequence) {
|
||||
int iMatrixRowCount;
|
||||
int iMatrixColCount;
|
||||
return (SWIG_SciBoolean_AsIntArrayAndSize(pvApiCtx, obj, &iMatrixRowCount, &iMatrixColCount, pSequence, SWIG_Scilab_GetFuncName()));
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsSize_Sequence_frag(bool), "header",
|
||||
fragment="SWIG_SciBoolean_AsIntArrayAndSize") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsSize_Sequence_dec(bool)(SwigSciObject obj, int *piSize) {
|
||||
int *piMatrix;
|
||||
int iMatrixRowCount;
|
||||
int iMatrixColCount;
|
||||
if (SWIG_SciBoolean_AsIntArrayAndSize(pvApiCtx, obj, &iMatrixRowCount, &iMatrixColCount, &piMatrix, SWIG_Scilab_GetFuncName()) == SWIG_OK) {
|
||||
if ((iMatrixRowCount > 1) && (iMatrixColCount > 1)) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: An integer vector is expected.\n"), SWIG_Scilab_GetFuncName(), obj);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
*piSize = iMatrixRowCount * iMatrixColCount;
|
||||
return SWIG_OK;
|
||||
}
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_FromCreate_Sequence_frag(bool), "header") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_FromCreate_Sequence_dec(bool)(int size, int **pSequence) {
|
||||
*pSequence = new int[size];
|
||||
return *pSequence != NULL ? SWIG_OK : SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_FromSet_Sequence_frag(bool), "header",
|
||||
fragment="SWIG_SciBoolean_FromIntArrayAndSize") {
|
||||
|
||||
SWIGINTERN SwigSciObject
|
||||
SWIG_FromSet_Sequence_dec(bool)(int size, int *pSequence) {
|
||||
SwigSciObject obj = SWIG_SciBoolean_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, size, pSequence);
|
||||
delete (int *)pSequence;
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsVal_SequenceItem_frag(bool), "header") {
|
||||
|
||||
SWIGINTERN bool
|
||||
SWIG_AsVal_SequenceItem_dec(bool)(SwigSciObject obj, int *pSequence, int iItemIndex) {
|
||||
return pSequence[iItemIndex];
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_SequenceItem_frag(bool), "header") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_From_SequenceItem_dec(bool)(int *pSequence, int iItemIndex, bool itemValue) {
|
||||
pSequence[iItemIndex] = itemValue;
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
99
Lib/scilab/scisequencedouble.swg
Normal file
99
Lib/scilab/scisequencedouble.swg
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
*
|
||||
* Scilab matrix of double <-> C++ double container
|
||||
*
|
||||
*/
|
||||
|
||||
%include <scidouble.swg>
|
||||
|
||||
%fragment(SWIG_AsCheck_Sequence_frag(double), "header") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsCheck_Sequence_dec(double)(SwigSciObject obj) {
|
||||
SciErr sciErr;
|
||||
int *piAddrVar;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, obj, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (isDoubleType(pvApiCtx, piAddrVar)) {
|
||||
return SWIG_OK;
|
||||
}
|
||||
else {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A double is expected.\n"), SWIG_Scilab_GetFuncName(), obj);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsGet_Sequence_frag(double), "header",
|
||||
fragment="SWIG_SciDouble_AsDoubleArrayAndSize") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsGet_Sequence_dec(double)(SwigSciObject obj, double **pSequence) {
|
||||
int iMatrixRowCount;
|
||||
int iMatrixColCount;
|
||||
return (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, obj, &iMatrixRowCount, &iMatrixColCount, pSequence, SWIG_Scilab_GetFuncName()));
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsSize_Sequence_frag(double), "header",
|
||||
fragment="SWIG_SciDouble_AsDoubleArrayAndSize") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsSize_Sequence_dec(double)(SwigSciObject obj, int *piSize) {
|
||||
double *pdblMatrix;
|
||||
int iMatrixRowCount;
|
||||
int iMatrixColCount;
|
||||
if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, obj, &iMatrixRowCount, &iMatrixColCount, &pdblMatrix, SWIG_Scilab_GetFuncName()) == SWIG_OK) {
|
||||
if ((iMatrixRowCount > 1) && (iMatrixColCount > 1)) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A double vector is expected.\n"), SWIG_Scilab_GetFuncName(), obj);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
*piSize = iMatrixRowCount * iMatrixColCount;
|
||||
return SWIG_OK;
|
||||
}
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_FromCreate_Sequence_frag(double), "header") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_FromCreate_Sequence_dec(double)(int size, double **pSequence) {
|
||||
*pSequence = new double[size];
|
||||
return *pSequence != NULL ? SWIG_OK : SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_FromSet_Sequence_frag(double), "header",
|
||||
fragment="SWIG_SciDouble_FromDoubleArrayAndSize") {
|
||||
|
||||
SWIGINTERN SwigSciObject
|
||||
SWIG_FromSet_Sequence_dec(double)(int size, double *pSequence) {
|
||||
SwigSciObject obj = SWIG_SciDouble_FromDoubleArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, size, pSequence);
|
||||
delete (double *)pSequence;
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsVal_SequenceItem_frag(double), "header") {
|
||||
|
||||
SWIGINTERN double
|
||||
SWIG_AsVal_SequenceItem_dec(double)(SwigSciObject obj, double *pSequence, int iItemIndex) {
|
||||
return pSequence[iItemIndex];
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_SequenceItem_frag(double), "header") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_From_SequenceItem_dec(double)(double *pSequence, int iItemIndex, double itemValue) {
|
||||
pSequence[iItemIndex] = itemValue;
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
98
Lib/scilab/scisequencefloat.swg
Normal file
98
Lib/scilab/scisequencefloat.swg
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
*
|
||||
* Scilab matrix of float <-> C++ float container
|
||||
*
|
||||
*/
|
||||
|
||||
%include <scifloat.swg>
|
||||
|
||||
%fragment(SWIG_AsCheck_Sequence_frag(float), "header") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsCheck_Sequence_dec(float)(SwigSciObject obj) {
|
||||
SciErr sciErr;
|
||||
int *piAddrVar;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, obj, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (isDoubleType(pvApiCtx, piAddrVar)) {
|
||||
return SWIG_OK;
|
||||
}
|
||||
else {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A double is expected.\n"), SWIG_Scilab_GetFuncName(), obj);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsGet_Sequence_frag(float), "header",
|
||||
fragment="SWIG_SciDouble_AsFloatArrayAndSize") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsGet_Sequence_dec(float)(SwigSciObject obj, float **pSequence) {
|
||||
int iMatrixRowCount;
|
||||
int iMatrixColCount;
|
||||
return (SWIG_SciDouble_AsFloatArrayAndSize(pvApiCtx, obj, &iMatrixRowCount, &iMatrixColCount, pSequence, SWIG_Scilab_GetFuncName()));
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsSize_Sequence_frag(float), "header",
|
||||
fragment="SWIG_SciDouble_AsFloatArrayAndSize") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsSize_Sequence_dec(float)(SwigSciObject obj, int *piSize) {
|
||||
float *pdblMatrix;
|
||||
int iMatrixRowCount;
|
||||
int iMatrixColCount;
|
||||
if (SWIG_SciDouble_AsFloatArrayAndSize(pvApiCtx, obj, &iMatrixRowCount, &iMatrixColCount, &pdblMatrix, SWIG_Scilab_GetFuncName()) == SWIG_OK) {
|
||||
if ((iMatrixRowCount > 1) && (iMatrixColCount > 1)) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A float vector is expected.\n"), SWIG_Scilab_GetFuncName(), obj);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
*piSize = iMatrixRowCount * iMatrixColCount;
|
||||
return SWIG_OK;
|
||||
}
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_FromCreate_Sequence_frag(float), "header") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_FromCreate_Sequence_dec(float)(int size, float **pSequence) {
|
||||
*pSequence = new float[size];
|
||||
return *pSequence != NULL ? SWIG_OK : SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_FromSet_Sequence_frag(float), "header",
|
||||
fragment="SWIG_SciDouble_FromFloatArrayAndSize") {
|
||||
|
||||
SWIGINTERN SwigSciObject
|
||||
SWIG_FromSet_Sequence_dec(float)(int size, float *pSequence) {
|
||||
SwigSciObject obj = SWIG_SciDouble_FromFloatArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, size, pSequence);
|
||||
delete (float *)pSequence;
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsVal_SequenceItem_frag(float), "header") {
|
||||
|
||||
SWIGINTERN float
|
||||
SWIG_AsVal_SequenceItem_dec(float)(SwigSciObject obj, float *pSequence, int iItemIndex) {
|
||||
return pSequence[iItemIndex];
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_SequenceItem_frag(float), "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_From_SequenceItem_dec(float)(float *pSequence, int iItemIndex, float itemValue) {
|
||||
pSequence[iItemIndex] = itemValue;
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
104
Lib/scilab/scisequenceint.swg
Normal file
104
Lib/scilab/scisequenceint.swg
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
/*
|
||||
*
|
||||
* Scilab matrix of int <-> C++ int container
|
||||
*
|
||||
*/
|
||||
|
||||
%include <sciint.swg>
|
||||
|
||||
%fragment(SWIG_AsCheck_Sequence_frag(int), "header") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsCheck_Sequence_dec(int)(SwigSciObject obj) {
|
||||
SciErr sciErr;
|
||||
int *piAddrVar;
|
||||
int iType = 0;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, obj, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if ((iType == sci_matrix) || (iType == sci_ints)) {
|
||||
return SWIG_OK;
|
||||
}
|
||||
else {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: An integer is expected.\n"), SWIG_Scilab_GetFuncName(), obj);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsGet_Sequence_frag(int), "header",
|
||||
fragment="SWIG_SciDoubleOrInt32_AsIntArrayAndSize") {
|
||||
SWIGINTERN int
|
||||
SWIG_AsGet_Sequence_dec(int)(SwigSciObject obj, int **pSequence) {
|
||||
int iMatrixRowCount;
|
||||
int iMatrixColCount;
|
||||
return (SWIG_SciDoubleOrInt32_AsIntArrayAndSize(pvApiCtx, obj, &iMatrixRowCount, &iMatrixColCount, pSequence, SWIG_Scilab_GetFuncName()));
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsSize_Sequence_frag(int), "header",
|
||||
fragment="SWIG_SciDoubleOrInt32_AsIntArrayAndSize") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsSize_Sequence_dec(int)(SwigSciObject obj, int *piSize) {
|
||||
int *piMatrix;
|
||||
int iMatrixRowCount;
|
||||
int iMatrixColCount;
|
||||
if (SWIG_SciDoubleOrInt32_AsIntArrayAndSize(pvApiCtx, obj, &iMatrixRowCount, &iMatrixColCount, &piMatrix, SWIG_Scilab_GetFuncName()) == SWIG_OK) {
|
||||
if ((iMatrixRowCount > 1) && (iMatrixColCount > 1)) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: An integer vector is expected.\n"), SWIG_Scilab_GetFuncName(), obj);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
*piSize = iMatrixRowCount * iMatrixColCount;
|
||||
return SWIG_OK;
|
||||
}
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_FromCreate_Sequence_frag(int), "header") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_FromCreate_Sequence_dec(int)(int size, int **pSequence) {
|
||||
*pSequence = new int[size];
|
||||
return *pSequence != NULL ? SWIG_OK : SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_FromSet_Sequence_frag(int), "header",
|
||||
fragment="SWIG_SciDouble_FromIntArrayAndSize") {
|
||||
|
||||
SWIGINTERN SwigSciObject
|
||||
SWIG_FromSet_Sequence_dec(int)(int size, int *pSequence) {
|
||||
SwigSciObject obj = SWIG_SciDouble_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, size, pSequence);
|
||||
delete (int *)pSequence;
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsVal_SequenceItem_frag(int), "header") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsVal_SequenceItem_dec(int)(SwigSciObject obj, int *pSequence, int iItemIndex) {
|
||||
return pSequence[iItemIndex];
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_SequenceItem_frag(int), "header") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_From_SequenceItem_dec(int)(int *pSequence, int iItemIndex, int itemValue) {
|
||||
pSequence[iItemIndex] = itemValue;
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
123
Lib/scilab/scisequencepointer.swg
Normal file
123
Lib/scilab/scisequencepointer.swg
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
/*
|
||||
*
|
||||
* Scilab list of pointer <-> C++ pointer container
|
||||
*
|
||||
*/
|
||||
|
||||
%include <scilist.swg>
|
||||
|
||||
%fragment("<stdint.h>", "header") {
|
||||
%#include <stdint.h>
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsCheck_Sequence_frag(ptr), "header",
|
||||
fragment="SWIG_ScilabList") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsCheck_Sequence_dec(ptr)(SwigSciObject obj) {
|
||||
return SWIG_CheckScilabList(obj);
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsGet_Sequence_frag(ptr), "header",
|
||||
fragment="SWIG_ScilabList") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsGet_Sequence_dec(ptr)(SwigSciObject obj, int **piSequence) {
|
||||
return SWIG_GetScilabList(obj, piSequence);
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsSize_Sequence_frag(ptr), "header",
|
||||
fragment="SWIG_ScilabList") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsSize_Sequence_dec(ptr)(SwigSciObject obj, int *piSize) {
|
||||
return SWIG_GetScilabListSize(obj, piSize);
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_FromCreate_Sequence_frag(ptr), "header",
|
||||
fragment="<stdint.h>") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_FromCreate_Sequence_dec(ptr)(int size, uintptr_t **pSequence) {
|
||||
*pSequence = new uintptr_t[size];
|
||||
return *pSequence != NULL ? SWIG_OK : SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_FromSet_Sequence_frag(ptr), "header",
|
||||
fragment="<stdint.h>") {
|
||||
|
||||
SWIGINTERN SwigSciObject
|
||||
SWIG_FromSet_Sequence_dec(ptr)(int size, uintptr_t *pSequence) {
|
||||
SciErr sciErr;
|
||||
int *piListAddr;
|
||||
|
||||
int iVarOut = SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition();
|
||||
|
||||
sciErr = createList(pvApiCtx, iVarOut, size, &piListAddr);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
for (int i=0; i<size; i++) {
|
||||
sciErr = createPointerInList(pvApiCtx, iVarOut, piListAddr, i + 1, (void *)pSequence[i]);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
delete (int*)pSequence;
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsVal_SequenceItem_frag(ptr), "header") {
|
||||
|
||||
SWIGINTERN void*
|
||||
SWIG_AsVal_SequenceItem_dec(ptr)(SwigSciObject obj, int *piSequence, int itemIndex)
|
||||
{
|
||||
SciErr sciErr;
|
||||
int *piItemAddr;
|
||||
int iType;
|
||||
void* pItemValue = NULL;
|
||||
|
||||
sciErr = getListItemAddress(pvApiCtx, piSequence, itemIndex + 1, &piItemAddr);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sciErr = getVarType(pvApiCtx, piItemAddr, &iType);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (iType != sci_pointer) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A pointer is expected at list item #%d.\n"), SWIG_Scilab_GetFuncName(), obj, itemIndex + 1);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sciErr = getPointerInList(pvApiCtx, piSequence, itemIndex + 1, &pItemValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return pItemValue;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_SequenceItem_frag(ptr), "header",
|
||||
fragment="<stdint.h>") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_From_SequenceItem_dec(ptr)(uintptr_t *pSequence, int iItemIndex, uintptr_t itemValue) {
|
||||
pSequence[iItemIndex] = itemValue;
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
97
Lib/scilab/scisequencestring.swg
Normal file
97
Lib/scilab/scisequencestring.swg
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
*char
|
||||
* Scilab matrix of string <-> C++ std::string container
|
||||
*
|
||||
*/
|
||||
|
||||
%include <scichar.swg>
|
||||
|
||||
%fragment(SWIG_AsCheck_Sequence_frag(std::string), "header") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsCheck_Sequence_dec(std::string)(SwigSciObject obj) {
|
||||
SciErr sciErr;
|
||||
int *piAddrVar;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, obj, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (isStringType(pvApiCtx, piAddrVar)) {
|
||||
return SWIG_OK;
|
||||
}
|
||||
else {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A string is expected.\n"), SWIG_Scilab_GetFuncName(), obj);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsGet_Sequence_frag(std::string), "header",
|
||||
fragment="SWIG_SciString_AsCharPtrArrayAndSize") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsGet_Sequence_dec(std::string)(SwigSciObject obj, char ***pSequence) {
|
||||
int iRows = 0;
|
||||
int iCols = 0;
|
||||
return (SWIG_SciString_AsCharPtrArrayAndSize(pvApiCtx, obj, &iRows, &iCols, pSequence, SWIG_Scilab_GetFuncName()));
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsSize_Sequence_frag(std::string), "header",
|
||||
fragment="SWIG_SciString_AsCharPtrArrayAndSize") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsSize_Sequence_dec(std::string)(SwigSciObject obj, int *piSize) {
|
||||
char **pstMatrix;
|
||||
int iCols = 0;
|
||||
int iRows = 0;
|
||||
if (SWIG_SciString_AsCharPtrArrayAndSize(pvApiCtx, obj, &iRows, &iCols, &pstMatrix, SWIG_Scilab_GetFuncName()) == SWIG_OK) {
|
||||
*piSize = iRows * iCols;
|
||||
return SWIG_OK;
|
||||
}
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_FromCreate_Sequence_frag(std::string), "header") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_FromCreate_Sequence_dec(std::string)(int size, char ***pSequence) {
|
||||
*pSequence = new char*[size];
|
||||
return *pSequence != NULL ? SWIG_OK : SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_FromSet_Sequence_frag(std::string), "header",
|
||||
fragment="SWIG_SciString_FromCharPtrArrayAndSize") {
|
||||
|
||||
SWIGINTERN SwigSciObject
|
||||
SWIG_FromSet_Sequence_dec(std::string)(int size, char **pSequence) {
|
||||
SwigSciObject obj = SWIG_SciString_FromCharPtrArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, size, pSequence);
|
||||
delete (char **)pSequence;
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsVal_SequenceItem_frag(std::string), "header") {
|
||||
|
||||
SWIGINTERN std::string
|
||||
SWIG_AsVal_SequenceItem_dec(std::string)(SwigSciObject obj, char **pSequence, int iItemIndex) {
|
||||
return std::string(pSequence[iItemIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_SequenceItem_frag(std::string), "header") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_From_SequenceItem_dec(std::string)(char **pSequence, int iItemIndex, std::string itemValue) {
|
||||
char *pChar = new char(itemValue.size() + 1);
|
||||
strcpy(pChar, itemValue.c_str());
|
||||
pSequence[iItemIndex] = pChar;
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
188
Lib/scilab/scishort.swg
Normal file
188
Lib/scilab/scishort.swg
Normal file
|
|
@ -0,0 +1,188 @@
|
|||
/*
|
||||
* C-type: short
|
||||
* Scilab type: double or int16
|
||||
*/
|
||||
|
||||
%fragment(SWIG_AsVal_frag(short), "header", fragment="SWIG_SciDoubleOrInt16_AsShort", fragment="<limits.h>") {
|
||||
#define SWIG_AsVal_short(scilabValue, valuePointer) SWIG_SciDoubleOrInt16_AsShort(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName())
|
||||
}
|
||||
%fragment("SWIG_SciDoubleOrInt16_AsShort", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciDoubleOrInt16_AsShort(void *pvApiCtx, int iVar, short *psValue, char *fname) {
|
||||
SciErr sciErr;
|
||||
int iType = 0;
|
||||
int iRows = 0;
|
||||
int iCols = 0;
|
||||
int *piAddrVar = NULL;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (iType == sci_ints) {
|
||||
int iPrec = 0;
|
||||
short *psData = NULL;
|
||||
|
||||
sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iPrec != SCI_INT16) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 16-bit signed integer or a double expected.\n"), fname, iVar);
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
sciErr = getMatrixOfInteger16(pvApiCtx, piAddrVar, &iRows, &iCols, &psData);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iRows * iCols != 1) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 16-bit signed integer or a double expected.\n"), fname, iVar);
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
*psValue = *psData;
|
||||
}
|
||||
else if (iType == sci_matrix) {
|
||||
double *pdData = NULL;
|
||||
double dValue = 0.0f;
|
||||
|
||||
sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, &iRows, &iCols, &pdData);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iRows * iCols != 1) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 16-bit signed integer or a double expected.\n"), fname, iVar);
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
dValue = *pdData;
|
||||
if (dValue != floor(dValue)) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Incorrect value for input argument #%d: The double value cannot be converted to a 16-bit signed integer.\n"), fname, iVar);
|
||||
return SWIG_ValueError;
|
||||
}
|
||||
if ((dValue < SHRT_MIN) || (dValue > SHRT_MAX)) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Overflow error for input argument #%d: The double value cannot be converted to a 16-bit signed integer.\n"), fname, iVar);
|
||||
return SWIG_OverflowError;
|
||||
}
|
||||
*psValue = (short) dValue;
|
||||
}
|
||||
else {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 16-bit signed integer or a double expected.\n"), fname, iVar);
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_frag(short), "header", fragment="SWIG_SciDouble_FromShort") {
|
||||
#define SWIG_From_short(scilabValue) SWIG_SciDouble_FromShort(pvApiCtx, SWIG_Scilab_GetOutputPosition(), scilabValue, SWIG_Scilab_GetFuncName())
|
||||
}
|
||||
%fragment("SWIG_SciDouble_FromShort", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciDouble_FromShort(void *pvApiCtx, int iVarOut, short sValue, char *fname) {
|
||||
if (createScalarDouble(pvApiCtx,
|
||||
SWIG_NbInputArgument(pvApiCtx) + iVarOut, (double) sValue))
|
||||
return SWIG_ERROR;
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* C-type: short[]
|
||||
* Scilab type: double or int16 matrix
|
||||
*/
|
||||
%fragment("SWIG_SciDoubleOrInt16_AsShortArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciDoubleOrInt16_AsShortArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, short **psValue, char *fname) {
|
||||
SciErr sciErr;
|
||||
int iType = 0;
|
||||
int iPrec = 0;
|
||||
int *piAddrVar = NULL;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (iType == sci_matrix) {
|
||||
double *pdData = NULL;
|
||||
int size = 0;
|
||||
int i;
|
||||
|
||||
sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, iRows, iCols, &pdData);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
size = (*iRows) * (*iCols);
|
||||
*psValue = (short*) malloc(size * sizeof(int*));
|
||||
for (i = 0; i < size; i++)
|
||||
(*psValue)[i] = (short) pdData[i];
|
||||
}
|
||||
else if (iType == sci_ints) {
|
||||
int iPrec = 0;
|
||||
sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iPrec != SCI_INT16) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 16-bit signed integer or a double matrix expected.\n"), fname, iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getMatrixOfInteger16(pvApiCtx, piAddrVar, iRows, iCols, psValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 16-bit signed integer or a double matrix expected.\n"), fname, iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
%fragment("SWIG_SciDouble_FromShortArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciDouble_FromShortArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, short *psValue) {
|
||||
SciErr sciErr;
|
||||
int i;
|
||||
double *pdValues = NULL;
|
||||
|
||||
pdValues = (double*) malloc(iRows * iCols * sizeof(double));
|
||||
for (i=0; i<iRows * iCols; i++)
|
||||
pdValues[i] = psValue[i];
|
||||
|
||||
sciErr = createMatrixOfDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, iRows, iCols, pdValues);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
free(pdValues);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
free(pdValues);
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
185
Lib/scilab/scisignedchar.swg
Normal file
185
Lib/scilab/scisignedchar.swg
Normal file
|
|
@ -0,0 +1,185 @@
|
|||
/*
|
||||
* C-type: signed char
|
||||
* Scilab type: double or int8
|
||||
*/
|
||||
%fragment(SWIG_AsVal_frag(signed char), "header", fragment="SWIG_SciDoubleOrInt8_AsSignedChar", fragment="<limits.h>") {
|
||||
#define SWIG_AsVal_signed_SS_char(scilabValue, valuePointer) SWIG_SciDoubleOrInt8_AsSignedChar(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName())
|
||||
}
|
||||
%fragment("SWIG_SciDoubleOrInt8_AsSignedChar", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciDoubleOrInt8_AsSignedChar(void *pvApiCtx, int iVar, signed char *pscValue, char *fname) {
|
||||
SciErr sciErr;
|
||||
int iType = 0;
|
||||
int iRows = 0;
|
||||
int iCols = 0;
|
||||
int iPrec = 0;
|
||||
int *piAddrVar = NULL;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (iType == sci_ints) {
|
||||
char *pcData = NULL;
|
||||
|
||||
sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iPrec != SCI_INT8) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 8-bit signed integer or a double expected.\n"), fname, iVar);
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
sciErr = getMatrixOfInteger8(pvApiCtx, piAddrVar, &iRows, &iCols, &pcData);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iRows * iCols != 1) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 8-bit signed integer or a double expected.\n"), fname, iVar);
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
*pscValue = *pcData;
|
||||
}
|
||||
else if (iType == sci_matrix) {
|
||||
double *pdData = NULL;
|
||||
double dValue = 0.0f;
|
||||
|
||||
sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, &iRows, &iCols, &pdData);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iRows * iCols != 1) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 8-bit signed integer or a double expected.\n"), fname, iVar);
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
dValue = *pdData;
|
||||
if (dValue != floor(dValue)) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Incorrect value for input argument #%d: The double value cannot be converted to a 8-bit signed integer.\n"), fname, iVar);
|
||||
return SWIG_ValueError;
|
||||
}
|
||||
if ((dValue < SCHAR_MIN) || (dValue > SCHAR_MAX)) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Overflow error for input argument #%d: The double value cannot be converted to a 8-bit signed integer.\n"), fname, iVar);
|
||||
return SWIG_OverflowError;
|
||||
}
|
||||
*pscValue = (signed char) dValue;
|
||||
}
|
||||
else {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 8-bit signed integer or a double expected.\n"), fname, iVar);
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_frag(signed char), "header", fragment="SWIG_SciDouble_FromSignedChar") {
|
||||
#define SWIG_From_signed_SS_char(scilabValue) SWIG_SciDouble_FromSignedChar(pvApiCtx, SWIG_Scilab_GetOutputPosition(), scilabValue)
|
||||
}
|
||||
%fragment("SWIG_SciDouble_FromSignedChar", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciDouble_FromSignedChar(void *pvApiCtx, int iVarOut, signed char scValue) {
|
||||
if (createScalarDouble(pvApiCtx,
|
||||
SWIG_NbInputArgument(pvApiCtx) + iVarOut, (double) scValue))
|
||||
return SWIG_ERROR;
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* C-type: signed char[]
|
||||
* Scilab type: double or int8 matrix
|
||||
*/
|
||||
%fragment("SWIG_SciDoubleOrInt8_AsSignedCharArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciDoubleOrInt8_AsSignedCharArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, signed char **pscValue, char *fname) {
|
||||
SciErr sciErr;
|
||||
int iType = 0;
|
||||
int *piAddrVar = NULL;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (iType == sci_matrix) {
|
||||
double *pdData = NULL;
|
||||
int size = 0;
|
||||
int i;
|
||||
|
||||
sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, iRows, iCols, &pdData);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
size = (*iRows) * (*iCols);
|
||||
*pscValue = (signed char*) malloc(size * sizeof(int*));
|
||||
for (i = 0; i < size; i++)
|
||||
(*pscValue)[i] = (signed char) pdData[i];
|
||||
}
|
||||
else if (iType == sci_ints) {
|
||||
int iPrec = 0;
|
||||
sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iPrec != SCI_INT8) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 8-bit signed integer or a double matrix expected.\n"), fname, iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getMatrixOfInteger8(pvApiCtx, piAddrVar, iRows, iCols, (char **)pscValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 8-bit signed integer or a double matrix expected.\n"), fname, iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment("SWIG_SciDouble_FromSignedCharArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciDouble_FromSignedCharArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, const signed char *pscValue) {
|
||||
SciErr sciErr;
|
||||
int i;
|
||||
double *pdValues = NULL;
|
||||
|
||||
pdValues = (double*) malloc(iRows * iCols * sizeof(double));
|
||||
for (i=0; i<iRows * iCols; i++)
|
||||
pdValues[i] = pscValue[i];
|
||||
|
||||
sciErr = createMatrixOfDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, iRows, iCols, pdValues);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
free(pdValues);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
free(pdValues);
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
226
Lib/scilab/scistdcommon.swg
Normal file
226
Lib/scilab/scistdcommon.swg
Normal file
|
|
@ -0,0 +1,226 @@
|
|||
%fragment("StdTraits","header",fragment="StdTraitsCommon")
|
||||
{
|
||||
namespace swig {
|
||||
// Traits that provides the from method
|
||||
template <class Type> struct traits_from_ptr {
|
||||
static SwigSciObject from(Type *val, int owner = 0) {
|
||||
return SWIG_OK; //SWIG_NewPointerObj(val, type_info<Type>(), owner);
|
||||
}
|
||||
};
|
||||
|
||||
template <class Type> struct traits_from {
|
||||
static SwigSciObject from(const Type& val) {
|
||||
return traits_from_ptr<Type>::from(new Type(val), 1);
|
||||
}
|
||||
};
|
||||
|
||||
template <class Type> struct traits_from<Type *> {
|
||||
static SwigSciObject from(Type* val) {
|
||||
return traits_from_ptr<Type>::from(val, 0);
|
||||
}
|
||||
};
|
||||
|
||||
template <class Type> struct traits_from<const Type *> {
|
||||
static SwigSciObject from(const Type* val) {
|
||||
return traits_from_ptr<Type>::from(const_cast<Type*>(val), 0);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <class Type>
|
||||
inline SwigSciObject from(const Type& val) {
|
||||
return traits_from<Type>::from(val);
|
||||
}
|
||||
|
||||
template <class Type>
|
||||
inline SwigSciObject from_ptr(Type* val, int owner) {
|
||||
return traits_from_ptr<Type>::from(val, owner);
|
||||
}
|
||||
|
||||
// Traits that provides the asval/as/check method
|
||||
template <class Type>
|
||||
struct traits_asptr {
|
||||
static int asptr(const SwigSciObject& obj, Type **val) {
|
||||
Type *p;
|
||||
int res = SWIG_ConvertPtr(obj, (void**)&p, type_info<Type>(), 0);
|
||||
if (SWIG_IsOK(res)) {
|
||||
if (val) *val = p;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
template <class Type>
|
||||
inline int asptr(const SwigSciObject& obj, Type **vptr) {
|
||||
return traits_asptr<Type>::asptr(obj, vptr);
|
||||
}
|
||||
|
||||
template <class Type>
|
||||
struct traits_asval {
|
||||
static int asval(const SwigSciObject& obj, Type *val) {
|
||||
if (val) {
|
||||
Type *p = 0;
|
||||
int res = traits_asptr<Type>::asptr(obj, &p);
|
||||
if (!SWIG_IsOK(res))
|
||||
return res;
|
||||
if (p) {
|
||||
typedef typename noconst_traits<Type>::noconst_type noconst_type;
|
||||
*(const_cast<noconst_type*>(val)) = *p;
|
||||
if (SWIG_IsNewObj(res)){
|
||||
%delete(p);
|
||||
res = SWIG_DelNewMask(res);
|
||||
}
|
||||
return res;
|
||||
} else {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
} else {
|
||||
return traits_asptr<Type>::asptr(obj, (Type **)(0));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <class Type> struct traits_asval<Type*> {
|
||||
static int asval(const SwigSciObject& obj, Type **val) {
|
||||
if (val) {
|
||||
typedef typename noconst_traits<Type>::noconst_type noconst_type;
|
||||
noconst_type *p = 0;
|
||||
int res = traits_asptr<noconst_type>::asptr(obj, &p);
|
||||
if (SWIG_IsOK(res)) {
|
||||
*(const_cast<noconst_type**>(val)) = p;
|
||||
}
|
||||
return res;
|
||||
} else {
|
||||
return traits_asptr<Type>::asptr(obj, (Type **)(0));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <class Type>
|
||||
inline int asval(const SwigSciObject& obj, Type *val) {
|
||||
return traits_asval<Type>::asval(obj, val);
|
||||
}
|
||||
|
||||
template <class Type>
|
||||
struct traits_as<Type, value_category> {
|
||||
static Type as(const SwigSciObject& obj, bool throw_error) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <class Type>
|
||||
struct traits_as<Type, pointer_category> {
|
||||
static Type as(const SwigSciObject& obj, bool throw_error) {
|
||||
Type *v = 0;
|
||||
int res = traits_asptr<Type>::asptr(obj, &v);
|
||||
if (SWIG_IsOK(res) && v) {
|
||||
if (SWIG_IsNewObj(res)) {
|
||||
Type r(*v);
|
||||
%delete(v);
|
||||
return r;
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <class Type>
|
||||
struct traits_as<Type*, pointer_category> {
|
||||
static Type* as(const SwigSciObject& obj, bool throw_error) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <class Type>
|
||||
inline Type as(const SwigSciObject& obj, bool te = false) {
|
||||
return traits_as<Type, typename traits<Type>::category>::as(obj, te);
|
||||
}
|
||||
|
||||
template <class Type>
|
||||
struct traits_check<Type, value_category> {
|
||||
static bool check(const SwigSciObject& obj) {
|
||||
int res = asval(obj, (Type *)(0));
|
||||
return SWIG_IsOK(res) ? true : false;
|
||||
}
|
||||
};
|
||||
|
||||
template <class Type>
|
||||
struct traits_check<Type, pointer_category> {
|
||||
static bool check(const SwigSciObject& obj) {
|
||||
int res = asptr(obj, (Type **)(0));
|
||||
return SWIG_IsOK(res) ? true : false;
|
||||
}
|
||||
};
|
||||
|
||||
template <class Type>
|
||||
inline bool check(const SwigSciObject& obj) {
|
||||
return traits_check<Type, typename traits<Type>::category>::check(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%define %specialize_std_container(Type,Check,As,From)
|
||||
%{
|
||||
namespace swig {
|
||||
template <> struct traits_asval<Type > {
|
||||
typedef Type value_type;
|
||||
static int asval(const SwigSciObject& obj, value_type *val) {
|
||||
if (Check(obj)) {
|
||||
if (val) *val = As(obj);
|
||||
return SWIG_OK;
|
||||
}
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
};
|
||||
template <> struct traits_from<Type > {
|
||||
typedef Type value_type;
|
||||
static SwigSciObject from(const value_type& val) {
|
||||
return From(val);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct traits_check<Type, value_category> {
|
||||
static int check(const SwigSciObject& obj) {
|
||||
int res = Check(obj);
|
||||
return obj && res ? res : 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
%}
|
||||
%enddef
|
||||
|
||||
|
||||
#define specialize_std_vector(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From)
|
||||
#define specialize_std_list(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From)
|
||||
#define specialize_std_deque(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From)
|
||||
#define specialize_std_set(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From)
|
||||
#define specialize_std_multiset(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From)
|
||||
|
||||
243
Lib/scilab/scitypemaps.swg
Normal file
243
Lib/scilab/scitypemaps.swg
Normal file
|
|
@ -0,0 +1,243 @@
|
|||
// Scilab fragments for primitive types
|
||||
%include <sciprimtypes.swg>
|
||||
|
||||
%include <scienum.swg>
|
||||
|
||||
// Scilab object type
|
||||
#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 %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
|
||||
#define %set_argoutput(obj) if (!SWIG_IsOK(SWIG_Scilab_SetOutput(pvApiCtx, obj))) return SWIG_ERROR
|
||||
|
||||
// Include the unified typemap library
|
||||
%include <typemaps/swigtypemaps.swg>
|
||||
|
||||
/* ---------------------------------------------------------------------------*/
|
||||
/* Generic typmemaps */
|
||||
/* */
|
||||
/* This typemap is used when Scilab does not store this type directly */
|
||||
/* For example, a 'float' is stored in Scilab as a 'double' */
|
||||
/* So we read a 'double' in Scilab and cast it to a 'float' */
|
||||
/* ---------------------------------------------------------------------------*/
|
||||
|
||||
%define %scilab_in_typemap_withcast(TYPEMAPTYPE, FRAGMENTNAME, CTYPE, TEMPTYPE, TEMPINIT)
|
||||
%typemap(TYPEMAPTYPE, fragment="FRAGMENTNAME") CTYPE {
|
||||
TEMPTYPE tempValue = TEMPINIT;
|
||||
if(FRAGMENTNAME(pvApiCtx, $input, &tempValue, SWIG_Scilab_GetFuncName()) != SWIG_OK) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
$1 = (CTYPE) tempValue;
|
||||
}
|
||||
%enddef
|
||||
%define %scilab_inptr_typemap(TYPEMAPTYPE, FRAGMENTNAME, CTYPE)
|
||||
%typemap(TYPEMAPTYPE, noblock=1, fragment="FRAGMENTNAME") CTYPE {
|
||||
if (FRAGMENTNAME(pvApiCtx, $input, %as_voidptrptr(&$1), SWIG_Scilab_GetFuncName()) != SWIG_OK) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
%enddef
|
||||
|
||||
%define %scilab_out_typemap(TYPEMAPTYPE, FRAGMENTNAME, CTYPE)
|
||||
%typemap(TYPEMAPTYPE, noblock=1, fragment="FRAGMENTNAME") CTYPE {
|
||||
if (FRAGMENTNAME(pvApiCtx, $result, $1) != SWIG_OK) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
%enddef
|
||||
|
||||
%define %scilab_outptr_typemap(TYPEMAPTYPE, FRAGMENTNAME, CTYPE)
|
||||
%typemap(TYPEMAPTYPE, noblock=1, fragment="FRAGMENTNAME") CTYPE {
|
||||
if (FRAGMENTNAME(pvApiCtx, $result, %as_voidptr($1)) != SWIG_OK) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
%enddef
|
||||
|
||||
%define %scilab_varout_typemap(TYPEMAPTYPE, FRAGMENTNAME, CTYPE)
|
||||
%typemap(TYPEMAPTYPE, noblock=1, fragment="FRAGMENTNAME") CTYPE {
|
||||
if (FRAGMENTNAME(pvApiCtx, $result, $value) != SWIG_OK) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
%enddef
|
||||
|
||||
%define %scilab_varoutptr_typemap(TYPEMAPTYPE, FRAGMENTNAME, CTYPE)
|
||||
%typemap(TYPEMAPTYPE, noblock=1, fragment="FRAGMENTNAME") CTYPE {
|
||||
if (FRAGMENTNAME(pvApiCtx, $result, %as_voidptr($value)) != SWIG_OK) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
%enddef
|
||||
|
||||
%define %scilab_in_typemap(TYPEMAPTYPE, FRAGMENTNAME, CTYPE)
|
||||
%typemap(TYPEMAPTYPE, noblock=1, fragment="FRAGMENTNAME") CTYPE {
|
||||
if (FRAGMENTNAME(pvApiCtx, $input, &$1, SWIG_Scilab_GetFuncName()) != SWIG_OK) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
%enddef
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------*/
|
||||
/* Array typmemaps */
|
||||
/* ---------------------------------------------------------------------------*/
|
||||
|
||||
%include <sciarray.swg>
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------*/
|
||||
/* Enum typemaps */
|
||||
/* ---------------------------------------------------------------------------*/
|
||||
|
||||
%typemap(in, noblock=1, fragment=SWIG_AsVal_frag(Enum)) enum SWIGTYPE (int val) {
|
||||
if (SWIG_AsVal_dec(Enum)($input, &val) != SWIG_OK) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
$1 = %reinterpret_cast(val, $ltype);
|
||||
}
|
||||
|
||||
%typemap(out, fragment=SWIG_From_frag(Enum)) enum SWIGTYPE {
|
||||
if (SWIG_From_dec(Enum)($1) != SWIG_OK) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------------*/
|
||||
/* Typecheck typemaps */
|
||||
/* ---------------------------------------------------------------------------*/
|
||||
|
||||
%define %scilab_typecheck_generic(PRECEDENCE, TYPE_CHECK_FUNCTION, TYPE)
|
||||
%typecheck(PRECEDENCE) TYPE {
|
||||
int *piAddrVar = NULL;
|
||||
SciErr sciErr = getVarAddressFromPosition(pvApiCtx, $input, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
$1 = TYPE_CHECK_FUNCTION(pvApiCtx, piAddrVar);
|
||||
}
|
||||
%enddef
|
||||
|
||||
/* Scilab equivalent for C integers can be sci_ints or sci_matrix */
|
||||
%define %scilab_typecheck_integer(PRECEDENCE, INTTYPE, TYPE)
|
||||
%typecheck(PRECEDENCE) TYPE {
|
||||
int *piAddrVar = NULL;
|
||||
SciErr sciErr = getVarAddressFromPosition(pvApiCtx, $input, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
$1 = isIntegerType(pvApiCtx, piAddrVar);
|
||||
if ($1 == 1) {
|
||||
int iPrec = 0;
|
||||
sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
$1 = (iPrec == INTTYPE) ? 1 : 0;
|
||||
}
|
||||
else {
|
||||
$1 = isDoubleType(pvApiCtx, piAddrVar);
|
||||
}
|
||||
}
|
||||
%enddef
|
||||
|
||||
// Double (and Float) have priority over before Integer type.
|
||||
|
||||
// Primitive types
|
||||
%scilab_typecheck_generic(SWIG_TYPECHECK_VOIDPTR, isPointerType, SWIGTYPE *)
|
||||
%scilab_typecheck_generic(SWIG_TYPECHECK_POINTER, isPointerType, SWIGTYPE *)
|
||||
%scilab_typecheck_generic(SWIG_TYPECHECK_BOOL, isBooleanType, bool)
|
||||
%scilab_typecheck_generic(16, isDoubleType, double)
|
||||
%scilab_typecheck_generic(17, isDoubleType, float)
|
||||
%scilab_typecheck_integer(SWIG_TYPECHECK_INT8, SCI_INT8, signed char)
|
||||
%scilab_typecheck_integer(SWIG_TYPECHECK_UINT8, SCI_UINT8, unsigned char)
|
||||
%scilab_typecheck_integer(SWIG_TYPECHECK_INT16, SCI_INT16, short)
|
||||
%scilab_typecheck_integer(SWIG_TYPECHECK_UINT16, SCI_UINT16, unsigned short)
|
||||
%scilab_typecheck_integer(SWIG_TYPECHECK_INT32, SCI_INT32, int)
|
||||
%scilab_typecheck_integer(SWIG_TYPECHECK_INT32, SCI_INT32, long)
|
||||
%scilab_typecheck_integer(SWIG_TYPECHECK_UINT32, SCI_UINT32, unsigned int)
|
||||
%scilab_typecheck_integer(SWIG_TYPECHECK_UINT32, SCI_UINT32, unsigned long)
|
||||
%scilab_typecheck_integer(SWIG_TYPECHECK_INT32, SCI_INT32, enum SWIGTYPE)
|
||||
%scilab_typecheck_generic(SWIG_TYPECHECK_CHAR, isStringType, char)
|
||||
|
||||
// Arrays
|
||||
%scilab_typecheck_generic(SWIG_TYPECHECK_BOOL_ARRAY, isBooleanType, bool)
|
||||
%scilab_typecheck_generic(1016, isDoubleType, double [ANY])
|
||||
%scilab_typecheck_generic(1017, isDoubleType, float [ANY])
|
||||
%scilab_typecheck_integer(SWIG_TYPECHECK_INT8_ARRAY, SCI_INT8, signed char [ANY])
|
||||
%scilab_typecheck_integer(1026, SCI_UINT8, unsigned char [ANY])
|
||||
%scilab_typecheck_integer(SWIG_TYPECHECK_INT16_ARRAY, SCI_INT16, short [ANY])
|
||||
%scilab_typecheck_integer(1036, SCI_UINT16, unsigned short [ANY])
|
||||
%scilab_typecheck_integer(SWIG_TYPECHECK_INT32_ARRAY, SCI_INT32, int [ANY])
|
||||
%scilab_typecheck_integer(SWIG_TYPECHECK_INT32_ARRAY, SCI_INT32, long [ANY])
|
||||
%scilab_typecheck_integer(1046, SCI_UINT32, unsigned int [ANY])
|
||||
%scilab_typecheck_integer(1046, SCI_UINT32, unsigned long [ANY])
|
||||
%scilab_typecheck_generic(SWIG_TYPECHECK_CHAR_ARRAY, isStringType, char [ANY])
|
||||
%scilab_typecheck_generic(SWIG_TYPECHECK_STRING_ARRAY, isStringType, char *[ANY])
|
||||
%scilab_typecheck_generic(SWIG_TYPECHECK_STRING_ARRAY, isStringType, char **)
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------*/
|
||||
/* %scilabconstcode() feature typemaps */
|
||||
/* ---------------------------------------------------------------------------*/
|
||||
|
||||
%typemap(scilabconstcode, fragment=SWIG_CreateScilabVariable_frag(double)) double
|
||||
%{
|
||||
if (SWIG_CreateScilabVariable_double(pvApiCtx, "$result", $value) != SWIG_OK)
|
||||
return SWIG_ERROR;
|
||||
%}
|
||||
|
||||
%typemap(scilabconstcode, fragment=SWIG_CreateScilabVariable_frag(int)) int
|
||||
%{
|
||||
if (SWIG_CreateScilabVariable_int(pvApiCtx, "$result", $value) != SWIG_OK)
|
||||
return SWIG_ERROR;
|
||||
%}
|
||||
|
||||
%typemap(scilabconstcode, fragment=SWIG_CreateScilabVariable_frag(uint)) unsigned int
|
||||
%{
|
||||
if (SWIG_CreateScilabVariable_uint(pvApiCtx, "$result", $value) != SWIG_OK)
|
||||
return SWIG_ERROR;
|
||||
%}
|
||||
|
||||
%typemap(scilabconstcode, fragment=SWIG_CreateScilabVariable_frag(int)) long
|
||||
%{
|
||||
if (SWIG_CreateScilabVariable_int(pvApiCtx, "$result", $value) != SWIG_OK)
|
||||
return SWIG_ERROR;
|
||||
%}
|
||||
|
||||
%typemap(scilabconstcode, fragment=SWIG_CreateScilabVariable_frag(uint)) unsigned long
|
||||
%{
|
||||
if (SWIG_CreateScilabVariable_uint(pvApiCtx, "$result", $value) != SWIG_OK)
|
||||
return SWIG_ERROR;
|
||||
%}
|
||||
|
||||
%typemap(scilabconstcode, fragment=SWIG_CreateScilabVariable_frag(char)) char
|
||||
%{
|
||||
if (SWIG_CreateScilabVariable_char(pvApiCtx, "$result", $value) != SWIG_OK)
|
||||
return SWIG_ERROR;
|
||||
%}
|
||||
|
||||
%typemap(scilabconstcode, fragment=SWIG_CreateScilabVariable_frag(charptr)) char *
|
||||
%{
|
||||
if (SWIG_CreateScilabVariable_charptr(pvApiCtx, "$result", $value) != SWIG_OK)
|
||||
return SWIG_ERROR;
|
||||
%}
|
||||
|
||||
%typemap(scilabconstcode, fragment=SWIG_CreateScilabVariable_frag(double)) enum SWIGTYPE
|
||||
%{
|
||||
if (SWIG_CreateScilabVariable_double(pvApiCtx, "$result", $value) != SWIG_OK)
|
||||
return SWIG_ERROR;
|
||||
%}
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------*/
|
||||
/* Exception typmemaps */
|
||||
/* ---------------------------------------------------------------------------*/
|
||||
|
||||
%include <sciexception.swg>
|
||||
190
Lib/scilab/sciunsignedchar.swg
Normal file
190
Lib/scilab/sciunsignedchar.swg
Normal file
|
|
@ -0,0 +1,190 @@
|
|||
/*
|
||||
* C-type: unsigned char
|
||||
* Scilab type: double or uint8
|
||||
*/
|
||||
%fragment(SWIG_AsVal_frag(unsigned char), "header", fragment="SWIG_SciDoubleOrUint8_AsUnsignedChar", fragment="<limits.h>") {
|
||||
#define SWIG_AsVal_unsigned_SS_char(scilabValue, valuePointer) SWIG_SciDoubleOrUint8_AsUnsignedChar(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName())
|
||||
}
|
||||
%fragment("SWIG_SciDoubleOrUint8_AsUnsignedChar", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciDoubleOrUint8_AsUnsignedChar(void *pvApiCtx, int iVar, unsigned char *pucValue, char *fname) {
|
||||
SciErr sciErr;
|
||||
int iType = 0;
|
||||
int iRows = 0;
|
||||
int iCols = 0;
|
||||
int iPrec = 0;
|
||||
int *piAddrVar = NULL;
|
||||
unsigned char *pucData = NULL;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (iType == sci_ints) {
|
||||
if (pucValue) {
|
||||
sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iPrec != SCI_UINT8) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 8-bit unsigned integer or a double expected.\n"), fname, iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getMatrixOfUnsignedInteger8(pvApiCtx, piAddrVar, &iRows, &iCols, &pucData);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iRows * iCols != 1) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 8-bit unsigned integer or a double expected.\n"), fname, iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
*pucValue = *pucData;
|
||||
}
|
||||
}
|
||||
else if (iType == sci_matrix) {
|
||||
if (pucValue) {
|
||||
double *pdData = NULL;
|
||||
double dValue = 0.0f;
|
||||
sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, &iRows, &iCols, &pdData);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iRows * iCols != 1) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 8-bit unsigned integer or a double expected.\n"), fname, iVar);
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
dValue = *pdData;
|
||||
if (dValue != floor(dValue)) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Incorrect value for input argument #%d: The double value cannot be converted to a 8-bit unsigned integer.\n"), fname, iVar);
|
||||
return SWIG_ValueError;
|
||||
}
|
||||
if ((dValue < 0) || (dValue > UCHAR_MAX)) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Overflow error for input argument #%d: The double value cannot be converted to a 8-bit unsigned integer.\n"), fname, iVar);
|
||||
return SWIG_OverflowError;
|
||||
}
|
||||
*pucValue = (unsigned char) dValue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 8-bit unsigned integer or a double expected.\n"), fname, iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_frag(unsigned char), "header", fragment="SWIG_SciDouble_FromUnsignedChar") {
|
||||
#define SWIG_From_unsigned_SS_char(value) SWIG_SciDouble_FromUnsignedChar(pvApiCtx, SWIG_Scilab_GetOutputPosition(), value)
|
||||
}
|
||||
%fragment("SWIG_SciDouble_FromUnsignedChar", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciDouble_FromUnsignedChar(void *pvApiCtx, int iVarOut, unsigned char ucValue) {
|
||||
if (createScalarDouble(pvApiCtx,
|
||||
SWIG_NbInputArgument(pvApiCtx) + iVarOut, (double) ucValue))
|
||||
return SWIG_ERROR;
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* C-type: unsigned char[]
|
||||
* Scilab type: double or uint8 matrix
|
||||
*/
|
||||
%fragment("SWIG_SciDoubleOrUint8_AsUnsignedCharArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciDoubleOrUint8_AsUnsignedCharArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, unsigned char **pucValue, char *fname) {
|
||||
SciErr sciErr;
|
||||
int iType = 0;
|
||||
int iPrec = 0;
|
||||
int *piAddrVar = NULL;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (iType == sci_matrix) {
|
||||
double *pdData = NULL;
|
||||
int size = 0;
|
||||
int i;
|
||||
|
||||
sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, iRows, iCols, &pdData);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
size = (*iRows) * (*iCols);
|
||||
*pucValue = (unsigned char*) malloc(size * sizeof(int*));
|
||||
for (i = 0; i < size; i++)
|
||||
(*pucValue)[i] = (unsigned char) pdData[i];
|
||||
}
|
||||
else if (iType == sci_ints) {
|
||||
sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (iPrec != SCI_UINT8) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 8-bit unsigned integer or a double vector expected.\n"), fname, iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getMatrixOfUnsignedInteger8(pvApiCtx, piAddrVar, iRows, iCols, pucValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 8-bit unsigned integer or a double vector expected.\n"), fname, iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment("SWIG_SciDouble_FromUnsignedCharArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciDouble_FromUnsignedCharArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, const unsigned char *pucValues) {
|
||||
SciErr sciErr;
|
||||
double *pdValues = NULL;
|
||||
int i;
|
||||
|
||||
pdValues = (double*) malloc(iRows * iCols * sizeof(double));
|
||||
for (i=0; i<iRows * iCols; i++)
|
||||
pdValues[i] = pucValues[i];
|
||||
|
||||
sciErr = createMatrixOfDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, iRows, iCols, pdValues);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
free(pdValues);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
free(pdValues);
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
204
Lib/scilab/sciunsignedint.swg
Normal file
204
Lib/scilab/sciunsignedint.swg
Normal file
|
|
@ -0,0 +1,204 @@
|
|||
/*
|
||||
* C-type: unsigned int
|
||||
* Scilab type: double or uint32
|
||||
*/
|
||||
%fragment(SWIG_AsVal_frag(unsigned int), "header", fragment="SWIG_SciDoubleOrUint32_AsUnsignedInt", fragment="<limits.h>") {
|
||||
%#define SWIG_AsVal_unsigned_SS_int(scilabValue, valuePointer) SWIG_SciDoubleOrUint32_AsUnsignedInt(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName())
|
||||
}
|
||||
%fragment("SWIG_SciDoubleOrUint32_AsUnsignedInt", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciDoubleOrUint32_AsUnsignedInt(void *pvApiCtx, int iVar, unsigned int *puiValue, char *fname) {
|
||||
SciErr sciErr;
|
||||
int iType = 0;
|
||||
int iRows = 0;
|
||||
int iCols = 0;
|
||||
int iPrec = 0;
|
||||
int *piAddrVar = NULL;
|
||||
unsigned int *puiData = NULL;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (iType == sci_ints) {
|
||||
if (puiValue) {
|
||||
sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iPrec != SCI_UINT32) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 32-bit unsigned integer or a double expected.\n"), fname, iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getMatrixOfUnsignedInteger32(pvApiCtx, piAddrVar, &iRows, &iCols, &puiData);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iRows * iCols != 1) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 32-bit unsigned integer or a double expected.\n"), fname, iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
*puiValue = *puiData;
|
||||
}
|
||||
}
|
||||
else if (iType == sci_matrix) {
|
||||
if (puiValue) {
|
||||
double *pdData = NULL;
|
||||
double dValue = 0.0f;
|
||||
sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, &iRows, &iCols, &pdData);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iRows * iCols != 1) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 32-bit unsigned integer or a double expected.\n"), fname, iVar);
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
dValue = *pdData;
|
||||
if (dValue != floor(dValue)) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Incorrect value for input argument #%d: The double value cannot be converted to a 32-bit unsigned integer.\n"), fname, iVar);
|
||||
return SWIG_ValueError;
|
||||
}
|
||||
if ((dValue < 0) || (dValue > UINT_MAX)) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Overflow error for input argument #%d: The double value cannot be converted to a 32-bit unsigned integer.\n"), fname, iVar);
|
||||
return SWIG_OverflowError;
|
||||
}
|
||||
*puiValue = (unsigned int) dValue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 32-bit unsigned integer or a double expected.\n"), fname, iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_frag(unsigned int), "header", fragment="SWIG_SciDouble_FromUnsignedInt") {
|
||||
%#define SWIG_From_unsigned_SS_int(scilabValue) SWIG_SciDouble_FromUnsignedInt(pvApiCtx, SWIG_Scilab_GetOutputPosition(), scilabValue, SWIG_Scilab_GetFuncName())
|
||||
}
|
||||
%fragment("SWIG_SciDouble_FromUnsignedInt", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciDouble_FromUnsignedInt(void *pvApiCtx, int iVarOut, unsigned int uiValue, char *fname) {
|
||||
if (createScalarDouble(pvApiCtx,
|
||||
SWIG_NbInputArgument(pvApiCtx) + iVarOut, (double) uiValue))
|
||||
return SWIG_ERROR;
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* C-type: unsigned int[]
|
||||
* Scilab type: uint32 vector
|
||||
*/
|
||||
%fragment("SWIG_SciDoubleOrUint32_AsUnsignedIntArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciDoubleOrUint32_AsUnsignedIntArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, unsigned int **puiValue, char *fname) {
|
||||
SciErr sciErr;
|
||||
int iType = 0;
|
||||
int iPrec = 0;
|
||||
int *piAddrVar = NULL;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (iType == sci_matrix) {
|
||||
double *pdData = NULL;
|
||||
int size = 0;
|
||||
int i;
|
||||
|
||||
sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, iRows, iCols, &pdData);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
size = (*iRows) * (*iCols);
|
||||
*puiValue = (unsigned int*) malloc(size * sizeof(int*));
|
||||
for (i = 0; i < size; i++)
|
||||
(*puiValue)[i] = (unsigned int) pdData[i];
|
||||
}
|
||||
else if (iType == sci_ints) {
|
||||
sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (iPrec != SCI_UINT32) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 32-bit unsigned integer or a double vector expected.\n"), fname, iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getMatrixOfUnsignedInteger32(pvApiCtx, piAddrVar, iRows, iCols, puiValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 32-bit unsigned integer or a double vector expected.\n"), fname, iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment("SWIG_SciDouble_FromUnsignedIntArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciDouble_FromUnsignedIntArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, unsigned int *puiValues) {
|
||||
SciErr sciErr;
|
||||
double *pdValues = NULL;
|
||||
int i;
|
||||
|
||||
pdValues = (double*) malloc(iRows * iCols * sizeof(double));
|
||||
for (i=0; i<iRows * iCols; i++)
|
||||
pdValues[i] = puiValues[i];
|
||||
|
||||
sciErr = createMatrixOfDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, iRows, iCols, pdValues);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
free(pdValues);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
free(pdValues);
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_CreateScilabVariable_frag(uint), "wrapper") {
|
||||
SWIGINTERN int
|
||||
SWIG_CreateScilabVariable_dec(uint)(void *pvApiCtx, const char* psVariableName, const unsigned int uiVariableValue) {
|
||||
SciErr sciErr;
|
||||
sciErr = createNamedMatrixOfUnsignedInteger32(pvApiCtx, psVariableName, 1, 1, &uiVariableValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
53
Lib/scilab/sciunsignedlong.swg
Normal file
53
Lib/scilab/sciunsignedlong.swg
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* C-type: unsigned long
|
||||
* Scilab type: see unsigned int
|
||||
*/
|
||||
|
||||
%fragment(SWIG_AsVal_frag(unsigned long), "header", fragment="SWIG_UnsignedInt_AsUnsignedLong") {
|
||||
#define SWIG_AsVal_unsigned_SS_long(scilabValue, valuePointer) SWIG_UnsignedInt_AsUnsignedLong(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName())
|
||||
}
|
||||
%fragment("SWIG_UnsignedInt_AsUnsignedLong", "header", fragment=SWIG_AsVal_frag(unsigned int)) {
|
||||
SWIGINTERN int
|
||||
SWIG_UnsignedInt_AsUnsignedLong(void *pvApiCtx, SwigSciObject iVar, unsigned long *pulValue, char *fname) {
|
||||
unsigned int uiValue = 0;
|
||||
if(SWIG_AsVal_unsigned_SS_int(iVar, &uiValue) != SWIG_OK) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
*pulValue = (unsigned long) uiValue;
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_frag(unsigned long), "header", fragment="SWIG_UnsignedInt_FromUnsignedLong") {
|
||||
#define SWIG_From_unsigned_SS_long(scilabValue) SWIG_UnsignedInt_FromUnsignedLong(pvApiCtx, SWIG_Scilab_GetOutputPosition(), scilabValue, SWIG_Scilab_GetFuncName())
|
||||
}
|
||||
%fragment("SWIG_UnsignedInt_FromUnsignedLong", "header", fragment=SWIG_From_frag(unsigned int)) {
|
||||
SWIGINTERN int
|
||||
SWIG_UnsignedInt_FromUnsignedLong(void *pvApiCtx, int iVarOut, unsigned long ulValue, char *fname) {
|
||||
return SWIG_From_unsigned_SS_int((unsigned int)ulValue);
|
||||
}
|
||||
}
|
||||
|
||||
%fragment("SWIG_SciDouble_FromUnsignedLongArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciDouble_FromUnsignedLongArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, const unsigned long *pulValues) {
|
||||
SciErr sciErr;
|
||||
double *pdValues = NULL;
|
||||
int i;
|
||||
|
||||
pdValues = (double*) malloc(iRows * iCols * sizeof(double));
|
||||
for (i=0; i<iRows * iCols; i++) {
|
||||
pdValues[i] = pulValues[i];
|
||||
}
|
||||
|
||||
sciErr = createMatrixOfDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, iRows, iCols, pdValues);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
free(pdValues);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
free(pdValues);
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
189
Lib/scilab/sciunsignedshort.swg
Normal file
189
Lib/scilab/sciunsignedshort.swg
Normal file
|
|
@ -0,0 +1,189 @@
|
|||
/*
|
||||
* C-type: unsigned short
|
||||
* Scilab type: double or uint16
|
||||
*/
|
||||
%fragment(SWIG_AsVal_frag(unsigned short), "header", fragment="SWIG_SciDoubleOrUint16_AsUnsignedShort", fragment="<limits.h>") {
|
||||
%#define SWIG_AsVal_unsigned_SS_short(scilabValue, valuePointer) SWIG_SciDoubleOrUint16_AsUnsignedShort(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName())
|
||||
}
|
||||
%fragment("SWIG_SciDoubleOrUint16_AsUnsignedShort", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciDoubleOrUint16_AsUnsignedShort(void *pvApiCtx, int iVar, unsigned short *pusValue, char *fname) {
|
||||
SciErr sciErr;
|
||||
int iType = 0;
|
||||
int iRows = 0;
|
||||
int iCols = 0;
|
||||
int iPrec = 0;
|
||||
int *piAddrVar = NULL;
|
||||
unsigned short *pusData = NULL;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (iType == sci_ints) {
|
||||
if (pusValue) {
|
||||
sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iPrec != SCI_UINT16) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 16-bit unsigned integer or a double expected.\n"), fname, iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getMatrixOfUnsignedInteger16(pvApiCtx, piAddrVar, &iRows, &iCols, &pusData);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iRows * iCols != 1) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 16-bit unsigned integer or a double expected.\n"), fname, iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
*pusValue = *pusData;
|
||||
}
|
||||
}
|
||||
else if (iType == sci_matrix) {
|
||||
if (pusValue) {
|
||||
double *pdData = NULL;
|
||||
double dValue = 0.0f;
|
||||
sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, &iRows, &iCols, &pdData);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iRows * iCols != 1) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 16-bit unsigned integer or a double expected.\n"), fname, iVar);
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
dValue = *pdData;
|
||||
if (dValue != floor(dValue)) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Incorrect value for input argument #%d: The double value cannot be converted to a 16-bit unsigned integer.\n"), fname, iVar);
|
||||
return SWIG_ValueError;
|
||||
}
|
||||
if ((dValue < 0) || (dValue > USHRT_MAX)) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Overflow error for input argument #%d: The double value cannot be converted to a 16-bit unsigned integer.\n"), fname, iVar);
|
||||
return SWIG_OverflowError;
|
||||
}
|
||||
*pusValue = (unsigned short) dValue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 16-bit unsigned integer or a double expected.\n"), fname, iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_frag(unsigned short), "header", fragment="SWIG_SciDouble_FromUnsignedShort") {
|
||||
%#define SWIG_From_unsigned_SS_short(scilabValue) SWIG_SciDouble_FromUnsignedShort(pvApiCtx, SWIG_Scilab_GetOutputPosition(), scilabValue, SWIG_Scilab_GetFuncName())
|
||||
}
|
||||
%fragment("SWIG_SciDouble_FromUnsignedShort", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciDouble_FromUnsignedShort(void *pvApiCtx, int iVarOut, unsigned short usValue, char *fname) {
|
||||
if (createScalarDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, (double) usValue))
|
||||
return SWIG_ERROR;
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* C-type: unsigned short[]
|
||||
* Scilab type: uint16 vector
|
||||
*/
|
||||
%fragment("SWIG_SciDoubleOrUint16_AsUnsignedShortArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciDoubleOrUint16_AsUnsignedShortArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, unsigned short **pusValue, char *fname) {
|
||||
SciErr sciErr;
|
||||
int iType = 0;
|
||||
int iPrec = 0;
|
||||
int *piAddrVar = NULL;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (iType == sci_matrix) {
|
||||
double *pdData = NULL;
|
||||
int size = 0;
|
||||
int i;
|
||||
|
||||
sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, iRows, iCols, &pdData);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
size = (*iRows) * (*iCols);
|
||||
*pusValue = (unsigned short*) malloc(size * sizeof(int*));
|
||||
for (i = 0; i < size; i++)
|
||||
(*pusValue)[i] = (unsigned short) pdData[i];
|
||||
}
|
||||
else if (iType == sci_ints) {
|
||||
sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (iPrec != SCI_UINT16) {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 16-bit unsigned integer or a double vector expected.\n"), fname, iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getMatrixOfUnsignedInteger16(pvApiCtx, piAddrVar, iRows, iCols, pusValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 16-bit unsigned integer or a double vector expected.\n"), fname, iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment("SWIG_SciDouble_FromUnsignedShortArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciDouble_FromUnsignedShortArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, unsigned short *pusValues) {
|
||||
SciErr sciErr;
|
||||
double *pdValues = NULL;
|
||||
int i;
|
||||
|
||||
pdValues = (double*) malloc(iRows * iCols * sizeof(double));
|
||||
for (i=0; i<iRows * iCols; i++)
|
||||
pdValues[i] = pusValues[i];
|
||||
|
||||
sciErr = createMatrixOfDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, iRows, iCols, pdValues);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
free(pdValues);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
free(pdValues);
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
2
Lib/scilab/std_alloc.i
Normal file
2
Lib/scilab/std_alloc.i
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
%include <std/std_alloc.i>
|
||||
|
||||
47
Lib/scilab/std_basic_string.i
Normal file
47
Lib/scilab/std_basic_string.i
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* C++: basic_string<char>
|
||||
* Scilab: string
|
||||
*/
|
||||
|
||||
#define %swig_basic_string(Type...) %swig_sequence_methods_val(Type)
|
||||
|
||||
%fragment(SWIG_AsPtr_frag(std::basic_string<char>), "header", fragment="SWIG_SciString_AsCharPtrAndLength") {
|
||||
SWIGINTERN int
|
||||
SWIG_AsPtr_dec(std::basic_string<char>)(int _iVar, std::basic_string<char> **_pstValue) {
|
||||
char* buf = 0;
|
||||
size_t len = 0;
|
||||
int alloc = SWIG_OLDOBJ;
|
||||
|
||||
if (SWIG_IsOK((SWIG_SciString_AsCharPtrAndSize(pvApiCtx, _iVar, &buf, &len, &alloc, SWIG_Scilab_GetFuncName())))) {
|
||||
if (buf) {
|
||||
if (_pstValue) {
|
||||
*_pstValue = new std::string(buf, len - 1);
|
||||
sciprint("%s\n", (*_pstValue)->c_str());
|
||||
}
|
||||
if (alloc == SWIG_NEWOBJ) {
|
||||
delete[] buf;
|
||||
}
|
||||
return SWIG_NEWOBJ;
|
||||
}
|
||||
else {
|
||||
if (_pstValue) {
|
||||
*_pstValue = NULL;
|
||||
}
|
||||
return SWIG_OLDOBJ;
|
||||
}
|
||||
} else {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_frag(std::basic_string<char>), "header", fragment="SWIG_SciString_FromCharPtr") {
|
||||
SWIGINTERN int
|
||||
SWIG_From_dec(std::basic_string<char>)(std::basic_string<char> _pstValue) {
|
||||
return SWIG_SciString_FromCharPtr(pvApiCtx, SWIG_Scilab_GetOutputPosition(), _pstValue.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
%include <std/std_basic_string.i>
|
||||
|
||||
|
||||
1
Lib/scilab/std_char_traits.i
Normal file
1
Lib/scilab/std_char_traits.i
Normal file
|
|
@ -0,0 +1 @@
|
|||
%include <std/std_char_traits.i>
|
||||
72
Lib/scilab/std_common.i
Normal file
72
Lib/scilab/std_common.i
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
%include <std/std_except.i>
|
||||
%include <scistdcommon.swg>
|
||||
|
||||
|
||||
// Generate the traits for a 'primitive' type, such as 'double',
|
||||
// for which the SWIG_AsVal and SWIG_From methods are already defined.
|
||||
|
||||
%define %traits_ptypen(Type...)
|
||||
%fragment(SWIG_Traits_frag(Type),"header",
|
||||
fragment=SWIG_AsVal_frag(Type),
|
||||
fragment=SWIG_From_frag(Type),
|
||||
fragment="StdTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits<Type > {
|
||||
typedef value_category category;
|
||||
static const char* type_name() { return #Type; }
|
||||
};
|
||||
template <> struct traits_asval<Type > {
|
||||
typedef Type value_type;
|
||||
static int asval(SwigSciObject obj, value_type *val) {
|
||||
return SWIG_AsVal(Type)(obj, val);
|
||||
}
|
||||
};
|
||||
template <> struct traits_from<Type > {
|
||||
typedef Type value_type;
|
||||
static SwigSciObject from(const value_type& val) {
|
||||
return SWIG_From(Type)(val);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
%enddef
|
||||
|
||||
/* Traits for enums. This is bit of a sneaky trick needed because a generic template specialization of enums
|
||||
is not possible (unless using template meta-programming which SWIG doesn't support because of the explicit
|
||||
instantiations required using %template). The STL containers define the 'front' method and the typemap
|
||||
below is used whenever the front method is wrapped returning an enum. This typemap simply picks up the
|
||||
standard enum typemap, but additionally drags in a fragment containing the traits_asval and traits_from
|
||||
required in the generated code for enums. */
|
||||
|
||||
%define %traits_enum(Type...)
|
||||
%fragment("SWIG_Traits_enum_"{Type},"header",
|
||||
fragment=SWIG_AsVal_frag(int),
|
||||
fragment=SWIG_From_frag(int),
|
||||
fragment="StdTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits_asval<Type > {
|
||||
typedef Type value_type;
|
||||
static int asval(SwigSciObject obj, value_type *val) {
|
||||
return SWIG_AsVal(int)(obj, (int *)val);
|
||||
}
|
||||
};
|
||||
template <> struct traits_from<Type > {
|
||||
typedef Type value_type;
|
||||
static SwigSciObject from(const value_type& val) {
|
||||
return SWIG_From(int)((int)val);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
%typemap(out, fragment="SWIG_Traits_enum_"{Type}) const enum SWIGTYPE& front %{$typemap(out, const enum SWIGTYPE&)%}
|
||||
%enddef
|
||||
|
||||
|
||||
%include <std/std_common.i>
|
||||
|
||||
//
|
||||
// Generates the traits for all the known primitive
|
||||
// C++ types (int, double, ...)
|
||||
//
|
||||
%apply_cpptypes(%traits_ptypen);
|
||||
|
||||
3
Lib/scilab/std_container.i
Normal file
3
Lib/scilab/std_container.i
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
%include <scicontainer.swg>
|
||||
%include <std/std_container.i>
|
||||
|
||||
31
Lib/scilab/std_deque.i
Normal file
31
Lib/scilab/std_deque.i
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
*
|
||||
* C++ type : STL deque
|
||||
* Scilab type : matrix (for primitive types) or list (for pointer types)
|
||||
*
|
||||
*/
|
||||
|
||||
%fragment("StdDequeTraits", "header", fragment="StdSequenceTraits")
|
||||
%{
|
||||
namespace swig {
|
||||
template <class T>
|
||||
struct traits_asptr<std::deque<T> > {
|
||||
static int asptr(const SwigSciObject &obj, std::deque<T> **deq) {
|
||||
return traits_asptr_stdseq<std::deque<T> >::asptr(obj, deq);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct traits_from<std::deque<T> > {
|
||||
static SwigSciObject from(const std::deque<T>& deq) {
|
||||
return traits_from_stdseq<std::deque<T> >::from(deq);
|
||||
}
|
||||
};
|
||||
}
|
||||
%}
|
||||
|
||||
|
||||
#define %swig_deque_methods(Type...) %swig_sequence_methods(Type)
|
||||
#define %swig_deque_methods_val(Type...) %swig_sequence_methods_val(Type);
|
||||
|
||||
%include <std/std_deque.i>
|
||||
1
Lib/scilab/std_except.i
Normal file
1
Lib/scilab/std_except.i
Normal file
|
|
@ -0,0 +1 @@
|
|||
%include <typemaps/std_except.swg>
|
||||
30
Lib/scilab/std_list.i
Normal file
30
Lib/scilab/std_list.i
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
*
|
||||
* C++ type : STL list
|
||||
* Scilab type : matrix (for primitive types) or list (for pointer types)
|
||||
*
|
||||
*/
|
||||
|
||||
%fragment("StdListTraits", "header", fragment="StdSequenceTraits")
|
||||
%{
|
||||
namespace swig {
|
||||
template <class T >
|
||||
struct traits_asptr<std::list<T> > {
|
||||
static int asptr(SwigSciObject obj, std::list<T> **lis) {
|
||||
return traits_asptr_stdseq<std::list<T> >::asptr(obj, lis);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct traits_from<std::list<T> > {
|
||||
static SwigSciObject from(const std::list<T> &lis) {
|
||||
return traits_from_stdseq<std::list<T> >::from(lis);
|
||||
}
|
||||
};
|
||||
}
|
||||
%}
|
||||
|
||||
#define %swig_list_methods(Type...) %swig_sequence_methods(Type)
|
||||
#define %swig_list_methods_val(Type...) %swig_sequence_methods_val(Type);
|
||||
|
||||
%include <std/std_list.i>
|
||||
69
Lib/scilab/std_map.i
Normal file
69
Lib/scilab/std_map.i
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
//
|
||||
// SWIG typemaps for std::map
|
||||
//
|
||||
// Common implementation
|
||||
|
||||
%include <std_common.i>
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// std::map
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
%{
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
%}
|
||||
|
||||
// exported class
|
||||
|
||||
namespace std {
|
||||
|
||||
template<class K, class T> class map {
|
||||
// add typemaps here
|
||||
public:
|
||||
map();
|
||||
map(const map<K,T> &);
|
||||
|
||||
unsigned int size() const;
|
||||
bool empty() const;
|
||||
void clear();
|
||||
%extend {
|
||||
const T& get(const K& key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
return i->second;
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
void set(const K& key, const T& x) {
|
||||
(*self)[key] = x;
|
||||
}
|
||||
void del(const K& key) throw (std::out_of_range) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
if (i != self->end())
|
||||
self->erase(i);
|
||||
else
|
||||
throw std::out_of_range("key not found");
|
||||
}
|
||||
bool has_key(const K& key) {
|
||||
std::map<K,T >::iterator i = self->find(key);
|
||||
return i != self->end();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Legacy macros (deprecated)
|
||||
%define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO)
|
||||
#warning "specialize_std_map_on_key ignored - macro is deprecated and no longer necessary"
|
||||
%enddef
|
||||
|
||||
%define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO)
|
||||
#warning "specialize_std_map_on_value ignored - macro is deprecated and no longer necessary"
|
||||
%enddef
|
||||
|
||||
%define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO)
|
||||
#warning "specialize_std_map_on_both ignored - macro is deprecated and no longer necessary"
|
||||
%enddef
|
||||
|
||||
}
|
||||
30
Lib/scilab/std_multiset.i
Normal file
30
Lib/scilab/std_multiset.i
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
*
|
||||
* C++ type : STL multiset
|
||||
* Scilab type : matrix (for primitive types) or list (for pointer types)
|
||||
*
|
||||
*/
|
||||
|
||||
%fragment("StdMultisetTraits", "header", fragment="StdSequenceTraits")
|
||||
%{
|
||||
namespace swig {
|
||||
template <class T>
|
||||
struct traits_asptr<std::multiset<T> > {
|
||||
static int asptr(const SwigSciObject &obj, std::multiset<T> **multiset) {
|
||||
return traits_asptr_stdseq<std::multiset<T> >::asptr(obj, multiset);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct traits_from<std::multiset<T> > {
|
||||
static SwigSciObject from(const std::multiset<T>& multiset) {
|
||||
return traits_from_stdseq<std::multiset<T> >::from(multiset);
|
||||
}
|
||||
};
|
||||
}
|
||||
%}
|
||||
|
||||
#define %swig_multiset_methods(Set...) %swig_sequence_methods(Type)
|
||||
#define %swig_multiset_methods_val(Type...) %swig_sequence_methods_val(Type);
|
||||
|
||||
%include <std/std_multiset.i>
|
||||
34
Lib/scilab/std_pair.i
Normal file
34
Lib/scilab/std_pair.i
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* std_pair.i
|
||||
*
|
||||
* Typemaps for std::pair
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include <std_common.i>
|
||||
%include <exception.i>
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// std::pair
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
%{
|
||||
#include <utility>
|
||||
%}
|
||||
|
||||
namespace std {
|
||||
|
||||
template<class T, class U> struct pair {
|
||||
|
||||
pair();
|
||||
pair(T first, U second);
|
||||
pair(const pair& p);
|
||||
|
||||
template <class U1, class U2> pair(const pair<U1, U2> &p);
|
||||
|
||||
T first;
|
||||
U second;
|
||||
};
|
||||
|
||||
// add specializations here
|
||||
|
||||
}
|
||||
32
Lib/scilab/std_set.i
Normal file
32
Lib/scilab/std_set.i
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
*
|
||||
* C++ type : STL set
|
||||
* Scilab type : matrix (for primitive types) or list (for pointer types)
|
||||
*
|
||||
*/
|
||||
|
||||
%fragment("StdSetTraits", "header", fragment="StdSequenceTraits")
|
||||
%{
|
||||
namespace swig {
|
||||
template <class T>
|
||||
struct traits_asptr<std::set<T> > {
|
||||
static int asptr(const SwigSciObject &obj, std::set<T> **set) {
|
||||
return traits_asptr_stdseq<std::set<T> >::asptr(obj, set);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct traits_from<std::set<T> > {
|
||||
static SwigSciObject from(const std::set<T>& set) {
|
||||
return traits_from_stdseq<std::set<T> >::from(set);
|
||||
}
|
||||
};
|
||||
}
|
||||
%}
|
||||
|
||||
|
||||
#define %swig_set_methods(Type...) %swig_sequence_methods(Type)
|
||||
#define %swig_set_methods_val(Type...) %swig_sequence_methods_val(Type);
|
||||
|
||||
%include <std/std_set.i>
|
||||
|
||||
39
Lib/scilab/std_string.i
Normal file
39
Lib/scilab/std_string.i
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* POINTER
|
||||
*/
|
||||
%fragment(SWIG_AsPtr_frag(std::string), "header", fragment="SWIG_SciString_AsCharPtrAndSize") {
|
||||
SWIGINTERN int
|
||||
SWIG_AsPtr_dec(std::string)(int iVar, std::string **pstValue) {
|
||||
char* buf = 0;
|
||||
size_t size = 0;
|
||||
int alloc = SWIG_OLDOBJ;
|
||||
|
||||
if (SWIG_IsOK((SWIG_SciString_AsCharPtrAndSize(pvApiCtx, iVar, &buf, &size, &alloc, SWIG_Scilab_GetFuncName())))) {
|
||||
if (buf) {
|
||||
if (pstValue) {
|
||||
*pstValue = new std::string(buf, size);
|
||||
}
|
||||
if (alloc == SWIG_NEWOBJ) {
|
||||
delete[] buf;
|
||||
}
|
||||
return SWIG_NEWOBJ;
|
||||
} else {
|
||||
if (pstValue) {
|
||||
*pstValue = NULL;
|
||||
}
|
||||
return SWIG_OLDOBJ;
|
||||
}
|
||||
} else {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_frag(std::string), "header", fragment="SWIG_SciString_FromCharPtr") {
|
||||
SWIGINTERN int
|
||||
SWIG_From_dec(std::string)(std::string pstValue) {
|
||||
return SWIG_SciString_FromCharPtr(pvApiCtx, SWIG_Scilab_GetOutputPosition(), pstValue.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
%include <typemaps/std_string.swg>
|
||||
31
Lib/scilab/std_vector.i
Normal file
31
Lib/scilab/std_vector.i
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
*
|
||||
* C++ type : STL vector
|
||||
* Scilab type : matrix (for primitive types) or list (for pointer types)
|
||||
*
|
||||
*/
|
||||
|
||||
%fragment("StdVectorTraits", "header", fragment="StdSequenceTraits")
|
||||
%{
|
||||
namespace swig {
|
||||
template <class T>
|
||||
struct traits_asptr<std::vector<T> > {
|
||||
static int asptr(const SwigSciObject &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 SwigSciObject 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);
|
||||
|
||||
%include <std/std_vector.i>
|
||||
6
Lib/scilab/stl.i
Normal file
6
Lib/scilab/stl.i
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
/* initial STL definition. extended as needed in each language */
|
||||
%include <std_common.i>
|
||||
%include <std_string.i>
|
||||
%include <std_vector.i>
|
||||
%include <std_map.i>
|
||||
%include <std_pair.i>
|
||||
62
Lib/scilab/typemaps.i
Normal file
62
Lib/scilab/typemaps.i
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* typemaps.i
|
||||
*
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
// INPUT typemaps
|
||||
%define %scilab_input_typemap(Type)
|
||||
%typemap(in, noblock=1, fragment=SWIG_AsVal_frag(Type)) Type *INPUT(Type temp)(int ecode), Type &INPUT(Type temp)(int ecode) {
|
||||
ecode = SWIG_AsVal_dec(Type)($input, &temp);
|
||||
if (!SWIG_IsOK(ecode)) {
|
||||
%argument_fail(ecode, "$type", $symname, $argnum);
|
||||
}
|
||||
$1 = &temp;
|
||||
}
|
||||
|
||||
%typemap(freearg, noblock=1) Type *INPUT, Type &INPUT {
|
||||
}
|
||||
|
||||
%typemap(typecheck) Type *INPUT, Type &INPUT {
|
||||
}
|
||||
%enddef
|
||||
|
||||
// OUTPUT typemaps
|
||||
%define %scilab_output_typemap(Type)
|
||||
%typemap(argout, noblock=1, fragment=SWIG_From_frag(Type)) Type *OUTPUT, Type &OUTPUT {
|
||||
%set_output(SWIG_From_dec(Type)(*$1));
|
||||
}
|
||||
%enddef
|
||||
|
||||
// INOUT typemaps
|
||||
%define %scilab_inout_typemap(Type)
|
||||
%typemap(in) Type *INOUT = Type *INPUT;
|
||||
%typemap(in) Type &INOUT = Type &INPUT;
|
||||
%typemap(argout) Type *INOUT = Type *OUTPUT;
|
||||
%typemap(argout) Type &INOUT = Type &OUTPUT;
|
||||
%enddef
|
||||
|
||||
|
||||
%define %scilab_inout_typemaps(Type)
|
||||
%scilab_input_typemap(%arg(Type))
|
||||
%scilab_output_typemap(%arg(Type))
|
||||
%scilab_inout_typemap(%arg(Type))
|
||||
%enddef
|
||||
|
||||
%scilab_inout_typemaps(double);
|
||||
%scilab_inout_typemaps(signed char);
|
||||
%scilab_inout_typemaps(unsigned char);
|
||||
%scilab_inout_typemaps(short);
|
||||
%scilab_inout_typemaps(unsigned short);
|
||||
%scilab_inout_typemaps(int);
|
||||
%scilab_inout_typemaps(unsigned int);
|
||||
%scilab_inout_typemaps(long);
|
||||
%scilab_inout_typemaps(unsigned long);
|
||||
%scilab_inout_typemaps(bool);
|
||||
%scilab_inout_typemaps(float);
|
||||
|
||||
//%apply_ctypes(%scilab_inout_typemaps);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -42,7 +42,7 @@
|
|||
#include <limits.h>
|
||||
#endif
|
||||
#if (__WORDSIZE == 64) || (LONG_MAX != INT_MAX)
|
||||
# error "SWIG wrapped code invalid in 64 bit architecture, regenarete code using -DSWIGWORDSIZE64"
|
||||
# error "SWIG wrapped code invalid in 64 bit architecture, regenerate code using -DSWIGWORDSIZE64"
|
||||
#endif
|
||||
%}
|
||||
#endif
|
||||
|
|
@ -54,7 +54,7 @@
|
|||
#include <limits.h>
|
||||
#endif
|
||||
#if (__WORDSIZE == 32) || (LONG_MAX == INT_MAX)
|
||||
# error "SWIG wrapped code invalid in 32 bit architecture, regenarete code using -DSWIGWORDSIZE32"
|
||||
# error "SWIG wrapped code invalid in 32 bit architecture, regenerate code using -DSWIGWORDSIZE32"
|
||||
#endif
|
||||
%}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ SWIGRUNTIME void
|
|||
SWIG_InitializeModule(void *clientdata) {
|
||||
size_t i;
|
||||
swig_module_info *module_head, *iter;
|
||||
int found, init;
|
||||
int init;
|
||||
|
||||
/* check to see if the circular list has been setup, if not, set it up */
|
||||
if (swig_module.next==0) {
|
||||
|
|
@ -74,22 +74,18 @@ SWIG_InitializeModule(void *clientdata) {
|
|||
/* This is the first module loaded for this interpreter */
|
||||
/* so set the swig module into the interpreter */
|
||||
SWIG_SetModule(clientdata, &swig_module);
|
||||
module_head = &swig_module;
|
||||
} else {
|
||||
/* the interpreter has loaded a SWIG module, but has it loaded this one? */
|
||||
found=0;
|
||||
iter=module_head;
|
||||
do {
|
||||
if (iter==&swig_module) {
|
||||
found=1;
|
||||
break;
|
||||
/* Our module is already in the list, so there's nothing more to do. */
|
||||
return;
|
||||
}
|
||||
iter=iter->next;
|
||||
} while (iter!= module_head);
|
||||
|
||||
/* if the is found in the list, then all is done and we may leave */
|
||||
if (found) return;
|
||||
/* otherwise we must add out module into the list */
|
||||
/* otherwise we must add our module into the list */
|
||||
swig_module.next = module_head->next;
|
||||
module_head->next = &swig_module;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,3 +106,7 @@
|
|||
# define _SCL_SECURE_NO_DEPRECATE
|
||||
#endif
|
||||
|
||||
/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */
|
||||
#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES)
|
||||
# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -300,7 +300,7 @@
|
|||
|
||||
/* varout */
|
||||
|
||||
%typemap(varout,noblock=1,fragment=#SWIG_CharBufLen)
|
||||
%typemap(varout,fragment=#SWIG_CharBufLen)
|
||||
Char [ANY], const Char [ANY] {
|
||||
%#ifndef SWIG_PRESERVE_CARRAY_SIZE
|
||||
size_t size = SWIG_CharBufLen($1, $1_dim0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue