Merge branch 'gsoc2012-scilab' of https://github.com/swig/swig into gsoc2012-scilab
This commit is contained in:
commit
2bd8c0eada
796 changed files with 16908 additions and 11794 deletions
|
|
@ -121,7 +121,7 @@ namespace std {
|
|||
// SWIG_exception(SWIG_TypeError, "string expected");
|
||||
// }
|
||||
|
||||
// %typemap(in) const string & (std::string temp) {
|
||||
// %typemap(in) const string & ($*1_ltype temp) {
|
||||
// if (caml_ptr_check($input)) {
|
||||
// temp.assign((char *)caml_ptr_val($input,0),
|
||||
// caml_string_len($input));
|
||||
|
|
@ -131,7 +131,7 @@ namespace std {
|
|||
// }
|
||||
// }
|
||||
|
||||
// %typemap(in) string & (std::string temp) {
|
||||
// %typemap(in) string & ($*1_ltype temp) {
|
||||
// if (caml_ptr_check($input)) {
|
||||
// temp.assign((char *)caml_ptr_val($input,0),
|
||||
// caml_string_len($input));
|
||||
|
|
@ -141,9 +141,9 @@ namespace std {
|
|||
// }
|
||||
// }
|
||||
|
||||
// %typemap(in) string * (std::string *temp) {
|
||||
// %typemap(in) string * ($*1_ltype *temp) {
|
||||
// if (caml_ptr_check($input)) {
|
||||
// temp = new std::string((char *)caml_ptr_val($input,0),
|
||||
// temp = new $*1_ltype((char *)caml_ptr_val($input,0),
|
||||
// caml_string_len($input));
|
||||
// $1 = temp;
|
||||
// } else {
|
||||
|
|
@ -151,7 +151,7 @@ namespace std {
|
|||
// }
|
||||
// }
|
||||
|
||||
// %typemap(free) string * (std::string *temp) {
|
||||
// %typemap(free) string * ($*1_ltype *temp) {
|
||||
// delete temp;
|
||||
// }
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
#define %attribute_exception(code,msg) printf("%s\n",msg)
|
||||
|
||||
#ifndef %arg
|
||||
#define %arg(x) x
|
||||
#define %arg(x...) x
|
||||
#endif
|
||||
|
||||
#ifndef %mangle
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ typedef struct SWIGCDATA {
|
|||
|
||||
#if SWIGGUILE
|
||||
%typemap(out) SWIGCDATA {
|
||||
$result = gh_str2scm($1.data,$1.len);
|
||||
$result = scm_from_locale_stringn($1.data,$1.len);
|
||||
}
|
||||
%typemap(in) (const void *indata, int inlen) = (char *STRING, int LENGTH);
|
||||
#elif SWIGCHICKEN
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@
|
|||
%insert("swiglisp") %{
|
||||
;;;SWIG wrapper code starts here
|
||||
|
||||
(cl:defmacro defanonenum (&body enums)
|
||||
(cl:defmacro defanonenum (cl:&body enums)
|
||||
"Converts anonymous enums to defconstants."
|
||||
`(cl:progn ,@(cl:loop for value in enums
|
||||
for index = 0 then (cl:1+ index)
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ extern "C" {
|
|||
SWIG_Chicken_Barf(SWIG_BARF1_CONTRACT_ASSERT, C_text(message)); } else
|
||||
|
||||
/* Runtime API */
|
||||
#define SWIG_GetModule(clientdata) SWIG_Chicken_GetModule()
|
||||
#define SWIG_GetModule(clientdata) SWIG_Chicken_GetModule(clientdata)
|
||||
#define SWIG_SetModule(clientdata, pointer) SWIG_Chicken_SetModule(pointer)
|
||||
|
||||
#define C_swig_is_bool(x) C_truep (C_booleanp (x))
|
||||
|
|
@ -309,7 +309,7 @@ SWIG_Chicken_MustGetPtr (C_word s, swig_type_info *type, int argnum, int flags)
|
|||
static char *chicken_runtimevar_name = "type_pointer" SWIG_TYPE_TABLE_NAME;
|
||||
|
||||
static swig_module_info *
|
||||
SWIG_Chicken_GetModule() {
|
||||
SWIG_Chicken_GetModule(void *SWIGUNUSEDPARM(clientdata)) {
|
||||
swig_module_info *ret = 0;
|
||||
C_word sym;
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ namespace std {
|
|||
}
|
||||
}
|
||||
|
||||
%typemap(in) const string& (std::string temp, char *tempptr) {
|
||||
%typemap(in) const string& ($*1_ltype temp, char *tempptr) {
|
||||
|
||||
if ($input == C_SCHEME_FALSE) {
|
||||
temp.resize(0);
|
||||
|
|
|
|||
|
|
@ -93,7 +93,6 @@ or you can use the %apply directive :
|
|||
|
||||
*/
|
||||
|
||||
// These typemaps contributed by Robin Dunn
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// T_OUTPUT typemap (and helper function) to return multiple argouts as
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@
|
|||
#endif
|
||||
%}
|
||||
|
||||
%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > ($&1_type argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
|
||||
%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
|
||||
// intrusive_ptr by value
|
||||
smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
|
||||
if (smartarg) {
|
||||
|
|
|
|||
|
|
@ -291,6 +291,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
|
|||
const long &,
|
||||
const unsigned long &,
|
||||
const long long &,
|
||||
const unsigned long long &,
|
||||
const float &,
|
||||
const double &
|
||||
%{ static $*1_ltype temp;
|
||||
|
|
@ -308,6 +309,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
|
|||
%typemap(directorin) const long & "$input = $1;"
|
||||
%typemap(directorin) const unsigned long & "$input = $1;"
|
||||
%typemap(directorin) const long long & "$input = $1;"
|
||||
%typemap(directorin) const unsigned long long & "$input = $1;"
|
||||
%typemap(directorin) const float & "$input = $1;"
|
||||
%typemap(directorin) const double & "$input = $1;"
|
||||
|
||||
|
|
@ -321,6 +323,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
|
|||
const long & ($*1_ltype temp),
|
||||
const unsigned long & ($*1_ltype temp),
|
||||
const long long & ($*1_ltype temp),
|
||||
const unsigned long long & ($*1_ltype temp),
|
||||
const float & ($*1_ltype temp),
|
||||
const double & ($*1_ltype temp)
|
||||
"$iminput"
|
||||
|
|
@ -335,6 +338,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
|
|||
const long & ($*1_ltype temp),
|
||||
const unsigned long & ($*1_ltype temp),
|
||||
const long long & ($*1_ltype temp),
|
||||
const unsigned long long & ($*1_ltype temp),
|
||||
const float & ($*1_ltype temp),
|
||||
const double & ($*1_ltype temp)
|
||||
"$cscall"
|
||||
|
|
|
|||
|
|
@ -215,12 +215,13 @@
|
|||
%}
|
||||
|
||||
public:
|
||||
map();
|
||||
map(const map< K, T > &other);
|
||||
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef K key_type;
|
||||
typedef T mapped_type;
|
||||
typedef size_t size_type;
|
||||
|
||||
map();
|
||||
map(const map< K, T > &other);
|
||||
size_type size() const;
|
||||
bool empty() const;
|
||||
%rename(Clear) clear;
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ class string;
|
|||
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
|
||||
return $null;
|
||||
}
|
||||
std::string $1_str($input);
|
||||
$*1_ltype $1_str($input);
|
||||
$1 = &$1_str; %}
|
||||
%typemap(out) const string & %{ $result = SWIG_csharp_string_callback($1->c_str()); %}
|
||||
|
||||
|
|
@ -85,7 +85,7 @@ class string;
|
|||
return $null;
|
||||
}
|
||||
/* possible thread/reentrant code problem */
|
||||
static std::string $1_str;
|
||||
static $*1_ltype $1_str;
|
||||
$1_str = $input;
|
||||
$result = &$1_str; %}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class string;
|
|||
SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "null string");
|
||||
return $null;
|
||||
}
|
||||
std::string $1_str($input);
|
||||
$*1_ltype $1_str($input);
|
||||
$1 = &$1_str; %}
|
||||
|
||||
%typemap(out) string %{ $result = SWIG_d_string_callback($1.c_str()); %}
|
||||
|
|
@ -63,7 +63,7 @@ class string;
|
|||
return $null;
|
||||
}
|
||||
/* possible thread/reentrant code problem */
|
||||
static std::string $1_str;
|
||||
static $*1_ltype $1_str;
|
||||
$1_str = $input;
|
||||
$result = &$1_str; %}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,12 +14,8 @@
|
|||
|
||||
#ifdef SWIGPHP
|
||||
%{
|
||||
#if PHP_MAJOR_VERSION < 5
|
||||
# define SWIG_exception(code, msg) { zend_error(E_ERROR, msg); }
|
||||
#else
|
||||
# include "zend_exceptions.h"
|
||||
# define SWIG_exception(code, msg) { zend_throw_exception(NULL, (char*)msg, code TSRMLS_CC); }
|
||||
#endif
|
||||
#include "zend_exceptions.h"
|
||||
#define SWIG_exception(code, msg) { zend_throw_exception(NULL, (char*)msg, code TSRMLS_CC); }
|
||||
%}
|
||||
#endif
|
||||
|
||||
|
|
@ -28,7 +24,7 @@
|
|||
SWIGINTERN void SWIG_exception_ (int code, const char *msg,
|
||||
const char *subr) {
|
||||
#define ERROR(scmerr) \
|
||||
scm_error(gh_symbol2scm((char *) (scmerr)), \
|
||||
scm_error(scm_from_locale_string((char *) (scmerr)), \
|
||||
(char *) subr, (char *) msg, \
|
||||
SCM_EOL, SCM_BOOL_F)
|
||||
#define MAP(swigerr, scmerr) \
|
||||
|
|
|
|||
|
|
@ -366,7 +366,7 @@
|
|||
%{ $1 = ($1_ltype)$input; %}
|
||||
|
||||
%typemap(out) enum SWIGTYPE
|
||||
%{ $result = $1; %}
|
||||
%{ $result = (intgo)$1; %}
|
||||
|
||||
%typemap(directorin) enum SWIGTYPE
|
||||
%{ $input = ($1_ltype)$1; %}
|
||||
|
|
@ -374,6 +374,18 @@
|
|||
%typemap(directorout) enum SWIGTYPE
|
||||
%{ $result = ($1_ltype)$input; %}
|
||||
|
||||
%typemap(directorin) enum SWIGTYPE & (intgo e)
|
||||
%{
|
||||
e = (intgo)$1;
|
||||
$input = &e;
|
||||
%}
|
||||
|
||||
%typemap(directorout) enum SWIGTYPE &
|
||||
%{
|
||||
$*1_ltype f = ($*1_ltype)*$input;
|
||||
$result = ($1_ltype)&f;
|
||||
%}
|
||||
|
||||
/* Arbitrary type. This is a type passed by value in the C/C++ code.
|
||||
We convert it to a pointer for the Go code. Note that all basic
|
||||
types are explicitly handled above. */
|
||||
|
|
|
|||
|
|
@ -5,12 +5,35 @@
|
|||
* ------------------------------------------------------------ */
|
||||
|
||||
%insert(runtime) %{
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
typedef struct { char *p; int n; } _gostring_;
|
||||
typedef struct { void* array; unsigned int len; unsigned int cap; } _goslice_;
|
||||
%}
|
||||
|
||||
#if SWIGGO_INTGO_SIZE == 32
|
||||
%insert(runtime) %{
|
||||
typedef int intgo;
|
||||
typedef unsigned int uintgo;
|
||||
%}
|
||||
#elif SWIGGO_INTGO_SIZE == 64
|
||||
%insert(runtime) %{
|
||||
typedef long long intgo;
|
||||
typedef unsigned long long uintgo;
|
||||
%}
|
||||
#else
|
||||
%insert(runtime) %{
|
||||
typedef ptrdiff_t intgo;
|
||||
typedef size_t uintgo;
|
||||
%}
|
||||
#endif
|
||||
|
||||
%insert(runtime) %{
|
||||
|
||||
typedef struct { char *p; intgo n; } _gostring_;
|
||||
typedef struct { void* array; intgo len; intgo cap; } _goslice_;
|
||||
|
||||
%}
|
||||
|
||||
|
|
@ -84,6 +107,57 @@ extern "C" {
|
|||
#endif
|
||||
extern void *_cgo_allocate(size_t);
|
||||
extern void _cgo_panic(const char *);
|
||||
|
||||
/* Implementations of SwigCgocall and friends for different versions
|
||||
of gccgo. The Go code will call these functions using C names with
|
||||
a prefix of the module name. The implementations here call the
|
||||
routine in libgo. The routines to call vary depending on the gccgo
|
||||
version. We assume that the version of gcc used to compile this
|
||||
file is the same as the version of gccgo. */
|
||||
|
||||
#define SWIGCONCAT2(s1, s2) s1 ## s2
|
||||
#define SWIGCONCAT1(s1, s2) SWIGCONCAT2(s1, s2)
|
||||
#define SwigCgocall SWIGCONCAT1(SWIGMODULE, SwigCgocall)
|
||||
#define SwigCgocallDone SWIGCONCAT1(SWIGMODULE, SwigCgocallDone)
|
||||
#define SwigCgocallBack SWIGCONCAT1(SWIGMODULE, SwigCgocallBack)
|
||||
#define SwigCgocallBackDone SWIGCONCAT1(SWIGMODULE, SwigCgocallBackDone)
|
||||
|
||||
#define SWIG_GCC_VERSION \
|
||||
(__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC__PATH_LEVEL__)
|
||||
|
||||
#if SWIG_GCC_VERSION < 40700
|
||||
#define SwigDoCgocall()
|
||||
#define SwigDoCgocallDone()
|
||||
#define SwigDoCgocallBack()
|
||||
#define SwigDoCgocallBackDone()
|
||||
#elif SWIG_GCC_VERSION == 40700
|
||||
void SwigDoCgocall(void) __asm__("libgo_syscall.syscall.Entersyscall");
|
||||
void SwigDoCgocallDone(void) __asm__("libgo_syscall.syscall.Exitsyscall");
|
||||
void SwigDoCgocallBack(void) __asm__("libgo_syscall.syscall.Exitsyscall");
|
||||
void SwigDoCgocallBackDone(void) __asm__("libgo_syscall.syscall.Entersyscall");
|
||||
#else
|
||||
void SwigDoCgocall(void) __asm__("syscall.Cgocall");
|
||||
void SwigDoCgocallDone(void) __asm__("syscall.CgocallDone");
|
||||
void SwigDoCgocallBack(void) __asm__("syscall.CgocallBack");
|
||||
void SwigDoCgocallBackDone(void) __asm__("syscall.CgocallBackDone");
|
||||
#endif
|
||||
|
||||
void SwigCgocall() {
|
||||
SwigDoCgocall();
|
||||
}
|
||||
|
||||
void SwigCgocallDone() {
|
||||
SwigDoCgocallDone();
|
||||
}
|
||||
|
||||
void SwigCgocallBack() {
|
||||
SwigDoCgocallBack();
|
||||
}
|
||||
|
||||
void SwigCgocallBackDone() {
|
||||
SwigDoCgocallBackDone();
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
@ -114,6 +188,9 @@ static _gostring_ _swig_makegostring(const char *p, size_t l) {
|
|||
%insert(go_header) %{
|
||||
|
||||
import _ "runtime/cgo"
|
||||
import "unsafe"
|
||||
|
||||
type _ unsafe.Pointer
|
||||
|
||||
%}
|
||||
|
||||
|
|
@ -122,9 +199,12 @@ import _ "runtime/cgo"
|
|||
%insert(go_header) %{
|
||||
|
||||
import "syscall"
|
||||
import "unsafe"
|
||||
|
||||
type _ syscall.Sockaddr
|
||||
|
||||
type _ unsafe.Pointer
|
||||
|
||||
%}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -35,13 +35,13 @@ class string;
|
|||
|
||||
%typemap(in) const string &
|
||||
%{
|
||||
std::string $1_str($input.p, $input.n);
|
||||
$*1_ltype $1_str($input.p, $input.n);
|
||||
$1 = &$1_str;
|
||||
%}
|
||||
|
||||
%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const string &
|
||||
%{
|
||||
static std::string $1_str;
|
||||
static $*1_ltype $1_str;
|
||||
$1_str.assign($input.p, $input.n);
|
||||
$result = &$1_str;
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -62,12 +62,9 @@ char * typemaps instead:
|
|||
%define INPUT_TYPEMAP(TYPE, GOTYPE)
|
||||
%typemap(gotype) TYPE *INPUT, TYPE &INPUT "GOTYPE"
|
||||
|
||||
%typemap(in) TYPE *INPUT
|
||||
%typemap(in) TYPE *INPUT, TYPE &INPUT
|
||||
%{ $1 = ($1_ltype)&$input; %}
|
||||
|
||||
%typemap(in) TYPE &INPUT
|
||||
%{ $1 = ($1_ltype)$input; %}
|
||||
|
||||
%typemap(out) TYPE *INPUT, TYPE &INPUT ""
|
||||
|
||||
%typemap(freearg) TYPE *INPUT, TYPE &INPUT ""
|
||||
|
|
@ -160,7 +157,7 @@ char * typemaps instead:
|
|||
%define OUTPUT_TYPEMAP(TYPE, GOTYPE)
|
||||
%typemap(gotype) TYPE *OUTPUT, TYPE &OUTPUT %{[]GOTYPE%}
|
||||
|
||||
%typemap(in) TYPE *OUTPUT($*1_ltype temp)
|
||||
%typemap(in) TYPE *OUTPUT($*1_ltype temp), TYPE &OUTPUT($*1_ltype temp)
|
||||
{
|
||||
if ($input.len == 0) {
|
||||
_swig_gopanic("array must contain at least 1 element");
|
||||
|
|
@ -168,30 +165,16 @@ char * typemaps instead:
|
|||
$1 = &temp;
|
||||
}
|
||||
|
||||
%typemap(in) TYPE &OUTPUT($*1_ltype temp)
|
||||
{
|
||||
if ($input->len == 0) {
|
||||
_swig_gopanic("array must contain at least 1 element");
|
||||
}
|
||||
$1 = &temp;
|
||||
}
|
||||
|
||||
%typemap(out) TYPE *OUTPUT, TYPE &OUTPUT ""
|
||||
|
||||
%typemap(freearg) TYPE *OUTPUT, TYPE &OUTPUT ""
|
||||
|
||||
%typemap(argout) TYPE *OUTPUT
|
||||
%typemap(argout) TYPE *OUTPUT, TYPE &OUTPUT
|
||||
{
|
||||
TYPE* a = (TYPE *) $input.array;
|
||||
a[0] = temp$argnum;
|
||||
}
|
||||
|
||||
%typemap(argout) TYPE &OUTPUT
|
||||
{
|
||||
TYPE* a = (TYPE *) $input->array;
|
||||
a[0] = temp$argnum;
|
||||
}
|
||||
|
||||
%enddef
|
||||
|
||||
OUTPUT_TYPEMAP(bool, bool);
|
||||
|
|
@ -276,20 +259,13 @@ char * typemaps instead:
|
|||
%define INOUT_TYPEMAP(TYPE, GOTYPE)
|
||||
%typemap(gotype) TYPE *INOUT, TYPE &INOUT %{[]GOTYPE%}
|
||||
|
||||
%typemap(in) TYPE *INOUT {
|
||||
%typemap(in) TYPE *INOUT, TYPE &INOUT {
|
||||
if ($input.len == 0) {
|
||||
_swig_gopanic("array must contain at least 1 element");
|
||||
}
|
||||
$1 = ($1_ltype) $input.array;
|
||||
}
|
||||
|
||||
%typemap(in) TYPE &INOUT {
|
||||
if ($input->len == 0) {
|
||||
_swig_gopanic("array must contain at least 1 element");
|
||||
}
|
||||
$1 = ($1_ltype) $input->array;
|
||||
}
|
||||
|
||||
%typemap(out) TYPE *INOUT, TYPE &INOUT ""
|
||||
|
||||
%typemap(freearg) TYPE *INOUT, TYPE &INOUT ""
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
|
||||
co::
|
||||
co:
|
||||
co RCS/*.i* RCS/*.swg*
|
||||
|
||||
|
|
|
|||
|
|
@ -5,18 +5,18 @@
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%typemap(guile,out) string, std::string {
|
||||
$result = gh_str02scm(const_cast<char*>($1.c_str()));
|
||||
$result = SWIG_str02scm(const_cast<char*>($1.c_str()));
|
||||
}
|
||||
%typemap(guile,in) string, std::string {
|
||||
$1 = SWIG_scm2str($input);
|
||||
}
|
||||
|
||||
%typemap(guile,out) complex, complex<double>, std::complex<double> {
|
||||
$result = scm_make_rectangular( gh_double2scm ($1.real ()),
|
||||
gh_double2scm ($1.imag ()) );
|
||||
$result = scm_make_rectangular( scm_from_double ($1.real ()),
|
||||
scm_from_double ($1.imag ()) );
|
||||
}
|
||||
%typemap(guile,in) complex, complex<double>, std::complex<double> {
|
||||
$1 = std::complex<double>( gh_scm2double (scm_real_part ($input)),
|
||||
gh_scm2double (scm_imag_part ($input)) );
|
||||
$1 = std::complex<double>( scm_to_double (scm_real_part ($input)),
|
||||
scm_to_double (scm_imag_part ($input)) );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,39 +0,0 @@
|
|||
#define gh_append2(a, b) scm_append(scm_listify(a, b, SCM_UNDEFINED))
|
||||
#define gh_apply(a, b) scm_apply(a, b, SCM_EOL)
|
||||
#define gh_bool2scm SCM_BOOL
|
||||
#define gh_boolean_p SCM_BOOLP
|
||||
#define gh_car SCM_CAR
|
||||
#define gh_cdr SCM_CDR
|
||||
#define gh_cons scm_cons
|
||||
#define gh_double2scm scm_make_real
|
||||
#define gh_int2scm scm_long2num
|
||||
#define gh_length(lst) scm_num2ulong(scm_length(lst), SCM_ARG1, FUNC_NAME)
|
||||
#define gh_list scm_listify
|
||||
#define gh_list_to_vector scm_vector
|
||||
#define gh_make_vector scm_make_vector
|
||||
#define gh_null_p SCM_NULLP
|
||||
#define gh_number_p SCM_NUMBERP
|
||||
#define gh_pair_p SCM_CONSP
|
||||
#define gh_scm2bool SCM_NFALSEP
|
||||
#define gh_scm2char SCM_CHAR
|
||||
#define gh_scm2double(a) scm_num2dbl(a, FUNC_NAME)
|
||||
#define gh_scm2int(a) scm_num2int(a, SCM_ARG1, FUNC_NAME)
|
||||
#define gh_scm2long(a) scm_num2long(a, SCM_ARG1, FUNC_NAME)
|
||||
#define gh_scm2short(a) scm_num2short(a, SCM_ARG1, FUNC_NAME)
|
||||
#define gh_scm2newstr SWIG_Guile_scm2newstr
|
||||
#define gh_scm2ulong(a) scm_num2ulong(a, SCM_ARG1, FUNC_NAME)
|
||||
#define gh_scm2ushort(a) scm_num2ushort(a, SCM_ARG1, FUNC_NAME)
|
||||
#define gh_scm2uint(a) scm_num2uint(a, SCM_ARG1, FUNC_NAME)
|
||||
#define gh_ulong2scm scm_ulong2num
|
||||
#define gh_long2scm scm_long2num
|
||||
#define gh_str02scm scm_makfrom0str
|
||||
#define gh_long_long2scm scm_long_long2num
|
||||
#define gh_scm2long_long(a) scm_num2long_long(a, SCM_ARG1, FUNC_NAME)
|
||||
#define gh_ulong_long2scm scm_ulong_long2num
|
||||
#define gh_scm2ulong_long(a) scm_num2ulong_long(a, SCM_ARG1, FUNC_NAME)
|
||||
#define gh_string_p SCM_STRINGP
|
||||
#define gh_vector_length SCM_VECTOR_LENGTH
|
||||
#define gh_vector_p SCM_VECTORP
|
||||
#define gh_vector_ref scm_vector_ref
|
||||
#define gh_vector_set_x scm_vector_set_x
|
||||
#define gh_char2scm SCM_MAKE_CHAR
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* guile_gh.swg
|
||||
*
|
||||
* This SWIG interface file is processed if the Guile module is run
|
||||
* with gh_ flavor.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#define SWIGGUILE_GH
|
||||
|
||||
%runtime "swigrun.swg"
|
||||
%runtime "guile_gh_run.swg"
|
||||
|
||||
#define SWIG_convert_short(o) \
|
||||
SWIG_convert_integer(o, - (1 << (8 * sizeof(short) - 1)), \
|
||||
(1 << (8 * sizeof(short) - 1)) - 1, \
|
||||
FUNC_NAME, $argnum)
|
||||
#define SWIG_convert_unsigned_short(o) \
|
||||
SWIG_convert_unsigned_integer(o, 0, \
|
||||
(1 << (8 * sizeof(short))) - 1, \
|
||||
FUNC_NAME, $argnum)
|
||||
#define SWIG_convert_unsigned_int(o) \
|
||||
SWIG_convert_unsigned_integer(o, 0, UINT_MAX, \
|
||||
FUNC_NAME, $argnum)
|
||||
|
||||
#define gh_scm2short(a) SWIG_convert_short(a)
|
||||
#define gh_scm2ushort(a) SWIG_convert_unsigned_short(a)
|
||||
#define gh_scm2uint(a) SWIG_convert_unsigned_int(a)
|
||||
|
||||
%include <guile.i>
|
||||
|
||||
%runtime %{
|
||||
|
||||
/* scm_values was implemented on C level in 1.4.1, and the prototype
|
||||
is not included in libguile.h, so play safe and lookup `values'... */
|
||||
#define GUILE_MAYBE_VALUES \
|
||||
if (gswig_list_p) \
|
||||
gswig_result = gh_apply(gh_lookup("values"), gswig_result);
|
||||
|
||||
#define GUILE_MAYBE_VECTOR \
|
||||
if (gswig_list_p) \
|
||||
gswig_result = gh_list_to_vector(gswig_result);
|
||||
|
||||
#define SWIG_APPEND_VALUE(object) \
|
||||
if (gswig_result == SCM_UNSPECIFIED) { \
|
||||
gswig_result = object; \
|
||||
} else { \
|
||||
if (!gswig_list_p) { \
|
||||
gswig_list_p = 1; \
|
||||
gswig_result = gh_list(gswig_result, object, SCM_UNDEFINED); \
|
||||
} \
|
||||
else \
|
||||
gswig_result = gh_append2(gswig_result, \
|
||||
gh_list(object, SCM_UNDEFINED)); \
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
%init "swiginit.swg"
|
||||
|
||||
%init %{
|
||||
static int _swig_module_smob_tag;
|
||||
|
||||
SWIG_GUILE_INIT_STATIC void
|
||||
SWIG_init(void)
|
||||
{
|
||||
|
||||
SWIG_InitializeModule(0);
|
||||
swig_module.clientdata = (void *) &_swig_module_smob_tag;
|
||||
|
||||
SWIG_Guile_Init(&swig_module);
|
||||
%}
|
||||
|
|
@ -1,258 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* guile_gh_run.swg
|
||||
*
|
||||
* Guile GH runtime file
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#define SWIGGUILE
|
||||
#include "guile/gh.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef SCM (*swig_guile_proc)();
|
||||
|
||||
#define SWIG_malloc(size) \
|
||||
SCM_MUST_MALLOC(size)
|
||||
#define SWIG_free(mem) \
|
||||
scm_must_free(mem)
|
||||
#define SWIG_ConvertPtr(s, result, type, flags) \
|
||||
SWIG_Guile_ConvertPtr(&swig_module, s, result, type, flags)
|
||||
#define SWIG_MustGetPtr(s, type, argnum, flags) \
|
||||
SWIG_Guile_MustGetPtr(&swig_module, s, type, argnum, flags, FUNC_NAME)
|
||||
#define SWIG_NewPointerObj(ptr, type, owner) \
|
||||
SWIG_Guile_NewPointerObj(&swig_module, (void*)ptr, type, owner)
|
||||
#define SWIG_GetModule(clientdata) SWIG_Guile_GetModule()
|
||||
#define SWIG_SetModule(clientdata, pointer) SWIG_Guile_SetModule(pointer)
|
||||
|
||||
/* Ignore object-ownership changes in gh mode */
|
||||
#define SWIG_Guile_MarkPointerNoncollectable(s) (s)
|
||||
#define SWIG_Guile_MarkPointerDestroyed(s) (s)
|
||||
|
||||
#define SWIG_contract_assert(expr, msg) \
|
||||
if (!(expr)) \
|
||||
scm_error(gh_symbol2scm("swig-contract-assertion-failed"), \
|
||||
(char *) FUNC_NAME, (char *) msg, \
|
||||
SCM_EOL, SCM_BOOL_F); else
|
||||
|
||||
/* SCM_CHAR and SCM_CHARP were introduced in Guile 1.4; the following is for
|
||||
1.3.4 compatibility. */
|
||||
#ifndef SCM_CHAR
|
||||
# define SCM_CHAR SCM_ICHR
|
||||
#endif
|
||||
#ifndef SCM_CHARP
|
||||
# define SCM_CHARP SCM_ICHRP
|
||||
#endif
|
||||
|
||||
/* This function replaces gh_scm2char, which is broken in Guile 1.4 */
|
||||
SWIGINTERN char
|
||||
GSWIG_scm2char (SCM s)
|
||||
{
|
||||
if (SCM_CHARP(s)) return SCM_CHAR(s);
|
||||
scm_wrong_type_arg(NULL, 0, s);
|
||||
}
|
||||
#define gh_scm2char GSWIG_scm2char
|
||||
|
||||
/* Interface function */
|
||||
#define SWIG_scm2str(x) gh_scm2newstr(x, NULL)
|
||||
|
||||
/* More 1.3.4 compatibility */
|
||||
#ifndef SCM_INPUT_PORT_P
|
||||
# define SCM_INPUT_PORT_P SCM_INPORTP
|
||||
# define SCM_OUTPUT_PORT_P SCM_OUTPORTP
|
||||
#endif
|
||||
|
||||
SWIGINTERN long
|
||||
SWIG_convert_integer(SCM o,
|
||||
long lower_bound, long upper_bound,
|
||||
const char *func_name, int argnum)
|
||||
{
|
||||
long value = gh_scm2long(o);
|
||||
if (value < lower_bound || value > upper_bound)
|
||||
scm_wrong_type_arg((char *) func_name, argnum, o);
|
||||
return value;
|
||||
}
|
||||
|
||||
SWIGINTERN unsigned long
|
||||
SWIG_convert_unsigned_integer(SCM o,
|
||||
unsigned long lower_bound,
|
||||
unsigned long upper_bound,
|
||||
const char *func_name, int argnum)
|
||||
{
|
||||
unsigned long value = gh_scm2ulong(o);
|
||||
if (value < lower_bound || value > upper_bound)
|
||||
scm_wrong_type_arg((char *) func_name, argnum, o);
|
||||
return value;
|
||||
}
|
||||
|
||||
SWIGINTERN swig_type_info *
|
||||
SWIG_Guile_LookupType(swig_module_info *module, SCM s, int normal)
|
||||
{
|
||||
swig_module_info *iter;
|
||||
if (!module) return 0;
|
||||
iter = module;
|
||||
do {
|
||||
if ((normal && (unsigned long) SCM_TYP16(s) == *((int *)iter->clientdata))) {
|
||||
|
||||
return iter->types[(long) SCM_CAR(s) >> 16];
|
||||
}
|
||||
iter = iter->next;
|
||||
} while (iter != module);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef SWIG_GLOBAL
|
||||
#define SWIG_GUILE_MODULE_STATIC
|
||||
#elif !defined(SWIG_NOINCLUDE)
|
||||
#define SWIG_GUILE_MODULE_STATIC static
|
||||
#endif
|
||||
|
||||
#ifdef SWIG_GUILE_MODULE_STATIC
|
||||
static swig_module_info *swig_guile_module = 0;
|
||||
SWIG_GUILE_MODULE_STATIC swig_module_info *SWIG_Guile_GetModule(void) {
|
||||
return swig_guile_module;
|
||||
}
|
||||
SWIG_GUILE_MODULE_STATIC void SWIG_Guile_SetModule(swig_module_info *pointer) {
|
||||
swig_guile_module = pointer;
|
||||
}
|
||||
#else
|
||||
SWIGEXPORT swig_module_info * SWIG_Guile_GetModule(void);
|
||||
SWIGEXPORT void SWIG_Guile_SetModule(swig_module_info *pointer);
|
||||
#endif
|
||||
|
||||
SWIGINTERN SCM
|
||||
SWIG_Guile_NewPointerObj(swig_module_info *module, void *ptr,
|
||||
swig_type_info *type, int owner)
|
||||
{
|
||||
unsigned long tag;
|
||||
if (ptr==NULL) return SCM_EOL;
|
||||
if (!module) return SCM_EOL;
|
||||
for (tag = 0; tag < module->size; ++tag) {
|
||||
if (module->types[tag] == type)
|
||||
break;
|
||||
}
|
||||
if (tag >= module->size)
|
||||
return SCM_EOL;
|
||||
|
||||
|
||||
SCM_RETURN_NEWSMOB( ((tag << 16) | *((int *)module->clientdata)), ptr);
|
||||
}
|
||||
|
||||
/* Return 0 if successful. */
|
||||
SWIGINTERN int
|
||||
SWIG_Guile_ConvertPtr(swig_module_info *module, SCM s, void **result,
|
||||
swig_type_info *type, int flags)
|
||||
{
|
||||
swig_cast_info *cast;
|
||||
swig_type_info *from;
|
||||
if (SCM_NULLP(s)) {
|
||||
*result = NULL;
|
||||
return SWIG_OK;
|
||||
} else if (SCM_NIMP(s)) {
|
||||
from = SWIG_Guile_LookupType(module, s, 1);
|
||||
if (!from) return SWIG_ERROR;
|
||||
if (type) {
|
||||
cast = SWIG_TypeCheckStruct(from, type);
|
||||
if (cast) {
|
||||
int newmemory = 0;
|
||||
*result = SWIG_TypeCast(cast, (void *) SCM_CDR(s), &newmemory);
|
||||
assert(!newmemory); /* newmemory handling not yet implemented */
|
||||
return SWIG_OK;
|
||||
} else {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
} else {
|
||||
*result = (void *) SCM_CDR(s);
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
SWIGINTERN void *
|
||||
SWIG_Guile_MustGetPtr (swig_module_info *module, SCM s, swig_type_info *type,
|
||||
int argnum, int flags, const char *func_name)
|
||||
{
|
||||
void *result;
|
||||
int res = SWIG_Guile_ConvertPtr(module, s, &result, type, flags);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
/* type mismatch */
|
||||
scm_wrong_type_arg((char *) func_name, argnum, s);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Init */
|
||||
|
||||
SWIGINTERN int
|
||||
print_swig (SCM swig_smob, SCM port, scm_print_state *pstate)
|
||||
{
|
||||
swig_type_info *type = SWIG_Guile_LookupType(0, swig_smob, 1);
|
||||
if (type) {
|
||||
scm_puts((char *) "#<swig ", port);
|
||||
if (type->str != NULL)
|
||||
scm_puts((char *) type->str, port);
|
||||
else
|
||||
scm_puts((char *) type->name, port);
|
||||
scm_puts((char *) " ", port);
|
||||
scm_intprint((long) SCM_CDR(swig_smob), 16, port);
|
||||
scm_puts((char *) ">", port);
|
||||
/* non-zero means success */
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
SWIGINTERN SCM
|
||||
equalp_swig (SCM A, SCM B)
|
||||
{
|
||||
if (SCM_CAR(A) == SCM_CAR(B)
|
||||
&& SCM_CDR(A) == SCM_CDR(B))
|
||||
return SCM_BOOL_T;
|
||||
else return SCM_BOOL_F;
|
||||
}
|
||||
|
||||
SWIGINTERN void
|
||||
SWIG_Guile_Init (swig_module_info *module)
|
||||
{
|
||||
*((int *)module->clientdata) =
|
||||
scm_make_smob_type_mfpe((char *) "swig", 0, NULL, NULL, print_swig, equalp_swig);
|
||||
}
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_Guile_GetArgs (SCM *dest, SCM rest,
|
||||
int reqargs, int optargs,
|
||||
const char *procname)
|
||||
{
|
||||
int i;
|
||||
int num_args_passed = 0;
|
||||
for (i = 0; i<reqargs; i++) {
|
||||
if (!SCM_CONSP(rest))
|
||||
scm_wrong_num_args(gh_str02scm((char *) procname));
|
||||
*dest++ = SCM_CAR(rest);
|
||||
rest = SCM_CDR(rest);
|
||||
num_args_passed++;
|
||||
}
|
||||
for (i = 0; i<optargs && SCM_CONSP(rest); i++) {
|
||||
*dest++ = SCM_CAR(rest);
|
||||
rest = SCM_CDR(rest);
|
||||
num_args_passed++;
|
||||
}
|
||||
for (; i<optargs; i++)
|
||||
*dest++ = SCM_UNDEFINED;
|
||||
if (!SCM_NULLP(rest))
|
||||
scm_wrong_num_args(gh_str02scm((char *) procname));
|
||||
return num_args_passed;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* guile.swg ends here */
|
||||
|
|
@ -10,7 +10,6 @@
|
|||
%runtime "swigrun.swg" // Common C API type-checking code
|
||||
|
||||
%runtime "guile_scm_run.swg"
|
||||
%include <ghinterface.i>
|
||||
%include <guile.i>
|
||||
|
||||
%runtime %{
|
||||
|
|
@ -32,10 +31,6 @@
|
|||
else \
|
||||
gswig_result = scm_append(scm_listify(gswig_result, scm_listify(object, SCM_UNDEFINED), SCM_UNDEFINED)); \
|
||||
}
|
||||
/* used by Lib/exception.i */
|
||||
#define gh_symbol2scm scm_str2symbol
|
||||
/* useb by Lib/cdata.i */
|
||||
#define gh_str2scm scm_mem2string
|
||||
|
||||
%}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,28 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* In the code below, use guile 2.0 compatible functions where possible.
|
||||
Functions that don't exist in older versions will be mapped to
|
||||
a deprecated equivalent for those versions only */
|
||||
#if defined (SCM_MAJOR_VERSION) && (SCM_MAJOR_VERSION < 2)
|
||||
|
||||
static SCM
|
||||
scm_module_variable (SCM module, SCM sym)
|
||||
{
|
||||
return scm_sym2var (sym, scm_module_lookup_closure (module), SCM_BOOL_F);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if SCM_MAJOR_VERSION >= 2
|
||||
// scm_c_define_gsubr takes a different parameter type
|
||||
// depending on the guile version
|
||||
|
||||
typedef scm_t_subr swig_guile_proc;
|
||||
#else
|
||||
typedef SCM (*swig_guile_proc)();
|
||||
#endif
|
||||
typedef SCM (*guile_destructor)(SCM);
|
||||
|
||||
typedef struct swig_guile_clientdata {
|
||||
|
|
@ -22,10 +43,12 @@ typedef struct swig_guile_clientdata {
|
|||
|
||||
#define SWIG_scm2str(s) \
|
||||
SWIG_Guile_scm2newstr(s, NULL)
|
||||
#define SWIG_malloc(size) \
|
||||
SCM_MUST_MALLOC(size)
|
||||
#define SWIG_free(mem) \
|
||||
scm_must_free(mem)
|
||||
#define SWIG_str02scm(str) \
|
||||
str ? scm_from_locale_string(str) : SCM_BOOL_F
|
||||
# define SWIG_malloc(size) \
|
||||
scm_malloc(size)
|
||||
# define SWIG_free(mem) \
|
||||
free(mem)
|
||||
#define SWIG_ConvertPtr(s, result, type, flags) \
|
||||
SWIG_Guile_ConvertPtr(s, result, type, flags)
|
||||
#define SWIG_MustGetPtr(s, type, argnum, flags) \
|
||||
|
|
@ -42,7 +65,7 @@ typedef struct swig_guile_clientdata {
|
|||
SWIG_Guile_IsPointer(object)
|
||||
#define SWIG_contract_assert(expr, msg) \
|
||||
if (!(expr)) \
|
||||
scm_error(scm_str2symbol("swig-contract-assertion-failed"), \
|
||||
scm_error(scm_from_locale_symbol("swig-contract-assertion-failed"), \
|
||||
(char *) FUNC_NAME, (char *) msg, \
|
||||
SCM_EOL, SCM_BOOL_F); else
|
||||
|
||||
|
|
@ -53,23 +76,27 @@ typedef struct swig_guile_clientdata {
|
|||
SWIG_Guile_NewMemberObj(ptr, sz, type, FUNC_NAME)
|
||||
|
||||
/* Runtime API */
|
||||
static swig_module_info *SWIG_Guile_GetModule(void);
|
||||
#define SWIG_GetModule(clientdata) SWIG_Guile_GetModule()
|
||||
static swig_module_info *SWIG_Guile_GetModule(void *SWIGUNUSEDPARM(clientdata));
|
||||
#define SWIG_GetModule(clientdata) SWIG_Guile_GetModule(clientdata)
|
||||
#define SWIG_SetModule(clientdata, pointer) SWIG_Guile_SetModule(pointer)
|
||||
|
||||
SWIGINTERN char *
|
||||
SWIG_Guile_scm2newstr(SCM str, size_t *len) {
|
||||
#define FUNC_NAME "SWIG_Guile_scm2newstr"
|
||||
char *ret;
|
||||
char *tmp;
|
||||
size_t l;
|
||||
|
||||
SCM_ASSERT (SCM_STRINGP(str), str, 1, FUNC_NAME);
|
||||
|
||||
l = SCM_STRING_LENGTH(str);
|
||||
SCM_ASSERT (scm_is_string(str), str, 1, FUNC_NAME);
|
||||
l = scm_c_string_length(str);
|
||||
|
||||
ret = (char *) SWIG_malloc( (l + 1) * sizeof(char));
|
||||
if (!ret) return NULL;
|
||||
|
||||
memcpy(ret, SCM_STRING_CHARS(str), l);
|
||||
tmp = scm_to_locale_string(str);
|
||||
memcpy(ret, tmp, l);
|
||||
free(tmp);
|
||||
|
||||
ret[l] = '\0';
|
||||
if (len) *len = l;
|
||||
return ret;
|
||||
|
|
@ -86,7 +113,7 @@ static SCM swig_keyword = SCM_EOL;
|
|||
static SCM swig_symbol = SCM_EOL;
|
||||
|
||||
#define SWIG_Guile_GetSmob(x) \
|
||||
( SCM_NNULLP(x) && SCM_INSTANCEP(x) && SCM_NFALSEP(scm_slot_exists_p(x, swig_symbol)) \
|
||||
( !scm_is_null(x) && SCM_INSTANCEP(x) && scm_is_true(scm_slot_exists_p(x, swig_symbol)) \
|
||||
? scm_slot_ref(x, swig_symbol) : (x) )
|
||||
|
||||
SWIGINTERN SCM
|
||||
|
|
@ -204,7 +231,7 @@ SWIGINTERNINLINE int
|
|||
SWIG_Guile_IsPointer (SCM s)
|
||||
{
|
||||
/* module might not be initialized yet, so initialize it */
|
||||
SWIG_Guile_GetModule();
|
||||
SWIG_GetModule(0);
|
||||
return SWIG_Guile_IsPointerOfType (s, NULL);
|
||||
}
|
||||
|
||||
|
|
@ -361,18 +388,16 @@ ensure_smob_tag(SCM swig_module,
|
|||
const char *smob_name,
|
||||
const char *scheme_variable_name)
|
||||
{
|
||||
SCM variable = scm_sym2var(scm_str2symbol(scheme_variable_name),
|
||||
scm_module_lookup_closure(swig_module),
|
||||
SCM_BOOL_T);
|
||||
if (SCM_UNBNDP(SCM_VARIABLE_REF(variable))) {
|
||||
SCM variable = scm_module_variable(swig_module,
|
||||
scm_from_locale_symbol(scheme_variable_name));
|
||||
if (scm_is_false(variable)) {
|
||||
*tag_variable = scm_make_smob_type((char*)scheme_variable_name, 0);
|
||||
SCM_VARIABLE_SET(variable,
|
||||
scm_ulong2num(*tag_variable));
|
||||
scm_c_module_define(swig_module, scheme_variable_name,
|
||||
scm_from_ulong(*tag_variable));
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
*tag_variable = scm_num2ulong(SCM_VARIABLE_REF(variable), 0,
|
||||
"SWIG_Guile_Init");
|
||||
*tag_variable = scm_to_ulong(SCM_VARIABLE_REF(variable));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -409,8 +434,8 @@ SWIG_Guile_Init ()
|
|||
}
|
||||
swig_make_func = scm_permanent_object(
|
||||
scm_variable_ref(scm_c_module_lookup(scm_c_resolve_module("oop goops"), "make")));
|
||||
swig_keyword = scm_permanent_object(scm_c_make_keyword((char*) "init-smob"));
|
||||
swig_symbol = scm_permanent_object(scm_str2symbol("swig-smob"));
|
||||
swig_keyword = scm_permanent_object(scm_from_locale_keyword((char*) "init-smob"));
|
||||
swig_symbol = scm_permanent_object(scm_from_locale_symbol("swig-smob"));
|
||||
#ifdef SWIG_INIT_RUNTIME_MODULE
|
||||
SWIG_INIT_RUNTIME_MODULE
|
||||
#endif
|
||||
|
|
@ -419,20 +444,19 @@ SWIG_Guile_Init ()
|
|||
}
|
||||
|
||||
SWIGINTERN swig_module_info *
|
||||
SWIG_Guile_GetModule(void)
|
||||
SWIG_Guile_GetModule(void *SWIGUNUSEDPARM(clientdata))
|
||||
{
|
||||
SCM module;
|
||||
SCM variable;
|
||||
|
||||
module = SWIG_Guile_Init();
|
||||
|
||||
variable = scm_sym2var(scm_str2symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME),
|
||||
scm_module_lookup_closure(module),
|
||||
SCM_BOOL_T);
|
||||
if (SCM_UNBNDP(SCM_VARIABLE_REF(variable))) {
|
||||
variable = scm_module_variable(module,
|
||||
scm_from_locale_symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME));
|
||||
if (scm_is_false(variable)) {
|
||||
return NULL;
|
||||
} else {
|
||||
return (swig_module_info *) scm_num2ulong(SCM_VARIABLE_REF(variable), 0, "SWIG_Guile_Init");
|
||||
return (swig_module_info *) scm_to_ulong(SCM_VARIABLE_REF(variable));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -444,11 +468,9 @@ SWIG_Guile_SetModule(swig_module_info *swig_module)
|
|||
|
||||
module = SWIG_Guile_Init();
|
||||
|
||||
variable = scm_sym2var(scm_str2symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME),
|
||||
scm_module_lookup_closure(module),
|
||||
SCM_BOOL_T);
|
||||
|
||||
SCM_VARIABLE_SET(variable, scm_ulong2num((unsigned long) swig_module));
|
||||
scm_module_define(module,
|
||||
scm_from_locale_symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME),
|
||||
scm_from_ulong((unsigned long) swig_module));
|
||||
}
|
||||
|
||||
SWIGINTERN int
|
||||
|
|
@ -460,7 +482,7 @@ SWIG_Guile_GetArgs (SCM *dest, SCM rest,
|
|||
int num_args_passed = 0;
|
||||
for (i = 0; i<reqargs; i++) {
|
||||
if (!SCM_CONSP(rest))
|
||||
scm_wrong_num_args(scm_makfrom0str((char *) procname));
|
||||
scm_wrong_num_args(scm_from_locale_string(procname ? (char *) procname : "unknown procedure"));
|
||||
*dest++ = SCM_CAR(rest);
|
||||
rest = SCM_CDR(rest);
|
||||
num_args_passed++;
|
||||
|
|
@ -473,7 +495,7 @@ SWIG_Guile_GetArgs (SCM *dest, SCM rest,
|
|||
for (; i<optargs; i++)
|
||||
*dest++ = SCM_UNDEFINED;
|
||||
if (!SCM_NULLP(rest))
|
||||
scm_wrong_num_args(scm_makfrom0str((char *) procname));
|
||||
scm_wrong_num_args(scm_from_locale_string(procname ? (char *) procname : "unknown procedure"));
|
||||
return num_args_passed;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,12 +61,12 @@
|
|||
(size_t VECTORLENINPUT, C_TYPE *VECTORINPUT)
|
||||
{
|
||||
SCM_VALIDATE_VECTOR($argnum, $input);
|
||||
$1 = gh_vector_length($input);
|
||||
$1 = scm_c_vector_length($input);
|
||||
if ($1 > 0) {
|
||||
$1_ltype i;
|
||||
$2 = (C_TYPE *) SWIG_malloc(sizeof(C_TYPE) * $1);
|
||||
for (i = 0; i<$1; i++) {
|
||||
SCM swig_scm_value = gh_vector_ref($input, gh_int2scm(i));
|
||||
SCM swig_scm_value = scm_vector_ref($input, scm_from_long(i));
|
||||
$2[i] = SCM_TO_C_EXPR;
|
||||
}
|
||||
}
|
||||
|
|
@ -78,15 +78,15 @@
|
|||
(size_t LISTLENINPUT, C_TYPE *LISTINPUT)
|
||||
{
|
||||
SCM_VALIDATE_LIST($argnum, $input);
|
||||
$1 = gh_length($input);
|
||||
$1 = scm_to_ulong(scm_length($input));
|
||||
if ($1 > 0) {
|
||||
$1_ltype i;
|
||||
SCM rest;
|
||||
$2 = (C_TYPE *) SWIG_malloc(sizeof(C_TYPE) * $1);
|
||||
for (i = 0, rest = $input;
|
||||
i<$1;
|
||||
i++, rest = gh_cdr(rest)) {
|
||||
SCM swig_scm_value = gh_car(rest);
|
||||
i++, rest = SCM_CDR(rest)) {
|
||||
SCM swig_scm_value = SCM_CAR(rest);
|
||||
$2[i] = SCM_TO_C_EXPR;
|
||||
}
|
||||
}
|
||||
|
|
@ -140,12 +140,12 @@
|
|||
(size_t *VECTORLENOUTPUT, C_TYPE **VECTOROUTPUT)
|
||||
{
|
||||
$*1_ltype i;
|
||||
SCM res = gh_make_vector(gh_int2scm(*$1),
|
||||
SCM res = scm_make_vector(scm_from_long(*$1),
|
||||
SCM_BOOL_F);
|
||||
for (i = 0; i<*$1; i++) {
|
||||
C_TYPE swig_c_value = (*$2)[i];
|
||||
SCM elt = C_TO_SCM_EXPR;
|
||||
gh_vector_set_x(res, gh_int2scm(i), elt);
|
||||
scm_vector_set_x(res, scm_from_long(i), elt);
|
||||
}
|
||||
SWIG_APPEND_VALUE(res);
|
||||
}
|
||||
|
|
@ -159,7 +159,7 @@
|
|||
for (i = ((int)(*$1)) - 1; i>=0; i--) {
|
||||
C_TYPE swig_c_value = (*$2)[i];
|
||||
SCM elt = C_TO_SCM_EXPR;
|
||||
res = gh_cons(elt, res);
|
||||
res = scm_cons(elt, res);
|
||||
}
|
||||
SWIG_APPEND_VALUE(res);
|
||||
}
|
||||
|
|
@ -200,21 +200,21 @@
|
|||
|
||||
/* We use the macro to define typemaps for some standard types. */
|
||||
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(bool, gh_scm2bool, gh_bool2scm, boolean);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(char, gh_scm2char, gh_char2scm, char);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned char, gh_scm2char, gh_char2scm, char);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(int, gh_scm2int, gh_int2scm, integer);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(short, gh_scm2int, gh_int2scm, integer);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(long, gh_scm2long, gh_long2scm, integer);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(ptrdiff_t, gh_scm2long, gh_long2scm, integer);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned int, gh_scm2ulong, gh_ulong2scm, integer);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned short, gh_scm2ulong, gh_ulong2scm, integer);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned long, gh_scm2ulong, gh_ulong2scm, integer);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(size_t, gh_scm2ulong, gh_ulong2scm, integer);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(float, gh_scm2double, gh_double2scm, real);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(double, gh_scm2double, gh_double2scm, real);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(char *, SWIG_scm2str, gh_str02scm, string);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, gh_str02scm, string);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(bool, scm_is_true, scm_from_bool, boolean);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(char, SCM_CHAR, SCM_MAKE_CHAR, char);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned char, SCM_CHAR, SCM_MAKE_CHAR, char);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(int, scm_to_int, scm_from_long, integer);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(short, scm_to_int, scm_from_long, integer);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(long, scm_to_long, scm_from_long, integer);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(ptrdiff_t, scm_to_long, scm_from_long, integer);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned int, scm_to_ulong, scm_from_ulong, integer);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned short, scm_to_ulong, scm_from_ulong, integer);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned long, scm_to_ulong, scm_from_ulong, integer);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(size_t, scm_to_ulong, scm_from_ulong, integer);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(float, scm_to_double, scm_from_double, real);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(double, scm_to_double, scm_from_double, real);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(char *, SWIG_scm2str, SWIG_str02scm, string);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, SWIG_str02scm, string);
|
||||
|
||||
/* For the char *, free all strings after converting */
|
||||
|
||||
|
|
@ -312,13 +312,13 @@ TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, gh_str02scm, string
|
|||
const C_TYPE *PARALLEL_VECTORINPUT
|
||||
{
|
||||
SCM_VALIDATE_VECTOR($argnum, $input);
|
||||
*_global_vector_length = gh_vector_length($input);
|
||||
*_global_vector_length = scm_c_vector_length($input);
|
||||
if (*_global_vector_length > 0) {
|
||||
int i;
|
||||
$1 = (C_TYPE *) SWIG_malloc(sizeof(C_TYPE)
|
||||
* (*_global_vector_length));
|
||||
for (i = 0; i<*_global_vector_length; i++) {
|
||||
SCM swig_scm_value = gh_vector_ref($input, gh_int2scm(i));
|
||||
SCM swig_scm_value = scm_vector_ref($input, scm_from_long(i));
|
||||
$1[i] = SCM_TO_C_EXPR;
|
||||
}
|
||||
}
|
||||
|
|
@ -330,7 +330,7 @@ TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, gh_str02scm, string
|
|||
const C_TYPE *PARALLEL_LISTINPUT
|
||||
{
|
||||
SCM_VALIDATE_LIST($argnum, $input);
|
||||
*_global_list_length = gh_length($input);
|
||||
*_global_list_length = scm_to_ulong(scm_length($input));
|
||||
if (*_global_list_length > 0) {
|
||||
int i;
|
||||
SCM rest;
|
||||
|
|
@ -338,8 +338,8 @@ TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, gh_str02scm, string
|
|||
* (*_global_list_length));
|
||||
for (i = 0, rest = $input;
|
||||
i<*_global_list_length;
|
||||
i++, rest = gh_cdr(rest)) {
|
||||
SCM swig_scm_value = gh_car(rest);
|
||||
i++, rest = SCM_CDR(rest)) {
|
||||
SCM swig_scm_value = SCM_CAR(rest);
|
||||
$1[i] = SCM_TO_C_EXPR;
|
||||
}
|
||||
}
|
||||
|
|
@ -391,12 +391,12 @@ TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, gh_str02scm, string
|
|||
C_TYPE **PARALLEL_VECTOROUTPUT
|
||||
{
|
||||
int i;
|
||||
SCM res = gh_make_vector(gh_int2scm(_global_arraylentemp),
|
||||
SCM res = scm_make_vector(scm_from_long(_global_arraylentemp),
|
||||
SCM_BOOL_F);
|
||||
for (i = 0; i<_global_arraylentemp; i++) {
|
||||
C_TYPE swig_c_value = (*$1)[i];
|
||||
SCM elt = C_TO_SCM_EXPR;
|
||||
gh_vector_set_x(res, gh_int2scm(i), elt);
|
||||
scm_vector_set_x(res, scm_from_long(i), elt);
|
||||
}
|
||||
SWIG_APPEND_VALUE(res);
|
||||
}
|
||||
|
|
@ -410,7 +410,7 @@ TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, gh_str02scm, string
|
|||
for (i = _global_arraylentemp - 1; i>=0; i--) {
|
||||
C_TYPE swig_c_value = (*$1)[i];
|
||||
SCM elt = C_TO_SCM_EXPR;
|
||||
res = gh_cons(elt, res);
|
||||
res = scm_cons(elt, res);
|
||||
}
|
||||
}
|
||||
SWIG_APPEND_VALUE(res);
|
||||
|
|
@ -449,21 +449,21 @@ TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, gh_str02scm, string
|
|||
|
||||
/* We use the macro to define typemaps for some standard types. */
|
||||
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(bool, gh_scm2bool, gh_bool2scm, boolean);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(char, gh_scm2char, gh_char2scm, char);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned char, gh_scm2char, gh_char2scm, char);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(int, gh_scm2int, gh_int2scm, integer);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(short, gh_scm2int, gh_int2scm, integer);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(long, gh_scm2long, gh_long2scm, integer);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(ptrdiff_t, gh_scm2long, gh_long2scm, integer);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned int, gh_scm2ulong, gh_ulong2scm, integer);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned short, gh_scm2ulong, gh_ulong2scm, integer);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned long, gh_scm2ulong, gh_ulong2scm, integer);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(size_t, gh_scm2ulong, gh_ulong2scm, integer);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(float, gh_scm2double, gh_double2scm, real);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(double, gh_scm2double, gh_double2scm, real);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(char *, SWIG_scm2str, gh_str02scm, string);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, gh_str02scm, string);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(bool, scm_is_true, scm_from_bool, boolean);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(char, SCM_CHAR, SCM_MAKE_CHAR, char);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned char, SCM_CHAR, SCM_MAKE_CHAR, char);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(int, scm_to_int, scm_from_long, integer);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(short, scm_to_int, scm_from_long, integer);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(long, scm_to_long, scm_from_long, integer);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(ptrdiff_t, scm_to_long, scm_from_long, integer);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned int, scm_to_ulong, scm_from_ulong, integer);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned short, scm_to_ulong, scm_from_ulong, integer);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned long, scm_to_ulong, scm_from_ulong, integer);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(size_t, scm_to_ulong, scm_from_ulong, integer);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(float, scm_to_double, scm_from_double, real);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(double, scm_to_double, scm_from_double, real);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(char *, SWIG_scm2str, SWIG_str02scm, string);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, SWIG_str02scm, string);
|
||||
|
||||
%typemap(freearg) char **PARALLEL_LISTINPUT, char **PARALLEL_VECTORINPUT,
|
||||
const char **PARALLEL_LISTINPUT, const char **PARALLEL_VECTORINPUT
|
||||
|
|
|
|||
|
|
@ -21,33 +21,30 @@
|
|||
*/
|
||||
|
||||
%typemap(in, doc="$NAME is a file port or a FILE * pointer") FILE *
|
||||
( int closep )
|
||||
{
|
||||
if (SWIG_ConvertPtr($input, (void**) &($1), $1_descriptor, 0) == 0) {
|
||||
closep = 0;
|
||||
}
|
||||
else if(!(SCM_FPORTP($input)))
|
||||
scm_wrong_type_arg("$name", $argnum, $input);
|
||||
else {
|
||||
int fd;
|
||||
if (SCM_OUTPUT_PORT_P($input))
|
||||
scm_force_output($input);
|
||||
fd=dup(SCM_FPORT_FDES($input));
|
||||
if(fd==-1)
|
||||
scm_misc_error("$name", strerror(errno), SCM_EOL);
|
||||
$1=fdopen(fd,
|
||||
SCM_OUTPUT_PORT_P($input)
|
||||
? (SCM_INPUT_PORT_P($input)
|
||||
? "r+" : "w")
|
||||
: "r");
|
||||
if($1==NULL)
|
||||
scm_misc_error("$name", strerror(errno), SCM_EOL);
|
||||
closep = 1;
|
||||
if (SWIG_ConvertPtr($input, (void**) &($1), $1_descriptor, 0) != 0) {
|
||||
if (!(SCM_FPORTP($input))) {
|
||||
scm_wrong_type_arg("$symname", $argnum, $input);
|
||||
} else {
|
||||
int fd;
|
||||
if (SCM_OUTPUT_PORT_P($input)) {
|
||||
scm_force_output($input);
|
||||
}
|
||||
fd=dup(SCM_FPORT_FDES($input));
|
||||
if (fd==-1) {
|
||||
scm_misc_error("$symname", strerror(errno), SCM_EOL);
|
||||
}
|
||||
$1=fdopen(fd, SCM_OUTPUT_PORT_P($input) ? (SCM_INPUT_PORT_P($input) ? "r+" : "w") : "r");
|
||||
if ($1==NULL) {
|
||||
scm_misc_error("$symname", strerror(errno), SCM_EOL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(freearg) FILE* {
|
||||
if (closep$argnum)
|
||||
if ($1) {
|
||||
fclose($1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
%apply size_t { std::size_t };
|
||||
|
||||
#define SWIG_bool2scm(b) gh_bool2scm(b ? 1 : 0)
|
||||
#define SWIG_string2scm(s) gh_str02scm(s.c_str())
|
||||
#define SWIG_bool2scm(b) scm_from_bool(b ? 1 : 0)
|
||||
#define SWIG_string2scm(s) SWIG_str02scm(s.c_str())
|
||||
|
||||
%{
|
||||
#include <string>
|
||||
|
|
|
|||
1172
Lib/guile/std_map.i
1172
Lib/guile/std_map.i
File diff suppressed because it is too large
Load diff
1021
Lib/guile/std_pair.i
1021
Lib/guile/std_pair.i
File diff suppressed because it is too large
Load diff
|
|
@ -27,7 +27,7 @@ namespace std {
|
|||
%typemap(typecheck) const string & = char *;
|
||||
|
||||
%typemap(in) string (char * tempptr) {
|
||||
if (gh_string_p($input)) {
|
||||
if (scm_is_string($input)) {
|
||||
tempptr = SWIG_scm2str($input);
|
||||
$1.assign(tempptr);
|
||||
if (tempptr) SWIG_free(tempptr);
|
||||
|
|
@ -36,8 +36,8 @@ namespace std {
|
|||
}
|
||||
}
|
||||
|
||||
%typemap(in) const string & (std::string temp, char *tempptr) {
|
||||
if (gh_string_p($input)) {
|
||||
%typemap(in) const string & ($*1_ltype temp, char *tempptr) {
|
||||
if (scm_is_string($input)) {
|
||||
tempptr = SWIG_scm2str($input);
|
||||
temp.assign(tempptr);
|
||||
if (tempptr) SWIG_free(tempptr);
|
||||
|
|
@ -48,9 +48,9 @@ namespace std {
|
|||
}
|
||||
|
||||
%typemap(in) string * (char *tempptr) {
|
||||
if (gh_string_p($input)) {
|
||||
if (scm_is_string($input)) {
|
||||
tempptr = SWIG_scm2str($input);
|
||||
$1 = new std::string(tempptr);
|
||||
$1 = new $*1_ltype(tempptr);
|
||||
if (tempptr) SWIG_free(tempptr);
|
||||
} else {
|
||||
SWIG_exception(SWIG_TypeError, "string expected");
|
||||
|
|
@ -58,19 +58,19 @@ namespace std {
|
|||
}
|
||||
|
||||
%typemap(out) string {
|
||||
$result = gh_str02scm($1.c_str());
|
||||
$result = SWIG_str02scm($1.c_str());
|
||||
}
|
||||
|
||||
%typemap(out) const string & {
|
||||
$result = gh_str02scm($1->c_str());
|
||||
$result = SWIG_str02scm($1->c_str());
|
||||
}
|
||||
|
||||
%typemap(out) string * {
|
||||
$result = gh_str02scm($1->c_str());
|
||||
$result = SWIG_str02scm($1->c_str());
|
||||
}
|
||||
|
||||
%typemap(varin) string {
|
||||
if (gh_string_p($input)) {
|
||||
if (scm_is_string($input)) {
|
||||
char *tempptr = SWIG_scm2str($input);
|
||||
$1.assign(tempptr);
|
||||
if (tempptr) SWIG_free(tempptr);
|
||||
|
|
@ -80,7 +80,7 @@ namespace std {
|
|||
}
|
||||
|
||||
%typemap(varout) string {
|
||||
$result = gh_str02scm($1.c_str());
|
||||
$result = SWIG_str02scm($1.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,23 +42,23 @@ namespace std {
|
|||
|
||||
template<class T> class vector {
|
||||
%typemap(in) vector<T> {
|
||||
if (gh_vector_p($input)) {
|
||||
unsigned long size = gh_vector_length($input);
|
||||
if (scm_is_vector($input)) {
|
||||
unsigned long size = scm_c_vector_length($input);
|
||||
$1 = std::vector<T >(size);
|
||||
for (unsigned long i=0; i<size; i++) {
|
||||
SCM o = gh_vector_ref($input,gh_ulong2scm(i));
|
||||
SCM o = scm_vector_ref($input,scm_from_ulong(i));
|
||||
(($1_type &)$1)[i] =
|
||||
*((T*) SWIG_MustGetPtr(o,$descriptor(T *),$argnum, 0));
|
||||
}
|
||||
} else if (gh_null_p($input)) {
|
||||
} else if (scm_is_null($input)) {
|
||||
$1 = std::vector<T >();
|
||||
} else if (gh_pair_p($input)) {
|
||||
} else if (scm_is_pair($input)) {
|
||||
SCM head, tail;
|
||||
$1 = std::vector<T >();
|
||||
tail = $input;
|
||||
while (!gh_null_p(tail)) {
|
||||
head = gh_car(tail);
|
||||
tail = gh_cdr(tail);
|
||||
while (!scm_is_null(tail)) {
|
||||
head = SCM_CAR(tail);
|
||||
tail = SCM_CDR(tail);
|
||||
$1.push_back(*((T*)SWIG_MustGetPtr(head,
|
||||
$descriptor(T *),
|
||||
$argnum, 0)));
|
||||
|
|
@ -70,27 +70,27 @@ namespace std {
|
|||
}
|
||||
%typemap(in) const vector<T>& (std::vector<T> temp),
|
||||
const vector<T>* (std::vector<T> temp) {
|
||||
if (gh_vector_p($input)) {
|
||||
unsigned long size = gh_vector_length($input);
|
||||
if (scm_is_vector($input)) {
|
||||
unsigned long size = scm_c_vector_length($input);
|
||||
temp = std::vector<T >(size);
|
||||
$1 = &temp;
|
||||
for (unsigned long i=0; i<size; i++) {
|
||||
SCM o = gh_vector_ref($input,gh_ulong2scm(i));
|
||||
SCM o = scm_vector_ref($input,scm_from_ulong(i));
|
||||
temp[i] = *((T*) SWIG_MustGetPtr(o,
|
||||
$descriptor(T *),
|
||||
$argnum, 0));
|
||||
}
|
||||
} else if (gh_null_p($input)) {
|
||||
} else if (scm_is_null($input)) {
|
||||
temp = std::vector<T >();
|
||||
$1 = &temp;
|
||||
} else if (gh_pair_p($input)) {
|
||||
} else if (scm_is_pair($input)) {
|
||||
temp = std::vector<T >();
|
||||
$1 = &temp;
|
||||
SCM head, tail;
|
||||
tail = $input;
|
||||
while (!gh_null_p(tail)) {
|
||||
head = gh_car(tail);
|
||||
tail = gh_cdr(tail);
|
||||
while (!scm_is_null(tail)) {
|
||||
head = SCM_CAR(tail);
|
||||
tail = SCM_CDR(tail);
|
||||
temp.push_back(*((T*) SWIG_MustGetPtr(head,
|
||||
$descriptor(T *),
|
||||
$argnum, 0)));
|
||||
|
|
@ -100,23 +100,23 @@ namespace std {
|
|||
}
|
||||
}
|
||||
%typemap(out) vector<T> {
|
||||
$result = gh_make_vector(gh_long2scm($1.size()),SCM_UNSPECIFIED);
|
||||
$result = scm_make_vector(scm_from_long($1.size()),SCM_UNSPECIFIED);
|
||||
for (unsigned int i=0; i<$1.size(); i++) {
|
||||
T* x = new T((($1_type &)$1)[i]);
|
||||
gh_vector_set_x($result,gh_long2scm(i),
|
||||
scm_vector_set_x($result,scm_from_long(i),
|
||||
SWIG_NewPointerObj(x, $descriptor(T *), 1));
|
||||
}
|
||||
}
|
||||
%typecheck(SWIG_TYPECHECK_VECTOR) vector<T> {
|
||||
/* native sequence? */
|
||||
if (gh_vector_p($input)) {
|
||||
unsigned int size = gh_vector_length($input);
|
||||
if (scm_is_vector($input)) {
|
||||
unsigned int size = scm_c_vector_length($input);
|
||||
if (size == 0) {
|
||||
/* an empty sequence can be of any type */
|
||||
$1 = 1;
|
||||
} else {
|
||||
/* check the first element only */
|
||||
SCM o = gh_vector_ref($input,gh_ulong2scm(0));
|
||||
SCM o = scm_vector_ref($input,scm_from_ulong(0));
|
||||
T* x;
|
||||
if (SWIG_ConvertPtr(o,(void**) &x,
|
||||
$descriptor(T *), 0) != -1)
|
||||
|
|
@ -124,13 +124,13 @@ namespace std {
|
|||
else
|
||||
$1 = 0;
|
||||
}
|
||||
} else if (gh_null_p($input)) {
|
||||
} else if (scm_is_null($input)) {
|
||||
/* again, an empty sequence can be of any type */
|
||||
$1 = 1;
|
||||
} else if (gh_pair_p($input)) {
|
||||
} else if (scm_is_pair($input)) {
|
||||
/* check the first element only */
|
||||
T* x;
|
||||
SCM head = gh_car($input);
|
||||
SCM head = SCM_CAR($input);
|
||||
if (SWIG_ConvertPtr(head,(void**) &x,
|
||||
$descriptor(T *), 0) != -1)
|
||||
$1 = 1;
|
||||
|
|
@ -149,28 +149,28 @@ namespace std {
|
|||
%typecheck(SWIG_TYPECHECK_VECTOR) const vector<T>&,
|
||||
const vector<T>* {
|
||||
/* native sequence? */
|
||||
if (gh_vector_p($input)) {
|
||||
unsigned int size = gh_vector_length($input);
|
||||
if (scm_is_vector($input)) {
|
||||
unsigned int size = scm_c_vector_length($input);
|
||||
if (size == 0) {
|
||||
/* an empty sequence can be of any type */
|
||||
$1 = 1;
|
||||
} else {
|
||||
/* check the first element only */
|
||||
T* x;
|
||||
SCM o = gh_vector_ref($input,gh_ulong2scm(0));
|
||||
SCM o = scm_vector_ref($input,scm_from_ulong(0));
|
||||
if (SWIG_ConvertPtr(o,(void**) &x,
|
||||
$descriptor(T *), 0) != -1)
|
||||
$1 = 1;
|
||||
else
|
||||
$1 = 0;
|
||||
}
|
||||
} else if (gh_null_p($input)) {
|
||||
} else if (scm_is_null($input)) {
|
||||
/* again, an empty sequence can be of any type */
|
||||
$1 = 1;
|
||||
} else if (gh_pair_p($input)) {
|
||||
} else if (scm_is_pair($input)) {
|
||||
/* check the first element only */
|
||||
T* x;
|
||||
SCM head = gh_car($input);
|
||||
SCM head = SCM_CAR($input);
|
||||
if (SWIG_ConvertPtr(head,(void**) &x,
|
||||
$descriptor(T *), 0) != -1)
|
||||
$1 = 1;
|
||||
|
|
@ -230,24 +230,24 @@ namespace std {
|
|||
%define specialize_stl_vector(T,CHECK,CONVERT_FROM,CONVERT_TO)
|
||||
template<> class vector<T> {
|
||||
%typemap(in) vector<T> {
|
||||
if (gh_vector_p($input)) {
|
||||
unsigned long size = gh_vector_length($input);
|
||||
if (scm_is_vector($input)) {
|
||||
unsigned long size = scm_c_vector_length($input);
|
||||
$1 = std::vector<T >(size);
|
||||
for (unsigned long i=0; i<size; i++) {
|
||||
SCM o = gh_vector_ref($input,gh_ulong2scm(i));
|
||||
SCM o = scm_vector_ref($input,scm_from_ulong(i));
|
||||
if (CHECK(o))
|
||||
(($1_type &)$1)[i] = (T)(CONVERT_FROM(o));
|
||||
else
|
||||
scm_wrong_type_arg(FUNC_NAME, $argnum, $input);
|
||||
}
|
||||
} else if (gh_null_p($input)) {
|
||||
} else if (scm_is_null($input)) {
|
||||
$1 = std::vector<T >();
|
||||
} else if (gh_pair_p($input)) {
|
||||
SCM v = gh_list_to_vector($input);
|
||||
unsigned long size = gh_vector_length(v);
|
||||
} else if (scm_is_pair($input)) {
|
||||
SCM v = scm_vector($input);
|
||||
unsigned long size = scm_c_vector_length(v);
|
||||
$1 = std::vector<T >(size);
|
||||
for (unsigned long i=0; i<size; i++) {
|
||||
SCM o = gh_vector_ref(v,gh_ulong2scm(i));
|
||||
SCM o = scm_vector_ref(v,scm_from_ulong(i));
|
||||
if (CHECK(o))
|
||||
(($1_type &)$1)[i] = (T)(CONVERT_FROM(o));
|
||||
else
|
||||
|
|
@ -260,27 +260,27 @@ namespace std {
|
|||
}
|
||||
%typemap(in) const vector<T>& (std::vector<T> temp),
|
||||
const vector<T>* (std::vector<T> temp) {
|
||||
if (gh_vector_p($input)) {
|
||||
unsigned long size = gh_vector_length($input);
|
||||
if (scm_is_vector($input)) {
|
||||
unsigned long size = scm_c_vector_length($input);
|
||||
temp = std::vector<T >(size);
|
||||
$1 = &temp;
|
||||
for (unsigned long i=0; i<size; i++) {
|
||||
SCM o = gh_vector_ref($input,gh_ulong2scm(i));
|
||||
SCM o = scm_vector_ref($input,scm_from_ulong(i));
|
||||
if (CHECK(o))
|
||||
temp[i] = (T)(CONVERT_FROM(o));
|
||||
else
|
||||
scm_wrong_type_arg(FUNC_NAME, $argnum, $input);
|
||||
}
|
||||
} else if (gh_null_p($input)) {
|
||||
} else if (scm_is_null($input)) {
|
||||
temp = std::vector<T >();
|
||||
$1 = &temp;
|
||||
} else if (gh_pair_p($input)) {
|
||||
SCM v = gh_list_to_vector($input);
|
||||
unsigned long size = gh_vector_length(v);
|
||||
} else if (scm_is_pair($input)) {
|
||||
SCM v = scm_vector($input);
|
||||
unsigned long size = scm_c_vector_length(v);
|
||||
temp = std::vector<T >(size);
|
||||
$1 = &temp;
|
||||
for (unsigned long i=0; i<size; i++) {
|
||||
SCM o = gh_vector_ref(v,gh_ulong2scm(i));
|
||||
SCM o = scm_vector_ref(v,scm_from_ulong(i));
|
||||
if (CHECK(o))
|
||||
temp[i] = (T)(CONVERT_FROM(o));
|
||||
else
|
||||
|
|
@ -291,32 +291,32 @@ namespace std {
|
|||
}
|
||||
}
|
||||
%typemap(out) vector<T> {
|
||||
$result = gh_make_vector(gh_long2scm($1.size()),SCM_UNSPECIFIED);
|
||||
$result = scm_make_vector(scm_from_long($1.size()),SCM_UNSPECIFIED);
|
||||
for (unsigned int i=0; i<$1.size(); i++) {
|
||||
SCM x = CONVERT_TO((($1_type &)$1)[i]);
|
||||
gh_vector_set_x($result,gh_long2scm(i),x);
|
||||
scm_vector_set_x($result,scm_from_long(i),x);
|
||||
}
|
||||
}
|
||||
%typecheck(SWIG_TYPECHECK_VECTOR) vector<T> {
|
||||
/* native sequence? */
|
||||
if (gh_vector_p($input)) {
|
||||
unsigned int size = gh_vector_length($input);
|
||||
if (scm_is_vector($input)) {
|
||||
unsigned int size = scm_c_vector_length($input);
|
||||
if (size == 0) {
|
||||
/* an empty sequence can be of any type */
|
||||
$1 = 1;
|
||||
} else {
|
||||
/* check the first element only */
|
||||
T* x;
|
||||
SCM o = gh_vector_ref($input,gh_ulong2scm(0));
|
||||
SCM o = scm_vector_ref($input,scm_from_ulong(0));
|
||||
$1 = CHECK(o) ? 1 : 0;
|
||||
}
|
||||
} else if (gh_null_p($input)) {
|
||||
} else if (scm_is_null($input)) {
|
||||
/* again, an empty sequence can be of any type */
|
||||
$1 = 1;
|
||||
} else if (gh_pair_p($input)) {
|
||||
} else if (scm_is_pair($input)) {
|
||||
/* check the first element only */
|
||||
T* x;
|
||||
SCM head = gh_car($input);
|
||||
SCM head = SCM_CAR($input);
|
||||
$1 = CHECK(head) ? 1 : 0;
|
||||
} else {
|
||||
/* wrapped vector? */
|
||||
|
|
@ -328,24 +328,24 @@ namespace std {
|
|||
%typecheck(SWIG_TYPECHECK_VECTOR) const vector<T>&,
|
||||
const vector<T>* {
|
||||
/* native sequence? */
|
||||
if (gh_vector_p($input)) {
|
||||
unsigned int size = gh_vector_length($input);
|
||||
if (scm_is_vector($input)) {
|
||||
unsigned int size = scm_c_vector_length($input);
|
||||
if (size == 0) {
|
||||
/* an empty sequence can be of any type */
|
||||
$1 = 1;
|
||||
} else {
|
||||
/* check the first element only */
|
||||
T* x;
|
||||
SCM o = gh_vector_ref($input,gh_ulong2scm(0));
|
||||
SCM o = scm_vector_ref($input,scm_from_ulong(0));
|
||||
$1 = CHECK(o) ? 1 : 0;
|
||||
}
|
||||
} else if (gh_null_p($input)) {
|
||||
} else if (scm_is_null($input)) {
|
||||
/* again, an empty sequence can be of any type */
|
||||
$1 = 1;
|
||||
} else if (gh_pair_p($input)) {
|
||||
} else if (scm_is_pair($input)) {
|
||||
/* check the first element only */
|
||||
T* x;
|
||||
SCM head = gh_car($input);
|
||||
SCM head = SCM_CAR($input);
|
||||
$1 = CHECK(head) ? 1 : 0;
|
||||
} else {
|
||||
/* wrapped vector? */
|
||||
|
|
@ -394,17 +394,17 @@ namespace std {
|
|||
};
|
||||
%enddef
|
||||
|
||||
specialize_stl_vector(bool,gh_boolean_p,gh_scm2bool,SWIG_bool2scm);
|
||||
specialize_stl_vector(char,gh_number_p,gh_scm2long,gh_long2scm);
|
||||
specialize_stl_vector(int,gh_number_p,gh_scm2long,gh_long2scm);
|
||||
specialize_stl_vector(long,gh_number_p,gh_scm2long,gh_long2scm);
|
||||
specialize_stl_vector(short,gh_number_p,gh_scm2long,gh_long2scm);
|
||||
specialize_stl_vector(unsigned char,gh_number_p,gh_scm2ulong,gh_ulong2scm);
|
||||
specialize_stl_vector(unsigned int,gh_number_p,gh_scm2ulong,gh_ulong2scm);
|
||||
specialize_stl_vector(unsigned long,gh_number_p,gh_scm2ulong,gh_ulong2scm);
|
||||
specialize_stl_vector(unsigned short,gh_number_p,gh_scm2ulong,gh_ulong2scm);
|
||||
specialize_stl_vector(float,gh_number_p,gh_scm2double,gh_double2scm);
|
||||
specialize_stl_vector(double,gh_number_p,gh_scm2double,gh_double2scm);
|
||||
specialize_stl_vector(std::string,gh_string_p,SWIG_scm2string,SWIG_string2scm);
|
||||
specialize_stl_vector(bool,scm_is_bool,scm_is_true,SWIG_bool2scm);
|
||||
specialize_stl_vector(char,scm_is_number,scm_to_long,scm_from_long);
|
||||
specialize_stl_vector(int,scm_is_number,scm_to_long,scm_from_long);
|
||||
specialize_stl_vector(long,scm_is_number,scm_to_long,scm_from_long);
|
||||
specialize_stl_vector(short,scm_is_number,scm_to_long,scm_from_long);
|
||||
specialize_stl_vector(unsigned char,scm_is_number,scm_to_ulong,scm_from_ulong);
|
||||
specialize_stl_vector(unsigned int,scm_is_number,scm_to_ulong,scm_from_ulong);
|
||||
specialize_stl_vector(unsigned long,scm_is_number,scm_to_ulong,scm_from_ulong);
|
||||
specialize_stl_vector(unsigned short,scm_is_number,scm_to_ulong,scm_from_ulong);
|
||||
specialize_stl_vector(float,scm_is_number,scm_to_double,scm_from_double);
|
||||
specialize_stl_vector(double,scm_is_number,scm_to_double,scm_from_double);
|
||||
specialize_stl_vector(std::string,scm_is_string,SWIG_scm2string,SWIG_string2scm);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -60,26 +60,26 @@
|
|||
|
||||
%typemap(throws) SWIGTYPE {
|
||||
$<ype temp = new $ltype($1);
|
||||
scm_throw(gh_symbol2scm((char *) "swig-exception"),
|
||||
gh_list(SWIG_NewPointerObj(temp, $&descriptor, 1),
|
||||
scm_throw(scm_from_locale_symbol((char *) "swig-exception"),
|
||||
scm_listify(SWIG_NewPointerObj(temp, $&descriptor, 1),
|
||||
SCM_UNDEFINED));
|
||||
}
|
||||
|
||||
%typemap(throws) SWIGTYPE & {
|
||||
scm_throw(gh_symbol2scm((char *) "swig-exception"),
|
||||
gh_list(SWIG_NewPointerObj(&$1, $descriptor, 1),
|
||||
scm_throw(scm_from_locale_symbol((char *) "swig-exception"),
|
||||
scm_listify(SWIG_NewPointerObj(&$1, $descriptor, 1),
|
||||
SCM_UNDEFINED));
|
||||
}
|
||||
|
||||
%typemap(throws) SWIGTYPE * {
|
||||
scm_throw(gh_symbol2scm((char *) "swig-exception"),
|
||||
gh_list(SWIG_NewPointerObj($1, $descriptor, 1),
|
||||
scm_throw(scm_from_locale_symbol((char *) "swig-exception"),
|
||||
scm_listify(SWIG_NewPointerObj($1, $descriptor, 1),
|
||||
SCM_UNDEFINED));
|
||||
}
|
||||
|
||||
%typemap(throws) SWIGTYPE [] {
|
||||
scm_throw(gh_symbol2scm((char *) "swig-exception"),
|
||||
gh_list(SWIG_NewPointerObj($1, $descriptor, 1),
|
||||
scm_throw(scm_from_locale_symbol((char *) "swig-exception"),
|
||||
scm_listify(SWIG_NewPointerObj($1, $descriptor, 1),
|
||||
SCM_UNDEFINED));
|
||||
}
|
||||
|
||||
|
|
@ -146,23 +146,23 @@
|
|||
|
||||
/* Enums */
|
||||
|
||||
%typemap(in) enum SWIGTYPE { $1 = ($1_type) gh_scm2int($input); }
|
||||
%typemap(in) enum SWIGTYPE { $1 = ($1_type) scm_to_int($input); }
|
||||
/* The complicated construction below needed to deal with anonymous
|
||||
enums, which cannot be cast to. */
|
||||
%typemap(varin) enum SWIGTYPE {
|
||||
if (sizeof(int) != sizeof($1)) {
|
||||
scm_error(scm_str2symbol("swig-error"),
|
||||
scm_error(scm_from_locale_symbol("swig-error"),
|
||||
(char *) FUNC_NAME,
|
||||
(char *) "enum variable '$name' cannot be set",
|
||||
SCM_EOL, SCM_BOOL_F);
|
||||
}
|
||||
* (int *) &($1) = gh_scm2int($input);
|
||||
* (int *) &($1) = scm_to_int($input);
|
||||
}
|
||||
%typemap(out) enum SWIGTYPE { $result = gh_int2scm($1); }
|
||||
%typemap(varout) enum SWIGTYPE { $result = gh_int2scm($1); }
|
||||
%typemap(out) enum SWIGTYPE { $result = scm_from_long($1); }
|
||||
%typemap(varout) enum SWIGTYPE { $result = scm_from_long($1); }
|
||||
%typemap(throws) enum SWIGTYPE {
|
||||
scm_throw(gh_symbol2scm((char *) "swig-exception"),
|
||||
gh_list(gh_int2scm($1), SCM_UNDEFINED));
|
||||
scm_throw(scm_from_locale_symbol((char *) "swig-exception"),
|
||||
scm_listify(scm_from_long($1), SCM_UNDEFINED));
|
||||
}
|
||||
|
||||
/* The SIMPLE_MAP_WITH_EXPR macro below defines the whole set of
|
||||
|
|
@ -210,8 +210,8 @@
|
|||
/* Throw typemap */
|
||||
%typemap(throws) C_NAME {
|
||||
C_NAME swig_c_value = $1;
|
||||
scm_throw(gh_symbol2scm((char *) "swig-exception"),
|
||||
gh_list(C_TO_SCM_EXPR, SCM_UNDEFINED));
|
||||
scm_throw(scm_from_locale_symbol((char *) "swig-exception"),
|
||||
scm_listify(C_TO_SCM_EXPR, SCM_UNDEFINED));
|
||||
}
|
||||
%enddef
|
||||
|
||||
|
|
@ -254,34 +254,34 @@
|
|||
}
|
||||
/* Throw typemap */
|
||||
%typemap(throws) C_NAME {
|
||||
scm_throw(gh_symbol2scm((char *) "swig-exception"),
|
||||
gh_list(C_TO_SCM($1), SCM_UNDEFINED));
|
||||
scm_throw(scm_from_locale_symbol((char *) "swig-exception"),
|
||||
scm_listify(C_TO_SCM($1), SCM_UNDEFINED));
|
||||
}
|
||||
%enddef
|
||||
|
||||
SIMPLE_MAP(bool, gh_scm2bool, gh_bool2scm, boolean);
|
||||
SIMPLE_MAP(char, gh_scm2char, gh_char2scm, char);
|
||||
SIMPLE_MAP(unsigned char, gh_scm2char, gh_char2scm, char);
|
||||
SIMPLE_MAP(signed char, gh_scm2char, gh_char2scm, char);
|
||||
SIMPLE_MAP(int, gh_scm2int, gh_int2scm, integer);
|
||||
SIMPLE_MAP(short, gh_scm2short, gh_int2scm, integer);
|
||||
SIMPLE_MAP(long, gh_scm2long, gh_long2scm, integer);
|
||||
SIMPLE_MAP(ptrdiff_t, gh_scm2long, gh_long2scm, integer);
|
||||
SIMPLE_MAP(unsigned int, gh_scm2uint, gh_ulong2scm, integer);
|
||||
SIMPLE_MAP(unsigned short, gh_scm2ushort, gh_ulong2scm, integer);
|
||||
SIMPLE_MAP(unsigned long, gh_scm2ulong, gh_ulong2scm, integer);
|
||||
SIMPLE_MAP(size_t, gh_scm2ulong, gh_ulong2scm, integer);
|
||||
SIMPLE_MAP(float, gh_scm2double, gh_double2scm, real);
|
||||
SIMPLE_MAP(double, gh_scm2double, gh_double2scm, real);
|
||||
// SIMPLE_MAP(char *, SWIG_scm2str, gh_str02scm, string);
|
||||
// SIMPLE_MAP(const char *, SWIG_scm2str, gh_str02scm, string);
|
||||
SIMPLE_MAP(bool, scm_is_true, scm_from_bool, boolean);
|
||||
SIMPLE_MAP(char, SCM_CHAR, SCM_MAKE_CHAR, char);
|
||||
SIMPLE_MAP(unsigned char, SCM_CHAR, SCM_MAKE_CHAR, char);
|
||||
SIMPLE_MAP(signed char, SCM_CHAR, SCM_MAKE_CHAR, char);
|
||||
SIMPLE_MAP(int, scm_to_int, scm_from_long, integer);
|
||||
SIMPLE_MAP(short, scm_to_short, scm_from_long, integer);
|
||||
SIMPLE_MAP(long, scm_to_long, scm_from_long, integer);
|
||||
SIMPLE_MAP(ptrdiff_t, scm_to_long, scm_from_long, integer);
|
||||
SIMPLE_MAP(unsigned int, scm_to_uint, scm_from_ulong, integer);
|
||||
SIMPLE_MAP(unsigned short, scm_to_ushort, scm_from_ulong, integer);
|
||||
SIMPLE_MAP(unsigned long, scm_to_ulong, scm_from_ulong, integer);
|
||||
SIMPLE_MAP(size_t, scm_to_ulong, scm_from_ulong, integer);
|
||||
SIMPLE_MAP(float, scm_to_double, scm_from_double, real);
|
||||
SIMPLE_MAP(double, scm_to_double, scm_from_double, real);
|
||||
// SIMPLE_MAP(char *, SWIG_scm2str, SWIG_str02scm, string);
|
||||
// SIMPLE_MAP(const char *, SWIG_scm2str, SWIG_str02scm, string);
|
||||
|
||||
/* Define long long typemaps -- uses functions that are only defined
|
||||
in recent versions of Guile, availability also depends on Guile's
|
||||
configuration. */
|
||||
|
||||
SIMPLE_MAP(long long, gh_scm2long_long, gh_long_long2scm, integer);
|
||||
SIMPLE_MAP(unsigned long long, gh_scm2ulong_long, gh_ulong_long2scm, integer);
|
||||
SIMPLE_MAP(long long, scm_to_long_long, scm_from_long_long, integer);
|
||||
SIMPLE_MAP(unsigned long long, scm_to_ulong_long, scm_from_ulong_long, integer);
|
||||
|
||||
/* Strings */
|
||||
|
||||
|
|
@ -290,8 +290,8 @@ SIMPLE_MAP(unsigned long long, gh_scm2ulong_long, gh_ulong_long2scm, integer);
|
|||
must_free = 1;
|
||||
}
|
||||
%typemap (varin, doc="NEW-VALUE is a string") char * {$1 = ($1_ltype)SWIG_scm2str($input);}
|
||||
%typemap (out, doc="<string>") char * {$result = gh_str02scm((const char *)$1);}
|
||||
%typemap (varout, doc="<string>") char * {$result = gh_str02scm($1);}
|
||||
%typemap (out, doc="<string>") char * {$result = SWIG_str02scm((const char *)$1);}
|
||||
%typemap (varout, doc="<string>") char * {$result = SWIG_str02scm($1);}
|
||||
%typemap (in, doc="$NAME is a string") char **INPUT(char * temp, int must_free = 0) {
|
||||
temp = (char *) SWIG_scm2str($input); $1 = &temp;
|
||||
must_free = 1;
|
||||
|
|
@ -299,7 +299,7 @@ SIMPLE_MAP(unsigned long long, gh_scm2ulong_long, gh_ulong_long2scm, integer);
|
|||
%typemap (in,numinputs=0) char **OUTPUT (char * temp)
|
||||
{$1 = &temp;}
|
||||
%typemap (argout,doc="$NAME (a string)") char **OUTPUT
|
||||
{SWIG_APPEND_VALUE(gh_str02scm(*$1));}
|
||||
{SWIG_APPEND_VALUE(SWIG_str02scm(*$1));}
|
||||
%typemap (in) char **BOTH = char **INPUT;
|
||||
%typemap (argout) char **BOTH = char **OUTPUT;
|
||||
%typemap (in) char **INOUT = char **INPUT;
|
||||
|
|
@ -329,8 +329,8 @@ SIMPLE_MAP(unsigned long long, gh_scm2ulong_long, gh_ulong_long2scm, integer);
|
|||
}
|
||||
|
||||
%typemap(throws) char * {
|
||||
scm_throw(gh_symbol2scm((char *) "swig-exception"),
|
||||
gh_list(gh_str02scm($1), SCM_UNDEFINED));
|
||||
scm_throw(scm_from_locale_symbol((char *) "swig-exception"),
|
||||
scm_listify(SWIG_str02scm($1), SCM_UNDEFINED));
|
||||
}
|
||||
|
||||
/* Void */
|
||||
|
|
@ -350,7 +350,7 @@ typedef unsigned long SCM;
|
|||
|
||||
%typemap(in) (char *STRING, int LENGTH), (char *STRING, size_t LENGTH) {
|
||||
size_t temp;
|
||||
$1 = ($1_ltype) gh_scm2newstr($input, &temp);
|
||||
$1 = ($1_ltype) SWIG_Guile_scm2newstr($input, &temp);
|
||||
$2 = ($2_ltype) temp;
|
||||
}
|
||||
|
||||
|
|
@ -406,7 +406,7 @@ typedef unsigned long SCM;
|
|||
const std::size_t &, const std::ptrdiff_t &,
|
||||
enum SWIGTYPE
|
||||
{
|
||||
$1 = SCM_NFALSEP(scm_integer_p($input)) && SCM_NFALSEP(scm_exact_p($input))? 1 : 0;
|
||||
$1 = scm_is_true(scm_integer_p($input)) && scm_is_true(scm_exact_p($input))? 1 : 0;
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_BOOL)
|
||||
|
|
@ -419,7 +419,7 @@ typedef unsigned long SCM;
|
|||
float, double,
|
||||
const float &, const double &
|
||||
{
|
||||
$1 = SCM_NFALSEP(scm_real_p($input)) ? 1 : 0;
|
||||
$1 = scm_is_true(scm_real_p($input)) ? 1 : 0;
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_CHAR) char {
|
||||
|
|
@ -427,7 +427,7 @@ typedef unsigned long SCM;
|
|||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_STRING) char * {
|
||||
$1 = SCM_STRINGP($input) ? 1 : 0;
|
||||
$1 = scm_is_string($input) ? 1 : 0;
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] {
|
||||
|
|
|
|||
|
|
@ -1,82 +1,82 @@
|
|||
// Allow for different namespaces for shared_ptr / intrusive_ptr - they could be boost or std or std::tr1
|
||||
// For example for std::tr1, use:
|
||||
// #define SWIG_SHARED_PTR_NAMESPACE std
|
||||
// #define SWIG_SHARED_PTR_SUBNAMESPACE tr1
|
||||
// #define SWIG_INTRUSIVE_PTR_NAMESPACE boost
|
||||
// #define SWIG_INTRUSIVE_PTR_SUBNAMESPACE
|
||||
|
||||
#if !defined(SWIG_INTRUSIVE_PTR_NAMESPACE)
|
||||
# define SWIG_INTRUSIVE_PTR_NAMESPACE boost
|
||||
#endif
|
||||
|
||||
#if defined(SWIG_INTRUSIVE_PTR_SUBNAMESPACE)
|
||||
# define SWIG_INTRUSIVE_PTR_QNAMESPACE SWIG_INTRUSIVE_PTR_NAMESPACE::SWIG_INTRUSIVE_PTR_SUBNAMESPACE
|
||||
#else
|
||||
# define SWIG_INTRUSIVE_PTR_QNAMESPACE SWIG_INTRUSIVE_PTR_NAMESPACE
|
||||
#endif
|
||||
|
||||
namespace SWIG_INTRUSIVE_PTR_NAMESPACE {
|
||||
#if defined(SWIG_INTRUSIVE_PTR_SUBNAMESPACE)
|
||||
namespace SWIG_INTRUSIVE_PTR_SUBNAMESPACE {
|
||||
#endif
|
||||
template <class T> class intrusive_ptr {
|
||||
};
|
||||
#if defined(SWIG_INTRUSIVE_PTR_SUBNAMESPACE)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
%fragment("SWIG_intrusive_deleter", "header") {
|
||||
template<class T> struct SWIG_intrusive_deleter {
|
||||
void operator()(T *p) {
|
||||
if (p)
|
||||
intrusive_ptr_release(p);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
%fragment("SWIG_null_deleter", "header") {
|
||||
struct SWIG_null_deleter {
|
||||
void operator() (void const *) const {
|
||||
}
|
||||
};
|
||||
%#define SWIG_NO_NULL_DELETER_0 , SWIG_null_deleter()
|
||||
%#define SWIG_NO_NULL_DELETER_1
|
||||
}
|
||||
|
||||
// Workaround empty first macro argument bug
|
||||
#define SWIGEMPTYHACK
|
||||
// Main user macro for defining intrusive_ptr typemaps for both const and non-const pointer types
|
||||
%define %intrusive_ptr(TYPE...)
|
||||
%feature("smartptr", noblock=1) TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > }
|
||||
SWIG_INTRUSIVE_PTR_TYPEMAPS(SWIGEMPTYHACK, TYPE)
|
||||
SWIG_INTRUSIVE_PTR_TYPEMAPS(const, TYPE)
|
||||
%enddef
|
||||
|
||||
%define %intrusive_ptr_no_wrap(TYPE...)
|
||||
%feature("smartptr", noblock=1) TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > }
|
||||
SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(SWIGEMPTYHACK, TYPE)
|
||||
SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(const, TYPE)
|
||||
%enddef
|
||||
|
||||
// Legacy macros
|
||||
%define SWIG_INTRUSIVE_PTR(PROXYCLASS, TYPE...)
|
||||
#warning "SWIG_INTRUSIVE_PTR(PROXYCLASS, TYPE) is deprecated. Please use %intrusive_ptr(TYPE) instead."
|
||||
%intrusive_ptr(TYPE)
|
||||
%enddef
|
||||
|
||||
%define SWIG_INTRUSIVE_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE...)
|
||||
#warning "SWIG_INTRUSIVE_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE) is deprecated. Please use %intrusive_ptr(TYPE) instead."
|
||||
%intrusive_ptr(TYPE)
|
||||
%enddef
|
||||
|
||||
%define SWIG_INTRUSIVE_PTR_NO_WRAP(PROXYCLASS, TYPE...)
|
||||
#warning "SWIG_INTRUSIVE_PTR_NO_WRAP(PROXYCLASS, TYPE) is deprecated. Please use %intrusive_ptr_no_wrap(TYPE) instead."
|
||||
%intrusive_ptr_no_wrap(TYPE)
|
||||
%enddef
|
||||
|
||||
%define SWIG_INTRUSIVE_PTR_DERIVED_NO_WRAP(PROXYCLASS, BASECLASSTYPE, TYPE...)
|
||||
#warning "SWIG_INTRUSIVE_PTR_DERIVED_NO_WRAP(PROXYCLASS, BASECLASSTYPE, TYPE) is deprecated. Please use %intrusive_ptr_no_wrap(TYPE) instead."
|
||||
%intrusive_ptr_no_wrap(TYPE)
|
||||
%enddef
|
||||
|
||||
// Allow for different namespaces for shared_ptr / intrusive_ptr - they could be boost or std or std::tr1
|
||||
// For example for std::tr1, use:
|
||||
// #define SWIG_SHARED_PTR_NAMESPACE std
|
||||
// #define SWIG_SHARED_PTR_SUBNAMESPACE tr1
|
||||
// #define SWIG_INTRUSIVE_PTR_NAMESPACE boost
|
||||
// #define SWIG_INTRUSIVE_PTR_SUBNAMESPACE
|
||||
|
||||
#if !defined(SWIG_INTRUSIVE_PTR_NAMESPACE)
|
||||
# define SWIG_INTRUSIVE_PTR_NAMESPACE boost
|
||||
#endif
|
||||
|
||||
#if defined(SWIG_INTRUSIVE_PTR_SUBNAMESPACE)
|
||||
# define SWIG_INTRUSIVE_PTR_QNAMESPACE SWIG_INTRUSIVE_PTR_NAMESPACE::SWIG_INTRUSIVE_PTR_SUBNAMESPACE
|
||||
#else
|
||||
# define SWIG_INTRUSIVE_PTR_QNAMESPACE SWIG_INTRUSIVE_PTR_NAMESPACE
|
||||
#endif
|
||||
|
||||
namespace SWIG_INTRUSIVE_PTR_NAMESPACE {
|
||||
#if defined(SWIG_INTRUSIVE_PTR_SUBNAMESPACE)
|
||||
namespace SWIG_INTRUSIVE_PTR_SUBNAMESPACE {
|
||||
#endif
|
||||
template <class T> class intrusive_ptr {
|
||||
};
|
||||
#if defined(SWIG_INTRUSIVE_PTR_SUBNAMESPACE)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
%fragment("SWIG_intrusive_deleter", "header") {
|
||||
template<class T> struct SWIG_intrusive_deleter {
|
||||
void operator()(T *p) {
|
||||
if (p)
|
||||
intrusive_ptr_release(p);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
%fragment("SWIG_null_deleter", "header") {
|
||||
struct SWIG_null_deleter {
|
||||
void operator() (void const *) const {
|
||||
}
|
||||
};
|
||||
%#define SWIG_NO_NULL_DELETER_0 , SWIG_null_deleter()
|
||||
%#define SWIG_NO_NULL_DELETER_1
|
||||
}
|
||||
|
||||
// Workaround empty first macro argument bug
|
||||
#define SWIGEMPTYHACK
|
||||
// Main user macro for defining intrusive_ptr typemaps for both const and non-const pointer types
|
||||
%define %intrusive_ptr(TYPE...)
|
||||
%feature("smartptr", noblock=1) TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > }
|
||||
SWIG_INTRUSIVE_PTR_TYPEMAPS(SWIGEMPTYHACK, TYPE)
|
||||
SWIG_INTRUSIVE_PTR_TYPEMAPS(const, TYPE)
|
||||
%enddef
|
||||
|
||||
%define %intrusive_ptr_no_wrap(TYPE...)
|
||||
%feature("smartptr", noblock=1) TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > }
|
||||
SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(SWIGEMPTYHACK, TYPE)
|
||||
SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(const, TYPE)
|
||||
%enddef
|
||||
|
||||
// Legacy macros
|
||||
%define SWIG_INTRUSIVE_PTR(PROXYCLASS, TYPE...)
|
||||
#warning "SWIG_INTRUSIVE_PTR(PROXYCLASS, TYPE) is deprecated. Please use %intrusive_ptr(TYPE) instead."
|
||||
%intrusive_ptr(TYPE)
|
||||
%enddef
|
||||
|
||||
%define SWIG_INTRUSIVE_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE...)
|
||||
#warning "SWIG_INTRUSIVE_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE) is deprecated. Please use %intrusive_ptr(TYPE) instead."
|
||||
%intrusive_ptr(TYPE)
|
||||
%enddef
|
||||
|
||||
%define SWIG_INTRUSIVE_PTR_NO_WRAP(PROXYCLASS, TYPE...)
|
||||
#warning "SWIG_INTRUSIVE_PTR_NO_WRAP(PROXYCLASS, TYPE) is deprecated. Please use %intrusive_ptr_no_wrap(TYPE) instead."
|
||||
%intrusive_ptr_no_wrap(TYPE)
|
||||
%enddef
|
||||
|
||||
%define SWIG_INTRUSIVE_PTR_DERIVED_NO_WRAP(PROXYCLASS, BASECLASSTYPE, TYPE...)
|
||||
#warning "SWIG_INTRUSIVE_PTR_DERIVED_NO_WRAP(PROXYCLASS, BASECLASSTYPE, TYPE) is deprecated. Please use %intrusive_ptr_no_wrap(TYPE) instead."
|
||||
%intrusive_ptr_no_wrap(TYPE)
|
||||
%enddef
|
||||
|
||||
|
|
|
|||
|
|
@ -1,473 +1,473 @@
|
|||
// Users can provide their own SWIG_INTRUSIVE_PTR_TYPEMAPS or SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP macros before including this file to change the
|
||||
// visibility of the constructor and getCPtr method if desired to public if using multiple modules.
|
||||
#ifndef SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP
|
||||
#define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(CONST, TYPE...) SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP_IMPLEMENTATION(protected, protected, CONST, TYPE)
|
||||
#endif
|
||||
#ifndef SWIG_INTRUSIVE_PTR_TYPEMAPS
|
||||
#define SWIG_INTRUSIVE_PTR_TYPEMAPS(CONST, TYPE...) SWIG_INTRUSIVE_PTR_TYPEMAPS_IMPLEMENTATION(protected, protected, CONST, TYPE)
|
||||
#endif
|
||||
|
||||
|
||||
%include <intrusive_ptr.i>
|
||||
|
||||
// Language specific macro implementing all the customisations for handling the smart pointer
|
||||
%define SWIG_INTRUSIVE_PTR_TYPEMAPS_IMPLEMENTATION(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, CONST, TYPE...)
|
||||
|
||||
// %naturalvar is as documented for member variables
|
||||
%naturalvar TYPE;
|
||||
%naturalvar SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >;
|
||||
|
||||
// destructor wrapper customisation
|
||||
%feature("unref") TYPE "(void)arg1; delete smartarg1;"
|
||||
|
||||
// Typemap customisations...
|
||||
|
||||
%typemap(in) CONST TYPE ($&1_type argp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
|
||||
// plain value
|
||||
argp = (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0;
|
||||
if (!argp) {
|
||||
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null $1_type");
|
||||
return $null;
|
||||
}
|
||||
$1 = *argp;
|
||||
%}
|
||||
%typemap(out, fragment="SWIG_intrusive_deleter") CONST TYPE %{
|
||||
//plain value(out)
|
||||
$1_ltype* resultp = new $1_ltype(($1_ltype &)$1);
|
||||
intrusive_ptr_add_ref(resultp);
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(resultp, SWIG_intrusive_deleter< CONST TYPE >());
|
||||
%}
|
||||
|
||||
%typemap(in) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
|
||||
// plain pointer
|
||||
smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input;
|
||||
$1 = (TYPE *)(smartarg ? smartarg->get() : 0);
|
||||
%}
|
||||
%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE * %{
|
||||
//plain pointer(out)
|
||||
#if ($owner)
|
||||
if ($1) {
|
||||
intrusive_ptr_add_ref($1);
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1, SWIG_intrusive_deleter< CONST TYPE >());
|
||||
} else {
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
|
||||
}
|
||||
#else
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0;
|
||||
#endif
|
||||
%}
|
||||
|
||||
%typemap(in) CONST TYPE & (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
|
||||
// plain reference
|
||||
$1 = ($1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0);
|
||||
if(!$1) {
|
||||
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null");
|
||||
return $null;
|
||||
}
|
||||
%}
|
||||
%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE & %{
|
||||
//plain reference(out)
|
||||
#if ($owner)
|
||||
if ($1) {
|
||||
intrusive_ptr_add_ref($1);
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1, SWIG_intrusive_deleter< CONST TYPE >());
|
||||
} else {
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
|
||||
}
|
||||
#else
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0;
|
||||
#endif
|
||||
%}
|
||||
|
||||
%typemap(in) TYPE *CONST& ($*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
|
||||
// plain pointer by reference
|
||||
temp = ($*1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0);
|
||||
$1 = &temp;
|
||||
%}
|
||||
%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") TYPE *CONST& %{
|
||||
// plain pointer by reference(out)
|
||||
#if ($owner)
|
||||
if (*$1) {
|
||||
intrusive_ptr_add_ref(*$1);
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1, SWIG_intrusive_deleter< CONST TYPE >());
|
||||
} else {
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
|
||||
}
|
||||
#else
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_0);
|
||||
#endif
|
||||
%}
|
||||
|
||||
%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > ($&1_type argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
|
||||
// intrusive_ptr by value
|
||||
smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
|
||||
if (smartarg) {
|
||||
$1 = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true);
|
||||
}
|
||||
%}
|
||||
%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > %{
|
||||
if ($1) {
|
||||
intrusive_ptr_add_ref(result.get());
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(result.get(), SWIG_intrusive_deleter< CONST TYPE >());
|
||||
} else {
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{
|
||||
// shared_ptr by value
|
||||
smartarg = *($&1_ltype*)&$input;
|
||||
if (smartarg) $1 = *smartarg;
|
||||
%}
|
||||
%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ANY_TYPE_SWIGSharedPtrUpcast %{
|
||||
*($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0;
|
||||
%}
|
||||
|
||||
%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & ($*1_ltype tempnull, $*1_ltype temp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
|
||||
// intrusive_ptr by reference
|
||||
if ( $input ) {
|
||||
smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
|
||||
temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true);
|
||||
$1 = &temp;
|
||||
} else {
|
||||
$1 = &tempnull;
|
||||
}
|
||||
%}
|
||||
%typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & %{
|
||||
delete &($1);
|
||||
if ($self) {
|
||||
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * temp = new SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(*$input);
|
||||
$1 = *temp;
|
||||
}
|
||||
%}
|
||||
%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & %{
|
||||
if (*$1) {
|
||||
intrusive_ptr_add_ref($1->get());
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1->get(), SWIG_intrusive_deleter< CONST TYPE >());
|
||||
} else {
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * ($*1_ltype tempnull, $*1_ltype temp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
|
||||
// intrusive_ptr by pointer
|
||||
if ( $input ) {
|
||||
smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
|
||||
temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true);
|
||||
$1 = &temp;
|
||||
} else {
|
||||
$1 = &tempnull;
|
||||
}
|
||||
%}
|
||||
%typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * %{
|
||||
delete $1;
|
||||
if ($self) $1 = new SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(*$input);
|
||||
%}
|
||||
%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * %{
|
||||
if ($1 && *$1) {
|
||||
intrusive_ptr_add_ref($1->get());
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1->get(), SWIG_intrusive_deleter< CONST TYPE >());
|
||||
} else {
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
|
||||
}
|
||||
if ($owner) delete $1;
|
||||
%}
|
||||
|
||||
%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& (SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > temp, $*1_ltype tempp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
|
||||
// intrusive_ptr by pointer reference
|
||||
smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
|
||||
if ($input) {
|
||||
temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true);
|
||||
}
|
||||
tempp = &temp;
|
||||
$1 = &tempp;
|
||||
%}
|
||||
%typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& %{
|
||||
if ($self) $1 = *$input;
|
||||
%}
|
||||
%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& %{
|
||||
if (*$1 && **$1) {
|
||||
intrusive_ptr_add_ref((*$1)->get());
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >((*$1)->get(), SWIG_intrusive_deleter< CONST TYPE >());
|
||||
} else {
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
|
||||
}
|
||||
%}
|
||||
|
||||
// various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug
|
||||
%typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
|
||||
#error "typemaps for $1_type not available"
|
||||
%}
|
||||
%typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
|
||||
#error "typemaps for $1_type not available"
|
||||
%}
|
||||
|
||||
|
||||
%typemap (jni) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >,
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
|
||||
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
|
||||
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *,
|
||||
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "jlong"
|
||||
%typemap (jtype) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >,
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
|
||||
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
|
||||
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *,
|
||||
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "long"
|
||||
%typemap (jstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >,
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
|
||||
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
|
||||
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *,
|
||||
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "$typemap(jstype, TYPE)"
|
||||
%typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >,
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
|
||||
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
|
||||
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *,
|
||||
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "$typemap(jstype, TYPE).getCPtr($javainput)"
|
||||
|
||||
%typemap(javaout) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > {
|
||||
long cPtr = $jnicall;
|
||||
return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
|
||||
}
|
||||
%typemap(javaout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
|
||||
long cPtr = $jnicall;
|
||||
return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
|
||||
}
|
||||
%typemap(javaout) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & {
|
||||
long cPtr = $jnicall;
|
||||
return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
|
||||
}
|
||||
%typemap(javaout) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * {
|
||||
long cPtr = $jnicall;
|
||||
return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
|
||||
}
|
||||
%typemap(javaout) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& {
|
||||
long cPtr = $jnicall;
|
||||
return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
|
||||
}
|
||||
|
||||
|
||||
%typemap(javaout) CONST TYPE {
|
||||
return new $typemap(jstype, TYPE)($jnicall, true);
|
||||
}
|
||||
%typemap(javaout) CONST TYPE & {
|
||||
return new $typemap(jstype, TYPE)($jnicall, true);
|
||||
}
|
||||
%typemap(javaout) CONST TYPE * {
|
||||
long cPtr = $jnicall;
|
||||
return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
|
||||
}
|
||||
%typemap(javaout) TYPE *CONST& {
|
||||
long cPtr = $jnicall;
|
||||
return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
|
||||
}
|
||||
|
||||
// Base proxy classes
|
||||
%typemap(javabody) TYPE %{
|
||||
private long swigCPtr;
|
||||
private boolean swigCMemOwnBase;
|
||||
|
||||
PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
|
||||
swigCMemOwnBase = cMemoryOwn;
|
||||
swigCPtr = cPtr;
|
||||
}
|
||||
|
||||
CPTR_VISIBILITY static long getCPtr($javaclassname obj) {
|
||||
return (obj == null) ? 0 : obj.swigCPtr;
|
||||
}
|
||||
%}
|
||||
|
||||
// Derived proxy classes
|
||||
%typemap(javabody_derived) TYPE %{
|
||||
private long swigCPtr;
|
||||
private boolean swigCMemOwnDerived;
|
||||
|
||||
PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
|
||||
super($imclassname.$javaclazznameSWIGSmartPtrUpcast(cPtr), true);
|
||||
swigCMemOwnDerived = cMemoryOwn;
|
||||
swigCPtr = cPtr;
|
||||
}
|
||||
|
||||
CPTR_VISIBILITY static long getCPtr($javaclassname obj) {
|
||||
return (obj == null) ? 0 : obj.swigCPtr;
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized") TYPE {
|
||||
if(swigCPtr != 0 && swigCMemOwnBase) {
|
||||
swigCMemOwnBase = false;
|
||||
$jnicall;
|
||||
}
|
||||
swigCPtr = 0;
|
||||
}
|
||||
|
||||
%typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized") TYPE {
|
||||
if(swigCPtr != 0 && swigCMemOwnDerived) {
|
||||
swigCMemOwnDerived = false;
|
||||
$jnicall;
|
||||
}
|
||||
swigCPtr = 0;
|
||||
super.delete();
|
||||
}
|
||||
|
||||
// CONST version needed ???? also for C#
|
||||
%typemap(jtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "long"
|
||||
%typemap(jtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "long"
|
||||
|
||||
|
||||
%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
|
||||
%template() SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >;
|
||||
%enddef
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
%include <shared_ptr.i>
|
||||
|
||||
%define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP_IMPLEMENTATION(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, CONST, TYPE...)
|
||||
|
||||
%naturalvar TYPE;
|
||||
%naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
|
||||
|
||||
// destructor mods
|
||||
%feature("unref") TYPE "(void)arg1; delete smartarg1;"
|
||||
|
||||
|
||||
// plain value
|
||||
%typemap(in) CONST TYPE ($&1_type argp = 0) %{
|
||||
argp = (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0;
|
||||
if (!argp) {
|
||||
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null $1_type");
|
||||
return $null;
|
||||
}
|
||||
$1 = *argp; %}
|
||||
%typemap(out) CONST TYPE
|
||||
%{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); %}
|
||||
|
||||
// plain pointer
|
||||
%typemap(in) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
|
||||
smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input;
|
||||
$1 = (TYPE *)(smartarg ? smartarg->get() : 0); %}
|
||||
%typemap(out, fragment="SWIG_null_deleter") CONST TYPE * %{
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0;
|
||||
%}
|
||||
|
||||
// plain reference
|
||||
%typemap(in) CONST TYPE & %{
|
||||
$1 = ($1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0);
|
||||
if (!$1) {
|
||||
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null");
|
||||
return $null;
|
||||
} %}
|
||||
%typemap(out, fragment="SWIG_null_deleter") CONST TYPE &
|
||||
%{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %}
|
||||
|
||||
// plain pointer by reference
|
||||
%typemap(in) TYPE *CONST& ($*1_ltype temp = 0)
|
||||
%{ temp = ($*1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0);
|
||||
$1 = &temp; %}
|
||||
%typemap(out, fragment="SWIG_null_deleter") TYPE *CONST&
|
||||
%{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %}
|
||||
|
||||
%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{
|
||||
// shared_ptr by value
|
||||
smartarg = *($&1_ltype*)&$input;
|
||||
if (smartarg) $1 = *smartarg;
|
||||
%}
|
||||
%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ANY_TYPE_SWIGSharedPtrUpcast %{
|
||||
*($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0;
|
||||
%}
|
||||
|
||||
// various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug
|
||||
%typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
|
||||
#error "typemaps for $1_type not available"
|
||||
%}
|
||||
%typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
|
||||
#error "typemaps for $1_type not available"
|
||||
%}
|
||||
|
||||
|
||||
%typemap (jni) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "jlong"
|
||||
%typemap (jtype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "long"
|
||||
%typemap (jstype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "$typemap(jstype, TYPE)"
|
||||
%typemap (javain) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "$typemap(jstype, TYPE).getCPtr($javainput)"
|
||||
%typemap(javaout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
|
||||
long cPtr = $jnicall;
|
||||
return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
|
||||
}
|
||||
|
||||
%typemap(javaout) CONST TYPE {
|
||||
return new $typemap(jstype, TYPE)($jnicall, true);
|
||||
}
|
||||
%typemap(javaout) CONST TYPE & {
|
||||
return new $typemap(jstype, TYPE)($jnicall, true);
|
||||
}
|
||||
%typemap(javaout) CONST TYPE * {
|
||||
long cPtr = $jnicall;
|
||||
return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
|
||||
}
|
||||
%typemap(javaout) TYPE *CONST& {
|
||||
long cPtr = $jnicall;
|
||||
return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
|
||||
}
|
||||
|
||||
// Base proxy classes
|
||||
%typemap(javabody) TYPE %{
|
||||
private long swigCPtr;
|
||||
private boolean swigCMemOwnBase;
|
||||
|
||||
PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
|
||||
swigCMemOwnBase = cMemoryOwn;
|
||||
swigCPtr = cPtr;
|
||||
}
|
||||
|
||||
CPTR_VISIBILITY static long getCPtr($javaclassname obj) {
|
||||
return (obj == null) ? 0 : obj.swigCPtr;
|
||||
}
|
||||
%}
|
||||
|
||||
// Derived proxy classes
|
||||
%typemap(javabody_derived) TYPE %{
|
||||
private long swigCPtr;
|
||||
private boolean swigCMemOwnDerived;
|
||||
|
||||
PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
|
||||
super($imclassname.$javaclazznameSWIGSmartPtrUpcast(cPtr), true);
|
||||
swigCMemOwnDerived = cMemoryOwn;
|
||||
swigCPtr = cPtr;
|
||||
}
|
||||
|
||||
CPTR_VISIBILITY static long getCPtr($javaclassname obj) {
|
||||
return (obj == null) ? 0 : obj.swigCPtr;
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized") TYPE {
|
||||
if (swigCPtr != 0) {
|
||||
if (swigCMemOwnBase) {
|
||||
swigCMemOwnBase = false;
|
||||
$jnicall;
|
||||
}
|
||||
swigCPtr = 0;
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized") TYPE {
|
||||
if (swigCPtr != 0) {
|
||||
if (swigCMemOwnDerived) {
|
||||
swigCMemOwnDerived = false;
|
||||
$jnicall;
|
||||
}
|
||||
swigCPtr = 0;
|
||||
}
|
||||
super.delete();
|
||||
}
|
||||
|
||||
// CONST version needed ???? also for C#
|
||||
%typemap(jtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "long"
|
||||
%typemap(jtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "long"
|
||||
|
||||
|
||||
%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
|
||||
%enddef
|
||||
|
||||
// Users can provide their own SWIG_INTRUSIVE_PTR_TYPEMAPS or SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP macros before including this file to change the
|
||||
// visibility of the constructor and getCPtr method if desired to public if using multiple modules.
|
||||
#ifndef SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP
|
||||
#define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(CONST, TYPE...) SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP_IMPLEMENTATION(protected, protected, CONST, TYPE)
|
||||
#endif
|
||||
#ifndef SWIG_INTRUSIVE_PTR_TYPEMAPS
|
||||
#define SWIG_INTRUSIVE_PTR_TYPEMAPS(CONST, TYPE...) SWIG_INTRUSIVE_PTR_TYPEMAPS_IMPLEMENTATION(protected, protected, CONST, TYPE)
|
||||
#endif
|
||||
|
||||
|
||||
%include <intrusive_ptr.i>
|
||||
|
||||
// Language specific macro implementing all the customisations for handling the smart pointer
|
||||
%define SWIG_INTRUSIVE_PTR_TYPEMAPS_IMPLEMENTATION(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, CONST, TYPE...)
|
||||
|
||||
// %naturalvar is as documented for member variables
|
||||
%naturalvar TYPE;
|
||||
%naturalvar SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >;
|
||||
|
||||
// destructor wrapper customisation
|
||||
%feature("unref") TYPE "(void)arg1; delete smartarg1;"
|
||||
|
||||
// Typemap customisations...
|
||||
|
||||
%typemap(in) CONST TYPE ($&1_type argp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
|
||||
// plain value
|
||||
argp = (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0;
|
||||
if (!argp) {
|
||||
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null $1_type");
|
||||
return $null;
|
||||
}
|
||||
$1 = *argp;
|
||||
%}
|
||||
%typemap(out, fragment="SWIG_intrusive_deleter") CONST TYPE %{
|
||||
//plain value(out)
|
||||
$1_ltype* resultp = new $1_ltype(($1_ltype &)$1);
|
||||
intrusive_ptr_add_ref(resultp);
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(resultp, SWIG_intrusive_deleter< CONST TYPE >());
|
||||
%}
|
||||
|
||||
%typemap(in) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
|
||||
// plain pointer
|
||||
smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input;
|
||||
$1 = (TYPE *)(smartarg ? smartarg->get() : 0);
|
||||
%}
|
||||
%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE * %{
|
||||
//plain pointer(out)
|
||||
#if ($owner)
|
||||
if ($1) {
|
||||
intrusive_ptr_add_ref($1);
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1, SWIG_intrusive_deleter< CONST TYPE >());
|
||||
} else {
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
|
||||
}
|
||||
#else
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0;
|
||||
#endif
|
||||
%}
|
||||
|
||||
%typemap(in) CONST TYPE & (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
|
||||
// plain reference
|
||||
$1 = ($1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0);
|
||||
if(!$1) {
|
||||
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null");
|
||||
return $null;
|
||||
}
|
||||
%}
|
||||
%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE & %{
|
||||
//plain reference(out)
|
||||
#if ($owner)
|
||||
if ($1) {
|
||||
intrusive_ptr_add_ref($1);
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1, SWIG_intrusive_deleter< CONST TYPE >());
|
||||
} else {
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
|
||||
}
|
||||
#else
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0;
|
||||
#endif
|
||||
%}
|
||||
|
||||
%typemap(in) TYPE *CONST& ($*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
|
||||
// plain pointer by reference
|
||||
temp = ($*1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0);
|
||||
$1 = &temp;
|
||||
%}
|
||||
%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") TYPE *CONST& %{
|
||||
// plain pointer by reference(out)
|
||||
#if ($owner)
|
||||
if (*$1) {
|
||||
intrusive_ptr_add_ref(*$1);
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1, SWIG_intrusive_deleter< CONST TYPE >());
|
||||
} else {
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
|
||||
}
|
||||
#else
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_0);
|
||||
#endif
|
||||
%}
|
||||
|
||||
%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > ($&1_type argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
|
||||
// intrusive_ptr by value
|
||||
smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
|
||||
if (smartarg) {
|
||||
$1 = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true);
|
||||
}
|
||||
%}
|
||||
%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > %{
|
||||
if ($1) {
|
||||
intrusive_ptr_add_ref(result.get());
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(result.get(), SWIG_intrusive_deleter< CONST TYPE >());
|
||||
} else {
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{
|
||||
// shared_ptr by value
|
||||
smartarg = *($&1_ltype*)&$input;
|
||||
if (smartarg) $1 = *smartarg;
|
||||
%}
|
||||
%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ANY_TYPE_SWIGSharedPtrUpcast %{
|
||||
*($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0;
|
||||
%}
|
||||
|
||||
%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & ($*1_ltype tempnull, $*1_ltype temp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
|
||||
// intrusive_ptr by reference
|
||||
if ( $input ) {
|
||||
smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
|
||||
temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true);
|
||||
$1 = &temp;
|
||||
} else {
|
||||
$1 = &tempnull;
|
||||
}
|
||||
%}
|
||||
%typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & %{
|
||||
delete &($1);
|
||||
if ($self) {
|
||||
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * temp = new SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(*$input);
|
||||
$1 = *temp;
|
||||
}
|
||||
%}
|
||||
%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & %{
|
||||
if (*$1) {
|
||||
intrusive_ptr_add_ref($1->get());
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1->get(), SWIG_intrusive_deleter< CONST TYPE >());
|
||||
} else {
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * ($*1_ltype tempnull, $*1_ltype temp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
|
||||
// intrusive_ptr by pointer
|
||||
if ( $input ) {
|
||||
smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
|
||||
temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true);
|
||||
$1 = &temp;
|
||||
} else {
|
||||
$1 = &tempnull;
|
||||
}
|
||||
%}
|
||||
%typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * %{
|
||||
delete $1;
|
||||
if ($self) $1 = new SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(*$input);
|
||||
%}
|
||||
%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * %{
|
||||
if ($1 && *$1) {
|
||||
intrusive_ptr_add_ref($1->get());
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1->get(), SWIG_intrusive_deleter< CONST TYPE >());
|
||||
} else {
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
|
||||
}
|
||||
if ($owner) delete $1;
|
||||
%}
|
||||
|
||||
%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& (SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > temp, $*1_ltype tempp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
|
||||
// intrusive_ptr by pointer reference
|
||||
smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
|
||||
if ($input) {
|
||||
temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true);
|
||||
}
|
||||
tempp = &temp;
|
||||
$1 = &tempp;
|
||||
%}
|
||||
%typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& %{
|
||||
if ($self) $1 = *$input;
|
||||
%}
|
||||
%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& %{
|
||||
if (*$1 && **$1) {
|
||||
intrusive_ptr_add_ref((*$1)->get());
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >((*$1)->get(), SWIG_intrusive_deleter< CONST TYPE >());
|
||||
} else {
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
|
||||
}
|
||||
%}
|
||||
|
||||
// various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug
|
||||
%typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
|
||||
#error "typemaps for $1_type not available"
|
||||
%}
|
||||
%typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
|
||||
#error "typemaps for $1_type not available"
|
||||
%}
|
||||
|
||||
|
||||
%typemap (jni) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >,
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
|
||||
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
|
||||
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *,
|
||||
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "jlong"
|
||||
%typemap (jtype) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >,
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
|
||||
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
|
||||
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *,
|
||||
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "long"
|
||||
%typemap (jstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >,
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
|
||||
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
|
||||
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *,
|
||||
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "$typemap(jstype, TYPE)"
|
||||
%typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >,
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
|
||||
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
|
||||
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *,
|
||||
SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "$typemap(jstype, TYPE).getCPtr($javainput)"
|
||||
|
||||
%typemap(javaout) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > {
|
||||
long cPtr = $jnicall;
|
||||
return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
|
||||
}
|
||||
%typemap(javaout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
|
||||
long cPtr = $jnicall;
|
||||
return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
|
||||
}
|
||||
%typemap(javaout) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & {
|
||||
long cPtr = $jnicall;
|
||||
return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
|
||||
}
|
||||
%typemap(javaout) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * {
|
||||
long cPtr = $jnicall;
|
||||
return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
|
||||
}
|
||||
%typemap(javaout) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& {
|
||||
long cPtr = $jnicall;
|
||||
return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
|
||||
}
|
||||
|
||||
|
||||
%typemap(javaout) CONST TYPE {
|
||||
return new $typemap(jstype, TYPE)($jnicall, true);
|
||||
}
|
||||
%typemap(javaout) CONST TYPE & {
|
||||
return new $typemap(jstype, TYPE)($jnicall, true);
|
||||
}
|
||||
%typemap(javaout) CONST TYPE * {
|
||||
long cPtr = $jnicall;
|
||||
return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
|
||||
}
|
||||
%typemap(javaout) TYPE *CONST& {
|
||||
long cPtr = $jnicall;
|
||||
return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
|
||||
}
|
||||
|
||||
// Base proxy classes
|
||||
%typemap(javabody) TYPE %{
|
||||
private long swigCPtr;
|
||||
private boolean swigCMemOwnBase;
|
||||
|
||||
PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
|
||||
swigCMemOwnBase = cMemoryOwn;
|
||||
swigCPtr = cPtr;
|
||||
}
|
||||
|
||||
CPTR_VISIBILITY static long getCPtr($javaclassname obj) {
|
||||
return (obj == null) ? 0 : obj.swigCPtr;
|
||||
}
|
||||
%}
|
||||
|
||||
// Derived proxy classes
|
||||
%typemap(javabody_derived) TYPE %{
|
||||
private long swigCPtr;
|
||||
private boolean swigCMemOwnDerived;
|
||||
|
||||
PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
|
||||
super($imclassname.$javaclazznameSWIGSmartPtrUpcast(cPtr), true);
|
||||
swigCMemOwnDerived = cMemoryOwn;
|
||||
swigCPtr = cPtr;
|
||||
}
|
||||
|
||||
CPTR_VISIBILITY static long getCPtr($javaclassname obj) {
|
||||
return (obj == null) ? 0 : obj.swigCPtr;
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized") TYPE {
|
||||
if(swigCPtr != 0 && swigCMemOwnBase) {
|
||||
swigCMemOwnBase = false;
|
||||
$jnicall;
|
||||
}
|
||||
swigCPtr = 0;
|
||||
}
|
||||
|
||||
%typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized") TYPE {
|
||||
if(swigCPtr != 0 && swigCMemOwnDerived) {
|
||||
swigCMemOwnDerived = false;
|
||||
$jnicall;
|
||||
}
|
||||
swigCPtr = 0;
|
||||
super.delete();
|
||||
}
|
||||
|
||||
// CONST version needed ???? also for C#
|
||||
%typemap(jtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "long"
|
||||
%typemap(jtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "long"
|
||||
|
||||
|
||||
%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
|
||||
%template() SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >;
|
||||
%enddef
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
%include <shared_ptr.i>
|
||||
|
||||
%define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP_IMPLEMENTATION(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, CONST, TYPE...)
|
||||
|
||||
%naturalvar TYPE;
|
||||
%naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
|
||||
|
||||
// destructor mods
|
||||
%feature("unref") TYPE "(void)arg1; delete smartarg1;"
|
||||
|
||||
|
||||
// plain value
|
||||
%typemap(in) CONST TYPE ($&1_type argp = 0) %{
|
||||
argp = (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0;
|
||||
if (!argp) {
|
||||
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null $1_type");
|
||||
return $null;
|
||||
}
|
||||
$1 = *argp; %}
|
||||
%typemap(out) CONST TYPE
|
||||
%{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); %}
|
||||
|
||||
// plain pointer
|
||||
%typemap(in) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
|
||||
smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input;
|
||||
$1 = (TYPE *)(smartarg ? smartarg->get() : 0); %}
|
||||
%typemap(out, fragment="SWIG_null_deleter") CONST TYPE * %{
|
||||
*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0;
|
||||
%}
|
||||
|
||||
// plain reference
|
||||
%typemap(in) CONST TYPE & %{
|
||||
$1 = ($1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0);
|
||||
if (!$1) {
|
||||
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null");
|
||||
return $null;
|
||||
} %}
|
||||
%typemap(out, fragment="SWIG_null_deleter") CONST TYPE &
|
||||
%{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %}
|
||||
|
||||
// plain pointer by reference
|
||||
%typemap(in) TYPE *CONST& ($*1_ltype temp = 0)
|
||||
%{ temp = ($*1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0);
|
||||
$1 = &temp; %}
|
||||
%typemap(out, fragment="SWIG_null_deleter") TYPE *CONST&
|
||||
%{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %}
|
||||
|
||||
%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{
|
||||
// shared_ptr by value
|
||||
smartarg = *($&1_ltype*)&$input;
|
||||
if (smartarg) $1 = *smartarg;
|
||||
%}
|
||||
%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ANY_TYPE_SWIGSharedPtrUpcast %{
|
||||
*($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0;
|
||||
%}
|
||||
|
||||
// various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug
|
||||
%typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
|
||||
#error "typemaps for $1_type not available"
|
||||
%}
|
||||
%typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
|
||||
#error "typemaps for $1_type not available"
|
||||
%}
|
||||
|
||||
|
||||
%typemap (jni) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "jlong"
|
||||
%typemap (jtype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "long"
|
||||
%typemap (jstype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "$typemap(jstype, TYPE)"
|
||||
%typemap (javain) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "$typemap(jstype, TYPE).getCPtr($javainput)"
|
||||
%typemap(javaout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
|
||||
long cPtr = $jnicall;
|
||||
return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
|
||||
}
|
||||
|
||||
%typemap(javaout) CONST TYPE {
|
||||
return new $typemap(jstype, TYPE)($jnicall, true);
|
||||
}
|
||||
%typemap(javaout) CONST TYPE & {
|
||||
return new $typemap(jstype, TYPE)($jnicall, true);
|
||||
}
|
||||
%typemap(javaout) CONST TYPE * {
|
||||
long cPtr = $jnicall;
|
||||
return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
|
||||
}
|
||||
%typemap(javaout) TYPE *CONST& {
|
||||
long cPtr = $jnicall;
|
||||
return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
|
||||
}
|
||||
|
||||
// Base proxy classes
|
||||
%typemap(javabody) TYPE %{
|
||||
private long swigCPtr;
|
||||
private boolean swigCMemOwnBase;
|
||||
|
||||
PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
|
||||
swigCMemOwnBase = cMemoryOwn;
|
||||
swigCPtr = cPtr;
|
||||
}
|
||||
|
||||
CPTR_VISIBILITY static long getCPtr($javaclassname obj) {
|
||||
return (obj == null) ? 0 : obj.swigCPtr;
|
||||
}
|
||||
%}
|
||||
|
||||
// Derived proxy classes
|
||||
%typemap(javabody_derived) TYPE %{
|
||||
private long swigCPtr;
|
||||
private boolean swigCMemOwnDerived;
|
||||
|
||||
PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
|
||||
super($imclassname.$javaclazznameSWIGSmartPtrUpcast(cPtr), true);
|
||||
swigCMemOwnDerived = cMemoryOwn;
|
||||
swigCPtr = cPtr;
|
||||
}
|
||||
|
||||
CPTR_VISIBILITY static long getCPtr($javaclassname obj) {
|
||||
return (obj == null) ? 0 : obj.swigCPtr;
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized") TYPE {
|
||||
if (swigCPtr != 0) {
|
||||
if (swigCMemOwnBase) {
|
||||
swigCMemOwnBase = false;
|
||||
$jnicall;
|
||||
}
|
||||
swigCPtr = 0;
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized") TYPE {
|
||||
if (swigCPtr != 0) {
|
||||
if (swigCMemOwnDerived) {
|
||||
swigCMemOwnDerived = false;
|
||||
$jnicall;
|
||||
}
|
||||
swigCPtr = 0;
|
||||
}
|
||||
super.delete();
|
||||
}
|
||||
|
||||
// CONST version needed ???? also for C#
|
||||
%typemap(jtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "long"
|
||||
%typemap(jtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "long"
|
||||
|
||||
|
||||
%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
|
||||
%enddef
|
||||
|
||||
|
|
|
|||
|
|
@ -146,10 +146,10 @@
|
|||
// Base proxy classes
|
||||
%typemap(javabody) TYPE %{
|
||||
private long swigCPtr;
|
||||
private boolean swigCMemOwnBase;
|
||||
private boolean swigCMemOwn;
|
||||
|
||||
PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
|
||||
swigCMemOwnBase = cMemoryOwn;
|
||||
swigCMemOwn = cMemoryOwn;
|
||||
swigCPtr = cPtr;
|
||||
}
|
||||
|
||||
|
|
@ -176,8 +176,8 @@
|
|||
|
||||
%typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized") TYPE {
|
||||
if (swigCPtr != 0) {
|
||||
if (swigCMemOwnBase) {
|
||||
swigCMemOwnBase = false;
|
||||
if (swigCMemOwn) {
|
||||
swigCMemOwn = false;
|
||||
$jnicall;
|
||||
}
|
||||
swigCPtr = 0;
|
||||
|
|
|
|||
|
|
@ -25,9 +25,9 @@ namespace Swig {
|
|||
|
||||
bool set(JNIEnv *jenv, jobject jobj, bool mem_own, bool weak_global) {
|
||||
if (!jthis_) {
|
||||
weak_global_ = weak_global;
|
||||
weak_global_ = weak_global || !mem_own; // hold as weak global if explicitly requested or not owned
|
||||
if (jobj)
|
||||
jthis_ = ((weak_global_ || !mem_own) ? jenv->NewWeakGlobalRef(jobj) : jenv->NewGlobalRef(jobj));
|
||||
jthis_ = weak_global_ ? jenv->NewWeakGlobalRef(jobj) : jenv->NewGlobalRef(jobj);
|
||||
#if defined(DEBUG_DIRECTOR_OWNED)
|
||||
std::cout << "JObjectWrapper::set(" << jobj << ", " << (weak_global ? "weak_global" : "global_ref") << ") -> " << jthis_ << std::endl;
|
||||
#endif
|
||||
|
|
@ -68,6 +68,7 @@ namespace Swig {
|
|||
weak_global_ = true;
|
||||
}
|
||||
|
||||
/* Only call peek if you know what you are doing wrt to weak/global references */
|
||||
jobject peek() {
|
||||
return jthis_;
|
||||
}
|
||||
|
|
@ -149,7 +150,7 @@ namespace Swig {
|
|||
void swig_disconnect_director_self(const char *disconn_method) {
|
||||
JNIEnvWrapper jnienv(this) ;
|
||||
JNIEnv *jenv = jnienv.getJNIEnv() ;
|
||||
jobject jobj = swig_self_.peek();
|
||||
jobject jobj = swig_self_.get(jenv);
|
||||
#if defined(DEBUG_DIRECTOR_OWNED)
|
||||
std::cout << "Swig::Director::disconnect_director_self(" << jobj << ")" << std::endl;
|
||||
#endif
|
||||
|
|
@ -162,6 +163,7 @@ namespace Swig {
|
|||
jenv->CallVoidMethod(jobj, disconn_meth);
|
||||
}
|
||||
}
|
||||
jenv->DeleteLocalRef(jobj);
|
||||
}
|
||||
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -1301,11 +1301,16 @@ SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE)
|
|||
%typemap(javain) (char *STRING, size_t LENGTH) "$javainput"
|
||||
%typemap(freearg) (char *STRING, size_t LENGTH) ""
|
||||
%typemap(in) (char *STRING, size_t LENGTH) {
|
||||
if ($input) {
|
||||
$1 = (char *) JCALL2(GetByteArrayElements, jenv, $input, 0);
|
||||
$2 = (size_t) JCALL1(GetArrayLength, jenv, $input);
|
||||
$2 = (size_t) JCALL1(GetArrayLength, jenv, $input);
|
||||
} else {
|
||||
$1 = 0;
|
||||
$2 = 0;
|
||||
}
|
||||
}
|
||||
%typemap(argout) (char *STRING, size_t LENGTH) {
|
||||
JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, 0);
|
||||
if ($input) JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, 0);
|
||||
}
|
||||
%typemap(directorin, descriptor="[B") (char *STRING, size_t LENGTH) {
|
||||
jbyteArray jb = (jenv)->NewByteArray($2);
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class string;
|
|||
|
||||
%typemap(in) string
|
||||
%{ if(!$input) {
|
||||
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::string");
|
||||
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null string");
|
||||
return $null;
|
||||
}
|
||||
const char *$1_pstr = (const char *)jenv->GetStringUTFChars($input, 0);
|
||||
|
|
@ -38,7 +38,7 @@ class string;
|
|||
|
||||
%typemap(directorout) string
|
||||
%{ if(!$input) {
|
||||
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::string");
|
||||
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null string");
|
||||
return $null;
|
||||
}
|
||||
const char *$1_pstr = (const char *)jenv->GetStringUTFChars($input, 0);
|
||||
|
|
@ -73,24 +73,24 @@ class string;
|
|||
|
||||
%typemap(in) const string &
|
||||
%{ if(!$input) {
|
||||
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::string");
|
||||
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null string");
|
||||
return $null;
|
||||
}
|
||||
const char *$1_pstr = (const char *)jenv->GetStringUTFChars($input, 0);
|
||||
if (!$1_pstr) return $null;
|
||||
std::string $1_str($1_pstr);
|
||||
$*1_ltype $1_str($1_pstr);
|
||||
$1 = &$1_str;
|
||||
jenv->ReleaseStringUTFChars($input, $1_pstr); %}
|
||||
|
||||
%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const string &
|
||||
%{ if(!$input) {
|
||||
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::string");
|
||||
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null string");
|
||||
return $null;
|
||||
}
|
||||
const char *$1_pstr = (const char *)jenv->GetStringUTFChars($input, 0);
|
||||
if (!$1_pstr) return $null;
|
||||
/* possible thread/reentrant code problem */
|
||||
static std::string $1_str;
|
||||
static $*1_ltype $1_str;
|
||||
$1_str = $1_pstr;
|
||||
$result = &$1_str;
|
||||
jenv->ReleaseStringUTFChars($input, $1_pstr); %}
|
||||
|
|
|
|||
|
|
@ -195,6 +195,7 @@ There are no char *OUTPUT typemaps, however you can apply the signed char * type
|
|||
SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element");
|
||||
return $null;
|
||||
}
|
||||
temp = ($*1_ltype)0;
|
||||
$1 = &temp;
|
||||
}
|
||||
|
||||
|
|
@ -206,8 +207,8 @@ There are no char *OUTPUT typemaps, however you can apply the signed char * type
|
|||
JCALL4(Set##JAVATYPE##ArrayRegion, jenv, $input, 0, 1, &jvalue);
|
||||
}
|
||||
|
||||
%typemap(typecheck) TYPE *INOUT = TYPECHECKTYPE;
|
||||
%typemap(typecheck) TYPE &INOUT = TYPECHECKTYPE;
|
||||
%typemap(typecheck) TYPE *OUTPUT = TYPECHECKTYPE;
|
||||
%typemap(typecheck) TYPE &OUTPUT = TYPECHECKTYPE;
|
||||
%enddef
|
||||
|
||||
OUTPUT_TYPEMAP(bool, jboolean, boolean, Boolean, "[Ljava/lang/Boolean;", jbooleanArray);
|
||||
|
|
@ -226,6 +227,20 @@ OUTPUT_TYPEMAP(double, jdouble, double, Double, "[Ljava/lang/Double;", jdoubleAr
|
|||
|
||||
#undef OUTPUT_TYPEMAP
|
||||
|
||||
%typemap(in) bool *OUTPUT($*1_ltype temp), bool &OUTPUT($*1_ltype temp)
|
||||
{
|
||||
if (!$input) {
|
||||
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null");
|
||||
return $null;
|
||||
}
|
||||
if (JCALL1(GetArrayLength, jenv, $input) == 0) {
|
||||
SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element");
|
||||
return $null;
|
||||
}
|
||||
temp = false;
|
||||
$1 = &temp;
|
||||
}
|
||||
|
||||
/* Convert to BigInteger - byte array holds number in 2's complement big endian format */
|
||||
/* Use first element in BigInteger array for output */
|
||||
/* Overrides the typemap in the OUTPUT_TYPEMAP macro */
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@
|
|||
$1[i] = 0;
|
||||
} else {
|
||||
$1 = 0;
|
||||
size = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -113,6 +114,7 @@
|
|||
return $null;
|
||||
}
|
||||
$1 = &temp;
|
||||
*$1 = 0;
|
||||
}
|
||||
|
||||
%typemap(argout) char **STRING_OUT {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
* std::helpers for LUA
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include <std_except.i> // the general exepctions
|
||||
%include <std_except.i> // the general exceptions
|
||||
|
||||
/*
|
||||
The basic idea here, is instead of trying to feed SWIG all the
|
||||
|
|
@ -16,9 +16,9 @@ so the class declarations become just a set of %defines
|
|||
*/
|
||||
|
||||
/* #define for basic container features
|
||||
note: I allow front(), back() & pop_back() to throw execptions
|
||||
note: I allow front(), back() & pop_back() to throw exceptions
|
||||
upon empty containers, rather than coredump
|
||||
(as we have'nt defined the methods, we can use %extend to add with
|
||||
(as we haven't defined the methods, we can use %extend to add with
|
||||
new features)
|
||||
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Small change to the standard carrays.i
|
||||
renaming the field to __getitem__ & __setitem__
|
||||
renaming the field to __getitem & __setitem
|
||||
for operator[] access
|
||||
*/
|
||||
%rename(__getitem) *::getitem; // the v=X[i] (get operator)
|
||||
|
|
|
|||
|
|
@ -5,30 +5,6 @@
|
|||
* This file is parsed by SWIG before reading any other interface file.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%insert("runtime") %{
|
||||
/* Lua flavors */
|
||||
#define SWIG_LUA_FLAVOR_LUA 1
|
||||
#define SWIG_LUA_FLAVOR_ELUA 2
|
||||
#define SWIG_LUA_FLAVOR_ELUAC 3
|
||||
|
||||
#if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)
|
||||
# define SWIG_LUA_CONSTTAB_INT(B, C) LSTRKEY(B), LNUMVAL(C)
|
||||
# define SWIG_LUA_CONSTTAB_FLOAT(B, C) LSTRKEY(B), LNUMVAL(C)
|
||||
# define SWIG_LUA_CONSTTAB_STRING(B, C) LSTRKEY(B), LSTRVAL(C)
|
||||
# define SWIG_LUA_CONSTTAB_CHAR(B, C) LSTRKEY(B), LNUMVAL(C)
|
||||
# else /* SWIG_LUA_FLAVOR_LUA */
|
||||
# define SWIG_LUA_CONSTTAB_INT(B, C) SWIG_LUA_INT, (char *)B, (long)C, 0, 0, 0
|
||||
# define SWIG_LUA_CONSTTAB_FLOAT(B, C) SWIG_LUA_FLOAT, (char *)B, 0, (double)C, 0, 0
|
||||
# define SWIG_LUA_CONSTTAB_STRING(B, C) SWIG_LUA_STRING, (char *)B, 0, 0, (void *)C, 0
|
||||
# define SWIG_LUA_CONSTTAB_CHAR(B, C) SWIG_LUA_CHAR, (char *)B, (long)C, 0, 0, 0
|
||||
#endif
|
||||
|
||||
#if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)
|
||||
# define LRO_STRVAL(v) {{.p = (char *) v}, LUA_TSTRING}
|
||||
# define LSTRVAL LRO_STRVAL
|
||||
#endif
|
||||
%}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* includes
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
@ -166,8 +142,8 @@
|
|||
/* ------------------------------------------------------------
|
||||
* Exceptions
|
||||
* ------------------------------------------------------------ */
|
||||
/* Confession: I dont really like C++ exceptions
|
||||
The python/lua ones are great, but C++ ones I dont like
|
||||
/* Confession: I don't really like C++ exceptions
|
||||
The python/lua ones are great, but C++ ones I don't like
|
||||
(mainly because I cannot get the stack trace out of it)
|
||||
Therefore I have not bothered to try doing much in this
|
||||
|
||||
|
|
@ -215,7 +191,7 @@ There are a few options:
|
|||
- return a copy of it: but not all objects are copyable
|
||||
(see exception_partial_info in the test suite for a case where you cannot do this)
|
||||
- convert to a string & throw that
|
||||
its not so useful, but it works (this is more lua like).
|
||||
it's not so useful, but it works (this is more lua like).
|
||||
The third option (though not nice) is used
|
||||
For a more useful solution: see std_except for more details
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
* Basic function pointer support
|
||||
* ----------------------------------------------------------------------------- */
|
||||
/*
|
||||
The structure: SWIGLUA_FN provides a simple (local only) wrappering for a function.
|
||||
The structure: SWIGLUA_FN provides a simple (local only) wrapping for a function.
|
||||
|
||||
For example if you wanted to have a C/C++ function take a lua function as a parameter.
|
||||
You could declare it as:
|
||||
|
|
@ -29,7 +29,7 @@ just push the parameters, call the function and return the result.
|
|||
return luaL_checknumber(fn.L,-1);
|
||||
}
|
||||
|
||||
SWIG will automatically performs the wrappering of the arguments in and out.
|
||||
SWIG will automatically performs the wrapping of the arguments in and out.
|
||||
|
||||
However: if you wish to store the function between calls, look to the SWIGLUA_REF below.
|
||||
|
||||
|
|
@ -64,8 +64,8 @@ Then call it later, You could declare it as:
|
|||
note: it should be passed by value, not byref or as a pointer.
|
||||
|
||||
The SWIGLUA_REF holds a pointer to the lua_State, and an integer reference to the object.
|
||||
Because it holds a permenet ref to an object, the SWIGLUA_REF must be handled with a bit more care.
|
||||
It should be initalised to {0,0}. The function swiglua_ref_set() should be used to set it.
|
||||
Because it holds a permanent ref to an object, the SWIGLUA_REF must be handled with a bit more care.
|
||||
It should be initialised to {0,0}. The function swiglua_ref_set() should be used to set it.
|
||||
swiglua_ref_clear() should be used to clear it when not in use, and swiglua_ref_get() to get the
|
||||
data back.
|
||||
|
||||
|
|
@ -82,7 +82,7 @@ if you need that you must add it yourself.
|
|||
return luaL_checknumber(fn.L,-1);
|
||||
}
|
||||
|
||||
SWIG will automatically performs the wrappering of the arguments in and out.
|
||||
SWIG will automatically performs the wrapping of the arguments in and out.
|
||||
|
||||
However: if you wish to store the function between calls, look to the SWIGLUA_REF below.
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,35 @@ extern "C" {
|
|||
#include <stdlib.h> /* for malloc */
|
||||
#include <assert.h> /* for a few sanity tests */
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Lua flavors
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#define SWIG_LUA_FLAVOR_LUA 1
|
||||
#define SWIG_LUA_FLAVOR_ELUA 2
|
||||
#define SWIG_LUA_FLAVOR_ELUAC 3
|
||||
|
||||
#if !defined(SWIG_LUA_TARGET)
|
||||
# error SWIG_LUA_TARGET not defined
|
||||
#endif
|
||||
|
||||
#if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)
|
||||
# define SWIG_LUA_CONSTTAB_INT(B, C) LSTRKEY(B), LNUMVAL(C)
|
||||
# define SWIG_LUA_CONSTTAB_FLOAT(B, C) LSTRKEY(B), LNUMVAL(C)
|
||||
# define SWIG_LUA_CONSTTAB_STRING(B, C) LSTRKEY(B), LSTRVAL(C)
|
||||
# define SWIG_LUA_CONSTTAB_CHAR(B, C) LSTRKEY(B), LNUMVAL(C)
|
||||
#else /* SWIG_LUA_FLAVOR_LUA */
|
||||
# define SWIG_LUA_CONSTTAB_INT(B, C) SWIG_LUA_INT, (char *)B, (long)C, 0, 0, 0
|
||||
# define SWIG_LUA_CONSTTAB_FLOAT(B, C) SWIG_LUA_FLOAT, (char *)B, 0, (double)C, 0, 0
|
||||
# define SWIG_LUA_CONSTTAB_STRING(B, C) SWIG_LUA_STRING, (char *)B, 0, 0, (void *)C, 0
|
||||
# define SWIG_LUA_CONSTTAB_CHAR(B, C) SWIG_LUA_CHAR, (char *)B, (long)C, 0, 0, 0
|
||||
#endif
|
||||
|
||||
#if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)
|
||||
# define LRO_STRVAL(v) {{.p = (char *) v}, LUA_TSTRING}
|
||||
# define LSTRVAL LRO_STRVAL
|
||||
#endif
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* compatibility defines
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
@ -92,7 +121,7 @@ typedef struct swig_lua_class {
|
|||
const char **base_names;
|
||||
} swig_lua_class;
|
||||
|
||||
/* this is the struct for wrappering all pointers in SwigLua
|
||||
/* this is the struct for wrapping all pointers in SwigLua
|
||||
*/
|
||||
typedef struct {
|
||||
swig_type_info *type;
|
||||
|
|
@ -100,7 +129,7 @@ typedef struct {
|
|||
void *ptr;
|
||||
} swig_lua_userdata;
|
||||
|
||||
/* this is the struct for wrapping arbitary packed binary data
|
||||
/* this is the struct for wrapping arbitrary packed binary data
|
||||
(currently it is only used for member function pointers)
|
||||
the data ordering is similar to swig_lua_userdata, but it is currently not possible
|
||||
to tell the two structures apart within SWIG, other than by looking at the type
|
||||
|
|
@ -184,7 +213,7 @@ SWIG_Lua_SetModule(lua_State* L, swig_module_info *module) {
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* this function is called when trying to set an immutable.
|
||||
default value is to print an error.
|
||||
default action is to print an error.
|
||||
This can removed with a compile flag SWIGLUA_IGNORE_SET_IMMUTABLE */
|
||||
SWIGINTERN int SWIG_Lua_set_immutable(lua_State* L)
|
||||
{
|
||||
|
|
@ -605,7 +634,7 @@ SWIGINTERN void SWIG_Lua_init_base_class(lua_State* L,swig_lua_class* clss)
|
|||
swig_type_info *info = SWIG_TypeQueryModule(module,module,clss->base_names[i]);
|
||||
if (info) clss->bases[i] = (swig_lua_class *) info->clientdata;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* performs the entire class registration process */
|
||||
|
|
@ -853,8 +882,8 @@ SWIG_Lua_InstallConstants(lua_State* L, swig_lua_const_info constants[]) {
|
|||
#ifndef SWIG_DOSTRING_FAIL /* Allows redefining of error function */
|
||||
#define SWIG_DOSTRING_FAIL(S) fprintf(stderr,"%s\n",S)
|
||||
#endif
|
||||
/* Executes a C string in Lua a really simple way of calling lua from C
|
||||
Unfortunately lua keeps changing its API's, so we need a conditional compile
|
||||
/* Executes a C string in Lua which is a really simple way of calling lua from C
|
||||
Unfortunately lua keeps changing its APIs, so we need a conditional compile
|
||||
In lua 5.0.X its lua_dostring()
|
||||
In lua 5.1.X its luaL_dostring()
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ extern "C" {
|
|||
#endif
|
||||
/* this is the initialization function
|
||||
added at the very end of the code
|
||||
the function is always called SWIG_init, but an eariler #define will rename it
|
||||
the function is always called SWIG_init, but an earlier #define will rename it
|
||||
*/
|
||||
#if ((SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC))
|
||||
LUALIB_API int SWIG_init(lua_State* L)
|
||||
|
|
@ -53,7 +53,7 @@ SWIGEXPORT int SWIG_init(lua_State* L) /* default Lua action */
|
|||
#endif
|
||||
|
||||
#if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC)
|
||||
/* set up base class pointers (the hierachy) */
|
||||
/* set up base class pointers (the hierarchy) */
|
||||
for (i = 0; swig_types[i]; i++){
|
||||
if (swig_types[i]->clientdata){
|
||||
SWIG_Lua_init_base_class(L,(swig_lua_class*)(swig_types[i]->clientdata));
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
the fn call must be of the form
|
||||
int checkfn(lua_State *L, int index);
|
||||
and return 1/0 depending upon if this is the correct type
|
||||
For the typemap(out), an additional SWIG_arg parmeter must be incremented
|
||||
For the typemap(out), an additional SWIG_arg parameter must be incremented
|
||||
to reflect the number of values returned (normally SWIG_arg++; will do)
|
||||
*/
|
||||
// numbers
|
||||
|
|
@ -33,7 +33,7 @@ $1 = ($type)lua_tonumber(L, $input);%}
|
|||
float,double
|
||||
%{ lua_pushnumber(L, (lua_Number) $1); SWIG_arg++;%}
|
||||
|
||||
// we must also provide typemaps for privitives by const reference:
|
||||
// we must also provide typemaps for primitives by const reference:
|
||||
// given a function:
|
||||
// int intbyref(const int& i);
|
||||
// SWIG assumes that this code will need a pointer to int to be passed in
|
||||
|
|
@ -132,7 +132,7 @@ SWIGINTERN int SWIG_lua_isnilstring(lua_State *L, int idx) {
|
|||
// it should be converted to a SWIG NULL.
|
||||
// This will only be allowed for pointers & arrays, not refs or by value
|
||||
// the checkfn lua_isuserdata will only work for userdata
|
||||
// the checkfn SWIG_isptrtype will work for both userdata and nil's
|
||||
// the checkfn SWIG_isptrtype will work for both userdata and nil
|
||||
%typemap(in,checkfn="SWIG_isptrtype") SWIGTYPE*,SWIGTYPE[]
|
||||
%{
|
||||
if (!SWIG_IsOK(SWIG_ConvertPtr(L,$input,(void**)&$1,$descriptor,$disown))){
|
||||
|
|
@ -219,9 +219,9 @@ $1=($1_ltype)&temp;%}
|
|||
|
||||
// member function pointer
|
||||
// a member fn ptr is not 4 bytes like a normal pointer, but 8 bytes (at least on mingw)
|
||||
// so the standard wrappering cannot be done
|
||||
// so the standard wrapping cannot be done
|
||||
// nor can you cast a member function pointer to a void* (obviously)
|
||||
// therefore a special wrappering functions SWIG_ConvertMember() & SWIG_NewMemberObj() were written
|
||||
// therefore a special wrapping functions SWIG_ConvertMember() & SWIG_NewMemberObj() were written
|
||||
#ifdef __cplusplus
|
||||
%typemap(in,checkfn="lua_isuserdata") SWIGTYPE (CLASS::*)
|
||||
%{
|
||||
|
|
@ -241,7 +241,7 @@ $1=($1_ltype)&temp;%}
|
|||
|
||||
/* void* is a special case
|
||||
A function void fn(void*) should take any kind of pointer as a parameter (just like C/C++ does)
|
||||
but if its an output, then it should be wrappered like any other SWIG object (using default typemap)
|
||||
but if its an output, then it should be wrapped like any other SWIG object (using default typemap)
|
||||
*/
|
||||
%typemap(in,checkfn="SWIG_isptrtype") void*
|
||||
%{$1=($1_ltype)SWIG_MustGetPtr(L,$input,0,0,$argnum,"$symname");%}
|
||||
|
|
@ -269,7 +269,7 @@ void fn(int a, float b, lua_State* s) is wrappable as
|
|||
* ----------------------------------------------------------------------------- */
|
||||
/* These are needed for the overloaded functions
|
||||
These define the detection routines which will spot what
|
||||
parmeters match which function
|
||||
parameters match which function
|
||||
*/
|
||||
|
||||
// unfortunately lua only considers one type of number
|
||||
|
|
@ -341,7 +341,7 @@ parmeters match which function
|
|||
}
|
||||
}
|
||||
|
||||
// Also needed for object ptrs by const ref
|
||||
// Also needed for object pointers by const ref
|
||||
// eg const A* ref_pointer(A* const& a);
|
||||
// found in mixed_types.i
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *const&
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ namespace std
|
|||
};
|
||||
}
|
||||
|
||||
// normally object which are thrown are returned to interpreter as errors
|
||||
// (which potentally may have problems if they are not copied)
|
||||
// normally objects which are thrown are returned to the interpreter as errors
|
||||
// (which potentially may have problems if they are not copied)
|
||||
// therefore all classes based upon std::exception are converted to their strings & returned as errors
|
||||
%typemap(throws) std::bad_exception "SWIG_exception(SWIG_RuntimeError, $1.what());"
|
||||
%typemap(throws) std::domain_error "SWIG_exception(SWIG_ValueError, $1.what());"
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
/*
|
||||
A really cut down version of the pair class.
|
||||
|
||||
this is not useful on its owns is it needs a %template definition with it
|
||||
this is not useful on its own - it needs a %template definition with it
|
||||
|
||||
eg.
|
||||
namespace std {
|
||||
|
|
|
|||
|
|
@ -5,10 +5,11 @@
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%{
|
||||
#include <string>
|
||||
#include <string>
|
||||
%}
|
||||
|
||||
/*
|
||||
Only std::string and const std::string& are typemaped
|
||||
Only std::string and const std::string& are typemapped
|
||||
they are converted to the Lua strings automatically
|
||||
|
||||
std::string& and std::string* are not
|
||||
|
|
@ -25,14 +26,15 @@ can be used as
|
|||
s="hello world"
|
||||
s2=test_value(s)
|
||||
assert(s==s2)
|
||||
|
||||
*/
|
||||
|
||||
%naturalvar std::string;
|
||||
namespace std {
|
||||
|
||||
%naturalvar string;
|
||||
|
||||
/*
|
||||
Bug report #1526022 by neomantra
|
||||
Lua strings and std::string can contain embeded zero's
|
||||
Bug report #1526022:
|
||||
Lua strings and std::string can contain embedded zero bytes
|
||||
Therefore a standard out typemap should not be:
|
||||
lua_pushstring(L,$1.c_str());
|
||||
but
|
||||
|
|
@ -46,77 +48,51 @@ becomes
|
|||
Not using: lua_tolstring() as this is only found in Lua 5.1 & not 5.0.2
|
||||
*/
|
||||
|
||||
%typemap(in,checkfn="lua_isstring") std::string
|
||||
%typemap(in,checkfn="lua_isstring") string
|
||||
%{$1.assign(lua_tostring(L,$input),lua_rawlen(L,$input));%}
|
||||
%typemap(out) std::string
|
||||
|
||||
%typemap(out) string
|
||||
%{ lua_pushlstring(L,$1.data(),$1.size()); SWIG_arg++;%}
|
||||
|
||||
%typemap(in,checkfn="lua_isstring") const std::string& (std::string temp)
|
||||
%typemap(in,checkfn="lua_isstring") const string& ($*1_ltype temp)
|
||||
%{temp.assign(lua_tostring(L,$input),lua_rawlen(L,$input)); $1=&temp;%}
|
||||
|
||||
%typemap(out) const std::string&
|
||||
%typemap(out) const string&
|
||||
%{ lua_pushlstring(L,$1->data(),$1->size()); SWIG_arg++;%}
|
||||
|
||||
// for throwing of any kind of string, string ref's and string pointers
|
||||
// we convert all to lua strings
|
||||
%typemap(throws) std::string,std::string&,const std::string&
|
||||
%typemap(throws) string, string&, const string&
|
||||
%{ lua_pushlstring(L,$1.data(),$1.size()); SWIG_fail;%}
|
||||
%typemap(throws) std::string*,const std::string*
|
||||
|
||||
%typemap(throws) string*, const string*
|
||||
%{ lua_pushlstring(L,$1->data(),$1->size()); SWIG_fail;%}
|
||||
|
||||
// and the typechecks
|
||||
%typecheck(SWIG_TYPECHECK_STRING) std::string,const std::string& {
|
||||
%typecheck(SWIG_TYPECHECK_STRING) string, const string& {
|
||||
$1 = lua_isstring(L,$input);
|
||||
}
|
||||
|
||||
/*
|
||||
std::string& can be wrappered, but you must inform SWIG if it is in or out
|
||||
std::string& can be wrapped, but you must inform SWIG if it is in or out
|
||||
|
||||
eg:
|
||||
void fn(std::string& str);
|
||||
Is this an in/out/inout value?
|
||||
|
||||
Therefore you need the usual
|
||||
%apply (std::string& INOUT) {(std::string& str)};
|
||||
%apply (std::string& INOUT) {std::string& str};
|
||||
or
|
||||
%apply std::string& INOUT {std::string& str};
|
||||
typemaps to tell SWIG what to do.
|
||||
*/
|
||||
|
||||
%typemap(in) std::string &INPUT=const std::string &;
|
||||
%typemap(in, numinputs=0) std::string &OUTPUT (std::string temp)
|
||||
%typemap(in) string &INPUT=const string &;
|
||||
%typemap(in, numinputs=0) string &OUTPUT ($*1_ltype temp)
|
||||
%{ $1 = &temp; %}
|
||||
%typemap(argout) std::string &OUTPUT
|
||||
%typemap(argout) string &OUTPUT
|
||||
%{ lua_pushlstring(L,$1->data(),$1->size()); SWIG_arg++;%}
|
||||
%typemap(in) std::string &INOUT =const std::string &;
|
||||
%typemap(argout) std::string &INOUT = std::string &OUTPUT;
|
||||
|
||||
/*
|
||||
For const std::string* and std::string* is not clear
|
||||
is this a pointer or an array?
|
||||
|
||||
Therefore just leaving it as is
|
||||
(there is some rough code below which could be used if needed
|
||||
|
||||
// SWIG wraps const ref's as pointer
|
||||
// typemaps to deal with this and const ptrs
|
||||
%typemap(in,checkfn="lua_isstring")
|
||||
const std::string& INPUT(std::string temp),
|
||||
const std::string* INPUT(std::string temp)
|
||||
%{temp=(char*)lua_tostring(L, $input); $1=&temp;%}
|
||||
%typemap(out) const std::string&, const std::string*
|
||||
%{ lua_pushstring(L,$1->c_str()); SWIG_arg++;%}
|
||||
|
||||
// the non-const pointer version
|
||||
%typemap(in) std::string *INPUT=const std::string *INPUT;
|
||||
%typemap(in, numinputs=0) std::string *OUTPUT (std::string temp)
|
||||
%{ $1 = &temp; %}
|
||||
%typemap(argout) std::string *OUTPUT
|
||||
%{ lua_pushstring(L,$1->c_str()); SWIG_arg++;%}
|
||||
%typemap(in) std::string *INOUT = std::string *INPUT;
|
||||
%typemap(argout) std::string *INOUT = std::string *OUTPUT;
|
||||
|
||||
*/
|
||||
%typemap(in) string &INOUT =const string &;
|
||||
%typemap(argout) string &INOUT = string &OUTPUT;
|
||||
|
||||
/*
|
||||
A really cut down version of the string class
|
||||
|
|
@ -128,25 +104,24 @@ and little else
|
|||
note: no fn's taking the const string&
|
||||
as this is overloaded by the const char* version
|
||||
*/
|
||||
namespace std {
|
||||
|
||||
class string {
|
||||
public:
|
||||
string();
|
||||
string(const char*);
|
||||
//string(const string&);
|
||||
unsigned int size() const;
|
||||
unsigned int length() const;
|
||||
bool empty() const;
|
||||
// no support for operator[]
|
||||
const char* c_str()const;
|
||||
const char* data()const;
|
||||
// assign does not return a copy of this object
|
||||
// (no point in a scripting language)
|
||||
void assign(const char*);
|
||||
//void assign(const string&);
|
||||
// no support for all the other features
|
||||
// its probably better to do it in lua
|
||||
};
|
||||
class string {
|
||||
public:
|
||||
string();
|
||||
string(const char*);
|
||||
//string(const string&);
|
||||
unsigned int size() const;
|
||||
unsigned int length() const;
|
||||
bool empty() const;
|
||||
// no support for operator[]
|
||||
const char* c_str()const;
|
||||
const char* data()const;
|
||||
// assign does not return a copy of this object
|
||||
// (no point in a scripting language)
|
||||
void assign(const char*);
|
||||
//void assign(const string&);
|
||||
// no support for all the other features
|
||||
// it's probably better to do it in lua
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
%{
|
||||
#include <vector>
|
||||
%}
|
||||
%include <std_except.i> // the general exepctions
|
||||
%include <std_except.i> // the general exceptions
|
||||
/*
|
||||
A really cut down version of the vector class.
|
||||
|
||||
|
|
|
|||
|
|
@ -140,21 +140,21 @@ a few things of note:
|
|||
so for the above mentioned return_array_5() would look like
|
||||
arr=return_array_5() -- no parameters passed in
|
||||
* for INOUT arrays, a table must be passed in, and a new table will be returned
|
||||
(this is consistant with the way that numbers are processed)
|
||||
(this is consistent with the way that numbers are processed)
|
||||
if you want just use
|
||||
arr={...}
|
||||
arr=process_var_array_inout(arr) -- arr is replaced by the new version
|
||||
|
||||
The following are not yet supported:
|
||||
* variable length output only array (inout's work ok)
|
||||
* multidimentional arrays
|
||||
* variable length output only array (inout works ok)
|
||||
* multidimensional arrays
|
||||
* arrays of objects/structs
|
||||
* arrays of pointers
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
The internals of the array managment stuff
|
||||
The internals of the array management stuff
|
||||
helper fns/macros
|
||||
SWIG_ALLOC_ARRAY(TYPE,LEN) // returns a typed array TYPE[LEN]
|
||||
SWIG_FREE_ARRAY(PTR) // delete the ptr (if not zero)
|
||||
|
|
@ -367,7 +367,7 @@ SWIG_TYPEMAP_NUM_ARR(double,double);
|
|||
%typemap(freearg) enum SWIGTYPE INPUT[ANY]
|
||||
%{ SWIG_FREE_ARRAY($1);%}
|
||||
|
||||
// variable size array's
|
||||
// variable size arrays
|
||||
%typemap(in) (enum SWIGTYPE *INPUT,int)
|
||||
%{ $1 = ($ltype)SWIG_get_int_num_array_var(L,$input,&$2);
|
||||
if (!$1) SWIG_fail;%}
|
||||
|
|
@ -414,7 +414,7 @@ void** SWIG_get_ptr_array_var(lua_State* L, int index, int* size,swig_type_info
|
|||
// all pointers have the ownership value 'own' (normally 0)
|
||||
void SWIG_write_ptr_array(lua_State* L,void **array,int size,int own);
|
||||
// read the specified table, and fills the array with ptrs
|
||||
// returns 1 of ok (only fails if it doesnt find correct type of ptrs)
|
||||
// returns 1 of ok (only fails if it doesn't find correct type of ptrs)
|
||||
// helper fn (called by SWIG_get_ptr_array_*() fns)
|
||||
int SWIG_read_ptr_array(lua_State* L,int index,void **array,int size,swig_type_info *type);
|
||||
|
||||
|
|
@ -424,7 +424,7 @@ modification of pointers ownership in the arrays
|
|||
eg A fn:
|
||||
void pointers_in(TYPE* arr[],int len);
|
||||
will make copies of the pointer into a temp array and then pass it into the fn
|
||||
Lua does not remeber that this fn held the pointers, so it is not safe to keep
|
||||
Lua does not remember that this fn held the pointers, so it is not safe to keep
|
||||
these pointers until later
|
||||
|
||||
eg A fn:
|
||||
|
|
@ -551,7 +551,7 @@ free(ptr);
|
|||
With the following SWIG code
|
||||
%apply SWIGTYPE** OUTPUT{iMath **pptr };
|
||||
|
||||
You can get natural wrappering in Lua as follows:
|
||||
You can get natural wrapping in Lua as follows:
|
||||
ok,ptr=Create_Math() -- ptr is a iMath* which is returned with the int
|
||||
ptr=nil -- the iMath* will be GC'ed as normal
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
|
||||
co::
|
||||
co:
|
||||
co RCS/*.i* RCS/*.swg*
|
||||
|
||||
|
|
|
|||
|
|
@ -91,7 +91,6 @@ SWIG_is_unsigned_integer(Scheme_Object *o)
|
|||
|
||||
/* -----------------------------------------------------------------------
|
||||
* mzscheme 30X support code
|
||||
* Contributed by Hans Oesterholt
|
||||
* ----------------------------------------------------------------------- */
|
||||
|
||||
#ifndef SCHEME_STR_VAL
|
||||
|
|
@ -252,10 +251,6 @@ SWIG_MzScheme_new_scheme_struct (Scheme_Env* env, const char* basename,
|
|||
return new_type;
|
||||
}
|
||||
|
||||
/*** DLOPEN PATCH ******************************************************
|
||||
* Contributed by Hans Oesterholt-Dijkema (jan. 2006)
|
||||
***********************************************************************/
|
||||
|
||||
#if defined(_WIN32) || defined(__WIN32__)
|
||||
#define __OS_WIN32
|
||||
#endif
|
||||
|
|
@ -442,10 +437,6 @@ SWIG_MzScheme_new_scheme_struct (Scheme_Env* env, const char* basename,
|
|||
}
|
||||
}
|
||||
|
||||
/*** DLOPEN PATCH ******************************************************
|
||||
* Contributed by Hans Oesterholt-Dijkema (jan. 2006)
|
||||
***********************************************************************/
|
||||
|
||||
/* The interpreter will store a pointer to this structure in a global
|
||||
variable called swig-runtime-data-type-pointer. The instance of this
|
||||
struct is only used if no other module has yet been loaded */
|
||||
|
|
|
|||
|
|
@ -217,6 +217,10 @@ namespace std {
|
|||
%rename("delete!") __delitem__;
|
||||
%rename("has-key?") has_key;
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef K key_type;
|
||||
typedef T mapped_type;
|
||||
map();
|
||||
map(const map<K,T> &);
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ namespace std {
|
|||
SWIG_exception(SWIG_TypeError, "string expected");
|
||||
}
|
||||
|
||||
%typemap(in) const string & (std::string temp) {
|
||||
%typemap(in) const string & ($*1_ltype temp) {
|
||||
if (SCHEME_STRINGP($input)) {
|
||||
temp.assign(SCHEME_STR_VAL($input));
|
||||
$1 = &temp;
|
||||
|
|
|
|||
|
|
@ -279,7 +279,7 @@ REF_MAP(double, SCHEME_REALP, scheme_real_to_double,
|
|||
|
||||
//%typemap(in) (char *STRING, int LENGTH) {
|
||||
// int temp;
|
||||
// $1 = ($1_ltype) gh_scm2newstr($input, &temp);
|
||||
// $1 = ($1_ltype) SWIG_Guile_scm2newstr($input, &temp);
|
||||
// $2 = ($2_ltype) temp;
|
||||
//}
|
||||
|
||||
|
|
|
|||
|
|
@ -578,7 +578,7 @@ extern "C" {
|
|||
}
|
||||
}
|
||||
|
||||
static swig_module_info *SWIG_Ocaml_GetModule() {
|
||||
static swig_module_info *SWIG_Ocaml_GetModule(void *SWIGUNUSEDPARM(clientdata)) {
|
||||
CAML_VALUE pointer;
|
||||
|
||||
pointer = callback(*caml_named_value("swig_find_type_info"), caml_val_int(0));
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ CAMLextern int64 Int64_val(caml_value_t v);
|
|||
#endif
|
||||
|
||||
#define SWIG_NewPointerObj(p,type,flags) caml_val_ptr(p,type)
|
||||
#define SWIG_GetModule(clientdata) SWIG_Ocaml_GetModule()
|
||||
#define SWIG_GetModule(clientdata) SWIG_Ocaml_GetModule(clientdata)
|
||||
#define SWIG_SetModule(clientdata, pointer) SWIG_Ocaml_SetModule(pointer)
|
||||
|
||||
#define SWIG_contract_assert(expr, msg) if(!(expr)) {failwith(msg);} else
|
||||
|
|
|
|||
|
|
@ -22,6 +22,10 @@ namespace std {
|
|||
template<class K, class T> class map {
|
||||
// add typemaps here
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef K key_type;
|
||||
typedef T mapped_type;
|
||||
map();
|
||||
map(const map<K,T> &);
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class wstring;
|
|||
SWIG_exception(SWIG_TypeError, "string expected");
|
||||
}
|
||||
|
||||
%typemap(in) const string & (std::string temp) {
|
||||
%typemap(in) const string & ($*1_ltype temp) {
|
||||
/* %typemap(in) const string & */
|
||||
if (caml_ptr_check($input)) {
|
||||
temp.assign((char *)caml_ptr_val($input,0), caml_string_len($input));
|
||||
|
|
@ -46,7 +46,7 @@ class wstring;
|
|||
}
|
||||
}
|
||||
|
||||
%typemap(in) string & (std::string temp) {
|
||||
%typemap(in) string & ($*1_ltype temp) {
|
||||
/* %typemap(in) string & */
|
||||
if (caml_ptr_check($input)) {
|
||||
temp.assign((char *)caml_ptr_val($input,0), caml_string_len($input));
|
||||
|
|
@ -56,17 +56,17 @@ class wstring;
|
|||
}
|
||||
}
|
||||
|
||||
%typemap(in) string * (std::string *temp) {
|
||||
%typemap(in) string * ($*1_ltype *temp) {
|
||||
/* %typemap(in) string * */
|
||||
if (caml_ptr_check($input)) {
|
||||
temp = new std::string((char *)caml_ptr_val($input,0), caml_string_len($input));
|
||||
temp = new $*1_ltype((char *)caml_ptr_val($input,0), caml_string_len($input));
|
||||
$1 = temp;
|
||||
} else {
|
||||
SWIG_exception(SWIG_TypeError, "string expected");
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(free) string * (std::string *temp) {
|
||||
%typemap(free) string * ($*1_ltype *temp) {
|
||||
delete temp;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,124 @@
|
|||
|
||||
// ***** move the director stuff from octrun.swg here...
|
||||
# define SWIG_DIRECTOR_CAST(ARG) dynamic_cast<Swig::Director *>(ARG)
|
||||
|
||||
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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,12 @@
|
|||
|
||||
#endif
|
||||
|
||||
#if OCTAVE_API_VERSION_NUMBER < 37
|
||||
#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
|
||||
|
||||
SWIGRUNTIME bool SWIG_check_num_args(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);
|
||||
|
|
@ -106,54 +112,35 @@ SWIGRUNTIME void SWIG_Octave_SetModule(void *clientdata, swig_module_info *point
|
|||
typedef octave_value_list(*octave_func) (const octave_value_list &, int);
|
||||
class octave_swig_type;
|
||||
|
||||
# define SWIG_DIRECTOR_CAST(ARG) dynamic_cast<Swig::Director *>(ARG)
|
||||
|
||||
namespace Swig {
|
||||
|
||||
#ifdef SWIG_DIRECTORS
|
||||
|
||||
class Director;
|
||||
|
||||
//SWIGRUNTIME void swig_register_director(octave_swig_type *self, void *ptr, Director *d);
|
||||
typedef std::map < void *, Director * > rtdir_map;
|
||||
SWIGINTERN rtdir_map* get_rtdir_map();
|
||||
SWIGINTERNINLINE void set_rtdir(void *vptr, Director *d);
|
||||
SWIGINTERNINLINE void erase_rtdir(void *vptr);
|
||||
SWIGINTERNINLINE Director *get_rtdir(void *vptr);
|
||||
|
||||
SWIGRUNTIME void swig_director_destroyed(octave_swig_type *self, Director *d);
|
||||
SWIGRUNTIME octave_swig_type *swig_director_get_self(Director *d);
|
||||
SWIGRUNTIME void swig_director_set_self(Director *d, octave_swig_type *self);
|
||||
|
||||
#endif
|
||||
|
||||
SWIGRUNTIME octave_base_value *swig_value_ref(octave_swig_type *ost);
|
||||
SWIGRUNTIME octave_swig_type *swig_value_deref(octave_value ov);
|
||||
SWIGRUNTIME octave_swig_type *swig_value_deref(const octave_base_value &ov);
|
||||
|
||||
typedef std::map < void *, Director * > rtdir_map;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SWIG_DIRECTORS
|
||||
SWIGRUNTIME void swig_acquire_ownership(void *vptr);
|
||||
SWIGRUNTIME void swig_acquire_ownership_array(void *vptr);
|
||||
SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
|
||||
#endif
|
||||
|
||||
struct swig_octave_member {
|
||||
const char *name;
|
||||
octave_func method;
|
||||
|
|
@ -376,11 +363,13 @@ namespace Swig {
|
|||
always_static(_always_static) {
|
||||
if (_type || _ptr)
|
||||
types.push_back(std::make_pair(_type, _ptr));
|
||||
#ifdef SWIG_DIRECTORS
|
||||
if (_ptr) {
|
||||
Swig::Director *d = Swig::get_rtdir(_ptr);
|
||||
if (d)
|
||||
Swig::swig_director_set_self(d, this);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
~octave_swig_type() {
|
||||
|
|
@ -395,8 +384,10 @@ namespace Swig {
|
|||
}
|
||||
}
|
||||
}
|
||||
#ifdef SWIG_DIRECTORS
|
||||
for (unsigned int j = 0; j < types.size(); ++j)
|
||||
Swig::erase_rtdir(types[j].second.ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
dim_vector dims(void) const {
|
||||
|
|
@ -503,9 +494,11 @@ namespace Swig {
|
|||
rhs.own = 0;
|
||||
for (unsigned int j = 0; j < rhs.types.size(); ++j) {
|
||||
assert(!rhs.types[j].second.destroyed);
|
||||
#ifdef SWIG_DIRECTORS
|
||||
Swig::Director *d = Swig::get_rtdir(rhs.types[j].second.ptr);
|
||||
if (d)
|
||||
Swig::swig_director_set_self(d, this);
|
||||
#endif
|
||||
}
|
||||
types.insert(types.end(), rhs.types.begin(), rhs.types.end());
|
||||
members.insert(rhs.members.begin(), rhs.members.end());
|
||||
|
|
@ -513,37 +506,9 @@ namespace Swig {
|
|||
rhs.members.clear();
|
||||
}
|
||||
|
||||
void install_global(bool global_load) {
|
||||
for (member_map::const_iterator it = members.begin(); it != members.end(); ++it) {
|
||||
bool is_global_op = (it->first.substr(0, strlen(SWIG_op_prefix)) == SWIG_op_prefix);
|
||||
bool is_func_defined = (it->second.first && it->second.first->method);
|
||||
if (is_func_defined && (is_global_op || global_load)) {
|
||||
install_builtin_function(it->second.first->method, it->first,
|
||||
it->second.first->doc ? it->second.first->doc : std::string());
|
||||
}
|
||||
octave_value global_val = is_global_op ? make_fcn_handle(it->first) : it->second.second;
|
||||
if (global_val.is_defined() && (is_global_op || global_load)) {
|
||||
#if OCTAVE_API_VERSION_NUMBER<37
|
||||
link_to_global_variable(curr_sym_tab->lookup(it->first, true));
|
||||
#else
|
||||
symbol_table::varref(it->first);
|
||||
symbol_table::mark_global(it->first);
|
||||
#endif
|
||||
set_global_value(it->first, global_val);
|
||||
|
||||
#if OCTAVE_API_VERSION_NUMBER<37
|
||||
octave_swig_type *ost = Swig::swig_value_deref(global_val);
|
||||
if (ost) {
|
||||
const char* h = ost->help_text();
|
||||
if (h) {
|
||||
symbol_record *sr = global_sym_tab->lookup (it->first, true);
|
||||
sr->document(h);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
typedef member_map::const_iterator swig_member_const_iterator;
|
||||
swig_member_const_iterator swig_members_begin() { return members.begin(); }
|
||||
swig_member_const_iterator swig_members_end() { return members.end(); }
|
||||
|
||||
void *cast(swig_type_info *type, int *_own, int flags) {
|
||||
if (_own)
|
||||
|
|
@ -571,6 +536,7 @@ namespace Swig {
|
|||
return own;
|
||||
}
|
||||
|
||||
#ifdef SWIG_DIRECTORS
|
||||
void director_destroyed(Swig::Director *d) {
|
||||
bool found = false;
|
||||
for (unsigned int j = 0; j < types.size(); ++j) {
|
||||
|
|
@ -582,6 +548,7 @@ namespace Swig {
|
|||
}
|
||||
assert(found);
|
||||
}
|
||||
#endif
|
||||
|
||||
void assign(const std::string &name, const octave_value &ov) {
|
||||
members[name] = std::make_pair((const swig_octave_member *) 0, ov);
|
||||
|
|
@ -842,10 +809,10 @@ namespace Swig {
|
|||
// we assume that SWIG_op_prefix-prefixed functions are installed in global namespace
|
||||
// (rather than any module namespace).
|
||||
|
||||
octave_value fcn = get_global_value(symbol, true);
|
||||
if (!fcn.is_function() && !fcn.is_function_handle())
|
||||
octave_function *fcn = is_valid_function(symbol, std::string(), false);
|
||||
if (!fcn)
|
||||
return false;
|
||||
ret = fcn.subsref("(", std::list < octave_value_list > (1, args), 1);
|
||||
ret = fcn->do_multi_index_op(1, args)(0);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -1157,179 +1124,28 @@ namespace Swig {
|
|||
}
|
||||
};
|
||||
|
||||
octave_value_list swig_subclass(const octave_value_list &args, int nargout) {
|
||||
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("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("member assignments must be of string,value form");
|
||||
return octave_value_list();
|
||||
}
|
||||
top->assign(args(j).string_value(), args(j + 1));
|
||||
++j;
|
||||
} else {
|
||||
error("invalid arguments to subclass");
|
||||
return octave_value_list();
|
||||
}
|
||||
}
|
||||
return octave_value(Swig::swig_value_ref(top));
|
||||
}
|
||||
|
||||
octave_value_list swig_type(const octave_value_list &args, int nargout) {
|
||||
if (args.length() != 1) {
|
||||
error("swig_typeinfo 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("object is not a swig_ref");
|
||||
return octave_value_list();
|
||||
}
|
||||
return octave_value(ost->swig_type_name());
|
||||
}
|
||||
|
||||
octave_value_list swig_typequery(const octave_value_list &args, int nargout) {
|
||||
if (args.length() != 1 || !args(0).is_string()) {
|
||||
error("swig_typeinfo 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);
|
||||
}
|
||||
|
||||
octave_value_list swig_this(const octave_value_list &args, int nargout) {
|
||||
if (args.length() != 1) {
|
||||
error("swig_typeinfo 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("object is not a swig_ref");
|
||||
return octave_value_list();
|
||||
}
|
||||
return octave_value(octave_uint64((unsigned long long) ost->swig_this()));
|
||||
}
|
||||
|
||||
#define SWIG_DIRECTORS
|
||||
|
||||
namespace Swig {
|
||||
class Director {
|
||||
octave_swig_type *self;
|
||||
bool swig_disowned;
|
||||
|
||||
Director(const Director &x);
|
||||
Director &operator=(const Director &rhs);
|
||||
public:
|
||||
SWIGRUNTIME octave_base_value *swig_value_ref(octave_swig_type *ost) {
|
||||
return new octave_swig_ref(ost);
|
||||
}
|
||||
|
||||
Director(void *vptr):self(0), swig_disowned(false) {
|
||||
set_rtdir(vptr, this);
|
||||
}
|
||||
SWIGRUNTIME octave_swig_type *swig_value_deref(octave_value ov) {
|
||||
if (ov.is_cell() && ov.rows() == 1 && ov.columns() == 1)
|
||||
ov = ov.cell_value()(0);
|
||||
return swig_value_deref(*ov.internal_rep());
|
||||
}
|
||||
|
||||
~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);
|
||||
}
|
||||
};
|
||||
SWIGRUNTIME octave_swig_type *swig_value_deref(const octave_base_value &ov) {
|
||||
if (ov.type_id() != octave_swig_ref::static_type_id())
|
||||
return 0;
|
||||
const octave_swig_ref *osr = static_cast < const octave_swig_ref *>(&ov);
|
||||
return osr->get_ptr();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
namespace Swig {
|
||||
SWIGRUNTIME void swig_director_destroyed(octave_swig_type *self, Director *d) {
|
||||
self->director_destroyed(d);
|
||||
}
|
||||
|
||||
SWIGRUNTIME void swig_director_set_self(Director *d, octave_swig_type *self) {
|
||||
d->swig_set_self(self);
|
||||
}
|
||||
|
||||
SWIGRUNTIME octave_base_value *swig_value_ref(octave_swig_type *ost) {
|
||||
return new octave_swig_ref(ost);
|
||||
}
|
||||
|
||||
SWIGRUNTIME octave_swig_type *swig_value_deref(octave_value ov) {
|
||||
if (ov.is_cell() && ov.rows() == 1 && ov.columns() == 1)
|
||||
ov = ov.cell_value()(0);
|
||||
return swig_value_deref(*ov.internal_rep());
|
||||
}
|
||||
|
||||
SWIGRUNTIME octave_swig_type *swig_value_deref(const octave_base_value &ov) {
|
||||
if (ov.type_id() != octave_swig_ref::static_type_id())
|
||||
return 0;
|
||||
const octave_swig_ref *osr = static_cast < const octave_swig_ref *>(&ov);
|
||||
return osr->get_ptr();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#define swig_unary_op(name) \
|
||||
SWIGRUNTIME octave_value swig_unary_op_##name(const octave_base_value &x) { \
|
||||
|
|
@ -1422,9 +1238,11 @@ octave_value_typeinfo::register_binary_op(octave_value::op_##name,tid1,tid2,swig
|
|||
SWIGRUNTIME 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 && d->swig_get_self())
|
||||
return d->swig_get_self()->as_value();
|
||||
if (d && Swig::swig_director_get_self(d))
|
||||
return Swig::swig_director_get_self(d)->as_value();
|
||||
#endif
|
||||
return Swig::swig_value_ref(new octave_swig_type(ptr, type, own));
|
||||
}
|
||||
|
||||
|
|
@ -1466,8 +1284,25 @@ void SWIG_Octave_SetConstant(octave_swig_type *module_ns, const std::string &nam
|
|||
module_ns->assign(name, ov);
|
||||
}
|
||||
|
||||
SWIGRUNTIMEINLINE octave_value SWIG_Octave_GetGlobalValue(std::string name) {
|
||||
return get_global_value(name, true);
|
||||
}
|
||||
|
||||
SWIGRUNTIME void SWIG_Octave_SetGlobalValue(std::string name, const octave_value& value) {
|
||||
set_global_value(name, value);
|
||||
}
|
||||
|
||||
SWIGRUNTIME void SWIG_Octave_LinkGlobalValue(std::string name) {
|
||||
#if OCTAVE_API_VERSION_NUMBER < 37
|
||||
link_to_global_variable(curr_sym_tab->lookup(name, true));
|
||||
#else
|
||||
symbol_table::varref(name);
|
||||
symbol_table::mark_global(name);
|
||||
#endif
|
||||
}
|
||||
|
||||
SWIGRUNTIME swig_module_info *SWIG_Octave_GetModule(void *clientdata) {
|
||||
octave_value ov = get_global_value("__SWIG_MODULE__" SWIG_TYPE_TABLE_NAME SWIG_RUNTIME_VERSION, true);
|
||||
octave_value ov = SWIG_Octave_GetGlobalValue("__SWIG_MODULE__" SWIG_TYPE_TABLE_NAME SWIG_RUNTIME_VERSION);
|
||||
if (!ov.is_defined() ||
|
||||
ov.type_id() != octave_swig_packed::static_type_id())
|
||||
return 0;
|
||||
|
|
@ -1480,12 +1315,5 @@ SWIGRUNTIME swig_module_info *SWIG_Octave_GetModule(void *clientdata) {
|
|||
|
||||
SWIGRUNTIME void SWIG_Octave_SetModule(void *clientdata, swig_module_info *pointer) {
|
||||
octave_value ov = new octave_swig_packed(0, &pointer, sizeof(swig_module_info *));
|
||||
const char *module_var = "__SWIG_MODULE__" SWIG_TYPE_TABLE_NAME SWIG_RUNTIME_VERSION;
|
||||
#if OCTAVE_API_VERSION_NUMBER<37
|
||||
link_to_global_variable(curr_sym_tab->lookup(module_var, true));
|
||||
#else
|
||||
symbol_table::varref(module_var);
|
||||
symbol_table::mark_global(module_var);
|
||||
#endif
|
||||
set_global_value(module_var, ov);
|
||||
SWIG_Octave_SetGlobalValue("__SWIG_MODULE__" SWIG_TYPE_TABLE_NAME SWIG_RUNTIME_VERSION, ov);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,15 @@
|
|||
%insert(runtime) %{
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <octave/oct.h>
|
||||
#include <octave/parse.h>
|
||||
#include <octave/ov-fcn-handle.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>
|
||||
%}
|
||||
|
||||
%insert(runtime) "swigrun.swg";
|
||||
|
|
@ -16,93 +20,245 @@
|
|||
|
||||
%insert(initbeforefunc) %{
|
||||
|
||||
static void SWIG_init_user(octave_swig_type* module_ns);
|
||||
static bool SWIG_init_user(octave_swig_type* module_ns);
|
||||
|
||||
#if OCTAVE_API_VERSION_NUMBER>=37
|
||||
octave_value_list SWIG_atexit_func(const octave_value_list &args, int nargout);
|
||||
#endif
|
||||
|
||||
DEFUN_DLD (SWIG_name,args,nargout,SWIG_name_d) {
|
||||
|
||||
// determine if module is already loaded
|
||||
bool already_load;
|
||||
#if OCTAVE_API_VERSION_NUMBER<37
|
||||
SWIGINTERN bool SWIG_Octave_LoadModule(std::string name) {
|
||||
bool retn;
|
||||
{
|
||||
symbol_record *rec = curr_sym_tab->lookup(SWIG_name_d);
|
||||
already_load = (rec && rec->is_linked_to_global());
|
||||
}
|
||||
#if OCTAVE_API_VERSION_NUMBER < 38
|
||||
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
|
||||
already_load = symbol_table::is_global(SWIG_name_d);
|
||||
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
|
||||
if (!already_load) {
|
||||
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 OCTAVE_API_VERSION_NUMBER < 38
|
||||
unwind_protect::run_frame("SWIG_Octave_LoadModule");
|
||||
#endif
|
||||
}
|
||||
if (!retn) {
|
||||
error(SWIG_name_d ": could not load module `%s'", name.c_str());
|
||||
}
|
||||
return retn;
|
||||
}
|
||||
|
||||
// parse command line
|
||||
const char* usage="usage: " SWIG_name_d " [-global|-noglobal] [-globals {<name>|.}]";
|
||||
bool global_load=SWIG_global_load;
|
||||
std::string global_name=SWIG_global_name;
|
||||
for (int j=0;j<args.length();++j)
|
||||
if (args(j).is_string()) {
|
||||
if (args(j).string_value()=="-help") {
|
||||
std::cout << usage << std::endl;
|
||||
return octave_value_list();
|
||||
} else if (args(j).string_value()=="-global") {
|
||||
global_load = true;
|
||||
} else if (args(j).string_value()=="-noglobal") {
|
||||
global_load = false;
|
||||
} else if (args(j).string_value()=="-globals") {
|
||||
if (j+1<args.length()&&args(j+1).is_string()) {
|
||||
global_name = args(j+1).string_value();
|
||||
++j;
|
||||
} else {
|
||||
std::cerr << "error: " SWIG_name_d ": option '-globals' requires an argument." << std::endl;
|
||||
std::cerr << usage << std::endl;
|
||||
return octave_value_list();
|
||||
}
|
||||
} else {
|
||||
std::cerr << "error: " SWIG_name_d ": unrecognised argument '" << args(j).string_value() << "'." << std::endl;
|
||||
std::cerr << usage << std::endl;
|
||||
return octave_value_list();
|
||||
}
|
||||
} else {
|
||||
std::cerr << "error: " SWIG_name_d ": unrecognised non-string argument." << std::endl;
|
||||
std::cerr << usage << std::endl;
|
||||
SWIGINTERN bool SWIG_Octave_InstallFunction(octave_function *octloadfcn, std::string name) {
|
||||
bool retn;
|
||||
{
|
||||
#if OCTAVE_API_VERSION_NUMBER < 38
|
||||
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 OCTAVE_API_VERSION_NUMBER < 38
|
||||
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();
|
||||
}
|
||||
|
||||
if (global_name != "." && !valid_identifier(global_name)) {
|
||||
std::cerr << "error: " SWIG_name_d ": '" << global_name << "' is not a valid Octave identifier." << std::endl;
|
||||
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();
|
||||
}
|
||||
|
||||
// load module in base frame
|
||||
#if OCTAVE_API_VERSION_NUMBER<37
|
||||
symbol_table *prev_sym_tab = curr_sym_tab;
|
||||
curr_sym_tab = top_level_sym_tab;
|
||||
#else
|
||||
octave_call_stack::goto_base_frame();
|
||||
}
|
||||
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 36 < OCTAVE_API_VERSION_NUMBER && OCTAVE_API_VERSION_NUMBER < 45
|
||||
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 OCTAVE_API_VERSION_NUMBER > 36
|
||||
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();
|
||||
|
||||
install_builtin_function(swig_type,"swig_type",std::string());
|
||||
install_builtin_function(swig_typequery,"swig_typequery",std::string());
|
||||
install_builtin_function(swig_this,"swig_this",std::string());
|
||||
install_builtin_function(swig_subclass,"subclass",std::string());
|
||||
|
||||
|
||||
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 (global_name != ".") {
|
||||
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]);
|
||||
}
|
||||
|
||||
octave_swig_type* module_ns=new octave_swig_type(0, 0, 0, true);
|
||||
if (global_name != ".") {
|
||||
module_ns->assign(global_name,Swig::swig_value_ref(cvar_ns));
|
||||
|
||||
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)
|
||||
|
|
@ -112,72 +268,56 @@ DEFUN_DLD (SWIG_name,args,nargout,SWIG_name_d) {
|
|||
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.
|
||||
|
||||
// * 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])));
|
||||
Swig::swig_value_ref
|
||||
(new octave_swig_type(0,swig_types[j])));
|
||||
}
|
||||
|
||||
SWIG_init_user(module_ns);
|
||||
|
||||
SWIG_InstallOps(octave_swig_ref::static_type_id());
|
||||
|
||||
// the incref is necessary so install_global doesn't destroy module_ns,
|
||||
// as it would if it installed something with the same name as the module.
|
||||
module_ns->incref();
|
||||
module_ns->install_global(global_load);
|
||||
module_ns->decref();
|
||||
|
||||
// create global variable containing module
|
||||
set_global_value(SWIG_name_d,Swig::swig_value_ref(module_ns));
|
||||
|
||||
#if OCTAVE_API_VERSION_NUMBER>=37
|
||||
install_builtin_function(SWIG_atexit_func,"__swig_atexit_" SWIG_name_d "__",std::string());
|
||||
octave_add_atexit_function("__swig_atexit_" SWIG_name_d "__");
|
||||
octave_remove_atexit_function("__finish__");
|
||||
#endif
|
||||
|
||||
// return from base frame
|
||||
#if OCTAVE_API_VERSION_NUMBER<37
|
||||
curr_sym_tab = prev_sym_tab;
|
||||
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 OCTAVE_API_VERSION_NUMBER < 37
|
||||
mlock(me->name());
|
||||
#else
|
||||
octave_call_stack::pop();
|
||||
#endif
|
||||
|
||||
#if OCTAVE_API_VERSION_NUMBER>=37
|
||||
mlock();
|
||||
#endif
|
||||
|
||||
} // !already_load
|
||||
|
||||
// link variable to module in current context
|
||||
#if OCTAVE_API_VERSION_NUMBER<37
|
||||
link_to_global_variable(curr_sym_tab->lookup(SWIG_name_d,true));
|
||||
#else
|
||||
symbol_table::varref(SWIG_name_d);
|
||||
symbol_table::mark_global(SWIG_name_d);
|
||||
#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();
|
||||
}
|
||||
|
||||
// workaround bug in octave where installing global variable of custom type and then
|
||||
// exiting without explicitly clearing the variable causes octave to segfault.
|
||||
#if OCTAVE_API_VERSION_NUMBER>=37
|
||||
octave_value_list SWIG_atexit_func(const octave_value_list &args, int nargout) {
|
||||
string_vector vars = symbol_table::global_variable_names();
|
||||
for (int i = 0; i < vars.length(); i++)
|
||||
symbol_table::clear_global(vars[i]);
|
||||
symbol_table::clear_functions();
|
||||
return octave_value();
|
||||
}
|
||||
#endif
|
||||
|
||||
%}
|
||||
|
||||
|
|
|
|||
|
|
@ -64,9 +64,6 @@
|
|||
#ifdef eof
|
||||
#undef eof
|
||||
#endif
|
||||
#ifdef bool
|
||||
#undef bool
|
||||
#endif
|
||||
#ifdef close
|
||||
#undef close
|
||||
#endif
|
||||
|
|
@ -106,3 +103,11 @@
|
|||
#ifdef stat
|
||||
#undef stat
|
||||
#endif
|
||||
|
||||
#ifdef bool
|
||||
/* Leave if macro is from C99 stdbool.h */
|
||||
#ifndef __bool_true_false_are_defined
|
||||
#undef bool
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ XS(SWIG_init) {
|
|||
|
||||
/* Install commands */
|
||||
for (i = 0; swig_commands[i].name; i++) {
|
||||
// Casts only needed for Perl < 5.10.
|
||||
/* Casts only needed for Perl < 5.10. */
|
||||
#ifdef __cplusplus
|
||||
newXS(const_cast<char*>(swig_commands[i].name), swig_commands[i].wrapper, const_cast<char*>(__FILE__));
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
|
||||
/* Runtime API */
|
||||
|
||||
#define SWIG_GetModule(clientdata) SWIG_Perl_GetModule()
|
||||
#define SWIG_GetModule(clientdata) SWIG_Perl_GetModule(clientdata)
|
||||
#define SWIG_SetModule(clientdata, pointer) SWIG_Perl_SetModule(pointer)
|
||||
|
||||
|
||||
|
|
@ -477,7 +477,7 @@ SWIGRUNTIME void _swig_create_magic(CPerlObj *pPerl, SV *sv, const char *name, i
|
|||
|
||||
|
||||
SWIGRUNTIME swig_module_info *
|
||||
SWIG_Perl_GetModule(void) {
|
||||
SWIG_Perl_GetModule(void *SWIGUNUSEDPARM(clientdata)) {
|
||||
static void *type_pointer = (void *)0;
|
||||
SV *pointer;
|
||||
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ as follows :
|
|||
}
|
||||
tempsv = SvRV($input);
|
||||
if (!SvIOK(tempsv)) {
|
||||
SWIG_croak("expected a integer reference");
|
||||
SWIG_croak("expected an integer reference");
|
||||
}
|
||||
dvalue = SvIV(tempsv);
|
||||
$1 = &dvalue;
|
||||
|
|
@ -99,7 +99,7 @@ as follows :
|
|||
}
|
||||
tempsv = SvRV($input);
|
||||
if (!SvIOK(tempsv)) {
|
||||
SWIG_croak("expected a integer reference");
|
||||
SWIG_croak("expected an integer reference");
|
||||
}
|
||||
dvalue = (short) SvIV(tempsv);
|
||||
$1 = &dvalue;
|
||||
|
|
@ -112,7 +112,7 @@ as follows :
|
|||
}
|
||||
tempsv = SvRV($input);
|
||||
if (!SvIOK(tempsv)) {
|
||||
SWIG_croak("expected a integer reference");
|
||||
SWIG_croak("expected an integer reference");
|
||||
}
|
||||
dvalue = (long) SvIV(tempsv);
|
||||
$1 = &dvalue;
|
||||
|
|
@ -125,7 +125,7 @@ as follows :
|
|||
}
|
||||
tempsv = SvRV($input);
|
||||
if (!SvIOK(tempsv)) {
|
||||
SWIG_croak("expected a integer reference");
|
||||
SWIG_croak("expected an integer reference");
|
||||
}
|
||||
dvalue = (unsigned int) SvUV(tempsv);
|
||||
$1 = &dvalue;
|
||||
|
|
@ -138,7 +138,7 @@ as follows :
|
|||
}
|
||||
tempsv = SvRV($input);
|
||||
if (!SvIOK(tempsv)) {
|
||||
SWIG_croak("expected a integer reference");
|
||||
SWIG_croak("expected an integer reference");
|
||||
}
|
||||
dvalue = (unsigned short) SvUV(tempsv);
|
||||
$1 = &dvalue;
|
||||
|
|
@ -151,7 +151,7 @@ as follows :
|
|||
}
|
||||
tempsv = SvRV($input);
|
||||
if (!SvIOK(tempsv)) {
|
||||
SWIG_croak("expected a integer reference");
|
||||
SWIG_croak("expected an integer reference");
|
||||
}
|
||||
dvalue = (unsigned long) SvUV(tempsv);
|
||||
$1 = &dvalue;
|
||||
|
|
@ -165,7 +165,7 @@ as follows :
|
|||
}
|
||||
tempsv = SvRV($input);
|
||||
if (!SvIOK(tempsv)) {
|
||||
SWIG_croak("expected a integer reference");
|
||||
SWIG_croak("expected an integer reference");
|
||||
}
|
||||
dvalue = (unsigned char) SvUV(tempsv);
|
||||
$1 = &dvalue;
|
||||
|
|
@ -179,7 +179,7 @@ as follows :
|
|||
}
|
||||
tempsv = SvRV($input);
|
||||
if (!SvIOK(tempsv)) {
|
||||
SWIG_croak("expected a integer reference");
|
||||
SWIG_croak("expected an integer reference");
|
||||
}
|
||||
dvalue = (signed char) SvIV(tempsv);
|
||||
$1 = &dvalue;
|
||||
|
|
@ -193,7 +193,7 @@ as follows :
|
|||
}
|
||||
tempsv = SvRV($input);
|
||||
if (!SvIOK(tempsv)) {
|
||||
SWIG_croak("expected a integer reference");
|
||||
SWIG_croak("expected an integer reference");
|
||||
}
|
||||
dvalue = SvIV(tempsv) ? true : false;
|
||||
$1 = &dvalue;
|
||||
|
|
|
|||
|
|
@ -188,6 +188,10 @@ namespace std {
|
|||
}
|
||||
}
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef T value_type;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
list();
|
||||
list(const list<T> &);
|
||||
|
||||
|
|
@ -337,6 +341,10 @@ namespace std {
|
|||
}
|
||||
}
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef T value_type;
|
||||
typedef const value_type& const_reference;
|
||||
|
||||
list();
|
||||
list(const list<T> &);
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,10 @@ namespace std {
|
|||
template<class K, class T> class map {
|
||||
// add typemaps here
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef K key_type;
|
||||
typedef T mapped_type;
|
||||
map();
|
||||
map(const map<K,T> &);
|
||||
|
||||
|
|
|
|||
|
|
@ -180,6 +180,9 @@ namespace std {
|
|||
}
|
||||
}
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef T value_type;
|
||||
typedef const value_type& const_reference;
|
||||
vector(unsigned int size = 0);
|
||||
vector(unsigned int size, const T& value);
|
||||
vector(const vector<T> &);
|
||||
|
|
@ -349,6 +352,9 @@ namespace std {
|
|||
}
|
||||
}
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef T value_type;
|
||||
typedef const value_type& const_reference;
|
||||
vector(unsigned int size = 0);
|
||||
vector(unsigned int size, T *value);
|
||||
vector(const vector<T *> &);
|
||||
|
|
@ -517,6 +523,9 @@ namespace std {
|
|||
}
|
||||
}
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef T value_type;
|
||||
typedef const value_type& const_reference;
|
||||
vector(unsigned int size = 0);
|
||||
vector(unsigned int size, T value);
|
||||
vector(const vector<T> &);
|
||||
|
|
|
|||
|
|
@ -32,17 +32,14 @@
|
|||
%typemap(consttab) SWIGTYPE *,
|
||||
SWIGTYPE &,
|
||||
SWIGTYPE [] {
|
||||
/* This actually registers it as a global variable and constant. I don't
|
||||
* like it, but I can't figure out the zend_constant code... */
|
||||
zval *z_var;
|
||||
MAKE_STD_ZVAL(z_var);
|
||||
SWIG_SetPointerZval(z_var, (void*)$value, $1_descriptor, 0);
|
||||
/* zend_hash_add(&EG(symbol_table), "$1", sizeof("$1"), (void *)&z_var,sizeof(zval *), NULL); */
|
||||
zend_constant c;
|
||||
c.value = *z_var;
|
||||
zval_copy_ctor(&c.value);
|
||||
size_t len = sizeof("$1") - 1;
|
||||
c.name = zend_strndup("$1", len);
|
||||
size_t len = sizeof("$symname") - 1;
|
||||
c.name = zend_strndup("$symname", len);
|
||||
c.name_len = len+1;
|
||||
c.flags = CONST_CS | CONST_PERSISTENT;
|
||||
c.module_number = module_number;
|
||||
|
|
|
|||
|
|
@ -269,6 +269,15 @@
|
|||
ZVAL_LONG($input,$1);
|
||||
}
|
||||
|
||||
%typemap(directorin) char *, char []
|
||||
{
|
||||
if(!$1) {
|
||||
ZVAL_NULL($input);
|
||||
} else {
|
||||
ZVAL_STRING($input, (char *)$1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(out) bool
|
||||
{
|
||||
ZVAL_BOOL(return_value,($1)?1:0);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ extern "C" {
|
|||
#include "zend_exceptions.h"
|
||||
#include "php.h"
|
||||
#include "ext/standard/php_string.h"
|
||||
#include <stdlib.h> /* for abort(), used in generated code. */
|
||||
|
||||
#ifdef ZEND_RAW_FENTRY
|
||||
/* ZEND_RAW_FENTRY was added somewhere between 5.2.0 and 5.2.3 */
|
||||
|
|
@ -78,7 +79,7 @@ static int default_error_code = E_ERROR;
|
|||
if (!(expr) ) { zend_printf("Contract Assert Failed %s\n",msg ); } else
|
||||
|
||||
/* Standard SWIG API */
|
||||
#define SWIG_GetModule(clientdata) SWIG_Php_GetModule()
|
||||
#define SWIG_GetModule(clientdata) SWIG_Php_GetModule(clientdata)
|
||||
#define SWIG_SetModule(clientdata, pointer) SWIG_Php_SetModule(pointer)
|
||||
|
||||
/* used to wrap returned objects in so we know whether they are newobject
|
||||
|
|
@ -251,7 +252,7 @@ SWIG_ZTS_ConvertPtr(zval *z, void **ptr, swig_type_info *ty, int flags TSRMLS_DC
|
|||
}
|
||||
|
||||
static char const_name[] = "swig_runtime_data_type_pointer";
|
||||
static swig_module_info *SWIG_Php_GetModule() {
|
||||
static swig_module_info *SWIG_Php_GetModule(void *SWIGUNUSEDPARM(clientdata)) {
|
||||
zval *pointer;
|
||||
swig_module_info *ret = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,10 @@ namespace std {
|
|||
template<class K, class T> class map {
|
||||
// add typemaps here
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef K key_type;
|
||||
typedef T mapped_type;
|
||||
map();
|
||||
map(const map<K,T> &);
|
||||
|
||||
|
|
|
|||
|
|
@ -56,15 +56,15 @@ namespace std {
|
|||
|
||||
/* These next two handle a function which takes a non-const reference to
|
||||
* a std::string and modifies the string. */
|
||||
%typemap(in) string & (std::string temp) %{
|
||||
%typemap(in) string & ($*1_ltype temp) %{
|
||||
convert_to_string_ex($input);
|
||||
temp.assign(Z_STRVAL_PP($input), Z_STRLEN_PP($input));
|
||||
$1 = &temp;
|
||||
%}
|
||||
|
||||
%typemap(directorout) string & (std::string *temp) %{
|
||||
%typemap(directorout) string & ($*1_ltype *temp) %{
|
||||
convert_to_string_ex($input);
|
||||
temp = new std::string(Z_STRVAL_PP($input), Z_STRLEN_PP($input));
|
||||
temp = new $*1_ltype(Z_STRVAL_PP($input), Z_STRLEN_PP($input));
|
||||
swig_acquire_ownership(temp);
|
||||
$result = temp;
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@
|
|||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <global.h>
|
||||
#include <module.h>
|
||||
#include <interpret.h>
|
||||
#include <pike/global.h>
|
||||
#include <pike/module.h>
|
||||
#include <pike/interpret.h>
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -9,11 +9,12 @@
|
|||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include "object.h"
|
||||
#include "program.h"
|
||||
#include "pike/object.h"
|
||||
#include "pike/program.h"
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include <assert.h>
|
||||
|
||||
/* Stores information about a wrapped object */
|
||||
typedef struct swig_object_wrapper {
|
||||
|
|
@ -28,11 +29,11 @@ typedef struct swig_object_wrapper {
|
|||
|
||||
#define SWIG_ConvertPtr SWIG_Pike_ConvertPtr
|
||||
#define SWIG_NewPointerObj SWIG_Pike_NewPointerObj
|
||||
#define SWIG_GetModule(clientdata) SWIG_Pike_GetModule()
|
||||
#define SWIG_GetModule(clientdata) SWIG_Pike_GetModule(clientdata)
|
||||
#define SWIG_SetModule(clientdata, pointer) SWIG_Pike_SetModule(pointer)
|
||||
|
||||
/* These need to be filled in before type sharing between modules will work */
|
||||
static swig_module_info *SWIG_Pike_GetModule() {
|
||||
static swig_module_info *SWIG_Pike_GetModule(void *SWIGUNUSEDPARM(clientdata)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ namespace std {
|
|||
$1.assign(STR0($input.u.string));
|
||||
}
|
||||
|
||||
%typemap(in, pikedesc="tStr") const string & (std::string temp) {
|
||||
%typemap(in, pikedesc="tStr") const string & ($*1_ltype temp) {
|
||||
if ($input.type != T_STRING)
|
||||
Pike_error("Bad argument: Expected a string.\n");
|
||||
temp.assign(STR0($input.u.string));
|
||||
|
|
@ -47,7 +47,7 @@ namespace std {
|
|||
throw Swig::DirectorTypeMismatchException("string expected");
|
||||
}
|
||||
|
||||
%typemap(directorout) const string & (std::string temp) {
|
||||
%typemap(directorout) const string & ($*1_ltype temp) {
|
||||
if ($input.type == T_STRING) {
|
||||
temp.assign(STR0($input.u.string));
|
||||
$result = &temp;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
/*
|
||||
Use -DSWIG_DIRECTOR_NO_UEH if you prefer to avoid the use of the
|
||||
Undefined Exception Handler provided by swift
|
||||
Undefined Exception Handler provided by swig.
|
||||
*/
|
||||
#ifndef SWIG_DIRECTOR_NO_UEH
|
||||
#ifndef SWIG_DIRECTOR_UEH
|
||||
|
|
|
|||
|
|
@ -339,7 +339,7 @@ namespace swig {
|
|||
std::advance(it,ii);
|
||||
for (size_t rc=0; rc<replacecount; ++rc) {
|
||||
*it++ = *isit++;
|
||||
for (Py_ssize_t c=0; c<(step-1); ++c)
|
||||
for (Py_ssize_t c=0; c<(step-1) && it != self->end(); ++c)
|
||||
it++;
|
||||
}
|
||||
}
|
||||
|
|
@ -357,7 +357,7 @@ namespace swig {
|
|||
std::advance(it,size-ii-1);
|
||||
for (size_t rc=0; rc<replacecount; ++rc) {
|
||||
*it++ = *isit++;
|
||||
for (Py_ssize_t c=0; c<(-step-1); ++c)
|
||||
for (Py_ssize_t c=0; c<(-step-1) && it != self->rend(); ++c)
|
||||
it++;
|
||||
}
|
||||
}
|
||||
|
|
@ -383,9 +383,7 @@ namespace swig {
|
|||
size_t delcount = (jj - ii + step - 1) / step;
|
||||
while (delcount) {
|
||||
it = self->erase(it);
|
||||
if (it==self->end())
|
||||
break;
|
||||
for (Py_ssize_t c=0; c<(step-1); ++c)
|
||||
for (Py_ssize_t c=0; c<(step-1) && it != self->end(); ++c)
|
||||
it++;
|
||||
delcount--;
|
||||
}
|
||||
|
|
@ -398,10 +396,8 @@ namespace swig {
|
|||
typename Sequence::reverse_iterator it = sb;
|
||||
size_t delcount = (ii - jj - step - 1) / -step;
|
||||
while (delcount) {
|
||||
self->erase((++it).base());
|
||||
if (it==self->rend())
|
||||
break;
|
||||
for (Py_ssize_t c=0; c<(-step-1); ++c)
|
||||
it = typename Sequence::reverse_iterator(self->erase((++it).base()));
|
||||
for (Py_ssize_t c=0; c<(-step-1) && it != self->rend(); ++c)
|
||||
it++;
|
||||
delcount--;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#define PyInt_Check(x) PyLong_Check(x)
|
||||
#define PyInt_AsLong(x) PyLong_AsLong(x)
|
||||
#define PyInt_FromLong(x) PyLong_FromLong(x)
|
||||
#define PyInt_FromSize_t(x) PyLong_FromSize_t(x)
|
||||
#define PyString_Check(name) PyBytes_Check(name)
|
||||
#define PyString_FromString(x) PyUnicode_FromString(x)
|
||||
#define PyString_Format(fmt, args) PyUnicode_Format(fmt, args)
|
||||
|
|
@ -174,6 +175,10 @@ static long PyNumber_AsSsize_t (PyObject *x, void *SWIGUNUSEDPARM(exc))
|
|||
}
|
||||
#endif
|
||||
|
||||
#if PY_VERSION_HEX < 0x02050000
|
||||
#define PyInt_FromSize_t(x) PyInt_FromLong((long)x)
|
||||
#endif
|
||||
|
||||
#if PY_VERSION_HEX < 0x02040000
|
||||
#define Py_VISIT(op) \
|
||||
do { \
|
||||
|
|
|
|||
|
|
@ -398,6 +398,7 @@ SWIG_init(void) {
|
|||
m = Py_InitModule((char *) SWIG_name, SwigMethods);
|
||||
#endif
|
||||
md = d = PyModule_GetDict(m);
|
||||
(void)md;
|
||||
|
||||
SWIG_InitializeModule(0);
|
||||
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@
|
|||
* However, this file may be removed in future release of SWIG, so using this file to
|
||||
* keep these inappropriate names in your SWIG interface file is also not recommended.
|
||||
* Instead, we provide a simple tool for converting your interface files to
|
||||
* the new naming convention. You can download the tool here:
|
||||
* https://swig.svn.sourceforge.net/svnroot/swig/trunk/Tools/pyname_patch.py
|
||||
* the new naming convention. You can get the tool from the SWIG distribution:
|
||||
* Tools/pyname_patch.py
|
||||
*/
|
||||
|
||||
%fragment("PySequence_Base", "header", fragment="SwigPySequence_Base") {}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,16 @@ SWIGINTERNINLINE PyObject*
|
|||
}
|
||||
}
|
||||
|
||||
/* unsigned int */
|
||||
|
||||
%fragment(SWIG_From_frag(unsigned int),"header") {
|
||||
SWIGINTERNINLINE PyObject*
|
||||
SWIG_From_dec(unsigned int)(unsigned int value)
|
||||
{
|
||||
return PyInt_FromSize_t((size_t) value);
|
||||
}
|
||||
}
|
||||
|
||||
/* long */
|
||||
|
||||
%fragment(SWIG_From_frag(long),"header") {
|
||||
|
|
@ -99,6 +109,7 @@ SWIG_From_dec(unsigned long)(unsigned long value)
|
|||
SWIGINTERN int
|
||||
SWIG_AsVal_dec(unsigned long)(PyObject *obj, unsigned long *val)
|
||||
{
|
||||
%#if PY_VERSION_HEX < 0x03000000
|
||||
if (PyInt_Check(obj)) {
|
||||
long v = PyInt_AsLong(obj);
|
||||
if (v >= 0) {
|
||||
|
|
@ -107,13 +118,27 @@ SWIG_AsVal_dec(unsigned long)(PyObject *obj, unsigned long *val)
|
|||
} else {
|
||||
return SWIG_OverflowError;
|
||||
}
|
||||
} else if (PyLong_Check(obj)) {
|
||||
} else
|
||||
%#endif
|
||||
if (PyLong_Check(obj)) {
|
||||
unsigned long v = PyLong_AsUnsignedLong(obj);
|
||||
if (!PyErr_Occurred()) {
|
||||
if (val) *val = v;
|
||||
return SWIG_OK;
|
||||
} else {
|
||||
PyErr_Clear();
|
||||
%#if PY_VERSION_HEX >= 0x03000000
|
||||
{
|
||||
long v = PyLong_AsLong(obj);
|
||||
if (!PyErr_Occurred()) {
|
||||
if (v < 0) {
|
||||
return SWIG_OverflowError;
|
||||
}
|
||||
} else {
|
||||
PyErr_Clear();
|
||||
}
|
||||
}
|
||||
%#endif
|
||||
}
|
||||
}
|
||||
%#ifdef SWIG_PYTHON_CAST_MODE
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@
|
|||
|
||||
/* Runtime API */
|
||||
|
||||
#define SWIG_GetModule(clientdata) SWIG_Python_GetModule()
|
||||
#define SWIG_GetModule(clientdata) SWIG_Python_GetModule(clientdata)
|
||||
#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer)
|
||||
#define SWIG_NewClientData(obj) SwigPyClientData_New(obj)
|
||||
|
||||
|
|
@ -668,7 +668,7 @@ SwigPyObject_own(PyObject *v, PyObject *args)
|
|||
static PyMethodDef
|
||||
swigobject_methods[] = {
|
||||
{(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"},
|
||||
{(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, (char *)"aquires ownership of the pointer"},
|
||||
{(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, (char *)"acquires ownership of the pointer"},
|
||||
{(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"},
|
||||
{(char *)"append", (PyCFunction)SwigPyObject_append, METH_O, (char *)"appends another 'this' object"},
|
||||
{(char *)"next", (PyCFunction)SwigPyObject_next, METH_NOARGS, (char *)"returns the next 'this' object"},
|
||||
|
|
@ -1331,23 +1331,29 @@ SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this)
|
|||
} else {
|
||||
#if PY_VERSION_HEX >= 0x03000000
|
||||
inst = PyBaseObject_Type.tp_new((PyTypeObject*) data->newargs, Py_None, Py_None);
|
||||
PyObject_SetAttr(inst, SWIG_This(), swig_this);
|
||||
Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG;
|
||||
if (inst) {
|
||||
PyObject_SetAttr(inst, SWIG_This(), swig_this);
|
||||
Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG;
|
||||
}
|
||||
#else
|
||||
PyObject *dict = PyDict_New();
|
||||
PyDict_SetItem(dict, SWIG_This(), swig_this);
|
||||
inst = PyInstance_NewRaw(data->newargs, dict);
|
||||
Py_DECREF(dict);
|
||||
if (dict) {
|
||||
PyDict_SetItem(dict, SWIG_This(), swig_this);
|
||||
inst = PyInstance_NewRaw(data->newargs, dict);
|
||||
Py_DECREF(dict);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return inst;
|
||||
#else
|
||||
#if (PY_VERSION_HEX >= 0x02010000)
|
||||
PyObject *inst;
|
||||
PyObject *inst = 0;
|
||||
PyObject *dict = PyDict_New();
|
||||
PyDict_SetItem(dict, SWIG_This(), swig_this);
|
||||
inst = PyInstance_NewRaw(data->newargs, dict);
|
||||
Py_DECREF(dict);
|
||||
if (dict) {
|
||||
PyDict_SetItem(dict, SWIG_This(), swig_this);
|
||||
inst = PyInstance_NewRaw(data->newargs, dict);
|
||||
Py_DECREF(dict);
|
||||
}
|
||||
return (PyObject *) inst;
|
||||
#else
|
||||
PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type);
|
||||
|
|
@ -1454,12 +1460,10 @@ SWIG_Python_NewPointerObj(PyObject *self, void *ptr, swig_type_info *type, int f
|
|||
assert(!(flags & SWIG_BUILTIN_TP_INIT));
|
||||
|
||||
robj = SwigPyObject_New(ptr, type, own);
|
||||
if (clientdata && !(flags & SWIG_POINTER_NOSHADOW)) {
|
||||
if (robj && clientdata && !(flags & SWIG_POINTER_NOSHADOW)) {
|
||||
PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj);
|
||||
if (inst) {
|
||||
Py_DECREF(robj);
|
||||
robj = inst;
|
||||
}
|
||||
Py_DECREF(robj);
|
||||
robj = inst;
|
||||
}
|
||||
return robj;
|
||||
}
|
||||
|
|
@ -1480,7 +1484,7 @@ void *SWIG_ReturnGlobalTypeList(void *);
|
|||
#endif
|
||||
|
||||
SWIGRUNTIME swig_module_info *
|
||||
SWIG_Python_GetModule(void) {
|
||||
SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) {
|
||||
static void *type_pointer = (void *)0;
|
||||
/* first check if module already created */
|
||||
if (!type_pointer) {
|
||||
|
|
@ -1606,7 +1610,7 @@ SWIG_Python_TypeQuery(const char *type)
|
|||
descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj);
|
||||
#endif
|
||||
} else {
|
||||
swig_module_info *swig_module = SWIG_Python_GetModule();
|
||||
swig_module_info *swig_module = SWIG_GetModule(0);
|
||||
descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type);
|
||||
if (descriptor) {
|
||||
#ifdef SWIGPY_USE_CAPSULE
|
||||
|
|
|
|||
|
|
@ -49,6 +49,14 @@
|
|||
return *(swig::cgetpos(self, i));
|
||||
}
|
||||
|
||||
void add(value_type x) {
|
||||
self->insert(x);
|
||||
}
|
||||
|
||||
void discard(value_type x) {
|
||||
self->erase(x);
|
||||
}
|
||||
|
||||
};
|
||||
%enddef
|
||||
|
||||
|
|
|
|||
307
Lib/r/boost_shared_ptr.i
Normal file
307
Lib/r/boost_shared_ptr.i
Normal file
|
|
@ -0,0 +1,307 @@
|
|||
%include <shared_ptr.i>
|
||||
|
||||
// Language specific macro implementing all the customisations for handling the smart pointer
|
||||
%define SWIG_SHARED_PTR_TYPEMAPS(CONST, TYPE...)
|
||||
|
||||
// %naturalvar is as documented for member variables
|
||||
%naturalvar TYPE;
|
||||
%naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
|
||||
|
||||
// destructor wrapper customisation
|
||||
%feature("unref") TYPE
|
||||
//"if (debug_shared) { cout << \"deleting use_count: \" << (*smartarg1).use_count() << \" [\" << (boost::get_deleter<SWIG_null_deleter>(*smartarg1) ? std::string(\"CANNOT BE DETERMINED SAFELY\") : ( (*smartarg1).get() ? (*smartarg1)->getValue() : std::string(\"NULL PTR\") )) << \"]\" << endl << flush; }\n"
|
||||
"(void)arg1; delete smartarg1;"
|
||||
|
||||
// Typemap customisations...
|
||||
|
||||
// plain value
|
||||
%typemap(in) CONST TYPE (void *argp, int res = 0) {
|
||||
int newmem = 0;
|
||||
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
%argument_fail(res, "$type", $symname, $argnum);
|
||||
}
|
||||
if (!argp) {
|
||||
%argument_nullref("$type", $symname, $argnum);
|
||||
} else {
|
||||
$1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get());
|
||||
if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
}
|
||||
}
|
||||
%typemap(out) CONST TYPE {
|
||||
%set_output(SWIG_NewPointerObj(new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
%typemap(varin) CONST TYPE {
|
||||
void *argp = 0;
|
||||
int newmem = 0;
|
||||
int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
%variable_fail(res, "$type", "$name");
|
||||
}
|
||||
if (!argp) {
|
||||
%argument_nullref("$type", $symname, $argnum);
|
||||
} else {
|
||||
$1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get());
|
||||
if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
}
|
||||
}
|
||||
%typemap(varout) CONST TYPE {
|
||||
%set_varoutput(SWIG_NewPointerObj(new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
// plain pointer
|
||||
// Note: $disown not implemented as it will lead to a memory leak of the shared_ptr instance
|
||||
%typemap(in) CONST TYPE * (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) {
|
||||
int newmem = 0;
|
||||
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
%argument_fail(res, "$type", $symname, $argnum);
|
||||
}
|
||||
if (newmem & SWIG_CAST_NEW_MEMORY) {
|
||||
tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
$1 = %const_cast(tempshared.get(), $1_ltype);
|
||||
} else {
|
||||
smartarg = %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
$1 = %const_cast((smartarg ? smartarg->get() : 0), $1_ltype);
|
||||
}
|
||||
}
|
||||
%typemap(out, fragment="SWIG_null_deleter") CONST TYPE * {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0;
|
||||
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), $owner | SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
%typemap(varin) CONST TYPE * {
|
||||
void *argp = 0;
|
||||
int newmem = 0;
|
||||
int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
%variable_fail(res, "$type", "$name");
|
||||
}
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared;
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0;
|
||||
if (newmem & SWIG_CAST_NEW_MEMORY) {
|
||||
tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
$1 = %const_cast(tempshared.get(), $1_ltype);
|
||||
} else {
|
||||
smartarg = %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
$1 = %const_cast((smartarg ? smartarg->get() : 0), $1_ltype);
|
||||
}
|
||||
}
|
||||
%typemap(varout, fragment="SWIG_null_deleter") CONST TYPE * {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0;
|
||||
%set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
// plain reference
|
||||
%typemap(in) CONST TYPE & (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) {
|
||||
int newmem = 0;
|
||||
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
%argument_fail(res, "$type", $symname, $argnum);
|
||||
}
|
||||
if (!argp) { %argument_nullref("$type", $symname, $argnum); }
|
||||
if (newmem & SWIG_CAST_NEW_MEMORY) {
|
||||
tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
$1 = %const_cast(tempshared.get(), $1_ltype);
|
||||
} else {
|
||||
$1 = %const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $1_ltype);
|
||||
}
|
||||
}
|
||||
%typemap(out, fragment="SWIG_null_deleter") CONST TYPE & {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner);
|
||||
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
%typemap(varin) CONST TYPE & {
|
||||
void *argp = 0;
|
||||
int newmem = 0;
|
||||
int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
%variable_fail(res, "$type", "$name");
|
||||
}
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared;
|
||||
if (!argp) { %argument_nullref("$type", $symname, $argnum); }
|
||||
if (newmem & SWIG_CAST_NEW_MEMORY) {
|
||||
tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
$1 = *%const_cast(tempshared.get(), $1_ltype);
|
||||
} else {
|
||||
$1 = *%const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $1_ltype);
|
||||
}
|
||||
}
|
||||
%typemap(varout, fragment="SWIG_null_deleter") CONST TYPE & {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(&$1 SWIG_NO_NULL_DELETER_0);
|
||||
%set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
// plain pointer by reference
|
||||
// Note: $disown not implemented as it will lead to a memory leak of the shared_ptr instance
|
||||
%typemap(in) TYPE *CONST& (void *argp = 0, int res = 0, $*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) {
|
||||
int newmem = 0;
|
||||
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
%argument_fail(res, "$type", $symname, $argnum);
|
||||
}
|
||||
if (newmem & SWIG_CAST_NEW_MEMORY) {
|
||||
tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
|
||||
temp = %const_cast(tempshared.get(), $*1_ltype);
|
||||
} else {
|
||||
temp = %const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $*1_ltype);
|
||||
}
|
||||
$1 = &temp;
|
||||
}
|
||||
%typemap(out, fragment="SWIG_null_deleter") TYPE *CONST& {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner);
|
||||
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
%typemap(varin) TYPE *CONST& %{
|
||||
#error "varin typemap not implemented"
|
||||
%}
|
||||
%typemap(varout) TYPE *CONST& %{
|
||||
#error "varout typemap not implemented"
|
||||
%}
|
||||
|
||||
// shared_ptr by value
|
||||
%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > (void *argp, int res = 0) {
|
||||
int newmem = 0;
|
||||
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
%argument_fail(res, "$type", $symname, $argnum);
|
||||
}
|
||||
if (argp) $1 = *(%reinterpret_cast(argp, $<ype));
|
||||
if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $<ype);
|
||||
}
|
||||
%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0;
|
||||
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
|
||||
int newmem = 0;
|
||||
void *argp = 0;
|
||||
int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
%variable_fail(res, "$type", "$name");
|
||||
}
|
||||
$1 = argp ? *(%reinterpret_cast(argp, $<ype)) : SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE >();
|
||||
if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $<ype);
|
||||
}
|
||||
%typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0;
|
||||
%set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
// shared_ptr by reference
|
||||
%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & (void *argp, int res = 0, $*1_ltype tempshared) {
|
||||
int newmem = 0;
|
||||
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
%argument_fail(res, "$type", $symname, $argnum);
|
||||
}
|
||||
if (newmem & SWIG_CAST_NEW_MEMORY) {
|
||||
if (argp) tempshared = *%reinterpret_cast(argp, $ltype);
|
||||
delete %reinterpret_cast(argp, $ltype);
|
||||
$1 = &tempshared;
|
||||
} else {
|
||||
$1 = (argp) ? %reinterpret_cast(argp, $ltype) : &tempshared;
|
||||
}
|
||||
}
|
||||
%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = *$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0;
|
||||
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{
|
||||
#error "varin typemap not implemented"
|
||||
%}
|
||||
%typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{
|
||||
#error "varout typemap not implemented"
|
||||
%}
|
||||
|
||||
// shared_ptr by pointer
|
||||
%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * (void *argp, int res = 0, $*1_ltype tempshared) {
|
||||
int newmem = 0;
|
||||
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
%argument_fail(res, "$type", $symname, $argnum);
|
||||
}
|
||||
if (newmem & SWIG_CAST_NEW_MEMORY) {
|
||||
if (argp) tempshared = *%reinterpret_cast(argp, $ltype);
|
||||
delete %reinterpret_cast(argp, $ltype);
|
||||
$1 = &tempshared;
|
||||
} else {
|
||||
$1 = (argp) ? %reinterpret_cast(argp, $ltype) : &tempshared;
|
||||
}
|
||||
}
|
||||
%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 && *$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0;
|
||||
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
if ($owner) delete $1;
|
||||
}
|
||||
|
||||
%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{
|
||||
#error "varin typemap not implemented"
|
||||
%}
|
||||
%typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{
|
||||
#error "varout typemap not implemented"
|
||||
%}
|
||||
|
||||
// shared_ptr by pointer reference
|
||||
%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& (void *argp, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, $*1_ltype temp = 0) {
|
||||
int newmem = 0;
|
||||
res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
%argument_fail(res, "$type", $symname, $argnum);
|
||||
}
|
||||
if (argp) tempshared = *%reinterpret_cast(argp, $*ltype);
|
||||
if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $*ltype);
|
||||
temp = &tempshared;
|
||||
$1 = &temp;
|
||||
}
|
||||
%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& {
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = *$1 && **$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(**$1) : 0;
|
||||
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
|
||||
}
|
||||
|
||||
%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{
|
||||
#error "varin typemap not implemented"
|
||||
%}
|
||||
%typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{
|
||||
#error "varout typemap not implemented"
|
||||
%}
|
||||
|
||||
// Typecheck typemaps
|
||||
// Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting
|
||||
// function is not called thereby avoiding a possible smart pointer copy constructor call when casting up the inheritance chain.
|
||||
%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1)
|
||||
TYPE CONST,
|
||||
TYPE CONST &,
|
||||
TYPE CONST *,
|
||||
TYPE *CONST&,
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &,
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *,
|
||||
SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& {
|
||||
int res = SWIG_ConvertPtr($input, 0, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), 0);
|
||||
$1 = SWIG_CheckState(res);
|
||||
}
|
||||
|
||||
|
||||
// various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug
|
||||
%typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
|
||||
#error "typemaps for $1_type not available"
|
||||
%}
|
||||
%typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
|
||||
#error "typemaps for $1_type not available"
|
||||
%}
|
||||
|
||||
|
||||
%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
|
||||
%enddef
|
||||
|
||||
|
|
@ -3,6 +3,12 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* for raw pointer */
|
||||
#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_R_ConvertPtr(obj, pptr, type, flags)
|
||||
#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_R_ConvertPtr(obj, pptr, type, flags)
|
||||
#define SWIG_NewPointerObj(ptr, type, flags) SWIG_R_NewPointerObj(ptr, type, flags)
|
||||
|
||||
|
||||
/* Remove global namespace pollution */
|
||||
#if !defined(SWIG_NO_R_NO_REMAP)
|
||||
# define R_NO_REMAP
|
||||
|
|
@ -264,6 +270,7 @@ SWIG_R_NewPointerObj(void *ptr, swig_type_info *type, int flags) {
|
|||
return rptr;
|
||||
}
|
||||
|
||||
|
||||
/* Convert a pointer value */
|
||||
SWIGRUNTIMEINLINE int
|
||||
SWIG_R_ConvertPtr(SEXP obj, void **ptr, swig_type_info *ty, int flags) {
|
||||
|
|
@ -293,7 +300,7 @@ SWIG_R_ConvertPtr(SEXP obj, void **ptr, swig_type_info *ty, int flags) {
|
|||
}
|
||||
|
||||
SWIGRUNTIME swig_module_info *
|
||||
SWIG_GetModule(void *v) {
|
||||
SWIG_GetModule(void *SWIGUNUSEDPARM(clientdata)) {
|
||||
static void *type_pointer = (void *)0;
|
||||
return (swig_module_info *) type_pointer;
|
||||
}
|
||||
|
|
|
|||
162
Lib/r/rtype.swg
162
Lib/r/rtype.swg
|
|
@ -4,24 +4,9 @@
|
|||
*/
|
||||
|
||||
%typemap("rtype") int, int *, int & "integer";
|
||||
%apply int {size_t}
|
||||
%apply int {std::size_t}
|
||||
%apply int {ptrdiff_t}
|
||||
%apply int {std::ptrdiff_t}
|
||||
%apply int {signed int}
|
||||
%apply int {unsigned int}
|
||||
%apply int {short}
|
||||
%apply int {unsigned short}
|
||||
|
||||
%typemap("rtype") long, long *, long & "integer";
|
||||
%apply long {long long}
|
||||
%apply long {signed long long}
|
||||
%apply long {unsigned long long}
|
||||
%apply long {signed long}
|
||||
%apply long {unsigned long}
|
||||
|
||||
%typemap("rtype") float, float*, float & "numeric";
|
||||
%typemap("rtype") double, double*, double & "numeric";
|
||||
%typemap("rtype") float, float *, float & "numeric";
|
||||
%typemap("rtype") char *, char ** "character";
|
||||
%typemap("rtype") char "character";
|
||||
%typemap("rtype") string, string *, string & "character";
|
||||
|
|
@ -36,16 +21,15 @@
|
|||
%typemap("rtype") SWIGTYPE & "$R_class";
|
||||
%typemap("rtype") SWIGTYPE "$&R_class";
|
||||
|
||||
%typemap("rtypecheck") int, int &, long, long &,
|
||||
unsigned char, unsigned char &
|
||||
%typemap("rtypecheck") int, int &, long, long &
|
||||
%{ (is.integer($arg) || is.numeric($arg)) && length($arg) == 1 %}
|
||||
%typemap("rtypecheck") int *, long *, unsigned char *
|
||||
%typemap("rtypecheck") int *, long *
|
||||
%{ is.integer($arg) || is.numeric($arg) %}
|
||||
|
||||
|
||||
%typemap("rtypecheck") double, double &, float, float &
|
||||
%typemap("rtypecheck") float, double
|
||||
%{ is.numeric($arg) && length($arg) == 1 %}
|
||||
%typemap("rtypecheck") double*, float *
|
||||
%typemap("rtypecheck") float *, double *
|
||||
%{ is.numeric($arg) %}
|
||||
|
||||
%typemap("rtypecheck") bool, bool &
|
||||
|
|
@ -88,9 +72,8 @@
|
|||
%{ $input = as.integer($input); %}
|
||||
%typemap(scoercein) long, long *, long &
|
||||
%{ $input = as.integer($input); %}
|
||||
%typemap(scoercein) double, double *, double &
|
||||
%{ %}
|
||||
%typemap(scoercein) float, float *, float &
|
||||
%typemap(scoercein) float, float*, float &,
|
||||
double, double *, double &
|
||||
%{ %}
|
||||
%typemap(scoercein) char, char *, char &
|
||||
%{ $input = as($input, "character"); %}
|
||||
|
|
@ -107,9 +90,8 @@
|
|||
%typemap(scoercein) enum SWIGTYPE *const
|
||||
%{ $input = enumToInteger($input, "$R_class"); %}
|
||||
|
||||
|
||||
%typemap(scoercein) SWIGTYPE, SWIGTYPE *, SWIGTYPE *const, SWIGTYPE &
|
||||
%{ %}
|
||||
%{ if (inherits($input, "ExternalReference")) $input = slot($input,"ref") %}
|
||||
|
||||
/*
|
||||
%typemap(scoercein) SWIGTYPE *, SWIGTYPE *const
|
||||
|
|
@ -136,12 +118,10 @@
|
|||
%typemap(scoercein) int,
|
||||
int *,
|
||||
int &,
|
||||
int[ANY],
|
||||
long,
|
||||
long *,
|
||||
long &,
|
||||
long[ANY]
|
||||
"$input = as.integer($input); ";
|
||||
long &
|
||||
"$input = as.integer($input);";
|
||||
|
||||
%typemap(scoercein) char *, string, std::string,
|
||||
string &, std::string &
|
||||
|
|
@ -159,27 +139,41 @@ string &, std::string &
|
|||
%typemap(scoerceout) enum SWIGTYPE *const
|
||||
%{ $result = enumToInteger($result, "$R_class"); %}
|
||||
|
||||
#%typemap(scoerceout) SWIGTYPE
|
||||
# %{ class($result) <- "$&R_class"; %}
|
||||
|
||||
%typemap(scoerceout) SWIGTYPE
|
||||
%{ class($result) <- "$&R_class"; %}
|
||||
#%typemap(scoerceout) SWIGTYPE &
|
||||
# %{ class($result) <- "$R_class"; %}
|
||||
|
||||
%typemap(scoerceout) SWIGTYPE &
|
||||
%{ class($result) <- "$R_class"; %}
|
||||
#%typemap(scoerceout) SWIGTYPE *
|
||||
# %{ class($result) <- "$R_class"; %}
|
||||
|
||||
%typemap(scoerceout) SWIGTYPE *
|
||||
%{ class($result) <- "$R_class"; %}
|
||||
#%typemap(scoerceout) SWIGTYPE *const
|
||||
# %{ class($result) <- "$R_class"; %}
|
||||
|
||||
%typemap(scoerceout) SWIGTYPE
|
||||
%{ $result <- new("$&R_class", ref=$result); %}
|
||||
|
||||
%typemap(scoerceout) SWIGTYPE &
|
||||
%{ $result <- new("$R_class", ref=$result) ; %}
|
||||
|
||||
%typemap(scoerceout) SWIGTYPE *
|
||||
%{ $result <- new("$R_class", ref=$result) ; %}
|
||||
|
||||
%typemap(scoerceout) SWIGTYPE *const
|
||||
%{ $result <- new("$R_class", ref=$result) ; %}
|
||||
|
||||
%typemap(scoerceout) SWIGTYPE *const
|
||||
%{ class($result) <- "$R_class"; %}
|
||||
|
||||
/* Override the SWIGTYPE * above. */
|
||||
%typemap(scoerceout) char,
|
||||
char *,
|
||||
char &,
|
||||
double,
|
||||
double &,
|
||||
float,
|
||||
double,
|
||||
float*,
|
||||
double*,
|
||||
float &,
|
||||
double &,
|
||||
int,
|
||||
int &,
|
||||
long,
|
||||
|
|
@ -208,10 +202,94 @@ string &, std::string &
|
|||
signed long &,
|
||||
unsigned long,
|
||||
unsigned long &,
|
||||
unsigned char *,
|
||||
unsigned char &
|
||||
signed char,
|
||||
signed char &,
|
||||
unsigned char,
|
||||
unsigned char &
|
||||
%{ %}
|
||||
|
||||
%apply int {size_t,
|
||||
std::size_t,
|
||||
ptrdiff_t,
|
||||
std::ptrdiff_t,
|
||||
signed int,
|
||||
unsigned int,
|
||||
short,
|
||||
unsigned short,
|
||||
signed char,
|
||||
unsigned char}
|
||||
|
||||
%apply int* {size_t[],
|
||||
std::size_t[],
|
||||
ptrdiff_t[],
|
||||
std::ptrdiff_t[],
|
||||
signed int[],
|
||||
unsigned int[],
|
||||
short[],
|
||||
unsigned short[],
|
||||
signed char[],
|
||||
unsigned char[]}
|
||||
|
||||
%apply int* {size_t[ANY],
|
||||
std::size_t[ANY],
|
||||
ptrdiff_t[ANY],
|
||||
std::ptrdiff_t[ANY],
|
||||
signed int[ANY],
|
||||
unsigned int[ANY],
|
||||
short[ANY],
|
||||
unsigned short[ANY],
|
||||
signed char[ANY],
|
||||
unsigned char[ANY]}
|
||||
|
||||
%apply int* {size_t*,
|
||||
std::size_t*,
|
||||
ptrdiff_t*,
|
||||
std::ptrdiff_t*,
|
||||
signed int*,
|
||||
unsigned int*,
|
||||
short*,
|
||||
unsigned short*,
|
||||
signed char*,
|
||||
unsigned char*}
|
||||
|
||||
%apply long {
|
||||
long long,
|
||||
signed long long,
|
||||
unsigned long long,
|
||||
signed long,
|
||||
unsigned long}
|
||||
|
||||
%apply long* {
|
||||
long long*,
|
||||
signed long long*,
|
||||
unsigned long long*,
|
||||
signed long*,
|
||||
unsigned long*,
|
||||
long long[],
|
||||
signed long long[],
|
||||
unsigned long long[],
|
||||
signed long[],
|
||||
unsigned long[],
|
||||
long long[ANY],
|
||||
signed long long[ANY],
|
||||
unsigned long long[ANY],
|
||||
signed long[ANY],
|
||||
unsigned long[ANY]}
|
||||
|
||||
%apply float* {
|
||||
float[],
|
||||
float[ANY]
|
||||
}
|
||||
%apply double * {
|
||||
double[],
|
||||
double[ANY]
|
||||
}
|
||||
|
||||
%apply bool* {
|
||||
bool[],
|
||||
bool[ANY]
|
||||
}
|
||||
|
||||
#if 0
|
||||
Just examining the values for a SWIGTYPE.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
// R specific swig components
|
||||
/*
|
||||
Vectors
|
||||
Thanks to Richard Beare - richard.beare@ieee.org for StdVectorTraits
|
||||
*/
|
||||
*/
|
||||
|
||||
%fragment("StdVectorTraits","header",fragment="StdSequenceTraits")
|
||||
%{
|
||||
|
|
@ -11,86 +10,87 @@
|
|||
template <>
|
||||
struct traits_from_ptr<std::vector<double> > {
|
||||
static SEXP from (std::vector<double > *val, int owner = 0) {
|
||||
SEXP result;
|
||||
PROTECT(result = Rf_allocVector(REALSXP, val->size()));
|
||||
for (unsigned pos = 0; pos < val->size(); pos++)
|
||||
{
|
||||
NUMERIC_POINTER(result)[pos] = ((*val)[pos]);
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return(result);
|
||||
SEXP result;
|
||||
PROTECT(result = Rf_allocVector(REALSXP, val->size()));
|
||||
for (unsigned pos = 0; pos < val->size(); pos++)
|
||||
{
|
||||
NUMERIC_POINTER(result)[pos] = ((*val)[pos]);
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return(result);
|
||||
}
|
||||
};
|
||||
// vectors of floats
|
||||
template <>
|
||||
struct traits_from_ptr<std::vector<float> > {
|
||||
static SEXP from (std::vector<float > *val, int owner = 0) {
|
||||
SEXP result;
|
||||
PROTECT(result = Rf_allocVector(REALSXP, val->size()));
|
||||
for (unsigned pos = 0; pos < val->size(); pos++)
|
||||
{
|
||||
NUMERIC_POINTER(result)[pos] = ((*val)[pos]);
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return(result);
|
||||
SEXP result;
|
||||
PROTECT(result = Rf_allocVector(REALSXP, val->size()));
|
||||
for (unsigned pos = 0; pos < val->size(); pos++)
|
||||
{
|
||||
NUMERIC_POINTER(result)[pos] = ((*val)[pos]);
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return(result);
|
||||
}
|
||||
};
|
||||
// vectors of unsigned int
|
||||
template <>
|
||||
struct traits_from_ptr<std::vector<unsigned int> > {
|
||||
static SEXP from (std::vector<unsigned int > *val, int owner = 0) {
|
||||
SEXP result;
|
||||
PROTECT(result = Rf_allocVector(INTSXP, val->size()));
|
||||
for (unsigned pos = 0; pos < val->size(); pos++)
|
||||
{
|
||||
INTEGER_POINTER(result)[pos] = ((*val)[pos]);
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return(result);
|
||||
SEXP result;
|
||||
PROTECT(result = Rf_allocVector(INTSXP, val->size()));
|
||||
for (unsigned pos = 0; pos < val->size(); pos++)
|
||||
{
|
||||
INTEGER_POINTER(result)[pos] = ((*val)[pos]);
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return(result);
|
||||
}
|
||||
};
|
||||
// vectors of int
|
||||
template <>
|
||||
struct traits_from_ptr<std::vector<int> > {
|
||||
static SEXP from (std::vector<int > *val, int owner = 0) {
|
||||
SEXP result;
|
||||
PROTECT(result = Rf_allocVector(INTSXP, val->size()));
|
||||
for (unsigned pos = 0; pos < val->size(); pos++)
|
||||
{
|
||||
INTEGER_POINTER(result)[pos] = ((*val)[pos]);
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return(result);
|
||||
SEXP result;
|
||||
PROTECT(result = Rf_allocVector(INTSXP, val->size()));
|
||||
for (unsigned pos = 0; pos < val->size(); pos++)
|
||||
{
|
||||
INTEGER_POINTER(result)[pos] = ((*val)[pos]);
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return(result);
|
||||
}
|
||||
};
|
||||
|
||||
// vectors of bool
|
||||
template <>
|
||||
struct traits_from_ptr<std::vector<bool> > {
|
||||
static SEXP from (std::vector<bool> *val, int owner = 0) {
|
||||
SEXP result;
|
||||
PROTECT(result = Rf_allocVector(LGLSXP, val->size()));
|
||||
for (unsigned pos = 0; pos < val->size(); pos++)
|
||||
{
|
||||
LOGICAL_POINTER(result)[pos] = ((*val)[pos]);
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return(result);
|
||||
//return SWIG_R_NewPointerObj(val, type_info< std::vector<T > >(), owner);
|
||||
SEXP result;
|
||||
PROTECT(result = Rf_allocVector(LGLSXP, val->size()));
|
||||
for (unsigned pos = 0; pos < val->size(); pos++)
|
||||
{
|
||||
LOGICAL_POINTER(result)[pos] = ((*val)[pos]);
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return(result);
|
||||
//return SWIG_R_NewPointerObj(val, type_info< std::vector<T > >(), owner);
|
||||
}
|
||||
};
|
||||
// vectors of strings
|
||||
template <>
|
||||
struct traits_from_ptr<std::vector<std::basic_string<char> > > {
|
||||
static SEXP from (std::vector<std::basic_string<char> > *val, int owner = 0) {
|
||||
SEXP result;
|
||||
PROTECT(result = Rf_allocVector(STRSXP, val->size()));
|
||||
for (unsigned pos = 0; pos < val->size(); pos++)
|
||||
{
|
||||
CHARACTER_POINTER(result)[pos] = Rf_mkChar(((*val)[pos]).c_str());
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return(result);
|
||||
//return SWIG_R_NewPointerObj(val, type_info< std::vector<T > >(), owner);
|
||||
SEXP result;
|
||||
PROTECT(result = Rf_allocVector(STRSXP, val->size()));
|
||||
for (unsigned pos = 0; pos < val->size(); pos++)
|
||||
{
|
||||
CHARACTER_POINTER(result)[pos] = Rf_mkChar(((*val)[pos]).c_str());
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return(result);
|
||||
//return SWIG_R_NewPointerObj(val, type_info< std::vector<T > >(), owner);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -98,12 +98,12 @@
|
|||
template <typename T>
|
||||
struct traits_from_ptr< std::vector< T > > {
|
||||
static SEXP from (std::vector< T > *val, int owner = 0) {
|
||||
return SWIG_R_NewPointerObj(val, type_info< std::vector< T > >(), owner);
|
||||
return SWIG_R_NewPointerObj(val, type_info< std::vector< T > >(), owner);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct traits_asptr < std::vector<double> > {
|
||||
struct traits_asptr < std::vector<double> > {
|
||||
static int asptr(SEXP obj, std::vector<double> **val) {
|
||||
std::vector<double> *p;
|
||||
// not sure how to check the size of the SEXP obj is correct
|
||||
|
|
@ -111,19 +111,19 @@
|
|||
p = new std::vector<double>(sexpsz);
|
||||
double *S = NUMERIC_POINTER(obj);
|
||||
for (unsigned pos = 0; pos < p->size(); pos++)
|
||||
{
|
||||
(*p)[pos] = static_cast<double>(S[pos]);
|
||||
}
|
||||
{
|
||||
(*p)[pos] = static_cast<double>(S[pos]);
|
||||
}
|
||||
int res = SWIG_OK;
|
||||
if (SWIG_IsOK(res)) {
|
||||
if (val) *val = p;
|
||||
if (val) *val = p;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template <>
|
||||
struct traits_asptr < std::vector<float> > {
|
||||
struct traits_asptr < std::vector<float> > {
|
||||
static int asptr(SEXP obj, std::vector<float> **val) {
|
||||
std::vector<float> *p;
|
||||
// not sure how to check the size of the SEXP obj is correct
|
||||
|
|
@ -131,19 +131,19 @@
|
|||
p = new std::vector<float>(sexpsz);
|
||||
double *S = NUMERIC_POINTER(obj);
|
||||
for (unsigned pos = 0; pos < p->size(); pos++)
|
||||
{
|
||||
(*p)[pos] = static_cast<double>(S[pos]);
|
||||
}
|
||||
{
|
||||
(*p)[pos] = static_cast<double>(S[pos]);
|
||||
}
|
||||
int res = SWIG_OK;
|
||||
if (SWIG_IsOK(res)) {
|
||||
if (val) *val = p;
|
||||
if (val) *val = p;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
template <>
|
||||
struct traits_asptr < std::vector<unsigned int> > {
|
||||
struct traits_asptr < std::vector<unsigned int> > {
|
||||
static int asptr(SEXP obj, std::vector<unsigned int> **val) {
|
||||
std::vector<unsigned int> *p;
|
||||
unsigned int sexpsz = Rf_length(obj);
|
||||
|
|
@ -152,20 +152,20 @@
|
|||
PROTECT(coerced = Rf_coerceVector(obj, INTSXP));
|
||||
int *S = INTEGER_POINTER(coerced);
|
||||
for (unsigned pos = 0; pos < p->size(); pos++)
|
||||
{
|
||||
(*p)[pos] = static_cast<unsigned int>(S[pos]);
|
||||
}
|
||||
{
|
||||
(*p)[pos] = static_cast<unsigned int>(S[pos]);
|
||||
}
|
||||
int res = SWIG_OK;
|
||||
if (SWIG_IsOK(res)) {
|
||||
if (val) *val = p;
|
||||
if (val) *val = p;
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return res;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template <>
|
||||
struct traits_asptr < std::vector<int> > {
|
||||
struct traits_asptr < std::vector<int> > {
|
||||
static int asptr(SEXP obj, std::vector<int> **val) {
|
||||
std::vector<int> *p;
|
||||
// not sure how to check the size of the SEXP obj is correct
|
||||
|
|
@ -175,31 +175,313 @@
|
|||
PROTECT(coerced = Rf_coerceVector(obj, INTSXP));
|
||||
int *S = INTEGER_POINTER(coerced);
|
||||
for (unsigned pos = 0; pos < p->size(); pos++)
|
||||
{
|
||||
(*p)[pos] = static_cast<int>(S[pos]);
|
||||
}
|
||||
{
|
||||
(*p)[pos] = static_cast<int>(S[pos]);
|
||||
}
|
||||
int res = SWIG_OK;
|
||||
if (SWIG_IsOK(res)) {
|
||||
if (val) *val = p;
|
||||
if (val) *val = p;
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return res;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template <>
|
||||
struct traits_asptr < std::vector<bool> > {
|
||||
static int asptr(SEXP obj, std::vector<bool> **val) {
|
||||
std::vector<bool> *p;
|
||||
// not sure how to check the size of the SEXP obj is correct
|
||||
int sexpsz = Rf_length(obj);
|
||||
p = new std::vector<bool>(sexpsz);
|
||||
SEXP coerced;
|
||||
PROTECT(coerced = Rf_coerceVector(obj, LGLSXP));
|
||||
int *S = LOGICAL_POINTER(coerced);
|
||||
for (unsigned pos = 0; pos < p->size(); pos++)
|
||||
{
|
||||
(*p)[pos] = static_cast<bool>(S[pos]);
|
||||
}
|
||||
int res = SWIG_OK;
|
||||
if (SWIG_IsOK(res)) {
|
||||
if (val) *val = p;
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
// catchall for R to vector conversion
|
||||
template <typename T>
|
||||
struct traits_asptr < std::vector<T> > {
|
||||
struct traits_asptr < std::vector<T> > {
|
||||
static int asptr(SEXP obj, std::vector<T> **val) {
|
||||
std::vector<T> *p;
|
||||
Rprintf("my asptr\n");
|
||||
int res = SWIG_R_ConvertPtr(obj, (void**)&p, type_info< std::vector<T> >(), 0);
|
||||
if (SWIG_IsOK(res)) {
|
||||
if (val) *val = p;
|
||||
if (val) *val = p;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// now for vectors of vectors. These will be represented as lists of vectors on the
|
||||
// catch all that does everything with vectors
|
||||
template <>
|
||||
struct traits_from_ptr<std::vector<std::vector<unsigned int> > > {
|
||||
static SEXP from (std::vector< std::vector<unsigned int > > *val, int owner = 0) {
|
||||
SEXP result;
|
||||
// allocate the R list
|
||||
PROTECT(result = Rf_allocVector(VECSXP, val->size()));
|
||||
for (unsigned pos = 0; pos < val->size(); pos++)
|
||||
{
|
||||
// allocate the R vector
|
||||
SET_VECTOR_ELT(result, pos, Rf_allocVector(INTSXP, val->at(pos).size()));
|
||||
// Fill the R vector
|
||||
for (unsigned vpos = 0; vpos < val->at(pos).size(); ++vpos)
|
||||
{
|
||||
INTEGER_POINTER(VECTOR_ELT(result, pos))[vpos] = static_cast<int>(val->at(pos).at(vpos));
|
||||
}
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return(result);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct traits_from_ptr<std::vector<std::vector<int> > > {
|
||||
static SEXP from (std::vector< std::vector<int > > *val, int owner = 0) {
|
||||
SEXP result;
|
||||
// allocate the R list
|
||||
PROTECT(result = Rf_allocVector(VECSXP, val->size()));
|
||||
for (unsigned pos = 0; pos < val->size(); pos++)
|
||||
{
|
||||
// allocate the R vector
|
||||
SET_VECTOR_ELT(result, pos, Rf_allocVector(INTSXP, val->at(pos).size()));
|
||||
// Fill the R vector
|
||||
for (unsigned vpos = 0; vpos < val->at(pos).size(); ++vpos)
|
||||
{
|
||||
INTEGER_POINTER(VECTOR_ELT(result, pos))[vpos] = static_cast<int>(val->at(pos).at(vpos));
|
||||
}
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return(result);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct traits_from_ptr<std::vector<std::vector<float> > > {
|
||||
static SEXP from (std::vector< std::vector<float > > *val, int owner = 0) {
|
||||
SEXP result;
|
||||
// allocate the R list
|
||||
PROTECT(result = Rf_allocVector(VECSXP, val->size()));
|
||||
for (unsigned pos = 0; pos < val->size(); pos++)
|
||||
{
|
||||
// allocate the R vector
|
||||
SET_VECTOR_ELT(result, pos, Rf_allocVector(REALSXP, val->at(pos).size()));
|
||||
// Fill the R vector
|
||||
for (unsigned vpos = 0; vpos < val->at(pos).size(); ++vpos)
|
||||
{
|
||||
NUMERIC_POINTER(VECTOR_ELT(result, pos))[vpos] = static_cast<double>(val->at(pos).at(vpos));
|
||||
}
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return(result);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct traits_from_ptr<std::vector<std::vector<double> > > {
|
||||
static SEXP from (std::vector< std::vector<double > > *val, int owner = 0) {
|
||||
SEXP result;
|
||||
// allocate the R list
|
||||
PROTECT(result = Rf_allocVector(VECSXP, val->size()));
|
||||
for (unsigned pos = 0; pos < val->size(); pos++)
|
||||
{
|
||||
// allocate the R vector
|
||||
SET_VECTOR_ELT(result, pos, Rf_allocVector(REALSXP, val->at(pos).size()));
|
||||
// Fill the R vector
|
||||
for (unsigned vpos = 0; vpos < val->at(pos).size(); ++vpos)
|
||||
{
|
||||
NUMERIC_POINTER(VECTOR_ELT(result, pos))[vpos] = static_cast<double>(val->at(pos).at(vpos));
|
||||
}
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return(result);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct traits_from_ptr<std::vector<std::vector<bool> > > {
|
||||
static SEXP from (std::vector< std::vector<bool> > *val, int owner = 0) {
|
||||
SEXP result;
|
||||
// allocate the R list
|
||||
PROTECT(result = Rf_allocVector(VECSXP, val->size()));
|
||||
for (unsigned pos = 0; pos < val->size(); pos++)
|
||||
{
|
||||
// allocate the R vector
|
||||
SET_VECTOR_ELT(result, pos, Rf_allocVector(LGLSXP, val->at(pos).size()));
|
||||
// Fill the R vector
|
||||
for (unsigned vpos = 0; vpos < val->at(pos).size(); ++vpos)
|
||||
{
|
||||
LOGICAL_POINTER(VECTOR_ELT(result, pos))[vpos] = (val->at(pos).at(vpos));
|
||||
}
|
||||
}
|
||||
UNPROTECT(1);
|
||||
return(result);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct traits_from_ptr< std::vector < std::vector< T > > > {
|
||||
static SEXP from (std::vector < std::vector< T > > *val, int owner = 0) {
|
||||
return SWIG_R_NewPointerObj(val, type_info< std::vector < std::vector< T > > >(), owner);
|
||||
}
|
||||
};
|
||||
|
||||
// R side
|
||||
template <>
|
||||
struct traits_asptr < std::vector< std::vector<unsigned int> > > {
|
||||
static int asptr(SEXP obj, std::vector< std::vector<unsigned int> > **val) {
|
||||
std::vector <std::vector<unsigned int> > *p;
|
||||
// this is the length of the list
|
||||
unsigned int sexpsz = Rf_length(obj);
|
||||
p = new std::vector< std::vector<unsigned int> > (sexpsz);
|
||||
|
||||
for (unsigned listpos = 0; listpos < sexpsz; ++listpos)
|
||||
{
|
||||
unsigned vecsize = Rf_length(VECTOR_ELT(obj, listpos));
|
||||
for (unsigned vpos = 0; vpos < vecsize; ++vpos)
|
||||
{
|
||||
(*p)[listpos].push_back(static_cast<int>(INTEGER_POINTER(VECTOR_ELT(obj, listpos))[vpos]));
|
||||
}
|
||||
}
|
||||
|
||||
int res = SWIG_OK;
|
||||
|
||||
if (SWIG_IsOK(res)) {
|
||||
if (val) *val = p;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct traits_asptr < std::vector< std::vector< int> > > {
|
||||
static int asptr(SEXP obj, std::vector< std::vector< int> > **val) {
|
||||
std::vector <std::vector< int> > *p;
|
||||
// this is the length of the list
|
||||
unsigned int sexpsz = Rf_length(obj);
|
||||
p = new std::vector< std::vector< int> > (sexpsz);
|
||||
|
||||
for (unsigned listpos = 0; listpos < sexpsz; ++listpos)
|
||||
{
|
||||
unsigned vecsize = Rf_length(VECTOR_ELT(obj, listpos));
|
||||
for (unsigned vpos = 0; vpos < vecsize; ++vpos)
|
||||
{
|
||||
(*p)[listpos].push_back(static_cast<int>(INTEGER_POINTER(VECTOR_ELT(obj, listpos))[vpos]));
|
||||
}
|
||||
}
|
||||
|
||||
int res = SWIG_OK;
|
||||
|
||||
if (SWIG_IsOK(res)) {
|
||||
if (val) *val = p;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct traits_asptr < std::vector< std::vector< float> > > {
|
||||
static int asptr(SEXP obj, std::vector< std::vector< float> > **val) {
|
||||
std::vector <std::vector< float> > *p;
|
||||
// this is the length of the list
|
||||
unsigned int sexpsz = Rf_length(obj);
|
||||
p = new std::vector< std::vector< float> > (sexpsz);
|
||||
|
||||
for (unsigned listpos = 0; listpos < sexpsz; ++listpos)
|
||||
{
|
||||
unsigned vecsize = Rf_length(VECTOR_ELT(obj, listpos));
|
||||
for (unsigned vpos = 0; vpos < vecsize; ++vpos)
|
||||
{
|
||||
(*p)[listpos].push_back(static_cast<float>(NUMERIC_POINTER(VECTOR_ELT(obj, listpos))[vpos]));
|
||||
}
|
||||
}
|
||||
|
||||
int res = SWIG_OK;
|
||||
|
||||
if (SWIG_IsOK(res)) {
|
||||
if (val) *val = p;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct traits_asptr < std::vector< std::vector< double> > > {
|
||||
static int asptr(SEXP obj, std::vector< std::vector< double> > **val) {
|
||||
std::vector <std::vector< double> > *p;
|
||||
// this is the length of the list
|
||||
unsigned int sexpsz = Rf_length(obj);
|
||||
p = new std::vector< std::vector< double> > (sexpsz);
|
||||
|
||||
for (unsigned listpos = 0; listpos < sexpsz; ++listpos)
|
||||
{
|
||||
unsigned vecsize = Rf_length(VECTOR_ELT(obj, listpos));
|
||||
for (unsigned vpos = 0; vpos < vecsize; ++vpos)
|
||||
{
|
||||
(*p)[listpos].push_back(static_cast<double>(NUMERIC_POINTER(VECTOR_ELT(obj, listpos))[vpos]));
|
||||
}
|
||||
}
|
||||
|
||||
int res = SWIG_OK;
|
||||
|
||||
if (SWIG_IsOK(res)) {
|
||||
if (val) *val = p;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct traits_asptr < std::vector< std::vector< bool > > > {
|
||||
static int asptr(SEXP obj, std::vector< std::vector< bool> > **val) {
|
||||
std::vector <std::vector< bool > > *p;
|
||||
// this is the length of the list
|
||||
unsigned int sexpsz = Rf_length(obj);
|
||||
p = new std::vector< std::vector< bool > > (sexpsz);
|
||||
|
||||
for (unsigned listpos = 0; listpos < sexpsz; ++listpos)
|
||||
{
|
||||
unsigned vecsize = Rf_length(VECTOR_ELT(obj, listpos));
|
||||
for (unsigned vpos = 0; vpos < vecsize; ++vpos)
|
||||
{
|
||||
(*p)[listpos].push_back(static_cast<bool>(LOGICAL_POINTER(VECTOR_ELT(obj, listpos))[vpos]));
|
||||
}
|
||||
}
|
||||
|
||||
int res = SWIG_OK;
|
||||
|
||||
if (SWIG_IsOK(res)) {
|
||||
if (val) *val = p;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
// catchall
|
||||
template <typename T>
|
||||
struct traits_asptr < std::vector< std::vector<T> > > {
|
||||
static int asptr(SEXP obj, std::vector< std::vector<T> > **val) {
|
||||
std::vector< std::vector<T> > *p;
|
||||
Rprintf("vector of vectors - unsupported content\n");
|
||||
int res = SWIG_R_ConvertPtr(obj, (void**)&p, type_info< std::vector< std::vector<T> > > (), 0);
|
||||
if (SWIG_IsOK(res)) {
|
||||
if (val) *val = p;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
%}
|
||||
|
|
@ -209,12 +491,12 @@
|
|||
|
||||
%define %traits_type_name(Type...)
|
||||
%fragment(SWIG_Traits_frag(Type), "header",
|
||||
fragment="StdTraits",fragment="StdVectorTraits") {
|
||||
fragment="StdTraits",fragment="StdVectorTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits< Type > {
|
||||
typedef pointer_category category;
|
||||
static const char* type_name() {
|
||||
return #Type;
|
||||
return #Type;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -225,32 +507,74 @@
|
|||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<double>)
|
||||
%traits_type_name(std::vector<double>)
|
||||
%typemap("rtypecheck") std::vector<double> %{ is.numeric($arg) %}
|
||||
%typemap("rtypecheck") std::vector<double>, std::vector<double> const, std::vector<double> const&
|
||||
%{ is.numeric($arg) %}
|
||||
%typemap("rtype") std::vector<double> "numeric"
|
||||
%typemap("scoercein") std::vector<double>, std::vector<double> const, std::vector<double> const& "";
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<float>)
|
||||
%traits_type_name(std::vector<float>)
|
||||
%typemap("rtypecheck") std::vector<float> %{ is.numeric($arg) %}
|
||||
%typemap("rtypecheck") std::vector<float>, std::vector<float> const, std::vector<float> const&
|
||||
%{ is.numeric($arg) %}
|
||||
%typemap("rtype") std::vector<float> "numeric"
|
||||
%typemap("scoercein") std::vector<double>, std::vector<float> const, std::vector<float> const& "";
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<bool>);
|
||||
%traits_type_name(std::vector<bool>);
|
||||
%typemap("rtypecheck") std::vector<bool> %{ is.logical($arg) %}
|
||||
%typemap("rtypecheck") std::vector<bool> , std::vector<bool> const, std::vector<bool> const&
|
||||
%{ is.logical($arg) %}
|
||||
%typemap("rtype") std::vector<bool> "logical"
|
||||
%typemap("scoercein") std::vector<bool> , std::vector<bool> const, std::vector<bool> const& "$input = as.logical($input);";
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<int>);
|
||||
%traits_type_name(std::vector<int>);
|
||||
%typemap("rtypecheck") std::vector<int>
|
||||
%typemap("rtypecheck") std::vector<int> , std::vector<int> const, std::vector<int> const&
|
||||
%{ is.integer($arg) || is.numeric($arg) %}
|
||||
%typemap("rtype") std::vector<int> "integer"
|
||||
%typemap("scoercein") std::vector<int> "$input = as.integer($input);";
|
||||
%typemap("scoercein") std::vector<int> , std::vector<int> const, std::vector<int> const& "$input = as.integer($input);";
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<unsigned int>);
|
||||
%traits_type_name(std::vector<unsigned int>);
|
||||
%typemap("rtypecheck") std::vector<unsigned int>
|
||||
%typemap("rtypecheck") std::vector<unsigned int>, std::vector<unsigned int> const, std::vector<unsigned int> const&
|
||||
%{ is.integer($arg) || is.numeric($arg) %}
|
||||
%typemap("rtype") std::vector<unsigned int> "integer"
|
||||
%typemap("scoercein") std::vector<unsigned int> "$input = as.integer($input);";
|
||||
%typemap("scoercein") std::vector<unsigned int>, std::vector<unsigned int> const, std::vector<unsigned int> const& "$input = as.integer($input);";
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<std::vector<unsigned int> >);
|
||||
%traits_type_name(std::vector< std::vector<unsigned int> >);
|
||||
%typemap("rtypecheck") std::vector<std::vector<unsigned int> >, std::vector<std::vector<unsigned int> > const, std::vector<std::vector<unsigned int> >const&
|
||||
%{ is.list($arg) && all(sapply($arg , is.integer) || sapply($arg, is.numeric)) %}
|
||||
%typemap("rtype") std::vector<std::vector<unsigned int> > "list"
|
||||
%typemap("scoercein") std::vector< std::vector<unsigned int> >, std::vector<std::vector<unsigned int> > const, std::vector<std::vector<unsigned int> >const& "$input = lapply($input, as.integer);";
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<std::vector<int> >);
|
||||
%traits_type_name(std::vector< std::vector<int> >);
|
||||
%typemap("rtypecheck") std::vector<std::vector<int> >, std::vector<std::vector<int> > const, std::vector<std::vector<int> >const&
|
||||
%{ is.list($arg) && all(sapply($arg , is.integer) || sapply($arg, is.numeric)) %}
|
||||
%typemap("rtype") std::vector<std::vector<int> > "list"
|
||||
%typemap("scoercein") std::vector< std::vector<int> >, std::vector<std::vector<int> > const, std::vector<std::vector<int> >const& "$input = lapply($input, as.integer);";
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<std::vector<float> >);
|
||||
%traits_type_name(std::vector< std::vector<float> >);
|
||||
%typemap("rtypecheck") std::vector<std::vector<float> >, std::vector<std::vector<float> > const, std::vector<std::vector<float> >const&
|
||||
%{ is.list($arg) && all(sapply($arg , is.integer) || sapply($arg, is.numeric)) %}
|
||||
%typemap("rtype") std::vector<std::vector<float> > "list"
|
||||
%typemap("scoercein") std::vector< std::vector<float> >, std::vector<std::vector<float> > const, std::vector<std::vector<float> >const& "$input = lapply($input, as.numeric);";
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<std::vector<double> >);
|
||||
%traits_type_name(std::vector< std::vector<double> >);
|
||||
%typemap("rtypecheck") std::vector<std::vector<double> >, std::vector<std::vector<double> > const, std::vector<std::vector<double> >const&
|
||||
%{ is.list($arg) && all(sapply($arg , is.integer) || sapply($arg, is.numeric)) %}
|
||||
%typemap("rtype") std::vector<std::vector<double> > "list"
|
||||
%typemap("scoercein") std::vector< std::vector<double> >, std::vector<std::vector<double> > const, std::vector<std::vector<double> >const&
|
||||
"$input = lapply($input, as.numeric);";
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<std::vector<bool> >);
|
||||
%traits_type_name(std::vector< std::vector<bool> >);
|
||||
%typemap("rtypecheck") std::vector<std::vector<bool> >, std::vector<std::vector<bool> > const, std::vector<std::vector<bool> >const&
|
||||
%{ is.list($arg) && all(sapply($arg , is.integer) || sapply($arg, is.numeric)) %}
|
||||
%typemap("rtype") std::vector<std::vector<bool> > "list"
|
||||
%typemap("scoercein") std::vector< std::vector<bool> >, std::vector<std::vector<bool> > const, std::vector<std::vector<bool> >const& "$input = lapply($input, as.logical);";
|
||||
|
||||
// we don't want these to be given R classes as they
|
||||
// have already been turned into R vectors.
|
||||
|
|
@ -262,7 +586,23 @@
|
|||
std::vector<bool> &,
|
||||
std::vector<unsigned int>,
|
||||
std::vector<unsigned int> *,
|
||||
std::vector<unsigned int> &
|
||||
std::vector<unsigned int> &,
|
||||
// vectors of vectors
|
||||
std::vector< std::vector<unsigned int> >,
|
||||
std::vector< std::vector<unsigned int> >*,
|
||||
std::vector< std::vector<unsigned int> >&,
|
||||
std::vector< std::vector<int> >,
|
||||
std::vector< std::vector<int> >*,
|
||||
std::vector< std::vector<int> >&,
|
||||
std::vector< std::vector<float> >,
|
||||
std::vector< std::vector<float> >*,
|
||||
std::vector< std::vector<float> >&,
|
||||
std::vector< std::vector<double> >,
|
||||
std::vector< std::vector<double> >*,
|
||||
std::vector< std::vector<double> >&,
|
||||
std::vector< std::vector<bool> >,
|
||||
std::vector< std::vector<bool> >*,
|
||||
std::vector< std::vector<bool> >&
|
||||
|
||||
|
||||
%{ %}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
/* initial STL definition. extended as needed in each language */
|
||||
%include std_common.i
|
||||
%include std_vector.i
|
||||
%include std_pair.i
|
||||
%include std_string.i
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
$2 = (char **) malloc((size+1)*sizeof(char *));
|
||||
VALUE *ptr = RARRAY_PTR($input);
|
||||
for (i=0; i < size; i++, ptr++) {
|
||||
$2[i]= STR2CSTR(*ptr);
|
||||
$2[i]= StringValuePtr(*ptr);
|
||||
}
|
||||
$2[i]=NULL;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
/*
|
||||
Use -DSWIG_DIRECTOR_NOUEH if you prefer to avoid the use of the
|
||||
Undefined Exception Handler provided by swift
|
||||
Undefined Exception Handler provided by swig.
|
||||
*/
|
||||
#ifndef SWIG_DIRECTOR_NOUEH
|
||||
#ifndef SWIG_DIRECTOR_UEH
|
||||
|
|
|
|||
|
|
@ -36,11 +36,64 @@
|
|||
|
||||
%fragment("GC_VALUE_definition","header") {
|
||||
namespace swig {
|
||||
class SwigGCReferences {
|
||||
// Hash of all GC_VALUE's currently in use
|
||||
static SwigGCReferences s_references;
|
||||
|
||||
VALUE _hash;
|
||||
|
||||
SwigGCReferences() : _hash(Qnil) {
|
||||
}
|
||||
~SwigGCReferences() {
|
||||
if (_hash != Qnil)
|
||||
rb_gc_unregister_address(&_hash);
|
||||
}
|
||||
static void EndProcHandler(VALUE) {
|
||||
// Ruby interpreter ending - _hash can no longer be accessed.
|
||||
s_references._hash = Qnil;
|
||||
}
|
||||
public:
|
||||
static SwigGCReferences& instance() {
|
||||
return s_references;
|
||||
}
|
||||
static void initialize() {
|
||||
if (s_references._hash == Qnil) {
|
||||
rb_set_end_proc(&EndProcHandler, Qnil);
|
||||
s_references._hash = rb_hash_new();
|
||||
rb_gc_register_address(&s_references._hash);
|
||||
}
|
||||
}
|
||||
void GC_register(VALUE& obj) {
|
||||
if (FIXNUM_P(obj) || SPECIAL_CONST_P(obj) || SYMBOL_P(obj))
|
||||
return;
|
||||
if (_hash != Qnil) {
|
||||
VALUE val = rb_hash_aref(_hash, obj);
|
||||
unsigned n = FIXNUM_P(val) ? NUM2UINT(val) : 0;
|
||||
++n;
|
||||
rb_hash_aset(_hash, obj, INT2NUM(n));
|
||||
}
|
||||
}
|
||||
void GC_unregister(const VALUE& obj) {
|
||||
if (FIXNUM_P(obj) || SPECIAL_CONST_P(obj) || SYMBOL_P(obj))
|
||||
return;
|
||||
// this test should not be needed but I've noticed some very erratic
|
||||
// behavior of none being unregistered in some very rare situations.
|
||||
if (BUILTIN_TYPE(obj) == T_NONE)
|
||||
return;
|
||||
if (_hash != Qnil) {
|
||||
VALUE val = rb_hash_aref(s_references._hash, obj);
|
||||
unsigned n = FIXNUM_P(val) ? NUM2UINT(val) : 1;
|
||||
--n;
|
||||
if (n)
|
||||
rb_hash_aset(s_references._hash, obj, INT2NUM(n));
|
||||
else
|
||||
rb_hash_delete(s_references._hash, obj);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class GC_VALUE {
|
||||
protected:
|
||||
// Hash of all GC_VALUE's currently in use
|
||||
static VALUE _hash;
|
||||
|
||||
VALUE _obj;
|
||||
|
||||
static ID hash_id;
|
||||
|
|
@ -77,75 +130,33 @@ namespace swig {
|
|||
|
||||
|
||||
public:
|
||||
static void initialize()
|
||||
{
|
||||
if ( _hash == Qnil )
|
||||
{
|
||||
_hash = rb_hash_new();
|
||||
rb_gc_register_address( &_hash );
|
||||
}
|
||||
}
|
||||
|
||||
// this function is never called. Provided for symmetry only.
|
||||
static void cleanup()
|
||||
{
|
||||
rb_gc_unregister_address( &_hash );
|
||||
}
|
||||
|
||||
GC_VALUE() : _obj( Qnil )
|
||||
GC_VALUE() : _obj(Qnil)
|
||||
{
|
||||
}
|
||||
|
||||
GC_VALUE(const GC_VALUE& item) : _obj(item._obj)
|
||||
{
|
||||
GC_register();
|
||||
SwigGCReferences::instance().GC_register(_obj);
|
||||
}
|
||||
|
||||
GC_VALUE(VALUE obj) :_obj(obj)
|
||||
{
|
||||
GC_register();
|
||||
SwigGCReferences::instance().GC_register(_obj);
|
||||
}
|
||||
|
||||
~GC_VALUE()
|
||||
{
|
||||
GC_unregister();
|
||||
SwigGCReferences::instance().GC_unregister(_obj);
|
||||
}
|
||||
|
||||
GC_VALUE & operator=(const GC_VALUE& item)
|
||||
{
|
||||
GC_unregister();
|
||||
SwigGCReferences::instance().GC_unregister(_obj);
|
||||
_obj = item._obj;
|
||||
GC_register();
|
||||
SwigGCReferences::instance().GC_register(_obj);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void GC_register()
|
||||
{
|
||||
if ( FIXNUM_P(_obj) || SPECIAL_CONST_P(_obj) || SYMBOL_P(_obj) )
|
||||
return;
|
||||
VALUE val = rb_hash_aref( _hash, _obj );
|
||||
unsigned n = FIXNUM_P(val) ? NUM2UINT(val) : 0;
|
||||
++n;
|
||||
rb_hash_aset( _hash, _obj, INT2NUM(n) );
|
||||
}
|
||||
|
||||
void GC_unregister()
|
||||
{
|
||||
if ( FIXNUM_P(_obj) || SPECIAL_CONST_P(_obj) || SYMBOL_P(_obj) )
|
||||
return;
|
||||
// this test should not be needed but I've noticed some very erratic
|
||||
// behavior of none being unregistered in some very rare situations.
|
||||
if ( BUILTIN_TYPE(_obj) == T_NONE ) return;
|
||||
|
||||
VALUE val = rb_hash_aref( _hash, _obj );
|
||||
unsigned n = FIXNUM_P(val) ? NUM2UINT(val) : 1;
|
||||
--n;
|
||||
if ( n )
|
||||
rb_hash_aset( _hash, _obj, INT2NUM(n) );
|
||||
else
|
||||
rb_hash_delete( _hash, _obj );
|
||||
}
|
||||
|
||||
operator VALUE() const
|
||||
{
|
||||
return _obj;
|
||||
|
|
@ -161,113 +172,110 @@ namespace swig {
|
|||
return rb_inspect(_obj);
|
||||
}
|
||||
|
||||
static VALUE swig_protect_funcall( VALUE p )
|
||||
static VALUE swig_rescue_swallow(VALUE)
|
||||
{
|
||||
/*
|
||||
VALUE errstr = rb_obj_as_string(rb_errinfo());
|
||||
printf("Swallowing error: '%s'\n", RSTRING_PTR(StringValue(errstr)));
|
||||
*/
|
||||
return Qnil; /* Swallow Ruby exception */
|
||||
}
|
||||
|
||||
static VALUE swig_rescue_funcall(VALUE p)
|
||||
{
|
||||
OpArgs* args = (OpArgs*) p;
|
||||
return rb_funcall( args->src, args->id, args->nargs, args->target );
|
||||
return rb_funcall(args->src, args->id, args->nargs, args->target);
|
||||
}
|
||||
|
||||
|
||||
%#define GC_VALUE_CMP( op_id, op, cmp, cmpval ) \
|
||||
bool op( const GC_VALUE& other ) const \
|
||||
{ \
|
||||
if ( FIXNUM_P(_obj) && FIXNUM_P(other._obj) ) \
|
||||
{ \
|
||||
return _obj cmp other._obj; \
|
||||
} \
|
||||
bool res = false; \
|
||||
VALUE ret = Qnil; \
|
||||
SWIG_RUBY_THREAD_BEGIN_BLOCK; \
|
||||
if ( rb_respond_to( _obj, op_id ) == Qtrue ) \
|
||||
{ \
|
||||
int status; \
|
||||
OpArgs args; \
|
||||
args.src = _obj; \
|
||||
args.id = op_id; \
|
||||
args.nargs = 1; \
|
||||
args.target = VALUE(other); \
|
||||
ret = rb_protect( PROTECTFUNC(swig_protect_funcall), \
|
||||
VALUE(&args), &status ); \
|
||||
} \
|
||||
if ( ret == Qnil ) { \
|
||||
VALUE a = rb_funcall( _obj, hash_id, 0 ); \
|
||||
VALUE b = rb_funcall( VALUE(other), hash_id, 0 ); \
|
||||
res = a cmp b; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
res = RTEST( ret ); \
|
||||
} \
|
||||
SWIG_RUBY_THREAD_END_BLOCK; \
|
||||
return res; \
|
||||
bool relational_equal_op(const GC_VALUE& other, const ID& op_id, bool (*op_func)(const VALUE& a, const VALUE& b)) const
|
||||
{
|
||||
if (FIXNUM_P(_obj) && FIXNUM_P(other._obj)) {
|
||||
return op_func(_obj, other._obj);
|
||||
}
|
||||
bool res = false;
|
||||
VALUE ret = Qnil;
|
||||
SWIG_RUBY_THREAD_BEGIN_BLOCK;
|
||||
if (rb_respond_to(_obj, op_id)) {
|
||||
OpArgs args;
|
||||
args.src = _obj;
|
||||
args.id = op_id;
|
||||
args.nargs = 1;
|
||||
args.target = VALUE(other);
|
||||
ret = rb_rescue(RUBY_METHOD_FUNC(swig_rescue_funcall), VALUE(&args),
|
||||
(RUBY_METHOD_FUNC(swig_rescue_swallow)), Qnil);
|
||||
}
|
||||
if (ret == Qnil) {
|
||||
VALUE a = rb_funcall( _obj, hash_id, 0 );
|
||||
VALUE b = rb_funcall( VALUE(other), hash_id, 0 );
|
||||
res = op_func(a, b);
|
||||
} else {
|
||||
res = RTEST(ret);
|
||||
}
|
||||
SWIG_RUBY_THREAD_END_BLOCK;
|
||||
return res;
|
||||
}
|
||||
|
||||
static bool operator_eq(const VALUE& a, const VALUE& b) { return a == b; }
|
||||
static bool operator_lt(const VALUE& a, const VALUE& b) { return a < b; }
|
||||
static bool operator_le(const VALUE& a, const VALUE& b) { return a <= b; }
|
||||
static bool operator_gt(const VALUE& a, const VALUE& b) { return a > b; }
|
||||
static bool operator_ge(const VALUE& a, const VALUE& b) { return a >= b; }
|
||||
|
||||
GC_VALUE_CMP( eq_id, operator==, ==, == 0 )
|
||||
GC_VALUE_CMP( lt_id, operator<, < , < 0 )
|
||||
GC_VALUE_CMP( le_id, operator<=, <=, <= 0 )
|
||||
GC_VALUE_CMP( gt_id, operator>, > , > 0 )
|
||||
GC_VALUE_CMP( ge_id, operator>=, >=, >= 0 )
|
||||
%#undef GC_VALUE_CMP
|
||||
bool operator==(const GC_VALUE& other) const { return relational_equal_op(other, eq_id, operator_eq); }
|
||||
bool operator<(const GC_VALUE& other) const { return relational_equal_op(other, lt_id, operator_lt); }
|
||||
bool operator<=(const GC_VALUE& other) const { return relational_equal_op(other, le_id, operator_le); }
|
||||
bool operator>(const GC_VALUE& other) const { return relational_equal_op(other, gt_id, operator_gt); }
|
||||
bool operator>=(const GC_VALUE& other) const { return relational_equal_op(other, ge_id, operator_ge); }
|
||||
|
||||
bool operator!=( const GC_VALUE& other )
|
||||
bool operator!=(const GC_VALUE& other) const
|
||||
{
|
||||
return !(this->operator==(other));
|
||||
}
|
||||
|
||||
%#define GC_VALUE_UNARY( proc_id, op ) \
|
||||
GC_VALUE op() const \
|
||||
{ \
|
||||
VALUE ret = Qnil; \
|
||||
SWIG_RUBY_THREAD_BEGIN_BLOCK; \
|
||||
int status; \
|
||||
OpArgs args; \
|
||||
args.src = _obj; \
|
||||
args.id = proc_id; \
|
||||
args.nargs = 0; \
|
||||
args.target = Qnil; \
|
||||
ret = rb_protect( PROTECTFUNC(swig_protect_funcall), VALUE(&args), \
|
||||
&status ); \
|
||||
SWIG_RUBY_THREAD_END_BLOCK; \
|
||||
return ret; \
|
||||
GC_VALUE unary_op(const ID& op_id) const
|
||||
{
|
||||
VALUE ret = Qnil;
|
||||
SWIG_RUBY_THREAD_BEGIN_BLOCK;
|
||||
OpArgs args;
|
||||
args.src = _obj;
|
||||
args.id = op_id;
|
||||
args.nargs = 0;
|
||||
args.target = Qnil;
|
||||
ret = rb_rescue(RUBY_METHOD_FUNC(swig_rescue_funcall), VALUE(&args),
|
||||
(RUBY_METHOD_FUNC(swig_rescue_swallow)), Qnil);
|
||||
SWIG_RUBY_THREAD_END_BLOCK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
GC_VALUE_UNARY( pos_id, operator+ )
|
||||
GC_VALUE_UNARY( neg_id, operator- )
|
||||
GC_VALUE_UNARY( inv_id, operator~ )
|
||||
%#undef GC_VALUE_BINARY
|
||||
GC_VALUE operator+() const { return unary_op(pos_id); }
|
||||
GC_VALUE operator-() const { return unary_op(neg_id); }
|
||||
GC_VALUE operator~() const { return unary_op(inv_id); }
|
||||
|
||||
%#define GC_VALUE_BINARY( proc_id, op ) \
|
||||
GC_VALUE op( const GC_VALUE& other ) const \
|
||||
{ \
|
||||
VALUE ret = Qnil; \
|
||||
SWIG_RUBY_THREAD_BEGIN_BLOCK; \
|
||||
int status; \
|
||||
OpArgs args; \
|
||||
args.src = _obj; \
|
||||
args.id = proc_id; \
|
||||
args.nargs = 1; \
|
||||
args.target = VALUE(other); \
|
||||
ret = rb_protect( PROTECTFUNC(swig_protect_funcall), VALUE(&args), \
|
||||
&status ); \
|
||||
SWIG_RUBY_THREAD_END_BLOCK; \
|
||||
return GC_VALUE(ret); \
|
||||
GC_VALUE binary_op(const GC_VALUE& other, const ID& op_id) const
|
||||
{
|
||||
VALUE ret = Qnil;
|
||||
SWIG_RUBY_THREAD_BEGIN_BLOCK;
|
||||
OpArgs args;
|
||||
args.src = _obj;
|
||||
args.id = op_id;
|
||||
args.nargs = 1;
|
||||
args.target = VALUE(other);
|
||||
ret = rb_rescue(RUBY_METHOD_FUNC(swig_rescue_funcall), VALUE(&args),
|
||||
(RUBY_METHOD_FUNC(swig_rescue_swallow)), Qnil);
|
||||
SWIG_RUBY_THREAD_END_BLOCK;
|
||||
return GC_VALUE(ret);
|
||||
}
|
||||
|
||||
GC_VALUE_BINARY( add_id, operator+ );
|
||||
GC_VALUE_BINARY( sub_id, operator- );
|
||||
GC_VALUE_BINARY( mul_id, operator* );
|
||||
GC_VALUE_BINARY( div_id, operator/ );
|
||||
GC_VALUE_BINARY( mod_id, operator% );
|
||||
|
||||
GC_VALUE_BINARY( and_id, operator& );
|
||||
GC_VALUE_BINARY( xor_id, operator^ );
|
||||
GC_VALUE_BINARY( or_id, operator| );
|
||||
|
||||
GC_VALUE_BINARY( lshift_id, operator<< );
|
||||
GC_VALUE_BINARY( rshift_id, operator>> );
|
||||
%#undef GC_VALUE_BINARY
|
||||
|
||||
GC_VALUE operator+(const GC_VALUE& other) const { return binary_op(other, add_id); }
|
||||
GC_VALUE operator-(const GC_VALUE& other) const { return binary_op(other, sub_id); }
|
||||
GC_VALUE operator*(const GC_VALUE& other) const { return binary_op(other, mul_id); }
|
||||
GC_VALUE operator/(const GC_VALUE& other) const { return binary_op(other, div_id); }
|
||||
GC_VALUE operator%(const GC_VALUE& other) const { return binary_op(other, mod_id); }
|
||||
GC_VALUE operator&(const GC_VALUE& other) const { return binary_op(other, and_id); }
|
||||
GC_VALUE operator^(const GC_VALUE& other) const { return binary_op(other, xor_id); }
|
||||
GC_VALUE operator|(const GC_VALUE& other) const { return binary_op(other, or_id); }
|
||||
GC_VALUE operator<<(const GC_VALUE& other) const { return binary_op(other, lshift_id); }
|
||||
GC_VALUE operator>>(const GC_VALUE& other) const { return binary_op(other, rshift_id); }
|
||||
};
|
||||
|
||||
ID GC_VALUE::hash_id = rb_intern("hash");
|
||||
|
|
@ -294,7 +302,7 @@ namespace swig {
|
|||
ID GC_VALUE::lshift_id = rb_intern("<<");
|
||||
ID GC_VALUE::rshift_id = rb_intern(">>");
|
||||
|
||||
VALUE GC_VALUE::_hash = Qnil;
|
||||
SwigGCReferences SwigGCReferences::s_references;
|
||||
|
||||
typedef GC_VALUE LANGUAGE_OBJ;
|
||||
|
||||
|
|
@ -337,7 +345,7 @@ namespace swig {
|
|||
VALUE to_s() const;
|
||||
GC_VALUE();
|
||||
protected:
|
||||
GC_VALUE( const GC_VALUE& );
|
||||
GC_VALUE(const GC_VALUE&);
|
||||
~GC_VALUE();
|
||||
};
|
||||
|
||||
|
|
@ -350,7 +358,7 @@ namespace swig {
|
|||
|
||||
|
||||
%init {
|
||||
swig::GC_VALUE::initialize();
|
||||
swig::SwigGCReferences::initialize();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,49 +1,61 @@
|
|||
/*
|
||||
Defines the As/From conversors for double/float complex, you need to
|
||||
provide complex Type, the Name you want to use in the conversors,
|
||||
provide complex Type, the Name you want to use in the converters,
|
||||
the complex Constructor method, and the Real and Imag complex
|
||||
accesor methods.
|
||||
accessor methods.
|
||||
|
||||
See the std_complex.i and ccomplex.i for concrete examples.
|
||||
*/
|
||||
|
||||
/*
|
||||
Ruby does not have native complex numbers. They are an extension in the
|
||||
STD library.
|
||||
*/
|
||||
%{
|
||||
static VALUE swig_rb_cComplex = Qnil;
|
||||
static ID swig_real_id = 0;
|
||||
static ID swig_imag_id = 0;
|
||||
|
||||
int Ruby_Is_Complex( VALUE obj )
|
||||
{
|
||||
return ( (rb_respond_to( obj, swig_real_id ) == Qtrue) &&
|
||||
(rb_respond_to( obj, swig_imag_id ) == Qtrue) );
|
||||
}
|
||||
%}
|
||||
|
||||
%init {
|
||||
rb_require("complex");
|
||||
swig_rb_cComplex = rb_const_get( rb_cObject, rb_intern("Complex") );
|
||||
if( swig_rb_cComplex == Qnil )
|
||||
rb_warn("Ruby's complex.so not found");
|
||||
swig_real_id = rb_intern("real");
|
||||
swig_imag_id = rb_intern("imag");
|
||||
%fragment("SWIG_Complex_Numbers","header")
|
||||
{
|
||||
%#if !defined(T_COMPLEX)
|
||||
/* Ruby versions prior to 1.9 did not have native complex numbers. They were an extension in the STD library. */
|
||||
VALUE rb_complex_new(VALUE x, VALUE y) {
|
||||
static ID new_id = rb_intern("new");
|
||||
static VALUE cComplex = rb_const_get(rb_cObject, rb_intern("Complex"));
|
||||
return rb_funcall(cComplex, new_id, 2, x, y);
|
||||
}
|
||||
|
||||
/* the common from conversor */
|
||||
static int SWIG_Is_Complex( VALUE obj ) {
|
||||
static ID real_id = rb_intern("real");
|
||||
static ID imag_id = rb_intern("imag");
|
||||
return ( (rb_respond_to( obj, real_id ) ) &&
|
||||
(rb_respond_to( obj, imag_id ) ) );
|
||||
}
|
||||
%#else
|
||||
static int SWIG_Is_Complex( VALUE obj ) {
|
||||
return TYPE(obj) == T_COMPLEX;
|
||||
}
|
||||
%#endif
|
||||
|
||||
VALUE SWIG_Complex_Real(VALUE obj) {
|
||||
static ID real_id = rb_intern("real");
|
||||
return rb_funcall(obj, real_id, 0);
|
||||
}
|
||||
|
||||
VALUE SWIG_Complex_Imaginary(VALUE obj) {
|
||||
static ID imag_id = rb_intern("imag");
|
||||
return rb_funcall(obj, imag_id, 0);
|
||||
}
|
||||
}
|
||||
|
||||
%init {
|
||||
%#if !defined(T_COMPLEX)
|
||||
rb_require("complex");
|
||||
%#endif
|
||||
}
|
||||
|
||||
/* the common from converter */
|
||||
%define %swig_fromcplx_conv(Type, Real, Imag)
|
||||
%fragment(SWIG_From_frag(Type),"header")
|
||||
{
|
||||
SWIGINTERNINLINE VALUE
|
||||
SWIG_From(Type)(%ifcplusplus(const Type&, Type) c)
|
||||
{
|
||||
VALUE args[] = {
|
||||
rb_float_new(Real(c)),
|
||||
rb_float_new(Imag(c))
|
||||
};
|
||||
return rb_class_new_instance(2, args, swig_rb_cComplex);
|
||||
VALUE re = rb_float_new(Real(c));
|
||||
VALUE im = rb_float_new(Imag(c));
|
||||
return rb_complex_new(re, im);
|
||||
}
|
||||
}
|
||||
%enddef
|
||||
|
|
@ -51,15 +63,16 @@ SWIG_From(Type)(%ifcplusplus(const Type&, Type) c)
|
|||
/* the double case */
|
||||
%define %swig_cplxdbl_conv(Type, Constructor, Real, Imag)
|
||||
%fragment(SWIG_AsVal_frag(Type),"header",
|
||||
fragment=SWIG_AsVal_frag(double))
|
||||
fragment=SWIG_AsVal_frag(double),
|
||||
fragment="SWIG_Complex_Numbers")
|
||||
{
|
||||
SWIGINTERN int
|
||||
SWIG_AsVal(Type) (VALUE o, Type* val)
|
||||
{
|
||||
if ( Ruby_Is_Complex( o ) ) {
|
||||
if ( SWIG_Is_Complex( o ) ) {
|
||||
if (val) {
|
||||
VALUE real = rb_funcall(o, swig_real_id, 0 );
|
||||
VALUE imag = rb_funcall(o, swig_imag_id, 0 );
|
||||
VALUE real = SWIG_Complex_Real(o);
|
||||
VALUE imag = SWIG_Complex_Imaginary(o);
|
||||
double re = 0;
|
||||
SWIG_AsVal_double( real, &re );
|
||||
double im = 0;
|
||||
|
|
@ -85,13 +98,14 @@ SWIG_AsVal(Type) (VALUE o, Type* val)
|
|||
%define %swig_cplxflt_conv(Type, Constructor, Real, Imag)
|
||||
%fragment(SWIG_AsVal_frag(Type),"header",
|
||||
fragment=SWIG_AsVal_frag(float),
|
||||
fragment=SWIG_AsVal_frag(double)) {
|
||||
fragment=SWIG_AsVal_frag(double),
|
||||
fragment="SWIG_Complex_Numbers") {
|
||||
SWIGINTERN int
|
||||
SWIG_AsVal(Type)(VALUE o, Type *val)
|
||||
{
|
||||
if ( Ruby_Is_Complex( o ) ) {
|
||||
VALUE real = rb_funcall(o, swig_real_id, 0 );
|
||||
VALUE imag = rb_funcall(o, swig_imag_id, 0 );
|
||||
if ( SWIG_Is_Complex( o ) ) {
|
||||
VALUE real = SWIG_Complex_Real(o);
|
||||
VALUE imag = SWIG_Complex_Imaginary(o);
|
||||
double re = 0;
|
||||
SWIG_AsVal_double( real, &re );
|
||||
double im = 0;
|
||||
|
|
|
|||
|
|
@ -677,27 +677,6 @@ namespace swig
|
|||
return r;
|
||||
}
|
||||
|
||||
%alias reject_bang "delete_if";
|
||||
Sequence* reject_bang() {
|
||||
if ( !rb_block_given_p() )
|
||||
rb_raise( rb_eArgError, "no block given" );
|
||||
|
||||
Sequence::iterator i = self->begin();
|
||||
Sequence::iterator e = self->end();
|
||||
for ( ; i != e; )
|
||||
{
|
||||
VALUE r = swig::from< Sequence::value_type >(*i);
|
||||
if ( RTEST( rb_yield(r) ) ) {
|
||||
$self->erase(i++);
|
||||
e = self->end();
|
||||
} else {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
VALUE delete_at(difference_type i) {
|
||||
VALUE r = Qnil;
|
||||
try {
|
||||
|
|
@ -757,6 +736,19 @@ namespace swig
|
|||
}
|
||||
%enddef
|
||||
|
||||
%define %swig_sequence_methods_extra(Sequence...)
|
||||
%extend {
|
||||
%alias reject_bang "delete_if";
|
||||
Sequence* reject_bang() {
|
||||
if ( !rb_block_given_p() )
|
||||
rb_raise( rb_eArgError, "no block given" );
|
||||
|
||||
$self->erase( std::remove_if( $self->begin(), $self->end(),
|
||||
swig::yield< Sequence::value_type >() ), $self->end() );
|
||||
return $self;
|
||||
}
|
||||
}
|
||||
%enddef
|
||||
|
||||
/**
|
||||
* Macro used to add functions for Sequences
|
||||
|
|
@ -764,6 +756,7 @@ namespace swig
|
|||
*/
|
||||
%define %swig_sequence_methods(Sequence...)
|
||||
%swig_sequence_methods_common(%arg(Sequence));
|
||||
%swig_sequence_methods_extra(%arg(Sequence));
|
||||
%swig_sequence_back_inserters(%arg(Sequence));
|
||||
|
||||
%extend {
|
||||
|
|
|
|||
|
|
@ -124,7 +124,6 @@
|
|||
%swig_container_extend( %arg( Container ), std::complex );
|
||||
%swig_container_extend( %arg( Container ), std::string );
|
||||
%swig_container_extend( %arg( Container ), swig::GC_VALUE );
|
||||
%swig_container_extend( %arg( Container ), swig::GC_VALUE );
|
||||
|
||||
%enddef
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
/* Runtime API */
|
||||
|
||||
#define SWIG_GetModule(clientdata) SWIG_Ruby_GetModule()
|
||||
#define SWIG_GetModule(clientdata) SWIG_Ruby_GetModule(clientdata)
|
||||
#define SWIG_SetModule(clientdata, pointer) SWIG_Ruby_SetModule(pointer)
|
||||
|
||||
|
||||
|
|
@ -371,7 +371,7 @@ SWIG_Ruby_ConvertPacked(VALUE obj, void *ptr, int sz, swig_type_info *ty) {
|
|||
}
|
||||
|
||||
SWIGRUNTIME swig_module_info *
|
||||
SWIG_Ruby_GetModule(void)
|
||||
SWIG_Ruby_GetModule(void *SWIGUNUSEDPARM(clientdata))
|
||||
{
|
||||
VALUE pointer;
|
||||
swig_module_info *ret = 0;
|
||||
|
|
@ -411,7 +411,7 @@ SWIG_Ruby_SetModule(swig_module_info *pointer)
|
|||
SWIGINTERN
|
||||
int SWIG_Ruby_isCallable( VALUE proc )
|
||||
{
|
||||
if ( rb_respond_to( proc, swig_call_id ) == Qtrue )
|
||||
if ( rb_respond_to( proc, swig_call_id ) )
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -424,7 +424,7 @@ int SWIG_Ruby_isCallable( VALUE proc )
|
|||
SWIGINTERN
|
||||
int SWIG_Ruby_arity( VALUE proc, int minimal )
|
||||
{
|
||||
if ( rb_respond_to( proc, swig_arity_id ) == Qtrue )
|
||||
if ( rb_respond_to( proc, swig_arity_id ) )
|
||||
{
|
||||
VALUE num = rb_funcall( proc, swig_arity_id, 0 );
|
||||
int arity = NUM2INT(num);
|
||||
|
|
|
|||
|
|
@ -7,11 +7,7 @@ SWIGINTERN int
|
|||
SWIG_AsCharPtrAndSize(VALUE obj, char** cptr, size_t* psize, int *alloc)
|
||||
{
|
||||
if (TYPE(obj) == T_STRING) {
|
||||
%#if defined(StringValuePtr)
|
||||
char *cstr = StringValuePtr(obj);
|
||||
%#else
|
||||
char *cstr = STR2CSTR(obj);
|
||||
%#endif
|
||||
size_t size = RSTRING_LEN(obj) + 1;
|
||||
if (cptr) {
|
||||
if (alloc) {
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue