Merge branch 'master' into gsoc2009-matevz

Conflicts:
	Examples/Makefile.in
	Examples/guile/Makefile.in
	Lib/php/php.swg
	Makefile.in
	Source/CParse/parser.y
	configure.ac
This commit is contained in:
William S Fulton 2013-10-10 07:26:09 +01:00
commit bcb7aee022
585 changed files with 9528 additions and 12959 deletions

View file

@ -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

View file

@ -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

View file

@ -153,7 +153,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)

View file

@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------------
* std_map.i
*
* SWIG typemaps for std::map< K, T >
* SWIG typemaps for std::map< K, T, C >
*
* The C# wrapper is made to look and feel like a C# System.Collections.Generic.IDictionary<>.
*
@ -26,10 +26,10 @@
%}
/* K is the C++ key type, T is the C++ value type */
%define SWIG_STD_MAP_INTERNAL(K, T)
%define SWIG_STD_MAP_INTERNAL(K, T, C)
%typemap(csinterfaces) std::map< K, T > "IDisposable \n#if !SWIG_DOTNET_1\n , System.Collections.Generic.IDictionary<$typemap(cstype, K), $typemap(cstype, T)>\n#endif\n";
%typemap(cscode) std::map<K, T > %{
%typemap(csinterfaces) std::map< K, T, C > "IDisposable \n#if !SWIG_DOTNET_1\n , System.Collections.Generic.IDictionary<$typemap(cstype, K), $typemap(cstype, T)>\n#endif\n";
%typemap(cscode) std::map<K, T, C > %{
public $typemap(cstype, T) this[$typemap(cstype, K) key] {
get {
@ -221,14 +221,14 @@
typedef T mapped_type;
map();
map(const map< K, T > &other);
map(const map< K, T, C > &other);
size_type size() const;
bool empty() const;
%rename(Clear) clear;
void clear();
%extend {
const mapped_type& getitem(const key_type& key) throw (std::out_of_range) {
std::map< K,T >::iterator iter = $self->find(key);
std::map< K, T, C >::iterator iter = $self->find(key);
if (iter != $self->end())
return iter->second;
else
@ -240,19 +240,19 @@
}
bool ContainsKey(const key_type& key) {
std::map< K, T >::iterator iter = $self->find(key);
std::map< K, T, C >::iterator iter = $self->find(key);
return iter != $self->end();
}
void Add(const key_type& key, const mapped_type& val) throw (std::out_of_range) {
std::map< K, T >::iterator iter = $self->find(key);
std::map< K, T, C >::iterator iter = $self->find(key);
if (iter != $self->end())
throw std::out_of_range("key already exists");
$self->insert(std::pair< K, T >(key, val));
}
bool Remove(const key_type& key) {
std::map< K, T >::iterator iter = $self->find(key);
std::map< K, T, C >::iterator iter = $self->find(key);
if (iter != $self->end()) {
$self->erase(iter);
return true;
@ -261,20 +261,20 @@
}
// create_iterator_begin(), get_next_key() and destroy_iterator work together to provide a collection of keys to C#
%apply void *VOID_INT_PTR { std::map< K, T >::iterator *create_iterator_begin }
%apply void *VOID_INT_PTR { std::map< K, T >::iterator *swigiterator }
%apply void *VOID_INT_PTR { std::map< K, T, C >::iterator *create_iterator_begin }
%apply void *VOID_INT_PTR { std::map< K, T, C >::iterator *swigiterator }
std::map< K, T >::iterator *create_iterator_begin() {
return new std::map< K, T >::iterator($self->begin());
std::map< K, T, C >::iterator *create_iterator_begin() {
return new std::map< K, T, C >::iterator($self->begin());
}
const key_type& get_next_key(std::map< K, T >::iterator *swigiterator) {
std::map< K, T >::iterator iter = *swigiterator;
const key_type& get_next_key(std::map< K, T, C >::iterator *swigiterator) {
std::map< K, T, C >::iterator iter = *swigiterator;
(*swigiterator)++;
return (*iter).first;
}
void destroy_iterator(std::map< K, T >::iterator *swigiterator) {
void destroy_iterator(std::map< K, T, C >::iterator *swigiterator) {
delete swigiterator;
}
}
@ -291,8 +291,8 @@
// Default implementation
namespace std {
template<class K, class T> class map {
SWIG_STD_MAP_INTERNAL(K, T)
template<class K, class T, class C = std::less<K> > class map {
SWIG_STD_MAP_INTERNAL(K, T, C)
};
}

View file

@ -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) \

View file

@ -446,7 +446,7 @@
%}
/* Typecheck typemaps. The purpose of these is merely to issue a
warning for overloaded C++ functions * that cannot be overloaded in
warning for overloaded C++ functions that cannot be overloaded in
Go as more than one C++ type maps to a single Go type. */
%typecheck(SWIG_TYPECHECK_BOOL) /* Go bool */

View file

@ -1,4 +1,4 @@
co::
co:
co RCS/*.i* RCS/*.swg*

View file

@ -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)) );
}

View file

@ -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

View file

@ -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);
%}

View file

@ -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(clientdata)
#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 *SWIGUNUSEDPARM(clientdata)) {
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 *SWIGUNUSEDPARM(clientdata));
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 */

View file

@ -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
%}

View file

@ -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
@ -61,15 +84,19 @@ 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
@ -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
@ -426,13 +451,12 @@ SWIG_Guile_GetModule(void *SWIGUNUSEDPARM(clientdata))
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;
}

View file

@ -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

View file

@ -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);
}
}

View file

@ -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>

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -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);
@ -37,7 +37,7 @@ namespace std {
}
%typemap(in) const string & ($*1_ltype temp, char *tempptr) {
if (gh_string_p($input)) {
if (scm_is_string($input)) {
tempptr = SWIG_scm2str($input);
temp.assign(tempptr);
if (tempptr) SWIG_free(tempptr);
@ -48,7 +48,7 @@ namespace std {
}
%typemap(in) string * (char *tempptr) {
if (gh_string_p($input)) {
if (scm_is_string($input)) {
tempptr = SWIG_scm2str($input);
$1 = new $*1_ltype(tempptr);
if (tempptr) SWIG_free(tempptr);
@ -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());
}
}

View file

@ -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);
}

View file

@ -68,14 +68,14 @@
%typemap(throws) SWIGTYPE {
$&ltype 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));
}
@ -86,14 +86,14 @@
}
%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));
}
@ -160,23 +160,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
@ -224,8 +224,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
@ -268,34 +268,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 */
@ -304,8 +304,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;
@ -313,7 +313,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;
@ -343,8 +343,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 */
@ -364,7 +364,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;
}
@ -420,7 +420,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)
@ -433,7 +433,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 {
@ -441,7 +441,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 &&, SWIGTYPE [] {

View file

@ -207,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);

View file

@ -52,7 +52,7 @@
%typemap(freearg) char **STRING_ARRAY {
int i;
for (i=0; i<size$argnum-1; i++)
for (i=0; i<size$argnum; i++)
#ifdef __cplusplus
delete[] $1[i];
delete[] $1;

View file

@ -71,6 +71,36 @@ extern "C" {
#endif
/* --------------------------------------------------------------------------
* Helper functions for error handling
* -------------------------------------------------------------------------- */
/* Push the string STR on the Lua stack, like lua_pushstring, but
prefixed with the the location of the innermost Lua call-point
(as formated by luaL_where). */
SWIGRUNTIME void
SWIG_Lua_pusherrstring (lua_State *L, const char *str)
{
luaL_where (L, 1);
lua_pushstring (L, str);
lua_concat (L, 2);
}
/* Push a formatted string generated from FMT and following args on
the Lua stack, like lua_pushfstring, but prefixed with the the
location of the innermost Lua call-point (as formated by luaL_where). */
SWIGRUNTIME void
SWIG_Lua_pushferrstring (lua_State *L, const char *fmt, ...)
{
va_list argp;
va_start(argp, fmt);
luaL_where(L, 1);
lua_pushvfstring(L, fmt, argp);
va_end(argp);
lua_concat(L, 2);
}
/* -----------------------------------------------------------------------------
* global swig types
* ----------------------------------------------------------------------------- */
@ -110,6 +140,15 @@ typedef struct {
lua_CFunction setmethod;
} swig_lua_attribute;
// Can be used to create namespaces. Currently used to
// wrap class static methods/variables/constants
typedef struct {
const char *name;
swig_lua_method *ns_methods;
swig_lua_attribute *ns_attributes;
swig_lua_const_info *ns_constants;
} swig_lua_namespace;
typedef struct swig_lua_class {
const char *name;
swig_type_info **type;
@ -117,6 +156,7 @@ typedef struct swig_lua_class {
void (*destructor)(void *);
swig_lua_method *methods;
swig_lua_attribute *attributes;
swig_lua_namespace cls_static;
struct swig_lua_class **bases;
const char **base_names;
} swig_lua_class;
@ -155,19 +195,20 @@ typedef struct {
/* Contract support */
#define SWIG_contract_assert(expr, msg) \
if (!(expr)) { lua_pushstring(L, (char *) msg); goto fail; } else
if (!(expr)) { SWIG_Lua_pusherrstring(L, (char *) msg); goto fail; } else
/* helper #defines */
#define SWIG_fail {goto fail;}
#define SWIG_fail_arg(func_name,argnum,type) \
{lua_pushfstring(L,"Error in %s (arg %d), expected '%s' got '%s'",\
{SWIG_Lua_pushferrstring(L,"Error in %s (arg %d), expected '%s' got '%s'",\
func_name,argnum,type,SWIG_Lua_typename(L,argnum));\
goto fail;}
#define SWIG_fail_ptr(func_name,argnum,type) \
SWIG_fail_arg(func_name,argnum,(type && type->str)?type->str:"void*")
#define SWIG_check_num_args(func_name,a,b) \
if (lua_gettop(L)<a || lua_gettop(L)>b) \
{lua_pushfstring(L,"Error in %s expected %d..%d args, got %d",func_name,a,b,lua_gettop(L));\
{SWIG_Lua_pushferrstring(L,"Error in %s expected %d..%d args, got %d",func_name,a,b,lua_gettop(L));\
goto fail;}
@ -220,8 +261,7 @@ SWIGINTERN int SWIG_Lua_set_immutable(lua_State* L)
/* there should be 1 param passed in: the new value */
#ifndef SWIGLUA_IGNORE_SET_IMMUTABLE
lua_pop(L,1); /* remove it */
lua_pushstring(L,"This variable is immutable");
lua_error(L);
luaL_error(L,"This variable is immutable");
#endif
return 0; /* should not return anything */
}
@ -385,6 +425,137 @@ SWIGINTERN void SWIG_Lua_module_add_function(lua_State* L,const char* name,lua_
SWIG_Lua_add_function(L,name,fn);
}
/* -----------------------------------------------------------------------------
* global variable support code: namespaces
* ----------------------------------------------------------------------------- */
SWIGINTERN int SWIG_Lua_namespace_get(lua_State* L)
{
/* there should be 2 params passed in
(1) table (not the meta table)
(2) string name of the attribute
*/
assert(lua_istable(L,-2)); /* just in case */
lua_getmetatable(L,-2);
assert(lua_istable(L,-1));
SWIG_Lua_get_table(L,".get"); /* find the .get table */
assert(lua_istable(L,-1));
/* look for the key in the .get table */
lua_pushvalue(L,2); /* key */
lua_rawget(L,-2);
lua_remove(L,-2); /* stack tidy, remove .get table */
if (lua_iscfunction(L,-1))
{ /* found it so call the fn & return its value */
lua_call(L,0,1); /* 1 value in (userdata),1 out (result) */
lua_remove(L,-2); /* stack tidy, remove metatable */
return 1;
}
lua_pop(L,1); /* remove whatever was there */
/* ok, so try the .fn table */
SWIG_Lua_get_table(L,".fn"); /* find the .get table */
assert(lua_istable(L,-1)); /* just in case */
lua_pushvalue(L,2); /* key */
lua_rawget(L,-2); /* look for the fn */
lua_remove(L,-2); /* stack tidy, remove .fn table */
if (lua_isfunction(L,-1)) /* note: whether it's a C function or lua function */
{ /* found it so return the fn & let lua call it */
lua_remove(L,-2); /* stack tidy, remove metatable */
return 1;
}
lua_pop(L,1); /* remove whatever was there */
return 0;
}
SWIGINTERN int SWIG_Lua_namespace_set(lua_State* L)
{
/* there should be 3 params passed in
(1) table (not the meta table)
(2) string name of the attribute
(3) any for the new value
*/
assert(lua_istable(L,1));
lua_getmetatable(L,1); /* get the meta table */
assert(lua_istable(L,-1));
SWIG_Lua_get_table(L,".set"); /* find the .set table */
if (lua_istable(L,-1))
{
/* look for the key in the .set table */
lua_pushvalue(L,2); /* key */
lua_rawget(L,-2);
if (lua_iscfunction(L,-1))
{ /* found it so call the fn & return its value */
lua_pushvalue(L,3); /* value */
lua_call(L,1,0);
return 0;
}
lua_pop(L,1); /* remove the value */
}
lua_pop(L,1); /* remove the value .set table */
return 0;
}
SWIGINTERN void SWIG_Lua_InstallConstants(lua_State* L, swig_lua_const_info constants[]); // forward declaration
SWIGINTERN void SWIG_Lua_add_class_variable(lua_State* L,const char* name,lua_CFunction getFn,lua_CFunction setFn); // forward declaration
/* helper function - register namespace methods and attributes into namespace */
SWIGINTERN int SWIG_Lua_add_namespace_details(lua_State* L, swig_lua_namespace* ns)
{
int i = 0;
assert(lua_istable(L,-1));
/* There must be table at the top of the stack */
SWIG_Lua_InstallConstants(L, ns->ns_constants);
lua_getmetatable(L,-1);
/* add fns */
for(i=0;ns->ns_attributes[i].name;i++){
SWIG_Lua_add_class_variable(L,ns->ns_attributes[i].name,ns->ns_attributes[i].getmethod,ns->ns_attributes[i].setmethod);
}
/* add methods to the metatable */
SWIG_Lua_get_table(L,".fn"); /* find the .fn table */
assert(lua_istable(L,-1)); /* just in case */
for(i=0;ns->ns_methods[i].name;i++){
SWIG_Lua_add_function(L,ns->ns_methods[i].name,ns->ns_methods[i].method);
}
lua_pop(L,1);
/* clear stack - remove metatble */
lua_pop(L,1);
}
/* helper function. creates namespace table and add it to module table */
SWIGINTERN int SWIG_Lua_namespace_register(lua_State* L, swig_lua_namespace* ns)
{
assert(lua_istable(L,-1)); /* just in case. This is supposed to be module table */
lua_checkstack(L,5);
lua_pushstring(L, ns->name);
lua_newtable(L); /* namespace itself */
lua_newtable(L); /* metatable for namespace */
/* add a table called ".get" */
lua_pushstring(L,".get");
lua_newtable(L);
lua_rawset(L,-3);
/* add a table called ".set" */
lua_pushstring(L,".set");
lua_newtable(L);
lua_rawset(L,-3);
/* add a table called ".fn" */
lua_pushstring(L,".fn");
lua_newtable(L);
lua_rawset(L,-3);
/* add accessor fns for using the .get,.set&.fn */
SWIG_Lua_add_function(L,"__index",SWIG_Lua_namespace_get);
SWIG_Lua_add_function(L,"__newindex",SWIG_Lua_namespace_set);
lua_setmetatable(L,-2); /* set metatable */
lua_rawset(L,-3); /* add namespace to module table */
}
/* -----------------------------------------------------------------------------
* global variable support code: classes
* ----------------------------------------------------------------------------- */
@ -540,6 +711,23 @@ SWIGINTERN int SWIG_Lua_class_disown(lua_State* L)
return 0;
}
/* Constructor proxy. Used when class name entry in module is not class constructor,
but special table instead. */
SWIGINTERN int SWIG_Lua_constructor_proxy(lua_State* L)
{
/* unlimited number of parameters
First one is our proxy table and we should remove it
Other we should pass to real constructor
*/
assert(lua_istable(L,1));
lua_pushstring(L,".constructor");
lua_rawget(L,1);
assert(!lua_isnil(L,-1));
lua_replace(L,1); /* replace our table with real constructor */
lua_call(L,lua_gettop(L)-1,1);
return 1;
}
/* gets the swig class registry (or creates it) */
SWIGINTERN void SWIG_Lua_get_class_registry(lua_State* L)
{
@ -584,6 +772,21 @@ SWIGINTERN void SWIG_Lua_add_class_variable(lua_State* L,const char* name,lua_C
}
}
/* helper to recursively add class static details (static attributes, operations and constants) */
SWIGINTERN void SWIG_Lua_add_class_static_details(lua_State* L, swig_lua_class* clss)
{
int i = 0;
/* The class namespace table must be on the top of the stack */
assert(lua_istable(L,-1));
/* call all the base classes first: we can then override these later: */
for(i=0;clss->bases[i];i++)
{
SWIG_Lua_add_class_static_details(L,clss->bases[i]);
}
SWIG_Lua_add_namespace_details(L, &clss->cls_static);
}
/* helper to recursively add class details (attributes & operations) */
SWIGINTERN void SWIG_Lua_add_class_details(lua_State* L,swig_lua_class* clss)
{
@ -637,15 +840,42 @@ SWIGINTERN void SWIG_Lua_init_base_class(lua_State* L,swig_lua_class* clss)
}
}
/* performs the entire class registration process */
SWIGINTERN void SWIG_Lua_class_register(lua_State* L,swig_lua_class* clss)
/* Register class static methods,attributes etc as well as constructor proxy */
SWIGINTERN void SWIG_Lua_class_register_static(lua_State* L, swig_lua_class* clss)
{
lua_checkstack(L,5); /* just in case */
assert(lua_istable(L,-1)); /* just in case */
assert(strcmp(clss->name, clss->cls_static.name) == 0); /* in class those 2 must be equal */
SWIG_Lua_namespace_register(L,&clss->cls_static);
SWIG_Lua_get_table(L,clss->name); // Get namespace table back
assert(lua_istable(L,-1)); /* just in case */
/* add its constructor to module with the name of the class
so you can do MyClass(...) as well as new_MyClass(...)
BUT only if a constructor is defined
(this overcomes the problem of pure virtual classes without constructors)*/
if (clss->constructor)
SWIG_Lua_add_function(L,clss->name,clss->constructor);
{
SWIG_Lua_add_function(L,".constructor", clss->constructor);
lua_getmetatable(L,-1);
assert(lua_istable(L,-1)); /* just in case */
SWIG_Lua_add_function(L,"__call", SWIG_Lua_constructor_proxy);
lua_pop(L,1);
}
assert(lua_istable(L,-1)); /* just in case */
SWIG_Lua_add_class_static_details(L, clss);
/* clear stack */
lua_pop(L,1);
}
/* performs the entire class registration process */
SWIGINTERN void SWIG_Lua_class_register(lua_State* L,swig_lua_class* clss)
{
SWIG_Lua_class_register_static(L,clss);
SWIG_Lua_get_class_registry(L); /* get the registry */
lua_pushstring(L,clss->name); /* get the name */
@ -756,9 +986,8 @@ SWIGRUNTIME void* SWIG_Lua_MustGetPtr(lua_State* L,int index,swig_type_info *typ
int argnum,const char* func_name){
void* result;
if (!SWIG_IsOK(SWIG_ConvertPtr(L,index,&result,type,flags))){
lua_pushfstring(L,"Error in %s, expected a %s at argument number %d\n",
func_name,(type && type->str)?type->str:"void*",argnum);
lua_error(L);
luaL_error (L,"Error in %s, expected a %s at argument number %d\n",
func_name,(type && type->str)?type->str:"void*",argnum);
}
return result;
}

View file

@ -250,12 +250,12 @@ SWIGINTERN int SWIG_table_size(lua_State* L, int index)
SWIGINTERN TYPE* SWIG_get_##NAME##_num_array_fixed(lua_State* L, int index, int size){\
TYPE *array;\
if (!lua_istable(L,index) || SWIG_itable_size(L,index) != size) {\
lua_pushfstring(L,"expected a table of size %d",size);\
SWIG_Lua_pushferrstring(L,"expected a table of size %d",size);\
return 0;\
}\
array=SWIG_ALLOC_ARRAY(TYPE,size);\
if (!SWIG_read_##NAME##_num_array(L,index,array,size)){\
lua_pushstring(L,"table must contain numbers");\
SWIG_Lua_pusherrstring(L,"table must contain numbers");\
SWIG_FREE_ARRAY(array);\
return 0;\
}\
@ -265,17 +265,17 @@ SWIGINTERN int SWIG_table_size(lua_State* L, int index)
{\
TYPE *array;\
if (!lua_istable(L,index)) {\
lua_pushstring(L,"expected a table");\
SWIG_Lua_pusherrstring(L,"expected a table");\
return 0;\
}\
*size=SWIG_itable_size(L,index);\
if (*size<1){\
lua_pushstring(L,"table appears to be empty");\
SWIG_Lua_pusherrstring(L,"table appears to be empty");\
return 0;\
}\
array=SWIG_ALLOC_ARRAY(TYPE,*size);\
if (!SWIG_read_##NAME##_num_array(L,index,array,*size)){\
lua_pushstring(L,"table must contain numbers");\
SWIG_Lua_pusherrstring(L,"table must contain numbers");\
SWIG_FREE_ARRAY(array);\
return 0;\
}\
@ -451,12 +451,12 @@ SWIGINTERN int SWIG_read_ptr_array(lua_State* L,int index,void **array,int size,
SWIGINTERN void** SWIG_get_ptr_array_fixed(lua_State* L, int index, int size,swig_type_info *type){
void **array;
if (!lua_istable(L,index) || SWIG_itable_size(L,index) != size) {
lua_pushfstring(L,"expected a table of size %d",size);
SWIG_Lua_pushferrstring(L,"expected a table of size %d",size);
return 0;
}
array=SWIG_ALLOC_ARRAY(void*,size);
if (!SWIG_read_ptr_array(L,index,array,size,type)){
lua_pushfstring(L,"table must contain pointers of type %s",type->name);
SWIG_Lua_pushferrstring(L,"table must contain pointers of type %s",type->name);
SWIG_FREE_ARRAY(array);
return 0;
}
@ -465,17 +465,17 @@ SWIGINTERN void** SWIG_get_ptr_array_fixed(lua_State* L, int index, int size,swi
SWIGINTERN void** SWIG_get_ptr_array_var(lua_State* L, int index, int* size,swig_type_info *type){
void **array;
if (!lua_istable(L,index)) {
lua_pushstring(L,"expected a table");
SWIG_Lua_pusherrstring(L,"expected a table");
return 0;
}
*size=SWIG_itable_size(L,index);
if (*size<1){
lua_pushstring(L,"table appears to be empty");
SWIG_Lua_pusherrstring(L,"table appears to be empty");
return 0;
}
array=SWIG_ALLOC_ARRAY(void*,*size);
if (!SWIG_read_ptr_array(L,index,array,*size,type)){
lua_pushfstring(L,"table must contain pointers of type %s",type->name);
SWIG_Lua_pushferrstring(L,"table must contain pointers of type %s",type->name);
SWIG_FREE_ARRAY(array);
return 0;
}

View file

@ -31,7 +31,7 @@ wchar_t* str2wstr(const char *str, int len)
%typemap(in, checkfn="SWIG_lua_isnilstring", fragment="SWIG_lua_isnilstring") wchar_t *
%{
$1 = str2wstr(lua_tostring( L, $input ),lua_rawlen( L, $input ));
if ($1==0) {lua_pushfstring(L,"Error in converting to wchar (arg %d)",$input);goto fail;}
if ($1==0) {SWIG_Lua_pushferrstring(L,"Error in converting to wchar (arg %d)",$input);goto fail;}
%}
%typemap(freearg) wchar_t *

View file

@ -1,4 +1,4 @@
co::
co:
co RCS/*.i* RCS/*.swg*

View file

@ -287,7 +287,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;
//}

View file

@ -1280,7 +1280,7 @@ SWIGRUNTIME int SWIG_Octave_ConvertPacked(const octave_value &ov, void *ptr, siz
return ost->copy(type, (char *) ptr, sz) ? SWIG_OK : SWIG_ERROR;
}
void SWIG_Octave_SetConstant(octave_swig_type *module_ns, const std::string &name, const octave_value &ov) {
SWIGRUNTIMEINLINE void SWIG_Octave_SetConstant(octave_swig_type *module_ns, const std::string &name, const octave_value &ov) {
module_ns->assign(name, ov);
}
@ -1289,16 +1289,7 @@ SWIGRUNTIMEINLINE octave_value SWIG_Octave_GetGlobalValue(std::string name) {
}
SWIGRUNTIME void SWIG_Octave_SetGlobalValue(std::string name, const octave_value& value) {
// It is critical that a newly-allocated octave_value is passed to set_global_value(),
// since it and the Octave symbol table take references to the values assigned to it.
// If we were to pass a reference to 'value' to set_global_value(), then the Octave
// symbol table would hold a reference to a variable owned by the SWIG .oct module.
// Both will think that they own the reference (since the .oct module is dynamically
// loaded, it appears to have its own C++ runtime), and so they will both try to
// de-allocate the octave_value on exit, resulting in a double-free or seg-fault.
// This is prevented by giving Octave its own heap-allocated copy of 'value'.
octave_value *pov = new octave_value(value);
set_global_value(name, *pov);
set_global_value(name, value);
}
SWIGRUNTIME void SWIG_Octave_LinkGlobalValue(std::string name) {

View file

@ -288,6 +288,15 @@ DEFUN_DLD( SWIG_name, args, nargout, SWIG_name_usage ) {
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
@ -296,16 +305,9 @@ DEFUN_DLD( SWIG_name, args, nargout, SWIG_name_usage ) {
}
octave_function *me = octave_call_stack::current();
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();
}
}
else if (mb->second.second.is_defined()) {
if (mb->second.second.is_defined()) {
SWIG_Octave_SetGlobalValue(mb->first, mb->second.second);
SWIG_Octave_LinkGlobalValue(mb->first);
}

View file

@ -2,73 +2,9 @@
%include <octcontainer.swg>
%fragment("StdMapTraits","header",fragment="StdSequenceTraits")
%fragment("StdMapCommonTraits","header",fragment="StdSequenceTraits")
{
namespace swig {
template <class OctSeq, class K, class T >
inline void
assign(const OctSeq& octseq, std::map<K,T > *map) {
typedef typename std::map<K,T>::value_type value_type;
typename OctSeq::const_iterator it = octseq.begin();
for (;it != octseq.end(); ++it) {
map->insert(value_type(it->first, it->second));
}
}
template <class K, class T>
struct traits_asptr<std::map<K,T> > {
typedef std::map<K,T> map_type;
static int asptr(octave_value obj, map_type **val) {
/*
int res = SWIG_ERROR;
if (PyDict_Check(obj)) {
SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL);
res = traits_asptr_stdseq<std::map<K,T>, std::pair<K, T> >::asptr(items, val);
} else {
map_type *p;
res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<map_type>(),0);
if (SWIG_IsOK(res) && val) *val = p;
}
return res;
*/
return SWIG_ERROR;
}
};
template <class K, class T >
struct traits_from<std::map<K,T> > {
typedef std::map<K,T> map_type;
typedef typename map_type::const_iterator const_iterator;
typedef typename map_type::size_type size_type;
static octave_value from(const map_type& map) {
/*
swig_type_info *desc = swig::type_info<map_type>();
if (desc && desc->clientdata) {
return SWIG_NewPointerObj(new map_type(map), desc, SWIG_POINTER_OWN);
} else {
size_type size = map.size();
int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1;
if (pysize < 0) {
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
PyErr_SetString(PyExc_OverflowError,
"map size not valid in python");
SWIG_PYTHON_THREAD_END_BLOCK;
return NULL;
}
PyObject *obj = PyDict_New();
for (const_iterator i= map.begin(); i!= map.end(); ++i) {
swig::SwigVar_PyObject key = swig::from(i->first);
swig::SwigVar_PyObject val = swig::from(i->second);
PyDict_SetItem(obj, key, val);
}
return obj;
}
*/
return octave_value();
}
};
template <class ValueType>
struct from_key_oper
{
@ -138,6 +74,75 @@
}
}
%fragment("StdMapTraits","header",fragment="StdMapCommonTraits")
{
namespace swig {
template <class OctSeq, class K, class T >
inline void
assign(const OctSeq& octseq, std::map<K,T > *map) {
typedef typename std::map<K,T>::value_type value_type;
typename OctSeq::const_iterator it = octseq.begin();
for (;it != octseq.end(); ++it) {
map->insert(value_type(it->first, it->second));
}
}
template <class K, class T>
struct traits_asptr<std::map<K,T> > {
typedef std::map<K,T> map_type;
static int asptr(octave_value obj, map_type **val) {
/*
int res = SWIG_ERROR;
if (PyDict_Check(obj)) {
SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL);
res = traits_asptr_stdseq<std::map<K,T>, std::pair<K, T> >::asptr(items, val);
} else {
map_type *p;
res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<map_type>(),0);
if (SWIG_IsOK(res) && val) *val = p;
}
return res;
*/
return SWIG_ERROR;
}
};
template <class K, class T >
struct traits_from<std::map<K,T> > {
typedef std::map<K,T> map_type;
typedef typename map_type::const_iterator const_iterator;
typedef typename map_type::size_type size_type;
static octave_value from(const map_type& map) {
/*
swig_type_info *desc = swig::type_info<map_type>();
if (desc && desc->clientdata) {
return SWIG_NewPointerObj(new map_type(map), desc, SWIG_POINTER_OWN);
} else {
size_type size = map.size();
int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1;
if (pysize < 0) {
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
PyErr_SetString(PyExc_OverflowError,
"map size not valid in python");
SWIG_PYTHON_THREAD_END_BLOCK;
return NULL;
}
PyObject *obj = PyDict_New();
for (const_iterator i= map.begin(); i!= map.end(); ++i) {
swig::SwigVar_PyObject key = swig::from(i->first);
swig::SwigVar_PyObject val = swig::from(i->second);
PyDict_SetItem(obj, key, val);
}
return obj;
}
*/
return octave_value();
}
};
}
}
%define %swig_map_common(Map...)
%swig_sequence_iterator(Map);
%swig_container_methods(Map);

View file

@ -47,7 +47,7 @@ SWIGOPT = -perl5
SWIGCC = $(CC)
# SWIG Library files. Uncomment this to staticly rebuild Perl
#SWIGLIB = -static -lperlmain.i
#SWIGLIBS = -static -lperlmain.i
# Rules for creating .o files from source.
@ -69,33 +69,21 @@ BUILD = @LDSHARED@
#DLL_LIBS = -L/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.7.2 \
-L/usr/local/lib -lg++ -lstdc++ -lgcc
# X11 installation (possibly needed if using Perl-Tk)
XLIB = @XLIBSW@
XINCLUDE = @XINCLUDES@
# Perl installation
PERL_INCLUDE = -I@PERL5EXT@
PERL_LIB = -L@PERL5EXT@ -lperl
PERL_FLAGS = -Dbool=char -Dexplicit=
# Tcl installation. If using Tk you might need this
TCL_INCLUDE = @TCLINCLUDE@
TCL_LIB = @TCLLIB@
# Build libraries (needed for static builds)
LIBM = @LIBM@
LIBC = @LIBC@
SYSLIBS = $(LIBM) $(LIBC) @LIBS@
# Build options (uncomment only one these)
# Build options
#TK_LIB = $(TCL_LIB) -ltcl -ltk $(XLIB)
BUILD_LIBS = $(LIBS) # Dynamic loading
#BUILD_LIBS = $(PERL_LIB) $(TK_LIB) $(LIBS) $(SYSLIBS) # Static linking
# Compilation rules for non-SWIG components
@ -123,7 +111,7 @@ $(WRAPOBJ) : $(WRAPFILE)
$(SWIGCC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(PERL_INCLUDE) $(PERL_FLAGS) $(WRAPFILE)
$(WRAPFILE) : $(INTERFACE)
$(SWIG) $(SWIGOPT) -o $(WRAPFILE) $(SWIGLIB) $(INTERFACE)
$(SWIG) $(SWIGOPT) -o $(WRAPFILE) $(SWIGLIBS) $(INTERFACE)
$(TARGET): $(WRAPOBJ) $(ALLOBJS)
$(BUILD) $(WRAPOBJ) $(ALLOBJS) $(BUILD_LIBS) -o $(TARGET)

View file

@ -295,6 +295,15 @@
ZVAL_LONG($input, (long)$1_name);
}
%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);

View file

@ -209,11 +209,11 @@ SWIG_ZTS_ConvertResourcePtr(zval *z, swig_type_info *ty, int flags TSRMLS_DC) {
const char *type_name;
value = (swig_object_wrapper *) zend_list_find(z->value.lval, &type);
if ( flags & SWIG_POINTER_DISOWN ) {
if (type==-1) return NULL;
if (flags & SWIG_POINTER_DISOWN) {
value->newobject = 0;
}
p = value->ptr;
if (type==-1) return NULL;
type_name=zend_rsrc_list_get_rsrc_type(z->value.lval TSRMLS_CC);

View file

@ -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

View file

@ -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 {

View file

@ -47,7 +47,7 @@ SWIGOPT = -python
SWIGCC = $(CC)
# SWIG Library files. Uncomment if rebuilding the Python interpreter
#SWIGLIB = -lembed.i
#SWIGLIBS = -lembed.i
# Rules for creating .o files from source.
@ -69,32 +69,20 @@ BUILD = @LDSHARED@
#DLL_LIBS = -L/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.7.2 \
-L/usr/local/lib -lg++ -lstdc++ -lgcc
# X11 installation (needed if rebuilding Python + tkinter)
XLIB = @XLIBSW@
XINCLUDE = @XINCLUDES@
# Python installation
PY_INCLUDE = -DHAVE_CONFIG_H @PYINCLUDE@
PY_LIB = @PYLIB@
# Tcl installation. Needed if rebuilding Python with tkinter.
TCL_INCLUDE = @TCLINCLUDE@
TCL_LIB = @TCLLIB@
# Build libraries (needed for static builds)
LIBM = @LIBM@
LIBC = @LIBC@
SYSLIBS = $(LIBM) $(LIBC) @LIBS@
# Build options (uncomment only one these)
# Build options
#TKINTER = $(TCL_LIB) -ltk -ltcl $(XLIB)
BUILD_LIBS = $(LIBS) # Dynamic loading
#BUILD_LIBS = $(PY_LIB) @PYLINK@ $(TKINTER) $(LIBS) $(SYSLIBS)
# Compilation rules for non-SWIG components
@ -122,7 +110,7 @@ $(WRAPOBJ) : $(WRAPFILE)
$(SWIGCC) -c $(CCSHARED) $(CFLAGS) $(WRAPFILE) $(INCLUDES) $(PY_INCLUDE)
$(WRAPFILE) : $(INTERFACE)
$(SWIG) $(SWIGOPT) -o $(WRAPFILE) $(SWIGLIB) $(INTERFACE)
$(SWIG) $(SWIGOPT) -o $(WRAPFILE) $(SWIGLIBS) $(INTERFACE)
$(TARGET): $(WRAPOBJ) $(ALLOBJS)
$(BUILD) $(WRAPOBJ) $(ALLOBJS) $(BUILD_LIBS) -o $(TARGET)

View file

@ -13,7 +13,11 @@ wrapper##_closure(PyObject *a) { \
PyObject *o = wrapper(a, NULL); \
Py_XDECREF(o); \
} \
PyObject_Del(a); \
if (PyType_IS_GC(a->ob_type)) { \
PyObject_GC_Del(a); \
} else { \
PyObject_Del(a); \
} \
}
#define SWIGPY_INQUIRY_CLOSURE(wrapper) \

View file

@ -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

View file

@ -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--;
}

View file

@ -67,10 +67,8 @@
#define PySwigObject_next SwigPyObject_next
#define PySwigObject_oct SwigPyObject_oct
#define PySwigObject_own SwigPyObject_own
#define PySwigObject_print SwigPyObject_print
#define PySwigObject_repr SwigPyObject_repr
#define PySwigObject_richcompare SwigPyObject_richcompare
#define PySwigObject_str SwigPyObject_str
#define PySwigObject_type SwigPyObject_type
#define PySwigPacked SwigPyPacked
#define PySwigPacked_Check SwigPyPacked_Check

View file

@ -127,6 +127,18 @@ SWIG_AsVal_dec(unsigned long)(PyObject *obj, unsigned long *val)
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

View file

@ -448,34 +448,6 @@ SwigPyObject_repr(SwigPyObject *v, PyObject *args)
return repr;
}
SWIGRUNTIME int
SwigPyObject_print(SwigPyObject *v, FILE *fp, int SWIGUNUSEDPARM(flags))
{
char *str;
#ifdef METH_NOARGS
PyObject *repr = SwigPyObject_repr(v);
#else
PyObject *repr = SwigPyObject_repr(v, NULL);
#endif
if (repr) {
str = SWIG_Python_str_AsChar(repr);
fputs(str, fp);
SWIG_Python_str_DelForPy3(str);
Py_DECREF(repr);
return 0;
} else {
return 1;
}
}
SWIGRUNTIME PyObject *
SwigPyObject_str(SwigPyObject *v)
{
char result[SWIG_BUFFER_SIZE];
return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ?
SWIG_Python_str_FromChar(result) : 0;
}
SWIGRUNTIME int
SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w)
{
@ -668,7 +640,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"},
@ -761,7 +733,7 @@ SwigPyObject_TypeOnce(void) {
sizeof(SwigPyObject), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)SwigPyObject_dealloc, /* tp_dealloc */
(printfunc)SwigPyObject_print, /* tp_print */
0, /* tp_print */
#if PY_VERSION_HEX < 0x02020000
(getattrfunc)SwigPyObject_getattr, /* tp_getattr */
#else
@ -779,7 +751,7 @@ SwigPyObject_TypeOnce(void) {
0, /* tp_as_mapping */
(hashfunc)0, /* tp_hash */
(ternaryfunc)0, /* tp_call */
(reprfunc)SwigPyObject_str, /* tp_str */
0, /* tp_str */
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
@ -1156,10 +1128,11 @@ SWIGRUNTIME int
SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) {
int res;
SwigPyObject *sobj;
int implicit_conv = (flags & SWIG_POINTER_IMPLICIT_CONV) != 0;
if (!obj)
return SWIG_ERROR;
if (obj == Py_None) {
if (obj == Py_None && !implicit_conv) {
if (ptr)
*ptr = 0;
return SWIG_OK;
@ -1208,7 +1181,7 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
}
res = SWIG_OK;
} else {
if (flags & SWIG_POINTER_IMPLICIT_CONV) {
if (implicit_conv) {
SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0;
if (data && !data->implicitconv) {
PyObject *klass = data->klass;
@ -1243,6 +1216,13 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
}
}
}
if (!SWIG_IsOK(res) && obj == Py_None) {
if (ptr)
*ptr = 0;
if (PyErr_Occurred())
PyErr_Clear();
res = SWIG_OK;
}
}
return res;
}
@ -1742,7 +1722,7 @@ SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) {
PyObject *descr;
PyObject *encoded_name;
descrsetfunc f;
int res;
int res = -1;
# ifdef Py_USING_UNICODE
if (PyString_Check(name)) {
@ -1765,7 +1745,6 @@ SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) {
goto done;
}
res = -1;
descr = _PyType_Lookup(tp, name);
f = NULL;
if (descr != NULL)

View file

@ -1,6 +1,12 @@
%insert(runtime) %{
/* Python.h has to appear first */
#include <Python.h>
#if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG)
/* Use debug wrappers with the Python release dll */
# undef _DEBUG
# include <Python.h>
# define _DEBUG
#else
# include <Python.h>
#endif
%}
%insert(runtime) "swigrun.swg"; /* SWIG API */
@ -13,4 +19,4 @@
#if defined(SWIGPYTHON_BUILTIN)
%insert(runtime) "builtin.swg"; /* Specialization for classes with single inheritance */
#endif
#endif

View file

@ -7,6 +7,7 @@
/* shadow code */
#define %shadow %insert("shadow")
#define %pythoncode %insert("python")
#define %pythonbegin %insert("pythonbegin")
/* ------------------------------------------------------------------------- */

View file

@ -18,9 +18,7 @@ SWIG_AsWCharPtrAndSize(PyObject *obj, wchar_t **cptr, size_t *psize, int *alloc)
int isunicode = PyUnicode_Check(obj);
%#if PY_VERSION_HEX < 0x03000000
if (!isunicode && PyString_Check(obj)) {
if (cptr) {
obj = tmp = PyUnicode_FromObject(obj);
}
obj = tmp = PyUnicode_FromObject(obj);
isunicode = 1;
}
%#endif

View file

@ -2,7 +2,79 @@
Maps
*/
%fragment("StdMapTraits","header",fragment="StdSequenceTraits")
%fragment("StdMapCommonTraits","header",fragment="StdSequenceTraits")
{
namespace swig {
template <class ValueType>
struct from_key_oper
{
typedef const ValueType& argument_type;
typedef PyObject *result_type;
result_type operator()(argument_type v) const
{
return swig::from(v.first);
}
};
template <class ValueType>
struct from_value_oper
{
typedef const ValueType& argument_type;
typedef PyObject *result_type;
result_type operator()(argument_type v) const
{
return swig::from(v.second);
}
};
template<class OutIterator, class FromOper, class ValueType = typename OutIterator::value_type>
struct SwigPyMapIterator_T : SwigPyIteratorClosed_T<OutIterator, ValueType, FromOper>
{
SwigPyMapIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
: SwigPyIteratorClosed_T<OutIterator,ValueType,FromOper>(curr, first, last, seq)
{
}
};
template<class OutIterator,
class FromOper = from_key_oper<typename OutIterator::value_type> >
struct SwigPyMapKeyIterator_T : SwigPyMapIterator_T<OutIterator, FromOper>
{
SwigPyMapKeyIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
: SwigPyMapIterator_T<OutIterator, FromOper>(curr, first, last, seq)
{
}
};
template<typename OutIter>
inline SwigPyIterator*
make_output_key_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0)
{
return new SwigPyMapKeyIterator_T<OutIter>(current, begin, end, seq);
}
template<class OutIterator,
class FromOper = from_value_oper<typename OutIterator::value_type> >
struct SwigPyMapValueITerator_T : SwigPyMapIterator_T<OutIterator, FromOper>
{
SwigPyMapValueITerator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
: SwigPyMapIterator_T<OutIterator, FromOper>(curr, first, last, seq)
{
}
};
template<typename OutIter>
inline SwigPyIterator*
make_output_value_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0)
{
return new SwigPyMapValueITerator_T<OutIter>(current, begin, end, seq);
}
}
}
%fragment("StdMapTraits","header",fragment="StdMapCommonTraits")
{
namespace swig {
template <class SwigPySeq, class K, class T, class Compare, class Alloc >
@ -73,74 +145,6 @@
}
}
};
template <class ValueType>
struct from_key_oper
{
typedef const ValueType& argument_type;
typedef PyObject *result_type;
result_type operator()(argument_type v) const
{
return swig::from(v.first);
}
};
template <class ValueType>
struct from_value_oper
{
typedef const ValueType& argument_type;
typedef PyObject *result_type;
result_type operator()(argument_type v) const
{
return swig::from(v.second);
}
};
template<class OutIterator, class FromOper, class ValueType = typename OutIterator::value_type>
struct SwigPyMapIterator_T : SwigPyIteratorClosed_T<OutIterator, ValueType, FromOper>
{
SwigPyMapIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
: SwigPyIteratorClosed_T<OutIterator,ValueType,FromOper>(curr, first, last, seq)
{
}
};
template<class OutIterator,
class FromOper = from_key_oper<typename OutIterator::value_type> >
struct SwigPyMapKeyIterator_T : SwigPyMapIterator_T<OutIterator, FromOper>
{
SwigPyMapKeyIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
: SwigPyMapIterator_T<OutIterator, FromOper>(curr, first, last, seq)
{
}
};
template<typename OutIter>
inline SwigPyIterator*
make_output_key_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0)
{
return new SwigPyMapKeyIterator_T<OutIter>(current, begin, end, seq);
}
template<class OutIterator,
class FromOper = from_value_oper<typename OutIterator::value_type> >
struct SwigPyMapValueITerator_T : SwigPyMapIterator_T<OutIterator, FromOper>
{
SwigPyMapValueITerator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
: SwigPyMapIterator_T<OutIterator, FromOper>(curr, first, last, seq)
{
}
};
template<typename OutIter>
inline SwigPyIterator*
make_output_value_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0)
{
return new SwigPyMapValueITerator_T<OutIter>(current, begin, end, seq);
}
}
}

View file

@ -3,7 +3,7 @@
*/
%include <std_map.i>
%fragment("StdMultimapTraits","header",fragment="StdSequenceTraits")
%fragment("StdMultimapTraits","header",fragment="StdMapCommonTraits")
{
namespace swig {
template <class SwigPySeq, class K, class T >

View file

@ -114,12 +114,19 @@ signed int *OUTPUT,
unsigned int *OUTPUT,
short *OUTPUT,
signed short *OUTPUT,
unsigned short *OUTPUT,
long *OUTPUT,
signed long *OUTPUT,
unsigned long *OUTPUT,
long long *OUTPUT,
signed long long *OUTPUT,
unsigned long long *OUTPUT,
float *OUTPUT,
double *OUTPUT {}
double *OUTPUT,
char *OUTPUT,
signed char *OUTPUT,
unsigned char *OUTPUT
{}

View file

@ -161,6 +161,8 @@ string &, std::string &
#%typemap(scoerceout) SWIGTYPE *const
# %{ class($result) <- "$R_class"; %}
%typemap(scoerceout) SEXP %{ %}
%typemap(scoerceout) SWIGTYPE
%{ $result <- new("$&R_class", ref=$result); %}

View file

@ -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

View file

@ -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();
}

View file

@ -1,49 +1,66 @@
/*
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("rb_complex_new","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. */
SWIGINTERN 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);
}
%#endif
}
/* the common from conversor */
%fragment("SWIG_Complex_Numbers","header")
{
%#if !defined(T_COMPLEX)
SWIGINTERN 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
SWIGINTERN int SWIG_Is_Complex( VALUE obj ) {
return TYPE(obj) == T_COMPLEX;
}
%#endif
SWIGINTERN VALUE SWIG_Complex_Real(VALUE obj) {
static ID real_id = rb_intern("real");
return rb_funcall(obj, real_id, 0);
}
SWIGINTERN 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")
%fragment(SWIG_From_frag(Type),"header",fragment="rb_complex_new")
{
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 +68,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 +103,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;

View file

@ -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 {

View file

@ -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

View file

@ -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);

View file

@ -1,67 +1,9 @@
//
// Maps
//
%fragment("StdMapTraits","header",fragment="StdSequenceTraits")
%fragment("StdMapCommonTraits","header",fragment="StdSequenceTraits")
{
namespace swig {
template <class RubySeq, class K, class T >
inline void
assign(const RubySeq& rubyseq, std::map<K,T > *map) {
typedef typename std::map<K,T>::value_type value_type;
typename RubySeq::const_iterator it = rubyseq.begin();
for (;it != rubyseq.end(); ++it) {
map->insert(value_type(it->first, it->second));
}
}
template <class K, class T>
struct traits_asptr<std::map<K,T> > {
typedef std::map<K,T> map_type;
static int asptr(VALUE obj, map_type **val) {
int res = SWIG_ERROR;
if ( TYPE(obj) == T_HASH ) {
static ID id_to_a = rb_intern("to_a");
VALUE items = rb_funcall(obj, id_to_a, 0);
res = traits_asptr_stdseq<std::map<K,T>, std::pair<K, T> >::asptr(items, val);
} else {
map_type *p;
res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<map_type>(),0);
if (SWIG_IsOK(res) && val) *val = p;
}
return res;
}
};
template <class K, class T >
struct traits_from<std::map<K,T> > {
typedef std::map<K,T> map_type;
typedef typename map_type::const_iterator const_iterator;
typedef typename map_type::size_type size_type;
static VALUE from(const map_type& map) {
swig_type_info *desc = swig::type_info<map_type>();
if (desc && desc->clientdata) {
return SWIG_NewPointerObj(new map_type(map), desc, SWIG_POINTER_OWN);
} else {
size_type size = map.size();
int rubysize = (size <= (size_type) INT_MAX) ? (int) size : -1;
if (rubysize < 0) {
SWIG_RUBY_THREAD_BEGIN_BLOCK;
rb_raise( rb_eRuntimeError, "map size not valid in Ruby");
SWIG_RUBY_THREAD_END_BLOCK;
return Qnil;
}
VALUE obj = rb_hash_new();
for (const_iterator i= map.begin(); i!= map.end(); ++i) {
VALUE key = swig::from(i->first);
VALUE val = swig::from(i->second);
rb_hash_aset(obj, key, val);
}
return obj;
}
}
};
template <class ValueType>
struct from_key_oper
{
@ -134,6 +76,69 @@
}
}
%fragment("StdMapTraits","header",fragment="StdMapCommonTraits")
{
namespace swig {
template <class RubySeq, class K, class T >
inline void
assign(const RubySeq& rubyseq, std::map<K,T > *map) {
typedef typename std::map<K,T>::value_type value_type;
typename RubySeq::const_iterator it = rubyseq.begin();
for (;it != rubyseq.end(); ++it) {
map->insert(value_type(it->first, it->second));
}
}
template <class K, class T>
struct traits_asptr<std::map<K,T> > {
typedef std::map<K,T> map_type;
static int asptr(VALUE obj, map_type **val) {
int res = SWIG_ERROR;
if ( TYPE(obj) == T_HASH ) {
static ID id_to_a = rb_intern("to_a");
VALUE items = rb_funcall(obj, id_to_a, 0);
res = traits_asptr_stdseq<std::map<K,T>, std::pair<K, T> >::asptr(items, val);
} else {
map_type *p;
res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<map_type>(),0);
if (SWIG_IsOK(res) && val) *val = p;
}
return res;
}
};
template <class K, class T >
struct traits_from<std::map<K,T> > {
typedef std::map<K,T> map_type;
typedef typename map_type::const_iterator const_iterator;
typedef typename map_type::size_type size_type;
static VALUE from(const map_type& map) {
swig_type_info *desc = swig::type_info<map_type>();
if (desc && desc->clientdata) {
return SWIG_NewPointerObj(new map_type(map), desc, SWIG_POINTER_OWN);
} else {
size_type size = map.size();
int rubysize = (size <= (size_type) INT_MAX) ? (int) size : -1;
if (rubysize < 0) {
SWIG_RUBY_THREAD_BEGIN_BLOCK;
rb_raise( rb_eRuntimeError, "map size not valid in Ruby");
SWIG_RUBY_THREAD_END_BLOCK;
return Qnil;
}
VALUE obj = rb_hash_new();
for (const_iterator i= map.begin(); i!= map.end(); ++i) {
VALUE key = swig::from(i->first);
VALUE val = swig::from(i->second);
rb_hash_aset(obj, key, val);
}
return obj;
}
}
};
}
}
%define %swig_map_common(Map...)
%swig_container_methods(%arg(Map));
// %swig_sequence_iterator(%arg(Map));

View file

@ -3,7 +3,7 @@
*/
%include <std_map.i>
%fragment("StdMultimapTraits","header",fragment="StdSequenceTraits")
%fragment("StdMultimapTraits","header",fragment="StdMapCommonTraits")
{
namespace swig {
template <class RubySeq, class K, class T >

View file

@ -152,10 +152,29 @@
}
%}
%define %swig_sequence_methods_extra_set(Sequence...)
%extend {
%alias reject_bang "delete_if";
Sequence* reject_bang() {
if ( !rb_block_given_p() )
rb_raise( rb_eArgError, "no block given" );
for ( Sequence::iterator i = $self->begin(); i != $self->end(); ) {
VALUE r = swig::from< Sequence::value_type >(*i);
Sequence::iterator current = i++;
if ( RTEST( rb_yield(r) ) )
$self->erase(current);
}
return self;
}
}
%enddef
%define %swig_set_methods(set...)
%swig_sequence_methods_common(%arg(set));
%swig_sequence_methods_extra_set(%arg(set));
%fragment("RubyPairBoolOutputIterator","header",fragment=SWIG_From_frag(bool),fragment="RubySequence_Cont") {}

View file

@ -60,6 +60,20 @@ namespace std {
%traits_swigtype(_Key);
%traits_swigtype(_Tp);
%fragment(SWIG_Traits_frag(std::pair< _Key, _Tp >), "header",
fragment=SWIG_Traits_frag(_Key),
fragment=SWIG_Traits_frag(_Tp),
fragment="StdPairTraits") {
namespace swig {
template <> struct traits<std::pair< _Key, _Tp > > {
typedef pointer_category category;
static const char* type_name() {
return "std::pair<" #_Key "," #_Tp " >";
}
};
}
}
%fragment(SWIG_Traits_frag(std::multimap<_Key, _Tp, _Compare, _Alloc >), "header",
fragment=SWIG_Traits_frag(std::pair<_Key, _Tp >),
fragment="StdMultimapTraits") {

View file

@ -1,16 +1,16 @@
/* Errors in SWIG */
#define SWIG_UnknownError -1
#define SWIG_IOError -2
#define SWIG_RuntimeError -3
#define SWIG_IndexError -4
#define SWIG_TypeError -5
#define SWIG_DivisionByZero -6
#define SWIG_OverflowError -7
#define SWIG_SyntaxError -8
#define SWIG_ValueError -9
#define SWIG_UnknownError -1
#define SWIG_IOError -2
#define SWIG_RuntimeError -3
#define SWIG_IndexError -4
#define SWIG_TypeError -5
#define SWIG_DivisionByZero -6
#define SWIG_OverflowError -7
#define SWIG_SyntaxError -8
#define SWIG_ValueError -9
#define SWIG_SystemError -10
#define SWIG_AttributeError -11
#define SWIG_MemoryError -12
#define SWIG_MemoryError -12
#define SWIG_NullReferenceError -13

View file

@ -1,17 +1,17 @@
/* -----------------------------------------------------------------------------
* Type initialization:
* This problem is tough by the requirement that no dynamic
* memory is used. Also, since swig_type_info structures store pointers to
* This problem is tough by the requirement that no dynamic
* memory is used. Also, since swig_type_info structures store pointers to
* swig_cast_info structures and swig_cast_info structures store pointers back
* to swig_type_info structures, we need some lookup code at initialization.
* The idea is that swig generates all the structures that are needed.
* The runtime then collects these partially filled structures.
* The SWIG_InitializeModule function takes these initial arrays out of
* to swig_type_info structures, we need some lookup code at initialization.
* The idea is that swig generates all the structures that are needed.
* The runtime then collects these partially filled structures.
* The SWIG_InitializeModule function takes these initial arrays out of
* swig_module, and does all the lookup, filling in the swig_module.types
* array with the correct data and linking the correct swig_cast_info
* structures together.
*
* The generated swig_type_info structures are assigned staticly to an initial
* The generated swig_type_info structures are assigned staticly to an initial
* array. We just loop through that array, and handle each type individually.
* First we lookup if this type has been already loaded, and if so, use the
* loaded structure instead of the generated one. Then we have to fill in the
@ -21,17 +21,17 @@
* a column is one of the swig_cast_info structures for that type.
* The cast_initial array is actually an array of arrays, because each row has
* a variable number of columns. So to actually build the cast linked list,
* we find the array of casts associated with the type, and loop through it
* we find the array of casts associated with the type, and loop through it
* adding the casts to the list. The one last trick we need to do is making
* sure the type pointer in the swig_cast_info struct is correct.
*
* First off, we lookup the cast->type name to see if it is already loaded.
* First off, we lookup the cast->type name to see if it is already loaded.
* There are three cases to handle:
* 1) If the cast->type has already been loaded AND the type we are adding
* casting info to has not been loaded (it is in this module), THEN we
* replace the cast->type pointer with the type pointer that has already
* been loaded.
* 2) If BOTH types (the one we are adding casting info to, and the
* 2) If BOTH types (the one we are adding casting info to, and the
* cast->type) are loaded, THEN the cast info has already been loaded by
* the previous module so we just ignore it.
* 3) Finally, if cast->type has not already been loaded, then we add that
@ -94,7 +94,7 @@ SWIG_InitializeModule(void *clientdata) {
module_head->next = &swig_module;
}
/* When multiple interpeters are used, a module could have already been initialized in
/* When multiple interpreters are used, a module could have already been initialized in
a different interpreter, but not yet have a pointer in this interpreter.
In this case, we do not want to continue adding types... everything should be
set up already */
@ -108,7 +108,7 @@ SWIG_InitializeModule(void *clientdata) {
swig_type_info *type = 0;
swig_type_info *ret;
swig_cast_info *cast;
#ifdef SWIGRUNTIME_DEBUG
printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
#endif
@ -135,7 +135,7 @@ SWIG_InitializeModule(void *clientdata) {
/* Insert casting types */
cast = swig_module.cast_initial[i];
while (cast->type) {
/* Don't need to add information already in the list */
ret = 0;
#ifdef SWIGRUNTIME_DEBUG

View file

@ -29,28 +29,28 @@
#ifndef SWIGUNUSED
# if defined(__GNUC__)
# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
# define SWIGUNUSED __attribute__ ((__unused__))
# define SWIGUNUSED __attribute__ ((__unused__))
# else
# define SWIGUNUSED
# endif
# elif defined(__ICC)
# define SWIGUNUSED __attribute__ ((__unused__))
# define SWIGUNUSED __attribute__ ((__unused__))
# else
# define SWIGUNUSED
# define SWIGUNUSED
# endif
#endif
#ifndef SWIG_MSC_UNSUPPRESS_4505
# if defined(_MSC_VER)
# pragma warning(disable : 4505) /* unreferenced local function has been removed */
# endif
# endif
#endif
#ifndef SWIGUNUSEDPARM
# ifdef __cplusplus
# define SWIGUNUSEDPARM(p)
# else
# define SWIGUNUSEDPARM(p) p SWIGUNUSED
# define SWIGUNUSEDPARM(p) p SWIGUNUSED
# endif
#endif
@ -93,7 +93,7 @@
# define SWIGSTDCALL __stdcall
# else
# define SWIGSTDCALL
# endif
# endif
#endif
/* Deal with Microsoft's attempt at deprecating C standard runtime functions */

View file

@ -22,7 +22,7 @@
You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
creating a static or dynamic library from the SWIG runtime code.
In 99.9% of the cases, SWIG just needs to declare them as 'static'.
But only do this if strictly necessary, ie, if you have problems
with your compiler or suchlike.
*/
@ -48,16 +48,16 @@
#define SWIG_POINTER_OWN 0x1
/*
/*
Flags/methods for returning states.
The SWIG conversion methods, as ConvertPtr, return an integer
The SWIG conversion methods, as ConvertPtr, return an integer
that tells if the conversion was successful or not. And if not,
an error code can be returned (see swigerrors.swg for the codes).
Use the following macros/flags to set or process the returning
states.
In old versions of SWIG, code such as the following was usually written:
if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
@ -90,23 +90,23 @@
} else {
// fail code
}
I.e., now SWIG_ConvertPtr can return new objects and you can
identify the case and take care of the deallocation. Of course that
also requires SWIG_ConvertPtr to return new result values, such as
int SWIG_ConvertPtr(obj, ptr,...) {
if (<obj is ok>) {
if (<need new object>) {
*ptr = <ptr to new allocated object>;
return SWIG_NEWOBJ;
} else {
*ptr = <ptr to old object>;
return SWIG_OLDOBJ;
}
} else {
return SWIG_BADOBJ;
}
int SWIG_ConvertPtr(obj, ptr,...) {
if (<obj is ok>) {
if (<need new object>) {
*ptr = <ptr to new allocated object>;
return SWIG_NEWOBJ;
} else {
*ptr = <ptr to old object>;
return SWIG_OLDOBJ;
}
} else {
return SWIG_BADOBJ;
}
}
Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
@ -120,17 +120,17 @@
int fooi(int);
and you call
food(1) // cast rank '1' (1 -> 1.0)
fooi(1) // cast rank '0'
just use the SWIG_AddCast()/SWIG_CheckState()
*/
#define SWIG_OK (0)
#define SWIG_OK (0)
#define SWIG_ERROR (-1)
#define SWIG_IsOK(r) (r >= 0)
#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError)
#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError)
/* The CastRankLimit says how many bits are used for the cast rank */
#define SWIG_CASTRANKLIMIT (1 << 8)
@ -161,14 +161,14 @@
# endif
# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1)
# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK)
SWIGINTERNINLINE int SWIG_AddCast(int r) {
SWIGINTERNINLINE int SWIG_AddCast(int r) {
return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r;
}
SWIGINTERNINLINE int SWIG_CheckState(int r) {
return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0;
SWIGINTERNINLINE int SWIG_CheckState(int r) {
return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0;
}
#else /* no cast-rank mode */
# define SWIG_AddCast
# define SWIG_AddCast(r) (r)
# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0)
#endif
@ -212,7 +212,7 @@ typedef struct swig_module_info {
void *clientdata; /* Language specific module data */
} swig_module_info;
/*
/*
Compare two type names skipping the space characters, therefore
"char*" == "char *" and "Class<int>" == "Class<int >", etc.
@ -232,18 +232,18 @@ SWIG_TypeNameComp(const char *f1, const char *l1,
/*
Check type equivalence in a name list like <name1>|<name2>|...
Return 0 if not equal, 1 if equal
Return 0 if equal, -1 if nb < tb, 1 if nb > tb
*/
SWIGRUNTIME int
SWIG_TypeEquiv(const char *nb, const char *tb) {
int equiv = 0;
SWIG_TypeCmp(const char *nb, const char *tb) {
int equiv = 1;
const char* te = tb + strlen(tb);
const char* ne = nb;
while (!equiv && *ne) {
while (equiv != 0 && *ne) {
for (nb = ne; *ne; ++ne) {
if (*ne == '|') break;
}
equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
equiv = SWIG_TypeNameComp(nb, ne, tb, te);
if (*ne) ++ne;
}
return equiv;
@ -251,24 +251,13 @@ SWIG_TypeEquiv(const char *nb, const char *tb) {
/*
Check type equivalence in a name list like <name1>|<name2>|...
Return 0 if equal, -1 if nb < tb, 1 if nb > tb
Return 0 if not equal, 1 if equal
*/
SWIGRUNTIME int
SWIG_TypeCompare(const char *nb, const char *tb) {
int equiv = 0;
const char* te = tb + strlen(tb);
const char* ne = nb;
while (!equiv && *ne) {
for (nb = ne; *ne; ++ne) {
if (*ne == '|') break;
}
equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
if (*ne) ++ne;
}
return equiv;
SWIG_TypeEquiv(const char *nb, const char *tb) {
return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0;
}
/*
Check the typename
*/
@ -296,7 +285,7 @@ SWIG_TypeCheck(const char *c, swig_type_info *ty) {
return 0;
}
/*
/*
Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison
*/
SWIGRUNTIME swig_cast_info *
@ -331,7 +320,7 @@ SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
}
/*
/*
Dynamic pointer casting. Down an inheritance hierarchy
*/
SWIGRUNTIME swig_type_info *
@ -375,7 +364,7 @@ SWIG_TypePrettyName(const swig_type_info *type) {
return type->name;
}
/*
/*
Set the clientdata field for a type
*/
SWIGRUNTIME void
@ -383,14 +372,14 @@ SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
swig_cast_info *cast = ti->cast;
/* if (ti->clientdata == clientdata) return; */
ti->clientdata = clientdata;
while (cast) {
if (!cast->converter) {
swig_type_info *tc = cast->type;
if (!tc->clientdata) {
SWIG_TypeClientData(tc, clientdata);
}
}
}
cast = cast->next;
}
}
@ -399,18 +388,18 @@ SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) {
SWIG_TypeClientData(ti, clientdata);
ti->owndata = 1;
}
/*
Search for a swig_type_info structure only by mangled name
Search is a O(log #types)
We start searching at module start, and finish searching when start == end.
We start searching at module start, and finish searching when start == end.
Note: if start == end at the beginning of the function, we go all the way around
the circular list.
*/
SWIGRUNTIME swig_type_info *
SWIG_MangledTypeQueryModule(swig_module_info *start,
swig_module_info *end,
SWIG_MangledTypeQueryModule(swig_module_info *start,
swig_module_info *end,
const char *name) {
swig_module_info *iter = start;
do {
@ -419,11 +408,11 @@ SWIG_MangledTypeQueryModule(swig_module_info *start,
register size_t r = iter->size - 1;
do {
/* since l+r >= 0, we can (>> 1) instead (/ 2) */
register size_t i = (l + r) >> 1;
register size_t i = (l + r) >> 1;
const char *iname = iter->types[i]->name;
if (iname) {
register int compare = strcmp(name, iname);
if (compare == 0) {
if (compare == 0) {
return iter->types[i];
} else if (compare < 0) {
if (i) {
@ -448,14 +437,14 @@ SWIG_MangledTypeQueryModule(swig_module_info *start,
Search for a swig_type_info structure for either a mangled name or a human readable name.
It first searches the mangled names of the types, which is a O(log #types)
If a type is not found it then searches the human readable names, which is O(#types).
We start searching at module start, and finish searching when start == end.
We start searching at module start, and finish searching when start == end.
Note: if start == end at the beginning of the function, we go all the way around
the circular list.
*/
SWIGRUNTIME swig_type_info *
SWIG_TypeQueryModule(swig_module_info *start,
swig_module_info *end,
SWIG_TypeQueryModule(swig_module_info *start,
swig_module_info *end,
const char *name) {
/* STEP 1: Search the name field using binary search */
swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);
@ -474,12 +463,12 @@ SWIG_TypeQueryModule(swig_module_info *start,
iter = iter->next;
} while (iter != end);
}
/* neither found a match */
return 0;
}
/*
/*
Pack binary data into a string
*/
SWIGRUNTIME char *
@ -495,7 +484,7 @@ SWIG_PackData(char *c, void *ptr, size_t sz) {
return c;
}
/*
/*
Unpack binary data from a string
*/
SWIGRUNTIME const char *
@ -509,21 +498,21 @@ SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
uu = ((d - '0') << 4);
else if ((d >= 'a') && (d <= 'f'))
uu = ((d - ('a'-10)) << 4);
else
else
return (char *) 0;
d = *(c++);
if ((d >= '0') && (d <= '9'))
uu |= (d - '0');
else if ((d >= 'a') && (d <= 'f'))
uu |= (d - ('a'-10));
else
else
return (char *) 0;
*u = uu;
}
return c;
}
/*
/*
Pack 'void *' into a string buffer.
*/
SWIGRUNTIME char *

View file

@ -1,5 +1,5 @@
# ---------------------------------------------------------------
# SWIG Tcl/Tk Makefile
# SWIG Tcl Makefile
#
# This file can be used to build various Tcl extensions with SWIG.
# By default this file is set up for dynamic loading, but it can
@ -48,9 +48,8 @@ SWIG = $(exec_prefix)/bin/swig
SWIGOPT = -tcl # use -tcl8 for Tcl 8.0
SWIGCC = $(CC)
# SWIG Library files. Uncomment one of these for rebuilding tclsh or wish
#SWIGLIB = -ltclsh.i
#SWIGLIB = -lwish.i
# SWIG Library files. Uncomment if rebuilding tclsh
#SWIGLIBS = -ltclsh.i
# Rules for creating .o files from source.
@ -72,12 +71,7 @@ BUILD = @LDSHARED@
#DLL_LIBS = -L/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.7.2 \
-L/usr/local/lib -lg++ -lstdc++ -lgcc
# X11 installation (needed to rebuild Tk extensions)
XLIB = @XLIBSW@
XINCLUDE = @XINCLUDES@
# Tcl installation (where is Tcl/Tk located)
# Tcl installation (where is Tcl located)
TCL_INCLUDE = @TCLINCLUDE@
TCL_LIB = @TCLLIB@
@ -88,11 +82,10 @@ LIBM = @LIBM@
LIBC = @LIBC@
SYSLIBS = $(LIBM) $(LIBC) @LIBS@
# Build options (uncomment only one these)
# Build options (uncomment only one of these)
BUILD_LIBS = $(LIBS) # Dynamic loading
#BUILD_LIBS = $(TCL_LIB) -ltcl $(LIBS) $(SYSLIBS) # tclsh
#BUILD_LIBS = $(TCL_LIB) -ltk -ltcl $(XLIB) $(LIBS) $(SYSLIBS) # wish
# Compilation rules for non-SWIG components
@ -120,7 +113,7 @@ $(WRAPOBJ) : $(WRAPFILE)
$(SWIGCC) -c $(CCSHARED) $(CFLAGS) $(WRAPFILE) $(INCLUDES) $(TCL_INCLUDE)
$(WRAPFILE) : $(INTERFACE)
$(SWIG) $(SWIGOPT) -o $(WRAPFILE) $(SWIGLIB) $(INTERFACE)
$(SWIG) $(SWIGOPT) -o $(WRAPFILE) $(SWIGLIBS) $(INTERFACE)
$(TARGET): $(WRAPOBJ) $(ALLOBJS)
$(BUILD) $(WRAPOBJ) $(ALLOBJS) $(BUILD_LIBS) -o $(TARGET)

View file

@ -195,42 +195,42 @@
%define %attribute(Class, AttributeType, AttributeName, GetMethod, SetMethod...)
#if #SetMethod != ""
%attribute_custom(Class, AttributeType, AttributeName, GetMethod, SetMethod, self_->GetMethod(), self_->SetMethod(val_))
%attribute_custom(%arg(Class), %arg(AttributeType), AttributeName, GetMethod, SetMethod, self_->GetMethod(), self_->SetMethod(val_))
#else
%attribute_readonly(Class, AttributeType, AttributeName, GetMethod, self_->GetMethod())
%attribute_readonly(%arg(Class), %arg(AttributeType), AttributeName, GetMethod, self_->GetMethod())
#endif
%enddef
%define %attribute2(Class, AttributeType, AttributeName, GetMethod, SetMethod...)
#if #SetMethod != ""
%attribute_custom(Class, AttributeType, AttributeName, GetMethod, SetMethod, &self_->GetMethod(), self_->SetMethod(*val_))
%attribute_custom(%arg(Class), %arg(AttributeType), AttributeName, GetMethod, SetMethod, &self_->GetMethod(), self_->SetMethod(*val_))
#else
%attribute_readonly(Class, AttributeType, AttributeName, GetMethod, &self_->GetMethod())
%attribute_readonly(%arg(Class), %arg(AttributeType), AttributeName, GetMethod, &self_->GetMethod())
#endif
%enddef
%define %attributeref(Class, AttributeType, AttributeName, AccessorMethod...)
#if #AccessorMethod != ""
%attribute_custom(Class, AttributeType, AttributeName, AccessorMethod, AccessorMethod, self_->AccessorMethod(), self_->AccessorMethod() = val_)
%attribute_custom(%arg(Class), %arg(AttributeType), AttributeName, AccessorMethod, AccessorMethod, self_->AccessorMethod(), self_->AccessorMethod() = val_)
#else
%attribute_custom(Class, AttributeType, AttributeName, AttributeName, AttributeName, self_->AttributeName(), self_->AttributeName() = val_)
%attribute_custom(%arg(Class), %arg(AttributeType), AttributeName, AttributeName, AttributeName, self_->AttributeName(), self_->AttributeName() = val_)
#endif
%enddef
%define %attribute2ref(Class, AttributeType, AttributeName, AccessorMethod...)
#if #AccessorMethod != ""
%attribute_custom(Class, AttributeType, AttributeName, AccessorMethod, AccessorMethod, &self_->AccessorMethod(), self_->AccessorMethod() = *val_)
%attribute_custom(%arg(Class), %arg(AttributeType), AttributeName, AccessorMethod, AccessorMethod, &self_->AccessorMethod(), self_->AccessorMethod() = *val_)
#else
%attribute_custom(Class, AttributeType, AccessorName, AccessorName, AccessorName, &self_->AccessorName(), self_->AccessorName() = *val_)
%attribute_custom(%arg(Class), %arg(AttributeType), AccessorName, AccessorName, AccessorName, &self_->AccessorName(), self_->AccessorName() = *val_)
#endif
%enddef
// deprecated (same as %attributeref, but there is an argument order inconsistency)
%define %attribute_ref(Class, AttributeType, AccessorMethod, AttributeName...)
#if #AttributeName != ""
%attribute_custom(Class, AttributeType, AttributeName, AccessorMethod, AccessorMethod, self_->AccessorMethod(), self_->AccessorMethod() = val_)
%attribute_custom(%arg(Class), %arg(AttributeType), AttributeName, AccessorMethod, AccessorMethod, self_->AccessorMethod(), self_->AccessorMethod() = val_)
#else
%attribute_custom(Class, AttributeType, AccessorMethod, AccessorMethod, AccessorMethod, self_->AccessorMethod(), self_->AccessorMethod() = val_)
%attribute_custom(%arg(Class), %arg(AttributeType), AccessorMethod, AccessorMethod, AccessorMethod, self_->AccessorMethod(), self_->AccessorMethod() = val_)
#endif
%enddef

View file

@ -153,6 +153,29 @@
#include <stddef.h>
%}
%fragment("SWIG_isfinite","header",fragment="<math.h>,<float.h>") %{
/* Getting isfinite working pre C99 across multiple platforms is non-trivial. Users can provide SWIG_isfinite on older platforms. */
#ifndef SWIG_isfinite
# if defined(isfinite)
# define SWIG_isfinite(X) (isfinite(X))
# elif defined(_MSC_VER)
# define SWIG_isfinite(X) (_finite(X))
# elif defined(__sun) && defined(__SVR4)
# include <ieeefp.h>
# define SWIG_isfinite(X) (finite(X))
# endif
#endif
%}
%fragment("SWIG_Float_Overflow_Check","header",fragment="<float.h>,SWIG_isfinite") %{
/* Accept infinite as a valid float value unless we are unable to check if a value is finite */
#ifdef SWIG_isfinite
# define SWIG_Float_Overflow_Check(X) ((X < -FLT_MAX || X > FLT_MAX) && SWIG_isfinite(X))
#else
# define SWIG_Float_Overflow_Check(X) ((X < -FLT_MAX || X > FLT_MAX))
#endif
%}
/* -----------------------------------------------------------------------------
* special macros for fragments
* ----------------------------------------------------------------------------- */
@ -213,13 +236,20 @@ SWIG_AsVal_dec(Type)(SWIG_Object obj, Type *val)
%enddef
/* Macro for 'double' derived types */
/* Macro for floating point derived types (original macro) */
%define %numeric_double(Type, Frag, Min, Max)
%numeric_type_from(Type, double)
%numeric_signed_type_asval(Type, double, Frag , Min, Max)
%enddef
/* Macro for floating point derived types */
%define %numeric_float(Type, Frag, OverflowCond)
%numeric_type_from(Type, double)
%numeric_type_asval(Type, double, Frag, OverflowCond)
%enddef
/* Macros for missing fragments */

View file

@ -1,5 +1,5 @@
/*
The %implict macro allows a SwigType (Class) to be accepted
The %implicit macro allows a SwigType (Class) to be accepted
as an input parameter and use its implicit constructors when needed.
For example:

View file

@ -139,7 +139,7 @@ SWIG_AsVal_dec(bool)(SWIG_Object obj, bool *val)
/* float */
%numeric_double(float, "<float.h>", -FLT_MAX, FLT_MAX)
%numeric_float(float, "SWIG_Float_Overflow_Check", SWIG_Float_Overflow_Check(v))
/* long/unsigned long */

View file

@ -9,9 +9,9 @@
--------------------------
%arg(Arg) Safe argument wrap
%str(Arg) Stringtify the argument
%begin_block Begin a execution block
%end_block End a execution block
%str(Arg) Stringtify the argument
%begin_block Begin a execution block
%end_block End a execution block
%block(Block) Execute Block as a excecution block
%define_as(Def, Val) Define 'Def' as 'Val', expanding Def and Val first
%ifcplusplus(V1, V2) if C++ Mode; then V1; else V2; fi
@ -19,33 +19,33 @@
Casting Operations:
-------------------
SWIG provides the following casting macros, which implement the
corresponding C++ casting operations:
%const_cast(a, Type) const_cast<Type >(a)
%static_cast(a, Type) static_cast<Type >(a)
%reinterpret_cast(a, Type) reinterpret_cast<Type >(a)
%numeric_cast(a, Type) static_cast<Type >(a)
%as_voidptr(a) const_cast<void *>(static_cast<const void *>(a))
%as_voidptrptr(a) reinterpret_cast<void **>(a)
%const_cast(a, Type) const_cast<Type >(a)
%static_cast(a, Type) static_cast<Type >(a)
%reinterpret_cast(a, Type) reinterpret_cast<Type >(a)
%numeric_cast(a, Type) static_cast<Type >(a)
%as_voidptr(a) const_cast<void *>(static_cast<const void *>(a))
%as_voidptrptr(a) reinterpret_cast<void **>(a)
or their C unsafe versions. In C++ we use the safe version unless
SWIG_NO_CPLUSPLUS_CAST is defined (usually via the -nocppcast swig flag).
Memory allocation:
------------------
These allocation/freeing macros are safe to use in C or C++ and
dispatch the proper new/delete/delete[] or free/malloc calls as
needed.
%new_instance(Type) Allocate a new instance of given Type
%new_copy(value,Type) Allocate and initialize a new instance with 'value'
%new_array(size,Type) Allocate a new array with given size and Type
%new_copy_array(cptr,size,Type) Allocate and initialize a new array from 'cptr'
%delete(cptr) Delete an instance
%delete(cptr) Delete an instance
%delete_array(cptr) Delete an array
@ -54,13 +54,13 @@
%formacro(Macro, Args...) or %formacro_1(Macro, Args...)
for i in Args
do
do
Macro($i)
done
%formacro_2(Macro2, Args...)
for i,j in Args
do
do
Macro2($i, $j)
done
@ -71,12 +71,12 @@
%mark_flag(flag)
flag := True
%evalif(flag,expr)
%evalif(flag,expr)
if flag; then
expr
fi
%evalif_2(flag1 flag2,expr)
%evalif_2(flag1 flag2,expr)
if flag1 and flag2; then
expr
fi
@ -84,7 +84,7 @@
*/
/* -----------------------------------------------------------------------------
* Basic preprocessor macros
* Basic preprocessor macros
* ----------------------------------------------------------------------------- */
#define %arg(Arg...) Arg
@ -115,7 +115,7 @@ nocppval
%define_as(SWIGVERSION, SWIG_VERSION)
%#define SWIG_VERSION SWIGVERSION
}
#endif
#endif
@ -153,10 +153,10 @@ nocppval
/* -----------------------------------------------------------------------------
* Allocating/freeing elements
* Allocating/freeing elements
* ----------------------------------------------------------------------------- */
#if defined(__cplusplus)
#if defined(__cplusplus)
# define %new_instance(Type...) (new Type)
# define %new_copy(val,Type...) (new Type(%static_cast(val, const Type&)))
# define %new_array(size,Type...) (new Type[size])
@ -184,7 +184,7 @@ nocppval
/* -----------------------------------------------------------------------------
* Auxiliary loop macros
* Auxiliary loop macros
* ----------------------------------------------------------------------------- */
@ -213,10 +213,10 @@ nocppval
* SWIG flags
* ----------------------------------------------------------------------------- */
/*
/*
mark a flag, ie, define a macro name but ignore it in
the interface.
the interface.
the flag can be later used with %evalif
*/
@ -224,16 +224,16 @@ nocppval
/*
%evalif and %evalif_2 are use to evaluate or process
%evalif and %evalif_2 are use to evaluate or process
an expression if the given predicate is 'true' (1).
*/
%define %_evalif(_x,_expr)
%define %_evalif(_x,_expr)
#if _x == 1
_expr
#endif
%enddef
%define %_evalif_2(_x,_y,_expr)
%define %_evalif_2(_x,_y,_expr)
#if _x == 1 && _y == 1
_expr
#endif