Merge branch 'master' into gsoc2009-matevz
parser.y still to be fixed up Conflicts: Doc/Devel/engineering.html Examples/Makefile.in Lib/allegrocl/allegrocl.swg Lib/csharp/csharp.swg Lib/csharp/enums.swg Lib/csharp/enumsimple.swg Lib/csharp/enumtypesafe.swg Lib/java/java.swg Lib/python/pydocs.swg Lib/r/rtype.swg Source/Include/swigwarn.h Source/Modules/octave.cxx Source/Modules/python.cxx Source/Modules/ruby.cxx Source/Swig/scanner.c Source/Swig/stype.c Source/Swig/swig.h configure.ac
This commit is contained in:
commit
e805d5f925
1074 changed files with 54339 additions and 20134 deletions
307
Lib/r/boost_shared_ptr.i
Normal file
307
Lib/r/boost_shared_ptr.i
Normal file
|
|
@ -0,0 +1,307 @@
|
|||
%include <shared_ptr.i>
|
||||
|
||||
// Language specific macro implementing all the customisations for handling the smart pointer
|
||||
%define SWIG_SHARED_PTR_TYPEMAPS(CONST, TYPE...)
|
||||
|
||||
// %naturalvar is as documented for member variables
|
||||
%naturalvar TYPE;
|
||||
%naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
|
||||
|
||||
// destructor wrapper customisation
|
||||
%feature("unref") TYPE
|
||||
//"if (debug_shared) { cout << \"deleting use_count: \" << (*smartarg1).use_count() << \" [\" << (boost::get_deleter<SWIG_null_deleter>(*smartarg1) ? std::string(\"CANNOT BE DETERMINED SAFELY\") : ( (*smartarg1).get() ? (*smartarg1)->getValue() : std::string(\"NULL PTR\") )) << \"]\" << endl << flush; }\n"
|
||||
"(void)arg1; delete smartarg1;"
|
||||
|
||||
// Typemap customisations...
|
||||
|
||||
// plain value
|
||||
%typemap(in) CONST TYPE (void *argp, int res = 0) {
|
||||
int newmem = 0;
|
||||
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
%argument_fail(res, "$type", $symname, $argnum);
|
||||
}
|
||||
if (!argp) {
|
||||
%argument_nullref("$type", $symname, $argnum);
|
||||
} else {
|
||||
$1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get());
|
||||
if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
}
|
||||
}
|
||||
%typemap(out) CONST TYPE {
|
||||
%set_output(SWIG_NewPointerObj(new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
%typemap(varin) CONST TYPE {
|
||||
void *argp = 0;
|
||||
int newmem = 0;
|
||||
int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
%variable_fail(res, "$type", "$name");
|
||||
}
|
||||
if (!argp) {
|
||||
%argument_nullref("$type", $symname, $argnum);
|
||||
} else {
|
||||
$1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get());
|
||||
if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
}
|
||||
}
|
||||
%typemap(varout) CONST TYPE {
|
||||
%set_varoutput(SWIG_NewPointerObj(new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
// plain pointer
|
||||
// Note: $disown not implemented as it will lead to a memory leak of the shared_ptr instance
|
||||
%typemap(in) CONST TYPE * (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) {
|
||||
int newmem = 0;
|
||||
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
%argument_fail(res, "$type", $symname, $argnum);
|
||||
}
|
||||
if (newmem & SWIG_CAST_NEW_MEMORY) {
|
||||
tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
$1 = %const_cast(tempshared.get(), $1_ltype);
|
||||
} else {
|
||||
smartarg = %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
$1 = %const_cast((smartarg ? smartarg->get() : 0), $1_ltype);
|
||||
}
|
||||
}
|
||||
%typemap(out, fragment="SWIG_null_deleter") CONST TYPE * {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0;
|
||||
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), $owner | SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
%typemap(varin) CONST TYPE * {
|
||||
void *argp = 0;
|
||||
int newmem = 0;
|
||||
int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
%variable_fail(res, "$type", "$name");
|
||||
}
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared;
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0;
|
||||
if (newmem & SWIG_CAST_NEW_MEMORY) {
|
||||
tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
$1 = %const_cast(tempshared.get(), $1_ltype);
|
||||
} else {
|
||||
smartarg = %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
$1 = %const_cast((smartarg ? smartarg->get() : 0), $1_ltype);
|
||||
}
|
||||
}
|
||||
%typemap(varout, fragment="SWIG_null_deleter") CONST TYPE * {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0;
|
||||
%set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
// plain reference
|
||||
%typemap(in) CONST TYPE & (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) {
|
||||
int newmem = 0;
|
||||
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
%argument_fail(res, "$type", $symname, $argnum);
|
||||
}
|
||||
if (!argp) { %argument_nullref("$type", $symname, $argnum); }
|
||||
if (newmem & SWIG_CAST_NEW_MEMORY) {
|
||||
tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
$1 = %const_cast(tempshared.get(), $1_ltype);
|
||||
} else {
|
||||
$1 = %const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $1_ltype);
|
||||
}
|
||||
}
|
||||
%typemap(out, fragment="SWIG_null_deleter") CONST TYPE & {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner);
|
||||
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
%typemap(varin) CONST TYPE & {
|
||||
void *argp = 0;
|
||||
int newmem = 0;
|
||||
int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
%variable_fail(res, "$type", "$name");
|
||||
}
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared;
|
||||
if (!argp) { %argument_nullref("$type", $symname, $argnum); }
|
||||
if (newmem & SWIG_CAST_NEW_MEMORY) {
|
||||
tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
$1 = *%const_cast(tempshared.get(), $1_ltype);
|
||||
} else {
|
||||
$1 = *%const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $1_ltype);
|
||||
}
|
||||
}
|
||||
%typemap(varout, fragment="SWIG_null_deleter") CONST TYPE & {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(&$1 SWIG_NO_NULL_DELETER_0);
|
||||
%set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
// plain pointer by reference
|
||||
// Note: $disown not implemented as it will lead to a memory leak of the shared_ptr instance
|
||||
%typemap(in) TYPE *CONST& (void *argp = 0, int res = 0, $*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) {
|
||||
int newmem = 0;
|
||||
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
%argument_fail(res, "$type", $symname, $argnum);
|
||||
}
|
||||
if (newmem & SWIG_CAST_NEW_MEMORY) {
|
||||
tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
temp = %const_cast(tempshared.get(), $*1_ltype);
|
||||
} else {
|
||||
temp = %const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $*1_ltype);
|
||||
}
|
||||
$1 = &temp;
|
||||
}
|
||||
%typemap(out, fragment="SWIG_null_deleter") TYPE *CONST& {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner);
|
||||
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
%typemap(varin) TYPE *CONST& %{
|
||||
#error "varin typemap not implemented"
|
||||
%}
|
||||
%typemap(varout) TYPE *CONST& %{
|
||||
#error "varout typemap not implemented"
|
||||
%}
|
||||
|
||||
// shared_ptr by value
|
||||
%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > (void *argp, int res = 0) {
|
||||
int newmem = 0;
|
||||
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
%argument_fail(res, "$type", $symname, $argnum);
|
||||
}
|
||||
if (argp) $1 = *(%reinterpret_cast(argp, $<ype));
|
||||
if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $<ype);
|
||||
}
|
||||
%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0;
|
||||
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
|
||||
int newmem = 0;
|
||||
void *argp = 0;
|
||||
int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
%variable_fail(res, "$type", "$name");
|
||||
}
|
||||
$1 = argp ? *(%reinterpret_cast(argp, $<ype)) : SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE >();
|
||||
if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $<ype);
|
||||
}
|
||||
%typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0;
|
||||
%set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
// shared_ptr by reference
|
||||
%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & (void *argp, int res = 0, $*1_ltype tempshared) {
|
||||
int newmem = 0;
|
||||
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
%argument_fail(res, "$type", $symname, $argnum);
|
||||
}
|
||||
if (newmem & SWIG_CAST_NEW_MEMORY) {
|
||||
if (argp) tempshared = *%reinterpret_cast(argp, $ltype);
|
||||
delete %reinterpret_cast(argp, $ltype);
|
||||
$1 = &tempshared;
|
||||
} else {
|
||||
$1 = (argp) ? %reinterpret_cast(argp, $ltype) : &tempshared;
|
||||
}
|
||||
}
|
||||
%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = *$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0;
|
||||
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{
|
||||
#error "varin typemap not implemented"
|
||||
%}
|
||||
%typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{
|
||||
#error "varout typemap not implemented"
|
||||
%}
|
||||
|
||||
// shared_ptr by pointer
|
||||
%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * (void *argp, int res = 0, $*1_ltype tempshared) {
|
||||
int newmem = 0;
|
||||
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
%argument_fail(res, "$type", $symname, $argnum);
|
||||
}
|
||||
if (newmem & SWIG_CAST_NEW_MEMORY) {
|
||||
if (argp) tempshared = *%reinterpret_cast(argp, $ltype);
|
||||
delete %reinterpret_cast(argp, $ltype);
|
||||
$1 = &tempshared;
|
||||
} else {
|
||||
$1 = (argp) ? %reinterpret_cast(argp, $ltype) : &tempshared;
|
||||
}
|
||||
}
|
||||
%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 && *$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0;
|
||||
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
if ($owner) delete $1;
|
||||
}
|
||||
|
||||
%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{
|
||||
#error "varin typemap not implemented"
|
||||
%}
|
||||
%typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{
|
||||
#error "varout typemap not implemented"
|
||||
%}
|
||||
|
||||
// shared_ptr by pointer reference
|
||||
%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& (void *argp, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, $*1_ltype temp = 0) {
|
||||
int newmem = 0;
|
||||
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
%argument_fail(res, "$type", $symname, $argnum);
|
||||
}
|
||||
if (argp) tempshared = *%reinterpret_cast(argp, $*ltype);
|
||||
if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $*ltype);
|
||||
temp = &tempshared;
|
||||
$1 = &temp;
|
||||
}
|
||||
%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = *$1 && **$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(**$1) : 0;
|
||||
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{
|
||||
#error "varin typemap not implemented"
|
||||
%}
|
||||
%typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{
|
||||
#error "varout typemap not implemented"
|
||||
%}
|
||||
|
||||
// Typecheck typemaps
|
||||
// Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting
|
||||
// function is not called thereby avoiding a possible smart pointer copy constructor call when casting up the inheritance chain.
|
||||
%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1)
|
||||
TYPE CONST,
|
||||
TYPE CONST &,
|
||||
TYPE CONST *,
|
||||
TYPE *CONST&,
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &,
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *,
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& {
|
||||
int res = SWIG_ConvertPtr($input, 0, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), 0);
|
||||
$1 = SWIG_CheckState(res);
|
||||
}
|
||||
|
||||
|
||||
// various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug
|
||||
%typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
|
||||
#error "typemaps for $1_type not available"
|
||||
%}
|
||||
%typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
|
||||
#error "typemaps for $1_type not available"
|
||||
%}
|
||||
|
||||
|
||||
%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
|
||||
%enddef
|
||||
|
||||
15
Lib/r/r.swg
15
Lib/r/r.swg
|
|
@ -109,10 +109,21 @@ SWIG_InitializeModule(0);
|
|||
free($1);
|
||||
%}
|
||||
|
||||
%typemap(freearg, noblock=1) int *OUTPUT,
|
||||
signed int *OUTPUT,
|
||||
unsigned int *OUTPUT,
|
||||
short *OUTPUT,
|
||||
signed short *OUTPUT,
|
||||
long *OUTPUT,
|
||||
signed long *OUTPUT,
|
||||
long long *OUTPUT,
|
||||
unsigned long long *OUTPUT,
|
||||
float *OUTPUT,
|
||||
double *OUTPUT {}
|
||||
|
||||
|
||||
|
||||
/* Shoul dwe recycle to make the length correct.
|
||||
/* Should we recycle to make the length correct.
|
||||
And warn if length() > the dimension.
|
||||
*/
|
||||
%typemap(scheck) SWIGTYPE [ANY] %{
|
||||
|
|
@ -132,8 +143,6 @@ SWIG_InitializeModule(0);
|
|||
};
|
||||
%}
|
||||
|
||||
|
||||
%include <typemaps/swigmacros.swg>
|
||||
%include <typemaps/fragments.swg>
|
||||
%include <rfragments.swg>
|
||||
%include <ropers.swg>
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
|
||||
|
||||
%fragment("RSequence_Base","header")
|
||||
%fragment("StdSequenceTraits","header",fragment="<stddef.h>")
|
||||
{
|
||||
%#include <functional>
|
||||
namespace swig {
|
||||
|
|
@ -133,7 +133,7 @@ namespace swig {
|
|||
// %swig_sequence_iterator(%arg(Sequence))
|
||||
%swig_container_methods(%arg(Sequence))
|
||||
|
||||
%fragment("RSequence_Base");
|
||||
%fragment("StdSequenceTraits");
|
||||
|
||||
%extend {
|
||||
value_type pop() throw (std::out_of_range) {
|
||||
|
|
|
|||
|
|
@ -170,12 +170,12 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size)
|
|||
order to allow for use of CHARSXP caches. */
|
||||
|
||||
Rf_protect(t = Rf_allocVector(STRSXP, 1));
|
||||
#if R_VERSION >= R_Version(2,7,0)
|
||||
%#if R_VERSION >= R_Version(2,7,0)
|
||||
c = Rf_mkCharLen(carray, size);
|
||||
#else
|
||||
%#else
|
||||
c = Rf_allocVector(CHARSXP, size);
|
||||
strncpy((char *)CHAR(c), carray, size);
|
||||
#endif
|
||||
%#endif
|
||||
SET_STRING_ELT(t, 0, c);
|
||||
Rf_unprotect(1);
|
||||
return t;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,12 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* for raw pointer */
|
||||
#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_R_ConvertPtr(obj, pptr, type, flags)
|
||||
#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_R_ConvertPtr(obj, pptr, type, flags)
|
||||
#define SWIG_NewPointerObj(ptr, type, flags) SWIG_R_NewPointerObj(ptr, type, flags)
|
||||
|
||||
|
||||
/* Remove global namespace pollution */
|
||||
#if !defined(SWIG_NO_R_NO_REMAP)
|
||||
# define R_NO_REMAP
|
||||
|
|
@ -261,10 +267,10 @@ SWIG_R_NewPointerObj(void *ptr, swig_type_info *type, int flags) {
|
|||
SEXP rptr = R_MakeExternalPtr(ptr,
|
||||
R_MakeExternalPtr(type, R_NilValue, R_NilValue), R_NilValue);
|
||||
SET_S4_OBJECT(rptr);
|
||||
// rptr = Rf_setAttrib(rptr, R_ClassSymbol, mkChar(SWIG_TypeName(type)));
|
||||
return rptr;
|
||||
}
|
||||
|
||||
|
||||
/* Convert a pointer value */
|
||||
SWIGRUNTIMEINLINE int
|
||||
SWIG_R_ConvertPtr(SEXP obj, void **ptr, swig_type_info *ty, int flags) {
|
||||
|
|
@ -294,7 +300,7 @@ SWIG_R_ConvertPtr(SEXP obj, void **ptr, swig_type_info *ty, int flags) {
|
|||
}
|
||||
|
||||
SWIGRUNTIME swig_module_info *
|
||||
SWIG_GetModule(void *v) {
|
||||
SWIG_GetModule(void *SWIGUNUSEDPARM(clientdata)) {
|
||||
static void *type_pointer = (void *)0;
|
||||
return (swig_module_info *) type_pointer;
|
||||
}
|
||||
|
|
@ -362,6 +368,13 @@ SWIG_R_ConvertPacked(SEXP obj, void *ptr, size_t sz, swig_type_info *ty) {
|
|||
return SWIG_OK;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <exception>
|
||||
#define SWIG_exception_noreturn(code, msg) do { throw std::runtime_error(msg); } while(0)
|
||||
#else
|
||||
#define SWIG_exception_noreturn(code, msg) do { return result; } while(0)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -104,10 +104,8 @@ namespace swig {
|
|||
Type v;
|
||||
int res = asval(obj, &v);
|
||||
if (!obj || !SWIG_IsOK(res)) {
|
||||
// if (!PyErr_Occurred()) {
|
||||
// %type_error(swig::type_name<Type>());
|
||||
// }
|
||||
if (throw_error) throw std::invalid_argument("bad type");
|
||||
if (throw_error)
|
||||
throw std::invalid_argument("bad type");
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
|
@ -129,10 +127,8 @@ namespace swig {
|
|||
} else {
|
||||
// Uninitialized return value, no Type() constructor required.
|
||||
static Type *v_def = (Type*) malloc(sizeof(Type));
|
||||
// if (!PyErr_Occurred()) {
|
||||
// %type_error(swig::type_name<Type>());
|
||||
// }
|
||||
if (throw_error) throw std::invalid_argument("bad type");
|
||||
if (throw_error)
|
||||
throw std::invalid_argument("bad type");
|
||||
memset(v_def,0,sizeof(Type));
|
||||
return *v_def;
|
||||
}
|
||||
|
|
@ -147,10 +143,8 @@ namespace swig {
|
|||
if (SWIG_IsOK(res)) {
|
||||
return v;
|
||||
} else {
|
||||
// if (!PyErr_Occurred()) {
|
||||
// %type_error(swig::type_name<Type>());
|
||||
// }
|
||||
if (throw_error) throw std::invalid_argument("bad type");
|
||||
if (throw_error)
|
||||
throw std::invalid_argument("bad type");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
192
Lib/r/rtype.swg
192
Lib/r/rtype.swg
|
|
@ -4,24 +4,9 @@
|
|||
*/
|
||||
|
||||
%typemap("rtype") int, int *, int & "integer";
|
||||
%apply int {size_t}
|
||||
%apply int {std::size_t}
|
||||
%apply int {ptrdiff_t}
|
||||
%apply int {std::ptrdiff_t}
|
||||
%apply int {signed int}
|
||||
%apply int {unsigned int}
|
||||
%apply int {short}
|
||||
%apply int {unsigned short}
|
||||
|
||||
%typemap("rtype") long, long *, long & "integer";
|
||||
%apply long {long long}
|
||||
%apply long {signed long long}
|
||||
%apply long {unsigned long long}
|
||||
%apply long {signed long}
|
||||
%apply long {unsigned long}
|
||||
|
||||
%typemap("rtype") float, float*, float & "numeric";
|
||||
%typemap("rtype") double, double*, double & "numeric";
|
||||
%typemap("rtype") float, float *, float & "numeric";
|
||||
%typemap("rtype") char *, char ** "character";
|
||||
%typemap("rtype") char "character";
|
||||
%typemap("rtype") string, string *, string & "character";
|
||||
|
|
@ -38,8 +23,44 @@
|
|||
%typemap("rtype") SWIGTYPE && "$R_class";
|
||||
%typemap("rtype") SWIGTYPE "$&R_class";
|
||||
|
||||
%typemap("rtypecheck") int, int &, long, long &
|
||||
%{ (is.integer($arg) || is.numeric($arg)) && length($arg) == 1 %}
|
||||
%typemap("rtypecheck") int *, long *
|
||||
%{ is.integer($arg) || is.numeric($arg) %}
|
||||
|
||||
|
||||
%typemap("rtypecheck") float, double
|
||||
%{ is.numeric($arg) && length($arg) == 1 %}
|
||||
%typemap("rtypecheck") float *, double *
|
||||
%{ is.numeric($arg) %}
|
||||
|
||||
%typemap("rtypecheck") bool, bool &
|
||||
%{ is.logical($arg) && length($arg) == 1 %}
|
||||
%typemap("rtypecheck") bool *
|
||||
%{ is.logical($arg) %}
|
||||
|
||||
/*
|
||||
Set up type checks to insure overloading precedence.
|
||||
We would like non pointer items to shadow pointer items, so that
|
||||
they get called if length = 1
|
||||
*/
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_BOOL) bool {}
|
||||
%typecheck(SWIG_TYPECHECK_UINT32) unsigned int {}
|
||||
%typecheck(SWIG_TYPECHECK_INTEGER) int {}
|
||||
%typecheck(SWIG_TYPECHECK_FLOAT) float {}
|
||||
%typecheck(SWIG_TYPECHECK_DOUBLE) double {}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_BOOL_PTR) bool * {}
|
||||
%typecheck(SWIG_TYPECHECK_INT32_PTR) int * {}
|
||||
%typecheck(SWIG_TYPECHECK_FLOAT_PTR) float * {}
|
||||
%typecheck(SWIG_TYPECHECK_DOUBLE_PTR) double * {}
|
||||
%typecheck(SWIG_TYPECHECK_CHAR_PTR) char * {}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_INT32_ARRAY) int[ANY] {}
|
||||
%typecheck(SWIG_TYPECHECK_FLOAT_ARRAY) float[ANY] {}
|
||||
%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY) double [ANY] {}
|
||||
|
||||
/* Have to be careful that as(x, "numeric") is different from as.numeric(x).
|
||||
The latter makes a REALSXP, whereas the former leaves an INTSXP as an
|
||||
INTSXP.
|
||||
|
|
@ -53,9 +74,8 @@
|
|||
%{ $input = as.integer($input); %}
|
||||
%typemap(scoercein) long, long *, long &
|
||||
%{ $input = as.integer($input); %}
|
||||
%typemap(scoercein) double, double *, double &
|
||||
%{ %}
|
||||
%typemap(scoercein) float, float *, float &
|
||||
%typemap(scoercein) float, float*, float &,
|
||||
double, double *, double &
|
||||
%{ %}
|
||||
%typemap(scoercein) char, char *, char &
|
||||
%{ $input = as($input, "character"); %}
|
||||
|
|
@ -74,9 +94,8 @@
|
|||
%typemap(scoercein) enum SWIGTYPE *const
|
||||
%{ $input = enumToInteger($input, "$R_class"); %}
|
||||
|
||||
|
||||
%typemap(scoercein) SWIGTYPE, SWIGTYPE *, SWIGTYPE *const, SWIGTYPE &, SWIGTYPE &&
|
||||
%{ %}
|
||||
%{ if (inherits($input, "ExternalReference")) $input = slot($input,"ref") %}
|
||||
|
||||
/*
|
||||
%typemap(scoercein) SWIGTYPE *, SWIGTYPE *const
|
||||
|
|
@ -106,12 +125,10 @@
|
|||
%typemap(scoercein) int,
|
||||
int *,
|
||||
int &,
|
||||
int[ANY],
|
||||
long,
|
||||
long *,
|
||||
long &,
|
||||
long[ANY]
|
||||
"$input = as.integer($input); ";
|
||||
long &
|
||||
"$input = as.integer($input);";
|
||||
|
||||
%typemap(scoercein) char *, string, std::string,
|
||||
string &, std::string &
|
||||
|
|
@ -132,30 +149,44 @@ string &, std::string &
|
|||
%typemap(scoerceout) enum SWIGTYPE *const
|
||||
%{ $result = enumToInteger($result, "$R_class"); %}
|
||||
|
||||
#%typemap(scoerceout) SWIGTYPE
|
||||
# %{ class($result) <- "$&R_class"; %}
|
||||
|
||||
%typemap(scoerceout) SWIGTYPE
|
||||
%{ class($result) <- "$&R_class"; %}
|
||||
#%typemap(scoerceout) SWIGTYPE &
|
||||
# %{ class($result) <- "$R_class"; %}
|
||||
|
||||
%typemap(scoerceout) SWIGTYPE &
|
||||
%{ class($result) <- "$R_class"; %}
|
||||
#%typemap(scoerceout) SWIGTYPE *
|
||||
# %{ class($result) <- "$R_class"; %}
|
||||
|
||||
%typemap(scoerceout) SWIGTYPE &&
|
||||
%{ class($result) <- "$R_class"; %}
|
||||
#%typemap(scoerceout) SWIGTYPE *const
|
||||
# %{ class($result) <- "$R_class"; %}
|
||||
|
||||
%typemap(scoerceout) SWIGTYPE *
|
||||
%{ class($result) <- "$R_class"; %}
|
||||
%typemap(scoerceout) SWIGTYPE
|
||||
%{ $result <- new("$&R_class", ref=$result); %}
|
||||
|
||||
%typemap(scoerceout) SWIGTYPE &
|
||||
%{ $result <- new("$R_class", ref=$result) ; %}
|
||||
|
||||
%typemap(scoerceout) SWIGTYPE &&
|
||||
%{ $result <- new("$R_class", ref=$result) ; %}
|
||||
|
||||
%typemap(scoerceout) SWIGTYPE *
|
||||
%{ $result <- new("$R_class", ref=$result) ; %}
|
||||
|
||||
%typemap(scoerceout) SWIGTYPE *const
|
||||
%{ $result <- new("$R_class", ref=$result) ; %}
|
||||
|
||||
%typemap(scoerceout) SWIGTYPE *const
|
||||
%{ class($result) <- "$R_class"; %}
|
||||
|
||||
/* Override the SWIGTYPE * above. */
|
||||
%typemap(scoerceout) char,
|
||||
char *,
|
||||
char &,
|
||||
double,
|
||||
double &,
|
||||
float,
|
||||
double,
|
||||
float*,
|
||||
double*,
|
||||
float &,
|
||||
double &,
|
||||
int,
|
||||
int &,
|
||||
long,
|
||||
|
|
@ -183,9 +214,94 @@ string &, std::string &
|
|||
signed long,
|
||||
signed long &,
|
||||
unsigned long,
|
||||
unsigned long &
|
||||
unsigned long &,
|
||||
signed char,
|
||||
signed char &,
|
||||
unsigned char,
|
||||
unsigned char &
|
||||
%{ %}
|
||||
|
||||
%apply int {size_t,
|
||||
std::size_t,
|
||||
ptrdiff_t,
|
||||
std::ptrdiff_t,
|
||||
signed int,
|
||||
unsigned int,
|
||||
short,
|
||||
unsigned short,
|
||||
signed char,
|
||||
unsigned char}
|
||||
|
||||
%apply int* {size_t[],
|
||||
std::size_t[],
|
||||
ptrdiff_t[],
|
||||
std::ptrdiff_t[],
|
||||
signed int[],
|
||||
unsigned int[],
|
||||
short[],
|
||||
unsigned short[],
|
||||
signed char[],
|
||||
unsigned char[]}
|
||||
|
||||
%apply int* {size_t[ANY],
|
||||
std::size_t[ANY],
|
||||
ptrdiff_t[ANY],
|
||||
std::ptrdiff_t[ANY],
|
||||
signed int[ANY],
|
||||
unsigned int[ANY],
|
||||
short[ANY],
|
||||
unsigned short[ANY],
|
||||
signed char[ANY],
|
||||
unsigned char[ANY]}
|
||||
|
||||
%apply int* {size_t*,
|
||||
std::size_t*,
|
||||
ptrdiff_t*,
|
||||
std::ptrdiff_t*,
|
||||
signed int*,
|
||||
unsigned int*,
|
||||
short*,
|
||||
unsigned short*,
|
||||
signed char*,
|
||||
unsigned char*}
|
||||
|
||||
%apply long {
|
||||
long long,
|
||||
signed long long,
|
||||
unsigned long long,
|
||||
signed long,
|
||||
unsigned long}
|
||||
|
||||
%apply long* {
|
||||
long long*,
|
||||
signed long long*,
|
||||
unsigned long long*,
|
||||
signed long*,
|
||||
unsigned long*,
|
||||
long long[],
|
||||
signed long long[],
|
||||
unsigned long long[],
|
||||
signed long[],
|
||||
unsigned long[],
|
||||
long long[ANY],
|
||||
signed long long[ANY],
|
||||
unsigned long long[ANY],
|
||||
signed long[ANY],
|
||||
unsigned long[ANY]}
|
||||
|
||||
%apply float* {
|
||||
float[],
|
||||
float[ANY]
|
||||
}
|
||||
%apply double * {
|
||||
double[],
|
||||
double[ANY]
|
||||
}
|
||||
|
||||
%apply bool* {
|
||||
bool[],
|
||||
bool[ANY]
|
||||
}
|
||||
|
||||
#if 0
|
||||
Just examining the values for a SWIGTYPE.
|
||||
|
|
|
|||
|
|
@ -1,2 +1,73 @@
|
|||
%include <rstdcommon.swg>
|
||||
|
||||
|
||||
/*
|
||||
Generate the traits for a 'primitive' type, such as 'double',
|
||||
for which the SWIG_AsVal and SWIG_From methods are already defined.
|
||||
*/
|
||||
|
||||
%define %traits_ptypen(Type...)
|
||||
%fragment(SWIG_Traits_frag(Type),"header",
|
||||
fragment=SWIG_AsVal_frag(Type),
|
||||
fragment=SWIG_From_frag(Type),
|
||||
fragment="StdTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits<Type > {
|
||||
typedef value_category category;
|
||||
static const char* type_name() { return #Type; }
|
||||
};
|
||||
template <> struct traits_asval<Type > {
|
||||
typedef Type value_type;
|
||||
static int asval(SEXP obj, value_type *val) {
|
||||
return SWIG_AsVal(Type)(obj, val);
|
||||
}
|
||||
};
|
||||
template <> struct traits_from<Type > {
|
||||
typedef Type value_type;
|
||||
static SEXP from(const value_type& val) {
|
||||
return SWIG_From(Type)(val);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
%enddef
|
||||
|
||||
/* Traits for enums. This is bit of a sneaky trick needed because a generic template specialization of enums
|
||||
is not possible (unless using template meta-programming which SWIG doesn't support because of the explicit
|
||||
instantiations required using %template). The STL containers define the 'front' method and the typemap
|
||||
below is used whenever the front method is wrapped returning an enum. This typemap simply picks up the
|
||||
standard enum typemap, but additionally drags in a fragment containing the traits_asval and traits_from
|
||||
required in the generated code for enums. */
|
||||
|
||||
%define %traits_enum(Type...)
|
||||
%fragment("SWIG_Traits_enum_"{Type},"header",
|
||||
fragment=SWIG_AsVal_frag(int),
|
||||
fragment=SWIG_From_frag(int),
|
||||
fragment="StdTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits_asval<Type > {
|
||||
typedef Type value_type;
|
||||
static int asval(SEXP obj, value_type *val) {
|
||||
return SWIG_AsVal(int)(obj, (int *)val);
|
||||
}
|
||||
};
|
||||
template <> struct traits_from<Type > {
|
||||
typedef Type value_type;
|
||||
static SEXP from(const value_type& val) {
|
||||
return SWIG_From(int)((int)val);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
%typemap(out, fragment="SWIG_Traits_enum_"{Type}) const enum SWIGTYPE& front %{$typemap(out, const enum SWIGTYPE&)%}
|
||||
%enddef
|
||||
|
||||
|
||||
%include <std/std_common.i>
|
||||
|
||||
//
|
||||
// Generates the traits for all the known primitive
|
||||
// C++ types (int, double, ...)
|
||||
//
|
||||
%apply_cpptypes(%traits_ptypen);
|
||||
|
||||
|
|
|
|||
5
Lib/r/std_list.i
Normal file
5
Lib/r/std_list.i
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#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,10 +1,608 @@
|
|||
%fragment("StdVectorTraits","header")
|
||||
// R specific swig components
|
||||
/*
|
||||
Vectors
|
||||
*/
|
||||
|
||||
%fragment("StdVectorTraits","header",fragment="StdSequenceTraits")
|
||||
%{
|
||||
namespace swig {
|
||||
// vectors of doubles
|
||||
template <>
|
||||
struct traits_from_ptr<std::vector<double> > {
|
||||
static SEXP from (std::vector<double > *val, int owner = 0) {
|
||||
SEXP result;
|
||||
PROTECT(result = Rf_allocVector(REALSXP, val->size()));
|
||||
for (unsigned pos = 0; pos < val->size(); pos++)
|
||||
{
|
||||
NUMERIC_POINTER(result)[pos] = ((*val)[pos]);
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return(result);
|
||||
}
|
||||
};
|
||||
// vectors of floats
|
||||
template <>
|
||||
struct traits_from_ptr<std::vector<float> > {
|
||||
static SEXP from (std::vector<float > *val, int owner = 0) {
|
||||
SEXP result;
|
||||
PROTECT(result = Rf_allocVector(REALSXP, val->size()));
|
||||
for (unsigned pos = 0; pos < val->size(); pos++)
|
||||
{
|
||||
NUMERIC_POINTER(result)[pos] = ((*val)[pos]);
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return(result);
|
||||
}
|
||||
};
|
||||
// vectors of unsigned int
|
||||
template <>
|
||||
struct traits_from_ptr<std::vector<unsigned int> > {
|
||||
static SEXP from (std::vector<unsigned int > *val, int owner = 0) {
|
||||
SEXP result;
|
||||
PROTECT(result = Rf_allocVector(INTSXP, val->size()));
|
||||
for (unsigned pos = 0; pos < val->size(); pos++)
|
||||
{
|
||||
INTEGER_POINTER(result)[pos] = ((*val)[pos]);
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return(result);
|
||||
}
|
||||
};
|
||||
// vectors of int
|
||||
template <>
|
||||
struct traits_from_ptr<std::vector<int> > {
|
||||
static SEXP from (std::vector<int > *val, int owner = 0) {
|
||||
SEXP result;
|
||||
PROTECT(result = Rf_allocVector(INTSXP, val->size()));
|
||||
for (unsigned pos = 0; pos < val->size(); pos++)
|
||||
{
|
||||
INTEGER_POINTER(result)[pos] = ((*val)[pos]);
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return(result);
|
||||
}
|
||||
};
|
||||
|
||||
// vectors of bool
|
||||
template <>
|
||||
struct traits_from_ptr<std::vector<bool> > {
|
||||
static SEXP from (std::vector<bool> *val, int owner = 0) {
|
||||
SEXP result;
|
||||
PROTECT(result = Rf_allocVector(LGLSXP, val->size()));
|
||||
for (unsigned pos = 0; pos < val->size(); pos++)
|
||||
{
|
||||
LOGICAL_POINTER(result)[pos] = ((*val)[pos]);
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return(result);
|
||||
//return SWIG_R_NewPointerObj(val, type_info< std::vector<T > >(), owner);
|
||||
}
|
||||
};
|
||||
// vectors of strings
|
||||
template <>
|
||||
struct traits_from_ptr<std::vector<std::basic_string<char> > > {
|
||||
static SEXP from (std::vector<std::basic_string<char> > *val, int owner = 0) {
|
||||
SEXP result;
|
||||
PROTECT(result = Rf_allocVector(STRSXP, val->size()));
|
||||
for (unsigned pos = 0; pos < val->size(); pos++)
|
||||
{
|
||||
CHARACTER_POINTER(result)[pos] = Rf_mkChar(((*val)[pos]).c_str());
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return(result);
|
||||
//return SWIG_R_NewPointerObj(val, type_info< std::vector<T > >(), owner);
|
||||
}
|
||||
};
|
||||
|
||||
// catch all that does everything with vectors
|
||||
template <typename T>
|
||||
struct traits_from_ptr< std::vector< T > > {
|
||||
static SEXP from (std::vector< T > *val, int owner = 0) {
|
||||
return SWIG_R_NewPointerObj(val, type_info< std::vector< T > >(), owner);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct traits_asptr < std::vector<double> > {
|
||||
static int asptr(SEXP obj, std::vector<double> **val) {
|
||||
std::vector<double> *p;
|
||||
// not sure how to check the size of the SEXP obj is correct
|
||||
unsigned int sexpsz = Rf_length(obj);
|
||||
p = new std::vector<double>(sexpsz);
|
||||
double *S = NUMERIC_POINTER(obj);
|
||||
for (unsigned pos = 0; pos < p->size(); pos++)
|
||||
{
|
||||
(*p)[pos] = static_cast<double>(S[pos]);
|
||||
}
|
||||
int res = SWIG_OK;
|
||||
if (SWIG_IsOK(res)) {
|
||||
if (val) *val = p;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct traits_asptr < std::vector<float> > {
|
||||
static int asptr(SEXP obj, std::vector<float> **val) {
|
||||
std::vector<float> *p;
|
||||
// not sure how to check the size of the SEXP obj is correct
|
||||
unsigned int sexpsz = Rf_length(obj);
|
||||
p = new std::vector<float>(sexpsz);
|
||||
double *S = NUMERIC_POINTER(obj);
|
||||
for (unsigned pos = 0; pos < p->size(); pos++)
|
||||
{
|
||||
(*p)[pos] = static_cast<double>(S[pos]);
|
||||
}
|
||||
int res = SWIG_OK;
|
||||
if (SWIG_IsOK(res)) {
|
||||
if (val) *val = p;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct traits_asptr < std::vector<unsigned int> > {
|
||||
static int asptr(SEXP obj, std::vector<unsigned int> **val) {
|
||||
std::vector<unsigned int> *p;
|
||||
unsigned int sexpsz = Rf_length(obj);
|
||||
p = new std::vector<unsigned int>(sexpsz);
|
||||
SEXP coerced;
|
||||
PROTECT(coerced = Rf_coerceVector(obj, INTSXP));
|
||||
int *S = INTEGER_POINTER(coerced);
|
||||
for (unsigned pos = 0; pos < p->size(); pos++)
|
||||
{
|
||||
(*p)[pos] = static_cast<unsigned int>(S[pos]);
|
||||
}
|
||||
int res = SWIG_OK;
|
||||
if (SWIG_IsOK(res)) {
|
||||
if (val) *val = p;
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct traits_asptr < std::vector<int> > {
|
||||
static int asptr(SEXP obj, std::vector<int> **val) {
|
||||
std::vector<int> *p;
|
||||
// not sure how to check the size of the SEXP obj is correct
|
||||
int sexpsz = Rf_length(obj);
|
||||
p = new std::vector<int>(sexpsz);
|
||||
SEXP coerced;
|
||||
PROTECT(coerced = Rf_coerceVector(obj, INTSXP));
|
||||
int *S = INTEGER_POINTER(coerced);
|
||||
for (unsigned pos = 0; pos < p->size(); pos++)
|
||||
{
|
||||
(*p)[pos] = static_cast<int>(S[pos]);
|
||||
}
|
||||
int res = SWIG_OK;
|
||||
if (SWIG_IsOK(res)) {
|
||||
if (val) *val = p;
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct traits_asptr < std::vector<bool> > {
|
||||
static int asptr(SEXP obj, std::vector<bool> **val) {
|
||||
std::vector<bool> *p;
|
||||
// not sure how to check the size of the SEXP obj is correct
|
||||
int sexpsz = Rf_length(obj);
|
||||
p = new std::vector<bool>(sexpsz);
|
||||
SEXP coerced;
|
||||
PROTECT(coerced = Rf_coerceVector(obj, LGLSXP));
|
||||
int *S = LOGICAL_POINTER(coerced);
|
||||
for (unsigned pos = 0; pos < p->size(); pos++)
|
||||
{
|
||||
(*p)[pos] = static_cast<bool>(S[pos]);
|
||||
}
|
||||
int res = SWIG_OK;
|
||||
if (SWIG_IsOK(res)) {
|
||||
if (val) *val = p;
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
// catchall for R to vector conversion
|
||||
template <typename T>
|
||||
struct traits_asptr < std::vector<T> > {
|
||||
static int asptr(SEXP obj, std::vector<T> **val) {
|
||||
std::vector<T> *p;
|
||||
Rprintf("my asptr\n");
|
||||
int res = SWIG_R_ConvertPtr(obj, (void**)&p, type_info< std::vector<T> >(), 0);
|
||||
if (SWIG_IsOK(res)) {
|
||||
if (val) *val = p;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
// now for vectors of vectors. These will be represented as lists of vectors on the
|
||||
// catch all that does everything with vectors
|
||||
template <>
|
||||
struct traits_from_ptr<std::vector<std::vector<unsigned int> > > {
|
||||
static SEXP from (std::vector< std::vector<unsigned int > > *val, int owner = 0) {
|
||||
SEXP result;
|
||||
// allocate the R list
|
||||
PROTECT(result = Rf_allocVector(VECSXP, val->size()));
|
||||
for (unsigned pos = 0; pos < val->size(); pos++)
|
||||
{
|
||||
// allocate the R vector
|
||||
SET_VECTOR_ELT(result, pos, Rf_allocVector(INTSXP, val->at(pos).size()));
|
||||
// Fill the R vector
|
||||
for (unsigned vpos = 0; vpos < val->at(pos).size(); ++vpos)
|
||||
{
|
||||
INTEGER_POINTER(VECTOR_ELT(result, pos))[vpos] = static_cast<int>(val->at(pos).at(vpos));
|
||||
}
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return(result);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct traits_from_ptr<std::vector<std::vector<int> > > {
|
||||
static SEXP from (std::vector< std::vector<int > > *val, int owner = 0) {
|
||||
SEXP result;
|
||||
// allocate the R list
|
||||
PROTECT(result = Rf_allocVector(VECSXP, val->size()));
|
||||
for (unsigned pos = 0; pos < val->size(); pos++)
|
||||
{
|
||||
// allocate the R vector
|
||||
SET_VECTOR_ELT(result, pos, Rf_allocVector(INTSXP, val->at(pos).size()));
|
||||
// Fill the R vector
|
||||
for (unsigned vpos = 0; vpos < val->at(pos).size(); ++vpos)
|
||||
{
|
||||
INTEGER_POINTER(VECTOR_ELT(result, pos))[vpos] = static_cast<int>(val->at(pos).at(vpos));
|
||||
}
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return(result);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct traits_from_ptr<std::vector<std::vector<float> > > {
|
||||
static SEXP from (std::vector< std::vector<float > > *val, int owner = 0) {
|
||||
SEXP result;
|
||||
// allocate the R list
|
||||
PROTECT(result = Rf_allocVector(VECSXP, val->size()));
|
||||
for (unsigned pos = 0; pos < val->size(); pos++)
|
||||
{
|
||||
// allocate the R vector
|
||||
SET_VECTOR_ELT(result, pos, Rf_allocVector(REALSXP, val->at(pos).size()));
|
||||
// Fill the R vector
|
||||
for (unsigned vpos = 0; vpos < val->at(pos).size(); ++vpos)
|
||||
{
|
||||
NUMERIC_POINTER(VECTOR_ELT(result, pos))[vpos] = static_cast<double>(val->at(pos).at(vpos));
|
||||
}
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return(result);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct traits_from_ptr<std::vector<std::vector<double> > > {
|
||||
static SEXP from (std::vector< std::vector<double > > *val, int owner = 0) {
|
||||
SEXP result;
|
||||
// allocate the R list
|
||||
PROTECT(result = Rf_allocVector(VECSXP, val->size()));
|
||||
for (unsigned pos = 0; pos < val->size(); pos++)
|
||||
{
|
||||
// allocate the R vector
|
||||
SET_VECTOR_ELT(result, pos, Rf_allocVector(REALSXP, val->at(pos).size()));
|
||||
// Fill the R vector
|
||||
for (unsigned vpos = 0; vpos < val->at(pos).size(); ++vpos)
|
||||
{
|
||||
NUMERIC_POINTER(VECTOR_ELT(result, pos))[vpos] = static_cast<double>(val->at(pos).at(vpos));
|
||||
}
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return(result);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct traits_from_ptr<std::vector<std::vector<bool> > > {
|
||||
static SEXP from (std::vector< std::vector<bool> > *val, int owner = 0) {
|
||||
SEXP result;
|
||||
// allocate the R list
|
||||
PROTECT(result = Rf_allocVector(VECSXP, val->size()));
|
||||
for (unsigned pos = 0; pos < val->size(); pos++)
|
||||
{
|
||||
// allocate the R vector
|
||||
SET_VECTOR_ELT(result, pos, Rf_allocVector(LGLSXP, val->at(pos).size()));
|
||||
// Fill the R vector
|
||||
for (unsigned vpos = 0; vpos < val->at(pos).size(); ++vpos)
|
||||
{
|
||||
LOGICAL_POINTER(VECTOR_ELT(result, pos))[vpos] = (val->at(pos).at(vpos));
|
||||
}
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return(result);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct traits_from_ptr< std::vector < std::vector< T > > > {
|
||||
static SEXP from (std::vector < std::vector< T > > *val, int owner = 0) {
|
||||
return SWIG_R_NewPointerObj(val, type_info< std::vector < std::vector< T > > >(), owner);
|
||||
}
|
||||
};
|
||||
|
||||
// R side
|
||||
template <>
|
||||
struct traits_asptr < std::vector< std::vector<unsigned int> > > {
|
||||
static int asptr(SEXP obj, std::vector< std::vector<unsigned int> > **val) {
|
||||
std::vector <std::vector<unsigned int> > *p;
|
||||
// this is the length of the list
|
||||
unsigned int sexpsz = Rf_length(obj);
|
||||
p = new std::vector< std::vector<unsigned int> > (sexpsz);
|
||||
|
||||
for (unsigned listpos = 0; listpos < sexpsz; ++listpos)
|
||||
{
|
||||
unsigned vecsize = Rf_length(VECTOR_ELT(obj, listpos));
|
||||
for (unsigned vpos = 0; vpos < vecsize; ++vpos)
|
||||
{
|
||||
(*p)[listpos].push_back(static_cast<int>(INTEGER_POINTER(VECTOR_ELT(obj, listpos))[vpos]));
|
||||
}
|
||||
}
|
||||
|
||||
int res = SWIG_OK;
|
||||
|
||||
if (SWIG_IsOK(res)) {
|
||||
if (val) *val = p;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct traits_asptr < std::vector< std::vector< int> > > {
|
||||
static int asptr(SEXP obj, std::vector< std::vector< int> > **val) {
|
||||
std::vector <std::vector< int> > *p;
|
||||
// this is the length of the list
|
||||
unsigned int sexpsz = Rf_length(obj);
|
||||
p = new std::vector< std::vector< int> > (sexpsz);
|
||||
|
||||
for (unsigned listpos = 0; listpos < sexpsz; ++listpos)
|
||||
{
|
||||
unsigned vecsize = Rf_length(VECTOR_ELT(obj, listpos));
|
||||
for (unsigned vpos = 0; vpos < vecsize; ++vpos)
|
||||
{
|
||||
(*p)[listpos].push_back(static_cast<int>(INTEGER_POINTER(VECTOR_ELT(obj, listpos))[vpos]));
|
||||
}
|
||||
}
|
||||
|
||||
int res = SWIG_OK;
|
||||
|
||||
if (SWIG_IsOK(res)) {
|
||||
if (val) *val = p;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct traits_asptr < std::vector< std::vector< float> > > {
|
||||
static int asptr(SEXP obj, std::vector< std::vector< float> > **val) {
|
||||
std::vector <std::vector< float> > *p;
|
||||
// this is the length of the list
|
||||
unsigned int sexpsz = Rf_length(obj);
|
||||
p = new std::vector< std::vector< float> > (sexpsz);
|
||||
|
||||
for (unsigned listpos = 0; listpos < sexpsz; ++listpos)
|
||||
{
|
||||
unsigned vecsize = Rf_length(VECTOR_ELT(obj, listpos));
|
||||
for (unsigned vpos = 0; vpos < vecsize; ++vpos)
|
||||
{
|
||||
(*p)[listpos].push_back(static_cast<float>(NUMERIC_POINTER(VECTOR_ELT(obj, listpos))[vpos]));
|
||||
}
|
||||
}
|
||||
|
||||
int res = SWIG_OK;
|
||||
|
||||
if (SWIG_IsOK(res)) {
|
||||
if (val) *val = p;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct traits_asptr < std::vector< std::vector< double> > > {
|
||||
static int asptr(SEXP obj, std::vector< std::vector< double> > **val) {
|
||||
std::vector <std::vector< double> > *p;
|
||||
// this is the length of the list
|
||||
unsigned int sexpsz = Rf_length(obj);
|
||||
p = new std::vector< std::vector< double> > (sexpsz);
|
||||
|
||||
for (unsigned listpos = 0; listpos < sexpsz; ++listpos)
|
||||
{
|
||||
unsigned vecsize = Rf_length(VECTOR_ELT(obj, listpos));
|
||||
for (unsigned vpos = 0; vpos < vecsize; ++vpos)
|
||||
{
|
||||
(*p)[listpos].push_back(static_cast<double>(NUMERIC_POINTER(VECTOR_ELT(obj, listpos))[vpos]));
|
||||
}
|
||||
}
|
||||
|
||||
int res = SWIG_OK;
|
||||
|
||||
if (SWIG_IsOK(res)) {
|
||||
if (val) *val = p;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct traits_asptr < std::vector< std::vector< bool > > > {
|
||||
static int asptr(SEXP obj, std::vector< std::vector< bool> > **val) {
|
||||
std::vector <std::vector< bool > > *p;
|
||||
// this is the length of the list
|
||||
unsigned int sexpsz = Rf_length(obj);
|
||||
p = new std::vector< std::vector< bool > > (sexpsz);
|
||||
|
||||
for (unsigned listpos = 0; listpos < sexpsz; ++listpos)
|
||||
{
|
||||
unsigned vecsize = Rf_length(VECTOR_ELT(obj, listpos));
|
||||
for (unsigned vpos = 0; vpos < vecsize; ++vpos)
|
||||
{
|
||||
(*p)[listpos].push_back(static_cast<bool>(LOGICAL_POINTER(VECTOR_ELT(obj, listpos))[vpos]));
|
||||
}
|
||||
}
|
||||
|
||||
int res = SWIG_OK;
|
||||
|
||||
if (SWIG_IsOK(res)) {
|
||||
if (val) *val = p;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
// catchall
|
||||
template <typename T>
|
||||
struct traits_asptr < std::vector< std::vector<T> > > {
|
||||
static int asptr(SEXP obj, std::vector< std::vector<T> > **val) {
|
||||
std::vector< std::vector<T> > *p;
|
||||
Rprintf("vector of vectors - unsupported content\n");
|
||||
int res = SWIG_R_ConvertPtr(obj, (void**)&p, type_info< std::vector< std::vector<T> > > (), 0);
|
||||
if (SWIG_IsOK(res)) {
|
||||
if (val) *val = p;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
%}
|
||||
|
||||
#define %swig_vector_methods(Type...) %swig_sequence_methods(Type)
|
||||
#define %swig_vector_methods_val(Type...) %swig_sequence_methods_val(Type);
|
||||
|
||||
%define %traits_type_name(Type...)
|
||||
%fragment(SWIG_Traits_frag(Type), "header",
|
||||
fragment="StdTraits",fragment="StdVectorTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits< Type > {
|
||||
typedef pointer_category category;
|
||||
static const char* type_name() {
|
||||
return #Type;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
%enddef
|
||||
|
||||
%include <std/std_vector.i>
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<double>)
|
||||
%traits_type_name(std::vector<double>)
|
||||
%typemap("rtypecheck") std::vector<double>, std::vector<double> const, std::vector<double> const&
|
||||
%{ is.numeric($arg) %}
|
||||
%typemap("rtype") std::vector<double> "numeric"
|
||||
%typemap("scoercein") std::vector<double>, std::vector<double> const, std::vector<double> const& "";
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<float>)
|
||||
%traits_type_name(std::vector<float>)
|
||||
%typemap("rtypecheck") std::vector<float>, std::vector<float> const, std::vector<float> const&
|
||||
%{ is.numeric($arg) %}
|
||||
%typemap("rtype") std::vector<float> "numeric"
|
||||
%typemap("scoercein") std::vector<double>, std::vector<float> const, std::vector<float> const& "";
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<bool>);
|
||||
%traits_type_name(std::vector<bool>);
|
||||
%typemap("rtypecheck") std::vector<bool> , std::vector<bool> const, std::vector<bool> const&
|
||||
%{ is.logical($arg) %}
|
||||
%typemap("rtype") std::vector<bool> "logical"
|
||||
%typemap("scoercein") std::vector<bool> , std::vector<bool> const, std::vector<bool> const& "$input = as.logical($input);";
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<int>);
|
||||
%traits_type_name(std::vector<int>);
|
||||
%typemap("rtypecheck") std::vector<int> , std::vector<int> const, std::vector<int> const&
|
||||
%{ is.integer($arg) || is.numeric($arg) %}
|
||||
%typemap("rtype") std::vector<int> "integer"
|
||||
%typemap("scoercein") std::vector<int> , std::vector<int> const, std::vector<int> const& "$input = as.integer($input);";
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<unsigned int>);
|
||||
%traits_type_name(std::vector<unsigned int>);
|
||||
%typemap("rtypecheck") std::vector<unsigned int>, std::vector<unsigned int> const, std::vector<unsigned int> const&
|
||||
%{ is.integer($arg) || is.numeric($arg) %}
|
||||
%typemap("rtype") std::vector<unsigned int> "integer"
|
||||
%typemap("scoercein") std::vector<unsigned int>, std::vector<unsigned int> const, std::vector<unsigned int> const& "$input = as.integer($input);";
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<std::vector<unsigned int> >);
|
||||
%traits_type_name(std::vector< std::vector<unsigned int> >);
|
||||
%typemap("rtypecheck") std::vector<std::vector<unsigned int> >, std::vector<std::vector<unsigned int> > const, std::vector<std::vector<unsigned int> >const&
|
||||
%{ is.list($arg) && all(sapply($arg , is.integer) || sapply($arg, is.numeric)) %}
|
||||
%typemap("rtype") std::vector<std::vector<unsigned int> > "list"
|
||||
%typemap("scoercein") std::vector< std::vector<unsigned int> >, std::vector<std::vector<unsigned int> > const, std::vector<std::vector<unsigned int> >const& "$input = lapply($input, as.integer);";
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<std::vector<int> >);
|
||||
%traits_type_name(std::vector< std::vector<int> >);
|
||||
%typemap("rtypecheck") std::vector<std::vector<int> >, std::vector<std::vector<int> > const, std::vector<std::vector<int> >const&
|
||||
%{ is.list($arg) && all(sapply($arg , is.integer) || sapply($arg, is.numeric)) %}
|
||||
%typemap("rtype") std::vector<std::vector<int> > "list"
|
||||
%typemap("scoercein") std::vector< std::vector<int> >, std::vector<std::vector<int> > const, std::vector<std::vector<int> >const& "$input = lapply($input, as.integer);";
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<std::vector<float> >);
|
||||
%traits_type_name(std::vector< std::vector<float> >);
|
||||
%typemap("rtypecheck") std::vector<std::vector<float> >, std::vector<std::vector<float> > const, std::vector<std::vector<float> >const&
|
||||
%{ is.list($arg) && all(sapply($arg , is.integer) || sapply($arg, is.numeric)) %}
|
||||
%typemap("rtype") std::vector<std::vector<float> > "list"
|
||||
%typemap("scoercein") std::vector< std::vector<float> >, std::vector<std::vector<float> > const, std::vector<std::vector<float> >const& "$input = lapply($input, as.numeric);";
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<std::vector<double> >);
|
||||
%traits_type_name(std::vector< std::vector<double> >);
|
||||
%typemap("rtypecheck") std::vector<std::vector<double> >, std::vector<std::vector<double> > const, std::vector<std::vector<double> >const&
|
||||
%{ is.list($arg) && all(sapply($arg , is.integer) || sapply($arg, is.numeric)) %}
|
||||
%typemap("rtype") std::vector<std::vector<double> > "list"
|
||||
%typemap("scoercein") std::vector< std::vector<double> >, std::vector<std::vector<double> > const, std::vector<std::vector<double> >const&
|
||||
"$input = lapply($input, as.numeric);";
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<std::vector<bool> >);
|
||||
%traits_type_name(std::vector< std::vector<bool> >);
|
||||
%typemap("rtypecheck") std::vector<std::vector<bool> >, std::vector<std::vector<bool> > const, std::vector<std::vector<bool> >const&
|
||||
%{ is.list($arg) && all(sapply($arg , is.integer) || sapply($arg, is.numeric)) %}
|
||||
%typemap("rtype") std::vector<std::vector<bool> > "list"
|
||||
%typemap("scoercein") std::vector< std::vector<bool> >, std::vector<std::vector<bool> > const, std::vector<std::vector<bool> >const& "$input = lapply($input, as.logical);";
|
||||
|
||||
// we don't want these to be given R classes as they
|
||||
// have already been turned into R vectors.
|
||||
%typemap(scoerceout) std::vector<double>,
|
||||
std::vector<double> *,
|
||||
std::vector<double> &,
|
||||
std::vector<bool>,
|
||||
std::vector<bool> *,
|
||||
std::vector<bool> &,
|
||||
std::vector<unsigned int>,
|
||||
std::vector<unsigned int> *,
|
||||
std::vector<unsigned int> &,
|
||||
// vectors of vectors
|
||||
std::vector< std::vector<unsigned int> >,
|
||||
std::vector< std::vector<unsigned int> >*,
|
||||
std::vector< std::vector<unsigned int> >&,
|
||||
std::vector< std::vector<int> >,
|
||||
std::vector< std::vector<int> >*,
|
||||
std::vector< std::vector<int> >&,
|
||||
std::vector< std::vector<float> >,
|
||||
std::vector< std::vector<float> >*,
|
||||
std::vector< std::vector<float> >&,
|
||||
std::vector< std::vector<double> >,
|
||||
std::vector< std::vector<double> >*,
|
||||
std::vector< std::vector<double> >&,
|
||||
std::vector< std::vector<bool> >,
|
||||
std::vector< std::vector<bool> >*,
|
||||
std::vector< std::vector<bool> >&
|
||||
|
||||
|
||||
%include <std/std_vector.i>
|
||||
%{ %}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
/* initial STL definition. extended as needed in each language */
|
||||
%include std_common.i
|
||||
%include std_vector.i
|
||||
%include std_pair.i
|
||||
%include std_string.i
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue