Start vector management

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@12945 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Vincent Couvert 2012-03-22 11:10:34 +00:00
commit eb64659740
27 changed files with 3908 additions and 267 deletions

View file

@ -0,0 +1,16 @@
TOP = ../..
SWIG = $(TOP)/../preinst-swig
SRCS = example.cpp
TARGET = example
INTERFACE = example.i
all::
$(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.cpp
check: all
$(MAKE) -f $(TOP)/Makefile scilab_run

View file

@ -0,0 +1,16 @@
mode(-1);
lines(0);
ilib_verbose(0);
ilib_name = "examplelib";
files = "example_wrap.cxx";
files($+1) = "example.cpp";
libs = [];
ldflags = "";
cflags = ["-g -I" + get_absolute_file_path("builder.sce")];
table = ["nlopt_doublevector_empty","_wrap_nlopt_doublevector_empty";"nlopt_doublevector_size","_wrap_nlopt_doublevector_size";"nlopt_doublevector_clear","_wrap_nlopt_doublevector_clear";"nlopt_doublevector_swap","_wrap_nlopt_doublevector_swap";"nlopt_doublevector_get_allocator","_wrap_nlopt_doublevector_get_allocator";"nlopt_doublevector_pop_back","_wrap_nlopt_doublevector_pop_back";"new_nlopt_doublevector","_wrap_new_nlopt_doublevector";"nlopt_doublevector_push_back","_wrap_nlopt_doublevector_push_back";"nlopt_doublevector_front","_wrap_nlopt_doublevector_front";];
table = [table;"nlopt_doublevector_back","_wrap_nlopt_doublevector_back";"nlopt_doublevector_assign","_wrap_nlopt_doublevector_assign";"nlopt_doublevector_resize","_wrap_nlopt_doublevector_resize";"nlopt_doublevector_reserve","_wrap_nlopt_doublevector_reserve";"nlopt_doublevector_capacity","_wrap_nlopt_doublevector_capacity";"delete_nlopt_doublevector","_wrap_delete_nlopt_doublevector";"opt_set_lower_bound","_wrap_opt_set_lower_bound";"new_opt","_wrap_new_opt";"delete_opt","_wrap_delete_opt";];
if ~isempty(table) then
ilib_build(ilib_name, table, files, libs, [], ldflags, cflags);
end
exit

View file

@ -0,0 +1,22 @@
// This file is released under the 3-clause BSD license. See COPYING-BSD.
// Generated by builder.sce : Please, do not edit this file
// cleaner.sce
// ------------------------------------------------------
curdir = pwd();
cleaner_path = get_file_path('cleaner.sce');
chdir(cleaner_path);
// ------------------------------------------------------
if fileinfo('loader.sce') <> [] then
mdelete('loader.sce');
end
// ------------------------------------------------------
if fileinfo('libexamplelib.so') <> [] then
mdelete('libexamplelib.so');
end
// ------------------------------------------------------
if fileinfo('libexamplelib.c') <> [] then
mdelete('libexamplelib.c');
end
// ------------------------------------------------------
chdir(curdir);
// ------------------------------------------------------

View file

@ -0,0 +1,19 @@
/* File : example.cpp */
#include <iostream>
#include <vector>
class opt {
public:
void set_lower_bound(const std::vector<double> &v) {
double sum = 0;
std::cout << "coucou" << std::endl;
for (int i = 0; i < v.size(); i++) {
sum += v[i];
std::cout << v[i] << std::endl;
}
//return sum;
}
};

View file

@ -0,0 +1,18 @@
/* File : example.cpp */
#include <vector>
namespace nlopt {
class opt {
public:
void set_lower_bound(const std::vector<double> &v) {
double sum = 0;
for (int i = 0; i < v.size(); i++) {
sum += v[i];
}
//return sum;
}
};
}

View file

@ -0,0 +1,13 @@
/* File : example.i */
%module example
%{
#include "example.hxx"
%}
%include "std_vector.i"
namespace std {
%template(nlopt_doublevector) vector<double>;
};
%include "example.hxx";

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,58 @@
#include <mex.h>
#include <sci_gateway.h>
#include <api_scilab.h>
#include <MALLOC.h>
static int direct_gateway(char *fname,void F(void)) { F();return 0;};
extern Gatefunc _wrap_nlopt_doublevector_empty;
extern Gatefunc _wrap_nlopt_doublevector_size;
extern Gatefunc _wrap_nlopt_doublevector_clear;
extern Gatefunc _wrap_nlopt_doublevector_swap;
extern Gatefunc _wrap_nlopt_doublevector_get_allocator;
extern Gatefunc _wrap_nlopt_doublevector_pop_back;
extern Gatefunc _wrap_new_nlopt_doublevector;
extern Gatefunc _wrap_nlopt_doublevector_push_back;
extern Gatefunc _wrap_nlopt_doublevector_front;
extern Gatefunc _wrap_nlopt_doublevector_back;
extern Gatefunc _wrap_nlopt_doublevector_assign;
extern Gatefunc _wrap_nlopt_doublevector_resize;
extern Gatefunc _wrap_nlopt_doublevector_reserve;
extern Gatefunc _wrap_nlopt_doublevector_capacity;
extern Gatefunc _wrap_delete_nlopt_doublevector;
extern Gatefunc _wrap_opt_set_lower_bound;
extern Gatefunc _wrap_new_opt;
extern Gatefunc _wrap_delete_opt;
static GenericTable Tab[]={
{(Myinterfun)sci_gateway,_wrap_nlopt_doublevector_empty,"nlopt_doublevector_empty"},
{(Myinterfun)sci_gateway,_wrap_nlopt_doublevector_size,"nlopt_doublevector_size"},
{(Myinterfun)sci_gateway,_wrap_nlopt_doublevector_clear,"nlopt_doublevector_clear"},
{(Myinterfun)sci_gateway,_wrap_nlopt_doublevector_swap,"nlopt_doublevector_swap"},
{(Myinterfun)sci_gateway,_wrap_nlopt_doublevector_get_allocator,"nlopt_doublevector_get_allocator"},
{(Myinterfun)sci_gateway,_wrap_nlopt_doublevector_pop_back,"nlopt_doublevector_pop_back"},
{(Myinterfun)sci_gateway,_wrap_new_nlopt_doublevector,"new_nlopt_doublevector"},
{(Myinterfun)sci_gateway,_wrap_nlopt_doublevector_push_back,"nlopt_doublevector_push_back"},
{(Myinterfun)sci_gateway,_wrap_nlopt_doublevector_front,"nlopt_doublevector_front"},
{(Myinterfun)sci_gateway,_wrap_nlopt_doublevector_back,"nlopt_doublevector_back"},
{(Myinterfun)sci_gateway,_wrap_nlopt_doublevector_assign,"nlopt_doublevector_assign"},
{(Myinterfun)sci_gateway,_wrap_nlopt_doublevector_resize,"nlopt_doublevector_resize"},
{(Myinterfun)sci_gateway,_wrap_nlopt_doublevector_reserve,"nlopt_doublevector_reserve"},
{(Myinterfun)sci_gateway,_wrap_nlopt_doublevector_capacity,"nlopt_doublevector_capacity"},
{(Myinterfun)sci_gateway,_wrap_delete_nlopt_doublevector,"delete_nlopt_doublevector"},
{(Myinterfun)sci_gateway,_wrap_opt_set_lower_bound,"opt_set_lower_bound"},
{(Myinterfun)sci_gateway,_wrap_new_opt,"new_opt"},
{(Myinterfun)sci_gateway,_wrap_delete_opt,"delete_opt"},
};
int C2F(libexamplelib)()
{
Rhs = Max(0, Rhs);
if (*(Tab[Fin-1].f) != NULL)
{
if(pvApiCtx == NULL)
{
pvApiCtx = (StrCtx*)MALLOC(sizeof(StrCtx));
}
pvApiCtx->pstName = (char*)Tab[Fin-1].name;
(*(Tab[Fin-1].f))(Tab[Fin-1].name,Tab[Fin-1].F);
}
return 0;
}

View file

@ -0,0 +1,38 @@
// This file is released under the 3-clause BSD license. See COPYING-BSD.
// Generated by builder.sce : Please, do not edit this file
// ----------------------------------------------------------------------------
//
libexamplelib_path = get_absolute_file_path('loader.sce');
//
// ulink previous function with same name
[bOK, ilib] = c_link('libexamplelib');
if bOK then
ulink(ilib);
end
//
list_functions = [ 'nlopt_doublevector_empty';
'nlopt_doublevector_size';
'nlopt_doublevector_clear';
'nlopt_doublevector_swap';
'nlopt_doublevector_get_allocator';
'nlopt_doublevector_pop_back';
'new_nlopt_doublevector';
'nlopt_doublevector_push_back';
'nlopt_doublevector_front';
'nlopt_doublevector_back';
'nlopt_doublevector_assign';
'nlopt_doublevector_resize';
'nlopt_doublevector_reserve';
'nlopt_doublevector_capacity';
'delete_nlopt_doublevector';
'opt_set_lower_bound';
'new_opt';
'delete_opt';
];
addinter(libexamplelib_path + filesep() + 'libexamplelib' + getdynlibext(), 'libexamplelib', list_functions);
// remove temp. variables on stack
clear libexamplelib_path;
clear bOK;
clear ilib;
clear list_functions;
// ----------------------------------------------------------------------------

View file

@ -73,7 +73,7 @@ public:
%include "std_vector.i"
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGR) || defined(SWIGOCTAVE) || defined(SWIGRUBY)
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGR) || defined(SWIGOCTAVE) || defined(SWIGSCILAB) || defined(SWIGRUBY)
#define SWIG_GOOD_VECTOR
%ignore std::vector<Space::Flow>::vector(size_type);
%ignore std::vector<Space::Flow>::resize(size_type);