diff options
author | Vince Harron <vharron@google.com> | 2015-06-02 18:58:48 -0700 |
---|---|---|
committer | Vince Harron <vharron@google.com> | 2015-06-02 18:58:48 -0700 |
commit | b46a6ee1ee38582dd3af57ebe1b6d5e4158c34e0 (patch) | |
tree | b342a62eea47f607a7c0846c731bf151c1503359 /share/swig/2.0.11/guile | |
parent | 6c85ed3bdac5c6dd65ad8cef83fc4fc7ef99a6c9 (diff) | |
download | linux-x86-studio-1.4-dev.tar.gz |
Adding binaries for 2.0.11HEADstudio-master-dev_before_27917934studio-master-dev_before_26911779studio-3.1.2studio-2.3studio-2.0-rc1studio-2.0studio-1.5studio-1.4gradle_3.1.2gradle_2.3.0gradle_2.0.0studio-master-releasestudio-1.4-releasestudio-1.4-devstudio-1.3-releasestudio-1.3-devmastermain
Diffstat (limited to 'share/swig/2.0.11/guile')
-rw-r--r-- | share/swig/2.0.11/guile/common.scm | 70 | ||||
-rw-r--r-- | share/swig/2.0.11/guile/cplusplus.i | 22 | ||||
-rw-r--r-- | share/swig/2.0.11/guile/guile.i | 33 | ||||
-rw-r--r-- | share/swig/2.0.11/guile/guile_scm.swg | 45 | ||||
-rw-r--r-- | share/swig/2.0.11/guile/guile_scm_run.swg | 504 | ||||
-rw-r--r-- | share/swig/2.0.11/guile/guilemain.i | 44 | ||||
-rw-r--r-- | share/swig/2.0.11/guile/interpreter.i | 59 | ||||
-rw-r--r-- | share/swig/2.0.11/guile/list-vector.i | 488 | ||||
-rw-r--r-- | share/swig/2.0.11/guile/pointer-in-out.i | 102 | ||||
-rw-r--r-- | share/swig/2.0.11/guile/ports.i | 50 | ||||
-rw-r--r-- | share/swig/2.0.11/guile/std_common.i | 24 | ||||
-rw-r--r-- | share/swig/2.0.11/guile/std_deque.i | 1 | ||||
-rw-r--r-- | share/swig/2.0.11/guile/std_except.i | 12 | ||||
-rw-r--r-- | share/swig/2.0.11/guile/std_map.i | 1352 | ||||
-rw-r--r-- | share/swig/2.0.11/guile/std_pair.i | 863 | ||||
-rw-r--r-- | share/swig/2.0.11/guile/std_string.i | 86 | ||||
-rw-r--r-- | share/swig/2.0.11/guile/std_vector.i | 410 | ||||
-rw-r--r-- | share/swig/2.0.11/guile/stl.i | 12 | ||||
-rw-r--r-- | share/swig/2.0.11/guile/swigrun.i | 49 | ||||
-rw-r--r-- | share/swig/2.0.11/guile/typemaps.i | 457 |
20 files changed, 4683 insertions, 0 deletions
diff --git a/share/swig/2.0.11/guile/common.scm b/share/swig/2.0.11/guile/common.scm new file mode 100644 index 0000000..17c9ab5 --- /dev/null +++ b/share/swig/2.0.11/guile/common.scm @@ -0,0 +1,70 @@ +;;;************************************************************************ +;;;*common.scm +;;;* +;;;* This file contains generic SWIG GOOPS classes for generated +;;;* GOOPS file support +;;;************************************************************************ + +(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/share/swig/2.0.11/guile/cplusplus.i b/share/swig/2.0.11/guile/cplusplus.i new file mode 100644 index 0000000..d5d65ef --- /dev/null +++ b/share/swig/2.0.11/guile/cplusplus.i @@ -0,0 +1,22 @@ +/* ----------------------------------------------------------------------------- + * cplusplus.i + * + * SWIG typemaps for C++ + * ----------------------------------------------------------------------------- */ + +%typemap(guile,out) string, std::string { + $result = SWIG_str02scm(const_cast<char*>($1.c_str())); +} +%typemap(guile,in) string, std::string { + $1 = SWIG_scm2str($input); +} + +%typemap(guile,out) complex, complex<double>, std::complex<double> { + $result = scm_make_rectangular( scm_from_double ($1.real ()), + scm_from_double ($1.imag ()) ); +} +%typemap(guile,in) complex, complex<double>, std::complex<double> { + $1 = std::complex<double>( scm_to_double (scm_real_part ($input)), + scm_to_double (scm_imag_part ($input)) ); +} + diff --git a/share/swig/2.0.11/guile/guile.i b/share/swig/2.0.11/guile/guile.i new file mode 100644 index 0000000..ef270d7 --- /dev/null +++ b/share/swig/2.0.11/guile/guile.i @@ -0,0 +1,33 @@ +/* ----------------------------------------------------------------------------- + * 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/share/swig/2.0.11/guile/guile_scm.swg b/share/swig/2.0.11/guile/guile_scm.swg new file mode 100644 index 0000000..dfd5da2 --- /dev/null +++ b/share/swig/2.0.11/guile/guile_scm.swg @@ -0,0 +1,45 @@ +/* ----------------------------------------------------------------------------- + * 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 <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)); \ + } + +%} + +%insert(init) "swiginit.swg" + +%init %{ +SWIG_GUILE_INIT_STATIC void +SWIG_init(void) +{ + SWIG_InitializeModule(0); + SWIG_PropagateClientData(); +%} diff --git a/share/swig/2.0.11/guile/guile_scm_run.swg b/share/swig/2.0.11/guile/guile_scm_run.swg new file mode 100644 index 0000000..0ac51f9 --- /dev/null +++ b/share/swig/2.0.11/guile/guile_scm_run.swg @@ -0,0 +1,504 @@ +/* ----------------------------------------------------------------------------- + * guile_scm_run.swg + * ----------------------------------------------------------------------------- */ + +#include <libguile.h> +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <assert.h> + +#ifdef __cplusplus +extern "C" { +#endif + + +/* In the code below, use guile 2.0 compatible functions where possible. + Functions that don't exist in older versions will be mapped to + a deprecated equivalent for those versions only */ +#if defined (SCM_MAJOR_VERSION) && (SCM_MAJOR_VERSION < 2) + +static SCM +scm_module_variable (SCM module, SCM sym) +{ + return scm_sym2var (sym, scm_module_lookup_closure (module), SCM_BOOL_F); +} + +#endif + +#if SCM_MAJOR_VERSION >= 2 +// scm_c_define_gsubr takes a different parameter type +// depending on the guile version + +typedef scm_t_subr swig_guile_proc; +#else +typedef SCM (*swig_guile_proc)(); +#endif +typedef SCM (*guile_destructor)(SCM); + +typedef struct swig_guile_clientdata { + guile_destructor destroy; + SCM goops_class; +} swig_guile_clientdata; + +#define SWIG_scm2str(s) \ + SWIG_Guile_scm2newstr(s, NULL) +#define SWIG_str02scm(str) \ + str ? scm_from_locale_string(str) : SCM_BOOL_F +# define SWIG_malloc(size) \ + scm_malloc(size) +# define SWIG_free(mem) \ + free(mem) +#define SWIG_ConvertPtr(s, result, type, flags) \ + SWIG_Guile_ConvertPtr(s, result, type, flags) +#define SWIG_MustGetPtr(s, type, argnum, flags) \ + 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_from_locale_symbol("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 *SWIGUNUSEDPARM(clientdata)); +#define SWIG_GetModule(clientdata) SWIG_Guile_GetModule(clientdata) +#define SWIG_SetModule(clientdata, pointer) SWIG_Guile_SetModule(pointer) + +SWIGINTERN char * +SWIG_Guile_scm2newstr(SCM str, size_t *len) { +#define FUNC_NAME "SWIG_Guile_scm2newstr" + char *ret; + char *tmp; + size_t l; + + SCM_ASSERT (scm_is_string(str), str, 1, FUNC_NAME); + l = scm_c_string_length(str); + + ret = (char *) SWIG_malloc( (l + 1) * sizeof(char)); + if (!ret) return NULL; + + tmp = scm_to_locale_string(str); + memcpy(ret, tmp, l); + free(tmp); + + 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_is_null(x) && SCM_INSTANCEP(x) && scm_is_true(scm_slot_exists_p(x, swig_symbol)) \ + ? scm_slot_ref(x, swig_symbol) : (x) ) + +SWIGINTERN SCM +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_GetModule(0); + 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_module_variable(swig_module, + scm_from_locale_symbol(scheme_variable_name)); + if (scm_is_false(variable)) { + *tag_variable = scm_make_smob_type((char*)scheme_variable_name, 0); + scm_c_module_define(swig_module, scheme_variable_name, + scm_from_ulong(*tag_variable)); + return 1; + } + else { + *tag_variable = scm_to_ulong(SCM_VARIABLE_REF(variable)); + 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_from_locale_keyword((char*) "init-smob")); + swig_symbol = scm_permanent_object(scm_from_locale_symbol("swig-smob")); +#ifdef SWIG_INIT_RUNTIME_MODULE + SWIG_INIT_RUNTIME_MODULE +#endif + + return swig_module; +} + +SWIGINTERN swig_module_info * +SWIG_Guile_GetModule(void *SWIGUNUSEDPARM(clientdata)) +{ + SCM module; + SCM variable; + + module = SWIG_Guile_Init(); + + variable = scm_module_variable(module, + scm_from_locale_symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME)); + if (scm_is_false(variable)) { + return NULL; + } else { + return (swig_module_info *) scm_to_ulong(SCM_VARIABLE_REF(variable)); + } +} + +SWIGINTERN void +SWIG_Guile_SetModule(swig_module_info *swig_module) +{ + SCM module; + SCM variable; + + module = SWIG_Guile_Init(); + + scm_module_define(module, + scm_from_locale_symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME), + scm_from_ulong((unsigned long) swig_module)); +} + +SWIGINTERN int +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_from_locale_string(procname ? (char *) procname : "unknown procedure")); + *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_from_locale_string(procname ? (char *) procname : "unknown procedure")); + return num_args_passed; +} + +#ifdef __cplusplus +} +#endif diff --git a/share/swig/2.0.11/guile/guilemain.i b/share/swig/2.0.11/guile/guilemain.i new file mode 100644 index 0000000..925b81f --- /dev/null +++ b/share/swig/2.0.11/guile/guilemain.i @@ -0,0 +1,44 @@ +/* ----------------------------------------------------------------------------- + * 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/share/swig/2.0.11/guile/interpreter.i b/share/swig/2.0.11/guile/interpreter.i new file mode 100644 index 0000000..524e069 --- /dev/null +++ b/share/swig/2.0.11/guile/interpreter.i @@ -0,0 +1,59 @@ +/* ----------------------------------------------------------------------------- + * 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/share/swig/2.0.11/guile/list-vector.i b/share/swig/2.0.11/guile/list-vector.i new file mode 100644 index 0000000..057a1da --- /dev/null +++ b/share/swig/2.0.11/guile/list-vector.i @@ -0,0 +1,488 @@ +/* ----------------------------------------------------------------------------- + * 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 = scm_c_vector_length($input); + if ($1 > 0) { + $1_ltype i; + $2 = (C_TYPE *) SWIG_malloc(sizeof(C_TYPE) * $1); + for (i = 0; i<$1; i++) { + SCM swig_scm_value = scm_vector_ref($input, scm_from_long(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 = scm_to_ulong(scm_length($input)); + if ($1 > 0) { + $1_ltype i; + SCM rest; + $2 = (C_TYPE *) SWIG_malloc(sizeof(C_TYPE) * $1); + for (i = 0, rest = $input; + i<$1; + i++, rest = SCM_CDR(rest)) { + SCM swig_scm_value = SCM_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 = scm_make_vector(scm_from_long(*$1), + SCM_BOOL_F); + for (i = 0; i<*$1; i++) { + C_TYPE swig_c_value = (*$2)[i]; + SCM elt = C_TO_SCM_EXPR; + scm_vector_set_x(res, scm_from_long(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 = scm_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, scm_is_true, scm_from_bool, boolean); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(char, SCM_CHAR, SCM_MAKE_CHAR, char); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned char, SCM_CHAR, SCM_MAKE_CHAR, char); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(int, scm_to_int, scm_from_long, integer); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(short, scm_to_int, scm_from_long, integer); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(long, scm_to_long, scm_from_long, integer); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(ptrdiff_t, scm_to_long, scm_from_long, integer); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned int, scm_to_ulong, scm_from_ulong, integer); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned short, scm_to_ulong, scm_from_ulong, integer); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned long, scm_to_ulong, scm_from_ulong, integer); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(size_t, scm_to_ulong, scm_from_ulong, integer); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(float, scm_to_double, scm_from_double, real); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(double, scm_to_double, scm_from_double, real); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(char *, SWIG_scm2str, SWIG_str02scm, string); +TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, SWIG_str02scm, string); + +/* For the char *, free all strings after converting */ + + %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 = scm_c_vector_length($input); + if (*_global_vector_length > 0) { + int i; + $1 = (C_TYPE *) SWIG_malloc(sizeof(C_TYPE) + * (*_global_vector_length)); + for (i = 0; i<*_global_vector_length; i++) { + SCM swig_scm_value = scm_vector_ref($input, scm_from_long(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 = scm_to_ulong(scm_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 = SCM_CDR(rest)) { + SCM swig_scm_value = SCM_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 = scm_make_vector(scm_from_long(_global_arraylentemp), + SCM_BOOL_F); + for (i = 0; i<_global_arraylentemp; i++) { + C_TYPE swig_c_value = (*$1)[i]; + SCM elt = C_TO_SCM_EXPR; + scm_vector_set_x(res, scm_from_long(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 = scm_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, scm_is_true, scm_from_bool, boolean); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(char, SCM_CHAR, SCM_MAKE_CHAR, char); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned char, SCM_CHAR, SCM_MAKE_CHAR, char); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(int, scm_to_int, scm_from_long, integer); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(short, scm_to_int, scm_from_long, integer); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(long, scm_to_long, scm_from_long, integer); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(ptrdiff_t, scm_to_long, scm_from_long, integer); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned int, scm_to_ulong, scm_from_ulong, integer); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned short, scm_to_ulong, scm_from_ulong, integer); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned long, scm_to_ulong, scm_from_ulong, integer); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(size_t, scm_to_ulong, scm_from_ulong, integer); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(float, scm_to_double, scm_from_double, real); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(double, scm_to_double, scm_from_double, real); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(char *, SWIG_scm2str, SWIG_str02scm, string); +TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, SWIG_str02scm, string); + +%typemap(freearg) char **PARALLEL_LISTINPUT, char **PARALLEL_VECTORINPUT, + const char **PARALLEL_LISTINPUT, const char **PARALLEL_VECTORINPUT +{ + 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/share/swig/2.0.11/guile/pointer-in-out.i b/share/swig/2.0.11/guile/pointer-in-out.i new file mode 100644 index 0000000..d8a631c --- /dev/null +++ b/share/swig/2.0.11/guile/pointer-in-out.i @@ -0,0 +1,102 @@ +/* ----------------------------------------------------------------------------- + * 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/share/swig/2.0.11/guile/ports.i b/share/swig/2.0.11/guile/ports.i new file mode 100644 index 0000000..7691d3e --- /dev/null +++ b/share/swig/2.0.11/guile/ports.i @@ -0,0 +1,50 @@ +/* ----------------------------------------------------------------------------- + * 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 * +{ + if (SWIG_ConvertPtr($input, (void**) &($1), $1_descriptor, 0) != 0) { + if (!(SCM_FPORTP($input))) { + scm_wrong_type_arg("$symname", $argnum, $input); + } else { + int fd; + if (SCM_OUTPUT_PORT_P($input)) { + scm_force_output($input); + } + fd=dup(SCM_FPORT_FDES($input)); + if (fd==-1) { + scm_misc_error("$symname", strerror(errno), SCM_EOL); + } + $1=fdopen(fd, SCM_OUTPUT_PORT_P($input) ? (SCM_INPUT_PORT_P($input) ? "r+" : "w") : "r"); + if ($1==NULL) { + scm_misc_error("$symname", strerror(errno), SCM_EOL); + } + } + } +} + +%typemap(freearg) FILE* { + if ($1) { + fclose($1); + } +} + diff --git a/share/swig/2.0.11/guile/std_common.i b/share/swig/2.0.11/guile/std_common.i new file mode 100644 index 0000000..18c7db0 --- /dev/null +++ b/share/swig/2.0.11/guile/std_common.i @@ -0,0 +1,24 @@ +/* ----------------------------------------------------------------------------- + * std_common.i + * + * SWIG typemaps for STL - common utilities + * ----------------------------------------------------------------------------- */ + +%include <std/std_except.i> + +%apply size_t { std::size_t }; + +#define SWIG_bool2scm(b) scm_from_bool(b ? 1 : 0) +#define SWIG_string2scm(s) SWIG_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/share/swig/2.0.11/guile/std_deque.i b/share/swig/2.0.11/guile/std_deque.i new file mode 100644 index 0000000..cb98f6c --- /dev/null +++ b/share/swig/2.0.11/guile/std_deque.i @@ -0,0 +1 @@ +%include <std/_std_deque.i> diff --git a/share/swig/2.0.11/guile/std_except.i b/share/swig/2.0.11/guile/std_except.i new file mode 100644 index 0000000..61bf481 --- /dev/null +++ b/share/swig/2.0.11/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/share/swig/2.0.11/guile/std_map.i b/share/swig/2.0.11/guile/std_map.i new file mode 100644 index 0000000..1e1014f --- /dev/null +++ b/share/swig/2.0.11/guile/std_map.i @@ -0,0 +1,1352 @@ +/* ----------------------------------------------------------------------------- + * 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 (scm_is_null($input)) { + $1 = std::map<K,T >(); + } else if (scm_is_pair($input)) { + $1 = std::map<K,T >(); + SCM alist = $input; + while (!scm_is_null(alist)) { + K* k; + T* x; + SCM entry, key, val; + entry = SCM_CAR(alist); + if (!scm_is_pair(entry)) + SWIG_exception(SWIG_TypeError,"alist expected"); + key = SCM_CAR(entry); + val = SCM_CDR(entry); + k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0); + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) != 0) { + if (!scm_is_pair(val)) + SWIG_exception(SWIG_TypeError,"alist expected"); + val = SCM_CAR(val); + x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0); + } + (($1_type &)$1)[*k] = *x; + alist = SCM_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 (scm_is_null($input)) { + temp = std::map<K,T >(); + $1 = &temp; + } else if (scm_is_pair($input)) { + temp = std::map<K,T >(); + $1 = &temp; + SCM alist = $input; + while (!scm_is_null(alist)) { + K* k; + T* x; + SCM entry, key, val; + entry = SCM_CAR(alist); + if (!scm_is_pair(entry)) + SWIG_exception(SWIG_TypeError,"alist expected"); + key = SCM_CAR(entry); + val = SCM_CDR(entry); + k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0); + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) != 0) { + if (!scm_is_pair(val)) + SWIG_exception(SWIG_TypeError,"alist expected"); + val = SCM_CAR(val); + x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0); + } + temp[*k] = *x; + alist = SCM_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=$i.rbegin(); + i!=$i.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 = scm_cons(k,x); + alist = scm_cons(entry,alist); + } + $result = alist; + } + %typecheck(SWIG_TYPECHECK_MAP) map<K,T> { + /* native sequence? */ + if (scm_is_null($input)) { + /* an empty sequence can be of any type */ + $1 = 1; + } else if (scm_is_pair($input)) { + /* check the first element only */ + K* k; + T* x; + SCM head = SCM_CAR($input); + if (scm_is_pair(head)) { + SCM key = SCM_CAR(head); + SCM val = SCM_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 (scm_is_pair(val)) { + val = SCM_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 (scm_is_null($input)) { + /* an empty sequence can be of any type */ + $1 = 1; + } else if (scm_is_pair($input)) { + /* check the first element only */ + K* k; + T* x; + SCM head = SCM_CAR($input); + if (scm_is_pair(head)) { + SCM key = SCM_CAR(head); + SCM val = SCM_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 (scm_is_pair(val)) { + val = SCM_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: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef K key_type; + typedef T mapped_type; + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + const 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=self->rbegin(); + i!=self->rend(); ++i) { + K* key = new K(i->first); + SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1); + result = scm_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 (scm_is_null($input)) { + $1 = std::map<K,T >(); + } else if (scm_is_pair($input)) { + $1 = std::map<K,T >(); + SCM alist = $input; + while (!scm_is_null(alist)) { + T* x; + SCM entry, key, val; + entry = SCM_CAR(alist); + if (!scm_is_pair(entry)) + SWIG_exception(SWIG_TypeError,"alist expected"); + key = SCM_CAR(entry); + val = SCM_CDR(entry); + if (!CHECK(key)) + SWIG_exception(SWIG_TypeError, + "map<" #K "," #T "> expected"); + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) != 0) { + if (!scm_is_pair(val)) + SWIG_exception(SWIG_TypeError,"alist expected"); + val = SCM_CAR(val); + x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0); + } + (($1_type &)$1)[CONVERT_FROM(key)] = *x; + alist = SCM_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 (scm_is_null($input)) { + temp = std::map<K,T >(); + $1 = &temp; + } else if (scm_is_pair($input)) { + temp = std::map<K,T >(); + $1 = &temp; + SCM alist = $input; + while (!scm_is_null(alist)) { + T* x; + SCM entry, key, val; + entry = SCM_CAR(alist); + if (!scm_is_pair(entry)) + SWIG_exception(SWIG_TypeError,"alist expected"); + key = SCM_CAR(entry); + val = SCM_CDR(entry); + if (!CHECK(key)) + SWIG_exception(SWIG_TypeError, + "map<" #K "," #T "> expected"); + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) != 0) { + if (!scm_is_pair(val)) + SWIG_exception(SWIG_TypeError,"alist expected"); + val = SCM_CAR(val); + x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0); + } + temp[CONVERT_FROM(key)] = *x; + alist = SCM_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 = scm_cons(k,x); + alist = scm_cons(entry,alist); + } + $result = alist; + } + %typecheck(SWIG_TYPECHECK_MAP) map<K,T> { + // native sequence? + if (scm_is_null($input)) { + /* an empty sequence can be of any type */ + $1 = 1; + } else if (scm_is_pair($input)) { + // check the first element only + T* x; + SCM head = SCM_CAR($input); + if (scm_is_pair(head)) { + SCM key = SCM_CAR(head); + SCM val = SCM_CDR(head); + if (!CHECK(key)) { + $1 = 0; + } else { + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) == 0) { + $1 = 1; + } else if (scm_is_pair(val)) { + val = SCM_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 (scm_is_null($input)) { + /* an empty sequence can be of any type */ + $1 = 1; + } else if (scm_is_pair($input)) { + // check the first element only + T* x; + SCM head = SCM_CAR($input); + if (scm_is_pair(head)) { + SCM key = SCM_CAR(head); + SCM val = SCM_CDR(head); + if (!CHECK(key)) { + $1 = 0; + } else { + if (SWIG_ConvertPtr(val,(void**) &x, + $descriptor(T *), 0) == 0) { + $1 = 1; + } else if (scm_is_pair(val)) { + val = SCM_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=self->rbegin(); + i!=self->rend(); ++i) { + SCM k = CONVERT_TO(i->first); + result = scm_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 (scm_is_null($input)) { + $1 = std::map<K,T >(); + } else if (scm_is_pair($input)) { + $1 = std::map<K,T >(); + SCM alist = $input; + while (!scm_is_null(alist)) { + K* k; + SCM entry, key, val; + entry = SCM_CAR(alist); + if (!scm_is_pair(entry)) + SWIG_exception(SWIG_TypeError,"alist expected"); + key = SCM_CAR(entry); + val = SCM_CDR(entry); + k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0); + if (!CHECK(val)) { + if (!scm_is_pair(val)) + SWIG_exception(SWIG_TypeError,"alist expected"); + val = SCM_CAR(val); + if (!CHECK(val)) + SWIG_exception(SWIG_TypeError, + "map<" #K "," #T "> expected"); + } + (($1_type &)$1)[*k] = CONVERT_FROM(val); + alist = SCM_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 (scm_is_null($input)) { + temp = std::map<K,T >(); + $1 = &temp; + } else if (scm_is_pair($input)) { + temp = std::map<K,T >(); + $1 = &temp; + SCM alist = $input; + while (!scm_is_null(alist)) { + K* k; + SCM entry, key, val; + entry = SCM_CAR(alist); + if (!scm_is_pair(entry)) + SWIG_exception(SWIG_TypeError,"alist expected"); + key = SCM_CAR(entry); + val = SCM_CDR(entry); + k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0); + if (!CHECK(val)) { + if (!scm_is_pair(val)) + SWIG_exception(SWIG_TypeError,"alist expected"); + val = SCM_CAR(val); + if (!CHECK(val)) + SWIG_exception(SWIG_TypeError, + "map<" #K "," #T "> expected"); + } + temp[*k] = CONVERT_FROM(val); + alist = SCM_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 = scm_cons(k,x); + alist = scm_cons(entry,alist); + } + $result = alist; + } + %typecheck(SWIG_TYPECHECK_MAP) map<K,T> { + // native sequence? + if (scm_is_null($input)) { + /* an empty sequence can be of any type */ + $1 = 1; + } else if (scm_is_pair($input)) { + // check the first element only + K* k; + SCM head = SCM_CAR($input); + if (scm_is_pair(head)) { + SCM key = SCM_CAR(head); + SCM val = SCM_CDR(head); + if (SWIG_ConvertPtr(val,(void **) &k, + $descriptor(K *), 0) != 0) { + $1 = 0; + } else { + if (CHECK(val)) { + $1 = 1; + } else if (scm_is_pair(val)) { + val = SCM_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 (scm_is_null($input)) { + /* an empty sequence can be of any type */ + $1 = 1; + } else if (scm_is_pair($input)) { + // check the first element only + K* k; + SCM head = SCM_CAR($input); + if (scm_is_pair(head)) { + SCM key = SCM_CAR(head); + SCM val = SCM_CDR(head); + if (SWIG_ConvertPtr(val,(void **) &k, + $descriptor(K *), 0) != 0) { + $1 = 0; + } else { + if (CHECK(val)) { + $1 = 1; + } else if (scm_is_pair(val)) { + val = SCM_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=self->rbegin(); + i!=self->rend(); ++i) { + K* key = new K(i->first); + SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1); + result = scm_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 (scm_is_null($input)) { + $1 = std::map<K,T >(); + } else if (scm_is_pair($input)) { + $1 = std::map<K,T >(); + SCM alist = $input; + while (!scm_is_null(alist)) { + SCM entry, key, val; + entry = SCM_CAR(alist); + if (!scm_is_pair(entry)) + SWIG_exception(SWIG_TypeError,"alist expected"); + key = SCM_CAR(entry); + val = SCM_CDR(entry); + if (!CHECK_K(key)) + SWIG_exception(SWIG_TypeError, + "map<" #K "," #T "> expected"); + if (!CHECK_T(val)) { + if (!scm_is_pair(val)) + SWIG_exception(SWIG_TypeError,"alist expected"); + val = SCM_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 = SCM_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 (scm_is_null($input)) { + temp = std::map<K,T >(); + $1 = &temp; + } else if (scm_is_pair($input)) { + temp = std::map<K,T >(); + $1 = &temp; + SCM alist = $input; + while (!scm_is_null(alist)) { + SCM entry, key, val; + entry = SCM_CAR(alist); + if (!scm_is_pair(entry)) + SWIG_exception(SWIG_TypeError,"alist expected"); + key = SCM_CAR(entry); + val = SCM_CDR(entry); + if (!CHECK_K(key)) + SWIG_exception(SWIG_TypeError, + "map<" #K "," #T "> expected"); + if (!CHECK_T(val)) { + if (!scm_is_pair(val)) + SWIG_exception(SWIG_TypeError,"alist expected"); + val = SCM_CAR(val); + if (!CHECK_T(val)) + SWIG_exception(SWIG_TypeError, + "map<" #K "," #T "> expected"); + } + temp[CONVERT_K_FROM(key)] = CONVERT_T_FROM(val); + alist = SCM_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 = scm_cons(k,x); + alist = scm_cons(entry,alist); + } + $result = alist; + } + %typecheck(SWIG_TYPECHECK_MAP) map<K,T> { + // native sequence? + if (scm_is_null($input)) { + /* an empty sequence can be of any type */ + $1 = 1; + } else if (scm_is_pair($input)) { + // check the first element only + SCM head = SCM_CAR($input); + if (scm_is_pair(head)) { + SCM key = SCM_CAR(head); + SCM val = SCM_CDR(head); + if (!CHECK_K(key)) { + $1 = 0; + } else { + if (CHECK_T(val)) { + $1 = 1; + } else if (scm_is_pair(val)) { + val = SCM_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 (scm_is_null($input)) { + /* an empty sequence can be of any type */ + $1 = 1; + } else if (scm_is_pair($input)) { + // check the first element only + SCM head = SCM_CAR($input); + if (scm_is_pair(head)) { + SCM key = SCM_CAR(head); + SCM val = SCM_CDR(head); + if (!CHECK_K(key)) { + $1 = 0; + } else { + if (CHECK_T(val)) { + $1 = 1; + } else if (scm_is_pair(val)) { + val = SCM_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=self->rbegin(); + i!=self->rend(); ++i) { + SCM k = CONVERT_K_TO(i->first); + result = scm_cons(k,result); + } + return result; + } + } + }; + %enddef + + + specialize_std_map_on_key(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_map_on_key(int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_key(short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_key(long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_key(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_key(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_key(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_key(double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_key(float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_key(std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm); + + specialize_std_map_on_value(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_map_on_value(int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_value(short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_value(long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_value(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_value(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_value(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_value(double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_value(float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_value(std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm); + + specialize_std_map_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_map_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm); + specialize_std_map_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_map_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm); + specialize_std_map_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_map_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm); + specialize_std_map_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_map_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm); + specialize_std_map_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_map_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm); + specialize_std_map_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_map_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm); + specialize_std_map_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_map_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm); + specialize_std_map_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_map_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm); + specialize_std_map_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_map_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm); + specialize_std_map_on_both(std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_map_on_both(std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_map_on_both(std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_map_on_both(std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_map_on_both(std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm, + std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm); +} diff --git a/share/swig/2.0.11/guile/std_pair.i b/share/swig/2.0.11/guile/std_pair.i new file mode 100644 index 0000000..512d0d5 --- /dev/null +++ b/share/swig/2.0.11/guile/std_pair.i @@ -0,0 +1,863 @@ +/* ----------------------------------------------------------------------------- + * 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> %{ + if (scm_is_pair($input)) { + T* x; + U* y; + SCM first, second; + first = SCM_CAR($input); + second = SCM_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 = 0), + const pair<T,U>* (std::pair<T,U> *temp = 0) %{ + if (scm_is_pair($input)) { + T* x; + U* y; + SCM first, second; + first = SCM_CAR($input); + second = SCM_CDR($input); + x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); + y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); + temp = new std::pair< T, U >(*x,*y); + $1 = temp; + } else { + $1 = ($1_ltype) + SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + %} + %typemap(freearg) const pair<T,U>&, const pair<T,U>* %{ delete temp$argnum; %} + %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 = scm_cons(first,second); + } + %typecheck(SWIG_TYPECHECK_PAIR) pair<T,U> { + /* native pair? */ + if (scm_is_pair($input)) { + T* x; + U* y; + SCM first = SCM_CAR($input); + SCM second = SCM_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 (scm_is_pair($input)) { + T* x; + U* y; + SCM first = SCM_CAR($input); + SCM second = SCM_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> %{ + if (scm_is_pair($input)) { + U* y; + SCM first, second; + first = SCM_CAR($input); + second = SCM_CDR($input); + if (!CHECK(first)) + SWIG_exception(SWIG_TypeError, + "pair<" #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 = 0), + const pair<T,U>* (std::pair<T,U> *temp = 0) %{ + if (scm_is_pair($input)) { + U* y; + SCM first, second; + first = SCM_CAR($input); + second = SCM_CDR($input); + if (!CHECK(first)) + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + y = (U*) SWIG_MustGetPtr(second,$descriptor(U *),$argnum, 0); + temp = new std::pair< T, U >(CONVERT_FROM(first),*y); + $1 = temp; + } else { + $1 = ($1_ltype) + SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + %} + %typemap(freearg) const pair<T,U>&, const pair<T,U>* %{ delete temp$argnum; %} + %typemap(out) pair<T,U> { + U* y = new U($1.second); + SCM second = SWIG_NewPointerObj(y,$descriptor(U *), 1); + $result = scm_cons(CONVERT_TO($1.first),second); + } + %typecheck(SWIG_TYPECHECK_PAIR) pair<T,U> { + /* native pair? */ + if (scm_is_pair($input)) { + U* y; + SCM first = SCM_CAR($input); + SCM second = SCM_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 (scm_is_pair($input)) { + U* y; + SCM first = SCM_CAR($input); + SCM second = SCM_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> %{ + if (scm_is_pair($input)) { + T* x; + SCM first, second; + first = SCM_CAR($input); + second = SCM_CDR($input); + x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); + if (!CHECK(second)) + SWIG_exception(SWIG_TypeError, + "pair<" #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 = 0), + const pair<T,U>* (std::pair<T,U> *temp = 0) %{ + if (scm_is_pair($input)) { + T* x; + SCM first, second; + first = SCM_CAR($input); + second = SCM_CDR($input); + x = (T*) SWIG_MustGetPtr(first,$descriptor(T *),$argnum, 0); + if (!CHECK(second)) + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + temp = new std::pair< T, U >(*x,CONVERT_FROM(second)); + $1 = temp; + } else { + $1 = ($1_ltype) + SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + %} + %typemap(freearg) const pair<T,U>&, const pair<T,U>* %{ delete temp$argnum; %} + %typemap(out) pair<T,U> { + T* x = new T($1.first); + SCM first = SWIG_NewPointerObj(x,$descriptor(T *), 1); + $result = scm_cons(first,CONVERT_TO($1.second)); + } + %typecheck(SWIG_TYPECHECK_PAIR) pair<T,U> { + /* native pair? */ + if (scm_is_pair($input)) { + T* x; + SCM first = SCM_CAR($input); + SCM second = SCM_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 (scm_is_pair($input)) { + T* x; + SCM first = SCM_CAR($input); + SCM second = SCM_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> %{ + if (scm_is_pair($input)) { + SCM first, second; + first = SCM_CAR($input); + second = SCM_CDR($input); + if (!CHECK_T(first) || !CHECK_U(second)) + SWIG_exception(SWIG_TypeError, + "pair<" #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 = 0), + const pair<T,U>* (std::pair<T,U> *temp = 0) %{ + if (scm_is_pair($input)) { + SCM first, second; + first = SCM_CAR($input); + second = SCM_CDR($input); + if (!CHECK_T(first) || !CHECK_U(second)) + SWIG_exception(SWIG_TypeError, + "pair<" #T "," #U "> expected"); + temp = new std::pair< T, U >(CONVERT_T_FROM(first), CONVERT_U_FROM(second)); + $1 = temp; + } else { + $1 = ($1_ltype) + SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); + } + %} + %typemap(freearg) const pair<T,U>&, const pair<T,U>* %{ delete temp$argnum; %} + %typemap(out) pair<T,U> { + $result = scm_cons(CONVERT_T_TO($1.first), + CONVERT_U_TO($1.second)); + } + %typecheck(SWIG_TYPECHECK_PAIR) pair<T,U> { + /* native pair? */ + if (scm_is_pair($input)) { + SCM first = SCM_CAR($input); + SCM second = SCM_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 (scm_is_pair($input)) { + SCM first = SCM_CAR($input); + SCM second = SCM_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,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_pair_on_first(int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_first(short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_first(long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_first(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_first(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_first(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_first(double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_first(float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_first(std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm); + + specialize_std_pair_on_second(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_pair_on_second(int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_second(short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_second(long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_second(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_second(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_second(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_second(double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_second(float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_second(std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm); + + specialize_std_pair_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_pair_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(bool,scm_is_bool, + scm_is_true,SWIG_bool2scm, + std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm); + specialize_std_pair_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_pair_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(int,scm_is_number, + scm_to_long,scm_from_long, + std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm); + specialize_std_pair_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_pair_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(short,scm_is_number, + scm_to_long,scm_from_long, + std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm); + specialize_std_pair_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_pair_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(long,scm_is_number, + scm_to_long,scm_from_long, + std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm); + specialize_std_pair_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_pair_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong, + std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm); + specialize_std_pair_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_pair_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong, + std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm); + specialize_std_pair_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_pair_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong, + std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm); + specialize_std_pair_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_pair_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(double,scm_is_number, + scm_to_double,scm_from_double, + std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm); + specialize_std_pair_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_pair_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(float,scm_is_number, + scm_to_double,scm_from_double, + std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm); + specialize_std_pair_on_both(std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm, + bool,scm_is_bool, + scm_is_true,SWIG_bool2scm); + specialize_std_pair_on_both(std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm, + int,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm, + short,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm, + long,scm_is_number, + scm_to_long,scm_from_long); + specialize_std_pair_on_both(std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm, + unsigned int,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm, + unsigned short,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm, + unsigned long,scm_is_number, + scm_to_ulong,scm_from_ulong); + specialize_std_pair_on_both(std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm, + double,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm, + float,scm_is_number, + scm_to_double,scm_from_double); + specialize_std_pair_on_both(std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm, + std::string,scm_is_string, + SWIG_scm2string,SWIG_string2scm); +} diff --git a/share/swig/2.0.11/guile/std_string.i b/share/swig/2.0.11/guile/std_string.i new file mode 100644 index 0000000..6513173 --- /dev/null +++ b/share/swig/2.0.11/guile/std_string.i @@ -0,0 +1,86 @@ +/* ----------------------------------------------------------------------------- + * 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 (scm_is_string($input)) { + tempptr = SWIG_scm2str($input); + $1.assign(tempptr); + if (tempptr) SWIG_free(tempptr); + } else { + SWIG_exception(SWIG_TypeError, "string expected"); + } + } + + %typemap(in) const string & ($*1_ltype temp, char *tempptr) { + if (scm_is_string($input)) { + tempptr = SWIG_scm2str($input); + temp.assign(tempptr); + if (tempptr) SWIG_free(tempptr); + $1 = &temp; + } else { + SWIG_exception(SWIG_TypeError, "string expected"); + } + } + + %typemap(in) string * (char *tempptr) { + if (scm_is_string($input)) { + tempptr = SWIG_scm2str($input); + $1 = new $*1_ltype(tempptr); + if (tempptr) SWIG_free(tempptr); + } else { + SWIG_exception(SWIG_TypeError, "string expected"); + } + } + + %typemap(out) string { + $result = SWIG_str02scm($1.c_str()); + } + + %typemap(out) const string & { + $result = SWIG_str02scm($1->c_str()); + } + + %typemap(out) string * { + $result = SWIG_str02scm($1->c_str()); + } + + %typemap(varin) string { + if (scm_is_string($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 = SWIG_str02scm($1.c_str()); + } + +} diff --git a/share/swig/2.0.11/guile/std_vector.i b/share/swig/2.0.11/guile/std_vector.i new file mode 100644 index 0000000..79c716b --- /dev/null +++ b/share/swig/2.0.11/guile/std_vector.i @@ -0,0 +1,410 @@ +/* ----------------------------------------------------------------------------- + * 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 (scm_is_vector($input)) { + unsigned long size = scm_c_vector_length($input); + $1 = std::vector<T >(size); + for (unsigned long i=0; i<size; i++) { + SCM o = scm_vector_ref($input,scm_from_ulong(i)); + (($1_type &)$1)[i] = + *((T*) SWIG_MustGetPtr(o,$descriptor(T *),$argnum, 0)); + } + } else if (scm_is_null($input)) { + $1 = std::vector<T >(); + } else if (scm_is_pair($input)) { + SCM head, tail; + $1 = std::vector<T >(); + tail = $input; + while (!scm_is_null(tail)) { + head = SCM_CAR(tail); + tail = SCM_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 (scm_is_vector($input)) { + unsigned long size = scm_c_vector_length($input); + temp = std::vector<T >(size); + $1 = &temp; + for (unsigned long i=0; i<size; i++) { + SCM o = scm_vector_ref($input,scm_from_ulong(i)); + temp[i] = *((T*) SWIG_MustGetPtr(o, + $descriptor(T *), + $argnum, 0)); + } + } else if (scm_is_null($input)) { + temp = std::vector<T >(); + $1 = &temp; + } else if (scm_is_pair($input)) { + temp = std::vector<T >(); + $1 = &temp; + SCM head, tail; + tail = $input; + while (!scm_is_null(tail)) { + head = SCM_CAR(tail); + tail = SCM_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 = scm_make_vector(scm_from_long($1.size()),SCM_UNSPECIFIED); + for (unsigned int i=0; i<$1.size(); i++) { + T* x = new T((($1_type &)$1)[i]); + scm_vector_set_x($result,scm_from_long(i), + SWIG_NewPointerObj(x, $descriptor(T *), 1)); + } + } + %typecheck(SWIG_TYPECHECK_VECTOR) vector<T> { + /* native sequence? */ + if (scm_is_vector($input)) { + unsigned int size = scm_c_vector_length($input); + if (size == 0) { + /* an empty sequence can be of any type */ + $1 = 1; + } else { + /* check the first element only */ + SCM o = scm_vector_ref($input,scm_from_ulong(0)); + T* x; + if (SWIG_ConvertPtr(o,(void**) &x, + $descriptor(T *), 0) != -1) + $1 = 1; + else + $1 = 0; + } + } else if (scm_is_null($input)) { + /* again, an empty sequence can be of any type */ + $1 = 1; + } else if (scm_is_pair($input)) { + /* check the first element only */ + T* x; + SCM head = SCM_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 (scm_is_vector($input)) { + unsigned int size = scm_c_vector_length($input); + if (size == 0) { + /* an empty sequence can be of any type */ + $1 = 1; + } else { + /* check the first element only */ + T* x; + SCM o = scm_vector_ref($input,scm_from_ulong(0)); + if (SWIG_ConvertPtr(o,(void**) &x, + $descriptor(T *), 0) != -1) + $1 = 1; + else + $1 = 0; + } + } else if (scm_is_null($input)) { + /* again, an empty sequence can be of any type */ + $1 = 1; + } else if (scm_is_pair($input)) { + /* check the first element only */ + T* x; + SCM head = SCM_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; + } + const 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 (scm_is_vector($input)) { + unsigned long size = scm_c_vector_length($input); + $1 = std::vector<T >(size); + for (unsigned long i=0; i<size; i++) { + SCM o = scm_vector_ref($input,scm_from_ulong(i)); + if (CHECK(o)) + (($1_type &)$1)[i] = (T)(CONVERT_FROM(o)); + else + scm_wrong_type_arg(FUNC_NAME, $argnum, $input); + } + } else if (scm_is_null($input)) { + $1 = std::vector<T >(); + } else if (scm_is_pair($input)) { + SCM v = scm_vector($input); + unsigned long size = scm_c_vector_length(v); + $1 = std::vector<T >(size); + for (unsigned long i=0; i<size; i++) { + SCM o = scm_vector_ref(v,scm_from_ulong(i)); + if (CHECK(o)) + (($1_type &)$1)[i] = (T)(CONVERT_FROM(o)); + else + scm_wrong_type_arg(FUNC_NAME, $argnum, $input); + } + } else { + $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 (scm_is_vector($input)) { + unsigned long size = scm_c_vector_length($input); + temp = std::vector<T >(size); + $1 = &temp; + for (unsigned long i=0; i<size; i++) { + SCM o = scm_vector_ref($input,scm_from_ulong(i)); + if (CHECK(o)) + temp[i] = (T)(CONVERT_FROM(o)); + else + scm_wrong_type_arg(FUNC_NAME, $argnum, $input); + } + } else if (scm_is_null($input)) { + temp = std::vector<T >(); + $1 = &temp; + } else if (scm_is_pair($input)) { + SCM v = scm_vector($input); + unsigned long size = scm_c_vector_length(v); + temp = std::vector<T >(size); + $1 = &temp; + for (unsigned long i=0; i<size; i++) { + SCM o = scm_vector_ref(v,scm_from_ulong(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 = scm_make_vector(scm_from_long($1.size()),SCM_UNSPECIFIED); + for (unsigned int i=0; i<$1.size(); i++) { + SCM x = CONVERT_TO((($1_type &)$1)[i]); + scm_vector_set_x($result,scm_from_long(i),x); + } + } + %typecheck(SWIG_TYPECHECK_VECTOR) vector<T> { + /* native sequence? */ + if (scm_is_vector($input)) { + unsigned int size = scm_c_vector_length($input); + if (size == 0) { + /* an empty sequence can be of any type */ + $1 = 1; + } else { + /* check the first element only */ + T* x; + SCM o = scm_vector_ref($input,scm_from_ulong(0)); + $1 = CHECK(o) ? 1 : 0; + } + } else if (scm_is_null($input)) { + /* again, an empty sequence can be of any type */ + $1 = 1; + } else if (scm_is_pair($input)) { + /* check the first element only */ + T* x; + SCM head = SCM_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 (scm_is_vector($input)) { + unsigned int size = scm_c_vector_length($input); + if (size == 0) { + /* an empty sequence can be of any type */ + $1 = 1; + } else { + /* check the first element only */ + T* x; + SCM o = scm_vector_ref($input,scm_from_ulong(0)); + $1 = CHECK(o) ? 1 : 0; + } + } else if (scm_is_null($input)) { + /* again, an empty sequence can be of any type */ + $1 = 1; + } else if (scm_is_pair($input)) { + /* check the first element only */ + T* x; + SCM head = SCM_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,scm_is_bool,scm_is_true,SWIG_bool2scm); + specialize_stl_vector(char,scm_is_number,scm_to_long,scm_from_long); + specialize_stl_vector(int,scm_is_number,scm_to_long,scm_from_long); + specialize_stl_vector(long,scm_is_number,scm_to_long,scm_from_long); + specialize_stl_vector(short,scm_is_number,scm_to_long,scm_from_long); + specialize_stl_vector(unsigned char,scm_is_number,scm_to_ulong,scm_from_ulong); + specialize_stl_vector(unsigned int,scm_is_number,scm_to_ulong,scm_from_ulong); + specialize_stl_vector(unsigned long,scm_is_number,scm_to_ulong,scm_from_ulong); + specialize_stl_vector(unsigned short,scm_is_number,scm_to_ulong,scm_from_ulong); + specialize_stl_vector(float,scm_is_number,scm_to_double,scm_from_double); + specialize_stl_vector(double,scm_is_number,scm_to_double,scm_from_double); + specialize_stl_vector(std::string,scm_is_string,SWIG_scm2string,SWIG_string2scm); +} + diff --git a/share/swig/2.0.11/guile/stl.i b/share/swig/2.0.11/guile/stl.i new file mode 100644 index 0000000..9d2e91e --- /dev/null +++ b/share/swig/2.0.11/guile/stl.i @@ -0,0 +1,12 @@ +/* ----------------------------------------------------------------------------- + * 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/share/swig/2.0.11/guile/swigrun.i b/share/swig/2.0.11/guile/swigrun.i new file mode 100644 index 0000000..4b9ea2c --- /dev/null +++ b/share/swig/2.0.11/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/share/swig/2.0.11/guile/typemaps.i b/share/swig/2.0.11/guile/typemaps.i new file mode 100644 index 0000000..ba447ac --- /dev/null +++ b/share/swig/2.0.11/guile/typemaps.i @@ -0,0 +1,457 @@ +/* ----------------------------------------------------------------------------- + * 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(scm_from_locale_symbol((char *) "swig-exception"), + scm_listify(SWIG_NewPointerObj(temp, $&descriptor, 1), + SCM_UNDEFINED)); +} + +%typemap(throws) SWIGTYPE & { + scm_throw(scm_from_locale_symbol((char *) "swig-exception"), + scm_listify(SWIG_NewPointerObj(&$1, $descriptor, 1), + SCM_UNDEFINED)); +} + +%typemap(throws) SWIGTYPE * { + scm_throw(scm_from_locale_symbol((char *) "swig-exception"), + scm_listify(SWIG_NewPointerObj($1, $descriptor, 1), + SCM_UNDEFINED)); +} + +%typemap(throws) SWIGTYPE [] { + scm_throw(scm_from_locale_symbol((char *) "swig-exception"), + scm_listify(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((const $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((const $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) scm_to_int($input); } +/* The complicated construction below needed to deal with anonymous + enums, which cannot be cast to. */ +%typemap(varin) enum SWIGTYPE { + if (sizeof(int) != sizeof($1)) { + scm_error(scm_from_locale_symbol("swig-error"), + (char *) FUNC_NAME, + (char *) "enum variable '$name' cannot be set", + SCM_EOL, SCM_BOOL_F); + } + * (int *) &($1) = scm_to_int($input); +} +%typemap(out) enum SWIGTYPE { $result = scm_from_long($1); } +%typemap(varout) enum SWIGTYPE { $result = scm_from_long($1); } +%typemap(throws) enum SWIGTYPE { + scm_throw(scm_from_locale_symbol((char *) "swig-exception"), + scm_listify(scm_from_long($1), SCM_UNDEFINED)); +} + +/* The SIMPLE_MAP_WITH_EXPR macro below defines the whole set of + 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(scm_from_locale_symbol((char *) "swig-exception"), + scm_listify(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(scm_from_locale_symbol((char *) "swig-exception"), + scm_listify(C_TO_SCM($1), SCM_UNDEFINED)); + } +%enddef + + SIMPLE_MAP(bool, scm_is_true, scm_from_bool, boolean); + SIMPLE_MAP(char, SCM_CHAR, SCM_MAKE_CHAR, char); + SIMPLE_MAP(unsigned char, SCM_CHAR, SCM_MAKE_CHAR, char); + SIMPLE_MAP(signed char, SCM_CHAR, SCM_MAKE_CHAR, char); + SIMPLE_MAP(int, scm_to_int, scm_from_long, integer); + SIMPLE_MAP(short, scm_to_short, scm_from_long, integer); + SIMPLE_MAP(long, scm_to_long, scm_from_long, integer); + SIMPLE_MAP(ptrdiff_t, scm_to_long, scm_from_long, integer); + SIMPLE_MAP(unsigned int, scm_to_uint, scm_from_ulong, integer); + SIMPLE_MAP(unsigned short, scm_to_ushort, scm_from_ulong, integer); + SIMPLE_MAP(unsigned long, scm_to_ulong, scm_from_ulong, integer); + SIMPLE_MAP(size_t, scm_to_ulong, scm_from_ulong, integer); + SIMPLE_MAP(float, scm_to_double, scm_from_double, real); + SIMPLE_MAP(double, scm_to_double, scm_from_double, real); +// SIMPLE_MAP(char *, SWIG_scm2str, SWIG_str02scm, string); +// SIMPLE_MAP(const char *, SWIG_scm2str, SWIG_str02scm, string); + +/* Define long long typemaps -- uses functions that are only defined + in recent versions of Guile, availability also depends on Guile's + configuration. */ + +SIMPLE_MAP(long long, scm_to_long_long, scm_from_long_long, integer); +SIMPLE_MAP(unsigned long long, scm_to_ulong_long, scm_from_ulong_long, 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 = SWIG_str02scm((const char *)$1);} + %typemap (varout, doc="<string>") char * {$result = SWIG_str02scm($1);} + %typemap (in, doc="$NAME is a string") char **INPUT(char * temp, int must_free = 0) { + temp = (char *) SWIG_scm2str($input); $1 = &temp; + must_free = 1; + } + %typemap (in,numinputs=0) char **OUTPUT (char * temp) + {$1 = &temp;} + %typemap (argout,doc="$NAME (a string)") char **OUTPUT + {SWIG_APPEND_VALUE(SWIG_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(scm_from_locale_symbol((char *) "swig-exception"), + scm_listify(SWIG_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), (char *STRING, size_t LENGTH) { + size_t temp; + $1 = ($1_ltype) SWIG_Guile_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_is_true(scm_integer_p($input)) && scm_is_true(scm_exact_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_is_true(scm_real_p($input)) ? 1 : 0; +} + +%typecheck(SWIG_TYPECHECK_CHAR) char { + $1 = SCM_CHARP($input) ? 1 : 0; +} + +%typecheck(SWIG_TYPECHECK_STRING) char * { + $1 = scm_is_string($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); +} + +/* Array reference typemaps */ +%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } + +/* const pointers */ +%apply SWIGTYPE * { SWIGTYPE *const } + +/* typemaps.i ends here */ |