diff options
Diffstat (limited to 'devtools/swigwin-1.3.34/Lib/guile')
25 files changed, 5099 insertions, 0 deletions
diff --git a/devtools/swigwin-1.3.34/Lib/guile/Makefile b/devtools/swigwin-1.3.34/Lib/guile/Makefile new file mode 100644 index 0000000..ff66f9e --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/Makefile @@ -0,0 +1,4 @@ + +co:: + co RCS/*.i* RCS/*.swg* + diff --git a/devtools/swigwin-1.3.34/Lib/guile/common.scm b/devtools/swigwin-1.3.34/Lib/guile/common.scm new file mode 100644 index 0000000..a51d3a7 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/common.scm @@ -0,0 +1,76 @@ +;;;************************************************************************ +;;;*common.scm +;;;* +;;;* This file contains generic SWIG GOOPS classes for generated +;;;* GOOPS file support +;;;* +;;;* Copyright (C) 2003 John Lenz ([email protected]) +;;;* Copyright (C) 2004 Matthias Koeppe ([email protected]) +;;;* +;;;* This file may be freely redistributed without license or fee provided +;;;* this copyright message remains intact. +;;;************************************************************************ + +(define-module (Swig swigrun)) + +(define-module (Swig common) + #:use-module (oop goops) + #:use-module (Swig swigrun)) + +(define-class <swig-metaclass> (<class>) + (new-function #:init-value #f)) + +(define-method (initialize (class <swig-metaclass>) initargs) + (slot-set! class 'new-function (get-keyword #:new-function initargs #f)) + (next-method)) + +(define-class <swig> () + (swig-smob #:init-value #f) + #:metaclass <swig-metaclass> +) + +(define-method (initialize (obj <swig>) initargs) + (next-method) + (slot-set! obj 'swig-smob + (let ((arg (get-keyword #:init-smob initargs #f))) + (if arg + arg + (let ((ret (apply (slot-ref (class-of obj) 'new-function) (get-keyword #:args initargs '())))) + ;; if the class is registered with runtime environment, + ;; new-Function will return a <swig> goops class. In that case, extract the smob + ;; from that goops class and set it as the current smob. + (if (slot-exists? ret 'swig-smob) + (slot-ref ret 'swig-smob) + ret)))))) + +(define (display-address o file) + (display (number->string (object-address o) 16) file)) + +(define (display-pointer-address o file) + ;; Don't fail if the function SWIG-PointerAddress is not present. + (let ((address (false-if-exception (SWIG-PointerAddress o)))) + (if address + (begin + (display " @ " file) + (display (number->string address 16) file))))) + +(define-method (write (o <swig>) file) + ;; We display _two_ addresses to show the object's identity: + ;; * first the address of the GOOPS proxy object, + ;; * second the pointer address. + ;; The reason is that proxy objects are created and discarded on the + ;; fly, so different proxy objects for the same C object will appear. + (let ((class (class-of o))) + (if (slot-bound? class 'name) + (begin + (display "#<" file) + (display (class-name class) file) + (display #\space file) + (display-address o file) + (display-pointer-address o file) + (display ">" file)) + (next-method)))) + +(export <swig-metaclass> <swig>) + +;;; common.scm ends here diff --git a/devtools/swigwin-1.3.34/Lib/guile/cplusplus.i b/devtools/swigwin-1.3.34/Lib/guile/cplusplus.i new file mode 100644 index 0000000..cb4cf74 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/cplusplus.i @@ -0,0 +1,25 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * cplusplus.i + * + * SWIG typemaps for C++ + * ----------------------------------------------------------------------------- */ + +%typemap(guile,out) string, std::string { + $result = gh_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 ()) ); +} +%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)) ); +} + diff --git a/devtools/swigwin-1.3.34/Lib/guile/extra-install.list b/devtools/swigwin-1.3.34/Lib/guile/extra-install.list new file mode 100644 index 0000000..05d2c0c --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/extra-install.list @@ -0,0 +1,2 @@ +# see top-level Makefile.in +common.scm diff --git a/devtools/swigwin-1.3.34/Lib/guile/ghinterface.i b/devtools/swigwin-1.3.34/Lib/guile/ghinterface.i new file mode 100644 index 0000000..c5fda62 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/ghinterface.i @@ -0,0 +1,39 @@ +#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 diff --git a/devtools/swigwin-1.3.34/Lib/guile/guile.i b/devtools/swigwin-1.3.34/Lib/guile/guile.i new file mode 100644 index 0000000..1bf28d6 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/guile.i @@ -0,0 +1,36 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * guile.i + * + * SWIG Configuration File for Guile. + * ----------------------------------------------------------------------------- */ + +/* Macro for inserting Scheme code into the stub */ +#define %scheme %insert("scheme") +#define %goops %insert("goops") + +/* Return-styles */ +%pragma(guile) return_nothing_doc = "Returns unspecified." +%pragma(guile) return_one_doc = "Returns $values." + +%define %values_as_list + %pragma(guile) beforereturn = "" + %pragma(guile) return_multi_doc = "Returns a list of $num_values values: $values." +%enddef +%values_as_list /* the default style */ + +%define %values_as_vector + %pragma(guile) beforereturn = "GUILE_MAYBE_VECTOR" + %pragma(guile) return_multi_doc = "Returns a vector of $num_values values: $values." +%enddef + +%define %multiple_values + %pragma(guile) beforereturn = "GUILE_MAYBE_VALUES" + %pragma(guile) return_multi_doc = "Returns $num_values values: $values." +%enddef + +#define GUILE_APPEND_RESULT SWIG_APPEND_VALUE + +%include <typemaps.i> diff --git a/devtools/swigwin-1.3.34/Lib/guile/guile_gh.swg b/devtools/swigwin-1.3.34/Lib/guile/guile_gh.swg new file mode 100644 index 0000000..6412a4c --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/guile_gh.swg @@ -0,0 +1,74 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * 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); +%} diff --git a/devtools/swigwin-1.3.34/Lib/guile/guile_gh_run.swg b/devtools/swigwin-1.3.34/Lib/guile/guile_gh_run.swg new file mode 100644 index 0000000..5b1fca0 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/guile_gh_run.swg @@ -0,0 +1,261 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * guile_gh_run.swg + * + * Guile GH runtime file + * ----------------------------------------------------------------------------- */ + +#define SWIGGUILE +#include "guile/gh.h" +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <assert.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef SCM (*swig_guile_proc)(); + +#define SWIG_malloc(size) \ + SCM_MUST_MALLOC(size) +#define SWIG_free(mem) \ + scm_must_free(mem) +#define SWIG_ConvertPtr(s, result, type, flags) \ + SWIG_Guile_ConvertPtr(&swig_module, s, result, type, flags) +#define SWIG_MustGetPtr(s, type, argnum, flags) \ + SWIG_Guile_MustGetPtr(&swig_module, s, type, argnum, flags, FUNC_NAME) +#define SWIG_NewPointerObj(ptr, type, owner) \ + SWIG_Guile_NewPointerObj(&swig_module, (void*)ptr, type, owner) +#define SWIG_GetModule(clientdata) SWIG_Guile_GetModule() +#define SWIG_SetModule(clientdata, pointer) SWIG_Guile_SetModule(pointer) + +/* Ignore object-ownership changes in gh mode */ +#define SWIG_Guile_MarkPointerNoncollectable(s) (s) +#define SWIG_Guile_MarkPointerDestroyed(s) (s) + +#define SWIG_contract_assert(expr, msg) \ + if (!(expr)) \ + scm_error(gh_symbol2scm("swig-contract-assertion-failed"), \ + (char *) FUNC_NAME, (char *) msg, \ + SCM_EOL, SCM_BOOL_F); else + +/* SCM_CHAR and SCM_CHARP were introduced in Guile 1.4; the following is for + 1.3.4 compatibility. */ +#ifndef SCM_CHAR +# define SCM_CHAR SCM_ICHR +#endif +#ifndef SCM_CHARP +# define SCM_CHARP SCM_ICHRP +#endif + +/* This function replaces gh_scm2char, which is broken in Guile 1.4 */ +SWIGINTERN char +GSWIG_scm2char (SCM s) +{ + if (SCM_CHARP(s)) return SCM_CHAR(s); + scm_wrong_type_arg(NULL, 0, s); +} +#define gh_scm2char GSWIG_scm2char + +/* Interface function */ +#define SWIG_scm2str(x) gh_scm2newstr(x, NULL) + +/* More 1.3.4 compatibility */ +#ifndef SCM_INPUT_PORT_P +# define SCM_INPUT_PORT_P SCM_INPORTP +# define SCM_OUTPUT_PORT_P SCM_OUTPORTP +#endif + +SWIGINTERN long +SWIG_convert_integer(SCM o, + long lower_bound, long upper_bound, + const char *func_name, int argnum) +{ + long value = gh_scm2long(o); + if (value < lower_bound || value > upper_bound) + scm_wrong_type_arg((char *) func_name, argnum, o); + return value; +} + +SWIGINTERN unsigned long +SWIG_convert_unsigned_integer(SCM o, + unsigned long lower_bound, + unsigned long upper_bound, + const char *func_name, int argnum) +{ + unsigned long value = gh_scm2ulong(o); + if (value < lower_bound || value > upper_bound) + scm_wrong_type_arg((char *) func_name, argnum, o); + return value; +} + +SWIGINTERN swig_type_info * +SWIG_Guile_LookupType(swig_module_info *module, SCM s, int normal) +{ + swig_module_info *iter; + if (!module) return 0; + iter = module; + do { + if ((normal && (unsigned long) SCM_TYP16(s) == *((int *)iter->clientdata))) { + + return iter->types[(long) SCM_CAR(s) >> 16]; + } + iter = iter->next; + } while (iter != module); + return 0; +} + +#ifdef SWIG_GLOBAL +#define SWIG_GUILE_MODULE_STATIC +#elif !defined(SWIG_NOINCLUDE) +#define SWIG_GUILE_MODULE_STATIC static +#endif + +#ifdef SWIG_GUILE_MODULE_STATIC +static swig_module_info *swig_guile_module = 0; +SWIG_GUILE_MODULE_STATIC swig_module_info *SWIG_Guile_GetModule(void) { + return swig_guile_module; +} +SWIG_GUILE_MODULE_STATIC void SWIG_Guile_SetModule(swig_module_info *pointer) { + swig_guile_module = pointer; +} +#else +SWIGEXPORT swig_module_info * SWIG_Guile_GetModule(void); +SWIGEXPORT void SWIG_Guile_SetModule(swig_module_info *pointer); +#endif + +SWIGINTERN SCM +SWIG_Guile_NewPointerObj(swig_module_info *module, void *ptr, + swig_type_info *type, int owner) +{ + unsigned long tag; + if (ptr==NULL) return SCM_EOL; + if (!module) return SCM_EOL; + for (tag = 0; tag < module->size; ++tag) { + if (module->types[tag] == type) + break; + } + if (tag >= module->size) + return SCM_EOL; + + + SCM_RETURN_NEWSMOB( ((tag << 16) | *((int *)module->clientdata)), ptr); +} + +/* Return 0 if successful. */ +SWIGINTERN int +SWIG_Guile_ConvertPtr(swig_module_info *module, SCM s, void **result, + swig_type_info *type, int flags) +{ + swig_cast_info *cast; + swig_type_info *from; + if (SCM_NULLP(s)) { + *result = NULL; + return SWIG_OK; + } else if (SCM_NIMP(s)) { + from = SWIG_Guile_LookupType(module, s, 1); + if (!from) return SWIG_ERROR; + if (type) { + cast = SWIG_TypeCheckStruct(from, type); + if (cast) { + int newmemory = 0; + *result = SWIG_TypeCast(cast, (void *) SCM_CDR(s), &newmemory); + assert(!newmemory); /* newmemory handling not yet implemented */ + return SWIG_OK; + } else { + return SWIG_ERROR; + } + } else { + *result = (void *) SCM_CDR(s); + return SWIG_OK; + } + } + return SWIG_ERROR; +} + +SWIGINTERN void * +SWIG_Guile_MustGetPtr (swig_module_info *module, SCM s, swig_type_info *type, + int argnum, int flags, const char *func_name) +{ + void *result; + int res = SWIG_Guile_ConvertPtr(module, s, &result, type, flags); + if (!SWIG_IsOK(res)) { + /* type mismatch */ + scm_wrong_type_arg((char *) func_name, argnum, s); + } + return result; +} + +/* Init */ + +SWIGINTERN int +print_swig (SCM swig_smob, SCM port, scm_print_state *pstate) +{ + swig_type_info *type = SWIG_Guile_LookupType(0, swig_smob, 1); + if (type) { + scm_puts((char *) "#<swig ", port); + if (type->str != NULL) + scm_puts((char *) type->str, port); + else + scm_puts((char *) type->name, port); + scm_puts((char *) " ", port); + scm_intprint((long) SCM_CDR(swig_smob), 16, port); + scm_puts((char *) ">", port); + /* non-zero means success */ + return 1; + } else { + return 0; + } +} + +SWIGINTERN SCM +equalp_swig (SCM A, SCM B) +{ + if (SCM_CAR(A) == SCM_CAR(B) + && SCM_CDR(A) == SCM_CDR(B)) + return SCM_BOOL_T; + else return SCM_BOOL_F; +} + +SWIGINTERN void +SWIG_Guile_Init (swig_module_info *module) +{ + *((int *)module->clientdata) = + scm_make_smob_type_mfpe((char *) "swig", 0, NULL, NULL, print_swig, equalp_swig); +} + +SWIGINTERN int +SWIG_Guile_GetArgs (SCM *dest, SCM rest, + int reqargs, int optargs, + const char *procname) +{ + int i; + int num_args_passed = 0; + for (i = 0; i<reqargs; i++) { + if (!SCM_CONSP(rest)) + scm_wrong_num_args(gh_str02scm((char *) procname)); + *dest++ = SCM_CAR(rest); + rest = SCM_CDR(rest); + num_args_passed++; + } + for (i = 0; i<optargs && SCM_CONSP(rest); i++) { + *dest++ = SCM_CAR(rest); + rest = SCM_CDR(rest); + num_args_passed++; + } + for (; i<optargs; i++) + *dest++ = SCM_UNDEFINED; + if (!SCM_NULLP(rest)) + scm_wrong_num_args(gh_str02scm((char *) procname)); + return num_args_passed; +} + +#ifdef __cplusplus +} +#endif + +/* guile.swg ends here */ diff --git a/devtools/swigwin-1.3.34/Lib/guile/guile_scm.swg b/devtools/swigwin-1.3.34/Lib/guile/guile_scm.swg new file mode 100644 index 0000000..caded72 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/guile_scm.swg @@ -0,0 +1,53 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * guile_scm.swg + * + * This SWIG interface file is processed if the Guile module is run + * with SCM_ flavor. + * ----------------------------------------------------------------------------- */ + +#define SWIGGUILE_SCM + +%runtime "swigrun.swg" // Common C API type-checking code + +%runtime "guile_scm_run.swg" +%include <ghinterface.i> +%include <guile.i> + +%runtime %{ + +#define GUILE_MAYBE_VALUES \ + if (gswig_list_p) gswig_result = scm_values(gswig_result); + +#define GUILE_MAYBE_VECTOR \ + if (gswig_list_p) gswig_result = scm_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 = scm_listify(gswig_result, object, SCM_UNDEFINED); \ + } \ + 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 + +%} + +%insert(init) "swiginit.swg" + +%init %{ +SWIG_GUILE_INIT_STATIC void +SWIG_init(void) +{ + SWIG_InitializeModule(0); + SWIG_PropagateClientData(); +%} diff --git a/devtools/swigwin-1.3.34/Lib/guile/guile_scm_run.swg b/devtools/swigwin-1.3.34/Lib/guile/guile_scm_run.swg new file mode 100644 index 0000000..5da8558 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/guile_scm_run.swg @@ -0,0 +1,485 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * guile_scm_run.swg + * ----------------------------------------------------------------------------- */ + +#include <libguile.h> +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <assert.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef SCM (*swig_guile_proc)(); +typedef SCM (*guile_destructor)(SCM); + +typedef struct swig_guile_clientdata { + guile_destructor destroy; + SCM goops_class; +} 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_ConvertPtr(s, result, type, flags) \ + SWIG_Guile_ConvertPtr(s, result, type, flags) +#define SWIG_MustGetPtr(s, type, argnum, flags) \ + SWIG_Guile_MustGetPtr(s, type, argnum, flags, FUNC_NAME) +#define SWIG_NewPointerObj(ptr, type, owner) \ + SWIG_Guile_NewPointerObj((void*)ptr, type, owner) +#define SWIG_PointerAddress(object) \ + SWIG_Guile_PointerAddress(object) +#define SWIG_PointerType(object) \ + SWIG_Guile_PointerType(object) +#define SWIG_IsPointerOfType(object, type) \ + SWIG_Guile_IsPointerOfType(object, type) +#define SWIG_IsPointer(object) \ + SWIG_Guile_IsPointer(object) +#define SWIG_contract_assert(expr, msg) \ + if (!(expr)) \ + scm_error(scm_str2symbol("swig-contract-assertion-failed"), \ + (char *) FUNC_NAME, (char *) msg, \ + SCM_EOL, SCM_BOOL_F); else + +/* for C++ member pointers, ie, member methods */ +#define SWIG_ConvertMember(obj, ptr, sz, ty) \ + SWIG_Guile_ConvertMember(obj, ptr, sz, ty, FUNC_NAME) +#define SWIG_NewMemberObj(ptr, sz, type) \ + SWIG_Guile_NewMemberObj(ptr, sz, type, FUNC_NAME) + +/* Runtime API */ +static swig_module_info *SWIG_Guile_GetModule(void); +#define SWIG_GetModule(clientdata) SWIG_Guile_GetModule() +#define SWIG_SetModule(clientdata, pointer) SWIG_Guile_SetModule(pointer) + +SWIGINTERN char * +SWIG_Guile_scm2newstr(SCM str, size_t *len) { +#define FUNC_NAME "SWIG_Guile_scm2newstr" + char *ret; + size_t l; + + SCM_ASSERT (SCM_STRINGP(str), str, 1, FUNC_NAME); + + l = SCM_STRING_LENGTH(str); + ret = (char *) SWIG_malloc( (l + 1) * sizeof(char)); + if (!ret) return NULL; + + memcpy(ret, SCM_STRING_CHARS(str), l); + ret[l] = '\0'; + if (len) *len = l; + return ret; +#undef FUNC_NAME +} + +static int swig_initialized = 0; +static scm_t_bits swig_tag = 0; +static scm_t_bits swig_collectable_tag = 0; +static scm_t_bits swig_destroyed_tag = 0; +static scm_t_bits swig_member_function_tag = 0; +static SCM swig_make_func = SCM_EOL; +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_slot_ref(x, swig_symbol) : (x) ) + +SWIGINTERN SCM +SWIG_Guile_NewPointerObj(void *ptr, swig_type_info *type, int owner) +{ + if (ptr == NULL) + return SCM_EOL; + else { + SCM smob; + swig_guile_clientdata *cdata = (swig_guile_clientdata *) type->clientdata; + if (owner) + SCM_NEWSMOB2(smob, swig_collectable_tag, ptr, (void *) type); + else + SCM_NEWSMOB2(smob, swig_tag, ptr, (void *) type); + + if (!cdata || SCM_NULLP(cdata->goops_class) || swig_make_func == SCM_EOL ) { + return smob; + } else { + /* the scm_make() C function only handles the creation of gf, + methods and classes (no instances) the (make ...) function is + later redefined in goops.scm. So we need to call that + Scheme function. */ + return scm_apply(swig_make_func, + scm_list_3(cdata->goops_class, + swig_keyword, + smob), + SCM_EOL); + } + } +} + +SWIGINTERN unsigned long +SWIG_Guile_PointerAddress(SCM object) +{ + SCM smob = SWIG_Guile_GetSmob(object); + if (SCM_NULLP(smob)) return 0; + else if (SCM_SMOB_PREDICATE(swig_tag, smob) + || SCM_SMOB_PREDICATE(swig_collectable_tag, smob) + || SCM_SMOB_PREDICATE(swig_destroyed_tag, smob)) { + return (unsigned long) (void *) SCM_CELL_WORD_1(smob); + } + else scm_wrong_type_arg("SWIG-Guile-PointerAddress", 1, object); +} + +SWIGINTERN swig_type_info * +SWIG_Guile_PointerType(SCM object) +{ + SCM smob = SWIG_Guile_GetSmob(object); + if (SCM_NULLP(smob)) return NULL; + else if (SCM_SMOB_PREDICATE(swig_tag, smob) + || SCM_SMOB_PREDICATE(swig_collectable_tag, smob) + || SCM_SMOB_PREDICATE(swig_destroyed_tag, smob)) { + return (swig_type_info *) SCM_CELL_WORD_2(smob); + } + else scm_wrong_type_arg("SWIG-Guile-PointerType", 1, object); +} + +SWIGINTERN int +SWIG_Guile_ConvertPtr(SCM s, void **result, swig_type_info *type, int flags) +{ + swig_cast_info *cast; + swig_type_info *from; + SCM smob = SWIG_Guile_GetSmob(s); + + if (SCM_NULLP(smob)) { + *result = NULL; + return SWIG_OK; + } else if (SCM_SMOB_PREDICATE(swig_tag, smob) || SCM_SMOB_PREDICATE(swig_collectable_tag, smob)) { + /* we do not accept smobs representing destroyed pointers */ + from = (swig_type_info *) SCM_CELL_WORD_2(smob); + if (!from) return SWIG_ERROR; + if (type) { + cast = SWIG_TypeCheckStruct(from, type); + if (cast) { + int newmemory = 0; + *result = SWIG_TypeCast(cast, (void *) SCM_CELL_WORD_1(smob), &newmemory); + assert(!newmemory); /* newmemory handling not yet implemented */ + return SWIG_OK; + } else { + return SWIG_ERROR; + } + } else { + *result = (void *) SCM_CELL_WORD_1(smob); + return SWIG_OK; + } + } + return SWIG_ERROR; +} + +SWIGINTERNINLINE void * +SWIG_Guile_MustGetPtr (SCM s, swig_type_info *type, + int argnum, int flags, const char *func_name) +{ + void *result; + int res = SWIG_Guile_ConvertPtr(s, &result, type, flags); + if (!SWIG_IsOK(res)) { + /* type mismatch */ + scm_wrong_type_arg((char *) func_name, argnum, s); + } + return result; +} + +SWIGINTERNINLINE int +SWIG_Guile_IsPointerOfType (SCM s, swig_type_info *type) +{ + void *result; + if (SWIG_Guile_ConvertPtr(s, &result, type, 0)) { + /* type mismatch */ + return 0; + } + else return 1; +} + +SWIGINTERNINLINE int +SWIG_Guile_IsPointer (SCM s) +{ + /* module might not be initialized yet, so initialize it */ + SWIG_Guile_GetModule(); + return SWIG_Guile_IsPointerOfType (s, NULL); +} + +/* Mark a pointer object non-collectable */ +SWIGINTERN void +SWIG_Guile_MarkPointerNoncollectable(SCM s) +{ + SCM smob = SWIG_Guile_GetSmob(s); + if (!SCM_NULLP(smob)) { + if (SCM_SMOB_PREDICATE(swig_tag, smob) || SCM_SMOB_PREDICATE(swig_collectable_tag, smob)) { + SCM_SET_CELL_TYPE(smob, swig_tag); + } + else scm_wrong_type_arg(NULL, 0, s); + } +} + +/* Mark a pointer object destroyed */ +SWIGINTERN void +SWIG_Guile_MarkPointerDestroyed(SCM s) +{ + SCM smob = SWIG_Guile_GetSmob(s); + if (!SCM_NULLP(smob)) { + if (SCM_SMOB_PREDICATE(swig_tag, smob) || SCM_SMOB_PREDICATE(swig_collectable_tag, smob)) { + SCM_SET_CELL_TYPE(smob, swig_destroyed_tag); + } + else scm_wrong_type_arg(NULL, 0, s); + } +} + +/* Member functions */ + +SWIGINTERN SCM +SWIG_Guile_NewMemberObj(void *ptr, size_t sz, swig_type_info *type, + const char *func_name) +{ + SCM smob; + void *copy = malloc(sz); + memcpy(copy, ptr, sz); + SCM_NEWSMOB2(smob, swig_member_function_tag, copy, (void *) type); + return smob; +} + +SWIGINTERN int +SWIG_Guile_ConvertMember(SCM smob, void *ptr, size_t sz, swig_type_info *type, + const char *func_name) +{ + swig_cast_info *cast; + swig_type_info *from; + + if (SCM_SMOB_PREDICATE(swig_member_function_tag, smob)) { + from = (swig_type_info *) SCM_CELL_WORD_2(smob); + if (!from) return SWIG_ERROR; + if (type) { + cast = SWIG_TypeCheckStruct(from, type); + if (!cast) return SWIG_ERROR; + } + memcpy(ptr, (void *) SCM_CELL_WORD_1(smob), sz); + return SWIG_OK; + } + return SWIG_ERROR; +} + + +/* Init */ + +SWIGINTERN int +print_swig_aux (SCM swig_smob, SCM port, scm_print_state *pstate, + const char *attribute) +{ + swig_type_info *type; + + type = (swig_type_info *) SCM_CELL_WORD_2(swig_smob); + if (type) { + scm_puts((char *) "#<", port); + scm_puts((char *) attribute, port); + scm_puts((char *) "swig-pointer ", port); + scm_puts((char *) SWIG_TypePrettyName(type), port); + scm_puts((char *) " ", port); + scm_intprint((long) SCM_CELL_WORD_1(swig_smob), 16, port); + scm_puts((char *) ">", port); + /* non-zero means success */ + return 1; + } else { + return 0; + } +} + + +SWIGINTERN int +print_swig (SCM swig_smob, SCM port, scm_print_state *pstate) +{ + return print_swig_aux(swig_smob, port, pstate, ""); +} + +SWIGINTERN int +print_collectable_swig (SCM swig_smob, SCM port, scm_print_state *pstate) +{ + return print_swig_aux(swig_smob, port, pstate, "collectable-"); +} + +SWIGINTERN int +print_destroyed_swig (SCM swig_smob, SCM port, scm_print_state *pstate) +{ + return print_swig_aux(swig_smob, port, pstate, "destroyed-"); +} + +SWIGINTERN int +print_member_function_swig (SCM swig_smob, SCM port, scm_print_state *pstate) +{ + swig_type_info *type; + type = (swig_type_info *) SCM_CELL_WORD_2(swig_smob); + if (type) { + scm_puts((char *) "#<", port); + scm_puts((char *) "swig-member-function-pointer ", port); + scm_puts((char *) SWIG_TypePrettyName(type), port); + scm_puts((char *) " >", port); + /* non-zero means success */ + return 1; + } else { + return 0; + } +} + +SWIGINTERN SCM +equalp_swig (SCM A, SCM B) +{ + if (SCM_CELL_WORD_0(A) == SCM_CELL_WORD_0(B) && SCM_CELL_WORD_1(A) == SCM_CELL_WORD_1(B) + && SCM_CELL_WORD_2(A) == SCM_CELL_WORD_2(B)) + return SCM_BOOL_T; + else return SCM_BOOL_F; +} + +SWIGINTERN size_t +free_swig(SCM A) +{ + swig_type_info *type = (swig_type_info *) SCM_CELL_WORD_2(A); + if (type) { + if (type->clientdata && ((swig_guile_clientdata *)type->clientdata)->destroy) + ((swig_guile_clientdata *)type->clientdata)->destroy(A); + } + return 0; +} + +SWIGINTERN size_t +free_swig_member_function(SCM A) +{ + free((swig_type_info *) SCM_CELL_WORD_1(A)); + return 0; +} + +SWIGINTERN int +ensure_smob_tag(SCM swig_module, + scm_t_bits *tag_variable, + 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))) { + *tag_variable = scm_make_smob_type((char*)scheme_variable_name, 0); + SCM_VARIABLE_SET(variable, + scm_ulong2num(*tag_variable)); + return 1; + } + else { + *tag_variable = scm_num2ulong(SCM_VARIABLE_REF(variable), 0, + "SWIG_Guile_Init"); + return 0; + } +} + +SWIGINTERN SCM +SWIG_Guile_Init () +{ + static SCM swig_module; + + if (swig_initialized) return swig_module; + swig_initialized = 1; + + swig_module = scm_c_resolve_module("Swig swigrun"); + if (ensure_smob_tag(swig_module, &swig_tag, + "swig-pointer", "swig-pointer-tag")) { + scm_set_smob_print(swig_tag, print_swig); + scm_set_smob_equalp(swig_tag, equalp_swig); + } + if (ensure_smob_tag(swig_module, &swig_collectable_tag, + "collectable-swig-pointer", "collectable-swig-pointer-tag")) { + scm_set_smob_print(swig_collectable_tag, print_collectable_swig); + scm_set_smob_equalp(swig_collectable_tag, equalp_swig); + scm_set_smob_free(swig_collectable_tag, free_swig); + } + if (ensure_smob_tag(swig_module, &swig_destroyed_tag, + "destroyed-swig-pointer", "destroyed-swig-pointer-tag")) { + scm_set_smob_print(swig_destroyed_tag, print_destroyed_swig); + scm_set_smob_equalp(swig_destroyed_tag, equalp_swig); + } + if (ensure_smob_tag(swig_module, &swig_member_function_tag, + "swig-member-function-pointer", "swig-member-function-pointer-tag")) { + scm_set_smob_print(swig_member_function_tag, print_member_function_swig); + scm_set_smob_free(swig_member_function_tag, free_swig_member_function); + } + 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")); +#ifdef SWIG_INIT_RUNTIME_MODULE + SWIG_INIT_RUNTIME_MODULE +#endif + + return swig_module; +} + +SWIGINTERN swig_module_info * +SWIG_Guile_GetModule(void) +{ + SCM module; + SCM variable; + + module = SWIG_Guile_Init(); + + variable = scm_sym2var(scm_str2symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME), + scm_module_lookup_closure(module), + SCM_BOOL_T); + if (SCM_UNBNDP(SCM_VARIABLE_REF(variable))) { + return NULL; + } else { + return (swig_module_info *) scm_num2ulong(SCM_VARIABLE_REF(variable), 0, "SWIG_Guile_Init"); + } +} + +SWIGINTERN void +SWIG_Guile_SetModule(swig_module_info *swig_module) +{ + SCM module; + SCM variable; + + module = SWIG_Guile_Init(); + + variable = scm_sym2var(scm_str2symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME), + scm_module_lookup_closure(module), + SCM_BOOL_T); + + SCM_VARIABLE_SET(variable, scm_ulong2num((unsigned long) swig_module)); +} + +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(scm_makfrom0str((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(scm_makfrom0str((char *) procname)); + return num_args_passed; +} + +#ifdef __cplusplus +} +#endif diff --git a/devtools/swigwin-1.3.34/Lib/guile/guilemain.i b/devtools/swigwin-1.3.34/Lib/guile/guilemain.i new file mode 100644 index 0000000..6f4e4d9 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/guilemain.i @@ -0,0 +1,47 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * guilemain.i + * + * The main functions for a user augmented guile + * version that can handle wrapped calls as generated by SWIG + * ----------------------------------------------------------------------------- */ + +%{ +#include <libguile.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/* Debugger interface (don't change the order of the following lines) */ +#define GDB_TYPE SCM +#include <libguile/gdb_interface.h> +GDB_INTERFACE; + +static void +inner_main(void *closure, int argc, char **argv) +{ +#ifdef SWIGINIT + SWIGINIT +#else + SWIG_init(); /* SWIG init function */ +#endif + scm_shell(argc, argv); /* scheme interpreter */ + /* never reached: scm_shell will perform an exit */ +} + +#ifdef __cplusplus +} +#endif + +int +main(int argc, char **argv) +{ + /* put any default initialisation code here: e.g. exit handlers */ + scm_boot_guile(argc, argv, inner_main, 0); /* make a stack entry for the + garbage collector */ + return 0; /* never reached, but avoids a warning */ +} +%} diff --git a/devtools/swigwin-1.3.34/Lib/guile/interpreter.i b/devtools/swigwin-1.3.34/Lib/guile/interpreter.i new file mode 100644 index 0000000..7e8f077 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/interpreter.i @@ -0,0 +1,62 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * interpreter.i + * + * SWIG file for a simple Guile interpreter + * ----------------------------------------------------------------------------- */ + +%{ + +#include <stdio.h> +GSCM_status guile_init(); + +int main(int argc, char **argv) { + GSCM_status status; + GSCM_top_level toplev; + char *eval_answer; + char input_str[16384]; + int done; + + /* start a scheme interpreter */ + status = gscm_run_scm(argc, argv, 0, stdout, stderr, guile_init, 0, "#t"); + if (status != GSCM_OK) { + fputs(gscm_error_msg(status), stderr); + fputc('\n', stderr); + printf("Error in startup.\n"); + exit(1); + } + + /* create the top level environment */ + status = gscm_create_top_level(&toplev); + if (status != GSCM_OK) { + fputs(gscm_error_msg(status), stderr); + fputc('\n', stderr); + exit(1); + } + + /* now sit in a scheme eval loop: I input the expressions, have guile + * evaluate them, and then get another expression. + */ + done = 0; + fprintf(stdout,"Guile > "); + while (!done) { + if (fgets(input_str,16384,stdin) == NULL) { + exit(1); + } else { + if (strncmp(input_str,"quit",4) == 0) exit(1); + status = gscm_eval_str(&eval_answer, toplev, input_str); + fprintf(stdout,"%s\n", eval_answer); + fprintf(stdout,"Guile > "); + } + } + + /* now clean up and quit */ + gscm_destroy_top_level(toplev); +} + +%} + + + diff --git a/devtools/swigwin-1.3.34/Lib/guile/list-vector.i b/devtools/swigwin-1.3.34/Lib/guile/list-vector.i new file mode 100644 index 0000000..d98cae5 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/list-vector.i @@ -0,0 +1,491 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * list_vector.i + * + * Guile typemaps for converting between arrays and Scheme lists or vectors + * ----------------------------------------------------------------------------- */ + +/* Here is a macro that will define typemaps for converting between C + arrays and Scheme lists or vectors when passing arguments to the C + function. + + TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(C_TYPE, SCM_TO_C, C_TO_SCM, SCM_TYPE) + + Supported calling conventions: + + func(int VECTORLENINPUT, [const] C_TYPE *VECTORINPUT) + + Scheme wrapper will take one argument, a vector. A temporary C + array of elements of type C_TYPE will be allocated and filled + with the elements of the vectors, converted to C with the + SCM_TO_C function. Length and address of the array are passed + to the C function. + + SCM_TYPE is used to describe the Scheme type of the elements in + the Guile procedure documentation. + + func(int LISTLENINPUT, [const] C_TYPE *LISTINPUT) + + Likewise, but the Scheme wrapper will take one argument, a list. + + func(int *VECTORLENOUTPUT, C_TYPE **VECTOROUTPUT) + + Scheme wrapper will take no arguments. Addresses of an integer + and a C_TYPE * variable will be passed to the C function. The + C function is expected to return address and length of a + freshly allocated array of elements of type C_TYPE through + these pointers. The elements of this array are converted to + Scheme with the C_TO_SCM function and returned as a Scheme + vector. + + If the function has a void return value, the vector constructed + by this typemap becomes the return value of the Scheme wrapper. + Otherwise, the function returns multiple values. (See + the documentation on how to deal with multiple values.) + + func(int *LISTLENOUTPUT, C_TYPE **LISTOUTPUT) + + Likewise, but the Scheme wrapper will return a list instead of + a vector. + + It is also allowed to use "size_t LISTLENINPUT" rather than "int + LISTLENINPUT". */ + +%define TYPEMAP_LIST_VECTOR_INPUT_WITH_EXPR(C_TYPE, SCM_TO_C_EXPR, SCM_TYPE) + + /* input */ + + /* We make use of the new multi-dispatch typemaps here. */ + + %typemap(in, doc="$NAME is a vector of " #SCM_TYPE " values") + (int VECTORLENINPUT, C_TYPE *VECTORINPUT), + (size_t VECTORLENINPUT, C_TYPE *VECTORINPUT) + { + SCM_VALIDATE_VECTOR($argnum, $input); + $1 = gh_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)); + $2[i] = SCM_TO_C_EXPR; + } + } + else $2 = NULL; + } + + %typemap(in, doc="$NAME is a list of " #SCM_TYPE " values") + (int LISTLENINPUT, C_TYPE *LISTINPUT), + (size_t LISTLENINPUT, C_TYPE *LISTINPUT) + { + SCM_VALIDATE_LIST($argnum, $input); + $1 = gh_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); + $2[i] = SCM_TO_C_EXPR; + } + } + else $2 = NULL; + } + + /* Do not check for NULL pointers (override checks). */ + + %typemap(check) (int VECTORLENINPUT, C_TYPE *VECTORINPUT), + (size_t VECTORLENINPUT, C_TYPE *VECTORINPUT), + (int LISTLENINPUT, C_TYPE *LISTINPUT), + (size_t LISTLENINPUT, C_TYPE *LISTINPUT) + "/* no check for NULL pointer */"; + + /* Discard the temporary array after the call. */ + + %typemap(freearg) (int VECTORLENINPUT, C_TYPE *VECTORINPUT), + (size_t VECTORLENINPUT, C_TYPE *VECTORINPUT), + (int LISTLENINPUT, C_TYPE *LISTINPUT), + (size_t LISTLENINPUT, C_TYPE *LISTINPUT) + {if ($2!=NULL) SWIG_free($2);} + +%enddef + + /* output */ + +%define TYPEMAP_LIST_VECTOR_OUTPUT_WITH_EXPR(C_TYPE, C_TO_SCM_EXPR, SCM_TYPE) + + /* First we make temporary variables ARRAYLENTEMP and ARRAYTEMP, + whose addresses we pass to the C function. We ignore both + arguments for Scheme. */ + + %typemap(in,numinputs=0) (int *VECTORLENOUTPUT, C_TYPE **VECTOROUTPUT) + (int arraylentemp, C_TYPE *arraytemp), + (int *LISTLENOUTPUT, C_TYPE **LISTOUTPUT) + (int arraylentemp, C_TYPE *arraytemp), + (size_t *VECTORLENOUTPUT, C_TYPE **VECTOROUTPUT) + (size_t arraylentemp, C_TYPE *arraytemp), + (size_t *LISTLENOUTPUT, C_TYPE **LISTOUTPUT) + (size_t arraylentemp, C_TYPE *arraytemp) + %{ + $1 = &arraylentemp; + $2 = &arraytemp; + %} + + /* In the ARGOUT typemaps, we convert the array into a vector or + a list and append it to the results. */ + + %typemap(argout, doc="$NAME (a vector of " #SCM_TYPE " values)") + (int *VECTORLENOUTPUT, C_TYPE **VECTOROUTPUT), + (size_t *VECTORLENOUTPUT, C_TYPE **VECTOROUTPUT) + { + $*1_ltype i; + SCM res = gh_make_vector(gh_int2scm(*$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); + } + SWIG_APPEND_VALUE(res); + } + + %typemap(argout, doc="$NAME (a list of " #SCM_TYPE " values)") + (int *LISTLENOUTPUT, C_TYPE **LISTOUTPUT), + (size_t *LISTLENOUTPUT, C_TYPE **LISTOUTPUT) + { + int i; + SCM res = SCM_EOL; + 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); + } + SWIG_APPEND_VALUE(res); + } + + /* In the FREEARG typemaps, get rid of the C vector. + (This can be overridden if you want to keep the C vector.) */ + + %typemap(freearg) + (int *VECTORLENOUTPUT, C_TYPE **VECTOROUTPUT), + (size_t *VECTORLENOUTPUT, C_TYPE **VECTOROUTPUT), + (int *LISTLENOUTPUT, C_TYPE **LISTOUTPUT), + (size_t *LISTLENOUTPUT, C_TYPE **LISTOUTPUT) + { + if ((*$2)!=NULL) free(*$2); + } + +%enddef + +%define TYPEMAP_LIST_VECTOR_INPUT_OUTPUT_WITH_EXPR(C_TYPE, SCM_TO_C_EXPR, C_TO_SCM_EXPR, SCM_TYPE) + TYPEMAP_LIST_VECTOR_INPUT_WITH_EXPR(C_TYPE, SCM_TO_C_EXPR, SCM_TYPE) + TYPEMAP_LIST_VECTOR_OUTPUT_WITH_EXPR(C_TYPE, C_TO_SCM_EXPR, SCM_TYPE) +%enddef + +%define TYPEMAP_LIST_VECTOR_INPUT(C_TYPE, SCM_TO_C, SCM_TYPE) + TYPEMAP_LIST_VECTOR_INPUT_WITH_EXPR + (C_TYPE, SCM_TO_C(swig_scm_value), SCM_TYPE) +%enddef + +%define TYPEMAP_LIST_VECTOR_OUTPUT(C_TYPE, C_TO_SCM, SCM_TYPE) + TYPEMAP_LIST_VECTOR_OUTPUT_WITH_EXPR + (C_TYPE, C_TO_SCM(swig_c_value), SCM_TYPE) +%enddef + +%define TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(C_TYPE, SCM_TO_C, C_TO_SCM, SCM_TYPE) + TYPEMAP_LIST_VECTOR_INPUT_OUTPUT_WITH_EXPR + (C_TYPE, SCM_TO_C(swig_scm_value), C_TO_SCM(swig_c_value), SCM_TYPE) +%enddef + +/* 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); + +/* For the char *, free all strings after converting */ + + %typemap(freearg) + (int *VECTORLENOUTPUT, char ***VECTOROUTPUT), + (size_t *VECTORLENOUTPUT, char ***VECTOROUTPUT), + (int *LISTLENOUTPUT, char ***LISTOUTPUT), + (size_t *LISTLENOUTPUT, char ***LISTOUTPUT), + (int *VECTORLENOUTPUT, const char ***VECTOROUTPUT), + (size_t *VECTORLENOUTPUT, const char ***VECTOROUTPUT), + (int *LISTLENOUTPUT, const char ***LISTOUTPUT), + (size_t *LISTLENOUTPUT, const char ***LISTOUTPUT) + { + if ((*$2)!=NULL) { + int i; + for (i = 0; i < *$1; i++) { + if ((*$2)[i] != NULL) free((*$2)[i]); + } + free(*$2); + } + } + +%typemap(freearg) (int VECTORLENINPUT, char **VECTORINPUT), + (size_t VECTORLENINPUT, char **VECTORINPUT), + (int LISTLENINPUT, char **LISTINPUT), + (size_t LISTLENINPUT, char **LISTINPUT), + (int VECTORLENINPUT, const char **VECTORINPUT), + (size_t VECTORLENINPUT, const char **VECTORINPUT), + (int LISTLENINPUT, const char **LISTINPUT), + (size_t LISTLENINPUT, const char **LISTINPUT) +{ + if (($2)!=NULL) { + int i; + for (i = 0; i< $1; i++) + if (($2)[i] != NULL) free(($2)[i]); + free($2); + } +} + + +/* Following is a macro that emits typemaps that are much more + flexible. (They are also messier.) It supports multiple parallel + lists and vectors (sharing one length argument each). + + TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(C_TYPE, SCM_TO_C, C_TO_SCM, SCM_TYPE) + + Supported calling conventions: + + func(int PARALLEL_VECTORLENINPUT, [const] C_TYPE *PARALLEL_VECTORINPUT, ...) or + func([const] C_TYPE *PARALLEL_VECTORINPUT, ..., int PARALLEL_VECTORLENINPUT) + + func(int PARALLEL_LISTLENINPUT, [const] C_TYPE *PARALLEL_LISTINPUT, ...) or + func([const] C_TYPE *PARALLEL_LISTINPUT, ..., int PARALLEL_LISTLENINPUT) + + func(int *PARALLEL_VECTORLENOUTPUT, C_TYPE **PARALLEL_VECTOROUTPUT, ...) or + func(C_TYPE **PARALLEL_VECTOROUTPUT, int *PARALLEL_VECTORLENOUTPUT, ...) + + func(int *PARALLEL_LISTLENOUTPUT, C_TYPE **PARALLEL_LISTOUTPUT) or + func(C_TYPE **PARALLEL_LISTOUTPUT, int *PARALLEL_LISTLENOUTPUT) + + It is also allowed to use "size_t PARALLEL_LISTLENINPUT" rather than "int + PARALLEL_LISTLENINPUT". */ + +%define TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_WITH_EXPR(C_TYPE, SCM_TO_C_EXPR, SCM_TYPE) + + /* input */ + + /* Passing data is a little complicated here; just remember: + IGNORE typemaps come first, then IN, then CHECK. But if + IGNORE is given, IN won't be used for this type. + + We need to "ignore" one of the parameters because there shall + be only one argument on the Scheme side. Here we only + initialize the array length to 0 but save its address for a + later change. */ + + %typemap(in,numinputs=0) int PARALLEL_VECTORLENINPUT (int *_global_vector_length), + size_t PARALLEL_VECTORLENINPUT (size_t *_global_vector_length) + { + $1 = 0; + _global_vector_length = &$1; + } + + %typemap(in,numinputs=0) int PARALLEL_LISTLENINPUT (int *_global_list_length), + size_t PARALLEL_LISTLENINPUT (size_t *_global_list_length) + { + $1 = 0; + _global_list_length = &$1; + } + + /* All the work is done in IN. */ + + %typemap(in, doc="$NAME is a vector of " #SCM_TYPE " values") + C_TYPE *PARALLEL_VECTORINPUT, + const C_TYPE *PARALLEL_VECTORINPUT + { + SCM_VALIDATE_VECTOR($argnum, $input); + *_global_vector_length = gh_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)); + $1[i] = SCM_TO_C_EXPR; + } + } + else $1 = NULL; + } + + %typemap(in, doc="$NAME is a list of " #SCM_TYPE " values") + C_TYPE *PARALLEL_LISTINPUT, + const C_TYPE *PARALLEL_LISTINPUT + { + SCM_VALIDATE_LIST($argnum, $input); + *_global_list_length = gh_length($input); + if (*_global_list_length > 0) { + int i; + SCM rest; + $1 = (C_TYPE *) SWIG_malloc(sizeof(C_TYPE) + * (*_global_list_length)); + for (i = 0, rest = $input; + i<*_global_list_length; + i++, rest = gh_cdr(rest)) { + SCM swig_scm_value = gh_car(rest); + $1[i] = SCM_TO_C_EXPR; + } + } + else $1 = NULL; + } + + /* Don't check for NULL pointers (override checks). */ + + %typemap(check) C_TYPE *PARALLEL_VECTORINPUT, + const C_TYPE *PARALLEL_VECTORINPUT, + C_TYPE *PARALLEL_LISTINPUT, + const C_TYPE *PARALLEL_LISTINPUT + "/* no check for NULL pointer */"; + + /* Discard the temporary array after the call. */ + + %typemap(freearg) C_TYPE *PARALLEL_VECTORINPUT, + const C_TYPE *PARALLEL_VECTORINPUT, + C_TYPE *PARALLEL_LISTINPUT, + const C_TYPE *PARALLEL_LISTINPUT + {if ($1!=NULL) SWIG_free($1);} + +%enddef + +%define TYPEMAP_PARALLEL_LIST_VECTOR_OUTPUT_WITH_EXPR(C_TYPE, C_TO_SCM_EXPR, SCM_TYPE) + + /* output */ + + /* First we make a temporary variable ARRAYLENTEMP, use its + address as the ...LENOUTPUT argument for the C function and + "ignore" the ...LENOUTPUT argument for Scheme. */ + + %typemap(in,numinputs=0) int *PARALLEL_VECTORLENOUTPUT (int _global_arraylentemp), + size_t *PARALLEL_VECTORLENOUTPUT (size_t _global_arraylentemp), + int *PARALLEL_LISTLENOUTPUT (int _global_arraylentemp), + size_t *PARALLEL_LISTLENOUTPUT (size_t _global_arraylentemp) + "$1 = &_global_arraylentemp;"; + + /* We also need to ignore the ...OUTPUT argument. */ + + %typemap(in,numinputs=0) C_TYPE **PARALLEL_VECTOROUTPUT (C_TYPE *arraytemp), + C_TYPE **PARALLEL_LISTOUTPUT (C_TYPE *arraytemp) + "$1 = &arraytemp;"; + + /* In the ARGOUT typemaps, we convert the array into a vector or + a list and append it to the results. */ + + %typemap(argout, doc="$NAME (a vector of " #SCM_TYPE " values)") + C_TYPE **PARALLEL_VECTOROUTPUT + { + int i; + SCM res = gh_make_vector(gh_int2scm(_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); + } + SWIG_APPEND_VALUE(res); + } + + %typemap(argout, doc="$NAME (a list of " #SCM_TYPE " values)") + C_TYPE **PARALLEL_LISTOUTPUT + { + int i; + SCM res = SCM_EOL; + if (_global_arraylentemp > 0) { + 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); + } + } + SWIG_APPEND_VALUE(res); + } + + /* In the FREEARG typemaps, get rid of the C vector. + (This can be overridden if you want to keep the C vector.) */ + + %typemap(freearg) C_TYPE **PARALLEL_VECTOROUTPUT, + C_TYPE **PARALLEL_LISTOUTPUT + { + if ((*$1)!=NULL) free(*$1); + } + +%enddef + +%define TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT_WITH_EXPR(C_TYPE, SCM_TO_C_EXPR, C_TO_SCM_EXPR, SCM_TYPE) + TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_WITH_EXPR(C_TYPE, SCM_TO_C_EXPR, SCM_TYPE) + TYPEMAP_PARALLEL_LIST_VECTOR_OUTPUT_WITH_EXPR(C_TYPE, C_TO_SCM_EXPR, SCM_TYPE) +%enddef + +%define TYPEMAP_PARALLEL_LIST_VECTOR_INPUT(C_TYPE, SCM_TO_C, SCM_TYPE) + TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_WITH_EXPR + (C_TYPE, SCM_TO_C(swig_scm_value), SCM_TYPE) +%enddef + +%define TYPEMAP_PARALLEL_LIST_VECTOR_OUTPUT(C_TYPE, C_TO_SCM, SCM_TYPE) + TYPEMAP_PARALLEL_LIST_VECTOR_OUTPUT_WITH_EXPR + (C_TYPE, C_TO_SCM(swig_c_value), SCM_TYPE) +%enddef + +%define TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(C_TYPE, SCM_TO_C, C_TO_SCM, SCM_TYPE) + TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT_WITH_EXPR + (C_TYPE, SCM_TO_C(swig_scm_value), C_TO_SCM(swig_c_value), SCM_TYPE) +%enddef + +/* 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(freearg) char **PARALLEL_LISTINPUT, char **PARALLEL_VECTORINPUT, + const char **PARALLEL_LISTINPUT, const char **PARALLEL_VECTORINPUT +{ + if (($1)!=NULL) { + int i; + for (i = 0; i<*_global_list_length; i++) + if (($1)[i] != NULL) SWIG_free(($1)[i]); + SWIG_free($1); + } +} + +%typemap(freearg) char ***PARALLEL_LISTOUTPUT, char ***PARALLEL_VECTOROUTPUT, + const char ***PARALLEL_LISTOUTPUT, const char ***PARALLEL_VECTOROUTPUT +{ + if ((*$1)!=NULL) { + int i; + for (i = 0; i<_global_arraylentemp; i++) + if ((*$1)[i] != NULL) free((*$1)[i]); + free(*$1); + } +} diff --git a/devtools/swigwin-1.3.34/Lib/guile/pointer-in-out.i b/devtools/swigwin-1.3.34/Lib/guile/pointer-in-out.i new file mode 100644 index 0000000..bc64387 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/pointer-in-out.i @@ -0,0 +1,105 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * pointer-in-out.i + * + * Guile typemaps for passing pointers indirectly + * ----------------------------------------------------------------------------- */ + +/* Here is a macro that will define typemaps for passing C pointers indirectly. + + TYPEMAP_POINTER_INPUT_OUTPUT(PTRTYPE, SCM_TYPE) + + Supported calling conventions (in this example, PTRTYPE is int *): + + func(int **INPUT) + + Scheme wrapper will take one argument, a wrapped C pointer. + The address of a variable containing this pointer will be + passed to the function. + + func(int **INPUT_CONSUMED) + + Likewise, but mark the pointer object as not garbage + collectable. + + func(int **INPUT_DESTROYED) + + Likewise, but mark the pointer object as destroyed. + + func(int **OUTPUT) + + Scheme wrapper will take no arguments. The address of an int * + variable will be passed to the function. The function is + expected to modify the variable; its value is wrapped and + becomes an extra return value. (See the documentation on how + to deal with multiple values.) + + func(int **OUTPUT_NONCOLLECTABLE) + + Likewise, but make the pointer object not garbage collectable. + + func(int **BOTH) + func(int **INOUT) + + This annotation combines INPUT and OUTPUT. + +*/ + +%define TYPEMAP_POINTER_INPUT_OUTPUT(PTRTYPE, SCM_TYPE) + +%typemap(in, doc="$NAME is of type <" #SCM_TYPE ">") PTRTYPE *INPUT(PTRTYPE temp) +{ + if (SWIG_ConvertPtr($input, (void **) &temp, $*descriptor, 0)) { + scm_wrong_type_arg(FUNC_NAME, $argnum, $input); + } + $1 = &temp; +} + +%typemap(in, doc="$NAME is of type <" #SCM_TYPE "> and is consumed by the function") PTRTYPE *INPUT_CONSUMED(PTRTYPE temp) +{ + if (SWIG_ConvertPtr($input, (void **) &temp, $*descriptor, 0)) { + scm_wrong_type_arg(FUNC_NAME, $argnum, $input); + } + SWIG_Guile_MarkPointerNoncollectable($input); + $1 = &temp; +} + +%typemap(in, doc="$NAME is of type <" #SCM_TYPE "> and is consumed by the function") PTRTYPE *INPUT_DESTROYED(PTRTYPE temp) +{ + if (SWIG_ConvertPtr($input, (void **) &temp, $*descriptor, 0)) { + scm_wrong_type_arg(FUNC_NAME, $argnum, $input); + } + SWIG_Guile_MarkPointerDestroyed($input); + $1 = &temp; +} + +%typemap(in, numinputs=0) PTRTYPE *OUTPUT(PTRTYPE temp), + PTRTYPE *OUTPUT_NONCOLLECTABLE(PTRTYPE temp) + "$1 = &temp;"; + +%typemap(argout, doc="<" #SCM_TYPE ">") PTRTYPE *OUTPUT + "SWIG_APPEND_VALUE(SWIG_NewPointerObj(*$1, $*descriptor, 1));"; + +%typemap(argout, doc="<" #SCM_TYPE ">") PTRTYPE *OUTPUT_NONCOLLECTABLE + "SWIG_APPEND_VALUE(SWIG_NewPointerObj(*$1, $*descriptor, 0));"; + +%typemap(in) PTRTYPE *BOTH = PTRTYPE *INPUT; +%typemap(argout) PTRTYPE *BOTH = PTRTYPE *OUTPUT; +%typemap(in) PTRTYPE *INOUT = PTRTYPE *INPUT; +%typemap(argout) PTRTYPE *INOUT = PTRTYPE *OUTPUT; + +/* As a special convenience measure, also attach docs involving + SCM_TYPE to the standard pointer typemaps */ + +%typemap(in, doc="$NAME is of type <" #SCM_TYPE ">") PTRTYPE { + if (SWIG_ConvertPtr($input, (void **) &$1, $descriptor, 0)) + scm_wrong_type_arg(FUNC_NAME, $argnum, $input); +} + +%typemap(out, doc="<" #SCM_TYPE ">") PTRTYPE { + $result = SWIG_NewPointerObj ($1, $descriptor, $owner); +} + +%enddef diff --git a/devtools/swigwin-1.3.34/Lib/guile/ports.i b/devtools/swigwin-1.3.34/Lib/guile/ports.i new file mode 100644 index 0000000..0d0e142 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/ports.i @@ -0,0 +1,56 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * ports.i + * + * Guile typemaps for handling ports + * ----------------------------------------------------------------------------- */ + +%{ + #ifndef _POSIX_SOURCE + /* This is needed on Solaris for fdopen(). */ + # define _POSIX_SOURCE 199506L + #endif + #include <stdio.h> + #include <errno.h> + #include <unistd.h> +%} + +/* This typemap for FILE * accepts + (1) FILE * pointer objects, + (2) Scheme file ports. In this case, it creates a temporary C stream + which reads or writes from a dup'ed file descriptor. + */ + +%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; + } +} + +%typemap(freearg) FILE* { + if (closep$argnum) + fclose($1); +} + diff --git a/devtools/swigwin-1.3.34/Lib/guile/std_common.i b/devtools/swigwin-1.3.34/Lib/guile/std_common.i new file mode 100644 index 0000000..ace5d65 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/std_common.i @@ -0,0 +1,27 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_common.i + * + * SWIG typemaps for STL - common utilities + * ----------------------------------------------------------------------------- */ + +%include <std/std_except.i> + +%apply size_t { std::size_t }; + +#define SWIG_bool2scm(b) gh_bool2scm(b ? 1 : 0) +#define SWIG_string2scm(s) gh_str02scm(s.c_str()) + +%{ +#include <string> + +inline std::string SWIG_scm2string(SCM x) { + char* temp; + temp = SWIG_scm2str(x); + std::string s(temp); + if (temp) SWIG_free(temp); + return s; +} +%} diff --git a/devtools/swigwin-1.3.34/Lib/guile/std_deque.i b/devtools/swigwin-1.3.34/Lib/guile/std_deque.i new file mode 100644 index 0000000..cb98f6c --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/std_deque.i @@ -0,0 +1 @@ +%include <std/_std_deque.i> diff --git a/devtools/swigwin-1.3.34/Lib/guile/std_except.i b/devtools/swigwin-1.3.34/Lib/guile/std_except.i new file mode 100644 index 0000000..61bf481 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/std_except.i @@ -0,0 +1,12 @@ +// TODO: STL exception handling +// Note that the generic std_except.i file did not work +%{ +#include <stdexcept> +%} + +namespace std { + %ignore exception; + struct exception { + }; +} + diff --git a/devtools/swigwin-1.3.34/Lib/guile/std_map.i b/devtools/swigwin-1.3.34/Lib/guile/std_map.i new file mode 100644 index 0000000..cc53e15 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/std_map.i @@ -0,0 +1,1351 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_map.i + * + * SWIG typemaps for std::map + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> + +// ------------------------------------------------------------------------ +// std::map +// +// The aim of all that follows would be to integrate std::map with +// Guile as much as possible, namely, to allow the user to pass and +// be returned Scheme association lists. +// const declarations are used to guess the intent of the function being +// exported; therefore, the following rationale is applied: +// +// -- f(std::map<T>), f(const std::map<T>&), f(const std::map<T>*): +// the parameter being read-only, either a Scheme alist or a +// previously wrapped std::map<T> can be passed. +// -- f(std::map<T>&), f(std::map<T>*): +// the parameter must be modified; therefore, only a wrapped std::map +// can be passed. +// -- std::map<T> f(): +// the map is returned by copy; therefore, a Scheme alist +// is returned which is most easily used in other Scheme functions +// -- std::map<T>& f(), std::map<T>* f(), const std::map<T>& f(), +// const std::map<T>* f(): +// the map is returned by reference; therefore, a wrapped std::map +// is returned +// ------------------------------------------------------------------------ + +%{ +#include <map> +#include <algorithm> +#include <stdexcept> +%} + +// exported class + +namespace std { + + template<class K, class T> class map { + %typemap(in) map<K,T> (std::map<K,T>* m) { + if (gh_null_p($input)) { + $1 = std::map<K,T >(); + } else if (gh_pair_p($input)) { + $1 = std::map<K,T >(); + SCM alist = $input; + while (!gh_null_p(alist)) { + K* k; + T* x; + SCM entry, key, val; + entry = gh_car(alist); + if (!gh_pair_p(entry)) + SWIG_exception(SWIG_TypeError,"alist expected"); + key = gh_car(entry); + val = gh_cdr(entry); + k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0); + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) != 0) { + if (!gh_pair_p(val)) + SWIG_exception(SWIG_TypeError,"alist expected"); + val = gh_car(val); + x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0); + } + (($1_type &)$1)[*k] = *x; + alist = gh_cdr(alist); + } + } else { + $1 = *(($&1_type) + SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); + } + } + %typemap(in) const map<K,T>& (std::map<K,T> temp, + std::map<K,T>* m), + const map<K,T>* (std::map<K,T> temp, + std::map<K,T>* m) { + if (gh_null_p($input)) { + temp = std::map<K,T >(); + $1 = &temp; + } else if (gh_pair_p($input)) { + temp = std::map<K,T >(); + $1 = &temp; + SCM alist = $input; + while (!gh_null_p(alist)) { + K* k; + T* x; + SCM entry, key, val; + entry = gh_car(alist); + if (!gh_pair_p(entry)) + SWIG_exception(SWIG_TypeError,"alist expected"); + key = gh_car(entry); + val = gh_cdr(entry); + k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0); + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) != 0) { + if (!gh_pair_p(val)) + SWIG_exception(SWIG_TypeError,"alist expected"); + val = gh_car(val); + x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0); + } + temp[*k] = *x; + alist = gh_cdr(alist); + } + } else { + $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + } + %typemap(out) map<K,T> { + SCM alist = SCM_EOL; + for (std::map<K,T >::reverse_iterator i=$1.rbegin(); + i!=$1.rend(); ++i) { + K* key = new K(i->first); + T* val = new T(i->second); + SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1); + SCM x = SWIG_NewPointerObj(val,$descriptor(T *), 1); + SCM entry = gh_cons(k,x); + alist = gh_cons(entry,alist); + } + $result = alist; + } + %typecheck(SWIG_TYPECHECK_MAP) map<K,T> { + /* native sequence? */ + if (gh_null_p($input)) { + /* an empty sequence can be of any type */ + $1 = 1; + } else if (gh_pair_p($input)) { + /* check the first element only */ + K* k; + T* x; + SCM head = gh_car($input); + if (gh_pair_p(head)) { + SCM key = gh_car(head); + SCM val = gh_cdr(head); + if (SWIG_ConvertPtr(key,(void**) &k, + $descriptor(K *), 0) != 0) { + $1 = 0; + } else { + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) == 0) { + $1 = 1; + } else if (gh_pair_p(val)) { + val = gh_car(val); + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) == 0) + $1 = 1; + else + $1 = 0; + } else { + $1 = 0; + } + } + } else { + $1 = 0; + } + } else { + /* wrapped map? */ + std::map<K,T >* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $&1_descriptor, 0) == 0) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_MAP) const map<K,T>&, + const map<K,T>* { + /* native sequence? */ + if (gh_null_p($input)) { + /* an empty sequence can be of any type */ + $1 = 1; + } else if (gh_pair_p($input)) { + /* check the first element only */ + K* k; + T* x; + SCM head = gh_car($input); + if (gh_pair_p(head)) { + SCM key = gh_car(head); + SCM val = gh_cdr(head); + if (SWIG_ConvertPtr(key,(void**) &k, + $descriptor(K *), 0) != 0) { + $1 = 0; + } else { + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) == 0) { + $1 = 1; + } else if (gh_pair_p(val)) { + val = gh_car(val); + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) == 0) + $1 = 1; + else + $1 = 0; + } else { + $1 = 0; + } + } + } else { + $1 = 0; + } + } else { + /* wrapped map? */ + std::map<K,T >* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $1_descriptor, 0) == 0) + $1 = 1; + else + $1 = 0; + } + } + %rename("length") size; + %rename("null?") empty; + %rename("clear!") clear; + %rename("ref") __getitem__; + %rename("set!") __setitem__; + %rename("delete!") __delitem__; + %rename("has-key?") has_key; + public: + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + T& __getitem__(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void __setitem__(const K& key, const T& x) { + (*self)[key] = x; + } + void __delitem__(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(const K& key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + SCM keys() { + SCM result = SCM_EOL; + for (std::map<K,T >::reverse_iterator i=$1.rbegin(); + i!=$1.rend(); ++i) { + K* key = new K(i->first); + SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1); + result = gh_cons(k,result); + } + return result; + } + } + }; + + + // specializations for built-ins + + %define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) + + template<class T> class map<K,T> { + %typemap(in) map<K,T> (std::map<K,T>* m) { + if (gh_null_p($input)) { + $1 = std::map<K,T >(); + } else if (gh_pair_p($input)) { + $1 = std::map<K,T >(); + SCM alist = $input; + while (!gh_null_p(alist)) { + T* x; + SCM entry, key, val; + entry = gh_car(alist); + if (!gh_pair_p(entry)) + SWIG_exception(SWIG_TypeError,"alist expected"); + key = gh_car(entry); + val = gh_cdr(entry); + if (!CHECK(key)) + SWIG_exception(SWIG_TypeError, + "map<" #K "," #T "> expected"); + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) != 0) { + if (!gh_pair_p(val)) + SWIG_exception(SWIG_TypeError,"alist expected"); + val = gh_car(val); + x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0); + } + (($1_type &)$1)[CONVERT_FROM(key)] = *x; + alist = gh_cdr(alist); + } + } else { + $1 = *(($&1_type) + SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); + } + } + %typemap(in) const map<K,T>& (std::map<K,T> temp, + std::map<K,T>* m), + const map<K,T>* (std::map<K,T> temp, + std::map<K,T>* m) { + if (gh_null_p($input)) { + temp = std::map<K,T >(); + $1 = &temp; + } else if (gh_pair_p($input)) { + temp = std::map<K,T >(); + $1 = &temp; + SCM alist = $input; + while (!gh_null_p(alist)) { + T* x; + SCM entry, key, val; + entry = gh_car(alist); + if (!gh_pair_p(entry)) + SWIG_exception(SWIG_TypeError,"alist expected"); + key = gh_car(entry); + val = gh_cdr(entry); + if (!CHECK(key)) + SWIG_exception(SWIG_TypeError, + "map<" #K "," #T "> expected"); + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) != 0) { + if (!gh_pair_p(val)) + SWIG_exception(SWIG_TypeError,"alist expected"); + val = gh_car(val); + x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0); + } + temp[CONVERT_FROM(key)] = *x; + alist = gh_cdr(alist); + } + } else { + $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + } + %typemap(out) map<K,T> { + SCM alist = SCM_EOL; + for (std::map<K,T >::reverse_iterator i=$1.rbegin(); + i!=$1.rend(); ++i) { + T* val = new T(i->second); + SCM k = CONVERT_TO(i->first); + SCM x = SWIG_NewPointerObj(val,$descriptor(T *), 1); + SCM entry = gh_cons(k,x); + alist = gh_cons(entry,alist); + } + $result = alist; + } + %typecheck(SWIG_TYPECHECK_MAP) map<K,T> { + // native sequence? + if (gh_null_p($input)) { + /* an empty sequence can be of any type */ + $1 = 1; + } else if (gh_pair_p($input)) { + // check the first element only + T* x; + SCM head = gh_car($input); + if (gh_pair_p(head)) { + SCM key = gh_car(head); + SCM val = gh_cdr(head); + if (!CHECK(key)) { + $1 = 0; + } else { + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) == 0) { + $1 = 1; + } else if (gh_pair_p(val)) { + val = gh_car(val); + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) == 0) + $1 = 1; + else + $1 = 0; + } else { + $1 = 0; + } + } + } else { + $1 = 0; + } + } else { + // wrapped map? + std::map<K,T >* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $&1_descriptor, 0) == 0) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_MAP) const map<K,T>&, + const map<K,T>* { + // native sequence? + if (gh_null_p($input)) { + /* an empty sequence can be of any type */ + $1 = 1; + } else if (gh_pair_p($input)) { + // check the first element only + T* x; + SCM head = gh_car($input); + if (gh_pair_p(head)) { + SCM key = gh_car(head); + SCM val = gh_cdr(head); + if (!CHECK(key)) { + $1 = 0; + } else { + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) == 0) { + $1 = 1; + } else if (gh_pair_p(val)) { + val = gh_car(val); + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) == 0) + $1 = 1; + else + $1 = 0; + } else { + $1 = 0; + } + } + } else { + $1 = 0; + } + } else { + // wrapped map? + std::map<K,T >* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $1_descriptor, 0) == 0) + $1 = 1; + else + $1 = 0; + } + } + %rename("length") size; + %rename("null?") empty; + %rename("clear!") clear; + %rename("ref") __getitem__; + %rename("set!") __setitem__; + %rename("delete!") __delitem__; + %rename("has-key?") has_key; + public: + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + T& __getitem__(K key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void __setitem__(K key, const T& x) { + (*self)[key] = x; + } + void __delitem__(K key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(K key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + SCM keys() { + SCM result = SCM_EOL; + for (std::map<K,T >::reverse_iterator i=$1.rbegin(); + i!=$1.rend(); ++i) { + SCM k = CONVERT_TO(i->first); + result = gh_cons(k,result); + } + return result; + } + } + }; + %enddef + + %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) + template<class K> class map<K,T> { + %typemap(in) map<K,T> (std::map<K,T>* m) { + if (gh_null_p($input)) { + $1 = std::map<K,T >(); + } else if (gh_pair_p($input)) { + $1 = std::map<K,T >(); + SCM alist = $input; + while (!gh_null_p(alist)) { + K* k; + SCM entry, key, val; + entry = gh_car(alist); + if (!gh_pair_p(entry)) + SWIG_exception(SWIG_TypeError,"alist expected"); + key = gh_car(entry); + val = gh_cdr(entry); + k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0); + if (!CHECK(val)) { + if (!gh_pair_p(val)) + SWIG_exception(SWIG_TypeError,"alist expected"); + val = gh_car(val); + if (!CHECK(val)) + SWIG_exception(SWIG_TypeError, + "map<" #K "," #T "> expected"); + } + (($1_type &)$1)[*k] = CONVERT_FROM(val); + alist = gh_cdr(alist); + } + } else { + $1 = *(($&1_type) + SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); + } + } + %typemap(in) const map<K,T>& (std::map<K,T> temp, + std::map<K,T>* m), + const map<K,T>* (std::map<K,T> temp, + std::map<K,T>* m) { + if (gh_null_p($input)) { + temp = std::map<K,T >(); + $1 = &temp; + } else if (gh_pair_p($input)) { + temp = std::map<K,T >(); + $1 = &temp; + SCM alist = $input; + while (!gh_null_p(alist)) { + K* k; + SCM entry, key, val; + entry = gh_car(alist); + if (!gh_pair_p(entry)) + SWIG_exception(SWIG_TypeError,"alist expected"); + key = gh_car(entry); + val = gh_cdr(entry); + k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0); + if (!CHECK(val)) { + if (!gh_pair_p(val)) + SWIG_exception(SWIG_TypeError,"alist expected"); + val = gh_car(val); + if (!CHECK(val)) + SWIG_exception(SWIG_TypeError, + "map<" #K "," #T "> expected"); + } + temp[*k] = CONVERT_FROM(val); + alist = gh_cdr(alist); + } + } else { + $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + } + %typemap(out) map<K,T> { + SCM alist = SCM_EOL; + for (std::map<K,T >::reverse_iterator i=$1.rbegin(); + i!=$1.rend(); ++i) { + K* key = new K(i->first); + SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1); + SCM x = CONVERT_TO(i->second); + SCM entry = gh_cons(k,x); + alist = gh_cons(entry,alist); + } + $result = alist; + } + %typecheck(SWIG_TYPECHECK_MAP) map<K,T> { + // native sequence? + if (gh_null_p($input)) { + /* an empty sequence can be of any type */ + $1 = 1; + } else if (gh_pair_p($input)) { + // check the first element only + K* k; + SCM head = gh_car($input); + if (gh_pair_p(head)) { + SCM key = gh_car(head); + SCM val = gh_cdr(head); + if (SWIG_ConvertPtr(val,(void **) &k, + $descriptor(K *), 0) != 0) { + $1 = 0; + } else { + if (CHECK(val)) { + $1 = 1; + } else if (gh_pair_p(val)) { + val = gh_car(val); + if (CHECK(val)) + $1 = 1; + else + $1 = 0; + } else { + $1 = 0; + } + } + } else { + $1 = 0; + } + } else { + // wrapped map? + std::map<K,T >* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $&1_descriptor, 0) == 0) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_MAP) const map<K,T>&, + const map<K,T>* { + // native sequence? + if (gh_null_p($input)) { + /* an empty sequence can be of any type */ + $1 = 1; + } else if (gh_pair_p($input)) { + // check the first element only + K* k; + SCM head = gh_car($input); + if (gh_pair_p(head)) { + SCM key = gh_car(head); + SCM val = gh_cdr(head); + if (SWIG_ConvertPtr(val,(void **) &k, + $descriptor(K *), 0) != 0) { + $1 = 0; + } else { + if (CHECK(val)) { + $1 = 1; + } else if (gh_pair_p(val)) { + val = gh_car(val); + if (CHECK(val)) + $1 = 1; + else + $1 = 0; + } else { + $1 = 0; + } + } + } else { + $1 = 0; + } + } else { + // wrapped map? + std::map<K,T >* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $1_descriptor, 0) == 0) + $1 = 1; + else + $1 = 0; + } + } + %rename("length") size; + %rename("null?") empty; + %rename("clear!") clear; + %rename("ref") __getitem__; + %rename("set!") __setitem__; + %rename("delete!") __delitem__; + %rename("has-key?") has_key; + public: + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + T __getitem__(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void __setitem__(const K& key, T x) { + (*self)[key] = x; + } + void __delitem__(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(const K& key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + SCM keys() { + SCM result = SCM_EOL; + for (std::map<K,T >::reverse_iterator i=$1.rbegin(); + i!=$1.rend(); ++i) { + K* key = new K(i->first); + SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1); + result = gh_cons(k,result); + } + return result; + } + } + }; + %enddef + + %define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, + T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) + template<> class map<K,T> { + %typemap(in) map<K,T> (std::map<K,T>* m) { + if (gh_null_p($input)) { + $1 = std::map<K,T >(); + } else if (gh_pair_p($input)) { + $1 = std::map<K,T >(); + SCM alist = $input; + while (!gh_null_p(alist)) { + SCM entry, key, val; + entry = gh_car(alist); + if (!gh_pair_p(entry)) + SWIG_exception(SWIG_TypeError,"alist expected"); + key = gh_car(entry); + val = gh_cdr(entry); + if (!CHECK_K(key)) + SWIG_exception(SWIG_TypeError, + "map<" #K "," #T "> expected"); + if (!CHECK_T(val)) { + if (!gh_pair_p(val)) + SWIG_exception(SWIG_TypeError,"alist expected"); + val = gh_car(val); + if (!CHECK_T(val)) + SWIG_exception(SWIG_TypeError, + "map<" #K "," #T "> expected"); + } + (($1_type &)$1)[CONVERT_K_FROM(key)] = + CONVERT_T_FROM(val); + alist = gh_cdr(alist); + } + } else { + $1 = *(($&1_type) + SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); + } + } + %typemap(in) const map<K,T>& (std::map<K,T> temp, + std::map<K,T>* m), + const map<K,T>* (std::map<K,T> temp, + std::map<K,T>* m) { + if (gh_null_p($input)) { + temp = std::map<K,T >(); + $1 = &temp; + } else if (gh_pair_p($input)) { + temp = std::map<K,T >(); + $1 = &temp; + SCM alist = $input; + while (!gh_null_p(alist)) { + SCM entry, key, val; + entry = gh_car(alist); + if (!gh_pair_p(entry)) + SWIG_exception(SWIG_TypeError,"alist expected"); + key = gh_car(entry); + val = gh_cdr(entry); + if (!CHECK_K(key)) + SWIG_exception(SWIG_TypeError, + "map<" #K "," #T "> expected"); + if (!CHECK_T(val)) { + if (!gh_pair_p(val)) + SWIG_exception(SWIG_TypeError,"alist expected"); + val = gh_car(val); + if (!CHECK_T(val)) + SWIG_exception(SWIG_TypeError, + "map<" #K "," #T "> expected"); + } + temp[CONVERT_K_FROM(key)] = CONVERT_T_FROM(val); + alist = gh_cdr(alist); + } + } else { + $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + } + %typemap(out) map<K,T> { + SCM alist = SCM_EOL; + for (std::map<K,T >::reverse_iterator i=$1.rbegin(); + i!=$1.rend(); ++i) { + SCM k = CONVERT_K_TO(i->first); + SCM x = CONVERT_T_TO(i->second); + SCM entry = gh_cons(k,x); + alist = gh_cons(entry,alist); + } + $result = alist; + } + %typecheck(SWIG_TYPECHECK_MAP) map<K,T> { + // native sequence? + if (gh_null_p($input)) { + /* an empty sequence can be of any type */ + $1 = 1; + } else if (gh_pair_p($input)) { + // check the first element only + SCM head = gh_car($input); + if (gh_pair_p(head)) { + SCM key = gh_car(head); + SCM val = gh_cdr(head); + if (!CHECK_K(key)) { + $1 = 0; + } else { + if (CHECK_T(val)) { + $1 = 1; + } else if (gh_pair_p(val)) { + val = gh_car(val); + if (CHECK_T(val)) + $1 = 1; + else + $1 = 0; + } else { + $1 = 0; + } + } + } else { + $1 = 0; + } + } else { + // wrapped map? + std::map<K,T >* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $&1_descriptor, 0) == 0) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_MAP) const map<K,T>&, + const map<K,T>* { + // native sequence? + if (gh_null_p($input)) { + /* an empty sequence can be of any type */ + $1 = 1; + } else if (gh_pair_p($input)) { + // check the first element only + SCM head = gh_car($input); + if (gh_pair_p(head)) { + SCM key = gh_car(head); + SCM val = gh_cdr(head); + if (!CHECK_K(key)) { + $1 = 0; + } else { + if (CHECK_T(val)) { + $1 = 1; + } else if (gh_pair_p(val)) { + val = gh_car(val); + if (CHECK_T(val)) + $1 = 1; + else + $1 = 0; + } else { + $1 = 0; + } + } + } else { + $1 = 0; + } + } else { + // wrapped map? + std::map<K,T >* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $1_descriptor, 0) == 0) + $1 = 1; + else + $1 = 0; + } + } + %rename("length") size; + %rename("null?") empty; + %rename("clear!") clear; + %rename("ref") __getitem__; + %rename("set!") __setitem__; + %rename("delete!") __delitem__; + %rename("has-key?") has_key; + public: + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + T __getitem__(K key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void __setitem__(K key, T x) { + (*self)[key] = x; + } + void __delitem__(K key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(K key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + SCM keys() { + SCM result = SCM_EOL; + for (std::map<K,T >::reverse_iterator i=$1.rbegin(); + i!=$1.rend(); ++i) { + SCM k = CONVERT_K_TO(i->first); + result = gh_cons(k,result); + } + return result; + } + } + }; + %enddef + + + specialize_std_map_on_key(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_map_on_key(int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_key(short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_key(long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_key(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_key(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_key(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_key(double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_key(float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_key(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + + specialize_std_map_on_value(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_map_on_value(int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_value(short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_value(long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_value(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_value(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_value(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_value(double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_value(float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_value(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + + specialize_std_map_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_map_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_map_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_map_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_map_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_map_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_map_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_map_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_map_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_map_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_map_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_map_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_map_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_map_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_map_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_map_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_map_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_map_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_map_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_map_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_map_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_map_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_map_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); +} diff --git a/devtools/swigwin-1.3.34/Lib/guile/std_pair.i b/devtools/swigwin-1.3.34/Lib/guile/std_pair.i new file mode 100644 index 0000000..f8c2ea6 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/std_pair.i @@ -0,0 +1,871 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_pair.i + * + * SWIG typemaps for std::pair + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> +%include <exception.i> + +// ------------------------------------------------------------------------ +// std::pair +// +// See std_vector.i for the rationale of typemap application +// ------------------------------------------------------------------------ + +%{ +#include <utility> +%} + +// exported class + +namespace std { + + template<class T, class U> struct pair { + %typemap(in) pair<T,U> (std::pair<T,U>* m) { + if (gh_pair_p($input)) { + T* x; + U* y; + SCM first, second; + first = gh_car($input); + second = gh_cdr($input); + x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); + y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); + $1 = std::make_pair(*x,*y); + } else { + $1 = *(($&1_type) + SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); + } + } + %typemap(in) const pair<T,U>& (std::pair<T,U> temp, + std::pair<T,U>* m), + const pair<T,U>* (std::pair<T,U> temp, + std::pair<T,U>* m) { + if (gh_pair_p($input)) { + T* x; + U* y; + SCM first, second; + first = gh_car($input); + second = gh_cdr($input); + x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); + y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); + temp = std::make_pair(*x,*y); + $1 = &temp; + } else { + $1 = ($1_ltype) + SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + } + %typemap(out) pair<T,U> { + T* x = new T($1.first); + U* y = new U($1.second); + SCM first = SWIG_NewPointerObj(x,$descriptor(T *), 1); + SCM second = SWIG_NewPointerObj(y,$descriptor(U *), 1); + $result = gh_cons(first,second); + } + %typecheck(SWIG_TYPECHECK_PAIR) pair<T,U> { + /* native pair? */ + if (gh_pair_p($input)) { + T* x; + U* y; + SCM first = gh_car($input); + SCM second = gh_cdr($input); + if (SWIG_ConvertPtr(first,(void**) &x, + $descriptor(T *), 0) == 0 && + SWIG_ConvertPtr(second,(void**) &y, + $descriptor(U *), 0) == 0) { + $1 = 1; + } else { + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair<T,U >* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $&1_descriptor, 0) == 0) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_PAIR) const pair<T,U>&, + const pair<T,U>* { + /* native pair? */ + if (gh_pair_p($input)) { + T* x; + U* y; + SCM first = gh_car($input); + SCM second = gh_cdr($input); + if (SWIG_ConvertPtr(first,(void**) &x, + $descriptor(T *), 0) == 0 && + SWIG_ConvertPtr(second,(void**) &y, + $descriptor(U *), 0) == 0) { + $1 = 1; + } else { + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair<T,U >* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $1_descriptor, 0) == 0) + $1 = 1; + else + $1 = 0; + } + } + pair(); + pair(T first, U second); + pair(const pair& p); + + template <class U1, class U2> pair(const pair<U1, U2> &p); + + T first; + U second; + }; + + + // specializations for built-ins + + %define specialize_std_pair_on_first(T,CHECK,CONVERT_FROM,CONVERT_TO) + template<class U> struct pair<T,U> { + %typemap(in) pair<T,U> (std::pair<T,U>* m) { + if (gh_pair_p($input)) { + U* y; + SCM first, second; + first = gh_car($input); + second = gh_cdr($input); + if (!CHECK(first)) + SWIG_exception(SWIG_TypeError, + "map<" #T "," #U "> expected"); + y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); + $1 = std::make_pair(CONVERT_FROM(first),*y); + } else { + $1 = *(($&1_type) + SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); + } + } + %typemap(in) const pair<T,U>& (std::pair<T,U> temp, + std::pair<T,U>* m), + const pair<T,U>* (std::pair<T,U> temp, + std::pair<T,U>* m) { + if (gh_pair_p($input)) { + U* y; + SCM first, second; + first = gh_car($input); + second = gh_cdr($input); + if (!CHECK(first)) + SWIG_exception(SWIG_TypeError, + "map<" #T "," #U "> expected"); + y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); + temp = std::make_pair(CONVERT_FROM(first),*y); + $1 = &temp; + } else { + $1 = ($1_ltype) + SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + } + %typemap(out) pair<T,U> { + U* y = new U($1.second); + SCM second = SWIG_NewPointerObj(y,$descriptor(U *), 1); + $result = gh_cons(CONVERT_TO($1.first),second); + } + %typecheck(SWIG_TYPECHECK_PAIR) pair<T,U> { + /* native pair? */ + if (gh_pair_p($input)) { + U* y; + SCM first = gh_car($input); + SCM second = gh_cdr($input); + if (CHECK(first) && + SWIG_ConvertPtr(second,(void**) &y, + $descriptor(U *), 0) == 0) { + $1 = 1; + } else { + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair<T,U >* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $&1_descriptor, 0) == 0) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_PAIR) const pair<T,U>&, + const pair<T,U>* { + /* native pair? */ + if (gh_pair_p($input)) { + U* y; + SCM first = gh_car($input); + SCM second = gh_cdr($input); + if (CHECK(first) && + SWIG_ConvertPtr(second,(void**) &y, + $descriptor(U *), 0) == 0) { + $1 = 1; + } else { + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair<T,U >* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $1_descriptor, 0) == 0) + $1 = 1; + else + $1 = 0; + } + } + pair(); + pair(T first, U second); + pair(const pair& p); + + template <class U1, class U2> pair(const pair<U1, U2> &p); + + T first; + U second; + }; + %enddef + + %define specialize_std_pair_on_second(U,CHECK,CONVERT_FROM,CONVERT_TO) + template<class T> struct pair<T,U> { + %typemap(in) pair<T,U> (std::pair<T,U>* m) { + if (gh_pair_p($input)) { + T* x; + SCM first, second; + first = gh_car($input); + second = gh_cdr($input); + x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); + if (!CHECK(second)) + SWIG_exception(SWIG_TypeError, + "map<" #T "," #U "> expected"); + $1 = std::make_pair(*x,CONVERT_FROM(second)); + } else { + $1 = *(($&1_type) + SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); + } + } + %typemap(in) const pair<T,U>& (std::pair<T,U> temp, + std::pair<T,U>* m), + const pair<T,U>* (std::pair<T,U> temp, + std::pair<T,U>* m) { + if (gh_pair_p($input)) { + T* x; + SCM first, second; + first = gh_car($input); + second = gh_cdr($input); + x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); + if (!CHECK(second)) + SWIG_exception(SWIG_TypeError, + "map<" #T "," #U "> expected"); + temp = std::make_pair(*x,CONVERT_FROM(second)); + $1 = &temp; + } else { + $1 = ($1_ltype) + SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + } + %typemap(out) pair<T,U> { + T* x = new T($1.first); + SCM first = SWIG_NewPointerObj(x,$descriptor(T *), 1); + $result = gh_cons(first,CONVERT_TO($1.second)); + } + %typecheck(SWIG_TYPECHECK_PAIR) pair<T,U> { + /* native pair? */ + if (gh_pair_p($input)) { + T* x; + SCM first = gh_car($input); + SCM second = gh_cdr($input); + if (SWIG_ConvertPtr(first,(void**) &x, + $descriptor(T *), 0) == 0 && + CHECK(second)) { + $1 = 1; + } else { + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair<T,U >* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $&1_descriptor, 0) == 0) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_PAIR) const pair<T,U>&, + const pair<T,U>* { + /* native pair? */ + if (gh_pair_p($input)) { + T* x; + SCM first = gh_car($input); + SCM second = gh_cdr($input); + if (SWIG_ConvertPtr(first,(void**) &x, + $descriptor(T *), 0) == 0 && + CHECK(second)) { + $1 = 1; + } else { + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair<T,U >* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $1_descriptor, 0) == 0) + $1 = 1; + else + $1 = 0; + } + } + pair(); + pair(T first, U second); + pair(const pair& p); + + template <class U1, class U2> pair(const pair<U1, U2> &p); + + T first; + U second; + }; + %enddef + + %define specialize_std_pair_on_both(T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO, + U,CHECK_U,CONVERT_U_FROM,CONVERT_U_TO) + template<> struct pair<T,U> { + %typemap(in) pair<T,U> (std::pair<T,U>* m) { + if (gh_pair_p($input)) { + SCM first, second; + first = gh_car($input); + second = gh_cdr($input); + if (!CHECK_T(first) || !CHECK_U(second)) + SWIG_exception(SWIG_TypeError, + "map<" #T "," #U "> expected"); + $1 = std::make_pair(CONVERT_T_FROM(first), + CONVERT_U_FROM(second)); + } else { + $1 = *(($&1_type) + SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); + } + } + %typemap(in) const pair<T,U>& (std::pair<T,U> temp, + std::pair<T,U>* m), + const pair<T,U>* (std::pair<T,U> temp, + std::pair<T,U>* m) { + if (gh_pair_p($input)) { + SCM first, second; + first = gh_car($input); + second = gh_cdr($input); + if (!CHECK_T(first) || !CHECK_U(second)) + SWIG_exception(SWIG_TypeError, + "map<" #T "," #U "> expected"); + temp = std::make_pair(CONVERT_T_FROM(first), + CONVERT_U_FROM(second)); + $1 = &temp; + } else { + $1 = ($1_ltype) + SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + } + %typemap(out) pair<T,U> { + $result = gh_cons(CONVERT_T_TO($1.first), + CONVERT_U_TO($1.second)); + } + %typecheck(SWIG_TYPECHECK_PAIR) pair<T,U> { + /* native pair? */ + if (gh_pair_p($input)) { + SCM first = gh_car($input); + SCM second = gh_cdr($input); + if (CHECK_T(first) && CHECK_U(second)) { + $1 = 1; + } else { + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair<T,U >* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $&1_descriptor, 0) == 0) + $1 = 1; + else + $1 = 0; + } + } + %typecheck(SWIG_TYPECHECK_PAIR) const pair<T,U>&, + const pair<T,U>* { + /* native pair? */ + if (gh_pair_p($input)) { + SCM first = gh_car($input); + SCM second = gh_cdr($input); + if (CHECK_T(first) && CHECK_U(second)) { + $1 = 1; + } else { + $1 = 0; + } + } else { + /* wrapped pair? */ + std::pair<T,U >* m; + if (SWIG_ConvertPtr($input,(void **) &m, + $1_descriptor, 0) == 0) + $1 = 1; + else + $1 = 0; + } + } + pair(); + pair(T first, U second); + pair(const pair& p); + + template <class U1, class U2> pair(const pair<U1, U2> &p); + + T first; + U second; + }; + %enddef + + + specialize_std_pair_on_first(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_pair_on_first(int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_first(short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_first(long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_first(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_first(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_first(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_first(double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_first(float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_first(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + + specialize_std_pair_on_second(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_pair_on_second(int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_second(short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_second(long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_second(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_second(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_second(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_second(double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_second(float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_second(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + + specialize_std_pair_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_pair_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_pair_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_pair_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(int,gh_number_p, + gh_scm2long,gh_long2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_pair_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_pair_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(short,gh_number_p, + gh_scm2long,gh_long2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_pair_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_pair_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(long,gh_number_p, + gh_scm2long,gh_long2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_pair_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_pair_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_pair_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_pair_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_pair_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_pair_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_pair_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_pair_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(double,gh_number_p, + gh_scm2double,gh_double2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_pair_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_pair_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(float,gh_number_p, + gh_scm2double,gh_double2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); + specialize_std_pair_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + bool,gh_boolean_p, + gh_scm2bool,SWIG_bool2scm); + specialize_std_pair_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + int,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + short,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + long,gh_number_p, + gh_scm2long,gh_long2scm); + specialize_std_pair_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + unsigned int,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + unsigned short,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + unsigned long,gh_number_p, + gh_scm2ulong,gh_ulong2scm); + specialize_std_pair_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + double,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + float,gh_number_p, + gh_scm2double,gh_double2scm); + specialize_std_pair_on_both(std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm, + std::string,gh_string_p, + SWIG_scm2string,SWIG_string2scm); +} diff --git a/devtools/swigwin-1.3.34/Lib/guile/std_string.i b/devtools/swigwin-1.3.34/Lib/guile/std_string.i new file mode 100644 index 0000000..f80a65c --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/std_string.i @@ -0,0 +1,90 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_string.i + * + * SWIG typemaps for std::string + * ----------------------------------------------------------------------------- */ + +// ------------------------------------------------------------------------ +// std::string is typemapped by value +// This can prevent exporting methods which return a string +// in order for the user to modify it. +// However, I think I'll wait until someone asks for it... +// ------------------------------------------------------------------------ + +%include <exception.i> + +%{ +#include <string> +%} + +namespace std { + + %naturalvar string; + + class string; + + %typemap(typecheck) string = char *; + %typemap(typecheck) const string & = char *; + + %typemap(in) string (char* tempptr) { + if (gh_string_p($input)) { + tempptr = SWIG_scm2str($input); + $1.assign(tempptr); + if (tempptr) SWIG_free(tempptr); + } else { + SWIG_exception(SWIG_TypeError, "string expected"); + } + } + + %typemap(in) const string & (std::string temp, + char* tempptr) { + if (gh_string_p($input)) { + tempptr = SWIG_scm2str($input); + temp.assign(tempptr); + if (tempptr) SWIG_free(tempptr); + $1 = &temp; + } else { + SWIG_exception(SWIG_TypeError, "string expected"); + } + } + + %typemap(in) string * (char* tempptr) { + if (gh_string_p($input)) { + tempptr = SWIG_scm2str($input); + $1 = new std::string(tempptr); + if (tempptr) SWIG_free(tempptr); + } else { + SWIG_exception(SWIG_TypeError, "string expected"); + } + } + + %typemap(out) string { + $result = gh_str02scm($1.c_str()); + } + + %typemap(out) const string & { + $result = gh_str02scm($1->c_str()); + } + + %typemap(out) string * { + $result = gh_str02scm($1->c_str()); + } + + %typemap(varin) string { + if (gh_string_p($input)) { + char *tempptr = SWIG_scm2str($input); + $1.assign(tempptr); + if (tempptr) SWIG_free(tempptr); + } else { + SWIG_exception(SWIG_TypeError, "string expected"); + } + } + + %typemap(varout) string { + $result = gh_str02scm($1.c_str()); + } + +} diff --git a/devtools/swigwin-1.3.34/Lib/guile/std_vector.i b/devtools/swigwin-1.3.34/Lib/guile/std_vector.i new file mode 100644 index 0000000..145db94 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/std_vector.i @@ -0,0 +1,413 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_vector.i + * + * SWIG typemaps for std::vector + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> + +// ------------------------------------------------------------------------ +// std::vector +// +// The aim of all that follows would be to integrate std::vector with +// Guile as much as possible, namely, to allow the user to pass and +// be returned Guile vectors or lists. +// const declarations are used to guess the intent of the function being +// exported; therefore, the following rationale is applied: +// +// -- f(std::vector<T>), f(const std::vector<T>&), f(const std::vector<T>*): +// the parameter being read-only, either a Guile sequence or a +// previously wrapped std::vector<T> can be passed. +// -- f(std::vector<T>&), f(std::vector<T>*): +// the parameter must be modified; therefore, only a wrapped std::vector +// can be passed. +// -- std::vector<T> f(): +// the vector is returned by copy; therefore, a Guile vector of T:s +// is returned which is most easily used in other Guile functions +// -- std::vector<T>& f(), std::vector<T>* f(), const std::vector<T>& f(), +// const std::vector<T>* f(): +// the vector is returned by reference; therefore, a wrapped std::vector +// is returned +// ------------------------------------------------------------------------ + +%{ +#include <vector> +#include <algorithm> +#include <stdexcept> +%} + +// exported class + +namespace std { + + template<class T> class vector { + %typemap(in) vector<T> { + if (gh_vector_p($input)) { + unsigned long size = gh_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)); + (($1_type &)$1)[i] = + *((T*) SWIG_MustGetPtr(o,$descriptor(T *),$argnum, 0)); + } + } else if (gh_null_p($input)) { + $1 = std::vector<T >(); + } else if (gh_pair_p($input)) { + SCM head, tail; + $1 = std::vector<T >(); + tail = $input; + while (!gh_null_p(tail)) { + head = gh_car(tail); + tail = gh_cdr(tail); + $1.push_back(*((T*)SWIG_MustGetPtr(head, + $descriptor(T *), + $argnum, 0))); + } + } else { + $1 = *(($&1_type) + SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); + } + } + %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); + temp = std::vector<T >(size); + $1 = &temp; + for (unsigned long i=0; i<size; i++) { + SCM o = gh_vector_ref($input,gh_ulong2scm(i)); + temp[i] = *((T*) SWIG_MustGetPtr(o, + $descriptor(T *), + $argnum, 0)); + } + } else if (gh_null_p($input)) { + temp = std::vector<T >(); + $1 = &temp; + } else if (gh_pair_p($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); + temp.push_back(*((T*) SWIG_MustGetPtr(head, + $descriptor(T *), + $argnum, 0))); + } + } else { + $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + } + %typemap(out) vector<T> { + $result = gh_make_vector(gh_long2scm($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), + 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 (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)); + T* x; + if (SWIG_ConvertPtr(o,(void**) &x, + $descriptor(T *), 0) != -1) + $1 = 1; + else + $1 = 0; + } + } else if (gh_null_p($input)) { + /* again, an empty sequence can be of any type */ + $1 = 1; + } else if (gh_pair_p($input)) { + /* check the first element only */ + T* x; + SCM head = gh_car($input); + if (SWIG_ConvertPtr(head,(void**) &x, + $descriptor(T *), 0) != -1) + $1 = 1; + else + $1 = 0; + } else { + /* wrapped vector? */ + std::vector<T >* v; + if (SWIG_ConvertPtr($input,(void **) &v, + $&1_descriptor, 0) != -1) + $1 = 1; + else + $1 = 0; + } + } + %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 (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)); + if (SWIG_ConvertPtr(o,(void**) &x, + $descriptor(T *), 0) != -1) + $1 = 1; + else + $1 = 0; + } + } else if (gh_null_p($input)) { + /* again, an empty sequence can be of any type */ + $1 = 1; + } else if (gh_pair_p($input)) { + /* check the first element only */ + T* x; + SCM head = gh_car($input); + if (SWIG_ConvertPtr(head,(void**) &x, + $descriptor(T *), 0) != -1) + $1 = 1; + else + $1 = 0; + } else { + /* wrapped vector? */ + std::vector<T >* v; + if (SWIG_ConvertPtr($input,(void **) &v, + $1_descriptor, 0) != -1) + $1 = 1; + else + $1 = 0; + } + } + public: + vector(unsigned int size = 0); + vector(unsigned int size, const T& value); + vector(const vector<T>&); + %rename(length) size; + unsigned int size() const; + %rename("empty?") empty; + bool empty() const; + %rename("clear!") clear; + void clear(); + %rename("set!") set; + %rename("pop!") pop; + %rename("push!") push_back; + void push_back(const T& x); + %extend { + T pop() throw (std::out_of_range) { + if (self->size() == 0) + throw std::out_of_range("pop from empty vector"); + T x = self->back(); + self->pop_back(); + return x; + } + T& ref(int i) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + return (*self)[i]; + else + throw std::out_of_range("vector index out of range"); + } + void set(int i, const T& x) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + (*self)[i] = x; + else + throw std::out_of_range("vector index out of range"); + } + } + }; + + + // specializations for built-ins + %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); + $1 = std::vector<T >(size); + for (unsigned long i=0; i<size; i++) { + SCM o = gh_vector_ref($input,gh_ulong2scm(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)) { + $1 = std::vector<T >(); + } else if (gh_pair_p($input)) { + SCM v = gh_list_to_vector($input); + unsigned long size = gh_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)); + if (CHECK(o)) + (($1_type &)$1)[i] = (T)(CONVERT_FROM(o)); + else + scm_wrong_type_arg(FUNC_NAME, $argnum, $input); + } + } else { + $1 = *(($&1_type) + SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); + } + } + %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); + temp = std::vector<T >(size); + $1 = &temp; + for (unsigned long i=0; i<size; i++) { + SCM o = gh_vector_ref($input,gh_ulong2scm(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)) { + 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); + temp = std::vector<T >(size); + $1 = &temp; + for (unsigned long i=0; i<size; i++) { + SCM o = gh_vector_ref(v,gh_ulong2scm(i)); + if (CHECK(o)) + temp[i] = (T)(CONVERT_FROM(o)); + else + scm_wrong_type_arg(FUNC_NAME, $argnum, $input); + } + } else { + $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + } + %typemap(out) vector<T> { + $result = gh_make_vector(gh_long2scm($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); + } + } + %typecheck(SWIG_TYPECHECK_VECTOR) vector<T> { + /* native sequence? */ + if (gh_vector_p($input)) { + unsigned int size = gh_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)); + $1 = CHECK(o) ? 1 : 0; + } + } else if (gh_null_p($input)) { + /* again, an empty sequence can be of any type */ + $1 = 1; + } else if (gh_pair_p($input)) { + /* check the first element only */ + T* x; + SCM head = gh_car($input); + $1 = CHECK(head) ? 1 : 0; + } else { + /* wrapped vector? */ + std::vector<T >* v; + $1 = (SWIG_ConvertPtr($input,(void **) &v, + $&1_descriptor, 0) != -1) ? 1 : 0; + } + } + %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 (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)); + $1 = CHECK(o) ? 1 : 0; + } + } else if (gh_null_p($input)) { + /* again, an empty sequence can be of any type */ + $1 = 1; + } else if (gh_pair_p($input)) { + /* check the first element only */ + T* x; + SCM head = gh_car($input); + $1 = CHECK(head) ? 1 : 0; + } else { + /* wrapped vector? */ + std::vector<T >* v; + $1 = (SWIG_ConvertPtr($input,(void **) &v, + $1_descriptor, 0) != -1) ? 1 : 0; + } + } + public: + vector(unsigned int size = 0); + vector(unsigned int size, const T& value); + vector(const vector<T>&); + %rename(length) size; + unsigned int size() const; + %rename("empty?") empty; + bool empty() const; + %rename("clear!") clear; + void clear(); + %rename("set!") set; + %rename("pop!") pop; + %rename("push!") push_back; + void push_back(T x); + %extend { + T pop() throw (std::out_of_range) { + if (self->size() == 0) + throw std::out_of_range("pop from empty vector"); + T x = self->back(); + self->pop_back(); + return x; + } + T ref(int i) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + return (*self)[i]; + else + throw std::out_of_range("vector index out of range"); + } + void set(int i, T x) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && i<size) + (*self)[i] = x; + else + throw std::out_of_range("vector index out of range"); + } + } + }; + %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); +} + diff --git a/devtools/swigwin-1.3.34/Lib/guile/stl.i b/devtools/swigwin-1.3.34/Lib/guile/stl.i new file mode 100644 index 0000000..66b72e0 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/stl.i @@ -0,0 +1,15 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * stl.i + * + * Initial STL definition. extended as needed in each language + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> +%include <std_string.i> +%include <std_vector.i> +%include <std_map.i> +%include <std_pair.i> + diff --git a/devtools/swigwin-1.3.34/Lib/guile/swigrun.i b/devtools/swigwin-1.3.34/Lib/guile/swigrun.i new file mode 100644 index 0000000..4b9ea2c --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/swigrun.i @@ -0,0 +1,49 @@ +/* -*- mode: c -*- */ + +%module swigrun + +#ifdef SWIGGUILE_SCM + +/* Hook the runtime module initialization + into the shared initialization function SWIG_Guile_Init. */ +%runtime %{ +/* Hook the runtime module initialization + into the shared initialization function SWIG_Guile_Init. */ +#include <libguile.h> +#ifdef __cplusplus +extern "C" +#endif +SCM scm_init_Swig_swigrun_module (void); +#define SWIG_INIT_RUNTIME_MODULE scm_init_Swig_swigrun_module(); +%} + +/* The runtime type system from common.swg */ + +typedef struct swig_type_info swig_type_info; + +const char * +SWIG_TypeName(const swig_type_info *type); + +const char * +SWIG_TypePrettyName(const swig_type_info *type); + +swig_type_info * +SWIG_TypeQuery(const char *); + +/* Language-specific stuff */ + +%apply bool { int }; + +int +SWIG_IsPointer(SCM object); + +int +SWIG_IsPointerOfType(SCM object, swig_type_info *type); + +unsigned long +SWIG_PointerAddress(SCM object); + +swig_type_info * +SWIG_PointerType(SCM object); + +#endif diff --git a/devtools/swigwin-1.3.34/Lib/guile/typemaps.i b/devtools/swigwin-1.3.34/Lib/guile/typemaps.i new file mode 100644 index 0000000..c088cca --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/guile/typemaps.i @@ -0,0 +1,454 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * typemaps.i + * + * Guile-specific typemaps + * ----------------------------------------------------------------------------- */ + +/* Pointers */ + +%typemap(in) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] { + $1 = ($1_ltype)SWIG_MustGetPtr($input, $descriptor, $argnum, 0); +} +%typemap(freearg) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] ""; + +%typemap(in) void * { + $1 = ($1_ltype)SWIG_MustGetPtr($input, NULL, $argnum, 0); +} +%typemap(freearg) void * ""; + +%typemap(varin) SWIGTYPE * { + $1 = ($1_ltype)SWIG_MustGetPtr($input, $descriptor, 1, 0); +} + +%typemap(varin) SWIGTYPE & { + $1 = *(($1_ltype)SWIG_MustGetPtr($input, $descriptor, 1, 0)); +} + +%typemap(varin) SWIGTYPE [] { + scm_wrong_type_arg((char *) FUNC_NAME, 1, $input); +} + +%typemap(varin) SWIGTYPE [ANY] { + void *temp; + int ii; + $1_basetype *b = 0; + temp = SWIG_MustGetPtr($input, $1_descriptor, 1, 0); + b = ($1_basetype *) $1; + for (ii = 0; ii < $1_size; ii++) b[ii] = *(($1_basetype *) temp + ii); +} + +%typemap(varin) void * { + $1 = SWIG_MustGetPtr($input, NULL, 1, 0); +} + +%typemap(out) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] { + $result = SWIG_NewPointerObj ($1, $descriptor, $owner); +} + +%typemap(out) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC { + swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor,(void **) &$1); + $result = SWIG_NewPointerObj ($1, ty, $owner); +} + +%typemap(varout) SWIGTYPE *, SWIGTYPE [] { + $result = SWIG_NewPointerObj ($1, $descriptor, 0); +} + +%typemap(varout) SWIGTYPE & { + $result = SWIG_NewPointerObj((void *) &$1, $1_descriptor, 0); +} + +%typemap(throws) SWIGTYPE { + $<ype temp = new $ltype($1); + scm_throw(gh_symbol2scm((char *) "swig-exception"), + gh_list(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_UNDEFINED)); +} + +%typemap(throws) SWIGTYPE * { + scm_throw(gh_symbol2scm((char *) "swig-exception"), + gh_list(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_UNDEFINED)); +} + +/* Change of object ownership, and interaction of destructor-like functions and the + garbage-collector */ + +%typemap(in, doc="$NAME is of type <$type> and gets destroyed by the function") SWIGTYPE *DESTROYED { + $1 = ($1_ltype)SWIG_MustGetPtr($input, $descriptor, $argnum, 0); +} + +%typemap(freearg) SWIGTYPE *DESTROYED { + SWIG_Guile_MarkPointerDestroyed($input); +} + +%typemap(in, doc="$NAME is of type <$type> and is consumed by the function") SWIGTYPE *CONSUMED { + $1 = ($1_ltype)SWIG_MustGetPtr($input, $descriptor, $argnum, 0); + SWIG_Guile_MarkPointerNoncollectable($input); +} + +/* Pass-by-value */ + +%typemap(in) SWIGTYPE($&1_ltype argp) { + argp = ($&1_ltype)SWIG_MustGetPtr($input, $&1_descriptor, $argnum, 0); + $1 = *argp; +} + +%typemap(varin) SWIGTYPE { + $&1_ltype argp; + argp = ($&1_ltype)SWIG_MustGetPtr($input, $&1_descriptor, 1, 0); + $1 = *argp; +} + +%typemap(out) SWIGTYPE +#ifdef __cplusplus +{ + $&1_ltype resultptr; + resultptr = new $1_ltype(($1_ltype &) $1); + $result = SWIG_NewPointerObj (resultptr, $&1_descriptor, 1); +} +#else +{ + $&1_ltype resultptr; + resultptr = ($&1_ltype) malloc(sizeof($1_type)); + memmove(resultptr, &$1, sizeof($1_type)); + $result = SWIG_NewPointerObj(resultptr, $&1_descriptor, 1); +} +#endif + +%typemap(varout) SWIGTYPE +#ifdef __cplusplus +{ + $&1_ltype resultptr; + resultptr = new $1_ltype(($1_ltype&) $1); + $result = SWIG_NewPointerObj (resultptr, $&1_descriptor, 0); +} +#else +{ + $&1_ltype resultptr; + resultptr = ($&1_ltype) malloc(sizeof($1_type)); + memmove(resultptr, &$1, sizeof($1_type)); + $result = SWIG_NewPointerObj(resultptr, $&1_descriptor, 0); +} +#endif + +/* Enums */ + +%typemap(in) enum SWIGTYPE { $1 = ($1_type) gh_scm2int($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"), + (char *) FUNC_NAME, + (char *) "enum variable '$name' cannot be set", + SCM_EOL, SCM_BOOL_F); + } + * (int *) &($1) = gh_scm2int($input); +} +%typemap(out) enum SWIGTYPE { $result = gh_int2scm($1); } +%typemap(varout) enum SWIGTYPE { $result = gh_int2scm($1); } +%typemap(throws) enum SWIGTYPE { + scm_throw(gh_symbol2scm((char *) "swig-exception"), + gh_list(gh_int2scm($1), SCM_UNDEFINED)); +} + +/* The SIMPLE_MAP_WITH_EXPR macro below defines the whole set of + typemaps needed for simple types. + -- SCM_TO_C_EXPR is a C expression that translates the Scheme value + "swig_scm_value" to a C value. + -- C_TO_SCM_EXPR is a C expression that translates the C value + "swig_c_value" to a Scheme value. */ + +%define SIMPLE_MAP_WITH_EXPR(C_NAME, SCM_TO_C_EXPR, C_TO_SCM_EXPR, SCM_NAME) + %typemap (in, doc="$NAME is of type <" #SCM_NAME ">") C_NAME + { SCM swig_scm_value = $input; + $1 = SCM_TO_C_EXPR; } + %typemap (varin, doc="NEW-VALUE is of type <" #SCM_NAME ">") C_NAME + { SCM swig_scm_value = $input; + $1 = SCM_TO_C_EXPR; } + %typemap (out, doc="<" #SCM_NAME ">") C_NAME + { C_NAME swig_c_value = $1; + $result = C_TO_SCM_EXPR; } + %typemap (varout, doc="<" #SCM_NAME ">") C_NAME + { C_NAME swig_c_value = $1; + $result = C_TO_SCM_EXPR; } + /* INPUT and OUTPUT */ + %typemap (in, doc="$NAME is of type <" #SCM_NAME ">)") + C_NAME *INPUT(C_NAME temp) { + SCM swig_scm_value = $input; + temp = (C_NAME) SCM_TO_C_EXPR; $1 = &temp; } + %typemap (in,numinputs=0) C_NAME *OUTPUT (C_NAME temp) + {$1 = &temp;} + %typemap (argout,doc="$name (of type <" #SCM_NAME ">)") C_NAME *OUTPUT + { C_NAME swig_c_value = *$1; + SWIG_APPEND_VALUE(C_TO_SCM_EXPR); } + %typemap (in) C_NAME *BOTH = C_NAME *INPUT; + %typemap (argout) C_NAME *BOTH = C_NAME *OUTPUT; + %typemap (in) C_NAME *INOUT = C_NAME *INPUT; + %typemap (argout) C_NAME *INOUT = C_NAME *OUTPUT; + /* Const primitive references. Passed by value */ + %typemap(in, doc="$NAME is of type <" #SCM_NAME ">") const C_NAME & (C_NAME temp) + { SCM swig_scm_value = $input; + temp = SCM_TO_C_EXPR; + $1 = &temp; } + %typemap(out, doc="<" #SCM_NAME ">") const C_NAME & + { C_NAME swig_c_value = *$1; + $result = C_TO_SCM_EXPR; } + /* 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)); + } +%enddef + +/* The SIMPLE_MAP macro below defines the whole set of typemaps needed + for simple types. It generates slightly simpler code than the + macro above, but it is only suitable for very simple conversion + expressions. */ + +%define SIMPLE_MAP(C_NAME, SCM_TO_C, C_TO_SCM, SCM_NAME) + %typemap (in, doc="$NAME is of type <" #SCM_NAME ">") + C_NAME {$1 = ($1_ltype) SCM_TO_C($input);} + %typemap (varin, doc="NEW-VALUE is of type <" #SCM_NAME ">") + C_NAME {$1 = ($1_ltype) SCM_TO_C($input);} + %typemap (out, doc="<" #SCM_NAME ">") + C_NAME {$result = C_TO_SCM($1);} + %typemap (varout, doc="<" #SCM_NAME ">") + C_NAME {$result = C_TO_SCM($1);} + /* INPUT and OUTPUT */ + %typemap (in, doc="$NAME is of type <" #SCM_NAME ">)") + C_NAME *INPUT(C_NAME temp), C_NAME &INPUT(C_NAME temp) { + temp = (C_NAME) SCM_TO_C($input); $1 = &temp; + } + %typemap (in,numinputs=0) C_NAME *OUTPUT (C_NAME temp), C_NAME &OUTPUT(C_NAME temp) + {$1 = &temp;} + %typemap (argout,doc="$name (of type <" #SCM_NAME ">)") C_NAME *OUTPUT, C_NAME &OUTPUT + {SWIG_APPEND_VALUE(C_TO_SCM(*$1));} + %typemap (in) C_NAME *BOTH = C_NAME *INPUT; + %typemap (argout) C_NAME *BOTH = C_NAME *OUTPUT; + %typemap (in) C_NAME *INOUT = C_NAME *INPUT; + %typemap (argout) C_NAME *INOUT = C_NAME *OUTPUT; + %typemap (in) C_NAME &INOUT = C_NAME &INPUT; + %typemap (argout) C_NAME &INOUT = C_NAME &OUTPUT; + /* Const primitive references. Passed by value */ + %typemap(in, doc="$NAME is of type <" #SCM_NAME ">") const C_NAME & (C_NAME temp) { + temp = SCM_TO_C($input); + $1 = ($1_ltype) &temp; + } + %typemap(out, doc="<" #SCM_NAME ">") const C_NAME & { + $result = C_TO_SCM(*$1); + } + /* Throw typemap */ + %typemap(throws) C_NAME { + scm_throw(gh_symbol2scm((char *) "swig-exception"), + gh_list(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); + +/* 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); + +/* Strings */ + + %typemap (in, doc="$NAME is a string") char *(int must_free = 0) { + $1 = ($1_ltype)SWIG_scm2str($input); + 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 (in, doc="$NAME is a string") char * *INPUT(char * temp, int must_free = 0) { + temp = (char *) SWIG_scm2str($input); $1 = &temp; + must_free = 1; + } + %typemap (in,numinputs=0) char * *OUTPUT (char * temp) + {$1 = &temp;} + %typemap (argout,doc="$NAME (a string)") char * *OUTPUT + {SWIG_APPEND_VALUE(gh_str02scm(*$1));} + %typemap (in) char * *BOTH = char * *INPUT; + %typemap (argout) char * *BOTH = char * *OUTPUT; + %typemap (in) char * *INOUT = char * *INPUT; + %typemap (argout) char * *INOUT = char * *OUTPUT; + +/* SWIG_scm2str makes a malloc'ed copy of the string, so get rid of it after + the function call. */ + +%typemap (freearg) char * "if (must_free$argnum && $1) SWIG_free($1);"; +%typemap (freearg) char **INPUT, char **BOTH "if (must_free$argnum && (*$1)) SWIG_free(*$1);" +%typemap (freearg) char **OUTPUT "SWIG_free(*$1);" + +/* But this shall not apply if we try to pass a single char by + reference. */ + +%typemap (freearg) char *OUTPUT, char *BOTH ""; + +/* If we set a string variable, delete the old result first, unless const. */ + +%typemap (varin) char * { + if ($1) free($1); + $1 = ($1_ltype) SWIG_scm2str($input); +} + +%typemap (varin) const char * { + $1 = ($1_ltype) SWIG_scm2str($input); +} + +%typemap(throws) char * { + scm_throw(gh_symbol2scm((char *) "swig-exception"), + gh_list(gh_str02scm($1), SCM_UNDEFINED)); +} + +/* Void */ + +%typemap (out,doc="") void "gswig_result = SCM_UNSPECIFIED;"; + +/* SCM is passed through */ + +typedef unsigned long SCM; +%typemap (in) SCM "$1=$input;"; +%typemap (out) SCM "$result=$1;"; +%typecheck(SWIG_TYPECHECK_POINTER) SCM "$1=1;"; + +/* ------------------------------------------------------------ + * String & length + * ------------------------------------------------------------ */ + +%typemap(in) (char *STRING, int LENGTH) { + size_t temp; + $1 = ($1_ltype) gh_scm2newstr($input, &temp); + $2 = ($2_ltype) temp; +} + +/* ------------------------------------------------------------ + * CLASS::* (member function pointer) typemaps + * taken from typemaps/swigtype.swg + * ------------------------------------------------------------ */ + +#define %set_output(obj) $result = obj +#define %set_varoutput(obj) $result = obj +#define %argument_fail(code, type, name, argn) scm_wrong_type_arg((char *) FUNC_NAME, argn, $input); +#define %as_voidptr(ptr) (void*)(ptr) + +%typemap(in) SWIGTYPE (CLASS::*) { + int res = SWIG_ConvertMember($input, %as_voidptr(&$1), sizeof($type),$descriptor); + if (!SWIG_IsOK(res)) { + %argument_fail(res,"$type",$symname, $argnum); + } +} + +%typemap(out,noblock=1) SWIGTYPE (CLASS::*) { + %set_output(SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($type), $descriptor)); +} + +%typemap(varin) SWIGTYPE (CLASS::*) { + int res = SWIG_ConvertMember($input,%as_voidptr(&$1), sizeof($type), $descriptor); + if (!SWIG_IsOK(res)) { + scm_wrong_type_arg((char *) FUNC_NAME, 1, $input); + } +} + +%typemap(varout,noblock=1) SWIGTYPE (CLASS::*) { + %set_varoutput(SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($type), $descriptor)); +} + +/* ------------------------------------------------------------ + * Typechecking rules + * ------------------------------------------------------------ */ + +/* adapted from python.swg */ + +%typecheck(SWIG_TYPECHECK_INTEGER) + int, short, long, + unsigned int, unsigned short, unsigned long, + signed char, unsigned char, + long long, unsigned long long, + size_t, ptrdiff_t, + std::size_t, std::ptrdiff_t, + const int &, const short &, const long &, + const unsigned int &, const unsigned short &, const unsigned long &, + const long long &, const unsigned long long &, + const size_t &, const ptrdiff_t &, + const std::size_t &, const std::ptrdiff_t &, + enum SWIGTYPE +{ + $1 = SCM_NFALSEP(scm_integer_p($input)) ? 1 : 0; +} + +%typecheck(SWIG_TYPECHECK_BOOL) + bool, bool&, const bool& +{ + $1 = SCM_BOOLP($input) ? 1 : 0; +} + +%typecheck(SWIG_TYPECHECK_DOUBLE) + float, double, + const float &, const double & +{ + $1 = SCM_NFALSEP(scm_real_p($input)) ? 1 : 0; +} + +%typecheck(SWIG_TYPECHECK_CHAR) char { + $1 = SCM_CHARP($input) ? 1 : 0; +} + +%typecheck(SWIG_TYPECHECK_STRING) char * { + $1 = SCM_STRINGP($input) ? 1 : 0; +} + +%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] { + void *ptr; + int res = SWIG_ConvertPtr($input, &ptr, $1_descriptor, 0); + $1 = SWIG_CheckState(res); +} + +%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE { + void *ptr; + int res = SWIG_ConvertPtr($input, &ptr, $&descriptor, 0); + $1 = SWIG_CheckState(res); +} + +%typecheck(SWIG_TYPECHECK_VOIDPTR) void * { + void *ptr; + int res = SWIG_ConvertPtr($input, &ptr, 0, 0); + $1 = SWIG_CheckState(res); +} + +/* typemaps.i ends here */ |