Merge pull request #67 from smarchetto/gsoc2012-scilab
Scilab: generic support of STL containers
This commit is contained in:
commit
dde9dea5b0
60 changed files with 2048 additions and 996 deletions
|
|
@ -1147,14 +1147,14 @@ R_CFLAGS=-fPIC
|
|||
r: $(SRCS)
|
||||
$(SWIG) -r $(SWIGOPT) $(INTERFACEPATH)
|
||||
ifneq ($(SRCS),)
|
||||
$(CXX) -g -c $(CFLAGS) $(R_CFLAGS) $(SRCS) $(INCLUDES)
|
||||
$(CXX) -g -c $(CFLAGS) $(R_CFLAGS) $(SRCS) $(INCLUDES)
|
||||
endif
|
||||
+( PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) $(OBJS) > /dev/null )
|
||||
|
||||
r_cpp: $(CXXSRCS)
|
||||
$(SWIG) -c++ -r $(SWIGOPT) -o $(RCXXSRCS) $(INTERFACEPATH)
|
||||
ifneq ($(CXXSRCS),)
|
||||
$(CXX) -g -c $(CFLAGS) $(R_CFLAGS) $(CXXSRCS) $(INCLUDES)
|
||||
$(CXX) -g -c $(CFLAGS) $(R_CFLAGS) $(CXXSRCS) $(INCLUDES)
|
||||
endif
|
||||
+( PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) $(OBJS) > /dev/null )
|
||||
|
||||
|
|
@ -1217,19 +1217,26 @@ scilab_cpp: $(SRCS)
|
|||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH SCILABPATH=$(srcdir):$$SCILABPATH echo 'exit(1)' |$(SCILAB) -nwni -noatomsautoload -nb -f builder.sce; \
|
||||
fi
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# -----------------------------------------------------------------
|
||||
# Running a Scilab example
|
||||
# -----------------------------------------------------------------
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
scilab_run:
|
||||
@env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH SCILABPATH=$(srcdir):$$SCILABPATH $(SCILAB) -nwni -noatomsautoload -nb -f runme.sci
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# Debugging a scilab example
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
scilab_debug:
|
||||
@env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH SCILABPATH=$(srcdir):$$SCILABPATH $(SCILAB) -noatomsautoload -nb -debug -f runme.sci
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# Cleaning the scilab examples
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
scilab_clean:
|
||||
rm -f *.sce *.so lib*lib.c
|
||||
rm -f *.sce *.so lib*lib.c *_wrap.*
|
||||
|
||||
##################################################################
|
||||
##### Go ######
|
||||
|
|
|
|||
|
|
@ -5,10 +5,14 @@ contract
|
|||
enum
|
||||
funcptr
|
||||
matrix
|
||||
#matrix2
|
||||
matrix2
|
||||
pointer
|
||||
simple
|
||||
std_set
|
||||
std_vector/std_vector
|
||||
std_vector/std_vector_as_function_argument
|
||||
struct
|
||||
template
|
||||
variables
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
double sumMatrixElements(double *inputMatrix, int nbRow, int nbCol)
|
||||
// Double matrix functions
|
||||
|
||||
double sumDoubleMatrix(double *inputMatrix, int nbRow, int nbCol)
|
||||
{
|
||||
int i;
|
||||
double total = 0.0;
|
||||
|
|
@ -11,7 +13,7 @@ double sumMatrixElements(double *inputMatrix, int nbRow, int nbCol)
|
|||
return total;
|
||||
}
|
||||
|
||||
void squareMatrixElements(double *inputMatrix, int nbRow, int nbCol, double** resultMatrix, int* nbRowRes, int* nbColRes)
|
||||
void squareDoubleMatrix(double *inputMatrix, int nbRow, int nbCol, double** resultMatrix, int* nbRowRes, int* nbColRes)
|
||||
{
|
||||
int i;
|
||||
int size = nbRow * nbCol;
|
||||
|
|
@ -24,7 +26,7 @@ void squareMatrixElements(double *inputMatrix, int nbRow, int nbCol, double** re
|
|||
}
|
||||
}
|
||||
|
||||
void getMatrix(double **resultMatrix, int *nbRowRes, int *nbColRes)
|
||||
void getDoubleMatrix(double **resultMatrix, int *nbRowRes, int *nbColRes)
|
||||
{
|
||||
int i;
|
||||
int size;
|
||||
|
|
@ -37,3 +39,77 @@ void getMatrix(double **resultMatrix, int *nbRowRes, int *nbColRes)
|
|||
(*resultMatrix)[i] = i*2;
|
||||
}
|
||||
}
|
||||
|
||||
// Integer matrix functions
|
||||
|
||||
int sumIntegerMatrix(int *inputMatrix, int nbRow, int nbCol)
|
||||
{
|
||||
int i;
|
||||
int total = 0;
|
||||
for (i=0; i<nbRow*nbCol; i++)
|
||||
{
|
||||
total += inputMatrix[i];
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
void squareIntegerMatrix(int *inputMatrix, int nbRow, int nbCol, int** resultMatrix, int* nbRowRes, int* nbColRes)
|
||||
{
|
||||
int i;
|
||||
int size = nbRow * nbCol;
|
||||
*nbRowRes = nbRow;
|
||||
*nbColRes = nbCol;
|
||||
*resultMatrix = (int*) malloc(size * sizeof(int));
|
||||
for (i=0; i<size; i++)
|
||||
{
|
||||
(*resultMatrix)[i] = inputMatrix[i] * inputMatrix[i];
|
||||
}
|
||||
}
|
||||
|
||||
void getIntegerMatrix(int **resultMatrix, int *nbRowRes, int *nbColRes)
|
||||
{
|
||||
int i;
|
||||
int size;
|
||||
*nbRowRes = 5;
|
||||
*nbColRes = 3;
|
||||
size = (*nbRowRes) * (*nbColRes);
|
||||
*resultMatrix = (int*) malloc(size * sizeof(int));
|
||||
for (i=0; i<size; i++)
|
||||
{
|
||||
(*resultMatrix)[i] = i*2;
|
||||
}
|
||||
}
|
||||
|
||||
// String matrix functions
|
||||
|
||||
char* concatStringVector(char **inputVector, int size)
|
||||
{
|
||||
int i;
|
||||
int resultSize;
|
||||
char *result;
|
||||
resultSize = 3 * size + 1;
|
||||
result = calloc(resultSize, sizeof(char));
|
||||
strcpy(result, inputVector[0]);
|
||||
for (i=1; i<size; i++)
|
||||
{
|
||||
strcat(result, " ");
|
||||
strcat(result, (const char*) inputVector[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void getStringVector(char ***resultVector, int *sizeRes)
|
||||
{
|
||||
int i;
|
||||
*sizeRes = 12;
|
||||
*resultVector = (char**) malloc((*sizeRes) * sizeof(char*));
|
||||
for (i=0; i<*sizeRes; i++)
|
||||
{
|
||||
char* pc = (char*) calloc(3, sizeof(char));
|
||||
sprintf(pc, "%d", i);
|
||||
(*resultVector)[i] = pc;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,14 +2,25 @@
|
|||
|
||||
%include matrix.i
|
||||
|
||||
%apply (double *matrixAsInput, int rows, int cols) { (double *inputMatrix, int nbRow, int nbCol) }
|
||||
%apply (double **matrixAsOutput, int *rows, int *cols) { (double **resultMatrix, int *nbRowRes, int *nbColRes) }
|
||||
%apply (double *matrixIn, int matrixInRowCount, int matrixInColCount) { (double *inputMatrix, int nbRow, int nbCol) }
|
||||
%apply (double **matrixOut, int *matrixOutRowCount, int *matrixOutColCount) { (double **resultMatrix, int *nbRowRes, int *nbColRes) }
|
||||
|
||||
%apply (int *matrixIn, int matrixInRowCount, int matrixInColCount) { (int *inputMatrix, int nbRow, int nbCol) }
|
||||
%apply (int **matrixOut, int *matrixOutRowCount, int *matrixOutColCount) { (int **resultMatrix, int *nbRowRes, int *nbColRes) }
|
||||
|
||||
%inline
|
||||
{
|
||||
extern double sumMatrixElements(double *inputMatrix, int nbRow, int nbCol);
|
||||
extern void squareMatrixElements(double *inputMatrix, int nbRow, int nbCol, double **resultMatrix, int *nbRowRes, int *nbColRes);
|
||||
extern void getMatrix(double **resultMatrix, int *nbRowRes, int *nbColRes);
|
||||
}
|
||||
%apply (char **vectorIn, int vectorInSize) { (char **inputVector, int size) }
|
||||
%apply (char ***vectorOut, int *vectorOutSize) { (char ***resultVector, int *sizeRes) }
|
||||
|
||||
%inline %{
|
||||
extern double sumDoubleMatrix(double *inputMatrix, int nbRow, int nbCol);
|
||||
extern void squareDoubleMatrix(double *inputMatrix, int nbRow, int nbCol, double **resultMatrix, int *nbRowRes, int *nbColRes);
|
||||
extern void getDoubleMatrix(double **resultMatrix, int *nbRowRes, int *nbColRes);
|
||||
|
||||
extern int sumIntegerMatrix(int *inputMatrix, int nbRow, int nbCol);
|
||||
extern void squareIntegerMatrix(int *inputMatrix, int nbRow, int nbCol, int **resultMatrix, int *nbRowRes, int *nbColRes);
|
||||
extern void getIntegerMatrix(int **resultMatrix, int *nbRowRes, int *nbColRes);
|
||||
|
||||
extern char* concatStringVector(char **inputVector, int size);
|
||||
extern void getStringVector(char ***resultVector, int *sizeRes);
|
||||
%}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,45 @@
|
|||
exec loader.sce
|
||||
|
||||
disp("Call lib function getMatrix()");
|
||||
matrix1 = getMatrix();
|
||||
disp(matrix1);
|
||||
// Test lib double matrix functions
|
||||
disp("Call lib function getDoubleMatrix()");
|
||||
doubleMatrix = getDoubleMatrix();
|
||||
disp(doubleMatrix);
|
||||
|
||||
disp("Call lib function sumMatrixElements()");
|
||||
s = sumMatrixElements(matrix1);
|
||||
disp("Call lib function sumDoubleMatrix()");
|
||||
s = sumDoubleMatrix(doubleMatrix);
|
||||
disp(s);
|
||||
|
||||
disp("Call lib function squareMatrixElements()");
|
||||
squareMatrix = squareMatrixElements(matrix1);
|
||||
disp(squareMatrix);
|
||||
disp("Call lib function squareDoubleMatrix()");
|
||||
squareDoubleMatrix = squareDoubleMatrix(doubleMatrix);
|
||||
disp(squareDoubleMatrix);
|
||||
|
||||
|
||||
// Test lib integer matrix functions
|
||||
|
||||
disp("Call lib function getIntegerMatrix()");
|
||||
integerMatrix = getIntegerMatrix();
|
||||
disp(integerMatrix);
|
||||
|
||||
disp("Call lib function sumIntegerMatrix()");
|
||||
s = sumIntegerMatrix(integerMatrix);
|
||||
disp(s);
|
||||
|
||||
disp("Call lib function squareIntegerMatrix()");
|
||||
squareIntegerMatrix = squareIntegerMatrix(integerMatrix);
|
||||
disp(squareIntegerMatrix);
|
||||
|
||||
|
||||
// Test lib string matrix functions
|
||||
|
||||
disp("Call lib function getStringVector()");
|
||||
stringVector = getStringVector();
|
||||
disp(stringVector);
|
||||
|
||||
disp("Call lib function concatStringVector()");
|
||||
stringVector2 = concatStringVector(stringVector);
|
||||
disp(stringVector2);
|
||||
|
||||
exit
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,29 +0,0 @@
|
|||
/* File : example.cpp */
|
||||
|
||||
#include "example.hxx"
|
||||
|
||||
std::set<int> create_iset(const int size, const int* values)
|
||||
{
|
||||
std::set<int> iset;
|
||||
std::copy(values, values + size, std::inserter(iset, iset.begin()));
|
||||
return iset;
|
||||
}
|
||||
|
||||
int sum_iset(const std::set<int> iset)
|
||||
{
|
||||
int sum = 0;
|
||||
std::set<int>::iterator it;
|
||||
for (it = iset.begin(); it != iset.end(); it++)
|
||||
{
|
||||
sum += *it;
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
void concat_iset(std::set<int>& iset, const std::set<int> other_iset)
|
||||
{
|
||||
std::copy(other_iset.begin(), other_iset.end(), std::inserter(iset, iset.begin()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
/* File : example.hxx */
|
||||
|
||||
#include <set>
|
||||
|
||||
std::set<int> create_iset(const int size, const int* values);
|
||||
|
||||
int sum_iset(const std::set<int> iset);
|
||||
|
||||
void concat_iset(std::set<int>& iset, const std::set<int> other_iset);
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
/* File : example.i */
|
||||
|
||||
%module example
|
||||
|
||||
%{
|
||||
#include "example.hxx"
|
||||
%}
|
||||
|
||||
%include "std_set.i"
|
||||
|
||||
%include "matrix.i"
|
||||
%apply (int size, int* matrixAsInput) { (const int size, const int* values) };
|
||||
|
||||
%include "example.hxx";
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
exec loader.sce;
|
||||
|
||||
disp("this is an example with sets of int.");
|
||||
disp("create the set from matrix [1, 2, 4, 4]:");
|
||||
iset = create_iset(int32([1, 2, 4, 4]));
|
||||
disp(iset);
|
||||
s = sum_iset(iset);
|
||||
disp("sum of this set elements is:");
|
||||
disp(s);
|
||||
iset2 = create_iset(int32([1, 10]));
|
||||
disp("concat this set with the set of int {1, 10}:");
|
||||
iset3 = concat_iset(iset, iset2);
|
||||
disp(iset3);
|
||||
|
||||
|
||||
|
||||
|
|
@ -4,13 +4,17 @@ SRCS = example.cpp
|
|||
TARGET = example
|
||||
INTERFACE = example.i
|
||||
|
||||
all:
|
||||
all: run
|
||||
|
||||
loader.sce:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab_cpp
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile scilab_clean
|
||||
rm -f *.sce *.so lib*lib.c *_wrap.cxx
|
||||
|
||||
check: all
|
||||
run: loader.sce
|
||||
$(MAKE) -f $(TOP)/Makefile scilab_run
|
||||
|
||||
debug: loader.sce
|
||||
$(MAKE) -f $(TOP)/Makefile scilab_debug
|
||||
61
Examples/scilab/std_list/example.cpp
Normal file
61
Examples/scilab/std_list/example.cpp
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/* File : example.cpp */
|
||||
|
||||
#include "example.hxx"
|
||||
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
#include <numeric>
|
||||
#include <sstream>
|
||||
|
||||
|
||||
template <typename T>
|
||||
std::list<T> concat_list(const std::list<T> list, const std::list<T> other_list)
|
||||
{
|
||||
std::list<T> out_list(list);
|
||||
out_list.insert(out_list.end(), other_list.begin(), other_list.end());
|
||||
return out_list;
|
||||
}
|
||||
|
||||
// int lists
|
||||
|
||||
std::list<int> create_integer_list(const int rangemin, const int rangemax)
|
||||
{
|
||||
std::list<int> out_list;
|
||||
for (int i = rangemin; i <= rangemax; i++)
|
||||
{
|
||||
out_list.push_back(i);
|
||||
}
|
||||
return out_list;
|
||||
}
|
||||
|
||||
int sum_integer_list(const std::list<int>& list)
|
||||
{
|
||||
return std::accumulate(list.begin(), list.end(), 0);
|
||||
}
|
||||
|
||||
std::list<int> concat_integer_list(const std::list<int> list, const std::list<int> other_list)
|
||||
{
|
||||
return concat_list<int>(list, other_list);
|
||||
}
|
||||
|
||||
// string lists
|
||||
|
||||
std::list<std::string> create_string_list(const char* svalue)
|
||||
{
|
||||
std::list<std::string> out_list;
|
||||
std::string str(svalue);
|
||||
|
||||
std::istringstream iss(str);
|
||||
std::copy(std::istream_iterator<std::string>(iss),
|
||||
std::istream_iterator<std::string>(),
|
||||
std::inserter<std::list<std::string> >(out_list, out_list.begin()));
|
||||
|
||||
return out_list;
|
||||
}
|
||||
|
||||
std::list<std::string> concat_string_list(const std::list<std::string> list, const std::list<std::string> other_list)
|
||||
{
|
||||
return concat_list<std::string>(list, other_list);
|
||||
}
|
||||
|
||||
14
Examples/scilab/std_list/example.hxx
Normal file
14
Examples/scilab/std_list/example.hxx
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
/* File : example.hxx */
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
|
||||
// integer lists
|
||||
std::list<int> create_integer_list(const int size, const int value);
|
||||
int sum_integer_list(const std::list<int>& list);
|
||||
std::list<int> concat_integer_list(const std::list<int> list, const std::list<int> other_list);
|
||||
|
||||
// string lists
|
||||
std::list<std::string> create_string_list(const char* value);
|
||||
std::list<std::string> concat_string_list(const std::list<std::string> list, const std::list<std::string> other_list);
|
||||
18
Examples/scilab/std_list/example.i
Normal file
18
Examples/scilab/std_list/example.i
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/* File : example.i */
|
||||
|
||||
%module example
|
||||
|
||||
%{
|
||||
#include "example.hxx"
|
||||
%}
|
||||
|
||||
%include stl.i
|
||||
|
||||
/* instantiate the required template specializations */
|
||||
namespace std
|
||||
{
|
||||
%template(IntList) list<int>;
|
||||
%template(StringList) list<std::string>;
|
||||
}
|
||||
|
||||
%include "example.hxx"
|
||||
31
Examples/scilab/std_list/runme.sci
Normal file
31
Examples/scilab/std_list/runme.sci
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
exec loader.sce;
|
||||
SWIG_Init();
|
||||
|
||||
// This example shows how to use C++ fonctions with STL lists arguments
|
||||
// Here, STL lists are converted from/to Scilab matrices (SWIG_SCILAB_EXTRA_NATIVE_CONTAINERS is not defined)
|
||||
|
||||
// integer lists
|
||||
|
||||
disp("Example of passing matrices of int as list arguments of C++ functions.");
|
||||
disp("get a list of int {1...4} from create_integer_list():");
|
||||
is = create_integer_list(1, 4);
|
||||
disp(is);
|
||||
disp("get the sum of this list elements with sum_integer_list():")
|
||||
sum = sum_integer_list(is);
|
||||
disp(is);
|
||||
is2 = create_integer_list(3, 6);
|
||||
disp("concat this list with the list of int {3...6} with concat_integer_list():");
|
||||
is3 = concat_integer_list(is, is2);
|
||||
disp(is3);
|
||||
|
||||
// string lists
|
||||
|
||||
disp("Example of passing matrices of string as list arguments of C++ functions.");
|
||||
disp("get a list of string {''aa'', ''bb'', ''cc'', ''dd''} with create_string_list():");
|
||||
ss = create_string_list("aa bb cc dd");
|
||||
disp(ss);
|
||||
ss2 = create_string_list("cc dd ee ff");
|
||||
disp("concat this list with the list of string {''cc'', ''dd'', ''ee'', ''ff''} with concat_string_list():");
|
||||
ss3 = concat_string_list(ss, ss2);
|
||||
disp(ss3);
|
||||
|
||||
|
|
@ -4,13 +4,17 @@ SRCS = example.cpp
|
|||
TARGET = example
|
||||
INTERFACE = example.i
|
||||
|
||||
all:
|
||||
all: check
|
||||
|
||||
loader.sce:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab_cpp
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile scilab_clean
|
||||
rm -f *.sce *.so lib*lib.c *_wrap.cxx
|
||||
|
||||
check: all
|
||||
check: loader.sce
|
||||
$(MAKE) -f $(TOP)/Makefile scilab_run
|
||||
|
||||
debug: loader.sce
|
||||
$(MAKE) -f $(TOP)/Makefile scilab_debug
|
||||
61
Examples/scilab/std_set/example.cpp
Normal file
61
Examples/scilab/std_set/example.cpp
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/* File : example.cpp */
|
||||
|
||||
#include "example.hxx"
|
||||
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
#include <numeric>
|
||||
#include <sstream>
|
||||
|
||||
|
||||
template <typename T>
|
||||
std::set<T> concat_set(const std::set<T> set, const std::set<T> other_set)
|
||||
{
|
||||
std::set<T> out_set(set);
|
||||
out_set.insert(other_set.begin(), other_set.end());
|
||||
return out_set;
|
||||
}
|
||||
|
||||
// int sets
|
||||
|
||||
std::set<int> create_integer_set(const int rangemin, const int rangemax)
|
||||
{
|
||||
std::set<int> out_set;
|
||||
for (int i = rangemin; i <= rangemax; i++)
|
||||
{
|
||||
out_set.insert(i);
|
||||
}
|
||||
return out_set;
|
||||
}
|
||||
|
||||
int sum_integer_set(const std::set<int>& set)
|
||||
{
|
||||
return std::accumulate(set.begin(), set.end(), 0);
|
||||
}
|
||||
|
||||
std::set<int> concat_integer_set(const std::set<int> set, const std::set<int> other_set)
|
||||
{
|
||||
return concat_set<int>(set, other_set);
|
||||
}
|
||||
|
||||
// string sets
|
||||
|
||||
std::set<std::string> create_string_set(const char* svalue)
|
||||
{
|
||||
std::set<std::string> out_set;
|
||||
std::string str(svalue);
|
||||
|
||||
std::istringstream iss(str);
|
||||
std::copy(std::istream_iterator<std::string>(iss),
|
||||
std::istream_iterator<std::string>(),
|
||||
std::inserter<std::set<std::string> >(out_set, out_set.begin()));
|
||||
|
||||
return out_set;
|
||||
}
|
||||
|
||||
std::set<std::string> concat_string_set(const std::set<std::string> set, const std::set<std::string> other_set)
|
||||
{
|
||||
return concat_set<std::string>(set, other_set);
|
||||
}
|
||||
|
||||
14
Examples/scilab/std_set/example.hxx
Normal file
14
Examples/scilab/std_set/example.hxx
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
/* File : example.hxx */
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
|
||||
// integer sets
|
||||
std::set<int> create_integer_set(const int size, const int value);
|
||||
int sum_integer_set(const std::set<int>& set);
|
||||
std::set<int> concat_integer_set(const std::set<int> set, const std::set<int> other_set);
|
||||
|
||||
// string sets
|
||||
std::set<std::string> create_string_set(const char* value);
|
||||
std::set<std::string> concat_string_set(const std::set<std::string> set, const std::set<std::string> other_set);
|
||||
18
Examples/scilab/std_set/example.i
Normal file
18
Examples/scilab/std_set/example.i
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/* File : example.i */
|
||||
|
||||
%module example
|
||||
|
||||
%{
|
||||
#include "example.hxx"
|
||||
%}
|
||||
|
||||
%include stl.i
|
||||
|
||||
/* instantiate the required template specializations */
|
||||
namespace std
|
||||
{
|
||||
%template(IntSet) set<int>;
|
||||
%template(StringSet) set<std::string>;
|
||||
}
|
||||
|
||||
%include "example.hxx"
|
||||
33
Examples/scilab/std_set/runme.sci
Normal file
33
Examples/scilab/std_set/runme.sci
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
exec loader.sce;
|
||||
SWIG_Init();
|
||||
|
||||
// This example shows how to use C++ fonctions with STL sets arguments
|
||||
// Here, STL sets are converted from/to Scilab matrices (SWIG_SCILAB_EXTRA_NATIVE_CONTAINERS is not defined)
|
||||
|
||||
// integer sets
|
||||
|
||||
disp("Example of passing matrices of int as set arguments of C++ functions.");
|
||||
disp("get a set of int {1...4} from create_integer_set():");
|
||||
is = create_integer_set(1, 4);
|
||||
disp(is);
|
||||
disp("get the sum of this set elements with sum_integer_set():")
|
||||
sum = sum_integer_set(is);
|
||||
disp(is);
|
||||
is2 = create_integer_set(3, 6);
|
||||
disp("concat this set with the set of int {3...6} with concat_integer_set():");
|
||||
is3 = concat_integer_set(is, is2);
|
||||
disp(is3);
|
||||
|
||||
// string sets
|
||||
|
||||
disp("Example of passing matrices of string as set arguments of C++ functions.");
|
||||
disp("get a set of string {''aa'', ''bb'', ''cc'', ''dd''} with create_string_set():");
|
||||
ss = create_string_set("aa bb cc dd");
|
||||
disp(ss);
|
||||
ss2 = create_string_set("cc dd ee ff");
|
||||
disp("concat this set with the set of string {''cc'', ''dd'', ''ee'', ''ff''} with concat_string_set():");
|
||||
ss3 = concat_string_set(ss, ss2);
|
||||
disp(ss3);
|
||||
|
||||
exit
|
||||
|
||||
20
Examples/scilab/std_vector/std_vector/Makefile
Normal file
20
Examples/scilab/std_vector/std_vector/Makefile
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
TOP = ../../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
SRCS =
|
||||
TARGET = example
|
||||
INTERFACE = example.i
|
||||
|
||||
all: check
|
||||
|
||||
loader.sce:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab_cpp
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile scilab_clean
|
||||
|
||||
check: loader.sce
|
||||
$(MAKE) -f $(TOP)/Makefile scilab_run
|
||||
|
||||
debug: loader.sce
|
||||
$(MAKE) -f $(TOP)/Makefile scilab_debug
|
||||
25
Examples/scilab/std_vector/std_vector/example.h
Normal file
25
Examples/scilab/std_vector/std_vector/example.h
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/* File : example.h */
|
||||
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <numeric>
|
||||
|
||||
double average(std::vector<int> v) {
|
||||
return std::accumulate(v.begin(),v.end(),0.0)/v.size();
|
||||
}
|
||||
|
||||
std::vector<double> half(const std::vector<double> v) {
|
||||
std::vector<double> w(v);
|
||||
for (unsigned int i=0; i<w.size(); i++)
|
||||
w[i] /= 2.0;
|
||||
return w;
|
||||
}
|
||||
|
||||
void halve_in_place(std::vector<double>& v) {
|
||||
// would you believe this is the same as the above?
|
||||
std::transform(v.begin(),v.end(),v.begin(),
|
||||
std::bind2nd(std::divides<double>(),2.0));
|
||||
}
|
||||
|
||||
|
||||
18
Examples/scilab/std_vector/std_vector/example.i
Normal file
18
Examples/scilab/std_vector/std_vector/example.i
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/* File : example.i */
|
||||
%module example
|
||||
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
||||
%include stl.i
|
||||
|
||||
/* instantiate the required template specializations */
|
||||
namespace std {
|
||||
%template(IntVector) vector<int>;
|
||||
%template(DoubleVector) vector<double>;
|
||||
}
|
||||
|
||||
/* Let's just grab the original header file here */
|
||||
%include "example.h"
|
||||
|
||||
37
Examples/scilab/std_vector/std_vector/runme.sci
Normal file
37
Examples/scilab/std_vector/std_vector/runme.sci
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
// file: runme.sci
|
||||
exec loader.sce;
|
||||
SWIG_Init();
|
||||
|
||||
|
||||
disp(mean([1,2,3,4]));
|
||||
|
||||
// ... or a wrapped std::vector<int>
|
||||
|
||||
v = new_IntVector();
|
||||
for i = 1:4
|
||||
IntVector_push_back(v, i);
|
||||
end;
|
||||
disp(average(v));
|
||||
|
||||
|
||||
// half will return a Scilab matrix.
|
||||
// Call it with a Scilab matrix...
|
||||
|
||||
disp(half([1.0, 1.5, 2.0, 2.5, 3.0]));
|
||||
|
||||
|
||||
// ... or a wrapped std::vector<double>
|
||||
|
||||
v = new_DoubleVector();
|
||||
for i = 1:4
|
||||
DoubleVector_push_back(v, i);
|
||||
end;
|
||||
disp(half(v));
|
||||
|
||||
// now halve a wrapped std::vector<double> in place
|
||||
|
||||
halve_in_place(v);
|
||||
disp(v);
|
||||
|
||||
exit
|
||||
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
TOP = ../../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
SRCS = example.cpp
|
||||
TARGET = example
|
||||
INTERFACE = example.i
|
||||
|
||||
all: check
|
||||
|
||||
loader.sce:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab_cpp
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile scilab_clean
|
||||
|
||||
check: loader.sce
|
||||
$(MAKE) -f $(TOP)/Makefile scilab_run
|
||||
|
||||
debug: loader.sce
|
||||
$(MAKE) -f $(TOP)/Makefile scilab_debug
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
/* File : example.cpp */
|
||||
|
||||
#include "example.hxx"
|
||||
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
#include <numeric>
|
||||
|
||||
|
||||
|
||||
template <typename T>
|
||||
std::vector<T> concat_vector(const std::vector<T> vector, const std::vector<T> other_vector)
|
||||
{
|
||||
std::vector<T> out_vector(vector);
|
||||
out_vector.insert(out_vector.end(), other_vector.begin(), other_vector.end());
|
||||
return out_vector;
|
||||
}
|
||||
|
||||
// double vectors
|
||||
|
||||
std::vector<double> create_double_vector(const int size, const double value)
|
||||
{
|
||||
return std::vector<double>(size, value);
|
||||
}
|
||||
|
||||
double sum_double_vector(const std::vector<double>& vector)
|
||||
{
|
||||
return std::accumulate(vector.begin(), vector.end(), 0);
|
||||
}
|
||||
|
||||
std::vector<double> concat_double_vector(const std::vector<double> vector, const std::vector<double> other_vector)
|
||||
{
|
||||
return concat_vector<double>(vector, other_vector);
|
||||
}
|
||||
|
||||
// int vectors
|
||||
|
||||
std::vector<int> create_integer_vector(const int size, const int value)
|
||||
{
|
||||
return std::vector<int>(size, value);
|
||||
}
|
||||
|
||||
int sum_integer_vector(const std::vector<int>& vector)
|
||||
{
|
||||
return std::accumulate(vector.begin(), vector.end(), 0);
|
||||
}
|
||||
|
||||
std::vector<int> concat_integer_vector(const std::vector<int> vector, const std::vector<int> other_vector)
|
||||
{
|
||||
return concat_vector<int>(vector, other_vector);
|
||||
}
|
||||
|
||||
// string vectors
|
||||
|
||||
std::vector<std::string> create_string_vector(const int size, const char* value)
|
||||
{
|
||||
return std::vector<std::string>(size, value);
|
||||
}
|
||||
|
||||
std::vector<std::string> concat_string_vector(const std::vector<std::string> vector, const std::vector<std::string> other_vector)
|
||||
{
|
||||
return concat_vector<std::string>(vector, other_vector);
|
||||
}
|
||||
|
||||
// bool vectors
|
||||
|
||||
std::vector<bool> create_bool_vector(const int size, const bool value)
|
||||
{
|
||||
return std::vector<bool>(size, value);
|
||||
}
|
||||
|
||||
std::vector<bool> concat_bool_vector(const std::vector<bool> vector, const std::vector<bool> other_vector)
|
||||
{
|
||||
return concat_vector<bool>(vector, other_vector);
|
||||
}
|
||||
|
||||
// pointer (on objects) vectors
|
||||
|
||||
std::vector<classA*> create_classAPtr_vector(const int size, const int value)
|
||||
{
|
||||
std::vector<classA*> out_vector;
|
||||
for (int i=0; i<size; i++)
|
||||
{
|
||||
classA* objA = new classA(value);
|
||||
out_vector.push_back(objA);
|
||||
}
|
||||
return out_vector;
|
||||
}
|
||||
|
||||
void print_classAPtr_vector(const std::vector<classA*>& vector)
|
||||
{
|
||||
std::vector<classA*>::const_iterator it;
|
||||
std::cout << std::endl;
|
||||
for (it = vector.begin(); it != vector.end(); ++it)
|
||||
{
|
||||
std::cout << "<classA* a:" << (*it)->a << ">" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<classA*> concat_classAPtr_vector(const std::vector<classA*> vector, const std::vector<classA*> other_vector)
|
||||
{
|
||||
return concat_vector<classA*>(vector, other_vector);
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
/* File : example.hxx */
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
|
||||
// double vectors
|
||||
std::vector<double> create_double_vector(const int size, const double value);
|
||||
double sum_double_vector(const std::vector<double>& vector);
|
||||
std::vector<double> concat_double_vector(const std::vector<double> vector, const std::vector<double> other_vector);
|
||||
|
||||
// integer vectors
|
||||
std::vector<int> create_integer_vector(const int size, const int value);
|
||||
int sum_integer_vector(const std::vector<int>& vector);
|
||||
std::vector<int> concat_integer_vector(const std::vector<int> vector, const std::vector<int> other_vector);
|
||||
|
||||
// string vectors
|
||||
std::vector<std::string> create_string_vector(const int size, const char* value);
|
||||
std::vector<std::string> concat_string_vector(const std::vector<std::string> vector, const std::vector<std::string> other_vector);
|
||||
|
||||
// bool vectors
|
||||
std::vector<bool> create_bool_vector(const int size, const bool value);
|
||||
std::vector<bool> concat_bool_vector(const std::vector<bool> vector, const std::vector<bool> other_vector);
|
||||
|
||||
// pointer (on object) vectors
|
||||
class classA
|
||||
{
|
||||
public:
|
||||
classA() : a(0) {}
|
||||
classA(int _a) : a(_a) {}
|
||||
classA(const classA& c) : a(c.a) {}
|
||||
int a;
|
||||
};
|
||||
|
||||
std::vector<classA*> create_classAPtr_vector(const int size, const int value);
|
||||
void print_classAPtr_vector(const std::vector<classA*>& pvector);
|
||||
std::vector<classA*> concat_classAPtr_vector(const std::vector<classA*> vector, const std::vector<classA*> other_vector);
|
||||
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
/* File : example.i */
|
||||
|
||||
%module example
|
||||
|
||||
%{
|
||||
#include "example.hxx"
|
||||
%}
|
||||
|
||||
%include stl.i
|
||||
|
||||
/* instantiate the required template specializations */
|
||||
namespace std
|
||||
{
|
||||
%template(IntVector) vector<int>;
|
||||
%template(DoubleVector) vector<double>;
|
||||
%template(StringVector) vector<std::string>;
|
||||
%template(BoolVector) vector<bool>;
|
||||
%template(ClassAPtrVector) vector<classA*>;
|
||||
}
|
||||
|
||||
%include "example.hxx"
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
exec loader.sce;
|
||||
SWIG_Init();
|
||||
|
||||
// This example shows how to use C++ fonctions with STL vectors arguments
|
||||
// Here, STL vectors are converted from/to Scilab matrices (SWIG_SCILAB_EXTRA_NATIVE_CONTAINERS is not defined)
|
||||
|
||||
// double vectors
|
||||
|
||||
disp("Example of passing matrices of double as vector arguments of C++ functions.");
|
||||
disp("get a vector of double {2.0, 2.0, 2.0, 2.0} from create_double_vector():");
|
||||
dv = create_double_vector(4, 2.0);
|
||||
disp(dv);
|
||||
disp("get the sum of this vector elements with sum_double_vector():")
|
||||
ds = sum_double_vector(dv);
|
||||
disp(ds);
|
||||
dv2 = create_double_vector(2, 5.0);
|
||||
disp("concat this vector with the vector of double {5.0, 5.0} with concat_double_vector():");
|
||||
dv3 = concat_double_vector(dv, dv2);
|
||||
disp(dv3);
|
||||
|
||||
// integer vectors
|
||||
|
||||
disp("Example of passing matrices of int as vector arguments of C++ functions.");
|
||||
disp("get a vector of int {3, 3, 3, 3} from create_integer_vector():");
|
||||
iv = create_integer_vector(3, 3);
|
||||
disp(iv);
|
||||
disp("get the sum of this vector elements with sum_integer_vector():")
|
||||
is = sum_integer_vector(iv);
|
||||
disp(is);
|
||||
iv2 = create_integer_vector(2, 1);
|
||||
disp("concat this vector with the vector of int {1, 1} with concat_integer_vector():");
|
||||
iv3 = concat_integer_vector(iv, iv2);
|
||||
disp(iv3);
|
||||
|
||||
// string vectors
|
||||
|
||||
disp("Example of passing matrices of string as vector arguments of C++ functions.");
|
||||
disp("get a vector of string {''aa'', ''aa''} with create_string_vector():");
|
||||
sv = create_string_vector(2, "aa");
|
||||
disp(sv);
|
||||
sv2 = create_string_vector(2, "bb");
|
||||
disp("concat this vector with the vector of string {''bb'', ''bb''} with concat_string_vector():");
|
||||
sv3 = concat_string_vector(sv, sv2);
|
||||
disp(sv3);
|
||||
|
||||
// bool vectors
|
||||
|
||||
disp("Example of passing matrices of bool as vector arguments of C++ functions.");
|
||||
disp("get a vector of bool {true, true} with create_bool_vector():");
|
||||
bv = create_bool_vector(2, %T);
|
||||
disp(bv);
|
||||
bv2 = create_bool_vector(3, %F);
|
||||
disp("concat this vector with the vector of bool {false, false, false} with concat_bool_vector():");
|
||||
bv3 = concat_bool_vector(bv, bv2);
|
||||
disp(bv3);
|
||||
|
||||
// pointer (on object) vectors
|
||||
|
||||
disp("Example of passing lists of pointers on object as vector of pointers on objects arguments of C++ functions.");
|
||||
disp("get a vector of pointers on object {<classA* a:1>, <classA* a:1>, <classA* a:1>} with create_classAPtr_vector():");
|
||||
pv = create_classAPtr_vector(3, 1);
|
||||
print_classAPtr_vector(pv);
|
||||
pv2 = create_classAPtr_vector(2, 5);
|
||||
disp("concat this vector with the vector of pointers on object {<classA* a:5>, <classA* a:5>} with concat_classAPtr_vector():");
|
||||
pv3 = concat_classAPtr_vector(pv, pv2);
|
||||
print_classAPtr_vector(pv3);
|
||||
|
||||
exit
|
||||
|
||||
|
|
@ -30,3 +30,5 @@ delete_SquareDouble(s);
|
|||
|
||||
printf("%i shapes remain\n", ShapeDouble_getNbShapes());
|
||||
|
||||
exit
|
||||
|
||||
|
|
|
|||
|
|
@ -1,47 +0,0 @@
|
|||
/* File : example.cpp */
|
||||
|
||||
#include "example.hxx"
|
||||
|
||||
|
||||
std::vector<double> create_dvector(const int size, const double value)
|
||||
{
|
||||
return std::vector<double>(size, value);
|
||||
}
|
||||
|
||||
std::vector<int> create_ivector(const int size, const int value)
|
||||
{
|
||||
return std::vector<int>(size, value);
|
||||
}
|
||||
|
||||
double sum_dvector(const std::vector<double> dvector)
|
||||
{
|
||||
double sum = 0;
|
||||
for (int i = 0; i < dvector.size(); i++)
|
||||
{
|
||||
sum += dvector[i];
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
int sum_ivector(const std::vector<int> ivector)
|
||||
{
|
||||
int sum = 0;
|
||||
for (int i = 0; i < ivector.size(); i++)
|
||||
{
|
||||
sum += ivector[i];
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
void concat_dvector(std::vector<double>& dvector, const std::vector<double> other_dvector)
|
||||
{
|
||||
dvector.insert(dvector.end(), other_dvector.begin(), other_dvector.end());
|
||||
}
|
||||
|
||||
void concat_ivector(std::vector<int>& ivector, const std::vector<int> other_ivector)
|
||||
{
|
||||
ivector.insert(ivector.end(), other_ivector.begin(), other_ivector.end());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
/* File : example.hxx */
|
||||
|
||||
#include <vector>
|
||||
|
||||
std::vector<double> create_dvector(const int size, const double value);
|
||||
std::vector<int> create_ivector(const int size, const int value);
|
||||
|
||||
double sum_dvector(const std::vector<double> dvector);
|
||||
int sum_ivector(const std::vector<int> ivector);
|
||||
|
||||
void concat_dvector(std::vector<double>& dvector, const std::vector<double> other_dvector);
|
||||
void concat_ivector(std::vector<int>& ivector, const std::vector<int> other_ivector);
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
/* File : example.i */
|
||||
|
||||
%module example
|
||||
|
||||
%{
|
||||
#include "example.hxx"
|
||||
%}
|
||||
|
||||
%include "std_vector.i"
|
||||
|
||||
%include "example.hxx";
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
exec loader.sce;
|
||||
|
||||
disp("this is an example with vectors of double.");
|
||||
disp("create the vector of double {2.0, 2.0, 2.0, 2.0}:");
|
||||
dv = create_dvector(4, 2.0);
|
||||
disp(dv);
|
||||
ds = sum_dvector(dv);
|
||||
disp("sum of this vector elements is:")
|
||||
disp(ds);
|
||||
dv2 = create_dvector(2, 5.0);
|
||||
disp("concat this vector with the vector of double {5.0, 5.0}:");
|
||||
dv3 = concat_dvector(dv, dv2);
|
||||
disp(dv3);
|
||||
|
||||
disp("now an example with vectors of int.");
|
||||
disp("create the vector of int {3, 3, 3}:");
|
||||
iv = create_ivector(3, 3);
|
||||
disp(iv);
|
||||
is = sum_ivector(iv);
|
||||
disp("sum of this vector elements is:");
|
||||
disp(is);
|
||||
iv2 = create_ivector(2, 1);
|
||||
disp("concat this vector with the vector of int {1, 1}:");
|
||||
iv3 = concat_ivector(iv, iv2);
|
||||
disp(iv3);
|
||||
|
||||
|
||||
|
||||
|
|
@ -5,13 +5,13 @@
|
|||
%nocopyctor Bar<double>;
|
||||
|
||||
%inline %{
|
||||
|
||||
|
||||
struct Foo1 {
|
||||
int x;
|
||||
|
||||
Foo1(int _x = 2) : x(_x)
|
||||
{
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct Foo2 {
|
||||
|
|
@ -25,7 +25,7 @@ struct Foo3 {
|
|||
|
||||
struct Foo4 {
|
||||
Foo4() { }
|
||||
|
||||
|
||||
protected:
|
||||
Foo4(const Foo4& ) { }
|
||||
};
|
||||
|
|
@ -33,7 +33,7 @@ protected:
|
|||
|
||||
struct Foo4a {
|
||||
Foo4a() { }
|
||||
|
||||
|
||||
private:
|
||||
Foo4a(const Foo4a& ) { }
|
||||
};
|
||||
|
|
@ -53,7 +53,7 @@ struct Foo8 {
|
|||
};
|
||||
|
||||
template <class T>
|
||||
class Bar
|
||||
class Bar
|
||||
{
|
||||
public:
|
||||
int x;
|
||||
|
|
@ -95,12 +95,14 @@ public:
|
|||
namespace Space {
|
||||
class Flow {
|
||||
public:
|
||||
Flow() {}
|
||||
Flow(int i) {}
|
||||
};
|
||||
|
||||
|
||||
class FlowFlow {
|
||||
public:
|
||||
FlowFlow() {}
|
||||
FlowFlow(int i) {}
|
||||
};
|
||||
|
||||
|
|
@ -124,7 +126,7 @@ public:
|
|||
template <class T>
|
||||
struct ModelUtils_T {};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
%}
|
||||
|
||||
|
|
@ -142,13 +144,13 @@ namespace Space1 {
|
|||
class TotalReturnSwap {
|
||||
public:
|
||||
TotalReturnSwap() {}
|
||||
};
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class TotalReturnSwap_T {
|
||||
public:
|
||||
TotalReturnSwap_T() {}
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,6 @@
|
|||
|
||||
%include <scimatrixdouble.swg>
|
||||
%include <scimatrixint.swg>
|
||||
|
||||
%include <scimatrixchar.swg>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -82,3 +82,18 @@ SWIG_SciBoolean_AsIntArrayAndSize(void *_pvApiCtx, int _iVar, int *_iRows, int *
|
|||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment("SWIG_SciBoolean_FromIntArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciBoolean_FromIntArrayAndSize(void *_pvApiCtx, int _iVarOut, int _iRows, int _iCols, const int *_piData) {
|
||||
SciErr sciErr;
|
||||
|
||||
sciErr = createMatrixOfBoolean(_pvApiCtx, Rhs + _iVarOut, _iRows, _iCols, _piData);
|
||||
if(sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return Rhs + _iVarOut;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@
|
|||
* C-type: char
|
||||
* Scilab type: string
|
||||
*/
|
||||
|
||||
/*
|
||||
* CHAR
|
||||
*/
|
||||
%fragment(SWIG_AsVal_frag(char), "header", fragment="SwigScilabStringToChar") {
|
||||
#define SWIG_AsVal_char(scilabValue, valuePointer) SwigScilabStringToChar(pvApiCtx, scilabValue, valuePointer, fname)
|
||||
}
|
||||
|
|
@ -84,58 +88,37 @@ SwigScilabStringFromChar(void *_pvApiCtx, int _iVarOut, char _chValue) {
|
|||
#define SWIG_AsCharPtrAndSize(scilabValue, charPtrPointer, charPtrLength, allocMemory) SwigScilabStringToCharPtrAndSize(pvApiCtx, scilabValue, charPtrPointer, charPtrLength, allocMemory, fname)
|
||||
}
|
||||
%fragment("SWIG_FromCharPtr", "header", fragment = "SwigScilabStringFromCharPtr") {
|
||||
#define SWIG_FromCharPtr(charPtr) SwigScilabStringFromCharPtr(pvApiCtx, $result, charPtr)
|
||||
#define SWIG_FromCharPtr(charPtr) SwigScilabStringFromCharPtr(pvApiCtx, SWIG_Scilab_GetOutputPosition(), charPtr)
|
||||
}
|
||||
%fragment("SWIG_FromCharPtrAndSize", "header", fragment = "SwigScilabStringFromCharPtrAndSize") {
|
||||
#define SWIG_FromCharPtrAndSize(charPtr, charPtrLength) SwigScilabStringFromCharPtrAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), charPtr)
|
||||
%fragment("SWIG_FromCharPtrAndSize", "header", fragment = "SwigScilabStringFromCharPtr") {
|
||||
#define SWIG_FromCharPtrAndSize(charPtr, charPtrLength) SwigScilabStringFromCharPtr(pvApiCtx, SWIG_Scilab_GetOutputPosition(), charPtr)
|
||||
}
|
||||
|
||||
%fragment("SwigScilabStringToCharPtr", "header") {
|
||||
SWIGINTERN int
|
||||
SwigScilabStringToCharPtr(void *_pvApiCtx, int _iVar, char *_pcValue, int _iLength, char *_fname) {
|
||||
SciErr sciErr;
|
||||
int iRows = 0;
|
||||
int iCols = 0;
|
||||
int iType = 0;
|
||||
int *piAddrVar = NULL;
|
||||
char *pstStrings = NULL;
|
||||
int piLength = 0;
|
||||
char* pcTmpValue = NULL;
|
||||
int iRet;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, _iVar, &piAddrVar);
|
||||
if (_pcValue == NULL) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
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(999, _("%s: Wrong type for input argument #%d: A string expected.\n"), _fname, _iVar);
|
||||
iRet = getAllocatedSingleString(_pvApiCtx, piAddrVar, &pcTmpValue);
|
||||
if (iRet) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getMatrixOfString(pvApiCtx, piAddrVar, &iRows, &iCols, &piLength, NULL);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iRows * iCols != 1) {
|
||||
Scierror(999, _("%s: Wrong size for input argument #%d: A string expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
pstStrings = (char *)malloc(sizeof(char) * (piLength + 1));
|
||||
sciErr = getMatrixOfString(pvApiCtx, piAddrVar, &iRows, &iCols, &piLength, (char **)&pstStrings);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
strcpy(_pcValue, pstStrings);
|
||||
|
||||
free(pstStrings);
|
||||
strncpy(_pcValue, pcTmpValue, _iLength);
|
||||
free(pcTmpValue);
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -144,57 +127,33 @@ SwigScilabStringToCharPtr(void *_pvApiCtx, int _iVar, char *_pcValue, int _iLeng
|
|||
SWIGINTERN int
|
||||
SwigScilabStringToCharPtrAndSize(void *_pvApiCtx, int _iVar, char **_pcValue, size_t *_piLength, int *alloc, char *_fname) {
|
||||
SciErr sciErr;
|
||||
int iRows = 0;
|
||||
int iCols = 0;
|
||||
int iType = 0;
|
||||
int *piAddrVar = NULL;
|
||||
char *_pstStrings = NULL;
|
||||
int piLength = 0;
|
||||
int iRet;
|
||||
char *pstStrings = NULL;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, _iVar, &piAddrVar);
|
||||
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(999, _("%s: Wrong type for input argument #%d: A string expected.\n"), _fname, _iVar);
|
||||
iRet = getAllocatedSingleString(_pvApiCtx, piAddrVar, &pstStrings);
|
||||
if (iRet) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getMatrixOfString(pvApiCtx, piAddrVar, &iRows, &iCols, &piLength, NULL);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iRows * iCols != 1) {
|
||||
Scierror(999, _("%s: Wrong size for input argument #%d: A string expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
// TODO: return SWIG_ERROR if _pcValue NULL (now returning SWIG_ERROR fails some typechecks)
|
||||
if (_pcValue)
|
||||
{
|
||||
*_pcValue = pstStrings;
|
||||
}
|
||||
|
||||
_pstStrings = (char *)malloc(sizeof(char) * (piLength + 1));
|
||||
sciErr = getMatrixOfString(pvApiCtx, piAddrVar, &iRows, &iCols, &piLength, (char **)&_pstStrings);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (alloc) {
|
||||
*_pcValue = %new_copy_array(_pstStrings, piLength + 1, char);
|
||||
if (alloc != NULL) {
|
||||
*alloc = SWIG_NEWOBJ;
|
||||
} else if (_pcValue) {
|
||||
*_pcValue = _pstStrings;
|
||||
}
|
||||
|
||||
free(_pstStrings);
|
||||
|
||||
if (_piLength != NULL) {
|
||||
*_piLength = (size_t) piLength;
|
||||
*_piLength = strlen(*_pcValue);
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
|
|
@ -220,23 +179,77 @@ SwigScilabStringFromCharPtr(void *_pvApiCtx, int _iVarOut, const char *_pchValue
|
|||
return Rhs + _iVarOut;
|
||||
}
|
||||
}
|
||||
%fragment("SwigScilabStringFromCharPtrAndSize", "header") {
|
||||
|
||||
/*
|
||||
* CHAR * ARRAY
|
||||
*/
|
||||
%fragment("SwigScilabStringToCharPtrArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SwigScilabStringFromCharPtrAndSize(void *_pvApiCtx, int _iVarOut, const char *_pchValue) {
|
||||
SwigScilabStringToCharPtrArrayAndSize(void *_pvApiCtx, int _iVar, char ***_charPtrArray, int* _charPtrArraySize, char *_fname) {
|
||||
SciErr sciErr;
|
||||
char **pstData = NULL;
|
||||
int i = 0;
|
||||
int *piAddrVar = NULL;
|
||||
int iRows = 0;
|
||||
int iCols = 0;
|
||||
int* piLength = NULL;
|
||||
|
||||
pstData = (char **)malloc(sizeof(char *));
|
||||
pstData[0] = strdup(_pchValue);
|
||||
if ((_charPtrArray == NULL) || (_charPtrArraySize == NULL)) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = createMatrixOfString(_pvApiCtx, Rhs + _iVarOut, 1, 1, (char **)pstData);
|
||||
sciErr = getVarAddressFromPosition(_pvApiCtx, _iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
free(pstData[0]);
|
||||
sciErr = getMatrixOfString(_pvApiCtx, piAddrVar, &iRows, &iCols, NULL, NULL);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return Rhs + _iVarOut;
|
||||
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;
|
||||
}
|
||||
*_charPtrArraySize = iRows * iCols;
|
||||
|
||||
free(piLength);
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
%fragment("SwigScilabStringFromCharPtrArray", "header") {
|
||||
SWIGINTERN int
|
||||
SwigScilabStringFromCharPtrArray(void *_pvApiCtx, int _iVarOut, char **_charPtrArray, int _charPtrArraySize) {
|
||||
SciErr sciErr;
|
||||
|
||||
if (_charPtrArray == NULL) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = createMatrixOfString(_pvApiCtx, nbInputArgument(pvApiCtx) + _iVarOut, _charPtrArraySize, 1, _charPtrArray);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return nbInputArgument(pvApiCtx) + _iVarOut;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* scicontainer.swg
|
||||
*
|
||||
* Scilab list <-> C++ container wrapper (Based on Octave wrapper)
|
||||
* 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.
|
||||
|
|
@ -15,177 +15,32 @@
|
|||
#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>
|
||||
|
||||
// The Scilab C++ Wrap
|
||||
|
||||
%insert(header) %{
|
||||
%{
|
||||
#include <stdexcept>
|
||||
%}
|
||||
|
||||
%include <std_except.i>
|
||||
|
||||
%fragment(SWIG_Traits_frag(SciObject),"header",fragment="StdTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits<SciObject > {
|
||||
typedef value_category category;
|
||||
static const char* type_name() { return "SciObject"; }
|
||||
};
|
||||
|
||||
template <> struct traits_from<SciObject> {
|
||||
typedef SciObject value_type;
|
||||
static SciObject from(const value_type& val) {
|
||||
return val;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct traits_check<SciObject, value_category> {
|
||||
static bool check(const SciObject&) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct traits_asval<SciObject > {
|
||||
typedef SciObject value_type;
|
||||
static int asval(const SciObject& obj, value_type *val) {
|
||||
if (val) *val = obj;
|
||||
return SWIG_OK;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%fragment("SciSequence_Base","header",fragment="<stddef.h>")
|
||||
{
|
||||
%#include <functional>
|
||||
|
||||
namespace std {
|
||||
template <>
|
||||
struct less <SciObject>: public binary_function<SciObject, SciObject, bool>
|
||||
{
|
||||
bool
|
||||
operator()(const SciObject& v, const SciObject& w) const
|
||||
{
|
||||
//SciObject res = do_binary_op(SciObject::op_le,v,w);
|
||||
return true;//res.is_true();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
namespace swig {
|
||||
inline size_t
|
||||
check_index(ptrdiff_t i, size_t size, bool insert = false) {
|
||||
if ( i < 0 ) {
|
||||
if ((size_t) (-i) <= size)
|
||||
return (size_t) (i + size);
|
||||
} else if ( (size_t) i < size ) {
|
||||
return (size_t) i;
|
||||
} else if (insert && ((size_t) i == size)) {
|
||||
return size;
|
||||
}
|
||||
|
||||
throw std::out_of_range("index out of range");
|
||||
}
|
||||
|
||||
inline size_t
|
||||
slice_index(ptrdiff_t i, size_t size) {
|
||||
if ( i < 0 ) {
|
||||
if ((size_t) (-i) <= size) {
|
||||
return (size_t) (i + size);
|
||||
} else {
|
||||
throw std::out_of_range("index out of range");
|
||||
}
|
||||
} else {
|
||||
return ( (size_t) i < size ) ? ((size_t) i) : size;
|
||||
}
|
||||
}
|
||||
|
||||
template <class Sequence, class Difference>
|
||||
inline typename Sequence::iterator
|
||||
getpos(Sequence* self, Difference i) {
|
||||
typename Sequence::iterator pos = self->begin();
|
||||
std::advance(pos, check_index(i,self->size()));
|
||||
return pos;
|
||||
}
|
||||
|
||||
template <class Sequence, class Difference>
|
||||
inline typename Sequence::const_iterator
|
||||
cgetpos(const Sequence* self, Difference i) {
|
||||
typename Sequence::const_iterator pos = self->begin();
|
||||
std::advance(pos, check_index(i,self->size()));
|
||||
return pos;
|
||||
}
|
||||
|
||||
template <class Sequence, class Difference>
|
||||
inline Sequence*
|
||||
getslice(const Sequence* self, Difference i, Difference j) {
|
||||
typename Sequence::size_type size = self->size();
|
||||
typename Sequence::size_type ii = swig::check_index(i, size);
|
||||
typename Sequence::size_type jj = swig::slice_index(j, size);
|
||||
|
||||
if (jj > ii) {
|
||||
typename Sequence::const_iterator vb = self->begin();
|
||||
typename Sequence::const_iterator ve = self->begin();
|
||||
std::advance(vb,ii);
|
||||
std::advance(ve,jj);
|
||||
return new Sequence(vb, ve);
|
||||
} else {
|
||||
return new Sequence();
|
||||
}
|
||||
}
|
||||
|
||||
template <class Sequence, class Difference, class InputSeq>
|
||||
inline void
|
||||
setslice(Sequence* self, Difference i, Difference j, const InputSeq& v) {
|
||||
typename Sequence::size_type size = self->size();
|
||||
typename Sequence::size_type ii = swig::check_index(i, size, true);
|
||||
typename Sequence::size_type jj = swig::slice_index(j, size);
|
||||
if (jj < ii) jj = ii;
|
||||
size_t ssize = jj - ii;
|
||||
if (ssize <= v.size()) {
|
||||
typename Sequence::iterator sb = self->begin();
|
||||
typename InputSeq::const_iterator vmid = v.begin();
|
||||
std::advance(sb,ii);
|
||||
std::advance(vmid, jj - ii);
|
||||
self->insert(std::copy(v.begin(), vmid, sb), vmid, v.end());
|
||||
} else {
|
||||
typename Sequence::iterator sb = self->begin();
|
||||
typename Sequence::iterator se = self->begin();
|
||||
std::advance(sb,ii);
|
||||
std::advance(se,jj);
|
||||
self->erase(sb,se);
|
||||
self->insert(sb, v.begin(), v.end());
|
||||
}
|
||||
}
|
||||
|
||||
template <class Sequence, class Difference>
|
||||
inline void
|
||||
delslice(Sequence* self, Difference i, Difference j) {
|
||||
typename Sequence::size_type size = self->size();
|
||||
typename Sequence::size_type ii = swig::check_index(i, size, true);
|
||||
typename Sequence::size_type jj = swig::slice_index(j, size);
|
||||
if (jj > ii) {
|
||||
typename Sequence::iterator sb = self->begin();
|
||||
typename Sequence::iterator se = self->begin();
|
||||
std::advance(sb,ii);
|
||||
std::advance(se,jj);
|
||||
self->erase(sb,se);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%fragment("SciSequence_Cont","header",
|
||||
%fragment("SciSequence_Cont", "header",
|
||||
fragment="StdTraits",
|
||||
fragment="SciSequence_Base",
|
||||
fragment="SciSwigIterator_T")
|
||||
{
|
||||
%#include <stdio.h>
|
||||
|
|
@ -193,43 +48,46 @@ namespace swig {
|
|||
namespace swig
|
||||
{
|
||||
template <class T>
|
||||
struct SciSequence_Ref // * Scilab can't support these, because of how assignment works
|
||||
struct SciSequence_Ref
|
||||
{
|
||||
SciSequence_Ref(const SciObject& 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
|
||||
{
|
||||
// swig::SwigVar_PyObject item = SciSequence_GetItem(_seq, _index);
|
||||
SciObject item; // * todo
|
||||
try {
|
||||
return swig::as<T>(item, true);
|
||||
} catch (std::exception& e) {
|
||||
char msg[1024];
|
||||
sprintf(msg, "in sequence element %d ", _index);
|
||||
if (!Scilab_Error_Occurred()) {
|
||||
%type_error(swig::type_name<T>());
|
||||
}
|
||||
SWIG_Scilab_AddErrorMsg(msg);
|
||||
SWIG_Scilab_AddErrorMsg(e.what());
|
||||
throw;
|
||||
try
|
||||
{
|
||||
T value;
|
||||
if (traits_asval_sequenceitem<T>::asval(_seq, _piSeqAddr, _index, &value) == SWIG_OK)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
SWIG_Scilab_AddErrorMsg(e.what());
|
||||
}
|
||||
}
|
||||
|
||||
SciSequence_Ref& operator=(const T& v)
|
||||
{
|
||||
// SciSequence_SetItem(_seq, _index, swig::from<T>(v));
|
||||
// * todo
|
||||
// TODO
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
SciObject _seq;
|
||||
int _index;
|
||||
private:
|
||||
SciObject _seq;
|
||||
int _index;
|
||||
void *_piSeqAddr;
|
||||
};
|
||||
|
||||
|
||||
template <class T>
|
||||
struct SciSequence_ArrowProxy
|
||||
{
|
||||
|
|
@ -349,14 +207,6 @@ namespace swig
|
|||
|
||||
SciSequence_Cont(const SciObject& seq) : _seq(seq)
|
||||
{
|
||||
// * assert that we have map type etc.
|
||||
/*
|
||||
if (!SciSequence_Check(seq)) {
|
||||
throw std::invalid_argument("a sequence is expected");
|
||||
}
|
||||
_seq = seq;
|
||||
Py_INCREF(_seq);
|
||||
*/
|
||||
}
|
||||
|
||||
~SciSequence_Cont()
|
||||
|
|
@ -365,8 +215,15 @@ namespace swig
|
|||
|
||||
size_type size() const
|
||||
{
|
||||
// return static_cast<size_type>(SciSequence_Size(_seq));
|
||||
return 0; // * todo
|
||||
int iSeqSize;
|
||||
if (traits_as_sequence<value_type>::size(_seq, &iSeqSize) == SWIG_OK)
|
||||
{
|
||||
return iSeqSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool empty() const
|
||||
|
|
@ -404,28 +261,9 @@ namespace swig
|
|||
return const_reference(_seq, n);
|
||||
}
|
||||
|
||||
bool check(bool set_err = true) const
|
||||
{
|
||||
int s = size();
|
||||
for (int i = 0; i < s; ++i) {
|
||||
// swig::SwigVar_PyObject item = SciSequence_GetItem(_seq, i);
|
||||
SciObject item; // * todo
|
||||
if (!swig::check<value_type>(item)) {
|
||||
if (set_err) {
|
||||
char msg[1024];
|
||||
sprintf(msg, "in sequence element %d", i);
|
||||
SWIG_Error(SWIG_RuntimeError, msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
SciObject _seq;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -491,30 +329,6 @@ namespace swig
|
|||
%swig_sequence_iterator(%arg(Sequence))
|
||||
%swig_container_methods(%arg(Sequence))
|
||||
|
||||
%fragment("SciSequence_Base");
|
||||
|
||||
%extend {
|
||||
value_type pop() throw (std::out_of_range) {
|
||||
if (self->size() == 0)
|
||||
throw std::out_of_range("pop from empty container");
|
||||
Sequence::value_type x = self->back();
|
||||
self->pop_back();
|
||||
return x;
|
||||
}
|
||||
|
||||
value_type __paren__(difference_type i) throw (std::out_of_range) {
|
||||
return *(swig::cgetpos(self, i));
|
||||
}
|
||||
|
||||
void __paren_asgn__(difference_type i, value_type x) throw (std::out_of_range) {
|
||||
*(swig::getpos(self,i)) = x;
|
||||
}
|
||||
|
||||
void append(value_type x) {
|
||||
self->push_back(x);
|
||||
}
|
||||
}
|
||||
|
||||
%enddef
|
||||
|
||||
%define %swig_sequence_methods(Sequence...)
|
||||
|
|
@ -531,20 +345,21 @@ namespace swig
|
|||
|
||||
%fragment("StdSequenceTraits","header",
|
||||
fragment="StdTraits",
|
||||
fragment="SciSequence_Cont")
|
||||
fragment="SciSequence_Cont",
|
||||
fragment=SWIG_Traits_SequenceItem_frag(ptr))
|
||||
{
|
||||
namespace swig {
|
||||
template <class SciSeq, class Seq>
|
||||
inline void
|
||||
assign(const SciSeq& sciseq, Seq* seq) {
|
||||
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) {
|
||||
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());
|
||||
seq->assign(sciSeq.begin(), sciSeq.end());
|
||||
%#endif
|
||||
}
|
||||
|
||||
|
|
@ -553,9 +368,41 @@ namespace swig {
|
|||
typedef Seq sequence;
|
||||
typedef T value_type;
|
||||
|
||||
static int asptr(const SciObject& obj, sequence **seq) {
|
||||
// TODO: convert input Scilab list (or pointer) to sequence.
|
||||
return SWIG_ERROR;
|
||||
static int asptr(const SciObject& 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_Scilab_AddErrorMsg(e.what());
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -566,15 +413,39 @@ namespace swig {
|
|||
typedef typename Seq::size_type size_type;
|
||||
typedef typename sequence::const_iterator const_iterator;
|
||||
|
||||
static SciObject from(const sequence& seq) {
|
||||
#ifdef SWIG_SCILAB_EXTRA_NATIVE_CONTAINERS
|
||||
swig_type_info *desc = swig::type_info<sequence>();
|
||||
if (desc && desc->clientdata) {
|
||||
return SWIG_NewPointerObj(new sequence(seq), desc, SWIG_POINTER_OWN);
|
||||
static SciObject 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);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
SWIG_Scilab_AddErrorMsg(e.what());
|
||||
}
|
||||
#endif
|
||||
// TODO: return a Scilab list from the sequence.
|
||||
return (SciObject)0;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
78
Lib/scilab/scilist.swg
Normal file
78
Lib/scilab/scilist.swg
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* Scilab list related functions
|
||||
*
|
||||
*/
|
||||
|
||||
%fragment("SWIG_ScilabList", "header")
|
||||
{
|
||||
SWIGINTERN int
|
||||
SWIG_GetScilabList(SciObject _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(SciObject _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_CheckScilabList(SciObject _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(999, _("%s: Wrong type for input argument #%d: A list is expected.\n"), fname, _obj);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
91
Lib/scilab/scimatrixchar.swg
Normal file
91
Lib/scilab/scimatrixchar.swg
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* C-type: char*
|
||||
* Scilab type: string matrix
|
||||
*/
|
||||
|
||||
%include <scichar.swg>
|
||||
|
||||
// in (char** vectorIn, int vectorInSize)
|
||||
|
||||
%typemap(in, fragment="SwigScilabStringToCharPtrArrayAndSize") (char** vectorIn, int vectorInSize)
|
||||
{
|
||||
if (SwigScilabStringToCharPtrArrayAndSize(pvApiCtx, $input, &$1, &$2, fname) == SWIG_ERROR)
|
||||
{
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
// out (char*** vectorOut, int* vectorOutSize)
|
||||
|
||||
%typemap(in, numinputs=0) (char*** vectorOut, int* vectorOutSize)
|
||||
{
|
||||
}
|
||||
|
||||
%typemap(arginit) (char*** vectorOut, int* vectorOutSize)
|
||||
{
|
||||
$1 = (char***) malloc(sizeof(char**));
|
||||
$2 = (int*) malloc(sizeof(int));
|
||||
}
|
||||
|
||||
%typemap(freearg) (char*** vectorOut, int* vectorOutSize)
|
||||
{
|
||||
free(*(*$1));
|
||||
free(*$1);
|
||||
free($1);
|
||||
free($2);
|
||||
}
|
||||
|
||||
%typemap(argout, fragment="SwigScilabStringFromCharPtrArray") (char*** vectorOut, int* vectorOutSize)
|
||||
{
|
||||
if (SwigScilabStringFromCharPtrArray(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$1, *$2) != SWIG_ERROR)
|
||||
{
|
||||
AssignOutputVariable(pvApiCtx, outputPosition) = nbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition();
|
||||
}
|
||||
else
|
||||
{
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
// in (int vectorInSize, char** vectorIn)
|
||||
|
||||
%typemap(in, fragment="SwigScilabStringToCharPtrArrayAndSize") (int vectorInSize, char** vectorIn)
|
||||
{
|
||||
if (SwigScilabStringToCharPtrArrayAndSize(pvApiCtx, $input, &$2, &$1, fname) == SWIG_ERROR)
|
||||
{
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
// out (int* vectorOutSize, char*** vectorOut)
|
||||
|
||||
%typemap(in, numinputs=0) (int* vectorOutSize, char*** vectorOut)
|
||||
{
|
||||
}
|
||||
|
||||
%typemap(arginit) (int* vectorOutSize, char*** vectorOut)
|
||||
{
|
||||
$1 = (int*) malloc(sizeof(int));
|
||||
$2 = (char***) malloc(sizeof(char**));
|
||||
}
|
||||
|
||||
%typemap(argout, fragment="SwigScilabStringFromCharPtrArray") (int* vectorOutSize, char*** vectorOut)
|
||||
{
|
||||
if (SwigScilabStringFromCharPtrArray(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$2, *$1) != SWIG_ERROR)
|
||||
{
|
||||
AssignOutputVariable(pvApiCtx, outputPosition) = nbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition();
|
||||
}
|
||||
else
|
||||
{
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(freearg) (int* vectorOutSize, char*** vectorOut)
|
||||
{
|
||||
free($1);
|
||||
free(*(*$2));
|
||||
free(*$2);
|
||||
free($2);
|
||||
}
|
||||
|
||||
|
|
@ -5,7 +5,9 @@
|
|||
|
||||
%include <scidouble.swg>
|
||||
|
||||
%typemap(in, fragment="SWIG_SciDouble_AsDoubleArrayAndSize") (double* matrixAsInput, int rows, int cols)
|
||||
// in (double* matrixIn, int matrixInRowCount, int matrixInColCount)
|
||||
|
||||
%typemap(in, fragment="SWIG_SciDouble_AsDoubleArrayAndSize") (double* matrixIn, int matrixInRowCount, int matrixInColCount)
|
||||
{
|
||||
if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &$2, &$3, &$1, fname) == SWIG_ERROR)
|
||||
{
|
||||
|
|
@ -13,7 +15,9 @@
|
|||
}
|
||||
}
|
||||
|
||||
%typemap(in, fragment="SWIG_SciDouble_AsDoubleArrayAndSize") (int rows, int cols, double* matrixAsInput)
|
||||
// in (int matrixInRowCount, int matrixInColCount, double* matrixIn)
|
||||
|
||||
%typemap(in, fragment="SWIG_SciDouble_AsDoubleArrayAndSize") (int matrixInRowCount, int matrixInColCount, double* matrixIn)
|
||||
{
|
||||
if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &$1, &$2, &$3, fname) == SWIG_ERROR)
|
||||
{
|
||||
|
|
@ -21,13 +25,15 @@
|
|||
}
|
||||
}
|
||||
|
||||
%typemap(in) (double* matrixAsInput, int size)
|
||||
// in (double* vectorIn, int vectorInSize)
|
||||
|
||||
%typemap(in) (double* vectorIn, int vectorInSize)
|
||||
{
|
||||
int nbRows;
|
||||
int nbCols;
|
||||
if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &nbRows, &nbCols, &$1, fname) != SWIG_ERROR)
|
||||
int rowCount;
|
||||
int colCount;
|
||||
if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$1, fname) != SWIG_ERROR)
|
||||
{
|
||||
$2 = nbRows * nbCols;
|
||||
$2 = rowCount * colCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -35,13 +41,15 @@
|
|||
}
|
||||
}
|
||||
|
||||
%typemap(in) (int size, double* matrixAsInput)
|
||||
// in (int vectorInSize, double* vectorIn)
|
||||
|
||||
%typemap(in) (int vectorInSize, double* vectorIn)
|
||||
{
|
||||
int nbRows;
|
||||
int nbCols;
|
||||
if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &nbRows, &nbCols, &$2, fname) != SWIG_ERROR)
|
||||
int rowCount;
|
||||
int colCount;
|
||||
if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$2, fname) != SWIG_ERROR)
|
||||
{
|
||||
$1 = nbRows * nbCols;
|
||||
$1 = rowCount * colCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -49,18 +57,20 @@
|
|||
}
|
||||
}
|
||||
|
||||
%typemap(in, numinputs=0) (double** matrixAsOutput, int* rows, int* cols)
|
||||
// out (double** matrixOut, int* matrixOutRowCount, int* matrixOutColCount)
|
||||
|
||||
%typemap(in, numinputs=0) (double** matrixOut, int* matrixOutRowCount, int* matrixOutColCount)
|
||||
{
|
||||
}
|
||||
|
||||
%typemap(arginit) (double** matrixAsOutput, int* rows, int* cols)
|
||||
%typemap(arginit) (double** matrixOut, int* matrixOutRowCount, int* matrixOutColCount)
|
||||
{
|
||||
$1 = (double**) malloc(sizeof(double*));
|
||||
$2 = (int*) malloc(sizeof(int));
|
||||
$3 = (int*) malloc(sizeof(int));
|
||||
}
|
||||
|
||||
%typemap(freearg) (double** matrixAsOutput, int* rows, int* cols)
|
||||
%typemap(freearg) (double** matrixOut, int* matrixOutRowCount, int* matrixOutColCount)
|
||||
{
|
||||
free(*$1);
|
||||
free($1);
|
||||
|
|
@ -68,7 +78,7 @@
|
|||
free($3);
|
||||
}
|
||||
|
||||
%typemap(argout, fragment="SWIG_SciDouble_FromDoubleArrayAndSize") (double** matrixAsOutput, int* rows, int* cols)
|
||||
%typemap(argout, fragment="SWIG_SciDouble_FromDoubleArrayAndSize") (double** matrixOut, int* matrixOutRowCount, int* matrixOutColCount)
|
||||
{
|
||||
if (SWIG_SciDouble_FromDoubleArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$2, *$3, *$1) != SWIG_ERROR)
|
||||
{
|
||||
|
|
@ -80,22 +90,22 @@
|
|||
}
|
||||
}
|
||||
|
||||
// (int* rows, int* cols, double** matrixAsOutput)
|
||||
// out (int* matrixOutRowCount, int* matrixOutColCount, double** matrixOut)
|
||||
|
||||
%typemap(in, numinputs=0) (int* rows, int* cols, double** matrixAsOutput)
|
||||
%typemap(in, numinputs=0) (int* matrixOutRowCount, int* matrixOutColCount, double** matrixOut)
|
||||
{
|
||||
}
|
||||
|
||||
%typemap(arginit) (int* rows, int* cols, double** matrixAsOutput)
|
||||
%typemap(arginit) (int* matrixOutRowCount, int* matrixOutColCount, double** matrixOut)
|
||||
{
|
||||
$1 = (int*) malloc(sizeof(int));
|
||||
$2 = (int*) malloc(sizeof(int));
|
||||
$3 = (double**) malloc(sizeof(double*));
|
||||
}
|
||||
|
||||
%typemap(argout, fragment="SWIG_SciInt32_FromIntArrayAndSize") (int* rows, int* cols, double** matrixAsOutput)
|
||||
%typemap(argout, fragment="SWIG_SciDouble_FromDoubleArrayAndSize") (int* matrixInRowCount, int* matrixInColCount, double** matrixOut)
|
||||
{
|
||||
if (SWIG_SciInt32_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$1, *$2, *$3) != SWIG_ERROR)
|
||||
if (SWIG_SciDouble_FromDoubleArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$1, *$2, *$3) != SWIG_ERROR)
|
||||
{
|
||||
AssignOutputVariable(pvApiCtx, outputPosition) = nbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition();
|
||||
}
|
||||
|
|
@ -105,7 +115,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
%typemap(freearg) (int* rows, int* cols, double** matrixAsOutput)
|
||||
%typemap(freearg) (int* matrixOutRowCount, int* matrixOutColCount, double** matrixOut)
|
||||
{
|
||||
free($1);
|
||||
free($2);
|
||||
|
|
@ -114,21 +124,20 @@
|
|||
}
|
||||
|
||||
|
||||
// (double** matrixAsOutput, int* size)
|
||||
// out (double** vectorOut, int* vectorOutSize)
|
||||
|
||||
%typemap(in, numinputs=0) (double** matrixAsOutput, int* size)
|
||||
%typemap(in, numinputs=0) (double** vectorOut, int* vectorOutSize)
|
||||
{
|
||||
}
|
||||
|
||||
%typemap(arginit) (double** matrixAsOutput, int* size)
|
||||
%typemap(arginit) (double** vectorOut, int* vectorOutSize)
|
||||
{
|
||||
$1 = (double**) malloc(sizeof(double*));
|
||||
$2 = (int*) malloc(sizeof(int));
|
||||
}
|
||||
|
||||
%typemap(argout, fragment="SWIG_SciInt32_FromIntArrayAndSize") (double** matrixAsOutput, int* size)
|
||||
%typemap(argout, fragment="SWIG_SciDouble_FromDoubleArrayAndSize") (double** vectorOut, int* vectorOutSize)
|
||||
{
|
||||
|
||||
if (SWIG_SciDouble_FromDoubleArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$2, *$1) != SWIG_ERROR)
|
||||
{
|
||||
AssignOutputVariable(pvApiCtx, outputPosition) = nbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition();
|
||||
|
|
@ -139,7 +148,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
%typemap(freearg) (double** matrixAsOutput, int* size)
|
||||
%typemap(freearg) (double** vectorOut, int* vectorOutSize)
|
||||
{
|
||||
free(*$1);
|
||||
free($1);
|
||||
|
|
@ -147,21 +156,20 @@
|
|||
}
|
||||
|
||||
|
||||
// (int* size, double** matrixAsOutput)
|
||||
// out (int* vectorOutSize, double** vectorOut)
|
||||
|
||||
%typemap(in, numinputs=0) (int* size, double** matrixAsOutput)
|
||||
%typemap(in, numinputs=0) (int* vectorOutSize, double** vectorOut)
|
||||
{
|
||||
}
|
||||
|
||||
%typemap(arginit) (int* size, double** matrixAsOutput)
|
||||
%typemap(arginit) (int* vectorOutSize, double** vectorOut)
|
||||
{
|
||||
$1 = (int*) malloc(sizeof(int));
|
||||
$2 = (double**) malloc(sizeof(double*));
|
||||
}
|
||||
|
||||
%typemap(argout, fragment="SWIG_SciInt32_FromIntArrayAndSize") (int* size, double** matrixAsOutput)
|
||||
%typemap(argout, fragment="SWIG_SciDouble_FromDoubleArrayAndSize") (int* vectorOutSize, double** vectorOut)
|
||||
{
|
||||
|
||||
if (SWIG_SciDouble_FromDoubleArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$1, *$2) != SWIG_ERROR)
|
||||
{
|
||||
AssignOutputVariable(pvApiCtx, outputPosition) = nbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition();
|
||||
|
|
@ -172,7 +180,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
%typemap(freearg) (int* size, double** matrixAsOutput)
|
||||
%typemap(freearg) (int* vectorOutSize, double** vectorOut)
|
||||
{
|
||||
free($1);
|
||||
free(*$2);
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@
|
|||
|
||||
%include <sciint.swg>
|
||||
|
||||
// (int* matrixAsInput, int rows, int cols)
|
||||
// in (int* matrixIn, int matrixInRowCount, int matrixInColCount)
|
||||
|
||||
%typemap(in, fragment="SWIG_SciInt32_AsIntArrayAndSize") (int* matrixAsInput, int rows, int cols)
|
||||
%typemap(in, fragment="SWIG_SciInt32_AsIntArrayAndSize") (int* matrixIn, int matrixInRowCount, int matrixInColCount)
|
||||
{
|
||||
if (SWIG_SciInt32_AsIntArrayAndSize(pvApiCtx, $input, &$2, &$3, &$1, fname) == SWIG_ERROR)
|
||||
{
|
||||
|
|
@ -16,9 +16,9 @@
|
|||
}
|
||||
|
||||
|
||||
// (int rows, int cols, int* matrixAsInput)
|
||||
// in (int matrixInRowCount, int matrixInColCount, int* matrixIn)
|
||||
|
||||
%typemap(in, fragment="SWIG_SciInt32_AsIntArrayAndSize") (int rows, int cols, int* matrixAsInput)
|
||||
%typemap(in, fragment="SWIG_SciInt32_AsIntArrayAndSize") (int matrixInRowCount, int matrixInColCount, int* matrixIn)
|
||||
{
|
||||
if (SWIG_SciInt32_AsIntArrayAndSize(pvApiCtx, $input, &$1, &$2, &$3, fname) == SWIG_ERROR)
|
||||
{
|
||||
|
|
@ -27,15 +27,15 @@
|
|||
}
|
||||
|
||||
|
||||
// (int* matrixAsInput, int size)
|
||||
// in (int* vectorIn, int vectorInSize)
|
||||
|
||||
%typemap(in) (int* matrixAsInput, int size)
|
||||
%typemap(in) (int* vectorIn, int vectorInSize)
|
||||
{
|
||||
int nbRows;
|
||||
int nbCols;
|
||||
if (SWIG_SciInt32_AsIntArrayAndSize(pvApiCtx, $input, &nbRows, &nbCols, &$1, fname) != SWIG_ERROR)
|
||||
int rowCount;
|
||||
int colCount;
|
||||
if (SWIG_SciInt32_AsIntArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$1, fname) != SWIG_ERROR)
|
||||
{
|
||||
$2 = nbRows * nbCols;
|
||||
$2 = rowCount * colCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -44,15 +44,15 @@
|
|||
}
|
||||
|
||||
|
||||
// (int size, int* matrixAsInput)
|
||||
// in (int vectorInSize, int* vectorIn)
|
||||
|
||||
%typemap(in) (int size, int* matrixAsInput)
|
||||
%typemap(in) (int vectorInSize, int* vectorIn)
|
||||
{
|
||||
int nbRows;
|
||||
int nbCols;
|
||||
if (SWIG_SciInt32_AsIntArrayAndSize(pvApiCtx, $input, &nbRows, &nbCols, &$2, fname) != SWIG_ERROR)
|
||||
int rowCount;
|
||||
int colCount;
|
||||
if (SWIG_SciInt32_AsIntArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$2, fname) != SWIG_ERROR)
|
||||
{
|
||||
$1 = nbRows * nbCols;
|
||||
$1 = rowCount * colCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -60,20 +60,20 @@
|
|||
}
|
||||
}
|
||||
|
||||
// (int** matrixAsOutput, int* rows, int* cols)
|
||||
// out (int** matrixOut, int* matrixOutRowCount, int* matrixOutColCount)
|
||||
|
||||
%typemap(in, numinputs=0) (int** matrixAsOutput, int* rows, int* cols)
|
||||
%typemap(in, numinputs=0) (int** matrixOut, int* matrixOutRowCount, int* matrixOutColCount)
|
||||
{
|
||||
}
|
||||
|
||||
%typemap(arginit) (int** matrixAsOutput, int* rows, int* cols)
|
||||
%typemap(arginit) (int** matrixOut, int* matrixOutRowCount, int* matrixOutColCount)
|
||||
{
|
||||
$1 = (int**) malloc(sizeof(int*));
|
||||
$2 = (int*) malloc(sizeof(int));
|
||||
$3 = (int*) malloc(sizeof(int));
|
||||
}
|
||||
|
||||
%typemap(argout, fragment="SWIG_SciInt32_FromIntArrayAndSize") (int** matrixAsOutput, int* rows, int* cols)
|
||||
%typemap(argout, fragment="SWIG_SciInt32_FromIntArrayAndSize") (int** matrixOut, int* matrixOutRowCount, int* matrixOutColCount)
|
||||
{
|
||||
if (SWIG_SciInt32_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$2, *$3, *$1) != SWIG_ERROR)
|
||||
{
|
||||
|
|
@ -85,7 +85,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
%typemap(freearg) (int** matrixAsOutput, int* rows, int* cols)
|
||||
%typemap(freearg) (int** matrixOut, int* matrixOutRowCount, int* matrixOutColCount)
|
||||
{
|
||||
free(*$1);
|
||||
free($1);
|
||||
|
|
@ -94,20 +94,20 @@
|
|||
}
|
||||
|
||||
|
||||
// (int* rows, int* cols, int** matrixAsOutput)
|
||||
// out (int* matrixOutRowCount, int* matrixOutColCount, int** matrixOut)
|
||||
|
||||
%typemap(in, numinputs=0) (int* rows, int* cols, int** matrixAsOutput)
|
||||
%typemap(in, numinputs=0) (int* matrixOutRowCount, int* matrixOutColCount, int** matrixOut)
|
||||
{
|
||||
}
|
||||
|
||||
%typemap(arginit) (int* rows, int* cols, int** matrixAsOutput)
|
||||
%typemap(arginit) (int* matrixOutRowCount, int* matrixOutColCount, int** matrixOut)
|
||||
{
|
||||
$1 = (int*) malloc(sizeof(int));
|
||||
$2 = (int*) malloc(sizeof(int));
|
||||
$3 = (int**) malloc(sizeof(int*));
|
||||
}
|
||||
|
||||
%typemap(argout, fragment="SWIG_SciInt32_FromIntArrayAndSize") (int* rows, int* cols, int** matrixAsOutput)
|
||||
%typemap(argout, fragment="SWIG_SciInt32_FromIntArrayAndSize") (int* matrixOutRowCount, int* matrixOutColCount, int** matrixOut)
|
||||
{
|
||||
if (SWIG_SciInt32_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$1, *$2, *$3) != SWIG_ERROR)
|
||||
{
|
||||
|
|
@ -119,7 +119,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
%typemap(freearg) (int* rows, int* cols, int** matrixAsOutput)
|
||||
%typemap(freearg) (int* matrixOutRowCount, int* matrixOutColCount, int** matrixOut)
|
||||
{
|
||||
free($1);
|
||||
free($2);
|
||||
|
|
@ -128,21 +128,20 @@
|
|||
}
|
||||
|
||||
|
||||
// (int** matrixAsOutput, int* size)
|
||||
// out (int** vectorOut, int* vectorOutSize)
|
||||
|
||||
%typemap(in, numinputs=0) (int** matrixAsOutput, int* size)
|
||||
%typemap(in, numinputs=0) (int** vectorOut, int* vectorOutSize)
|
||||
{
|
||||
}
|
||||
|
||||
%typemap(arginit) (int** matrixAsOutput, int* size)
|
||||
%typemap(arginit) (int** vectorOut, int* vectorOutSize)
|
||||
{
|
||||
$1 = (int**) malloc(sizeof(int*));
|
||||
$2 = (int*) malloc(sizeof(int));
|
||||
}
|
||||
|
||||
%typemap(argout, fragment="SWIG_SciInt32_FromIntArrayAndSize") (int** matrixAsOutput, int* size)
|
||||
%typemap(argout, fragment="SWIG_SciInt32_FromIntArrayAndSize") (int** vectorOut, int* vectorOutSize)
|
||||
{
|
||||
|
||||
if (SWIG_SciInt32_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$2, *$1) != SWIG_ERROR)
|
||||
{
|
||||
AssignOutputVariable(pvApiCtx, outputPosition) = nbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition();
|
||||
|
|
@ -153,7 +152,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
%typemap(freearg) (int** matrixAsOutput, int* size)
|
||||
%typemap(freearg) (int** vectorOut, int* vectorOutSize)
|
||||
{
|
||||
free(*$1);
|
||||
free($1);
|
||||
|
|
@ -161,21 +160,20 @@
|
|||
}
|
||||
|
||||
|
||||
// (int* size, int** matrixAsOutput)
|
||||
// out (int* vectorOutSize, int** vectorOut)
|
||||
|
||||
%typemap(in, numinputs=0) (int* size, int** matrixAsOutput)
|
||||
%typemap(in, numinputs=0) (int* vectorOutSize, int** vectorOut)
|
||||
{
|
||||
}
|
||||
|
||||
%typemap(arginit) (int* size, int** matrixAsOutput)
|
||||
%typemap(arginit) (int* vectorOutSize, int** vectorOut)
|
||||
{
|
||||
$1 = (int*) malloc(sizeof(int));
|
||||
$2 = (int**) malloc(sizeof(int*));
|
||||
}
|
||||
|
||||
%typemap(argout, fragment="SWIG_SciInt32_FromIntArrayAndSize") (int* size, int** matrixAsOutput)
|
||||
%typemap(argout, fragment="SWIG_SciInt32_FromIntArrayAndSize") (int* vectorOutSize, int** vectorOut)
|
||||
{
|
||||
|
||||
if (SWIG_SciInt32_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$1, *$2) != SWIG_ERROR)
|
||||
{
|
||||
AssignOutputVariable(pvApiCtx, outputPosition) = nbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition();
|
||||
|
|
@ -186,7 +184,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
%typemap(freearg) (int* size, int** matrixAsOutput)
|
||||
%typemap(freearg) (int* vectorInSize, int** vectorOut)
|
||||
{
|
||||
free($1);
|
||||
free(*$2);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
|
||||
%fragment("SWIG_NewPointerObj", "header") {
|
||||
#define SWIG_NewPointerObj(pointer, pointerDescriptor, flags) SwigScilabPtrFromObject(pvApiCtx, $result, pointer, pointerDescriptor, flags)
|
||||
#define SWIG_NewPointerObj(pointer, pointerDescriptor, flags) SwigScilabPtrFromObject(pvApiCtx, SWIG_Scilab_GetOutputPosition(), pointer, pointerDescriptor, flags)
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
}
|
||||
|
||||
%fragment("SWIG_NewFunctionPtrObj", "header") {
|
||||
#define SWIG_NewFunctionPtrObj(pointer, pointerDescriptor) SwigScilabPtrFromObject(pvApiCtx, $result, pointer, pointerDescriptor, 0)
|
||||
#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
|
||||
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ SWIG_Scilab_ErrorMsg(int code, const char *mesg)
|
|||
|
||||
|
||||
#define SWIG_fail return SWIG_ERROR;
|
||||
#define SWIG_ErrorType(code) SWIG_Scilab_ErrorType(code)
|
||||
#define SWIG_ErrorType(code) SWIG_Scilab_ErrorType(code)
|
||||
#define SWIG_Error(code, msg) SWIG_Scilab_ErrorMsg(code,msg)
|
||||
|
||||
/* Used for C++ enums */
|
||||
|
|
@ -218,14 +218,39 @@ SWIG_Scilab_SetOutput(void *_pvApiCtx, SciObject _output) {
|
|||
return SWIG_OK;
|
||||
}
|
||||
|
||||
#define SwigScilabRaise(OBJ, TYPE, DESC) Scierror(999, "C++ side threw an exception of type %s.\n", TYPE)
|
||||
#define SWIG_Scilab_Raise(obj, type, desc) SwigScilabRaise(type)
|
||||
|
||||
SWIGRUNTIME int
|
||||
SwigScilabRaise(const char *type) {
|
||||
Scierror(999, "An exception of type %s has been thrown.\n", type);
|
||||
#ifdef __cplusplus
|
||||
throw;
|
||||
#endif
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
//%insert(init) "swiginit.swg"
|
||||
%init %{
|
||||
/* -----------------------------------------------------------------------------*
|
||||
* Partial Init method
|
||||
* -----------------------------------------------------------------------------*/
|
||||
#define SWIG_GetModule(clientdata) SWIG_Scilab_GetModule()
|
||||
#define SWIG_SetModule(clientdata, pointer) SWIG_Scilab_SetModule(pointer)
|
||||
|
||||
SWIGEXPORT int SWIG_init(void) {
|
||||
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"
|
||||
int SWIG_Init(char *fname, unsigned long fname_len) {
|
||||
SWIG_InitializeModule(NULL);
|
||||
%}
|
||||
|
|
|
|||
155
Lib/scilab/scisequence.swg
Normal file
155
Lib/scilab/scisequence.swg
Normal file
|
|
@ -0,0 +1,155 @@
|
|||
/*
|
||||
*
|
||||
* 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 <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)) {
|
||||
|
||||
namespace swig {
|
||||
template <typename T> struct traits_as_sequence {
|
||||
static int check(SciObject obj) {
|
||||
return SWIG_AsCheck_Sequence_dec(ptr)(obj);
|
||||
}
|
||||
static int get(SciObject obj, void **sequence) {
|
||||
return SWIG_AsGet_Sequence_dec(ptr)(obj, (int **)sequence);
|
||||
}
|
||||
static int size(SciObject obj, int *size) {
|
||||
return SWIG_AsSize_Sequence_dec(ptr)(obj, size);
|
||||
}
|
||||
};
|
||||
template <typename T> struct traits_from_sequence {
|
||||
static int create(int size, void **sequence) {
|
||||
return SWIG_FromCreate_Sequence_dec(ptr)(size, (int ***)sequence);
|
||||
}
|
||||
static SciObject set(int size, void *sequence) {
|
||||
return SWIG_FromSet_Sequence_dec(ptr)(size, (int **)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(SciObject obj) {
|
||||
return SWIG_AsCheck_Sequence_dec(CppType)(obj);
|
||||
}
|
||||
static int get(SciObject obj, void **sequence) {
|
||||
return SWIG_AsGet_Sequence_dec(CppType)(obj, (ScilabType **)sequence);
|
||||
}
|
||||
static int size(SciObject 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 SciObject 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)) {
|
||||
|
||||
namespace swig {
|
||||
template <typename T> struct traits_asval_sequenceitem {
|
||||
static int asval(SciObject obj, void *pSequence, int iItemIndex, T *pItemValue) {
|
||||
return SWIG_AsVal_SequenceItem_dec(ptr)(obj, (int *)pSequence, iItemIndex, (int **)pItemValue);
|
||||
}
|
||||
};
|
||||
template <typename T> struct traits_from_sequenceitem {
|
||||
static int from(void *pSequence, int iItemIndex, T itemValue) {
|
||||
return SWIG_From_SequenceItem_dec(ptr)((int **)pSequence, iItemIndex, (int*)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 int asval(SciObject obj, void *pSequence, int iItemIndex, CppType *pItemValue) {
|
||||
return SWIG_AsVal_SequenceItem_dec(CppType)(obj, (ScilabType *)pSequence, iItemIndex, pItemValue);
|
||||
}
|
||||
};
|
||||
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(std::string, char*);
|
||||
%add_traits_sequence(bool, int);
|
||||
|
||||
102
Lib/scilab/scisequencebool.swg
Normal file
102
Lib/scilab/scisequencebool.swg
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
*
|
||||
* Scilab matrix of bool <-> C++ bool container
|
||||
*
|
||||
*/
|
||||
|
||||
%include <scibool.swg>
|
||||
|
||||
%fragment(SWIG_AsCheck_Sequence_frag(bool), "header",
|
||||
fragment="SWIG_SciInt32_AsIntArrayAndSize") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsCheck_Sequence_dec(bool)(SciObject _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(999, _("%s: Wrong type for input argument #%d: A boolean is expected.\n"), SWIG_Scilab_GetFname(), _obj);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsGet_Sequence_frag(bool), "header",
|
||||
fragment="SWIG_SciBoolean_AsIntArrayAndSize") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsGet_Sequence_dec(bool)(SciObject _obj, int **_pSequence) {
|
||||
int iMatrixRowCount;
|
||||
int iMatrixColCount;
|
||||
return (SWIG_SciBoolean_AsIntArrayAndSize(pvApiCtx, _obj, &iMatrixRowCount, &iMatrixColCount, _pSequence, SWIG_Scilab_GetFname()));
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsSize_Sequence_frag(bool), "header",
|
||||
fragment="SWIG_SciBoolean_AsIntArrayAndSize") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsSize_Sequence_dec(bool)(SciObject _obj, int *_piSize) {
|
||||
int *piMatrix;
|
||||
int iMatrixRowCount;
|
||||
int iMatrixColCount;
|
||||
if (SWIG_SciBoolean_AsIntArrayAndSize(pvApiCtx, _obj, &iMatrixRowCount, &iMatrixColCount, &piMatrix, SWIG_Scilab_GetFname()) == SWIG_OK) {
|
||||
if ((iMatrixRowCount > 1) && (iMatrixColCount > 1)) {
|
||||
Scierror(999, _("%s: Wrong size for input argument #%d: An integer vector is expected.\n"), SWIG_Scilab_GetFname(), _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 **_sequence) {
|
||||
*_sequence = new int[_size];
|
||||
return *_sequence != NULL ? SWIG_OK : SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_FromSet_Sequence_frag(bool), "header",
|
||||
fragment="SWIG_SciBoolean_FromIntArrayAndSize") {
|
||||
|
||||
SWIGINTERN SciObject
|
||||
SWIG_FromSet_Sequence_dec(bool)(int _size, int *_sequence) {
|
||||
SciObject obj = SWIG_SciBoolean_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, _size, _sequence);
|
||||
delete (int *)_sequence;
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsVal_SequenceItem_frag(bool), "header") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsVal_SequenceItem_dec(bool)(SciObject _obj, int *_pSequence, int _iItemIndex, bool *_pItemValue) {
|
||||
*_pItemValue = _pSequence[_iItemIndex];
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%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;
|
||||
}
|
||||
}
|
||||
103
Lib/scilab/scisequencedouble.swg
Normal file
103
Lib/scilab/scisequencedouble.swg
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
/*
|
||||
*
|
||||
* Scilab matrix of double <-> C++ double container
|
||||
*
|
||||
*/
|
||||
|
||||
%include <scidouble.swg>
|
||||
|
||||
%fragment(SWIG_AsCheck_Sequence_frag(double), "header",
|
||||
fragment="SWIG_SciDouble_AsDoubleArrayAndSize") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsCheck_Sequence_dec(double)(SciObject _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(999, _("%s: Wrong type for input argument #%d: A double is expected.\n"), SWIG_Scilab_GetFname(), _obj);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsGet_Sequence_frag(double), "header",
|
||||
fragment="SWIG_SciDouble_AsDoubleArrayAndSize") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsGet_Sequence_dec(double)(SciObject _obj, double **_pSequence) {
|
||||
int iMatrixRowCount;
|
||||
int iMatrixColCount;
|
||||
return (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, _obj, &iMatrixRowCount, &iMatrixColCount, _pSequence, SWIG_Scilab_GetFname()));
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsSize_Sequence_frag(double), "header",
|
||||
fragment="SWIG_SciDouble_AsDoubleArrayAndSize") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsSize_Sequence_dec(double)(SciObject _obj, int *_piSize) {
|
||||
double *pdblMatrix;
|
||||
int iMatrixRowCount;
|
||||
int iMatrixColCount;
|
||||
if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, _obj, &iMatrixRowCount, &iMatrixColCount, &pdblMatrix, SWIG_Scilab_GetFname()) == SWIG_OK) {
|
||||
if ((iMatrixRowCount > 1) && (iMatrixColCount > 1)) {
|
||||
Scierror(999, _("%s: Wrong size for input argument #%d: A double vector is expected.\n"), SWIG_Scilab_GetFname(), _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 **_sequence) {
|
||||
*_sequence = new double[_size];
|
||||
return *_sequence != NULL ? SWIG_OK : SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_FromSet_Sequence_frag(double), "header",
|
||||
fragment="SWIG_SciDouble_FromDoubleArrayAndSize") {
|
||||
|
||||
SWIGINTERN SciObject
|
||||
SWIG_FromSet_Sequence_dec(double)(int _size, double *_sequence) {
|
||||
SciObject obj = SWIG_SciDouble_FromDoubleArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, _size, _sequence);
|
||||
delete (double *)_sequence;
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsVal_SequenceItem_frag(double), "header") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsVal_SequenceItem_dec(double)(SciObject _obj, double *_pSequence, int _iItemIndex, double *_pItemValue) {
|
||||
*_pItemValue = _pSequence[_iItemIndex];
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%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;
|
||||
}
|
||||
}
|
||||
|
||||
102
Lib/scilab/scisequenceint.swg
Normal file
102
Lib/scilab/scisequenceint.swg
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
*
|
||||
* Scilab matrix of int <-> C++ int container
|
||||
*
|
||||
*/
|
||||
|
||||
%include <sciint.swg>
|
||||
|
||||
%fragment(SWIG_AsCheck_Sequence_frag(int), "header",
|
||||
fragment="SWIG_SciInt32_AsIntArrayAndSize") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsCheck_Sequence_dec(int)(SciObject _obj) {
|
||||
SciErr sciErr;
|
||||
int *piAddrVar;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, _obj, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (isIntegerType(pvApiCtx, piAddrVar))
|
||||
{
|
||||
return SWIG_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: An integer is expected.\n"), SWIG_Scilab_GetFname(), _obj);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsGet_Sequence_frag(int), "header",
|
||||
fragment="SWIG_SciInt32_AsIntArrayAndSize") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsGet_Sequence_dec(int)(SciObject _obj, int **_pSequence) {
|
||||
int iMatrixRowCount;
|
||||
int iMatrixColCount;
|
||||
return (SWIG_SciInt32_AsIntArrayAndSize(pvApiCtx, _obj, &iMatrixRowCount, &iMatrixColCount, _pSequence, SWIG_Scilab_GetFname()));
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsSize_Sequence_frag(int), "header",
|
||||
fragment="SWIG_SciInt32_AsIntArrayAndSize") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsSize_Sequence_dec(int)(SciObject _obj, int *_piSize) {
|
||||
int *piMatrix;
|
||||
int iMatrixRowCount;
|
||||
int iMatrixColCount;
|
||||
if (SWIG_SciInt32_AsIntArrayAndSize(pvApiCtx, _obj, &iMatrixRowCount, &iMatrixColCount, &piMatrix, SWIG_Scilab_GetFname()) == SWIG_OK) {
|
||||
if ((iMatrixRowCount > 1) && (iMatrixColCount > 1)) {
|
||||
Scierror(999, _("%s: Wrong size for input argument #%d: An integer vector is expected.\n"), SWIG_Scilab_GetFname(), _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 **_sequence) {
|
||||
*_sequence = new int[_size];
|
||||
return *_sequence != NULL ? SWIG_OK : SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_FromSet_Sequence_frag(int), "header",
|
||||
fragment="SWIG_SciInt32_FromIntArrayAndSize") {
|
||||
|
||||
SWIGINTERN SciObject
|
||||
SWIG_FromSet_Sequence_dec(int)(int _size, int *_sequence) {
|
||||
SciObject obj = SWIG_SciInt32_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, _size, _sequence);
|
||||
delete (int *)_sequence;
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsVal_SequenceItem_frag(int), "header") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsVal_SequenceItem_dec(int)(SciObject _obj, int *_pSequence, int _iItemIndex, int *_pItemValue) {
|
||||
*_pItemValue = _pSequence[_iItemIndex];
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%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;
|
||||
}
|
||||
}
|
||||
121
Lib/scilab/scisequencepointer.swg
Normal file
121
Lib/scilab/scisequencepointer.swg
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
/*
|
||||
*
|
||||
* Scilab list of pointer <-> C++ pointer container
|
||||
*
|
||||
*/
|
||||
|
||||
%include <scilist.swg>
|
||||
|
||||
%fragment(SWIG_AsCheck_Sequence_frag(ptr), "header",
|
||||
fragment="SWIG_ScilabList") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsCheck_Sequence_dec(ptr)(SciObject _obj) {
|
||||
return SWIG_CheckScilabList(_obj);
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsGet_Sequence_frag(ptr), "header",
|
||||
fragment="SWIG_ScilabList") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsGet_Sequence_dec(ptr)(SciObject _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)(SciObject _obj, int *_piSize) {
|
||||
return SWIG_GetScilabListSize(_obj, _piSize);
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_FromCreate_Sequence_frag(ptr), "header") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_FromCreate_Sequence_dec(ptr)(int _size, int ***_sequence) {
|
||||
*_sequence = new int*[_size];
|
||||
return *_sequence != NULL ? SWIG_OK : SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_FromSet_Sequence_frag(ptr), "header") {
|
||||
|
||||
SWIGINTERN SciObject
|
||||
SWIG_FromSet_Sequence_dec(ptr)(int _size, int **_sequence) {
|
||||
SciErr sciErr;
|
||||
int *piListAddr;
|
||||
|
||||
int iVarOut = 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 *)_sequence[i]);
|
||||
if (sciErr.iErr)
|
||||
{
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
delete (int*)_sequence;
|
||||
return iVarOut;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsVal_SequenceItem_frag(ptr), "header") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsVal_SequenceItem_dec(ptr)(SciObject _obj, int* _piSequence, int _itemIndex, int **_pItemValue)
|
||||
{
|
||||
SciErr sciErr;
|
||||
int *piItemAddr;
|
||||
int iType;
|
||||
|
||||
sciErr = getListItemAddress(pvApiCtx, _piSequence, _itemIndex + 1, &piItemAddr);
|
||||
if (sciErr.iErr)
|
||||
{
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getVarType(pvApiCtx, piItemAddr, &iType);
|
||||
if (sciErr.iErr)
|
||||
{
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (iType != sci_pointer)
|
||||
{
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: A pointer is expected at list item #%d.\n"), fname, _obj, _itemIndex + 1);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getPointerInList(pvApiCtx, _piSequence, _itemIndex + 1, (void **)_pItemValue);
|
||||
if (sciErr.iErr)
|
||||
{
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_SequenceItem_frag(ptr), "header") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_From_SequenceItem_dec(ptr)(int **_pSequence, int _iItemIndex, int *_itemValue) {
|
||||
_pSequence[_iItemIndex] = _itemValue;
|
||||
}
|
||||
}
|
||||
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",
|
||||
fragment="SwigScilabStringToCharPtrArrayAndSize") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsCheck_Sequence_dec(std::string)(SciObject _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(999, _("%s: Wrong type for input argument #%d: A string is expected.\n"), SWIG_Scilab_GetFname(), _obj);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsGet_Sequence_frag(std::string), "header",
|
||||
fragment="SwigScilabStringToCharPtrArrayAndSize") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsGet_Sequence_dec(std::string)(SciObject _obj, char ***_pSequence) {
|
||||
int iSize;
|
||||
return (SwigScilabStringToCharPtrArrayAndSize(pvApiCtx, _obj, _pSequence, &iSize, SWIG_Scilab_GetFname()));
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsSize_Sequence_frag(std::string), "header",
|
||||
fragment="SwigScilabStringToCharPtrArrayAndSize") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsSize_Sequence_dec(std::string)(SciObject _obj, int *_piSize) {
|
||||
char **pstMatrix;
|
||||
if (SwigScilabStringToCharPtrArrayAndSize(pvApiCtx, _obj, &pstMatrix, _piSize, SWIG_Scilab_GetFname()) == SWIG_OK) {
|
||||
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 ***_sequence) {
|
||||
*_sequence = new char*[_size];
|
||||
return *_sequence != NULL ? SWIG_OK : SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_FromSet_Sequence_frag(std::string), "header",
|
||||
fragment="SwigScilabStringFromCharPtrArray") {
|
||||
|
||||
SWIGINTERN SciObject
|
||||
SWIG_FromSet_Sequence_dec(std::string)(int _size, char **_sequence) {
|
||||
SciObject obj = SwigScilabStringFromCharPtrArray(pvApiCtx, SWIG_Scilab_GetOutputPosition(), _sequence, _size);
|
||||
delete (char **)_sequence;
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsVal_SequenceItem_frag(std::string), "header") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsVal_SequenceItem_dec(std::string)(SciObject _obj, char **_pSequence, int _iItemIndex, std::string *_pItemValue) {
|
||||
*_pItemValue = std::string(_pSequence[_iItemIndex]);
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
#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) SwigScilabRaise(obj, type, desc)
|
||||
#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
|
||||
|
|
|
|||
|
|
@ -1,94 +0,0 @@
|
|||
/*
|
||||
* C++ type: std::vector<double>
|
||||
* Scilab 5 type: double matrix
|
||||
*/
|
||||
|
||||
%include <scidouble.swg>
|
||||
|
||||
%typemap(in, fragment="SWIG_SciDouble_AsDoubleArrayAndSize") std::vector<double>(std::vector<double> temp)
|
||||
{
|
||||
double* dmatrix;
|
||||
int nbRows;
|
||||
int nbCols;
|
||||
if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &nbRows, &nbCols, &dmatrix, fname) != SWIG_ERROR)
|
||||
{
|
||||
if ((nbRows > 1) && (nbCols > 1))
|
||||
{
|
||||
Scierror(999, _("%s: Wrong size for input argument #%d: A real vector expected.\n"), fname, $input);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
$1 = temp;
|
||||
$1.reserve(nbRows * nbCols);
|
||||
std::copy(dmatrix, dmatrix + nbRows * nbCols, std::back_inserter((std::vector<double>&)$1));
|
||||
}
|
||||
else
|
||||
{
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(in, fragment="SWIG_SciDouble_AsDoubleArrayAndSize") std::vector<double>&(std::vector<double> temp)
|
||||
{
|
||||
double* dmatrix;
|
||||
int nbRows;
|
||||
int nbCols;
|
||||
if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &nbRows, &nbCols, &dmatrix, fname) != SWIG_ERROR)
|
||||
{
|
||||
if ((nbRows > 1) && (nbCols > 1))
|
||||
{
|
||||
Scierror(999, _("%s: Wrong size for input argument #%d: A real vector expected.\n"), fname, $input);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
$1 = &temp;
|
||||
$1->reserve(nbRows * nbCols);
|
||||
std::copy(dmatrix, dmatrix + nbRows * nbCols, std::back_inserter(*$1));
|
||||
}
|
||||
else
|
||||
{
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(out, fragment="SWIG_SciDouble_FromDoubleArrayAndSize") std::vector<double>
|
||||
{
|
||||
int nbCols = $1.size();
|
||||
double* dmatrix = new double[nbCols];
|
||||
std::copy($1.begin(), $1.end(), dmatrix);
|
||||
|
||||
int ret = SWIG_SciDouble_FromDoubleArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, nbCols, dmatrix);
|
||||
delete[] dmatrix;
|
||||
|
||||
if (ret != SWIG_ERROR)
|
||||
{
|
||||
AssignOutputVariable(pvApiCtx, outputPosition) = nbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition();
|
||||
}
|
||||
else
|
||||
{
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(argout, fragment="SWIG_SciDouble_FromDoubleArrayAndSize") std::vector<double>&
|
||||
{
|
||||
int nbCols = $1->size();
|
||||
double* dmatrix = new double[nbCols];
|
||||
std::copy($1->begin(), $1->end(), dmatrix);
|
||||
|
||||
int ret = SWIG_SciDouble_FromDoubleArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, nbCols, dmatrix);
|
||||
delete[] dmatrix;
|
||||
|
||||
if (ret != SWIG_ERROR)
|
||||
{
|
||||
AssignOutputVariable(pvApiCtx, outputPosition) = nbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition();
|
||||
}
|
||||
else
|
||||
{
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,91 +0,0 @@
|
|||
/*
|
||||
* C++ type: std::vector<int>
|
||||
* Scilab 5 type: integer matrix
|
||||
*/
|
||||
|
||||
%include <sciint.swg>
|
||||
|
||||
%typemap(in, fragment="SWIG_SciInt32_AsIntArrayAndSize") std::vector<int>(std::vector<int> temp)
|
||||
{
|
||||
int* imatrix;
|
||||
int nbRows;
|
||||
int nbCols;
|
||||
if (SWIG_SciInt32_AsIntArrayAndSize(pvApiCtx, $input, &nbRows, &nbCols, &imatrix, fname) != SWIG_ERROR)
|
||||
{
|
||||
if ((nbRows > 1) && (nbCols > 1))
|
||||
{
|
||||
Scierror(999, _("%s: Wrong size for input argument #%d: An integer vector expected.\n"), fname, $input);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
$1 = temp;
|
||||
$1.reserve(nbRows * nbCols);
|
||||
std::copy(imatrix, imatrix + nbRows * nbCols, std::back_inserter((std::vector<int>&)$1));
|
||||
}
|
||||
else
|
||||
{
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(in, fragment="SWIG_SciInt32_AsIntArrayAndSize") std::vector<int>&(std::vector<int> temp)
|
||||
{
|
||||
int* imatrix;
|
||||
int nbRows;
|
||||
int nbCols;
|
||||
if (SWIG_SciInt32_AsIntArrayAndSize(pvApiCtx, $input, &nbRows, &nbCols, &imatrix, fname) != SWIG_ERROR)
|
||||
{
|
||||
if ((nbRows > 1) && (nbCols > 1))
|
||||
{
|
||||
Scierror(999, _("%s: Wrong size for input argument #%d: An integer vector expected.\n"), fname, $input);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
$1 = &temp;
|
||||
$1->reserve(nbRows * nbCols);
|
||||
std::copy(imatrix, imatrix + nbRows * nbCols, std::back_inserter(*$1));
|
||||
}
|
||||
else
|
||||
{
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(out, fragment="SWIG_SciInt32_FromIntArrayAndSize") std::vector<int>
|
||||
{
|
||||
int nbCols = $1.size();
|
||||
int* imatrix = new int[nbCols];
|
||||
std::copy($1.begin(), $1.end(), imatrix);
|
||||
|
||||
int ret = SWIG_SciInt32_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, nbCols, imatrix);
|
||||
delete[] imatrix;
|
||||
|
||||
if (ret != SWIG_ERROR)
|
||||
{
|
||||
AssignOutputVariable(pvApiCtx, outputPosition) = nbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition();
|
||||
}
|
||||
else
|
||||
{
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(argout, fragment="SWIG_SciInt32_FromIntArrayAndSize") std::vector<int>&
|
||||
{
|
||||
int nbCols = $1->size();
|
||||
int* imatrix = new int[nbCols];
|
||||
std::copy($1->begin(), $1->end(), imatrix);
|
||||
|
||||
int ret = SWIG_SciInt32_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, nbCols, imatrix);
|
||||
delete[] imatrix;
|
||||
|
||||
if (ret != SWIG_ERROR)
|
||||
{
|
||||
AssignOutputVariable(pvApiCtx, outputPosition) = nbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition();
|
||||
}
|
||||
else
|
||||
{
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,94 +0,0 @@
|
|||
/*
|
||||
* C++ type: std::vector<string>
|
||||
* Scilab 5 type: double matrix
|
||||
*/
|
||||
|
||||
%include <scidouble.swg>
|
||||
|
||||
%typemap(in, fragment="SWIG_SciDouble_AsDoubleArrayAndSize") std::vector<string>(std::vector<string> temp)
|
||||
{
|
||||
double* dmatrix;
|
||||
int nbRows;
|
||||
int nbCols;
|
||||
if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &nbRows, &nbCols, &dmatrix, fname) != SWIG_ERROR)
|
||||
{
|
||||
if ((nbRows > 1) && (nbCols > 1))
|
||||
{
|
||||
Scierror(999, _("%s: Wrong size for input argument #%d: A real vector expected.\n"), fname, $input);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
$1 = temp;
|
||||
$1.reserve(nbRows * nbCols);
|
||||
std::copy(dmatrix, dmatrix + nbRows * nbCols, std::back_inserter((std::vector<string>&)$1));
|
||||
}
|
||||
else
|
||||
{
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(in, fragment="SWIG_SciDouble_AsDoubleArrayAndSize") std::vector<string>&(std::vector<string> temp)
|
||||
{
|
||||
double* dmatrix;
|
||||
int nbRows;
|
||||
int nbCols;
|
||||
if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &nbRows, &nbCols, &dmatrix, fname) != SWIG_ERROR)
|
||||
{
|
||||
if ((nbRows > 1) && (nbCols > 1))
|
||||
{
|
||||
Scierror(999, _("%s: Wrong size for input argument #%d: A real vector expected.\n"), fname, $input);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
$1 = &temp;
|
||||
$1->reserve(nbRows * nbCols);
|
||||
std::copy(dmatrix, dmatrix + nbRows * nbCols, std::back_inserter(*$1));
|
||||
}
|
||||
else
|
||||
{
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(out, fragment="SWIG_SciDouble_FromDoubleArrayAndSize") std::vector<string>
|
||||
{
|
||||
int nbCols = $1.size();
|
||||
double* dmatrix = new double[nbCols];
|
||||
std::copy($1.begin(), $1.end(), dmatrix);
|
||||
|
||||
int ret = SWIG_SciDouble_FromDoubleArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, nbCols, dmatrix);
|
||||
delete[] dmatrix;
|
||||
|
||||
if (ret != SWIG_ERROR)
|
||||
{
|
||||
AssignOutputVariable(pvApiCtx, outputPosition) = nbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition();
|
||||
}
|
||||
else
|
||||
{
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(argout, fragment="SWIG_SciDouble_FromDoubleArrayAndSize") std::vector<string>&
|
||||
{
|
||||
int nbCols = $1->size();
|
||||
double* dmatrix = new double[nbCols];
|
||||
std::copy($1->begin(), $1->end(), dmatrix);
|
||||
|
||||
int ret = SWIG_SciDouble_FromDoubleArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, nbCols, dmatrix);
|
||||
delete[] dmatrix;
|
||||
|
||||
if (ret != SWIG_ERROR)
|
||||
{
|
||||
AssignOutputVariable(pvApiCtx, outputPosition) = nbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition();
|
||||
}
|
||||
else
|
||||
{
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
27
Lib/scilab/std_list.i
Normal file
27
Lib/scilab/std_list.i
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
Lists
|
||||
*/
|
||||
|
||||
%fragment("StdListTraits", "header", fragment="StdSequenceTraits")
|
||||
%{
|
||||
namespace swig {
|
||||
template <class T >
|
||||
struct traits_asptr<std::list<T> > {
|
||||
static int asptr(SciObject 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 SciObject 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>
|
||||
|
|
@ -1,84 +1,32 @@
|
|||
/*
|
||||
* C++ type: std::set<int>
|
||||
* Scilab 5 type: integer matrix
|
||||
*/
|
||||
*
|
||||
* C++ type : STL set
|
||||
* Scilab type : matrix (for sets of primitive types) or list (for sets of all other types : pointers...)
|
||||
*
|
||||
*/
|
||||
|
||||
%include <sciint.swg>
|
||||
%fragment("StdSetTraits", "header", fragment="StdSequenceTraits")
|
||||
%{
|
||||
namespace swig {
|
||||
template <class T>
|
||||
struct traits_asptr<std::set<T> > {
|
||||
static int asptr(const SciObject &obj, std::set<T> **set) {
|
||||
return traits_asptr_stdseq<std::set<T> >::asptr(obj, set);
|
||||
}
|
||||
};
|
||||
|
||||
%typemap(in, fragment="SWIG_SciInt32_AsIntArrayAndSize") std::set<int>(std::set<int> temp)
|
||||
{
|
||||
int* imatrix;
|
||||
int nbRows;
|
||||
int nbCols;
|
||||
if (SWIG_SciInt32_AsIntArrayAndSize(pvApiCtx, $input, &nbRows, &nbCols, &imatrix, fname) != SWIG_ERROR)
|
||||
{
|
||||
if ((nbRows > 1) && (nbCols > 1))
|
||||
{
|
||||
Scierror(999, _("%s: Wrong size for input argument #%d: An integer vector expected.\n"), fname, $input);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
$1 = temp;
|
||||
std::set<int>& tmpset = (std::set<int>&)$1;
|
||||
std::copy(imatrix, imatrix + nbRows * nbCols, std::inserter(tmpset, tmpset.begin()));
|
||||
template <class T>
|
||||
struct traits_from<std::set<T> > {
|
||||
static SciObject from(const std::set<T>& set) {
|
||||
return traits_from_stdseq<std::set<T> >::from(set);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(in, fragment="SWIG_SciInt32_AsIntArrayAndSize") std::set<int>& (std::set<int> temp)
|
||||
{
|
||||
int* imatrix;
|
||||
int nbRows;
|
||||
int nbCols;
|
||||
if (SWIG_SciInt32_AsIntArrayAndSize(pvApiCtx, $input, &nbRows, &nbCols, &imatrix, fname) != SWIG_ERROR)
|
||||
{
|
||||
if ((nbRows > 1) && (nbCols > 1))
|
||||
{
|
||||
Scierror(999, _("%s: Wrong size for input argument #%d: An integer vector expected.\n"), fname, $input);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
$1 = &temp;
|
||||
std::set<int>& tmpset = *$1;
|
||||
std::copy(imatrix, imatrix + nbRows * nbCols, std::inserter(tmpset, tmpset.begin()));
|
||||
}
|
||||
}
|
||||
%}
|
||||
|
||||
|
||||
%typemap(out, fragment="SWIG_SciInt32_FromIntArrayAndSize") std::set<int>
|
||||
{
|
||||
int nbCols = $1.size();
|
||||
int* imatrix = new int[nbCols];
|
||||
std::copy($1.begin(), $1.end(), imatrix);
|
||||
#define %swig_set_methods(Type...) %swig_sequence_methods(Type)
|
||||
#define %swig_set_methods_val(Type...) %swig_sequence_methods_val(Type);
|
||||
|
||||
int ret = SWIG_SciInt32_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, nbCols, imatrix);
|
||||
delete[] imatrix;
|
||||
|
||||
if (ret != SWIG_ERROR)
|
||||
{
|
||||
AssignOutputVariable(pvApiCtx, outputPosition) = nbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition();
|
||||
}
|
||||
else
|
||||
{
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(argout) std::set<int>&
|
||||
{
|
||||
int nbCols = $1->size();
|
||||
int* imatrix = new int[nbCols];
|
||||
std::copy($1->begin(), $1->end(), imatrix);
|
||||
|
||||
int ret = SWIG_SciInt32_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, nbCols, imatrix);
|
||||
delete[] imatrix;
|
||||
|
||||
if (ret != SWIG_ERROR)
|
||||
{
|
||||
AssignOutputVariable(pvApiCtx, outputPosition) = nbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition();
|
||||
}
|
||||
else
|
||||
{
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
%include <std/std_set.i>
|
||||
|
||||
|
|
|
|||
|
|
@ -29,10 +29,10 @@ SWIG_AsPtr_dec(std::string)(int _iVar, std::string **_pstValue) {
|
|||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_frag(std::string), "header", fragment="SwigScilabStringFromCharPtrAndSize") {
|
||||
%fragment(SWIG_From_frag(std::string), "header", fragment="SwigScilabStringFromCharPtr") {
|
||||
SWIGINTERN int
|
||||
SWIG_From_dec(std::string)(std::string _pstValue) {
|
||||
return SwigScilabStringFromCharPtrAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), _pstValue.c_str());
|
||||
return SwigScilabStringFromCharPtr(pvApiCtx, SWIG_Scilab_GetOutputPosition(), _pstValue.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
/*
|
||||
Vectors
|
||||
*
|
||||
* C++ type : STL vector
|
||||
* Scilab type : matrix (for vectors of primitive types) or list (for sets of all other types : pointers...)
|
||||
*
|
||||
*/
|
||||
|
||||
%fragment("StdVectorTraits","header",fragment="StdSequenceTraits")
|
||||
%{
|
||||
namespace swig {
|
||||
|
|
@ -14,7 +18,7 @@
|
|||
template <class T>
|
||||
struct traits_from<std::vector<T> > {
|
||||
static SciObject from(const std::vector<T>& vec) {
|
||||
return traits_from_stdseq<std::vector<T> >::from(vec);
|
||||
return traits_from_stdseq<std::vector<T> >::from(vec);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -24,9 +28,5 @@
|
|||
#define %swig_vector_methods(Type...) %swig_sequence_methods(Type)
|
||||
#define %swig_vector_methods_val(Type...) %swig_sequence_methods_val(Type);
|
||||
|
||||
|
||||
%include <scivectordouble.swg>
|
||||
%include <scivectorint.swg>
|
||||
|
||||
%include <std/std_vector.i>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
/* initial STL definition. extended as needed in each language */
|
||||
%include std_common.i
|
||||
%include std_vector.i
|
||||
%include std_string.i
|
||||
|
||||
|
||||
|
||||
|
||||
%include std_vector.i
|
||||
%include std_set.i
|
||||
%include std_list.i
|
||||
|
|
|
|||
|
|
@ -17,10 +17,12 @@
|
|||
/*#define SWIG_DEBUG*/
|
||||
|
||||
static const char *usage = (char*) "\
|
||||
Scilab Options (available with -scilab)\n\
|
||||
-addsrc - Additionnal source file for builder.sce file (Ex: myfile.cxx)\n\
|
||||
-addcflag - Additionnal path to includes for builder.sce file (Ex: -I/usr/includes/)\n\
|
||||
-addldlag - Additionnal library flag for builder.sce file (Ex: -lm)\n\n";
|
||||
Scilab options\n\
|
||||
-addsrc <source files> additionnal source files (separated by comma) to include in build script (ex: myfile.cxx myfile2.cxx)\n\
|
||||
-addcflag -I<path> additionnal include path to include in build script (ex: -I/usr/includes/)\n\
|
||||
-addldlag <flag> additionnal link flag to include in build script (ex: -lm)\n\n";
|
||||
|
||||
const char* SWIG_INIT_FUNCTION_NAME = "SWIG_Init";
|
||||
|
||||
class SCILAB : public Language {
|
||||
protected:
|
||||
|
|
@ -174,6 +176,11 @@ public:
|
|||
|
||||
Printf(builderCode, "table = [");
|
||||
|
||||
/* In C++ mode, add initialization function to builder table */
|
||||
if (CPlusPlus) {
|
||||
Printf(builderCode, "\"%s\",\"%s\";", SWIG_INIT_FUNCTION_NAME, SWIG_INIT_FUNCTION_NAME);
|
||||
}
|
||||
|
||||
/* Emit code for children */
|
||||
if (CPlusPlus) {
|
||||
Printf(wrappersSection, "extern \"C\" {\n");
|
||||
|
|
@ -201,8 +208,8 @@ public:
|
|||
Close(builderFile);
|
||||
Delete(builderFile);
|
||||
|
||||
/* Close the init function and quit (opened in sciruntime.swg) */
|
||||
Printf(initSection, "return 0;\n}\n");
|
||||
/* Close the init function (opened in sciinit.swg) */
|
||||
Printf(initSection, "return 0;\n}\n#endif\n");
|
||||
|
||||
/* Write all to the wrapper file */
|
||||
SwigType_emit_type_table(runtimeSection, wrappersSection); // Declare pointer types, ... (Ex: SWIGTYPE_p_p_double)
|
||||
|
|
@ -219,6 +226,8 @@ public:
|
|||
Close(beginSection);
|
||||
Delete(beginSection);
|
||||
|
||||
Delete(sourceFileList);
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -350,7 +359,7 @@ public:
|
|||
maxOutputArguments++;
|
||||
}
|
||||
|
||||
Delete(functionReturnTypemap);
|
||||
//Delete(functionReturnTypemap); // Makes SWIG crash on vararg test case.
|
||||
|
||||
} else {
|
||||
Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(functionReturnType, 0), functionName);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue