Implement functionwrapper
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@11242 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
f2c5fb59d6
commit
4aa72f9b01
16 changed files with 739 additions and 12 deletions
0
Lib/scilab/scifragments.swg
Normal file
0
Lib/scilab/scifragments.swg
Normal file
4
Lib/scilab/scilab.swg
Normal file
4
Lib/scilab/scilab.swg
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
%include <typemaps/swigmacros.swg>
|
||||
%include <typemaps/fragments.swg>
|
||||
%include <scitypemaps.swg>
|
||||
|
||||
123
Lib/scilab/scitypemaps.swg
Normal file
123
Lib/scilab/scitypemaps.swg
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
|
||||
// Include fundamental fragemt definitions
|
||||
%include <typemaps/fragments.swg>
|
||||
|
||||
// Look for user fragments file.
|
||||
%include <scifragments.swg>
|
||||
|
||||
// Scilab fragments for primitive types
|
||||
%include <sciprimtypes.swg>
|
||||
|
||||
// Include the unified typemap library
|
||||
//%include <typemaps/swigtypemaps.swg>
|
||||
|
||||
|
||||
%typemap(in) char (int m, int n,int l),
|
||||
signed char (int m,int n,int l),
|
||||
unsigned char(int m,int n,int l)
|
||||
{
|
||||
if (GetType($argnum) == sci_strings)
|
||||
{
|
||||
GetRhsVar($argnum,STRING_DATATYPE,&m,&n,&l);
|
||||
$1=($1_ltype)(*cstk(l));
|
||||
}
|
||||
else
|
||||
Scierror(999,"error ...\n");
|
||||
}
|
||||
|
||||
%typemap(in) short (int m, int n,int l),
|
||||
unsigned short (int m,int n,int l),
|
||||
int(int m,int n,int l),
|
||||
unsigned int(int m, int n,int l),
|
||||
long(int m,int n,int l),
|
||||
unsigned long(int m,int n,int l),
|
||||
double(int m,int n,int l)
|
||||
|
||||
|
||||
{
|
||||
if (GetType($argnum) == sci_matrix)
|
||||
{
|
||||
GetRhsVar($argnum,MATRIX_OF_DOUBLE_DATATYPE,&m,&n,&l);
|
||||
$1=($1_ltype)(*stk(l));
|
||||
}
|
||||
else
|
||||
Scierror(999,"error ...\n");
|
||||
}
|
||||
|
||||
%typemap(in) float (int m, int n,int l)
|
||||
{
|
||||
if (GetType($argnum) == sci_matrix)
|
||||
{
|
||||
GetRhsVar($argnum,MATRIX_OF_DOUBLE_DATATYPE,&m,&n,&l);
|
||||
$1=($1_ltype)(*stk(l));
|
||||
}
|
||||
else
|
||||
Scierror(999,"error ...\n");
|
||||
}
|
||||
|
||||
%typemap(in) char *(int m,int n,int l)
|
||||
{
|
||||
if (GetType($argnum) == sci_strings)
|
||||
{
|
||||
GetRhsVar($argnum,STRING_DATATYPE,&m,&n,&l);
|
||||
$1=($1_ltype)strdup(cstk(l));
|
||||
}
|
||||
else
|
||||
Scierror(999,"error ...\n");
|
||||
|
||||
}
|
||||
|
||||
|
||||
%typemap(out) char (int m, int n,int l),
|
||||
signed char (int m,int n,int l),
|
||||
unsigned char(int m,int n,int l)
|
||||
{
|
||||
m=1,n=1;
|
||||
CreateVar(Rhs+1,STRING_DATATYPE,&m,&n,&l);
|
||||
*cstk(l)=$1;
|
||||
LhsVar(1)=Rhs+1;
|
||||
}
|
||||
|
||||
%typemap(out) short (int m, int n,int l),
|
||||
unsigned short (int m,int n,int l),
|
||||
int(int m,int n,int l),
|
||||
unsigned int(int m, int n,int l),
|
||||
long(int m,int n,int l),
|
||||
unsigned long(int m,int n,int l),
|
||||
double(int m,int n,int l)
|
||||
{
|
||||
m=1,n=1;
|
||||
CreateVar(Rhs+1,MATRIX_OF_DOUBLE_DATATYPE,&m,&n,&l);
|
||||
*stk(l)=(double)$1;
|
||||
LhsVar(1)=Rhs+1;
|
||||
}
|
||||
|
||||
%typemap(out) float (int m, int n,int l)
|
||||
{
|
||||
m=1,n=1;
|
||||
CreateVar(Rhs+1,MATRIX_OF_DOUBLE_DATATYPE,&m,&n,&l);
|
||||
*stk(l)=(double)$1;
|
||||
LhsVar(1)=Rhs+1;
|
||||
}
|
||||
|
||||
|
||||
%typemap(out) char *(int m,int n, int l)
|
||||
{
|
||||
m=1;
|
||||
if ($1)
|
||||
n = (int)strlen($1);
|
||||
else
|
||||
n = (int)strlen("");
|
||||
|
||||
CreateVar(Rhs+1,STRING_DATATYPE ,&m,&n,&l);
|
||||
if ($1) strcpy(cstk(l),$1);
|
||||
else strcpy(cstk(l),"");
|
||||
LhsVar(1) = Rhs+1;
|
||||
}
|
||||
|
||||
|
||||
%typemap(out,noblock=1) void
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
1
Lib/scilab/std_string.i
Normal file
1
Lib/scilab/std_string.i
Normal file
|
|
@ -0,0 +1 @@
|
|||
%include <typemaps/std_string.swg>
|
||||
10
Lib/scilab/std_vector.i
Normal file
10
Lib/scilab/std_vector.i
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
%fragment("StdVectorTraits","header")
|
||||
%{
|
||||
%}
|
||||
|
||||
#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>
|
||||
8
Lib/scilab/stl.i
Normal file
8
Lib/scilab/stl.i
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
/* initial STL definition. extended as needed in each language */
|
||||
%include std_common.i
|
||||
%include std_vector.i
|
||||
%include std_string.i
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue