Octave: cleanup/restructure library files

- Restructure runtime code into declarations, function
  and class definitions, and initialisation code
- Rename internal functions/types to follow SWIG_Octave...
  or SwigOct... naming styles
- Style/comment/whitespace cleanups
This commit is contained in:
Karl Wette 2014-06-02 03:02:47 +02:00 committed by Karl Wette
commit bf12d76d03
42 changed files with 4288 additions and 3702 deletions

View file

@ -1 +1,5 @@
//
// attribute.i - Attribute support
//
%include <typemaps/attribute.swg>

View file

@ -1,3 +1,7 @@
//
// boost_shared_ptr.i - Boost shared pointer support
//
%include <shared_ptr.i>
// Language specific macro implementing all the customisations for handling the smart pointer
@ -10,30 +14,32 @@
// 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;"
"(void)arg1; delete smartarg1;"
// Typemap customisations...
///// Typemap customisations /////
// plain value
%typemap(in) CONST TYPE (void *argp, int res = 0) {
// 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);
%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 > *);
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));
%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;
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)) {
@ -43,20 +49,22 @@
%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 > *);
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));
%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
// 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) {
%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);
%argument_fail(res, "$type", $symname, $argnum);
}
if (newmem & SWIG_CAST_NEW_MEMORY) {
tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
@ -67,13 +75,13 @@
$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 SWIG_NO_NULL_DELETER_$owner) : 0;
%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 SWIG_NO_NULL_DELETER_$owner) : 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;
%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)) {
@ -90,19 +98,21 @@
$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;
%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) {
// 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);
%argument_fail(res, "$type", $symname, $argnum);
}
if (!argp) {
%argument_nullref("$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 > *);
@ -111,20 +121,22 @@
$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);
%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;
%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 (!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 > *);
@ -133,18 +145,18 @@
$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);
%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
// 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) {
%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);
%argument_fail(res, "$type", $symname, $argnum);
}
if (newmem & SWIG_CAST_NEW_MEMORY) {
tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
@ -155,57 +167,65 @@
}
$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);
%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& %{
%typemap(varin) TYPE* CONST& %{
#error "varin typemap not implemented"
%}
%typemap(varout) TYPE *CONST& %{
%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) {
// 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);
%argument_fail(res, "$type", $symname, $argnum);
}
if (argp) {
$1 = *(%reinterpret_cast(argp, $&ltype));
}
if (newmem & SWIG_CAST_NEW_MEMORY) {
delete %reinterpret_cast(argp, $&ltype);
}
if (argp) $1 = *(%reinterpret_cast(argp, $&ltype));
if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $&ltype);
}
%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;
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;
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, $&ltype)) : SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE >();
if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $&ltype);
if (newmem & SWIG_CAST_NEW_MEMORY) {
delete %reinterpret_cast(argp, $&ltype);
}
}
%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;
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) {
// 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);
%argument_fail(res, "$type", $symname, $argnum);
}
if (newmem & SWIG_CAST_NEW_MEMORY) {
if (argp) tempshared = *%reinterpret_cast(argp, $ltype);
if (argp) {
tempshared = *%reinterpret_cast(argp, $ltype);
}
delete %reinterpret_cast(argp, $ltype);
$1 = &tempshared;
} else {
@ -213,7 +233,7 @@
}
}
%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;
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));
}
@ -224,15 +244,17 @@
#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) {
// 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);
%argument_fail(res, "$type", $symname, $argnum);
}
if (newmem & SWIG_CAST_NEW_MEMORY) {
if (argp) tempshared = *%reinterpret_cast(argp, $ltype);
if (argp) {
tempshared = *%reinterpret_cast(argp, $ltype);
}
delete %reinterpret_cast(argp, $ltype);
$1 = &tempshared;
} else {
@ -240,9 +262,11 @@
}
}
%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;
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;
if ($owner) {
delete $1;
}
}
%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{
@ -252,20 +276,24 @@
#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) {
// 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);
%argument_fail(res, "$type", $symname, $argnum);
}
if (argp) {
tempshared = *%reinterpret_cast(argp, $*ltype);
}
if (newmem & SWIG_CAST_NEW_MEMORY) {
delete %reinterpret_cast(argp, $*ltype);
}
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;
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));
}
@ -277,31 +305,30 @@
%}
// Typecheck typemaps
// Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting
// 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 > *& {
%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::*) %{
// 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::*) %{
%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

View file

@ -1,5 +1,9 @@
//
// carrays.i - Manipulate simple pointers as arrays
//
%define %array_class(TYPE,NAME)
%array_class_wrap(TYPE,NAME,__paren__,__paren_asgn__)
%array_class_wrap(TYPE,NAME,__paren__,__paren_asgn__)
%enddef
%include <typemaps/carrays.swg>

View file

@ -1 +1,5 @@
//
// cdata.i - Manipulate raw C data as strings
//
%include <typemaps/cdata.swg>

View file

@ -1 +1,5 @@
//
// cmalloc.i - Object creation using C malloc()
//
%include <typemaps/cmalloc.swg>

View file

@ -1,132 +0,0 @@
/* -----------------------------------------------------------------------------
* director.swg
*
* This file contains support for director classes so that D proxy
* methods can be called from C++.
* ----------------------------------------------------------------------------- */
# define SWIG_DIRECTOR_CAST(ARG) dynamic_cast<Swig::Director *>(ARG)
#include <exception>
namespace Swig {
class Director {
octave_swig_type *self;
bool swig_disowned;
Director(const Director &x);
Director &operator=(const Director &rhs);
public:
Director(void *vptr):self(0), swig_disowned(false) {
set_rtdir(vptr, this);
}
~Director() {
swig_director_destroyed(self, this);
if (swig_disowned)
self->decref();
}
void swig_set_self(octave_swig_type *new_self) {
assert(!swig_disowned);
self = new_self;
}
octave_swig_type *swig_get_self() const {
return self;
}
void swig_disown() {
if (swig_disowned)
return;
swig_disowned = true;
self->incref();
}
};
struct DirectorTypeMismatchException {
static void raise(const char *msg) {
// ... todo
throw(DirectorTypeMismatchException());
}
static void raise(const octave_value &ov, const char *msg) {
// ... todo
raise(msg);
}
};
struct DirectorPureVirtualException {
static void raise(const char *msg) {
// ... todo
throw(DirectorPureVirtualException());
}
static void raise(const octave_value &ov, const char *msg) {
// ... todo
raise(msg);
}
};
SWIGINTERN rtdir_map *get_rtdir_map() {
static swig_module_info *module = 0;
if (!module)
module = SWIG_GetModule(0);
if (!module)
return 0;
if (!module->clientdata)
module->clientdata = new rtdir_map;
return (rtdir_map *) module->clientdata;
}
SWIGINTERNINLINE void set_rtdir(void *vptr, Director *d) {
rtdir_map *rm = get_rtdir_map();
if (rm)
(*rm)[vptr] = d;
}
SWIGINTERNINLINE void erase_rtdir(void *vptr) {
rtdir_map *rm = get_rtdir_map();
if (rm)
(*rm).erase(vptr);
}
SWIGINTERNINLINE Director *get_rtdir(void *vptr) {
rtdir_map *rm = get_rtdir_map();
if (!rm)
return 0;
rtdir_map::const_iterator pos = rm->find(vptr);
Director *rtdir = (pos != rm->end())? pos->second : 0;
return rtdir;
}
SWIGRUNTIME void swig_director_destroyed(octave_swig_type *self, Director *d) {
self->director_destroyed(d);
}
SWIGRUNTIME octave_swig_type *swig_director_get_self(Director *d) {
return d->swig_get_self();
}
SWIGRUNTIME void swig_director_set_self(Director *d, octave_swig_type *self) {
d->swig_set_self(self);
}
}
SWIGRUNTIME void swig_acquire_ownership(void *vptr) {
// assert(0);
// ... todo
}
SWIGRUNTIME void swig_acquire_ownership_array(void *vptr) {
// assert(0);
// ... todo
}
SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own) {
// assert(0);
// ... todo
}

View file

@ -1,6 +1,9 @@
//
// exception.i - C++ exception support
//
%include <typemaps/exception.swg>
%insert("runtime") {
%define_as(SWIG_exception(code, msg), %block(%error(code, msg); SWIG_fail; ))
%define_as(SWIG_exception(code, msg), %block(%error(code, msg); SWIG_fail; ))
}

View file

@ -1 +1,5 @@
//
// factory.i - Factory method wrapping
//
%include <typemaps/factory.swg>

View file

@ -1,7 +1,10 @@
//
// implicit.i - %implicit directive
//
%include <std_common.i>
%include <typemaps/implicit.swg>
#warning "This file provides the %implicit directive, which is an old and fragile"
#warning "way to implement the C++ implicit conversion mechanism."
#warning "Try using the more robust '%implicitconv Type;' directive instead."

View file

@ -1,8 +1,19 @@
//
// octave.swg - Octave configuration module
//
// Include standard SWIG macros and fragments
%include <typemaps/swigmacros.swg>
%include <typemaps/fragments.swg>
// Include Octave runtime code
%include <octruntime.swg>
%include <octuserdir.swg>
// Include Octave typemaps
%include <octtypemaps.swg>
// Include Octave overloaded operator support
%include <octopers.swg>
%define %docstring %feature("docstring") %enddef
// Include Octave special user directives
%include <octuserdir.swg>

View file

@ -1,92 +1,83 @@
/*
Defines the As/From conversors for double/float complex, you need to
provide complex Type, the Name you want to use in the conversors,
the complex Constructor method, and the Real and Imag complex
accesor methods.
//
// octcomplex.swg - Octave complex number support
//
See the std_complex.i and ccomplex.i for concrete examples.
*/
// Defines the As/From conversors for double/float complex, you need to
// provide complex Type, the Name you want to use in the conversors,
// the complex Constructor method, and the Real and Imag complex accessor
// methods. See the std_complex.i and ccomplex.i for concrete examples.
/* the common from conversor */
// Common 'from' conversor
%define %swig_fromcplx_conv(Type, OctConstructor, Real, Imag)
%fragment(SWIG_From_frag(Type),"header")
%fragment(SWIG_From_frag(Type), "header")
{
SWIGINTERNINLINE octave_value
SWIG_From(Type)(const Type& c)
{
return octave_value(OctConstructor(Real(c), Imag(c)));
}
SWIGINTERNINLINE octave_value SWIG_From(Type)(const Type & c) {
return octave_value(OctConstructor(Real(c), Imag(c)));
}
}
%enddef
// the double case
// Double-precision 'as' conversor
%define %swig_cplxdbl_conv(Type, Constructor, Real, Imag)
%fragment(SWIG_AsVal_frag(Type),"header",
fragment=SWIG_AsVal_frag(double))
%fragment(SWIG_AsVal_frag(Type), "header", fragment = SWIG_AsVal_frag(double))
{
SWIGINTERN int
SWIG_AsVal(Type) (const octave_value& ov, Type* val)
{
if (ov.is_complex_scalar()) {
if (val) {
Complex c(ov.complex_value());
*val=Constructor(c.real(),c.imag());
}
return SWIG_OK;
} else {
double d;
int res = SWIG_AddCast(SWIG_AsVal(double)(ov, &d));
if (SWIG_IsOK(res)) {
if (val)
*val = Constructor(d, 0.0);
return res;
}
SWIGINTERN int SWIG_AsVal(Type)(const octave_value & ov, Type * val) {
if (ov.is_complex_scalar()) {
if (val) {
Complex c(ov.complex_value());
*val = Constructor(c.real(), c.imag());
}
return SWIG_OK;
} else {
double d;
int res = SWIG_AddCast(SWIG_AsVal(double)(ov, &d));
if (SWIG_IsOK(res)) {
if (val) {
*val = Constructor(d, 0.0);
}
return res;
}
return SWIG_TypeError;
}
return SWIG_TypeError;
}
}
%swig_fromcplx_conv(Type, Complex, Real, Imag);
%enddef
// the float case
// Single-precision 'as' conversor
%define %swig_cplxflt_conv(Type, Constructor, Real, Imag)
%fragment(SWIG_AsVal_frag(Type),"header",
fragment=SWIG_AsVal_frag(float)) {
SWIGINTERN int
SWIG_AsVal(Type) (const octave_value& ov, Type* val)
{
if (ov.is_complex_scalar()) {
if (val) {
Complex c(ov.complex_value());
double re = c.real();
double im = c.imag();
if ((-FLT_MAX <= re && re <= FLT_MAX) && (-FLT_MAX <= im && im <= FLT_MAX)) {
if (val)
*val = Constructor(%numeric_cast(re, float),
%numeric_cast(im, float));
return SWIG_OK;
} else
return SWIG_OverflowError;
}
} else {
float d;
int res = SWIG_AddCast(SWIG_AsVal(float)(ov, &d));
if (SWIG_IsOK(res)) {
if (val)
*val = Constructor(d, 0.0);
return res;
}
%fragment(SWIG_AsVal_frag(Type), "header", fragment = SWIG_AsVal_frag(float))
{
SWIGINTERN int SWIG_AsVal(Type)(const octave_value & ov, Type * val) {
if (ov.is_complex_scalar()) {
if (val) {
Complex c(ov.complex_value());
double re = c.real();
double im = c.imag();
if ((-FLT_MAX <= re && re <= FLT_MAX) && (-FLT_MAX <= im && im <= FLT_MAX)) {
if (val)
*val = Constructor(%numeric_cast(re, float), %numeric_cast(im, float));
return SWIG_OK;
} else {
return SWIG_OverflowError;
}
}
} else {
float d;
int res = SWIG_AddCast(SWIG_AsVal(float)(ov, &d));
if (SWIG_IsOK(res)) {
if (val) {
*val = Constructor(d, 0.0);
}
return res;
}
return SWIG_TypeError;
}
return SWIG_TypeError;
}
}
%swig_fromcplx_conv(Type, FloatComplex, Real, Imag);
%enddef
#define %swig_cplxflt_convn(Type, Constructor, Real, Imag) \
%swig_cplxflt_conv(Type, Constructor, Real, Imag)
#define %swig_cplxdbl_convn(Type, Constructor, Real, Imag) \
%swig_cplxdbl_conv(Type, Constructor, Real, Imag)
#define %swig_cplxflt_convn(Type, Constructor, Real, Imag) %swig_cplxflt_conv(Type, Constructor, Real, Imag)
#define %swig_cplxdbl_convn(Type, Constructor, Real, Imag) %swig_cplxdbl_conv(Type, Constructor, Real, Imag)

File diff suppressed because it is too large Load diff

View file

@ -1 +1,20 @@
//
// octfragments.swg - Octave user fragments
//
// Create a file with this name, 'octfragments.swg', in your working
// directory and add all the %fragments you want to take precedence
// over the default ones defined by SWIG.
//
// For example, if you add:
//
// %fragment(SWIG_AsVal_frag(int),"header") {
// SWIGINTERNINLINE int SWIG_AsVal(int)(octave_value& obj, int *val) {
// <your code here>;
// }
// }
//
// this will replace the code used to retrieve an integer value for all
// the typemaps that need it, including:
//
// int, std::vector<int>, std::list<std::pair<int,int> >, etc.

View file

@ -1,357 +1,345 @@
/* -----------------------------------------------------------------------------
* octiterators.swg
*
* Users can derive form the OctSwigIterator to implemet their
* own iterators. As an example (real one since we use it for STL/STD
* containers), the template OctSwigIterator_T does the
* implementation for generic C++ iterators.
* ----------------------------------------------------------------------------- */
//
// octiterators.swg - Octave STL iterator support
//
// Users can derive form the OctIterator to implement their
// own iterators. As an example (real one since we use it for STL/STD
// containers), the template OctIterator_T does the
// implementation for generic C++ iterators.
%include <std_common.i>
%fragment("OctSwigIterator","header",fragment="<stddef.h>") {
namespace swig {
struct stop_iteration {
};
struct OctSwigIterator {
private:
octave_value _seq;
protected:
OctSwigIterator(octave_value seq) : _seq(seq)
{
}
public:
virtual ~OctSwigIterator() {}
virtual octave_value value() const = 0;
virtual OctSwigIterator *incr(size_t n = 1) = 0;
virtual OctSwigIterator *decr(size_t n = 1)
{
throw stop_iteration();
}
virtual ptrdiff_t distance(const OctSwigIterator &x) const
{
throw std::invalid_argument("operation not supported");
}
virtual bool equal (const OctSwigIterator &x) const
{
throw std::invalid_argument("operation not supported");
}
virtual OctSwigIterator *copy() const = 0;
octave_value next()
{
octave_value obj = value();
incr();
return obj;
}
octave_value previous()
{
decr();
return value();
}
OctSwigIterator *advance(ptrdiff_t n)
{
return (n > 0) ? incr(n) : decr(-n);
}
bool operator == (const OctSwigIterator& x) const
{
return equal(x);
}
bool operator != (const OctSwigIterator& x) const
{
return ! operator==(x);
}
OctSwigIterator* operator ++ () {
incr();
return this;
}
OctSwigIterator* operator -- () {
decr();
return this;
}
OctSwigIterator* operator + (ptrdiff_t n) const
{
return copy()->advance(n);
}
OctSwigIterator* operator - (ptrdiff_t n) const
{
return copy()->advance(-n);
}
ptrdiff_t operator - (const OctSwigIterator& x) const
{
return x.distance(*this);
}
static swig_type_info* descriptor() {
static int init = 0;
static swig_type_info* desc = 0;
if (!init) {
desc = SWIG_TypeQuery("swig::OctSwigIterator *");
init = 1;
}
return desc;
}
};
}
}
%fragment("OctSwigIterator_T","header",fragment="<stddef.h>",fragment="OctSwigIterator",fragment="StdTraits",fragment="StdIteratorTraits") {
namespace swig {
template<typename OutIterator>
class OctSwigIterator_T : public OctSwigIterator
{
public:
typedef OutIterator out_iterator;
typedef typename std::iterator_traits<out_iterator>::value_type value_type;
typedef OctSwigIterator_T<out_iterator> self_type;
OctSwigIterator_T(out_iterator curr, octave_value seq)
: OctSwigIterator(seq), current(curr)
{
}
const out_iterator& get_current() const
{
return current;
}
bool equal (const OctSwigIterator &iter) const
{
const self_type *iters = dynamic_cast<const self_type *>(&iter);
if (iters) {
return (current == iters->get_current());
} else {
throw std::invalid_argument("bad iterator type");
}
}
ptrdiff_t distance(const OctSwigIterator &iter) const
{
const self_type *iters = dynamic_cast<const self_type *>(&iter);
if (iters) {
return std::distance(current, iters->get_current());
} else {
throw std::invalid_argument("bad iterator type");
}
}
protected:
out_iterator current;
};
template <class ValueType>
struct from_oper
{
typedef const ValueType& argument_type;
typedef octave_value result_type;
result_type operator()(argument_type v) const
{
return swig::from(v);
}
};
template<typename OutIterator,
typename ValueType = typename std::iterator_traits<OutIterator>::value_type,
typename FromOper = from_oper<ValueType> >
class OctSwigIteratorOpen_T : public OctSwigIterator_T<OutIterator>
{
public:
FromOper from;
typedef OutIterator out_iterator;
typedef ValueType value_type;
typedef OctSwigIterator_T<out_iterator> base;
typedef OctSwigIteratorOpen_T<OutIterator, ValueType, FromOper> self_type;
OctSwigIteratorOpen_T(out_iterator curr, octave_value seq)
: OctSwigIterator_T<OutIterator>(curr, seq)
{
}
octave_value value() const {
return from(static_cast<const value_type&>(*(base::current)));
}
OctSwigIterator *copy() const
{
return new self_type(*this);
}
OctSwigIterator *incr(size_t n = 1)
{
while (n--) {
++base::current;
}
return this;
}
OctSwigIterator *decr(size_t n = 1)
{
while (n--) {
--base::current;
}
return this;
}
};
template<typename OutIterator,
typename ValueType = typename std::iterator_traits<OutIterator>::value_type,
typename FromOper = from_oper<ValueType> >
class OctSwigIteratorClosed_T : public OctSwigIterator_T<OutIterator>
{
public:
FromOper from;
typedef OutIterator out_iterator;
typedef ValueType value_type;
typedef OctSwigIterator_T<out_iterator> base;
typedef OctSwigIteratorClosed_T<OutIterator, ValueType, FromOper> self_type;
OctSwigIteratorClosed_T(out_iterator curr, out_iterator first, out_iterator last, octave_value seq)
: OctSwigIterator_T<OutIterator>(curr, seq), begin(first), end(last)
{
}
octave_value value() const {
if (base::current == end) {
throw stop_iteration();
} else {
return from(static_cast<const value_type&>(*(base::current)));
}
}
OctSwigIterator *copy() const
{
return new self_type(*this);
}
OctSwigIterator *incr(size_t n = 1)
{
while (n--) {
if (base::current == end) {
throw stop_iteration();
} else {
++base::current;
}
}
return this;
}
OctSwigIterator *decr(size_t n = 1)
{
while (n--) {
if (base::current == begin) {
throw stop_iteration();
} else {
--base::current;
}
}
return this;
}
private:
out_iterator begin;
out_iterator end;
};
template<typename OutIter>
inline OctSwigIterator*
make_output_iterator(const OutIter& current, const OutIter& begin,const OutIter& end, octave_value seq = octave_value())
{
return new OctSwigIteratorClosed_T<OutIter>(current, begin, end, seq);
}
template<typename OutIter>
inline OctSwigIterator*
make_output_iterator(const OutIter& current, octave_value seq = octave_value())
{
return new OctSwigIteratorOpen_T<OutIter>(current, seq);
}
}
}
%fragment("OctSwigIterator");
namespace swig
%fragment("OctIterator", "header", fragment = "<stddef.h>")
{
// Throw a StopIteration exception
%ignore stop_iteration;
struct stop_iteration {};
%typemap(throws) stop_iteration {
error("stop_iteration exception");
namespace swig
{
struct OctStopIteration {
};
struct OctIterator {
private:
octave_value _seq;
protected:
OctIterator(octave_value seq) : _seq(seq) {
}
public:
virtual ~OctIterator() {}
virtual octave_value value() const = 0;
virtual OctIterator* incr(size_t n = 1) = 0;
virtual OctIterator* decr(size_t n = 1) {
throw OctStopIteration();
}
virtual ptrdiff_t distance(const OctIterator& x) const {
throw std::invalid_argument("operation not supported");
}
virtual bool equal(const OctIterator& x) const {
throw std::invalid_argument("operation not supported");
}
virtual OctIterator* copy() const = 0;
octave_value next() {
octave_value obj = value();
incr();
return obj;
}
octave_value previous() {
decr();
return value();
}
OctIterator* advance(ptrdiff_t n) {
return (n > 0) ? incr(n) : decr(-n);
}
bool operator== (const OctIterator& x) const {
return equal(x);
}
bool operator!= (const OctIterator& x) const {
return ! operator== (x);
}
OctIterator* operator++ () {
incr();
return this;
}
OctIterator* operator-- () {
decr();
return this;
}
OctIterator* operator+ (ptrdiff_t n) const {
return copy()->advance(n);
}
OctIterator* operator- (ptrdiff_t n) const {
return copy()->advance(-n);
}
ptrdiff_t operator- (const OctIterator& x) const {
return x.distance(*this);
}
static swig_type_info* descriptor() {
static int init = 0;
static swig_type_info* desc = 0;
if (!init) {
desc = SWIG_TypeQuery("swig::OctIterator *");
init = 1;
}
return desc;
}
};
}
}
%fragment("OctIterator_T", "header", fragment = "<stddef.h>", fragment = "OctIterator", fragment = "StdTraits", fragment = "StdIteratorTraits")
{
namespace swig
{
template<typename OutIterator>
class OctIterator_T : public OctIterator
{
public:
typedef OutIterator out_iterator;
typedef typename std::iterator_traits<out_iterator>::value_type value_type;
typedef OctIterator_T<out_iterator> self_type;
OctIterator_T(out_iterator curr, octave_value seq)
: OctIterator(seq), current(curr) {
}
const out_iterator& get_current() const {
return current;
}
bool equal(const OctIterator& iter) const {
const self_type* iters = dynamic_cast<const self_type*>(&iter);
if (iters) {
return (current == iters->get_current());
} else {
throw std::invalid_argument("bad iterator type");
}
}
ptrdiff_t distance(const OctIterator& iter) const {
const self_type* iters = dynamic_cast<const self_type*>(&iter);
if (iters) {
return std::distance(current, iters->get_current());
} else {
throw std::invalid_argument("bad iterator type");
}
}
protected:
out_iterator current;
};
template <class ValueType>
struct OctFromOper {
typedef const ValueType& argument_type;
typedef octave_value result_type;
result_type operator()(argument_type v) const {
return swig::from(v);
}
};
template < typename OutIterator, typename ValueType = typename std::iterator_traits<OutIterator>::value_type, typename FromOper = OctFromOper<ValueType> >
class OctIteratorOpen_T : public OctIterator_T<OutIterator>
{
public:
FromOper from;
typedef OutIterator out_iterator;
typedef ValueType value_type;
typedef OctIterator_T<out_iterator> base;
typedef OctIteratorOpen_T<OutIterator, ValueType, FromOper> self_type;
OctIteratorOpen_T(out_iterator curr, octave_value seq)
: OctIterator_T<OutIterator> (curr, seq) {
}
octave_value value() const {
return from(static_cast<const value_type&>(* (base::current)));
}
OctIterator* copy() const {
return new self_type(*this);
}
OctIterator* incr(size_t n = 1) {
while (n--) {
++base::current;
}
return this;
}
OctIterator* decr(size_t n = 1) {
while (n--) {
--base::current;
}
return this;
}
};
template < typename OutIterator, typename ValueType = typename std::iterator_traits<OutIterator>::value_type, typename FromOper = OctFromOper<ValueType> >
class OctIteratorClosed_T : public OctIterator_T<OutIterator>
{
public:
FromOper from;
typedef OutIterator out_iterator;
typedef ValueType value_type;
typedef OctIterator_T<out_iterator> base;
typedef OctIteratorClosed_T<OutIterator, ValueType, FromOper> self_type;
OctIteratorClosed_T(out_iterator curr, out_iterator first, out_iterator last, octave_value seq)
: OctIterator_T<OutIterator> (curr, seq), begin(first), end(last) {
}
octave_value value() const {
if (base::current == end) {
throw OctStopIteration();
} else {
return from(static_cast<const value_type&>(* (base::current)));
}
}
OctIterator* copy() const {
return new self_type(*this);
}
OctIterator* incr(size_t n = 1) {
while (n--) {
if (base::current == end) {
throw OctStopIteration();
} else {
++base::current;
}
}
return this;
}
OctIterator* decr(size_t n = 1) {
while (n--) {
if (base::current == begin) {
throw OctStopIteration();
} else {
--base::current;
}
}
return this;
}
private:
out_iterator begin;
out_iterator end;
};
template<typename OutIter>
inline OctIterator* make_output_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, octave_value seq = octave_value())
{
return new OctIteratorClosed_T<OutIter> (current, begin, end, seq);
}
template<typename OutIter>
inline OctIterator* make_output_iterator(const OutIter& current, octave_value seq = octave_value())
{
return new OctIteratorOpen_T<OutIter> (current, seq);
}
}
}
%fragment("OctIterator");
namespace swig
{
// Throw a StopIteration exception
%ignore OctStopIteration;
struct OctStopIteration {};
%typemap(throws) OctStopIteration {
error("OctStopIteration exception");
SWIG_fail;
}
// Mark methods that return new objects
%newobject OctSwigIterator::copy;
%newobject OctSwigIterator::operator + (ptrdiff_t n) const;
%newobject OctSwigIterator::operator - (ptrdiff_t n) const;
// Mark methods that return new objects
%newobject OctIterator::copy;
%newobject OctIterator::operator+ (ptrdiff_t n) const;
%newobject OctIterator::operator- (ptrdiff_t n) const;
%nodirector OctSwigIterator;
%catches(swig::OctStopIteration) OctIterator::value() const;
%catches(swig::OctStopIteration) OctIterator::incr(size_t n = 1);
%catches(swig::OctStopIteration) OctIterator::decr(size_t n = 1);
%catches(std::invalid_argument) OctIterator::distance(const OctIterator& x) const;
%catches(std::invalid_argument) OctIterator::equal(const OctIterator& x) const;
%catches(swig::OctStopIteration) OctIterator::next();
%catches(swig::OctStopIteration) OctIterator::previous();
%catches(swig::OctStopIteration) OctIterator::advance(ptrdiff_t n);
%catches(swig::OctStopIteration) OctIterator::operator+= (ptrdiff_t n);
%catches(swig::OctStopIteration) OctIterator::operator-= (ptrdiff_t n);
%catches(swig::OctStopIteration) OctIterator::operator+ (ptrdiff_t n) const;
%catches(swig::OctStopIteration) OctIterator::operator- (ptrdiff_t n) const;
%catches(swig::stop_iteration) OctSwigIterator::value() const;
%catches(swig::stop_iteration) OctSwigIterator::incr(size_t n = 1);
%catches(swig::stop_iteration) OctSwigIterator::decr(size_t n = 1);
%catches(std::invalid_argument) OctSwigIterator::distance(const OctSwigIterator &x) const;
%catches(std::invalid_argument) OctSwigIterator::equal (const OctSwigIterator &x) const;
%catches(swig::stop_iteration) OctSwigIterator::next();
%catches(swig::stop_iteration) OctSwigIterator::previous();
%catches(swig::stop_iteration) OctSwigIterator::advance(ptrdiff_t n);
%catches(swig::stop_iteration) OctSwigIterator::operator += (ptrdiff_t n);
%catches(swig::stop_iteration) OctSwigIterator::operator -= (ptrdiff_t n);
%catches(swig::stop_iteration) OctSwigIterator::operator + (ptrdiff_t n) const;
%catches(swig::stop_iteration) OctSwigIterator::operator - (ptrdiff_t n) const;
%nodirector OctIterator;
struct OctIterator {
struct OctSwigIterator
{
protected:
OctSwigIterator(octave_value seq);
OctIterator(octave_value seq);
public:
virtual ~OctSwigIterator();
virtual ~OctIterator();
virtual octave_value value() const = 0;
virtual OctSwigIterator *incr(size_t n = 1) = 0;
virtual OctSwigIterator *decr(size_t n = 1);
virtual ptrdiff_t distance(const OctSwigIterator &x) const;
virtual bool equal (const OctSwigIterator &x) const;
virtual OctSwigIterator *copy() const = 0;
virtual OctIterator* incr(size_t n = 1) = 0;
virtual OctIterator* decr(size_t n = 1);
virtual ptrdiff_t distance(const OctIterator& x) const;
virtual bool equal(const OctIterator& x) const;
virtual OctIterator* copy() const = 0;
octave_value next();
octave_value previous();
OctSwigIterator *advance(ptrdiff_t n);
OctIterator* advance(ptrdiff_t n);
bool operator== (const OctIterator& x) const;
bool operator!= (const OctIterator& x) const;
OctIterator* operator++ ();
OctIterator* operator-- ();
OctIterator* operator+ (ptrdiff_t n) const;
OctIterator* operator- (ptrdiff_t n) const;
ptrdiff_t operator- (const OctIterator& x) const;
bool operator == (const OctSwigIterator& x) const;
bool operator != (const OctSwigIterator& x) const;
OctSwigIterator* operator ++ ();
OctSwigIterator* operator -- ();
OctSwigIterator* operator + (ptrdiff_t n) const;
OctSwigIterator* operator - (ptrdiff_t n) const;
ptrdiff_t operator - (const OctSwigIterator& x) const;
};
}
}

View file

@ -1,17 +1,17 @@
/* ------------------------------------------------------------
* Overloaded operator support
* ------------------------------------------------------------ */
//
// octopers.swg - Octave overloaded operator support
//
#ifdef __cplusplus
// operators supported in Octave, and the methods they are routed to
// Operators supported in Octave, and the methods they are routed to:
//
// __brace__ a{args}
// __brace_asgn__ a{args} = rhs
// __paren__ a(args)
// __paren_asgn__ a(args) = rhs
// __str__ generates string rep
//
// __not__ !a
// __uplus__ +a
// __uminus__ -a
@ -40,8 +40,7 @@
// __el_and__ a & b
// __el_or__ a | b
// operators supported in C++, and the methods that route to them
// Operators supported in C++, and the methods that route to them:
%rename(__add__) *::operator+;
%rename(__add__) *::operator+();
%rename(__add__) *::operator+() const;
@ -85,4 +84,4 @@
%ignoreoperator(EQ) operator=;
%ignoreoperator(ARROWSTAR) operator->*;
#endif /* __cplusplus */
#endif // __cplusplus

View file

@ -1,232 +1,259 @@
/* ------------------------------------------------------------
* Primitive Types
* ------------------------------------------------------------ */
//
// octprimtypes.swg - Octave primitive types
//
// boolean
%fragment(SWIG_From_frag(bool),"header") {
SWIGINTERNINLINE octave_value
SWIG_From_dec(bool)(bool value)
%fragment(SWIG_From_frag(bool), "header")
{
return octave_value(value);
}
SWIGINTERNINLINE octave_value
SWIG_From_dec(bool)(bool value) {
return octave_value(value);
}
}
%fragment(SWIG_AsVal_frag(bool),"header",
fragment=SWIG_AsVal_frag(long)) {
SWIGINTERN int
SWIG_AsVal_dec(bool)(const octave_value& ov, bool *val)
%fragment(SWIG_AsVal_frag(bool), "header",
fragment = SWIG_AsVal_frag(long))
{
if (!ov.is_bool_type())
return SWIG_ERROR;
if (val)
*val = ov.bool_value();
return SWIG_OK;
}
SWIGINTERN int
SWIG_AsVal_dec(bool)(const octave_value & ov, bool * val) {
if (!ov.is_bool_type()) {
return SWIG_ERROR;
}
if (val) {
*val = ov.bool_value();
}
return SWIG_OK;
}
}
// long
%fragment(SWIG_From_frag(long),"header") {
SWIGINTERNINLINE octave_value SWIG_From_dec(long) (long value)
{
return octave_value(value);
}
%fragment(SWIG_From_frag(long), "header")
{
SWIGINTERNINLINE octave_value SWIG_From_dec(long)(long value) {
return octave_value(value);
}
}
%fragment(SWIG_AsVal_frag(long),"header") {
SWIGINTERN int SWIG_AsVal_dec(long)(const octave_value& ov, long* val)
{
if (!ov.is_scalar_type())
return SWIG_TypeError;
if (ov.is_complex_scalar())
return SWIG_TypeError;
if (ov.is_double_type()||ov.is_single_type()) {
double v=ov.double_value();
if (v!=floor(v))
return SWIG_TypeError;
}
if (val)
*val = ov.long_value();
return SWIG_OK;
%fragment(SWIG_AsVal_frag(long), "header")
{
SWIGINTERN int SWIG_AsVal_dec(long)(const octave_value & ov, long * val) {
if (!ov.is_scalar_type()) {
return SWIG_TypeError;
}
if (ov.is_complex_scalar()) {
return SWIG_TypeError;
}
if (ov.is_double_type() || ov.is_single_type()) {
double v = ov.double_value();
if (v != floor(v)) {
return SWIG_TypeError;
}
}
if (val) {
*val = ov.long_value();
}
return SWIG_OK;
}
}
// unsigned long
%fragment(SWIG_From_frag(unsigned long),"header") {
SWIGINTERNINLINE octave_value SWIG_From_dec(unsigned long) (unsigned long value)
{
return octave_value(value);
}
%fragment(SWIG_From_frag(unsigned long), "header")
{
SWIGINTERNINLINE octave_value SWIG_From_dec(unsigned long)(unsigned long value) {
return octave_value(value);
}
}
%fragment(SWIG_AsVal_frag(unsigned long),"header") {
SWIGINTERN int SWIG_AsVal_dec(unsigned long)(const octave_value& ov, unsigned long* val)
{
if (!ov.is_scalar_type())
return SWIG_TypeError;
if (ov.is_complex_scalar())
return SWIG_TypeError;
if (ov.is_double_type()||ov.is_single_type()) {
double v=ov.double_value();
if (v<0)
return SWIG_OverflowError;
if (v!=floor(v))
return SWIG_TypeError;
}
if (ov.is_int8_type()||ov.is_int16_type()||
ov.is_int32_type()) {
long v=ov.long_value();
if (v<0)
return SWIG_OverflowError;
}
if (ov.is_int64_type()) {
long long v=ov.int64_scalar_value().value();
if (v<0)
return SWIG_OverflowError;
}
if (val)
*val = ov.ulong_value();
return SWIG_OK;
%fragment(SWIG_AsVal_frag(unsigned long), "header")
{
SWIGINTERN int SWIG_AsVal_dec(unsigned long)(const octave_value & ov, unsigned long * val) {
if (!ov.is_scalar_type()) {
return SWIG_TypeError;
}
if (ov.is_complex_scalar()) {
return SWIG_TypeError;
}
if (ov.is_double_type() || ov.is_single_type()) {
double v = ov.double_value();
if (v < 0) {
return SWIG_OverflowError;
}
if (v != floor(v)) {
return SWIG_TypeError;
}
}
if (ov.is_int8_type() || ov.is_int16_type() || ov.is_int32_type()) {
long v = ov.long_value();
if (v < 0) {
return SWIG_OverflowError;
}
}
if (ov.is_int64_type()) {
long long v = ov.int64_scalar_value().value();
if (v < 0) {
return SWIG_OverflowError;
}
}
if (val) {
*val = ov.ulong_value();
}
return SWIG_OK;
}
}
// long long
%fragment(SWIG_From_frag(long long),"header") {
SWIGINTERNINLINE octave_value SWIG_From_dec(long long) (long long value)
{
return octave_int64(value);
}
%fragment(SWIG_From_frag(long long), "header")
{
SWIGINTERNINLINE octave_value SWIG_From_dec(long long)(long long value) {
return octave_int64(value);
}
}
%fragment(SWIG_AsVal_frag(long long),"header") {
SWIGINTERN int SWIG_AsVal_dec(long long)(const octave_value& ov, long long* val)
{
if (!ov.is_scalar_type())
return SWIG_TypeError;
if (ov.is_complex_scalar())
return SWIG_TypeError;
if (ov.is_double_type()||ov.is_single_type()) {
double v=ov.double_value();
if (v!=floor(v))
return SWIG_TypeError;
}
if (val) {
if (ov.is_int64_type())
*val = ov.int64_scalar_value().value();
else if (ov.is_uint64_type())
*val = ov.uint64_scalar_value().value();
else
*val = ov.long_value();
}
return SWIG_OK;
%fragment(SWIG_AsVal_frag(long long), "header")
{
SWIGINTERN int SWIG_AsVal_dec(long long)(const octave_value & ov, long long * val) {
if (!ov.is_scalar_type()) {
return SWIG_TypeError;
}
}
%fragment(SWIG_From_frag(unsigned long long),"header") {
SWIGINTERNINLINE octave_value SWIG_From_dec(unsigned long long) (unsigned long long value)
{
return octave_uint64(value);
if (ov.is_complex_scalar()) {
return SWIG_TypeError;
}
}
%fragment(SWIG_AsVal_frag(unsigned long long),"header") {
SWIGINTERN int SWIG_AsVal_dec(unsigned long long)(const octave_value& ov, unsigned long long* val)
{
if (!ov.is_scalar_type())
return SWIG_TypeError;
if (ov.is_complex_scalar())
return SWIG_TypeError;
if (ov.is_double_type()||ov.is_single_type()) {
double v=ov.double_value();
if (v<0)
return SWIG_OverflowError;
if (v!=floor(v))
return SWIG_TypeError;
}
if (ov.is_int8_type()||ov.is_int16_type()||
ov.is_int32_type()) {
long v=ov.long_value();
if (v<0)
return SWIG_OverflowError;
if (ov.is_double_type() || ov.is_single_type()) {
double v = ov.double_value();
if (v != floor(v)) {
return SWIG_TypeError;
}
}
if (val) {
if (ov.is_int64_type()) {
long long v=ov.int64_scalar_value().value();
if (v<0)
return SWIG_OverflowError;
*val = ov.int64_scalar_value().value();
} else if (ov.is_uint64_type()) {
*val = ov.uint64_scalar_value().value();
} else {
*val = ov.long_value();
}
if (val) {
if (ov.is_int64_type())
*val = ov.int64_scalar_value().value();
else if (ov.is_uint64_type())
*val = ov.uint64_scalar_value().value();
else
*val = ov.long_value();
}
return SWIG_OK;
}
return SWIG_OK;
}
}
%fragment(SWIG_From_frag(unsigned long long), "header")
{
SWIGINTERNINLINE octave_value SWIG_From_dec(unsigned long long)(unsigned long long value) {
return octave_uint64(value);
}
}
%fragment(SWIG_AsVal_frag(unsigned long long), "header")
{
SWIGINTERN int SWIG_AsVal_dec(unsigned long long)(const octave_value & ov, unsigned long long * val) {
if (!ov.is_scalar_type()) {
return SWIG_TypeError;
}
if (ov.is_complex_scalar()) {
return SWIG_TypeError;
}
if (ov.is_double_type() || ov.is_single_type()) {
double v = ov.double_value();
if (v < 0) {
return SWIG_OverflowError;
}
if (v != floor(v)) {
return SWIG_TypeError;
}
}
if (ov.is_int8_type() || ov.is_int16_type() ||
ov.is_int32_type()) {
long v = ov.long_value();
if (v < 0) {
return SWIG_OverflowError;
}
}
if (ov.is_int64_type()) {
long long v = ov.int64_scalar_value().value();
if (v < 0) {
return SWIG_OverflowError;
}
}
if (val) {
if (ov.is_int64_type()) {
*val = ov.int64_scalar_value().value();
} else if (ov.is_uint64_type()) {
*val = ov.uint64_scalar_value().value();
} else {
*val = ov.long_value();
}
}
return SWIG_OK;
}
}
// double
%fragment(SWIG_From_frag(double),"header") {
SWIGINTERNINLINE octave_value SWIG_From_dec(double) (double value)
{
return octave_value(value);
}
%fragment(SWIG_From_frag(double), "header")
{
SWIGINTERNINLINE octave_value SWIG_From_dec(double)(double value) {
return octave_value(value);
}
}
%fragment(SWIG_AsVal_frag(double),"header") {
SWIGINTERN int SWIG_AsVal_dec(double)(const octave_value& ov, double* val)
{
if (!ov.is_scalar_type())
return SWIG_TypeError;
if (ov.is_complex_scalar())
return SWIG_TypeError;
if (val)
*val = ov.double_value();
return SWIG_OK;
%fragment(SWIG_AsVal_frag(double), "header")
{
SWIGINTERN int SWIG_AsVal_dec(double)(const octave_value & ov, double * val) {
if (!ov.is_scalar_type()) {
return SWIG_TypeError;
}
if (ov.is_complex_scalar()) {
return SWIG_TypeError;
}
if (val) {
*val = ov.double_value();
}
return SWIG_OK;
}
}
// const char* (strings)
%fragment("SWIG_AsCharPtrAndSize","header") {
SWIGINTERN int
SWIG_AsCharPtrAndSize(octave_value ov, char** cptr, size_t* psize, int *alloc)
%fragment("SWIG_AsCharPtrAndSize", "header")
{
if (ov.is_cell() && ov.rows() == 1 && ov.columns() == 1)
ov = ov.cell_value()(0);
if (!ov.is_string())
return SWIG_TypeError;
std::string str=ov.string_value();
size_t len=str.size();
char* cstr=(char*)str.c_str();
if (alloc) {
*cptr = %new_copy_array(cstr, len + 1, char);
*alloc = SWIG_NEWOBJ;
} else if (cptr)
*cptr = cstr;
if (psize)
*psize = len + 1;
return SWIG_OK;
}
SWIGINTERN int
SWIG_AsCharPtrAndSize(octave_value ov, char** cptr, size_t * psize, int * alloc) {
if (ov.is_cell() && ov.rows() == 1 && ov.columns() == 1) {
ov = ov.cell_value()(0);
}
if (!ov.is_string()) {
return SWIG_TypeError;
}
std::string str = ov.string_value();
size_t len = str.size();
char* cstr = (char*) str.c_str();
if (alloc) {
*cptr = %new_copy_array(cstr, len + 1, char);
*alloc = SWIG_NEWOBJ;
} else if (cptr) {
*cptr = cstr;
}
if (psize) {
*psize = len + 1;
}
return SWIG_OK;
}
}
%fragment("SWIG_FromCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") {
SWIGINTERNINLINE octave_value
SWIG_FromCharPtrAndSize(const char* carray, size_t size)
%fragment("SWIG_FromCharPtrAndSize", "header", fragment = "SWIG_pchar_descriptor")
{
return std::string(carray,carray+size);
SWIGINTERNINLINE octave_value
SWIG_FromCharPtrAndSize(const char * carray, size_t size) {
return std::string(carray, carray + size);
}
}
}

File diff suppressed because it is too large Load diff

1203
Lib/octave/octrunclass.swg Normal file

File diff suppressed because it is too large Load diff

479
Lib/octave/octrundecl.swg Normal file
View file

@ -0,0 +1,479 @@
//
// octrundecl.swg - Declarations of Octave runtime code
//
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <octave/oct.h>
#include <octave/Cell.h>
#include <octave/dynamic-ld.h>
#include <octave/oct-env.h>
#include <octave/oct-map.h>
#include <octave/ov-fcn-handle.h>
#include <octave/parse.h>
#include <octave/toplev.h>
#include <octave/unwind-prot.h>
#include <octave/version.h>
////////// Determine Octave version //////////
// Macro for enabling features which require Octave version >= major.minor.patch
#define SWIG_OCTAVE_PREREQ(major, minor, patch) \
( (OCTAVE_MAJOR_VERSION<<16) + (OCTAVE_MINOR_VERSION<<8) + OCTAVE_PATCH_VERSION >= ((major)<<16) + ((minor)<<8) + (patch) )
// Reconstruct Octave major, minor, and patch versions for releases prior to 3.8.1
#if !defined(OCTAVE_MAJOR_VERSION)
# if !defined(OCTAVE_API_VERSION_NUMBER)
// Hack to distinguish between Octave 3.8.0, which removed OCTAVE_API_VERSION_NUMBER but did not yet
// introduce OCTAVE_MAJOR_VERSION, and Octave <= 3.2, which did not define OCTAVE_API_VERSION_NUMBER
# include <octave/ov.h>
# if defined(octave_ov_h)
# define OCTAVE_MAJOR_VERSION 3
# define OCTAVE_MINOR_VERSION 8
# define OCTAVE_PATCH_VERSION 0
# else
// Hack to distinguish between Octave 3.2 and earlier versions, before OCTAVE_API_VERSION_NUMBER existed
# define ComplexLU __ignore
# include <octave/CmplxLU.h>
# undef ComplexLU
# if defined(octave_Complex_LU_h)
// We know only that this version is prior to Octave 3.2, i.e. OCTAVE_API_VERSION_NUMBER < 37
# define OCTAVE_MAJOR_VERSION 3
# define OCTAVE_MINOR_VERSION 1
# define OCTAVE_PATCH_VERSION 99
# else
// OCTAVE_API_VERSION_NUMBER == 37
# define OCTAVE_MAJOR_VERSION 3
# define OCTAVE_MINOR_VERSION 2
# define OCTAVE_PATCH_VERSION 0
# endif // defined(octave_Complex_LU_h)
# endif // defined(octave_ov_h)
// Correlation between Octave API and version numbers extracted from Octave's
// ChangeLogs; version is the *earliest* released Octave with that API number
# elif OCTAVE_API_VERSION_NUMBER >= 48
# define OCTAVE_MAJOR_VERSION 3
# define OCTAVE_MINOR_VERSION 6
# define OCTAVE_PATCH_VERSION 0
# elif OCTAVE_API_VERSION_NUMBER >= 45
# define OCTAVE_MAJOR_VERSION 3
# define OCTAVE_MINOR_VERSION 4
# define OCTAVE_PATCH_VERSION 1
# elif OCTAVE_API_VERSION_NUMBER >= 42
# define OCTAVE_MAJOR_VERSION 3
# define OCTAVE_MINOR_VERSION 3
# define OCTAVE_PATCH_VERSION 54
# elif OCTAVE_API_VERSION_NUMBER >= 41
# define OCTAVE_MAJOR_VERSION 3
# define OCTAVE_MINOR_VERSION 3
# define OCTAVE_PATCH_VERSION 53
# elif OCTAVE_API_VERSION_NUMBER >= 40
# define OCTAVE_MAJOR_VERSION 3
# define OCTAVE_MINOR_VERSION 3
# define OCTAVE_PATCH_VERSION 52
# elif OCTAVE_API_VERSION_NUMBER >= 39
# define OCTAVE_MAJOR_VERSION 3
# define OCTAVE_MINOR_VERSION 3
# define OCTAVE_PATCH_VERSION 51
# else // OCTAVE_API_VERSION_NUMBER == 38
# define OCTAVE_MAJOR_VERSION 3
# define OCTAVE_MINOR_VERSION 3
# define OCTAVE_PATCH_VERSION 50
# endif // !defined(OCTAVE_API_VERSION_NUMBER)
#endif // !defined(OCTAVE_MAJOR_VERSION)
// Octave_map was renamed to octave_map in v3.3.52
#if !SWIG_OCTAVE_PREREQ(3,3,52)
#define octave_map Octave_map
#endif
////////// Declare/define SWIG interface function loadable by Octave //////////
#if !SWIG_OCTAVE_PREREQ(3,2,0)
#define SWIG_DEFUN(cname, wname, doc) DEFUNX_DLD(#cname, wname, FS ## cname, args, nargout, doc)
#else
#define SWIG_DEFUN(cname, wname, doc) DEFUNX_DLD(#cname, wname, G ## cname, args, nargout, doc)
#endif
////////// Define visibility of Octave runtime functions //////////
#define SWIGOCTRT SWIGRUNTIME
#define SWIGOCTRTINLINE SWIGOCTRT SWIGINLINE
////////// Octave implementations of SWIG runtime functions //////////
#define SWIG_fail goto fail
#define swig_owntype int
#define SWIG_MODULE_CLIENTDATA_TYPE void*
#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_ConvertPtr(obj, pptr, type, 0)
#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Octave_ConvertPacked(obj, ptr, sz, ty)
#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Octave_ConvertPacked(obj, ptr, sz, ty)
#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Octave_ConvertPtr(obj, pptr, type, flags)
#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Octave_ConvertPtr(obj, pptr, type, flags)
#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Octave_ConvertPtrAndOwn(obj, pptr, type, flags, own)
#define SWIG_GetModule(clientdata) SWIG_Octave_GetModule(clientdata)
#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_NewPointerObj(ptr, type, 0)
#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Octave_NewPackedObj(ptr, sz, type)
#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Octave_NewPackedObj(ptr, sz, type)
#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Octave_NewPointerObj(ptr, type, flags)
#define SWIG_Octave_AddErrorMsg(msg) {;}
#define SWIG_Octave_ConvertPtr(obj, pptr, type, flags) SWIG_Octave_ConvertPtrAndOwn(obj, pptr, type, flags, 0)
#define SWIG_Octave_ErrorOccurred() 0
#define SWIG_SetModule(clientdata, pointer) SWIG_Octave_SetModule(clientdata,pointer);
#define SWIG_DIRECTOR_CAST(ARG) dynamic_cast<Swig::Director *>(ARG)
// For backward compatibility only
#define SWIG_POINTER_EXCEPTION 0
#define SWIG_arg_fail(arg) 0
////////// Forward declarations of Octave runtime classes and types //////////
class SwigOctPacked;
class SwigOctRef;
class SwigOctType;
struct SwigOctClass;
struct SwigOctMember;
struct SwigOctValueRef;
typedef octave_value_list(*SwigOctFuncPtr)(const octave_value_list&, int);
#ifdef SWIG_DIRECTORS
namespace Swig
{
class Director;
typedef std::map < void* , Director* > rtdir_map;
}
#endif
////////// Declarations of Octave runtime functions //////////
SWIGOCTRT octave_value SWIG_Error(int code, const char* msg);
SWIGOCTRT octave_value SWIG_ErrorType(int code);
SWIGOCTRT octave_value_list* SWIG_Octave_AppendOutput(octave_value_list* ovl, const octave_value& ov);
SWIGOCTRT bool SWIG_Octave_CheckNumArgs(const char* func_name, int num_args, int max_args, int min_args, int varargs);
SWIGOCTRT int SWIG_Octave_ConvertPacked(const octave_value& ov, void* ptr, size_t sz, swig_type_info* type);
SWIGOCTRT int SWIG_Octave_ConvertPtrAndOwn(octave_value ov, void** ptr, swig_type_info* type, int flags, int* own);
SWIGOCTRTINLINE octave_value SWIG_Octave_GetGlobalValue(std::string name);
SWIGOCTRT swig_module_info* SWIG_Octave_GetModule(void* clientdata);
SWIGOCTRT swig_module_info* SWIG_Octave_GetModule(void* clientdata);
SWIGOCTRT void SWIG_Octave_LinkGlobalValue(std::string name);
SWIGOCTRT octave_value SWIG_Octave_NewPackedObj(void* ptr, size_t sz, swig_type_info* type);
SWIGOCTRT octave_value SWIG_Octave_NewPointerObj(void* ptr, swig_type_info* type, int flags);
SWIGOCTRTINLINE void SWIG_Octave_SetConstant(SwigOctType* module_ns, const std::string& name, const octave_value& ov);
SWIGOCTRT void SWIG_Octave_SetGlobalValue(std::string name, const octave_value& value);
SWIGOCTRT octave_value_list SWIG_Octave_SetImmutable(const octave_value_list& args, int nargout);
SWIGOCTRT void SWIG_Octave_SetModule(void* clientdata, swig_module_info* pointer);
SWIGOCTRT void SWIG_Octave_SetModule(void* clientdata, swig_module_info* pointer);
SWIGOCTRT SwigOctType* SWIG_Octave_ValueDeref(const octave_base_value& ov);
SWIGOCTRT SwigOctType* SWIG_Octave_ValueDeref(octave_value ov);
SWIGOCTRT octave_base_value* SWIG_Octave_ValueRef(SwigOctType* ost);
#ifdef SWIG_DIRECTORS
namespace Swig
{
SWIGOCTRTINLINE void erase_rtdir(void* vptr);
SWIGOCTRTINLINE Director* get_rtdir(void* vptr);
SWIGOCTRT rtdir_map* get_rtdir_map();
SWIGOCTRTINLINE void set_rtdir(void* vptr, Director* d);
SWIGOCTRT void swig_director_destroyed(SwigOctType* self, Director* d);
SWIGOCTRT SwigOctType* swig_director_get_self(Director* d);
SWIGOCTRT void swig_director_set_self(Director* d, SwigOctType* self);
}
SWIGOCTRT void swig_acquire_ownership(void* vptr);
SWIGOCTRT void swig_acquire_ownership_array(void* vptr);
SWIGOCTRT void swig_acquire_ownership_obj(void* vptr, int own);
#endif
////////// Declare Octave class: SwigOctMember //////////
struct SwigOctMember {
const char* name;
SwigOctFuncPtr method;
SwigOctFuncPtr get_method;
SwigOctFuncPtr set_method;
int flags; // 1=static, 2=global
const char* doc;
bool is_static() const {
return flags & 1;
}
bool is_global() const {
return flags & 2;
}
};
////////// Declare Octave class: SwigOctClass //////////
struct SwigOctClass {
const char* name;
swig_type_info** type;
int director;
SwigOctFuncPtr constructor;
const char* constructor_doc;
SwigOctFuncPtr destructor;
const SwigOctMember* members;
const char** base_names;
const swig_type_info** base;
};
////////// Declare Octave class: SwigOctValueRef //////////
struct SwigOctValueRef {
const octave_value_list& ovl;
int j;
SwigOctValueRef(const octave_value_list& _ovl, int _j)
: ovl(_ovl), j(_j) {
}
operator octave_value() const {
return ovl(j);
}
octave_value operator*() const {
return ovl(j);
}
};
////////// Declare Octave class: SwigOctType //////////
// SwigOctType plays the role of both the shadow class and the class
// representation within Octave, since there is no support for classes.
//
// These should really be decoupled, with the class support added to Octave
// and the shadow class given by an m-file script. That would dramatically
// reduce the runtime complexity, and be more in line w/ other modules.
class SwigOctType: public octave_base_value
{
struct cpp_ptr {
void* ptr;
bool destroyed;
cpp_ptr(void* _ptr) : ptr(_ptr), destroyed(false) {
}
};
typedef std::pair < const swig_type_info* , cpp_ptr > type_ptr_pair;
typedef std::pair < const SwigOctMember* , octave_value > member_value_pair;
typedef std::map < std::string, member_value_pair > member_map;
mutable swig_module_info* module;
const swig_type_info* construct_type; // type of special type object
std::vector < type_ptr_pair > types; // our c++ base classes
int own; // whether we call c++ destructors when we die
member_map members;
bool always_static;
SwigOctType(const SwigOctType& x);
SwigOctType& operator= (const SwigOctType& rhs);
bool dispatch_binary_op(const std::string& symbol, const octave_base_value& rhs, octave_value& ret);
bool dispatch_index_op(const std::string& symbol, const octave_value_list& rhs, octave_value_list& ret);
bool dispatch_unary_op(const std::string& symbol, octave_value& ret);
const swig_type_info* find_base(const std::string& name, const swig_type_info* base);
member_value_pair* find_member(const std::string& name, bool insert_if_not_found);
const SwigOctMember* find_member(const swig_type_info* type, const std::string& name);
void load_members(const SwigOctClass* c, member_map& out) const;
void load_members(member_map& out) const;
static octave_value make_value_hack(const octave_base_value& x);
octave_value_list member_deref(member_value_pair* m, const octave_value_list& args);
octave_value_list member_invoke(member_value_pair* m, const octave_value_list& args, int nargout);
public:
typedef member_map::const_iterator swig_member_const_iterator;
SwigOctType(void* _ptr = 0, const swig_type_info* _type = 0, int _own = 0, bool _always_static = false);
~SwigOctType();
octave_value as_value();
void assign(const std::string& name, const octave_value& ov);
void assign(const std::string& name, const SwigOctMember* m);
void* cast(swig_type_info* type, int* _own, int flags);
octave_base_value* clone() const;
virtual octave_value convert_to_str(bool pad = false, bool force = false, char type = '"') const;
virtual octave_value convert_to_str_internal(bool pad, bool force, char type) const;
void decref();
dim_vector dims(void) const;
static octave_value dispatch_binary_op(const octave_base_value& lhs, const octave_base_value& rhs, const char* op_name);
static bool dispatch_global_op(const std::string& symbol, const octave_value_list& args, octave_value& ret);
static octave_value dispatch_unary_op(const octave_base_value& x, const char* op_name);
octave_base_value* empty_clone() const;
const char* help_text() const;
void incref();
bool is_defined() const;
virtual bool is_map() const;
virtual bool is_object() const;
bool is_owned() const;
virtual bool is_string() const;
virtual bool load_ascii(std::istream& is);
virtual bool load_binary(std::istream& is, bool swap, oct_mach_info::float_format fmt);
virtual string_vector map_keys() const;
virtual octave_map map_value() const;
void merge(SwigOctType& rhs);
void print(std::ostream& os, bool pr_as_read_syntax = false) const;
virtual bool save_ascii(std::ostream& os);
virtual bool save_binary(std::ostream& os, bool& save_as_floats);
virtual std::string string_value(bool force = false) const;
octave_value subsasgn(const std::string& ops, const std::list < octave_value_list > &idx, const octave_value& rhs);
virtual octave_value subsref(const std::string& ops, const std::list < octave_value_list > &idx);
virtual octave_value_list subsref(const std::string& ops, const std::list < octave_value_list > &idx, int nargout);
swig_member_const_iterator swig_members_begin();
swig_member_const_iterator swig_members_end();
long swig_this() const;
std::string swig_type_name() const;
#ifdef HAVE_HDF5
virtual bool load_hdf5(hid_t loc_id, const char* name, bool have_h5giterate_bug);
virtual bool save_hdf5(hid_t loc_id, const char* name, bool save_as_floats);
#endif
#ifdef SWIG_DIRECTORS
void director_destroyed(Swig::Director* d);
#endif
};
////////// Declare Octave class: SwigOctType //////////
// Octave tries hard to preserve pass-by-value semantics. Eg, assignments
// will call clone() via make_unique() if there is more than one outstanding
// reference to the lhs, and forces the clone's reference count to 1
// (so you can't just increment your own count and return this).
//
// One way to fix this (without modifying Octave) is to add a level of
// indirection such that clone copies ref-counted pointer and we keep
// pass-by-ref semantics (which are more natural/expected for C++ bindings).
//
// Supporting both pass-by-{ref,value} and toggling via %feature/option
// might be nice.
class SwigOctRef: public octave_base_value
{
DECLARE_OCTAVE_ALLOCATOR;
DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA;
SwigOctType* ptr;
public:
SwigOctRef(SwigOctType* _ptr = 0);
~SwigOctRef();
octave_base_value* clone() const;
virtual octave_value convert_to_str(bool pad = false, bool force = false, char type = '"') const;
virtual octave_value convert_to_str_internal(bool pad, bool force, char type) const;
dim_vector dims(void) const;
octave_base_value* empty_clone() const;
SwigOctType* get_ptr() const;
bool is_defined() const;
virtual bool is_map() const;
virtual bool is_object() const;
virtual bool is_string() const;
virtual bool load_ascii(std::istream& is);
virtual bool load_binary(std::istream& is, bool swap, oct_mach_info::float_format fmt);
virtual string_vector map_keys() const;
virtual octave_map map_value() const;
void print(std::ostream& os, bool pr_as_read_syntax = false) const;
virtual bool save_ascii(std::ostream& os);
virtual bool save_binary(std::ostream& os, bool& save_as_floats);
virtual std::string string_value(bool force = false) const;
octave_value subsasgn(const std::string& ops, const std::list < octave_value_list > &idx, const octave_value& rhs);
virtual octave_value subsref(const std::string& ops, const std::list < octave_value_list > &idx);
virtual octave_value_list subsref(const std::string& ops, const std::list < octave_value_list > &idx, int nargout);
#ifdef HAVE_HDF5
virtual bool load_hdf5(hid_t loc_id, const char* name, bool have_h5giterate_bug);
virtual bool save_hdf5(hid_t loc_id, const char* name, bool save_as_floats);
#endif
};
////////// Declare Octave class: SwigOctPacked //////////
class SwigOctPacked: public octave_base_value
{
DECLARE_OCTAVE_ALLOCATOR;
DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA;
swig_type_info* type;
std::vector < char > buf;
public:
SwigOctPacked(swig_type_info* _type = 0, const void* _buf = 0, size_t _buf_len = 0);
octave_base_value* clone() const;
bool copy(swig_type_info* outtype, void* ptr, size_t sz) const;
octave_base_value* empty_clone() const;
bool is_defined() const;
virtual bool load_ascii(std::istream& is);
virtual bool load_binary(std::istream& is, bool swap, oct_mach_info::float_format fmt);
void print(std::ostream& os, bool pr_as_read_syntax = false) const;
virtual bool save_ascii(std::ostream& os);
virtual bool save_binary(std::ostream& os, bool& save_as_floats);
#ifdef HAVE_HDF5
virtual bool load_hdf5(hid_t loc_id, const char* name, bool have_h5giterate_bug);
virtual bool save_hdf5(hid_t loc_id, const char* name, bool save_as_floats);
#endif
};
////////// Declare Octave class: Swig::Director and related classes //////////
#ifdef SWIG_DIRECTORS
namespace Swig
{
class Director
{
SwigOctType* self;
bool swig_disowned;
Director(const Director& x);
Director& operator= (const Director& rhs);
public:
Director(void* vptr);
~Director();
void swig_disown();
SwigOctType* swig_get_self() const;
void swig_set_self(SwigOctType* new_self);
};
struct DirectorTypeMismatchException {
static void raise(const char* msg);
static void raise(const octave_value& ov, const char* msg);
};
struct DirectorPureVirtualException {
static void raise(const char* msg);
static void raise(const octave_value& ov, const char* msg);
};
}
#endif

187
Lib/octave/octrunfunc.swg Normal file
View file

@ -0,0 +1,187 @@
//
// octrunfunc.swg - Octave runtime functions
//
SWIGOCTRT bool SWIG_Octave_CheckNumArgs(const char* func_name, int num_args, int max_args, int min_args, int varargs)
{
if (num_args > max_args && !varargs) {
error("function %s takes at most %i arguments", func_name, max_args);
} else if (num_args < min_args) {
error("function %s requires at least %i arguments", func_name, min_args);
} else {
return true;
}
return false;
}
SWIGOCTRT octave_value_list* SWIG_Octave_AppendOutput(octave_value_list* ovl, const octave_value& ov)
{
ovl->append(ov);
return ovl;
}
SWIGOCTRT octave_value SWIG_ErrorType(int code)
{
switch (code) {
case SWIG_MemoryError:
return "SWIG_MemoryError";
case SWIG_IOError:
return "SWIG_IOError";
case SWIG_RuntimeError:
return "SWIG_RuntimeError";
case SWIG_IndexError:
return "SWIG_IndexError";
case SWIG_TypeError:
return "SWIG_TypeError";
case SWIG_DivisionByZero:
return "SWIG_DivisionByZero";
case SWIG_OverflowError:
return "SWIG_OverflowError";
case SWIG_SyntaxError:
return "SWIG_SyntaxError";
case SWIG_ValueError:
return "SWIG_ValueError";
case SWIG_SystemError:
return "SWIG_SystemError";
case SWIG_AttributeError:
return "SWIG_AttributeError";
}
return "SWIG unknown error";
}
SWIGOCTRT octave_value SWIG_Error(int code, const char* msg)
{
octave_value type(SWIG_ErrorType(code));
std::string r = msg;
r += " (" + type.string_value() + ")";
error(r.c_str());
return octave_value(r);
}
SWIGOCTRT octave_value SWIG_Octave_NewPointerObj(void* ptr, swig_type_info* type, int flags)
{
int own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0;
#ifdef SWIG_DIRECTORS
Swig::Director* d = Swig::get_rtdir(ptr);
if (d && Swig::swig_director_get_self(d)) {
return Swig::swig_director_get_self(d)->as_value();
}
#endif
return SWIG_Octave_ValueRef(new SwigOctType(ptr, type, own));
}
SWIGOCTRT int SWIG_Octave_ConvertPtrAndOwn(octave_value ov, void** ptr, swig_type_info* type, int flags, int* own)
{
if (ov.is_cell() && ov.rows() == 1 && ov.columns() == 1) {
ov = ov.cell_value()(0);
}
if (!ov.is_defined() || (ov.is_matrix_type() && ov.rows() == 0 && ov.columns() == 0)) {
if (ptr) {
*ptr = 0;
}
return SWIG_OK;
}
if (ov.type_id() != SwigOctRef::static_type_id()) {
return SWIG_ERROR;
}
SwigOctRef* osr = static_cast < SwigOctRef*>(ov.internal_rep());
SwigOctType* ost = osr->get_ptr();
void* vptr = ost->cast(type, own, flags);
if (!vptr) {
return SWIG_ERROR;
}
if (ptr) {
*ptr = vptr;
}
return SWIG_OK;
}
SWIGOCTRT octave_value SWIG_Octave_NewPackedObj(void* ptr, size_t sz, swig_type_info* type)
{
return new SwigOctPacked(type, (char*) ptr, sz);
}
SWIGOCTRT int SWIG_Octave_ConvertPacked(const octave_value& ov, void* ptr, size_t sz, swig_type_info* type)
{
if (!ov.is_defined()) {
return SWIG_ERROR;
}
if (ov.type_id() != SwigOctPacked::static_type_id()) {
return SWIG_ERROR;
}
SwigOctPacked* ost = static_cast < SwigOctPacked*>(ov.internal_rep());
return ost->copy(type, (char*) ptr, sz) ? SWIG_OK : SWIG_ERROR;
}
SWIGOCTRTINLINE void SWIG_Octave_SetConstant(SwigOctType* module_ns, const std::string& name, const octave_value& ov)
{
module_ns->assign(name, ov);
}
SWIGOCTRTINLINE octave_value SWIG_Octave_GetGlobalValue(std::string name)
{
return get_global_value(name, true);
}
SWIGOCTRT void SWIG_Octave_SetGlobalValue(std::string name, const octave_value& value)
{
set_global_value(name, value);
}
SWIGOCTRT void SWIG_Octave_LinkGlobalValue(std::string name)
{
#if !SWIG_OCTAVE_PREREQ(3,2,0)
link_to_global_variable(curr_sym_tab->lookup(name, true));
#else
#if !SWIG_OCTAVE_PREREQ(3,8,0)
symbol_table::varref(name);
#endif
symbol_table::mark_global(name);
#endif
}
SWIGOCTRT swig_module_info* SWIG_Octave_GetModule(void* clientdata)
{
octave_value ov = SWIG_Octave_GetGlobalValue("__SWIG_MODULE__" SWIG_TYPE_TABLE_NAME SWIG_RUNTIME_VERSION);
if (!ov.is_defined() || ov.type_id() != SwigOctPacked::static_type_id()) {
return 0;
}
const SwigOctPacked* osp = static_cast < const SwigOctPacked*>(ov.internal_rep());
swig_module_info* pointer = 0;
osp->copy(0, &pointer, sizeof(swig_module_info*));
return pointer;
}
SWIGOCTRT void SWIG_Octave_SetModule(void* clientdata, swig_module_info* pointer)
{
octave_value ov = new SwigOctPacked(0, &pointer, sizeof(swig_module_info*));
SWIG_Octave_SetGlobalValue("__SWIG_MODULE__" SWIG_TYPE_TABLE_NAME SWIG_RUNTIME_VERSION, ov);
}
SWIGOCTRT octave_base_value* SWIG_Octave_ValueRef(SwigOctType* ost)
{
return new SwigOctRef(ost);
}
SWIGOCTRT SwigOctType* SWIG_Octave_ValueDeref(octave_value ov)
{
if (ov.is_cell() && ov.rows() == 1 && ov.columns() == 1) {
ov = ov.cell_value()(0);
}
return SWIG_Octave_ValueDeref(*ov.internal_rep());
}
SWIGOCTRT SwigOctType* SWIG_Octave_ValueDeref(const octave_base_value& ov)
{
if (ov.type_id() != SwigOctRef::static_type_id()) {
return 0;
}
const SwigOctRef* osr = static_cast < const SwigOctRef*>(&ov);
return osr->get_ptr();
}
SWIGOCTRT octave_value_list SWIG_Octave_SetImmutable(const octave_value_list& args, int nargout)
{
error("attempt to set immutable member variable");
return octave_value_list();
}

422
Lib/octave/octruninit.swg Normal file
View file

@ -0,0 +1,422 @@
//
// octruninit.swg - Octave runtime initialisation code
//
// Forward declaration of module initialisation function
SWIGINTERN bool SWIG_Octave_InitUser(SwigOctType* module_ns);
////////// Define, register, and install unary and binary operator dispatch functions //////////
#define SWIG_Octave_UnaryOp(name) \
SWIGINTERN octave_value SWIG_Octave_UnaryOp_##name(const octave_base_value &x) { \
return SwigOctType::dispatch_unary_op(x,#name); \
}
#define SWIG_Octave_BinaryOp(name) \
SWIGINTERN octave_value SWIG_Octave_BinaryOp_##name(const octave_base_value&lhs,const octave_base_value &rhs) { \
return SwigOctType::dispatch_binary_op(lhs,rhs,#name); \
}
SWIG_Octave_UnaryOp(not);
SWIG_Octave_UnaryOp(uplus);
SWIG_Octave_UnaryOp(uminus);
SWIG_Octave_UnaryOp(transpose);
SWIG_Octave_UnaryOp(hermitian);
SWIG_Octave_UnaryOp(incr);
SWIG_Octave_UnaryOp(decr);
SWIG_Octave_BinaryOp(add);
SWIG_Octave_BinaryOp(sub);
SWIG_Octave_BinaryOp(mul);
SWIG_Octave_BinaryOp(div);
SWIG_Octave_BinaryOp(pow);
SWIG_Octave_BinaryOp(ldiv);
SWIG_Octave_BinaryOp(lshift);
SWIG_Octave_BinaryOp(rshift);
SWIG_Octave_BinaryOp(lt);
SWIG_Octave_BinaryOp(le);
SWIG_Octave_BinaryOp(eq);
SWIG_Octave_BinaryOp(ge);
SWIG_Octave_BinaryOp(gt);
SWIG_Octave_BinaryOp(ne);
SWIG_Octave_BinaryOp(el_mul);
SWIG_Octave_BinaryOp(el_div);
SWIG_Octave_BinaryOp(el_pow);
SWIG_Octave_BinaryOp(el_ldiv);
SWIG_Octave_BinaryOp(el_and);
SWIG_Octave_BinaryOp(el_or);
#define SWIG_Octave_RegisterUnaryOp(name) \
if (!octave_value_typeinfo::lookup_unary_op(octave_value::op_##name,tid)) \
octave_value_typeinfo::register_unary_op(octave_value::op_##name,tid,SWIG_Octave_UnaryOp_##name);
#define SWIG_Octave_RegisterBinaryOp(name) \
if (!octave_value_typeinfo::lookup_binary_op(octave_value::op_##name,tid1,tid2)) \
octave_value_typeinfo::register_binary_op(octave_value::op_##name,tid1,tid2,SWIG_Octave_BinaryOp_##name);
SWIGINTERN void SWIG_Octave_InstallUnaryOps(int tid)
{
SWIG_Octave_RegisterUnaryOp(not);
SWIG_Octave_RegisterUnaryOp(uplus);
SWIG_Octave_RegisterUnaryOp(uminus);
SWIG_Octave_RegisterUnaryOp(transpose);
SWIG_Octave_RegisterUnaryOp(hermitian);
SWIG_Octave_RegisterUnaryOp(incr);
SWIG_Octave_RegisterUnaryOp(decr);
}
SWIGINTERN void SWIG_Octave_InstallBinaryOps(int tid1, int tid2)
{
SWIG_Octave_RegisterBinaryOp(add);
SWIG_Octave_RegisterBinaryOp(sub);
SWIG_Octave_RegisterBinaryOp(mul);
SWIG_Octave_RegisterBinaryOp(div);
SWIG_Octave_RegisterBinaryOp(pow);
SWIG_Octave_RegisterBinaryOp(ldiv);
SWIG_Octave_RegisterBinaryOp(lshift);
SWIG_Octave_RegisterBinaryOp(rshift);
SWIG_Octave_RegisterBinaryOp(lt);
SWIG_Octave_RegisterBinaryOp(le);
SWIG_Octave_RegisterBinaryOp(eq);
SWIG_Octave_RegisterBinaryOp(ge);
SWIG_Octave_RegisterBinaryOp(gt);
SWIG_Octave_RegisterBinaryOp(ne);
SWIG_Octave_RegisterBinaryOp(el_mul);
SWIG_Octave_RegisterBinaryOp(el_div);
SWIG_Octave_RegisterBinaryOp(el_pow);
SWIG_Octave_RegisterBinaryOp(el_ldiv);
SWIG_Octave_RegisterBinaryOp(el_and);
SWIG_Octave_RegisterBinaryOp(el_or);
}
SWIGINTERN void SWIG_Octave_InstallOps(int tid)
{
// here we assume that tid are conseq integers increasing from zero, and
// that our tid is the last one. might be better to have explicit string
// list of types we should bind to, and use lookup_type to resolve their tid.
SWIG_Octave_InstallUnaryOps(tid);
SWIG_Octave_InstallBinaryOps(tid, tid);
for (int j = 0; j < tid; ++j) {
SWIG_Octave_InstallBinaryOps(j, tid);
SWIG_Octave_InstallBinaryOps(tid, j);
}
}
////////// Internal functions for loading/installing modules //////////
SWIGINTERN bool SWIG_Octave_LoadModule(std::string name)
{
bool retn;
{
#if !SWIG_OCTAVE_PREREQ(3,3,50)
unwind_protect::begin_frame("SWIG_Octave_LoadModule");
unwind_protect_int(error_state);
unwind_protect_int(warning_state);
unwind_protect_bool(discard_error_messages);
unwind_protect_bool(discard_warning_messages);
#else
unwind_protect frame;
frame.protect_var(error_state);
frame.protect_var(warning_state);
frame.protect_var(discard_error_messages);
frame.protect_var(discard_warning_messages);
#endif
error_state = 0;
warning_state = 0;
discard_error_messages = true;
discard_warning_messages = true;
feval(name, octave_value_list(), 0);
retn = (error_state == 0);
#if !SWIG_OCTAVE_PREREQ(3,3,50)
unwind_protect::run_frame("SWIG_Octave_LoadModule");
#endif
}
if (!retn) {
error(SWIG_name_d ": could not load module `%s'", name.c_str());
}
return retn;
}
SWIGINTERN bool SWIG_Octave_InstallFunction(octave_function* octloadfcn, std::string name)
{
bool retn;
{
#if !SWIG_OCTAVE_PREREQ(3,3,50)
unwind_protect::begin_frame("SWIG_Octave_InstallFunction");
unwind_protect_int(error_state);
unwind_protect_int(warning_state);
unwind_protect_bool(discard_error_messages);
unwind_protect_bool(discard_warning_messages);
#else
unwind_protect frame;
frame.protect_var(error_state);
frame.protect_var(warning_state);
frame.protect_var(discard_error_messages);
frame.protect_var(discard_warning_messages);
#endif
error_state = 0;
warning_state = 0;
discard_error_messages = true;
discard_warning_messages = true;
octave_value_list args;
args.append(name);
args.append(octloadfcn->fcn_file_name());
error_state = 0;
feval("autoload", args, 0);
retn = (error_state == 0);
#if !SWIG_OCTAVE_PREREQ(3,3,50)
unwind_protect::run_frame("SWIG_Octave_InstallFunction");
#endif
}
if (!retn) {
error(SWIG_name_d ": could not load function `%s'", name.c_str());
}
return retn;
}
////////// Public module function: swig_type() //////////
static const char* const swig_type_usage = "-*- texinfo -*- \n\
@deftypefn {Loadable Function} {} swig_type(@var{swigref})\n\
Return the underlying C/C++ type name of a SWIG-wrapped object.\n\
@end deftypefn";
DEFUN_DLD(swig_type, args, nargout, swig_type_usage)
{
if (args.length() != 1) {
error("swig_type: must be called with only a single object");
return octave_value_list();
}
SwigOctType* ost = SWIG_Octave_ValueDeref(args(0));
if (!ost) {
error("swig_type: object is not a swig_ref");
return octave_value_list();
}
return octave_value(ost->swig_type_name());
}
////////// Public module function: swig_typequery() //////////
static const char* const swig_typequery_usage = "-*- texinfo -*- \n\
@deftypefn {Loadable Function} {} swig_typequery(@var{string})\n\
Return @var{string} if it is a recognised SWIG-wrapped C/C++ type name;\n\
otherwise return `<unknown>'.\n\
@end deftypefn";
DEFUN_DLD(swig_typequery, args, nargout, swig_typequery_usage)
{
if (args.length() != 1 || !args(0).is_string()) {
error("swig_typequery: must be called with single string argument");
return octave_value_list();
}
swig_module_info* module = SWIG_GetModule(0);
swig_type_info* type = SWIG_TypeQueryModule(module, module, args(0).string_value().c_str());
if (!type) {
return octave_value("<unknown>");
}
return octave_value(type->name);
}
////////// Public module function: swig_this() //////////
static const char* const swig_this_usage = "-*- texinfo -*- \n\
@deftypefn {Loadable Function} {} swig_this(@var{swigref})\n\
Return the underlying C/C++ pointer of a SWIG-wrapped object.\n\
@end deftypefn";
DEFUN_DLD(swig_this, args, nargout, swig_this_usage)
{
if (args.length() != 1) {
error("swig_this: must be called with only a single object");
return octave_value_list();
}
if (args(0).is_matrix_type() && args(0).rows() == 0 && args(0).columns() == 0) {
return octave_value(octave_uint64(0));
}
SwigOctType* ost = SWIG_Octave_ValueDeref(args(0));
if (!ost) {
error("swig_this: object is not a swig_ref");
return octave_value_list();
}
return octave_value(octave_uint64((unsigned long long) ost->swig_this()));
}
////////// Public module function: subclass() //////////
static const char* const subclass_usage = "-*- texinfo -*- \n\
@deftypefn {Loadable Function} {} subclass()\n\
@deftypefnx{Loadable Function} {} subclass(@var{swigclass}, @var{name}, @var{fcn}, @dots{})\n\
Subclass a C++ class from within Octave, and provide implementations of its virtual methods.\n\
\n\
See the SWIG manual for usage examples.\n\
@end deftypefn";
DEFUN_DLD(subclass, args, nargout, subclass_usage)
{
SwigOctType* top = new SwigOctType;
for (int j = 0; j < args.length(); ++j) {
if (args(j).type_id() == SwigOctRef::static_type_id()) {
SwigOctRef* osr = static_cast < SwigOctRef*>(args(j).internal_rep());
SwigOctType* ost = osr->get_ptr();
if (!ost->is_owned()) {
error("subclass: cannot subclass object not constructed on octave side");
return octave_value_list();
}
top->merge(*ost);
} else if (args(j).is_function_handle()) {
top->assign(args(j).fcn_handle_value()->fcn_name(), args(j));
} else if (args(j).is_string()) {
if (j + 1 >= args.length()) {
error("subclass: member assignments must be of string,value form");
return octave_value_list();
}
top->assign(args(j).string_value(), args(j + 1));
++j;
} else {
error("subclass: invalid arguments to subclass()");
return octave_value_list();
}
}
return octave_value(SWIG_Octave_ValueRef(top));
}
////////// Public function which loads the Octave module //////////
static const char* const SWIG_name_usage = "-*- texinfo -*- \n\
@deftypefn {Loadable Module} {} " SWIG_name_d "\n\
Loads the SWIG-generated module `" SWIG_name_d "'.\n\
@end deftypefn";
DEFUN_DLD(SWIG_name, args, nargout, SWIG_name_usage)
{
static SwigOctType* module_ns = 0;
// workaround to prevent octave seg-faulting on exit: set Octave exit function
// octave_exit to _Exit, which exits immediately without trying to cleanup memory.
// definitely affects version 3.2.*, not sure about 3.3.*, seems to be fixed in
// version 3.4.* and above. can be turned off with macro definition.
#ifndef SWIG_OCTAVE_NO_SEGFAULT_HACK
#if SWIG_OCTAVE_PREREQ(3,2,0) && !SWIG_OCTAVE_PREREQ(3,4,1)
octave_exit = ::_Exit;
#endif
#endif
// check for no input and output args
if (args.length() != 0 || nargout != 0) {
print_usage();
return octave_value_list();
}
// create module on first function call
if (!module_ns) {
// workaround bug in octave where installing global variable of custom type and then
// exiting without explicitly clearing the variable causes octave to segfault.
#if SWIG_OCTAVE_PREREQ(3,2,0)
octave_value_list eval_args;
eval_args.append("base");
eval_args.append("function __swig_atexit__; "
" if mislocked() "
" clear -all; "
" else "
" mlock(); "
" endif; "
"endfunction; "
"__swig_atexit__; "
"atexit(\"__swig_atexit__\", false); "
"atexit(\"__swig_atexit__\")");
feval("evalin", eval_args, 0);
#endif
SwigOctRef::register_type();
SwigOctPacked::register_type();
SWIG_InitializeModule(0);
SWIG_PropagateClientData();
octave_function* me = octave_call_stack::current();
if (!SWIG_Octave_InstallFunction(me, "swig_type")) {
return octave_value_list();
}
if (!SWIG_Octave_InstallFunction(me, "swig_typequery")) {
return octave_value_list();
}
if (!SWIG_Octave_InstallFunction(me, "swig_this")) {
return octave_value_list();
}
if (!SWIG_Octave_InstallFunction(me, "subclass")) {
return octave_value_list();
}
SwigOctType* cvar_ns = 0;
if (std::string(SWIG_global_name) != ".") {
cvar_ns = new SwigOctType;
for (int j = 0; swig_globals[j].name; ++j)
if (swig_globals[j].get_method) {
cvar_ns->assign(swig_globals[j].name, &swig_globals[j]);
}
}
module_ns = new SwigOctType(0, 0, 0, true);
if (std::string(SWIG_global_name) != ".") {
module_ns->assign(SWIG_global_name, SWIG_Octave_ValueRef(cvar_ns));
} else {
for (int j = 0; swig_globals[j].name; ++j)
if (swig_globals[j].get_method) {
module_ns->assign(swig_globals[j].name, &swig_globals[j]);
}
}
for (int j = 0; swig_globals[j].name; ++j)
if (swig_globals[j].method) {
module_ns->assign(swig_globals[j].name, &swig_globals[j]);
}
// * need better solution here; swig_type -> octave_class mapping is
// * really n-to-1, in some cases such as template partial spec, etc.
// * see failing tests.
for (int j = 0; swig_types[j]; ++j)
if (swig_types[j]->clientdata) {
SwigOctClass* c = (SwigOctClass*) swig_types[j]->clientdata;
module_ns->assign(c->name,
SWIG_Octave_ValueRef
(new SwigOctType(0, swig_types[j])));
}
if (!SWIG_Octave_InitUser(module_ns)) {
delete module_ns;
module_ns = 0;
return octave_value_list();
}
SWIG_Octave_InstallOps(SwigOctRef::static_type_id());
SwigOctType::swig_member_const_iterator mb;
for (mb = module_ns->swig_members_begin(); mb != module_ns->swig_members_end(); ++mb) {
if (mb->second.first && mb->second.first->method) {
if (!SWIG_Octave_InstallFunction(me, mb->first)) {
return octave_value_list();
}
}
}
#if !SWIG_OCTAVE_PREREQ(3,2,0)
mlock(me->name());
#else
mlock();
#endif
}
SwigOctType::swig_member_const_iterator mb;
for (mb = module_ns->swig_members_begin(); mb != module_ns->swig_members_end(); ++mb) {
if (mb->second.second.is_defined()) {
SWIG_Octave_SetGlobalValue(mb->first, mb->second.second);
SWIG_Octave_LinkGlobalValue(mb->first);
}
}
SWIG_Octave_SetGlobalValue(SWIG_name_d, module_ns->as_value());
SWIG_Octave_LinkGlobalValue(SWIG_name_d);
return octave_value_list();
}

View file

@ -1,323 +1,20 @@
%insert(runtime) %{
#include <cstdlib>
#include <iostream>
#include <octave/oct.h>
#include <octave/Cell.h>
#include <octave/dynamic-ld.h>
#include <octave/oct-env.h>
#include <octave/oct-map.h>
#include <octave/ov-fcn-handle.h>
#include <octave/parse.h>
#include <octave/toplev.h>
#include <octave/unwind-prot.h>
%}
//
// octruntime.swg - Octave runtime code
//
%insert(runtime) "swigrun.swg";
%insert(runtime) "swigerrors.swg";
%insert(runtime) "octrun.swg";
// Insert standard SWIG runtime code
%insert("runtime") "swigrun.swg";
%insert("runtime") "swigerrors.swg";
%insert("initbeforefunc") "swiginit.swg"
%insert(initbeforefunc) "swiginit.swg"
// Declarations of Octave runtime code
%insert("runtime") "octrundecl.swg";
%insert(initbeforefunc) %{
// Octave runtime functions
%insert("runtime") "octrunfunc.swg"
static bool SWIG_init_user(octave_swig_type* module_ns);
// Octave runtime classes
%insert("runtime") "octrunclass.swg"
SWIGINTERN bool SWIG_Octave_LoadModule(std::string name) {
bool retn;
{
#if !SWIG_OCTAVE_PREREQ(3,3,50)
unwind_protect::begin_frame("SWIG_Octave_LoadModule");
unwind_protect_int(error_state);
unwind_protect_int(warning_state);
unwind_protect_bool(discard_error_messages);
unwind_protect_bool(discard_warning_messages);
#else
unwind_protect frame;
frame.protect_var(error_state);
frame.protect_var(warning_state);
frame.protect_var(discard_error_messages);
frame.protect_var(discard_warning_messages);
#endif
error_state = 0;
warning_state = 0;
discard_error_messages = true;
discard_warning_messages = true;
feval(name, octave_value_list(), 0);
retn = (error_state == 0);
#if !SWIG_OCTAVE_PREREQ(3,3,50)
unwind_protect::run_frame("SWIG_Octave_LoadModule");
#endif
}
if (!retn) {
error(SWIG_name_d ": could not load module `%s'", name.c_str());
}
return retn;
}
SWIGINTERN bool SWIG_Octave_InstallFunction(octave_function *octloadfcn, std::string name) {
bool retn;
{
#if !SWIG_OCTAVE_PREREQ(3,3,50)
unwind_protect::begin_frame("SWIG_Octave_InstallFunction");
unwind_protect_int(error_state);
unwind_protect_int(warning_state);
unwind_protect_bool(discard_error_messages);
unwind_protect_bool(discard_warning_messages);
#else
unwind_protect frame;
frame.protect_var(error_state);
frame.protect_var(warning_state);
frame.protect_var(discard_error_messages);
frame.protect_var(discard_warning_messages);
#endif
error_state = 0;
warning_state = 0;
discard_error_messages = true;
discard_warning_messages = true;
octave_value_list args;
args.append(name);
args.append(octloadfcn->fcn_file_name());
error_state = 0;
feval("autoload", args, 0);
retn = (error_state == 0);
#if !SWIG_OCTAVE_PREREQ(3,3,50)
unwind_protect::run_frame("SWIG_Octave_InstallFunction");
#endif
}
if (!retn) {
error(SWIG_name_d ": could not load function `%s'", name.c_str());
}
return retn;
}
static const char *const subclass_usage = "-*- texinfo -*- \n\
@deftypefn {Loadable Function} {} subclass()\n\
@deftypefnx{Loadable Function} {} subclass(@var{swigclass}, @var{name}, @var{fcn}, @dots{})\n\
Subclass a C++ class from within Octave, and provide implementations of its virtual methods.\n\
\n\
See the SWIG manual for usage examples.\n\
@end deftypefn";
DEFUN_DLD( subclass, args, nargout, subclass_usage ) {
octave_swig_type *top = new octave_swig_type;
for (int j = 0; j < args.length(); ++j) {
if (args(j).type_id() == octave_swig_ref::static_type_id()) {
octave_swig_ref *osr = static_cast < octave_swig_ref *>(args(j).internal_rep());
octave_swig_type *ost = osr->get_ptr();
if (!ost->is_owned()) {
error("subclass: cannot subclass object not constructed on octave side");
return octave_value_list();
}
top->merge(*ost);
} else if (args(j).is_function_handle()) {
top->assign(args(j).fcn_handle_value()->fcn_name(), args(j));
} else if (args(j).is_string()) {
if (j + 1 >= args.length()) {
error("subclass: member assignments must be of string,value form");
return octave_value_list();
}
top->assign(args(j).string_value(), args(j + 1));
++j;
} else {
error("subclass: invalid arguments to subclass()");
return octave_value_list();
}
}
return octave_value(Swig::swig_value_ref(top));
}
static const char *const swig_type_usage = "-*- texinfo -*- \n\
@deftypefn {Loadable Function} {} swig_type(@var{swigref})\n\
Return the underlying C/C++ type name of a SWIG-wrapped object.\n\
@end deftypefn";
DEFUN_DLD( swig_type, args, nargout, swig_type_usage ) {
if (args.length() != 1) {
error("swig_type: must be called with only a single object");
return octave_value_list();
}
octave_swig_type *ost = Swig::swig_value_deref(args(0));
if (!ost) {
error("swig_type: object is not a swig_ref");
return octave_value_list();
}
return octave_value(ost->swig_type_name());
}
static const char *const swig_typequery_usage = "-*- texinfo -*- \n\
@deftypefn {Loadable Function} {} swig_typequery(@var{string})\n\
Return @var{string} if it is a recognised SWIG-wrapped C/C++ type name;\n\
otherwise return `<unknown>'.\n\
@end deftypefn";
DEFUN_DLD( swig_typequery, args, nargout, swig_typequery_usage ) {
if (args.length() != 1 || !args(0).is_string()) {
error("swig_typequery: must be called with single string argument");
return octave_value_list();
}
swig_module_info *module = SWIG_GetModule(0);
swig_type_info *type = SWIG_TypeQueryModule(module, module, args(0).string_value().c_str());
if (!type)
return octave_value("<unknown>");
return octave_value(type->name);
}
static const char *const swig_this_usage = "-*- texinfo -*- \n\
@deftypefn {Loadable Function} {} swig_this(@var{swigref})\n\
Return the underlying C/C++ pointer of a SWIG-wrapped object.\n\
@end deftypefn";
DEFUN_DLD( swig_this, args, nargout, swig_this_usage ) {
if (args.length() != 1) {
error("swig_this: must be called with only a single object");
return octave_value_list();
}
if (args(0).is_matrix_type() && args(0).rows() == 0 && args(0).columns() == 0)
return octave_value(octave_uint64(0));
octave_swig_type *ost = Swig::swig_value_deref(args(0));
if (!ost) {
error("swig_this: object is not a swig_ref");
return octave_value_list();
}
return octave_value(octave_uint64((unsigned long long) ost->swig_this()));
}
static const char *const SWIG_name_usage = "-*- texinfo -*- \n\
@deftypefn {Loadable Module} {} " SWIG_name_d "\n\
Loads the SWIG-generated module `" SWIG_name_d "'.\n\
@end deftypefn";
DEFUN_DLD( SWIG_name, args, nargout, SWIG_name_usage ) {
static octave_swig_type* module_ns = 0;
// workaround to prevent octave seg-faulting on exit: set Octave exit function
// octave_exit to _Exit, which exits immediately without trying to cleanup memory.
// definitely affects version 3.2.*, not sure about 3.3.*, seems to be fixed in
// version 3.4.* and above. can be turned off with macro definition.
#ifndef SWIG_OCTAVE_NO_SEGFAULT_HACK
#if SWIG_OCTAVE_PREREQ(3,2,0) && !SWIG_OCTAVE_PREREQ(3,4,1)
octave_exit = ::_Exit;
#endif
#endif
// check for no input and output args
if (args.length() != 0 || nargout != 0) {
print_usage();
return octave_value_list();
}
// create module on first function call
if (!module_ns) {
// workaround bug in octave where installing global variable of custom type and then
// exiting without explicitly clearing the variable causes octave to segfault.
#if SWIG_OCTAVE_PREREQ(3,2,0)
octave_value_list eval_args;
eval_args.append("base");
eval_args.append("function __swig_atexit__; "
" if mislocked() "
" clear -all; "
" else "
" mlock(); "
" endif; "
"endfunction; "
"__swig_atexit__; "
"atexit(\"__swig_atexit__\", false); "
"atexit(\"__swig_atexit__\")");
feval("evalin", eval_args, 0);
#endif
octave_swig_ref::register_type();
octave_swig_packed::register_type();
SWIG_InitializeModule(0);
SWIG_PropagateClientData();
octave_function *me = octave_call_stack::current();
if (!SWIG_Octave_InstallFunction(me, "swig_type")) {
return octave_value_list();
}
if (!SWIG_Octave_InstallFunction(me, "swig_typequery")) {
return octave_value_list();
}
if (!SWIG_Octave_InstallFunction(me, "swig_this")) {
return octave_value_list();
}
if (!SWIG_Octave_InstallFunction(me, "subclass")) {
return octave_value_list();
}
octave_swig_type* cvar_ns=0;
if (std::string(SWIG_global_name) != ".") {
cvar_ns=new octave_swig_type;
for (int j=0;swig_globals[j].name;++j)
if (swig_globals[j].get_method)
cvar_ns->assign(swig_globals[j].name,&swig_globals[j]);
}
module_ns=new octave_swig_type(0, 0, 0, true);
if (std::string(SWIG_global_name) != ".") {
module_ns->assign(SWIG_global_name,Swig::swig_value_ref(cvar_ns));
}
else {
for (int j=0;swig_globals[j].name;++j)
if (swig_globals[j].get_method)
module_ns->assign(swig_globals[j].name,&swig_globals[j]);
}
for (int j=0;swig_globals[j].name;++j)
if (swig_globals[j].method)
module_ns->assign(swig_globals[j].name,&swig_globals[j]);
// * need better solution here; swig_type -> octave_class mapping is
// * really n-to-1, in some cases such as template partial spec, etc.
// * see failing tests.
for (int j=0;swig_types[j];++j)
if (swig_types[j]->clientdata) {
swig_octave_class* c=(swig_octave_class*)swig_types[j]->clientdata;
module_ns->assign(c->name,
Swig::swig_value_ref
(new octave_swig_type(0,swig_types[j])));
}
if (!SWIG_init_user(module_ns)) {
delete module_ns;
module_ns=0;
return octave_value_list();
}
SWIG_InstallOps(octave_swig_ref::static_type_id());
octave_swig_type::swig_member_const_iterator mb;
for (mb = module_ns->swig_members_begin(); mb != module_ns->swig_members_end(); ++mb) {
if (mb->second.first && mb->second.first->method) {
if (!SWIG_Octave_InstallFunction(me, mb->first)) {
return octave_value_list();
}
}
}
#if !SWIG_OCTAVE_PREREQ(3,2,0)
mlock(me->name());
#else
mlock();
#endif
}
octave_swig_type::swig_member_const_iterator mb;
for (mb = module_ns->swig_members_begin(); mb != module_ns->swig_members_end(); ++mb) {
if (mb->second.second.is_defined()) {
SWIG_Octave_SetGlobalValue(mb->first, mb->second.second);
SWIG_Octave_LinkGlobalValue(mb->first);
}
}
SWIG_Octave_SetGlobalValue(SWIG_name_d, module_ns->as_value());
SWIG_Octave_LinkGlobalValue(SWIG_name_d);
return octave_value_list();
}
%}
// Octave runtime initialisation code
%insert("initbeforefunc") "octruninit.swg"

View file

@ -1,226 +1,258 @@
%fragment("StdTraits","header",fragment="StdTraitsCommon")
//
// octstdcommon.swg - Octave common STL code
//
%fragment("StdTraits", "header", fragment = "StdTraitsCommon")
{
namespace swig {
// Traits that provides the from method
template <class Type> struct traits_from_ptr {
static octave_value from(Type *val, int owner = 0) {
return SWIG_NewPointerObj(val, type_info<Type>(), owner);
namespace swig
{
// Traits that provides the from method
template <class Type> struct traits_from_ptr {
static octave_value from(Type* val, int owner = 0) {
return SWIG_NewPointerObj(val, type_info<Type>(), owner);
}
};
template <class Type> struct traits_from {
static octave_value from(const Type& val) {
return traits_from_ptr<Type>::from(new Type(val), 1);
}
};
template <class Type> struct traits_from<Type*> {
static octave_value from(Type* val) {
return traits_from_ptr<Type>::from(val, 0);
}
};
template <class Type> struct traits_from<const Type*> {
static octave_value from(const Type* val) {
return traits_from_ptr<Type>::from(const_cast<Type*>(val), 0);
}
};
template <class Type>
inline octave_value from(const Type& val)
{
return traits_from<Type>::from(val);
}
};
template <class Type> struct traits_from {
static octave_value from(const Type& val) {
return traits_from_ptr<Type>::from(new Type(val), 1);
template <class Type>
inline octave_value from_ptr(Type* val, int owner)
{
return traits_from_ptr<Type>::from(val, owner);
}
};
template <class Type> struct traits_from<Type *> {
static octave_value from(Type* val) {
return traits_from_ptr<Type>::from(val, 0);
}
};
template <class Type> struct traits_from<const Type *> {
static octave_value from(const Type* val) {
return traits_from_ptr<Type>::from(const_cast<Type*>(val), 0);
}
};
template <class Type>
inline octave_value from(const Type& val) {
return traits_from<Type>::from(val);
}
template <class Type>
inline octave_value from_ptr(Type* val, int owner) {
return traits_from_ptr<Type>::from(val, owner);
}
// Traits that provides the asval/as/check method
template <class Type>
struct traits_asptr {
static int asptr(const octave_value& obj, Type **val) {
Type *p;
int res = SWIG_ConvertPtr(obj, (void**)&p, type_info<Type>(), 0);
if (SWIG_IsOK(res)) {
if (val) *val = p;
}
return res;
}
};
template <class Type>
inline int asptr(const octave_value& obj, Type **vptr) {
return traits_asptr<Type>::asptr(obj, vptr);
}
template <class Type>
struct traits_asval {
static int asval(const octave_value& obj, Type *val) {
if (val) {
Type *p = 0;
int res = traits_asptr<Type>::asptr(obj, &p);
if (!SWIG_IsOK(res)) return res;
if (p) {
typedef typename noconst_traits<Type>::noconst_type noconst_type;
*(const_cast<noconst_type*>(val)) = *p;
if (SWIG_IsNewObj(res)){
%delete(p);
res = SWIG_DelNewMask(res);
}
return res;
} else {
return SWIG_ERROR;
}
} else {
return traits_asptr<Type>::asptr(obj, (Type **)(0));
}
}
};
template <class Type> struct traits_asval<Type*> {
static int asval(const octave_value& obj, Type **val) {
if (val) {
typedef typename noconst_traits<Type>::noconst_type noconst_type;
noconst_type *p = 0;
int res = traits_asptr<noconst_type>::asptr(obj, &p);
template <class Type>
struct traits_asptr {
static int asptr(const octave_value& obj, Type** val) {
Type* p;
int res = SWIG_ConvertPtr(obj, (void**) &p, type_info<Type>(), 0);
if (SWIG_IsOK(res)) {
*(const_cast<noconst_type**>(val)) = p;
}
return res;
} else {
return traits_asptr<Type>::asptr(obj, (Type **)(0));
if (val) {
*val = p;
}
}
return res;
}
};
template <class Type>
inline int asptr(const octave_value& obj, Type** vptr)
{
return traits_asptr<Type>::asptr(obj, vptr);
}
};
template <class Type>
inline int asval(const octave_value& obj, Type *val) {
return traits_asval<Type>::asval(obj, val);
template <class Type>
struct traits_asval {
static int asval(const octave_value& obj, Type* val) {
if (val) {
Type* p = 0;
int res = traits_asptr<Type>::asptr(obj, &p);
if (!SWIG_IsOK(res)) {
return res;
}
if (p) {
typedef typename noconst_traits<Type>::noconst_type noconst_type;
* (const_cast<noconst_type*>(val)) = *p;
if (SWIG_IsNewObj(res)) {
%delete(p);
res = SWIG_DelNewMask(res);
}
return res;
} else {
return SWIG_ERROR;
}
} else {
return traits_asptr<Type>::asptr(obj, (Type**)(0));
}
}
};
template <class Type> struct traits_asval<Type*> {
static int asval(const octave_value& obj, Type** val) {
if (val) {
typedef typename noconst_traits<Type>::noconst_type noconst_type;
noconst_type* p = 0;
int res = traits_asptr<noconst_type>::asptr(obj, &p);
if (SWIG_IsOK(res)) {
* (const_cast<noconst_type**>(val)) = p;
}
return res;
} else {
return traits_asptr<Type>::asptr(obj, (Type**)(0));
}
}
};
template <class Type>
inline int asval(const octave_value& obj, Type* val)
{
return traits_asval<Type>::asval(obj, val);
}
template <class Type>
struct traits_as<Type, value_category> {
static Type as(const octave_value& obj, bool throw_error) {
Type v;
int res = asval(obj, &v);
if (!obj.is_defined() || !SWIG_IsOK(res)) {
if (!SWIG_Octave_ErrorOccurred()) {
%type_error(swig::type_name<Type>());
}
if (throw_error) {
throw std::invalid_argument("bad type");
}
}
return v;
}
};
template <class Type>
struct traits_as<Type, pointer_category> {
static Type as(const octave_value& obj, bool throw_error) {
Type* v = 0;
int res = traits_asptr<Type>::asptr(obj, &v);
if (SWIG_IsOK(res) && v) {
if (SWIG_IsNewObj(res)) {
Type r(*v);
%delete(v);
return r;
} else {
return *v;
}
} else {
// Uninitialized return value, no Type() constructor required.
static Type* v_def = (Type*) malloc(sizeof(Type));
if (!SWIG_Octave_ErrorOccurred()) {
%type_error(swig::type_name<Type>());
}
if (throw_error) {
throw std::invalid_argument("bad type");
}
memset(v_def, 0, sizeof(Type));
return *v_def;
}
}
};
template <class Type>
struct traits_as<Type*, pointer_category> {
static Type* as(const octave_value& obj, bool throw_error) {
Type* v = 0;
int res = traits_asptr<Type>::asptr(obj, &v);
if (SWIG_IsOK(res)) {
return v;
} else {
if (!SWIG_Octave_ErrorOccurred()) {
%type_error(swig::type_name<Type>());
}
if (throw_error) {
throw std::invalid_argument("bad type");
}
return 0;
}
}
};
template <class Type>
inline Type as(const octave_value& obj, bool te = false)
{
return traits_as<Type, typename traits<Type>::category>::as(obj, te);
}
template <class Type>
struct traits_check<Type, value_category> {
static bool check(const octave_value& obj) {
int res = asval(obj, (Type*)(0));
return SWIG_IsOK(res) ? true : false;
}
};
template <class Type>
struct traits_check<Type, pointer_category> {
static bool check(const octave_value& obj) {
int res = asptr(obj, (Type**)(0));
return SWIG_IsOK(res) ? true : false;
}
};
template <class Type>
inline bool check(const octave_value& obj)
{
return traits_check<Type, typename traits<Type>::category>::check(obj);
}
}
template <class Type>
struct traits_as<Type, value_category> {
static Type as(const octave_value& obj, bool throw_error) {
Type v;
int res = asval(obj, &v);
if (!obj.is_defined() || !SWIG_IsOK(res)) {
if (!Octave_Error_Occurred()) {
%type_error(swig::type_name<Type>());
}
if (throw_error) throw std::invalid_argument("bad type");
}
return v;
}
};
}
template <class Type>
struct traits_as<Type, pointer_category> {
static Type as(const octave_value& obj, bool throw_error) {
Type *v = 0;
int res = traits_asptr<Type>::asptr(obj, &v);
if (SWIG_IsOK(res) && v) {
if (SWIG_IsNewObj(res)) {
Type r(*v);
%delete(v);
return r;
} else {
return *v;
}
} else {
// Uninitialized return value, no Type() constructor required.
static Type *v_def = (Type*) malloc(sizeof(Type));
if (!Octave_Error_Occurred()) {
%type_error(swig::type_name<Type>());
}
if (throw_error) throw std::invalid_argument("bad type");
memset(v_def,0,sizeof(Type));
return *v_def;
}
}
};
%define %specialize_std_container(Type, Check, As, From)
%header %{
template <class Type>
struct traits_as<Type*, pointer_category> {
static Type* as(const octave_value& obj, bool throw_error) {
Type *v = 0;
int res = traits_asptr<Type>::asptr(obj, &v);
if (SWIG_IsOK(res)) {
return v;
} else {
if (!Octave_Error_Occurred()) {
%type_error(swig::type_name<Type>());
}
if (throw_error) throw std::invalid_argument("bad type");
return 0;
namespace swig {
template <>
struct traits_asval<Type > {
typedef Type value_type;
static int asval(const octave_value& obj, value_type* val) {
if (Check(obj)) {
if (val) {
*val = As(obj);
}
return SWIG_OK;
}
return SWIG_ERROR;
}
}
};
template <class Type>
inline Type as(const octave_value& obj, bool te = false) {
return traits_as<Type, typename traits<Type>::category>::as(obj, te);
};
template <>
struct traits_from<Type > {
typedef Type value_type;
static octave_value from(const value_type& val) {
return From(val);
}
};
template <>
struct traits_check<Type, value_category> {
static int check(const octave_value& obj) {
int res = Check(obj);
return obj && res ? res : 0;
}
};
}
template <class Type>
struct traits_check<Type, value_category> {
static bool check(const octave_value& obj) {
int res = asval(obj, (Type *)(0));
return SWIG_IsOK(res) ? true : false;
}
};
template <class Type>
struct traits_check<Type, pointer_category> {
static bool check(const octave_value& obj) {
int res = asptr(obj, (Type **)(0));
return SWIG_IsOK(res) ? true : false;
}
};
template <class Type>
inline bool check(const octave_value& obj) {
return traits_check<Type, typename traits<Type>::category>::check(obj);
}
}
}
%define %specialize_std_container(Type,Check,As,From)
%{
namespace swig {
template <> struct traits_asval<Type > {
typedef Type value_type;
static int asval(const octave_value& obj, value_type *val) {
if (Check(obj)) {
if (val) *val = As(obj);
return SWIG_OK;
}
return SWIG_ERROR;
}
};
template <> struct traits_from<Type > {
typedef Type value_type;
static octave_value from(const value_type& val) {
return From(val);
}
};
template <>
struct traits_check<Type, value_category> {
static int check(const octave_value& obj) {
int res = Check(obj);
return obj && res ? res : 0;
}
};
}
%}
%enddef
#define specialize_std_vector(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From)
#define specialize_std_list(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From)
#define specialize_std_deque(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From)
#define specialize_std_set(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From)
#define specialize_std_multiset(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From)

View file

@ -1,46 +1,45 @@
//
// octtypemaps.swg - Octave typemaps
//
// Include fundamental fragment definitions
%include <typemaps/fragments.swg>
// Look for user fragments file.
// Look for user fragments file
%include <octfragments.swg>
// Octave fragments for primitive types
%include <octprimtypes.swg>
// Octave fragments for char* strings
//%include <octstrings.swg>
#ifndef SWIG_DIRECTOR_TYPEMAPS
#define SWIG_DIRECTOR_TYPEMAPS
#endif
// Octave types
#define SWIG_Object octave_value
#define VOID_Object octave_value()
#define SWIG_Object octave_value
#define VOID_Object octave_value()
/*
// Octave allows implicit conversion
#define %implicitconv_flag $implicitconv
*/
//#define %implicitconv_flag $implicitconv
// append output
#define SWIG_AppendOutput(result, obj) SWIG_Octave_AppendOutput(result, obj)
// Append output
#define SWIG_AppendOutput(result, obj) SWIG_Octave_AppendOutput(result, obj)
// set constant
#define SWIG_SetConstant(name, obj) SWIG_Octave_SetConstant(module_ns,name,obj)
// Set constant
#define SWIG_SetConstant(name, obj) SWIG_Octave_SetConstant(module_ns,name,obj)
// raise
#define SWIG_Octave_Raise(OBJ, TYPE, DESC) error("C++ side threw an exception of type " TYPE)
#define SWIG_Raise(obj, type, desc) SWIG_Octave_Raise(obj, type, desc)
// Raise errors
#define SWIG_Octave_Raise(OBJ, TYPE, DESC) error("C++ side threw an exception of type " TYPE)
#define SWIG_Raise(obj, type, desc) SWIG_Octave_Raise(obj, type, desc)
// Include the unified typemap library
%include <typemaps/swigtypemaps.swg>
// Typechecks for Octave types
%typecheck(SWIG_TYPECHECK_SWIGOBJECT) SWIG_Object "$1 = (*$input).is_defined();";
%typecheck(SWIG_TYPECHECK_SWIGOBJECT) octave_value_list "$1 = true;";
// Typemaps for Octave types
%typemap(in) (octave_value_list varargs,...) {
for (int j=$argnum-1;j<args.length();++j)
$1.append(args(j));
@ -48,7 +47,6 @@
%typecheck(2000) (octave_value_list varargs,...) {
$1=1;
}
%typemap(in) (const octave_value_list& varargs,...) (octave_value_list tmp) {
for (int j=$argnum-1;j<args.length();++j)
tmp.append(args(j));
@ -57,7 +55,6 @@
%typecheck(2000) (const octave_value_list& varargs,...) {
$1=1;
}
%typemap(out) octave_value_list {
_outp->append($1);
}
@ -70,23 +67,3 @@
%typemap(out,noblock=1) Cell {
$result=$1;
}
/*
// Smart Pointers
%typemap(out,noblock=1) const SWIGTYPE & SMARTPOINTER {
$result = SWIG_NewPointerObj(%new_copy(*$1, $*ltype), $descriptor, SWIG_POINTER_OWN | %newpointer_flags);
}
%typemap(ret) const SWIGTYPE & SMARTPOINTER, SWIGTYPE SMARTPOINTER {
octave_swig_type* lobj=Swig::swig_value_deref($result);
if (lobj) {
std::list<octave_value_list> idx;
idx.push_back(octave_value("__deref__"));
idx.push_back(octave_value_list());
octave_value_list ovl(lobj->subsref(".(",idx));
octave_swig_type* robj=ovl.length()>=1?Swig::swig_value_deref(ovl(0)):0;
if (robj && !error_state)
lobj->append(robj);
}
}
*/

View file

@ -1,70 +1,65 @@
/* -------------------------------------------------------------------------
* Special user directives
* ------------------------------------------------------------------------- */
//
// octuserdir.swg - Octave special user directives
//
/* ------------------------------------------------------------------------- */
/*
Implicit Conversion using the C++ constructor mechanism
*/
// Document string directive
#define %docstring %feature("docstring")
#define %implicitconv %feature("implicitconv")
// Implicit conversion using the C++ constructor mechanism
#define %implicitconv %feature("implicitconv")
#define %noimplicitconv %feature("implicitconv", "0")
#define %clearimplicitconv %feature("implicitconv", "")
/* ------------------------------------------------------------------------- */
/*
%extend_smart_pointer extend the smart pointer support.
For example, if you have a smart pointer as:
template <class Type> class RCPtr {
public:
...
RCPtr(Type *p);
Type * operator->() const;
...
};
you use the %extend_smart_pointer directive as:
%extend_smart_pointer(RCPtr<A>);
%template(RCPtr_A) RCPtr<A>;
then, if you have something like:
RCPtr<A> make_ptr();
int foo(A *);
you can do the following:
a = make_ptr();
b = foo(a);
ie, swig will accept a RCPtr<A> object where a 'A *' is
expected.
Also, when using vectors
%extend_smart_pointer(RCPtr<A>);
%template(RCPtr_A) RCPtr<A>;
%template(vector_A) std::vector<RCPtr<A> >;
you can type
a = A();
v = vector_A(2)
v[0] = a
ie, an 'A *' object is accepted, via implicit conversion,
where a RCPtr<A> object is expected. Additionally
x = v[0]
returns (and sets 'x' as) a copy of v[0], making reference
counting possible and consistent.
*/
// %extend_smart_pointer: extend the smart pointer support.
//
// For example, if you have a smart pointer as:
//
// template <class Type> class RCPtr {
// public:
// ...
// RCPtr(Type *p);
// Type * operator->() const;
// ...
// };
//
// you use the %extend_smart_pointer directive as:
//
// %extend_smart_pointer(RCPtr<A>);
// %template(RCPtr_A) RCPtr<A>;
//
// then, if you have something like:
//
// RCPtr<A> make_ptr();
// int foo(A *);
//
// you can do the following:
//
// a = make_ptr();
// b = foo(a);
//
// ie, swig will accept a RCPtr<A> object where a 'A *' is
// expected.
//
// Also, when using vectors
//
// %extend_smart_pointer(RCPtr<A>);
// %template(RCPtr_A) RCPtr<A>;
// %template(vector_A) std::vector<RCPtr<A> >;
//
// you can type
//
// a = A();
// v = vector_A(2)
// v[0] = a
//
// ie, an 'A *' object is accepted, via implicit conversion,
// where a RCPtr<A> object is expected. Additionally
//
// x = v[0]
//
// returns (and sets 'x' as) a copy of v[0], making reference
// counting possible and consistent.
//
%define %extend_smart_pointer(Type...)
%implicitconv Type;
%apply const SWIGTYPE& SMARTPOINTER { const Type& };

View file

@ -1 +1,5 @@
//
// std_alloc.i - STL allocator support
//
%include <std/std_alloc.i>

View file

@ -1,4 +1,8 @@
#if !defined(SWIG_STD_STRING)
//
// std_basic_string.i - STL string support
//
#if !defined(SWIG_STD_STRING)
#define SWIG_STD_BASIC_STRING
#define SWIG_STD_MODERN_STL
@ -6,28 +10,25 @@
#define %swig_basic_string(Type...) %swig_sequence_methods_val(Type)
%fragment(SWIG_AsPtr_frag(std::basic_string<char>),"header",
fragment="SWIG_AsCharPtrAndSize") {
SWIGINTERN int
SWIG_AsPtr(std::basic_string<char>)(octave_value obj, std::string **val)
%fragment(SWIG_AsPtr_frag(std::basic_string<char>), "header", fragment = "SWIG_AsCharPtrAndSize")
{
if (obj.is_string()) {
if (val)
*val = new std::string(obj.string_value());
return SWIG_NEWOBJ;
SWIGINTERN int SWIG_AsPtr(std::basic_string<char>)(octave_value obj, std::string** val) {
if (obj.is_string()) {
if (val) {
*val = new std::string(obj.string_value());
}
return SWIG_NEWOBJ;
}
if (val) {
error("a string is expected");
}
return 0;
}
if (val)
error("a string is expected");
return 0;
}
}
%fragment(SWIG_From_frag(std::basic_string<char>),"header",
fragment="SWIG_FromCharPtrAndSize") {
SWIGINTERNINLINE octave_value
SWIG_From(std::basic_string<char>)(const std::string& s)
{
%fragment(SWIG_From_frag(std::basic_string<char>), "header", fragment = "SWIG_FromCharPtrAndSize")
{
SWIGINTERNINLINE octave_value SWIG_From(std::basic_string<char>)(const std::string & s) {
return SWIG_FromCharPtrAndSize(s.data(), s.size());
}
}
@ -35,51 +36,54 @@ SWIGINTERNINLINE octave_value
%ignore std::basic_string::operator +=;
%include <std/std_basic_string.i>
%typemaps_asptrfromn(%checkcode(STRING), std::basic_string<char>);
#endif
#if !defined(SWIG_STD_WSTRING)
%fragment(SWIG_AsPtr_frag(std::basic_string<wchar_t>),"header",
fragment="SWIG_AsWCharPtrAndSize") {
SWIGINTERN int
SWIG_AsPtr(std::basic_string<wchar_t>)(PyObject* obj, std::wstring **val)
{
static swig_type_info* string_info =
SWIG_TypeQuery("std::basic_string<wchar_t> *");
std::wstring *vptr;
if (SWIG_ConvertPtr(obj, (void**)&vptr, string_info, 0) == SWIG_OK) {
if (val) *val = vptr;
%fragment(SWIG_AsPtr_frag(std::basic_string<wchar_t>), "header", fragment = "SWIG_AsWCharPtrAndSize")
{
SWIGINTERN int SWIG_AsPtr(std::basic_string<wchar_t>)(PyObject * obj, std::wstring** val) {
static swig_type_info* string_info = SWIG_TypeQuery("std::basic_string<wchar_t> *");
std::wstring* vptr;
if (SWIG_ConvertPtr(obj, (void**) &vptr, string_info, 0) == SWIG_OK) {
if (val) {
*val = vptr;
}
return SWIG_OLDOBJ;
} else {
PyErr_Clear();
wchar_t *buf = 0 ; size_t size = 0; int alloc = 0;
wchar_t* buf = 0 ;
size_t size = 0;
int alloc = 0;
if (SWIG_AsWCharPtrAndSize(obj, &buf, &size, &alloc) == SWIG_OK) {
if (buf) {
if (val) *val = new std::wstring(buf, size - 1);
if (alloc == SWIG_NEWOBJ) %delete_array(buf);
return SWIG_NEWOBJ;
}
if (buf) {
if (val) {
*val = new std::wstring(buf, size - 1);
}
if (alloc == SWIG_NEWOBJ) {
%delete_array(buf);
}
return SWIG_NEWOBJ;
}
} else {
PyErr_Clear();
}
PyErr_Clear();
}
if (val) {
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
PyErr_SetString(PyExc_TypeError,"a wstring is expected");
SWIG_PYTHON_THREAD_END_BLOCK;
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
PyErr_SetString(PyExc_TypeError, "a wstring is expected");
SWIG_PYTHON_THREAD_END_BLOCK;
}
return 0;
}
}
}
%fragment(SWIG_From_frag(std::basic_string<wchar_t>),"header",
fragment="SWIG_FromWCharPtrAndSize") {
SWIGINTERNINLINE PyObject*
SWIG_From(std::basic_string<wchar_t>)(const std::wstring& s)
{
%fragment(SWIG_From_frag(std::basic_string<wchar_t>), "header", fragment = "SWIG_FromWCharPtrAndSize")
{
SWIGINTERNINLINE PyObject* SWIG_From(std::basic_string<wchar_t>)(const std::wstring & s) {
return SWIG_FromWCharPtrAndSize(s.data(), s.size());
}
}

View file

@ -0,0 +1,3 @@
//
// std_carray.i
//

View file

@ -1 +1,5 @@
//
// std_char_traits.i - STL character traits
//
%include <std/std_char_traits.i>

View file

@ -1,72 +1,82 @@
//
// std_common.i - Common STL support code
//
%include <std/std_except.i>
%include <octstdcommon.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(octave_value obj, value_type *val) {
return SWIG_AsVal(Type)(obj, val);
}
};
template <> struct traits_from<Type > {
typedef Type value_type;
static octave_value from(const value_type& val) {
return SWIG_From(Type)(val);
}
};
}
%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(octave_value obj, value_type* val) {
return SWIG_AsVal(Type)(obj, val);
}
};
template <> struct traits_from<Type > {
typedef Type value_type;
static octave_value 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. */
// 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(octave_value obj, value_type *val) {
return SWIG_AsVal(int)(obj, (int *)val);
}
};
template <> struct traits_from<Type > {
typedef Type value_type;
static octave_value 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
%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(octave_value obj, value_type* val) {
return SWIG_AsVal(int)(obj, (int*) val);
}
};
template <> struct traits_from<Type > {
typedef Type value_type;
static octave_value 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, ...)
//
// Generates the traits for all the known primitive C++ types (int, double, ...)
%apply_cpptypes(%traits_ptypen);

View file

@ -1,22 +1,17 @@
/*
* STD C++ complex typemaps
*/
//
// std_complex.i - STL complex typemaps
//
%include <octcomplex.swg>
%{
#include <complex>
%header %{
#include <complex>
%}
/* defining the complex as/from converters */
// Define the complex as/from converters
%swig_cplxdbl_convn(std::complex<double>, std::complex<double>, std::real, std::imag)
%swig_cplxflt_convn(std::complex<float>, std::complex<float>, std::real, std::imag)
/* defining the typemaps */
// Define the typemaps
%typemaps_primitive(%checkcode(CPLXDBL), std::complex<double>);
%typemaps_primitive(%checkcode(CPLXFLT), std::complex<float>);

View file

@ -1,2 +1,6 @@
//
// std_container.i - STL container support
//
%include <octcontainer.swg>
%include <std/std_container.i>

View file

@ -1,22 +1,29 @@
// Deques
//
// std_deque.i - STL deque support
//
%fragment("StdDequeTraits","header",fragment="StdSequenceTraits")
%fragment("StdDequeTraits", "header", fragment = "StdSequenceTraits")
%{
namespace swig {
namespace swig
{
template <class T>
struct traits_asptr<std::deque<T> > {
static int asptr(octave_value obj, std::deque<T> **vec) {
return traits_asptr_stdseq<std::deque<T> >::asptr(obj, vec);
static int asptr(octave_value obj, std::deque<T> **vec) {
return traits_asptr_stdseq<std::deque<T> >::asptr(obj, vec);
}
};
template <class T>
struct traits_from<std::deque<T> > {
static octave_value from(const std::deque<T> & vec) {
return traits_from_stdseq<std::deque<T> >::from(vec);
return traits_from_stdseq<std::deque<T> >::from(vec);
}
};
}
%}
#define %swig_deque_methods(Type...) %swig_sequence_methods(Type)

View file

@ -1 +1,5 @@
//
// std_except.i - STL exception support
//
%include <typemaps/std_except.swg>

View file

@ -1,26 +1,32 @@
// Lists
//
// std_list.i - STL list support
//
%fragment("StdListTraits","header",fragment="StdSequenceTraits")
%fragment("StdListTraits", "header", fragment = "StdSequenceTraits")
%{
namespace swig {
namespace swig
{
template <class T >
struct traits_asptr<std::list<T> > {
static int asptr(const octave_value& obj, std::list<T> **lis) {
return traits_asptr_stdseq<std::list<T> >::asptr(obj, lis);
return traits_asptr_stdseq<std::list<T> >::asptr(obj, lis);
}
};
template <class T>
struct traits_from<std::list<T> > {
static octave_value *from(const std::list<T> & vec) {
return traits_from_stdseq<std::list<T> >::from(vec);
static octave_value* from(const std::list<T> & vec) {
return traits_from_stdseq<std::list<T> >::from(vec);
}
};
}
%}
#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>

View file

@ -1,156 +1,125 @@
// Maps
//
// std_map.i - STL map support
//
%include <octcontainer.swg>
%fragment("StdMapCommonTraits","header",fragment="StdSequenceTraits")
%fragment("StdMapCommonTraits", "header", fragment = "StdSequenceTraits")
{
namespace swig {
namespace swig
{
template <class ValueType>
struct from_key_oper
{
struct from_key_oper {
typedef const ValueType& argument_type;
typedef octave_value result_type;
result_type operator()(argument_type v) const
{
return swig::from(v.first);
result_type operator()(argument_type v) const {
return swig::from(v.first);
}
};
template <class ValueType>
struct from_value_oper
{
struct from_value_oper {
typedef const ValueType& argument_type;
typedef octave_value result_type;
result_type operator()(argument_type v) const
{
return swig::from(v.second);
result_type operator()(argument_type v) const {
return swig::from(v.second);
}
};
template<class OutIterator, class FromOper, class ValueType = typename OutIterator::value_type>
struct OctMapIterator_T : OctSwigIteratorClosed_T<OutIterator, ValueType, FromOper>
{
struct OctMapIterator_T : OctIteratorClosed_T<OutIterator, ValueType, FromOper> {
OctMapIterator_T(OutIterator curr, OutIterator first, OutIterator last, octave_value seq)
: OctSwigIteratorClosed_T<OutIterator,ValueType,FromOper>(curr, first, last, seq)
{
: OctIteratorClosed_T<OutIterator, ValueType, FromOper> (curr, first, last, seq) {
}
};
template<class OutIterator,
class FromOper = from_key_oper<typename OutIterator::value_type> >
struct OctMapKeyIterator_T : OctMapIterator_T<OutIterator, FromOper>
{
template < class OutIterator, class FromOper = from_key_oper<typename OutIterator::value_type> >
struct OctMapKeyIterator_T : OctMapIterator_T<OutIterator, FromOper> {
OctMapKeyIterator_T(OutIterator curr, OutIterator first, OutIterator last, octave_value seq)
: OctMapIterator_T<OutIterator, FromOper>(curr, first, last, seq)
{
: OctMapIterator_T<OutIterator, FromOper> (curr, first, last, seq) {
}
};
template<typename OutIter>
inline OctSwigIterator*
make_output_key_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, octave_value seq = octave_value())
inline OctIterator* make_output_key_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, octave_value seq = octave_value())
{
return new OctMapKeyIterator_T<OutIter>(current, begin, end, seq);
return new OctMapKeyIterator_T<OutIter> (current, begin, end, seq);
}
template<class OutIterator,
class FromOper = from_value_oper<typename OutIterator::value_type> >
struct OctMapValueIterator_T : OctMapIterator_T<OutIterator, FromOper>
{
template < class OutIterator, class FromOper = from_value_oper<typename OutIterator::value_type> >
struct OctMapValueIterator_T : OctMapIterator_T<OutIterator, FromOper> {
OctMapValueIterator_T(OutIterator curr, OutIterator first, OutIterator last, octave_value seq)
: OctMapIterator_T<OutIterator, FromOper>(curr, first, last, seq)
{
: OctMapIterator_T<OutIterator, FromOper> (curr, first, last, seq) {
}
};
template<typename OutIter>
inline OctSwigIterator*
inline OctIterator*
make_output_value_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, octave_value seq = 0)
{
return new OctMapValueIterator_T<OutIter>(current, begin, end, seq);
return new OctMapValueIterator_T<OutIter> (current, begin, end, seq);
}
}
}
%fragment("StdMapTraits","header",fragment="StdMapCommonTraits")
%fragment("StdMapTraits", "header", fragment = "StdMapCommonTraits")
{
namespace swig {
namespace swig
{
template <class OctSeq, class K, class T >
inline void
assign(const OctSeq& octseq, std::map<K,T > *map) {
typedef typename std::map<K,T>::value_type value_type;
assign(const OctSeq& octseq, std::map<K, T > *map)
{
typedef typename std::map<K, T>::value_type value_type;
typename OctSeq::const_iterator it = octseq.begin();
for (;it != octseq.end(); ++it) {
map->insert(value_type(it->first, it->second));
for (; it != octseq.end(); ++it) {
map->insert(value_type(it->first, it->second));
}
}
template <class K, class T>
struct traits_asptr<std::map<K,T> > {
typedef std::map<K,T> map_type;
static int asptr(octave_value obj, map_type **val) {
/*
int res = SWIG_ERROR;
if (PyDict_Check(obj)) {
SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL);
res = traits_asptr_stdseq<std::map<K,T>, std::pair<K, T> >::asptr(items, val);
} else {
map_type *p;
res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<map_type>(),0);
if (SWIG_IsOK(res) && val) *val = p;
}
return res;
*/
return SWIG_ERROR;
}
struct traits_asptr<std::map<K, T> > {
typedef std::map<K, T> map_type;
static int asptr(octave_value obj, map_type** val) {
// * todo
return SWIG_ERROR;
}
};
template <class K, class T >
struct traits_from<std::map<K,T> > {
typedef std::map<K,T> map_type;
struct traits_from<std::map<K, T> > {
typedef std::map<K, T> map_type;
typedef typename map_type::const_iterator const_iterator;
typedef typename map_type::size_type size_type;
static octave_value from(const map_type& map) {
/*
swig_type_info *desc = swig::type_info<map_type>();
if (desc && desc->clientdata) {
return SWIG_NewPointerObj(new map_type(map), desc, SWIG_POINTER_OWN);
} else {
size_type size = map.size();
int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1;
if (pysize < 0) {
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
PyErr_SetString(PyExc_OverflowError,
"map size not valid in python");
SWIG_PYTHON_THREAD_END_BLOCK;
return NULL;
}
PyObject *obj = PyDict_New();
for (const_iterator i= map.begin(); i!= map.end(); ++i) {
swig::SwigVar_PyObject key = swig::from(i->first);
swig::SwigVar_PyObject val = swig::from(i->second);
PyDict_SetItem(obj, key, val);
}
return obj;
}
*/
return octave_value();
// * todo
return octave_value();
}
};
}
}
%define %swig_map_common(Map...)
%swig_sequence_iterator(Map);
%swig_container_methods(Map);
%swig_sequence_iterator(Map);
%swig_container_methods(Map);
%enddef
%define %swig_map_methods(Map...)
%swig_map_common(Map)
%swig_map_common(Map)
%enddef
%include <std/std_map.i>

View file

@ -1,129 +1,145 @@
// Pairs
//
// std_pair.i - STL pair support
//
%include <octstdcommon.swg>
//#define SWIG_STD_PAIR_ASVAL
%fragment("StdPairTraits","header",fragment="StdTraits") {
namespace swig {
#ifdef SWIG_STD_PAIR_ASVAL
template <class T, class U >
struct traits_asval<std::pair<T,U> > {
typedef std::pair<T,U> value_type;
%fragment("StdPairTraits", "header", fragment = "StdTraits")
{
namespace swig
{
static int get_pair(const octave_value& first, octave_value second,
std::pair<T,U> *val)
{
if (val) {
T *pfirst = &(val->first);
int res1 = swig::asval(first, pfirst);
if (!SWIG_IsOK(res1))
return res1;
U *psecond = &(val->second);
int res2 = swig::asval(second, psecond);
if (!SWIG_IsOK(res2))
return res2;
return res1 > res2 ? res1 : res2;
} else {
T *pfirst = 0;
int res1 = swig::asval(first, pfirst);
if (!SWIG_IsOK(res1))
return res1;
U *psecond = 0;
int res2 = swig::asval((PyObject*)second, psecond);
if (!SWIG_IsOK(res2))
return res2;
return res1 > res2 ? res1 : res2;
}
#ifdef SWIG_STD_PAIR_ASVAL
template <class T, class U >
struct traits_asval<std::pair<T, U> > {
typedef std::pair<T, U> value_type;
static int get_pair(const octave_value& first, octave_value second, std::pair<T, U> *val) {
if (val) {
T* pfirst = & (val->first);
int res1 = swig::asval(first, pfirst);
if (!SWIG_IsOK(res1)) {
return res1;
}
U* psecond = & (val->second);
int res2 = swig::asval(second, psecond);
if (!SWIG_IsOK(res2)) {
return res2;
}
return res1 > res2 ? res1 : res2;
} else {
T* pfirst = 0;
int res1 = swig::asval(first, pfirst);
if (!SWIG_IsOK(res1)) {
return res1;
}
U* psecond = 0;
int res2 = swig::asval((PyObject*) second, psecond);
if (!SWIG_IsOK(res2)) {
return res2;
}
return res1 > res2 ? res1 : res2;
}
}
static int asval(const octave_value& obj, std::pair<T,U> *val) {
if (obj.is_cell()) {
Cell c=obj.cell_value();
if (c.numel()<2) {
error("pair from Cell array requires at least two elements");
return SWIG_ERROR;
}
return get_pair(c(0),c(1),val);
} else {
value_type *p;
int res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<value_type>(),0);
if (SWIG_IsOK(res) && val)
*val = *p;
return res;
}
return SWIG_ERROR;
static int asval(const octave_value& obj, std::pair<T, U> *val) {
if (obj.is_cell()) {
Cell c = obj.cell_value();
if (c.numel() < 2) {
error("pair from Cell array requires at least two elements");
return SWIG_ERROR;
}
return get_pair(c(0), c(1), val);
} else {
value_type* p;
int res = SWIG_ConvertPtr(obj, (void**) &p, swig::type_info<value_type>(), 0);
if (SWIG_IsOK(res) && val) {
*val = *p;
}
return res;
}
return SWIG_ERROR;
}
};
#else
template <class T, class U >
struct traits_asptr<std::pair<T,U> > {
typedef std::pair<T,U> value_type;
static int get_pair(const octave_value& first, octave_value second,
std::pair<T,U> **val)
{
if (val) {
value_type *vp = %new_instance(std::pair<T,U>);
T *pfirst = &(vp->first);
int res1 = swig::asval(first, pfirst);
if (!SWIG_IsOK(res1))
return res1;
U *psecond = &(vp->second);
int res2 = swig::asval(second, psecond);
if (!SWIG_IsOK(res2))
return res2;
*val = vp;
return SWIG_AddNewMask(res1 > res2 ? res1 : res2);
} else {
T *pfirst = 0;
int res1 = swig::asval(first, pfirst);
if (!SWIG_IsOK(res1))
return res1;
U *psecond = 0;
int res2 = swig::asval(second, psecond);
if (!SWIG_IsOK(res2))
return res2;
return res1 > res2 ? res1 : res2;
}
return SWIG_ERROR;
template <class T, class U >
struct traits_asptr<std::pair<T, U> > {
typedef std::pair<T, U> value_type;
static int get_pair(const octave_value& first, octave_value second, std::pair<T, U> **val) {
if (val) {
value_type* vp = %new_instance(std::pair<T, U>);
T* pfirst = & (vp->first);
int res1 = swig::asval(first, pfirst);
if (!SWIG_IsOK(res1)) {
return res1;
}
U* psecond = & (vp->second);
int res2 = swig::asval(second, psecond);
if (!SWIG_IsOK(res2)) {
return res2;
}
*val = vp;
return SWIG_AddNewMask(res1 > res2 ? res1 : res2);
} else {
T* pfirst = 0;
int res1 = swig::asval(first, pfirst);
if (!SWIG_IsOK(res1)) {
return res1;
}
U* psecond = 0;
int res2 = swig::asval(second, psecond);
if (!SWIG_IsOK(res2)) {
return res2;
}
return res1 > res2 ? res1 : res2;
}
return SWIG_ERROR;
}
static int asptr(const octave_value& obj, std::pair<T,U> **val) {
if (obj.is_cell()) {
Cell c=obj.cell_value();
if (c.numel()<2) {
error("pair from Cell array requires at least two elements");
return SWIG_ERROR;
}
return get_pair(c(0),c(1),val);
} else {
value_type *p;
int res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<value_type>(),0);
if (SWIG_IsOK(res) && val)
*val = p;
return res;
}
return SWIG_ERROR;
static int asptr(const octave_value& obj, std::pair<T, U> **val) {
if (obj.is_cell()) {
Cell c = obj.cell_value();
if (c.numel() < 2) {
error("pair from Cell array requires at least two elements");
return SWIG_ERROR;
}
return get_pair(c(0), c(1), val);
} else {
value_type* p;
int res = SWIG_ConvertPtr(obj, (void**) &p, swig::type_info<value_type>(), 0);
if (SWIG_IsOK(res) && val) {
*val = p;
}
return res;
}
return SWIG_ERROR;
}
};
#endif
template <class T, class U >
struct traits_from<std::pair<T,U> > {
static octave_value from(const std::pair<T,U>& val) {
Cell c(1,2);
c(0)=swig::from(val.first);
c(1)=swig::from(val.second);
return c;
struct traits_from<std::pair<T, U> > {
static octave_value from(const std::pair<T, U>& val) {
Cell c(1, 2);
c(0) = swig::from(val.first);
c(1) = swig::from(val.second);
return c;
}
};
}
}
%define %swig_pair_methods(pair...)
%enddef
%include <std/std_pair.i>

View file

@ -1 +1,5 @@
//
// std_string.i - STL string support
//
%include <typemaps/std_string.swg>

View file

@ -1,19 +1,21 @@
// Vectors
//
// std_vector.i - STL vector support
//
%fragment("StdVectorTraits","header",fragment="StdSequenceTraits")
%fragment("StdVectorTraits", "header", fragment = "StdSequenceTraits")
%{
namespace swig {
template <class T>
struct traits_asptr<std::vector<T> > {
static int asptr(const octave_value& obj, std::vector<T> **vec) {
return traits_asptr_stdseq<std::vector<T> >::asptr(obj, vec);
return traits_asptr_stdseq<std::vector<T> >::asptr(obj, vec);
}
};
template <class T>
struct traits_from<std::vector<T> > {
static octave_value from(const std::vector<T>& vec) {
return traits_from_stdseq<std::vector<T> >::from(vec);
return traits_from_stdseq<std::vector<T> >::from(vec);
}
};
}
@ -23,4 +25,3 @@
#define %swig_vector_methods_val(Type...) %swig_sequence_methods_val(Type);
%include <std/std_vector.i>

View file

@ -1,4 +1,7 @@
/* initial STL definition. extended as needed in each language */
//
// stl.i - STL support
//
%include <std_common.i>
%include <std_string.i>
%include <std_vector.i>

View file

@ -1 +1,5 @@
//
// typemaps.i - Standard typemaps
//
%include <typemaps/typemaps.swg>

View file

@ -205,8 +205,8 @@ public:
Printf(f_runtime, "\n");
Printf(s_global_tab, "\nstatic const struct swig_octave_member swig_globals[] = {\n");
Printf(f_init, "static bool SWIG_init_user(octave_swig_type* module_ns)\n{\n");
Printf(s_global_tab, "\nstatic const struct SwigOctMember swig_globals[] = {\n");
Printf(f_init, "SWIGINTERN bool SWIG_Octave_InitUser(SwigOctType* module_ns)\n{\n");
if (!CPlusPlus) {
Printf(f_header, "extern \"C\" {\n");
@ -222,10 +222,6 @@ public:
emit_doc_texinfo();
}
if (directorsEnabled()) {
Swig_insert_file("director.swg", f_runtime);
}
Printf(f_init, "return true;\n}\n");
Printf(s_global_tab, "{0,0,0,0,0}\n};\n");
@ -590,7 +586,7 @@ public:
int varargs = emit_isvarargs(l);
char source[64];
Printf(w->code, "if (!SWIG_check_num_args(\"%s\",args.length(),%i,%i,%i)) "
Printf(w->code, "if (!SWIG_Octave_CheckNumArgs(\"%s\",args.length(),%i,%i,%i)) "
"{\n SWIG_fail;\n }\n", iname, num_arguments, num_required, varargs);
if (constructor && num_arguments == 1 && num_required == 1) {
@ -811,9 +807,9 @@ public:
Octave_begin_function(n, w->def, iname, wname, true);
Wrapper_add_local(w, "argc", "int argc = args.length()");
Printf(tmp, "octave_value_ref argv[%d]={", maxargs);
Printf(tmp, "SwigOctValueRef argv[%d] = {", maxargs);
for (int j = 0; j < maxargs; ++j) {
Printf(tmp, "%soctave_value_ref(args,%d)", j ? "," : " ", j);
Printf(tmp, "%sSwigOctValueRef(args,%d)", j ? "," : " ", j);
}
Printf(tmp, "}");
Wrapper_add_local(w, "argv", tmp);
@ -849,7 +845,7 @@ public:
String* setwname = Swig_name_wrapper(setname);
Octave_begin_function(n, setw->def, setname, setwname, true);
Printf(setw->def, "if (!SWIG_check_num_args(\"%s_set\",args.length(),1,1,0)) return octave_value_list();", iname);
Printf(setw->def, "if (!SWIG_Octave_CheckNumArgs(\"%s_set\",args.length(),1,1,0)) return octave_value_list();", iname);
if (is_assignable(n)) {
Setattr(n, "wrap:name", setname);
if ((tm = Swig_typemap_lookup("varin", n, name, 0))) {
@ -867,7 +863,7 @@ public:
Append(setw->code, "fail:\n");
Printf(setw->code, "return octave_value_list();\n");
} else {
Printf(setw->code, "return octave_set_immutable(args,nargout);");
Printf(setw->code, "return SWIG_Octave_SetImmutable(args,nargout);");
}
Append(setw->code, "}\n");
Wrapper_print(setw, f_wrappers);
@ -977,7 +973,7 @@ public:
assert(!s_members_tab);
s_members_tab = NewStringEmpty();
Printv(s_members_tab, "static swig_octave_member swig_", class_name, "_members[] = {\n", NIL);
Printv(s_members_tab, "static SwigOctMember swig_", class_name, "_members[] = {\n", NIL);
Language::classHandler(n);
@ -1037,7 +1033,7 @@ public:
Printv(f_wrappers, "static const char *swig_", class_name, "_base_names[] = {", base_class_names, "0};\n", NIL);
Printv(f_wrappers, "static const swig_type_info *swig_", class_name, "_base[] = {", base_class, "0};\n", NIL);
Printv(f_wrappers, "static swig_octave_class _wrap_class_", class_name, " = {\"", class_name, "\", &SWIGTYPE", SwigType_manglestr(t), ",", NIL);
Printv(f_wrappers, "static SwigOctClass _wrap_class_", class_name, " = {\"", class_name, "\", &SWIGTYPE", SwigType_manglestr(t), ",", NIL);
Printv(f_wrappers, Swig_directorclass(n) ? "1," : "0,", NIL);
if (have_constructor) {
String* nspace = Getattr(n, "sym:nspace");
@ -1111,7 +1107,7 @@ public:
String* getname = Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname));
String* setname = Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname));
String* getwname = Swig_name_wrapper(getname);
String* setwname = GetFlag(n, "feature:immutable") ? NewString("octave_set_immutable") : Swig_name_wrapper(setname);
String* setwname = GetFlag(n, "feature:immutable") ? NewString("SWIG_Octave_SetImmutable") : Swig_name_wrapper(setname);
assert(s_members_tab);
Printf(s_members_tab, "{\"%s\",0,%s,%s,0,0},\n", symname, getwname, setwname);
@ -1200,7 +1196,7 @@ public:
String* getname = Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname));
String* setname = Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname));
String* getwname = Swig_name_wrapper(getname);
String* setwname = GetFlag(n, "feature:immutable") ? NewString("octave_set_immutable") : Swig_name_wrapper(setname);
String* setwname = GetFlag(n, "feature:immutable") ? NewString("SWIG_Octave_SetImmutable") : Swig_name_wrapper(setname);
assert(s_members_tab);
Printf(s_members_tab, "{\"%s\",0,%s,%s,1,0},\n", symname, getwname, setwname);
@ -1281,12 +1277,12 @@ public:
{
Wrapper* w = NewWrapper();
Printf(w->def, "SwigDirector_%s::SwigDirector_%s(void* self) :"
"\nSwig::Director((octave_swig_type*)self,static_cast<%s*>(this)) { \n", classname, classname, classname);
"\nSwig::Director((SwigOctType*)self,static_cast<%s*>(this)) { \n", classname, classname, classname);
Append(w->def, "}\n");
Wrapper_print(w, f_directors);
DelWrapper(w);
}
Printf(f_directors_h, " SwigDirector_%s(octave_swig_type* self);\n", classname);
Printf(f_directors_h, " SwigDirector_%s(SwigOctType* self);\n", classname);
Delete(classname);
return Language::classDirectorDefaultConstructor(n);
}
@ -1567,12 +1563,20 @@ public:
String* runtimeCode() {
String* s = NewStringEmpty();
String* srun = Swig_include_sys("octrun.swg");
if (!srun) {
Printf(stderr, "*** Unable to open 'octrun.swg'\n");
} else {
Append(s, srun);
Delete(srun);
const char* runtimeFiles[] = {
"octrundecl.swg",
"octrunfunc.swg",
"octrunclass.swg",
"octruninit.swg"
};
for (size_t i = 0; i < sizeof(runtimeFiles)/sizeof(runtimeFiles[0]); ++i) {
String* srun = Swig_include_sys(runtimeFiles[i]);
if (!srun) {
Printf(stderr, "*** Unable to open '%s'\n", runtimeFiles[i]);
} else {
Append(s, srun);
Delete(srun);
}
}
return s;
}