update swig on windows
This commit is contained in:
17
winx64/bin/swigwin-4.0.0/Examples/scilab/std_list/Makefile
Normal file
17
winx64/bin/swigwin-4.0.0/Examples/scilab/std_list/Makefile
Normal file
@@ -0,0 +1,17 @@
|
||||
TOP = ../..
|
||||
SWIGEXE = $(TOP)/../swig
|
||||
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||
CXXSRCS = example.cxx
|
||||
TARGET = example
|
||||
INTERFACE = example.i
|
||||
|
||||
check: build
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run
|
||||
|
||||
build:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
|
||||
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab_cpp
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_clean
|
||||
@@ -0,0 +1,61 @@
|
||||
/* File : example.cpp */
|
||||
|
||||
#include "example.h"
|
||||
|
||||
#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
winx64/bin/swigwin-4.0.0/Examples/scilab/std_list/example.h
Normal file
14
winx64/bin/swigwin-4.0.0/Examples/scilab/std_list/example.h
Normal file
@@ -0,0 +1,14 @@
|
||||
/* File : example.h */
|
||||
|
||||
#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);
|
||||
19
winx64/bin/swigwin-4.0.0/Examples/scilab/std_list/example.i
Normal file
19
winx64/bin/swigwin-4.0.0/Examples/scilab/std_list/example.i
Normal file
@@ -0,0 +1,19 @@
|
||||
/* File : example.i */
|
||||
|
||||
%module example
|
||||
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
||||
%include stl.i
|
||||
%include std_list.i
|
||||
|
||||
/* instantiate the required template specializations */
|
||||
namespace std
|
||||
{
|
||||
%template(IntList) list<int>;
|
||||
%template(StringList) list<std::string>;
|
||||
}
|
||||
|
||||
%include "example.h"
|
||||
39
winx64/bin/swigwin-4.0.0/Examples/scilab/std_list/runme.sci
Normal file
39
winx64/bin/swigwin-4.0.0/Examples/scilab/std_list/runme.sci
Normal file
@@ -0,0 +1,39 @@
|
||||
lines(0);
|
||||
ilib_verbose(0);
|
||||
ierr = exec('loader.sce', 'errcatch');
|
||||
if ierr <> 0 then
|
||||
disp(lasterror());
|
||||
exit(ierr);
|
||||
end
|
||||
example_Init();
|
||||
|
||||
// This example shows how to use C++ functions 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);
|
||||
|
||||
exit
|
||||
|
||||
Reference in New Issue
Block a user