Drop guilegh interface
All of guile's interface files now use the scm interface. This should not affect any users. Swig generated code using the scm interface can be mixed with gh interface using user code. It does simplify maintenance of the guile swig code though.
This commit is contained in:
parent
3c47730803
commit
b819d2a91e
25 changed files with 1283 additions and 1829 deletions
|
|
@ -17,7 +17,7 @@ typedef struct SWIGCDATA {
|
|||
|
||||
#if SWIGGUILE
|
||||
%typemap(out) SWIGCDATA {
|
||||
$result = gh_str2scm($1.data,$1.len);
|
||||
$result = scm_mem2string($1.data,$1.len);
|
||||
}
|
||||
%typemap(in) (const void *indata, int inlen) = (char *STRING, int LENGTH);
|
||||
#elif SWIGCHICKEN
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
SWIGINTERN void SWIG_exception_ (int code, const char *msg,
|
||||
const char *subr) {
|
||||
#define ERROR(scmerr) \
|
||||
scm_error(gh_symbol2scm((char *) (scmerr)), \
|
||||
scm_error(scm_str2symbol((char *) (scmerr)), \
|
||||
(char *) subr, (char *) msg, \
|
||||
SCM_EOL, SCM_BOOL_F)
|
||||
#define MAP(swigerr, scmerr) \
|
||||
|
|
|
|||
|
|
@ -5,18 +5,18 @@
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%typemap(guile,out) string, std::string {
|
||||
$result = gh_str02scm(const_cast<char*>($1.c_str()));
|
||||
$result = SWIG_str02scm(const_cast<char*>($1.c_str()));
|
||||
}
|
||||
%typemap(guile,in) string, std::string {
|
||||
$1 = SWIG_scm2str($input);
|
||||
}
|
||||
|
||||
%typemap(guile,out) complex, complex<double>, std::complex<double> {
|
||||
$result = scm_make_rectangular( gh_double2scm ($1.real ()),
|
||||
gh_double2scm ($1.imag ()) );
|
||||
$result = scm_make_rectangular( scm_from_double ($1.real ()),
|
||||
scm_from_double ($1.imag ()) );
|
||||
}
|
||||
%typemap(guile,in) complex, complex<double>, std::complex<double> {
|
||||
$1 = std::complex<double>( gh_scm2double (scm_real_part ($input)),
|
||||
gh_scm2double (scm_imag_part ($input)) );
|
||||
$1 = std::complex<double>( scm_to_double (scm_real_part ($input)),
|
||||
scm_to_double (scm_imag_part ($input)) );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,39 +0,0 @@
|
|||
#define gh_append2(a, b) scm_append(scm_listify(a, b, SCM_UNDEFINED))
|
||||
#define gh_apply(a, b) scm_apply(a, b, SCM_EOL)
|
||||
#define gh_bool2scm scm_from_bool
|
||||
#define gh_boolean_p scm_is_bool
|
||||
#define gh_car SCM_CAR
|
||||
#define gh_cdr SCM_CDR
|
||||
#define gh_cons scm_cons
|
||||
#define gh_double2scm scm_from_double
|
||||
#define gh_int2scm scm_from_long
|
||||
#define gh_length(lst) scm_to_ulong(scm_length(lst))
|
||||
#define gh_list scm_listify
|
||||
#define gh_list_to_vector scm_vector
|
||||
#define gh_make_vector scm_make_vector
|
||||
#define gh_null_p scm_is_null
|
||||
#define gh_number_p scm_is_number
|
||||
#define gh_pair_p scm_is_pair
|
||||
#define gh_scm2bool scm_is_true
|
||||
#define gh_scm2char SCM_CHAR
|
||||
#define gh_scm2double scm_to_double
|
||||
#define gh_scm2int scm_to_int
|
||||
#define gh_scm2long scm_to_long
|
||||
#define gh_scm2short scm_to_short
|
||||
#define gh_scm2newstr SWIG_Guile_scm2newstr
|
||||
#define gh_scm2ulong scm_to_ulong
|
||||
#define gh_scm2ushort scm_to_ushort
|
||||
#define gh_scm2uint scm_to_uint
|
||||
#define gh_ulong2scm scm_from_ulong
|
||||
#define gh_long2scm scm_from_long
|
||||
#define gh_str02scm(str) str ? scm_from_locale_string(str) : SCM_BOOL_F
|
||||
#define gh_long_long2scm scm_from_long_long
|
||||
#define gh_scm2long_long scm_to_long_long
|
||||
#define gh_ulong_long2scm scm_from_ulong_long
|
||||
#define gh_scm2ulong_long scm_to_ulong_long
|
||||
#define gh_string_p scm_is_string
|
||||
#define gh_vector_length scm_c_vector_length
|
||||
#define gh_vector_p scm_is_vector
|
||||
#define gh_vector_ref scm_vector_ref
|
||||
#define gh_vector_set_x scm_vector_set_x
|
||||
#define gh_char2scm SCM_MAKE_CHAR
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* guile_gh.swg
|
||||
*
|
||||
* This SWIG interface file is processed if the Guile module is run
|
||||
* with gh_ flavor.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#define SWIGGUILE_GH
|
||||
|
||||
%runtime "swigrun.swg"
|
||||
%runtime "guile_gh_run.swg"
|
||||
|
||||
#define SWIG_convert_short(o) \
|
||||
SWIG_convert_integer(o, - (1 << (8 * sizeof(short) - 1)), \
|
||||
(1 << (8 * sizeof(short) - 1)) - 1, \
|
||||
FUNC_NAME, $argnum)
|
||||
#define SWIG_convert_unsigned_short(o) \
|
||||
SWIG_convert_unsigned_integer(o, 0, \
|
||||
(1 << (8 * sizeof(short))) - 1, \
|
||||
FUNC_NAME, $argnum)
|
||||
#define SWIG_convert_unsigned_int(o) \
|
||||
SWIG_convert_unsigned_integer(o, 0, UINT_MAX, \
|
||||
FUNC_NAME, $argnum)
|
||||
|
||||
#define gh_scm2short(a) SWIG_convert_short(a)
|
||||
#define gh_scm2ushort(a) SWIG_convert_unsigned_short(a)
|
||||
#define gh_scm2uint(a) SWIG_convert_unsigned_int(a)
|
||||
|
||||
%include <guile.i>
|
||||
|
||||
%runtime %{
|
||||
|
||||
/* scm_values was implemented on C level in 1.4.1, and the prototype
|
||||
is not included in libguile.h, so play safe and lookup `values'... */
|
||||
#define GUILE_MAYBE_VALUES \
|
||||
if (gswig_list_p) \
|
||||
gswig_result = gh_apply(gh_lookup("values"), gswig_result);
|
||||
|
||||
#define GUILE_MAYBE_VECTOR \
|
||||
if (gswig_list_p) \
|
||||
gswig_result = gh_list_to_vector(gswig_result);
|
||||
|
||||
#define SWIG_APPEND_VALUE(object) \
|
||||
if (gswig_result == SCM_UNSPECIFIED) { \
|
||||
gswig_result = object; \
|
||||
} else { \
|
||||
if (!gswig_list_p) { \
|
||||
gswig_list_p = 1; \
|
||||
gswig_result = gh_list(gswig_result, object, SCM_UNDEFINED); \
|
||||
} \
|
||||
else \
|
||||
gswig_result = gh_append2(gswig_result, \
|
||||
gh_list(object, SCM_UNDEFINED)); \
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
%init "swiginit.swg"
|
||||
|
||||
%init %{
|
||||
static int _swig_module_smob_tag;
|
||||
|
||||
SWIG_GUILE_INIT_STATIC void
|
||||
SWIG_init(void)
|
||||
{
|
||||
|
||||
SWIG_InitializeModule(0);
|
||||
swig_module.clientdata = (void *) &_swig_module_smob_tag;
|
||||
|
||||
SWIG_Guile_Init(&swig_module);
|
||||
%}
|
||||
|
|
@ -1,273 +0,0 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* guile_gh_run.swg
|
||||
*
|
||||
* Guile GH runtime file
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#define SWIGGUILE
|
||||
#include "guile/gh.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* 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 */
|
||||
/* ... setup guile 2-like interface for guile 1.8 */
|
||||
#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
|
||||
|
||||
typedef SCM (*swig_guile_proc)();
|
||||
|
||||
#define SWIG_malloc(size) \
|
||||
SCM_MUST_MALLOC(size)
|
||||
#define SWIG_free(mem) \
|
||||
scm_must_free(mem)
|
||||
#define SWIG_ConvertPtr(s, result, type, flags) \
|
||||
SWIG_Guile_ConvertPtr(&swig_module, s, result, type, flags)
|
||||
#define SWIG_MustGetPtr(s, type, argnum, flags) \
|
||||
SWIG_Guile_MustGetPtr(&swig_module, s, type, argnum, flags, FUNC_NAME)
|
||||
#define SWIG_NewPointerObj(ptr, type, owner) \
|
||||
SWIG_Guile_NewPointerObj(&swig_module, (void*)ptr, type, owner)
|
||||
#define SWIG_GetModule(clientdata) SWIG_Guile_GetModule(clientdata)
|
||||
#define SWIG_SetModule(clientdata, pointer) SWIG_Guile_SetModule(pointer)
|
||||
|
||||
/* Ignore object-ownership changes in gh mode */
|
||||
#define SWIG_Guile_MarkPointerNoncollectable(s) (s)
|
||||
#define SWIG_Guile_MarkPointerDestroyed(s) (s)
|
||||
|
||||
#define SWIG_contract_assert(expr, msg) \
|
||||
if (!(expr)) \
|
||||
scm_error(gh_symbol2scm("swig-contract-assertion-failed"), \
|
||||
(char *) FUNC_NAME, (char *) msg, \
|
||||
SCM_EOL, SCM_BOOL_F); else
|
||||
|
||||
/* SCM_CHAR and SCM_CHARP were introduced in Guile 1.4; the following is for
|
||||
1.3.4 compatibility. */
|
||||
#ifndef SCM_CHAR
|
||||
# define SCM_CHAR SCM_ICHR
|
||||
#endif
|
||||
#ifndef SCM_CHARP
|
||||
# define SCM_CHARP SCM_ICHRP
|
||||
#endif
|
||||
|
||||
/* This function replaces gh_scm2char, which is broken in Guile 1.4 */
|
||||
SWIGINTERN char
|
||||
GSWIG_scm2char (SCM s)
|
||||
{
|
||||
if (SCM_CHARP(s)) return SCM_CHAR(s);
|
||||
scm_wrong_type_arg(NULL, 0, s);
|
||||
}
|
||||
#define gh_scm2char GSWIG_scm2char
|
||||
|
||||
/* Interface function */
|
||||
#define SWIG_scm2str(x) gh_scm2newstr(x, NULL)
|
||||
|
||||
/* More 1.3.4 compatibility */
|
||||
#ifndef SCM_INPUT_PORT_P
|
||||
# define SCM_INPUT_PORT_P SCM_INPORTP
|
||||
# define SCM_OUTPUT_PORT_P SCM_OUTPORTP
|
||||
#endif
|
||||
|
||||
SWIGINTERN long
|
||||
SWIG_convert_integer(SCM o,
|
||||
long lower_bound, long upper_bound,
|
||||
const char *func_name, int argnum)
|
||||
{
|
||||
long value = gh_scm2long(o);
|
||||
if (value < lower_bound || value > upper_bound)
|
||||
scm_wrong_type_arg((char *) func_name, argnum, o);
|
||||
return value;
|
||||
}
|
||||
|
||||
SWIGINTERN unsigned long
|
||||
SWIG_convert_unsigned_integer(SCM o,
|
||||
unsigned long lower_bound,
|
||||
unsigned long upper_bound,
|
||||
const char *func_name, int argnum)
|
||||
{
|
||||
unsigned long value = gh_scm2ulong(o);
|
||||
if (value < lower_bound || value > upper_bound)
|
||||
scm_wrong_type_arg((char *) func_name, argnum, o);
|
||||
return value;
|
||||
}
|
||||
|
||||
SWIGINTERN swig_type_info *
|
||||
SWIG_Guile_LookupType(swig_module_info *module, SCM s, int normal)
|
||||
{
|
||||
swig_module_info *iter;
|
||||
if (!module) return 0;
|
||||
iter = module;
|
||||
do {
|
||||
if ((normal && (unsigned long) SCM_TYP16(s) == *((int *)iter->clientdata))) {
|
||||
|
||||
return iter->types[(long) SCM_CAR(s) >> 16];
|
||||
}
|
||||
iter = iter->next;
|
||||
} while (iter != module);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef SWIG_GLOBAL
|
||||
#define SWIG_GUILE_MODULE_STATIC
|
||||
#elif !defined(SWIG_NOINCLUDE)
|
||||
#define SWIG_GUILE_MODULE_STATIC static
|
||||
#endif
|
||||
|
||||
#ifdef SWIG_GUILE_MODULE_STATIC
|
||||
static swig_module_info *swig_guile_module = 0;
|
||||
SWIG_GUILE_MODULE_STATIC swig_module_info *SWIG_Guile_GetModule(void *SWIGUNUSEDPARM(clientdata)) {
|
||||
return swig_guile_module;
|
||||
}
|
||||
SWIG_GUILE_MODULE_STATIC void SWIG_Guile_SetModule(swig_module_info *pointer) {
|
||||
swig_guile_module = pointer;
|
||||
}
|
||||
#else
|
||||
SWIGEXPORT swig_module_info * SWIG_Guile_GetModule(void *SWIGUNUSEDPARM(clientdata));
|
||||
SWIGEXPORT void SWIG_Guile_SetModule(swig_module_info *pointer);
|
||||
#endif
|
||||
|
||||
SWIGINTERN SCM
|
||||
SWIG_Guile_NewPointerObj(swig_module_info *module, void *ptr,
|
||||
swig_type_info *type, int owner)
|
||||
{
|
||||
unsigned long tag;
|
||||
if (ptr==NULL) return SCM_EOL;
|
||||
if (!module) return SCM_EOL;
|
||||
for (tag = 0; tag < module->size; ++tag) {
|
||||
if (module->types[tag] == type)
|
||||
break;
|
||||
}
|
||||
if (tag >= module->size)
|
||||
return SCM_EOL;
|
||||
|
||||
|
||||
SCM_RETURN_NEWSMOB( ((tag << 16) | *((int *)module->clientdata)), ptr);
|
||||
}
|
||||
|
||||
/* Return 0 if successful. */
|
||||
SWIGINTERN int
|
||||
SWIG_Guile_ConvertPtr(swig_module_info *module, SCM s, void **result,
|
||||
swig_type_info *type, int flags)
|
||||
{
|
||||
swig_cast_info *cast;
|
||||
swig_type_info *from;
|
||||
if (scm_is_null(s)) {
|
||||
*result = NULL;
|
||||
return SWIG_OK;
|
||||
} else if (SCM_NIMP(s)) {
|
||||
from = SWIG_Guile_LookupType(module, s, 1);
|
||||
if (!from) return SWIG_ERROR;
|
||||
if (type) {
|
||||
cast = SWIG_TypeCheckStruct(from, type);
|
||||
if (cast) {
|
||||
int newmemory = 0;
|
||||
*result = SWIG_TypeCast(cast, (void *) SCM_CDR(s), &newmemory);
|
||||
assert(!newmemory); /* newmemory handling not yet implemented */
|
||||
return SWIG_OK;
|
||||
} else {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
} else {
|
||||
*result = (void *) SCM_CDR(s);
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
SWIGINTERN void *
|
||||
SWIG_Guile_MustGetPtr (swig_module_info *module, SCM s, swig_type_info *type,
|
||||
int argnum, int flags, const char *func_name)
|
||||
{
|
||||
void *result;
|
||||
int res = SWIG_Guile_ConvertPtr(module, s, &result, type, flags);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
/* type mismatch */
|
||||
scm_wrong_type_arg((char *) func_name, argnum, s);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Init */
|
||||
|
||||
SWIGINTERN int
|
||||
print_swig (SCM swig_smob, SCM port, scm_print_state *pstate)
|
||||
{
|
||||
swig_type_info *type = SWIG_Guile_LookupType(0, swig_smob, 1);
|
||||
if (type) {
|
||||
scm_puts((char *) "#<swig ", port);
|
||||
if (type->str != NULL)
|
||||
scm_puts((char *) type->str, port);
|
||||
else
|
||||
scm_puts((char *) type->name, port);
|
||||
scm_puts((char *) " ", port);
|
||||
scm_intprint((long) SCM_CDR(swig_smob), 16, port);
|
||||
scm_puts((char *) ">", port);
|
||||
/* non-zero means success */
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
SWIGINTERN SCM
|
||||
equalp_swig (SCM A, SCM B)
|
||||
{
|
||||
if (SCM_CAR(A) == SCM_CAR(B)
|
||||
&& SCM_CDR(A) == SCM_CDR(B))
|
||||
return SCM_BOOL_T;
|
||||
else return SCM_BOOL_F;
|
||||
}
|
||||
|
||||
SWIGINTERN void
|
||||
SWIG_Guile_Init (swig_module_info *module)
|
||||
{
|
||||
*((int *)module->clientdata) =
|
||||
scm_make_smob_type_mfpe((char *) "swig", 0, NULL, NULL, print_swig, equalp_swig);
|
||||
}
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_Guile_GetArgs (SCM *dest, SCM rest,
|
||||
int reqargs, int optargs,
|
||||
const char *procname)
|
||||
{
|
||||
int i;
|
||||
int num_args_passed = 0;
|
||||
for (i = 0; i<reqargs; i++) {
|
||||
if (!SCM_CONSP(rest))
|
||||
scm_wrong_num_args(gh_str02scm((char *) procname));
|
||||
*dest++ = SCM_CAR(rest);
|
||||
rest = SCM_CDR(rest);
|
||||
num_args_passed++;
|
||||
}
|
||||
for (i = 0; i<optargs && SCM_CONSP(rest); i++) {
|
||||
*dest++ = SCM_CAR(rest);
|
||||
rest = SCM_CDR(rest);
|
||||
num_args_passed++;
|
||||
}
|
||||
for (; i<optargs; i++)
|
||||
*dest++ = SCM_UNDEFINED;
|
||||
if (!scm_is_null(rest))
|
||||
scm_wrong_num_args(gh_str02scm((char *) procname));
|
||||
return num_args_passed;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* guile.swg ends here */
|
||||
|
|
@ -10,7 +10,6 @@
|
|||
%runtime "swigrun.swg" // Common C API type-checking code
|
||||
|
||||
%runtime "guile_scm_run.swg"
|
||||
%include <ghinterface.i>
|
||||
%include <guile.i>
|
||||
|
||||
%runtime %{
|
||||
|
|
@ -32,10 +31,6 @@
|
|||
else \
|
||||
gswig_result = scm_append(scm_listify(gswig_result, scm_listify(object, SCM_UNDEFINED), SCM_UNDEFINED)); \
|
||||
}
|
||||
/* used by Lib/exception.i */
|
||||
#define gh_symbol2scm scm_str2symbol
|
||||
/* useb by Lib/cdata.i */
|
||||
#define gh_str2scm scm_mem2string
|
||||
|
||||
%}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,10 +43,12 @@ typedef struct 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)
|
||||
scm_malloc(size)
|
||||
# define SWIG_free(mem) \
|
||||
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) \
|
||||
|
|
|
|||
|
|
@ -61,12 +61,12 @@
|
|||
(size_t VECTORLENINPUT, C_TYPE *VECTORINPUT)
|
||||
{
|
||||
SCM_VALIDATE_VECTOR($argnum, $input);
|
||||
$1 = gh_vector_length($input);
|
||||
$1 = scm_c_vector_length($input);
|
||||
if ($1 > 0) {
|
||||
$1_ltype i;
|
||||
$2 = (C_TYPE *) SWIG_malloc(sizeof(C_TYPE) * $1);
|
||||
for (i = 0; i<$1; i++) {
|
||||
SCM swig_scm_value = gh_vector_ref($input, gh_int2scm(i));
|
||||
SCM swig_scm_value = scm_vector_ref($input, scm_from_long(i));
|
||||
$2[i] = SCM_TO_C_EXPR;
|
||||
}
|
||||
}
|
||||
|
|
@ -78,15 +78,15 @@
|
|||
(size_t LISTLENINPUT, C_TYPE *LISTINPUT)
|
||||
{
|
||||
SCM_VALIDATE_LIST($argnum, $input);
|
||||
$1 = gh_length($input);
|
||||
$1 = scm_to_ulong(scm_length($input));
|
||||
if ($1 > 0) {
|
||||
$1_ltype i;
|
||||
SCM rest;
|
||||
$2 = (C_TYPE *) SWIG_malloc(sizeof(C_TYPE) * $1);
|
||||
for (i = 0, rest = $input;
|
||||
i<$1;
|
||||
i++, rest = gh_cdr(rest)) {
|
||||
SCM swig_scm_value = gh_car(rest);
|
||||
i++, rest = SCM_CDR(rest)) {
|
||||
SCM swig_scm_value = SCM_CAR(rest);
|
||||
$2[i] = SCM_TO_C_EXPR;
|
||||
}
|
||||
}
|
||||
|
|
@ -140,12 +140,12 @@
|
|||
(size_t *VECTORLENOUTPUT, C_TYPE **VECTOROUTPUT)
|
||||
{
|
||||
$*1_ltype i;
|
||||
SCM res = gh_make_vector(gh_int2scm(*$1),
|
||||
SCM res = scm_make_vector(scm_from_long(*$1),
|
||||
SCM_BOOL_F);
|
||||
for (i = 0; i<*$1; i++) {
|
||||
C_TYPE swig_c_value = (*$2)[i];
|
||||
SCM elt = C_TO_SCM_EXPR;
|
||||
gh_vector_set_x(res, gh_int2scm(i), elt);
|
||||
scm_vector_set_x(res, scm_from_long(i), elt);
|
||||
}
|
||||
SWIG_APPEND_VALUE(res);
|
||||
}
|
||||
|
|
@ -159,7 +159,7 @@
|
|||
for (i = ((int)(*$1)) - 1; i>=0; i--) {
|
||||
C_TYPE swig_c_value = (*$2)[i];
|
||||
SCM elt = C_TO_SCM_EXPR;
|
||||
res = gh_cons(elt, res);
|
||||
res = scm_cons(elt, res);
|
||||
}
|
||||
SWIG_APPEND_VALUE(res);
|
||||
}
|
||||
|
|
@ -200,21 +200,21 @@
|
|||
|
||||
/* We use the macro to define typemaps for some standard types. */
|
||||
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(bool, gh_scm2bool, gh_bool2scm, boolean);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(char, gh_scm2char, gh_char2scm, char);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned char, gh_scm2char, gh_char2scm, char);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(int, gh_scm2int, gh_int2scm, integer);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(short, gh_scm2int, gh_int2scm, integer);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(long, gh_scm2long, gh_long2scm, integer);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(ptrdiff_t, gh_scm2long, gh_long2scm, integer);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned int, gh_scm2ulong, gh_ulong2scm, integer);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned short, gh_scm2ulong, gh_ulong2scm, integer);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned long, gh_scm2ulong, gh_ulong2scm, integer);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(size_t, gh_scm2ulong, gh_ulong2scm, integer);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(float, gh_scm2double, gh_double2scm, real);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(double, gh_scm2double, gh_double2scm, real);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(char *, SWIG_scm2str, gh_str02scm, string);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, gh_str02scm, string);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(bool, scm_is_true, scm_from_bool, boolean);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(char, SCM_CHAR, SCM_MAKE_CHAR, char);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned char, SCM_CHAR, SCM_MAKE_CHAR, char);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(int, scm_to_int, scm_from_long, integer);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(short, scm_to_int, scm_from_long, integer);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(long, scm_to_long, scm_from_long, integer);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(ptrdiff_t, scm_to_long, scm_from_long, integer);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned int, scm_to_ulong, scm_from_ulong, integer);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned short, scm_to_ulong, scm_from_ulong, integer);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(unsigned long, scm_to_ulong, scm_from_ulong, integer);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(size_t, scm_to_ulong, scm_from_ulong, integer);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(float, scm_to_double, scm_from_double, real);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(double, scm_to_double, scm_from_double, real);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(char *, SWIG_scm2str, SWIG_str02scm, string);
|
||||
TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, SWIG_str02scm, string);
|
||||
|
||||
/* For the char *, free all strings after converting */
|
||||
|
||||
|
|
@ -312,13 +312,13 @@ TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, gh_str02scm, string
|
|||
const C_TYPE *PARALLEL_VECTORINPUT
|
||||
{
|
||||
SCM_VALIDATE_VECTOR($argnum, $input);
|
||||
*_global_vector_length = gh_vector_length($input);
|
||||
*_global_vector_length = scm_c_vector_length($input);
|
||||
if (*_global_vector_length > 0) {
|
||||
int i;
|
||||
$1 = (C_TYPE *) SWIG_malloc(sizeof(C_TYPE)
|
||||
* (*_global_vector_length));
|
||||
for (i = 0; i<*_global_vector_length; i++) {
|
||||
SCM swig_scm_value = gh_vector_ref($input, gh_int2scm(i));
|
||||
SCM swig_scm_value = scm_vector_ref($input, scm_from_long(i));
|
||||
$1[i] = SCM_TO_C_EXPR;
|
||||
}
|
||||
}
|
||||
|
|
@ -330,7 +330,7 @@ TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, gh_str02scm, string
|
|||
const C_TYPE *PARALLEL_LISTINPUT
|
||||
{
|
||||
SCM_VALIDATE_LIST($argnum, $input);
|
||||
*_global_list_length = gh_length($input);
|
||||
*_global_list_length = scm_to_ulong(scm_length($input));
|
||||
if (*_global_list_length > 0) {
|
||||
int i;
|
||||
SCM rest;
|
||||
|
|
@ -338,8 +338,8 @@ TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, gh_str02scm, string
|
|||
* (*_global_list_length));
|
||||
for (i = 0, rest = $input;
|
||||
i<*_global_list_length;
|
||||
i++, rest = gh_cdr(rest)) {
|
||||
SCM swig_scm_value = gh_car(rest);
|
||||
i++, rest = SCM_CDR(rest)) {
|
||||
SCM swig_scm_value = SCM_CAR(rest);
|
||||
$1[i] = SCM_TO_C_EXPR;
|
||||
}
|
||||
}
|
||||
|
|
@ -391,12 +391,12 @@ TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, gh_str02scm, string
|
|||
C_TYPE **PARALLEL_VECTOROUTPUT
|
||||
{
|
||||
int i;
|
||||
SCM res = gh_make_vector(gh_int2scm(_global_arraylentemp),
|
||||
SCM res = scm_make_vector(scm_from_long(_global_arraylentemp),
|
||||
SCM_BOOL_F);
|
||||
for (i = 0; i<_global_arraylentemp; i++) {
|
||||
C_TYPE swig_c_value = (*$1)[i];
|
||||
SCM elt = C_TO_SCM_EXPR;
|
||||
gh_vector_set_x(res, gh_int2scm(i), elt);
|
||||
scm_vector_set_x(res, scm_from_long(i), elt);
|
||||
}
|
||||
SWIG_APPEND_VALUE(res);
|
||||
}
|
||||
|
|
@ -410,7 +410,7 @@ TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, gh_str02scm, string
|
|||
for (i = _global_arraylentemp - 1; i>=0; i--) {
|
||||
C_TYPE swig_c_value = (*$1)[i];
|
||||
SCM elt = C_TO_SCM_EXPR;
|
||||
res = gh_cons(elt, res);
|
||||
res = scm_cons(elt, res);
|
||||
}
|
||||
}
|
||||
SWIG_APPEND_VALUE(res);
|
||||
|
|
@ -449,21 +449,21 @@ TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, gh_str02scm, string
|
|||
|
||||
/* We use the macro to define typemaps for some standard types. */
|
||||
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(bool, gh_scm2bool, gh_bool2scm, boolean);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(char, gh_scm2char, gh_char2scm, char);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned char, gh_scm2char, gh_char2scm, char);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(int, gh_scm2int, gh_int2scm, integer);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(short, gh_scm2int, gh_int2scm, integer);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(long, gh_scm2long, gh_long2scm, integer);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(ptrdiff_t, gh_scm2long, gh_long2scm, integer);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned int, gh_scm2ulong, gh_ulong2scm, integer);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned short, gh_scm2ulong, gh_ulong2scm, integer);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned long, gh_scm2ulong, gh_ulong2scm, integer);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(size_t, gh_scm2ulong, gh_ulong2scm, integer);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(float, gh_scm2double, gh_double2scm, real);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(double, gh_scm2double, gh_double2scm, real);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(char *, SWIG_scm2str, gh_str02scm, string);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, gh_str02scm, string);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(bool, scm_is_true, scm_from_bool, boolean);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(char, SCM_CHAR, SCM_MAKE_CHAR, char);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned char, SCM_CHAR, SCM_MAKE_CHAR, char);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(int, scm_to_int, scm_from_long, integer);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(short, scm_to_int, scm_from_long, integer);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(long, scm_to_long, scm_from_long, integer);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(ptrdiff_t, scm_to_long, scm_from_long, integer);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned int, scm_to_ulong, scm_from_ulong, integer);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned short, scm_to_ulong, scm_from_ulong, integer);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(unsigned long, scm_to_ulong, scm_from_ulong, integer);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(size_t, scm_to_ulong, scm_from_ulong, integer);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(float, scm_to_double, scm_from_double, real);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(double, scm_to_double, scm_from_double, real);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(char *, SWIG_scm2str, SWIG_str02scm, string);
|
||||
TYPEMAP_PARALLEL_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, SWIG_str02scm, string);
|
||||
|
||||
%typemap(freearg) char **PARALLEL_LISTINPUT, char **PARALLEL_VECTORINPUT,
|
||||
const char **PARALLEL_LISTINPUT, const char **PARALLEL_VECTORINPUT
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
%apply size_t { std::size_t };
|
||||
|
||||
#define SWIG_bool2scm(b) gh_bool2scm(b ? 1 : 0)
|
||||
#define SWIG_string2scm(s) gh_str02scm(s.c_str())
|
||||
#define SWIG_bool2scm(b) scm_from_bool(b ? 1 : 0)
|
||||
#define SWIG_string2scm(s) SWIG_str02scm(s.c_str())
|
||||
|
||||
%{
|
||||
#include <string>
|
||||
|
|
|
|||
1148
Lib/guile/std_map.i
1148
Lib/guile/std_map.i
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -27,7 +27,7 @@ namespace std {
|
|||
%typemap(typecheck) const string & = char *;
|
||||
|
||||
%typemap(in) string (char * tempptr) {
|
||||
if (gh_string_p($input)) {
|
||||
if (scm_is_string($input)) {
|
||||
tempptr = SWIG_scm2str($input);
|
||||
$1.assign(tempptr);
|
||||
if (tempptr) SWIG_free(tempptr);
|
||||
|
|
@ -37,7 +37,7 @@ namespace std {
|
|||
}
|
||||
|
||||
%typemap(in) const string & ($*1_ltype temp, char *tempptr) {
|
||||
if (gh_string_p($input)) {
|
||||
if (scm_is_string($input)) {
|
||||
tempptr = SWIG_scm2str($input);
|
||||
temp.assign(tempptr);
|
||||
if (tempptr) SWIG_free(tempptr);
|
||||
|
|
@ -48,7 +48,7 @@ namespace std {
|
|||
}
|
||||
|
||||
%typemap(in) string * (char *tempptr) {
|
||||
if (gh_string_p($input)) {
|
||||
if (scm_is_string($input)) {
|
||||
tempptr = SWIG_scm2str($input);
|
||||
$1 = new $*1_ltype(tempptr);
|
||||
if (tempptr) SWIG_free(tempptr);
|
||||
|
|
@ -58,19 +58,19 @@ namespace std {
|
|||
}
|
||||
|
||||
%typemap(out) string {
|
||||
$result = gh_str02scm($1.c_str());
|
||||
$result = SWIG_str02scm($1.c_str());
|
||||
}
|
||||
|
||||
%typemap(out) const string & {
|
||||
$result = gh_str02scm($1->c_str());
|
||||
$result = SWIG_str02scm($1->c_str());
|
||||
}
|
||||
|
||||
%typemap(out) string * {
|
||||
$result = gh_str02scm($1->c_str());
|
||||
$result = SWIG_str02scm($1->c_str());
|
||||
}
|
||||
|
||||
%typemap(varin) string {
|
||||
if (gh_string_p($input)) {
|
||||
if (scm_is_string($input)) {
|
||||
char *tempptr = SWIG_scm2str($input);
|
||||
$1.assign(tempptr);
|
||||
if (tempptr) SWIG_free(tempptr);
|
||||
|
|
@ -80,7 +80,7 @@ namespace std {
|
|||
}
|
||||
|
||||
%typemap(varout) string {
|
||||
$result = gh_str02scm($1.c_str());
|
||||
$result = SWIG_str02scm($1.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,23 +42,23 @@ namespace std {
|
|||
|
||||
template<class T> class vector {
|
||||
%typemap(in) vector<T> {
|
||||
if (gh_vector_p($input)) {
|
||||
unsigned long size = gh_vector_length($input);
|
||||
if (scm_is_vector($input)) {
|
||||
unsigned long size = scm_c_vector_length($input);
|
||||
$1 = std::vector<T >(size);
|
||||
for (unsigned long i=0; i<size; i++) {
|
||||
SCM o = gh_vector_ref($input,gh_ulong2scm(i));
|
||||
SCM o = scm_vector_ref($input,scm_from_ulong(i));
|
||||
(($1_type &)$1)[i] =
|
||||
*((T*) SWIG_MustGetPtr(o,$descriptor(T *),$argnum, 0));
|
||||
}
|
||||
} else if (gh_null_p($input)) {
|
||||
} else if (scm_is_null($input)) {
|
||||
$1 = std::vector<T >();
|
||||
} else if (gh_pair_p($input)) {
|
||||
} else if (scm_is_pair($input)) {
|
||||
SCM head, tail;
|
||||
$1 = std::vector<T >();
|
||||
tail = $input;
|
||||
while (!gh_null_p(tail)) {
|
||||
head = gh_car(tail);
|
||||
tail = gh_cdr(tail);
|
||||
while (!scm_is_null(tail)) {
|
||||
head = SCM_CAR(tail);
|
||||
tail = SCM_CDR(tail);
|
||||
$1.push_back(*((T*)SWIG_MustGetPtr(head,
|
||||
$descriptor(T *),
|
||||
$argnum, 0)));
|
||||
|
|
@ -70,27 +70,27 @@ namespace std {
|
|||
}
|
||||
%typemap(in) const vector<T>& (std::vector<T> temp),
|
||||
const vector<T>* (std::vector<T> temp) {
|
||||
if (gh_vector_p($input)) {
|
||||
unsigned long size = gh_vector_length($input);
|
||||
if (scm_is_vector($input)) {
|
||||
unsigned long size = scm_c_vector_length($input);
|
||||
temp = std::vector<T >(size);
|
||||
$1 = &temp;
|
||||
for (unsigned long i=0; i<size; i++) {
|
||||
SCM o = gh_vector_ref($input,gh_ulong2scm(i));
|
||||
SCM o = scm_vector_ref($input,scm_from_ulong(i));
|
||||
temp[i] = *((T*) SWIG_MustGetPtr(o,
|
||||
$descriptor(T *),
|
||||
$argnum, 0));
|
||||
}
|
||||
} else if (gh_null_p($input)) {
|
||||
} else if (scm_is_null($input)) {
|
||||
temp = std::vector<T >();
|
||||
$1 = &temp;
|
||||
} else if (gh_pair_p($input)) {
|
||||
} else if (scm_is_pair($input)) {
|
||||
temp = std::vector<T >();
|
||||
$1 = &temp;
|
||||
SCM head, tail;
|
||||
tail = $input;
|
||||
while (!gh_null_p(tail)) {
|
||||
head = gh_car(tail);
|
||||
tail = gh_cdr(tail);
|
||||
while (!scm_is_null(tail)) {
|
||||
head = SCM_CAR(tail);
|
||||
tail = SCM_CDR(tail);
|
||||
temp.push_back(*((T*) SWIG_MustGetPtr(head,
|
||||
$descriptor(T *),
|
||||
$argnum, 0)));
|
||||
|
|
@ -100,23 +100,23 @@ namespace std {
|
|||
}
|
||||
}
|
||||
%typemap(out) vector<T> {
|
||||
$result = gh_make_vector(gh_long2scm($1.size()),SCM_UNSPECIFIED);
|
||||
$result = scm_make_vector(scm_from_long($1.size()),SCM_UNSPECIFIED);
|
||||
for (unsigned int i=0; i<$1.size(); i++) {
|
||||
T* x = new T((($1_type &)$1)[i]);
|
||||
gh_vector_set_x($result,gh_long2scm(i),
|
||||
scm_vector_set_x($result,scm_from_long(i),
|
||||
SWIG_NewPointerObj(x, $descriptor(T *), 1));
|
||||
}
|
||||
}
|
||||
%typecheck(SWIG_TYPECHECK_VECTOR) vector<T> {
|
||||
/* native sequence? */
|
||||
if (gh_vector_p($input)) {
|
||||
unsigned int size = gh_vector_length($input);
|
||||
if (scm_is_vector($input)) {
|
||||
unsigned int size = scm_c_vector_length($input);
|
||||
if (size == 0) {
|
||||
/* an empty sequence can be of any type */
|
||||
$1 = 1;
|
||||
} else {
|
||||
/* check the first element only */
|
||||
SCM o = gh_vector_ref($input,gh_ulong2scm(0));
|
||||
SCM o = scm_vector_ref($input,scm_from_ulong(0));
|
||||
T* x;
|
||||
if (SWIG_ConvertPtr(o,(void**) &x,
|
||||
$descriptor(T *), 0) != -1)
|
||||
|
|
@ -124,13 +124,13 @@ namespace std {
|
|||
else
|
||||
$1 = 0;
|
||||
}
|
||||
} else if (gh_null_p($input)) {
|
||||
} else if (scm_is_null($input)) {
|
||||
/* again, an empty sequence can be of any type */
|
||||
$1 = 1;
|
||||
} else if (gh_pair_p($input)) {
|
||||
} else if (scm_is_pair($input)) {
|
||||
/* check the first element only */
|
||||
T* x;
|
||||
SCM head = gh_car($input);
|
||||
SCM head = SCM_CAR($input);
|
||||
if (SWIG_ConvertPtr(head,(void**) &x,
|
||||
$descriptor(T *), 0) != -1)
|
||||
$1 = 1;
|
||||
|
|
@ -149,28 +149,28 @@ namespace std {
|
|||
%typecheck(SWIG_TYPECHECK_VECTOR) const vector<T>&,
|
||||
const vector<T>* {
|
||||
/* native sequence? */
|
||||
if (gh_vector_p($input)) {
|
||||
unsigned int size = gh_vector_length($input);
|
||||
if (scm_is_vector($input)) {
|
||||
unsigned int size = scm_c_vector_length($input);
|
||||
if (size == 0) {
|
||||
/* an empty sequence can be of any type */
|
||||
$1 = 1;
|
||||
} else {
|
||||
/* check the first element only */
|
||||
T* x;
|
||||
SCM o = gh_vector_ref($input,gh_ulong2scm(0));
|
||||
SCM o = scm_vector_ref($input,scm_from_ulong(0));
|
||||
if (SWIG_ConvertPtr(o,(void**) &x,
|
||||
$descriptor(T *), 0) != -1)
|
||||
$1 = 1;
|
||||
else
|
||||
$1 = 0;
|
||||
}
|
||||
} else if (gh_null_p($input)) {
|
||||
} else if (scm_is_null($input)) {
|
||||
/* again, an empty sequence can be of any type */
|
||||
$1 = 1;
|
||||
} else if (gh_pair_p($input)) {
|
||||
} else if (scm_is_pair($input)) {
|
||||
/* check the first element only */
|
||||
T* x;
|
||||
SCM head = gh_car($input);
|
||||
SCM head = SCM_CAR($input);
|
||||
if (SWIG_ConvertPtr(head,(void**) &x,
|
||||
$descriptor(T *), 0) != -1)
|
||||
$1 = 1;
|
||||
|
|
@ -230,24 +230,24 @@ namespace std {
|
|||
%define specialize_stl_vector(T,CHECK,CONVERT_FROM,CONVERT_TO)
|
||||
template<> class vector<T> {
|
||||
%typemap(in) vector<T> {
|
||||
if (gh_vector_p($input)) {
|
||||
unsigned long size = gh_vector_length($input);
|
||||
if (scm_is_vector($input)) {
|
||||
unsigned long size = scm_c_vector_length($input);
|
||||
$1 = std::vector<T >(size);
|
||||
for (unsigned long i=0; i<size; i++) {
|
||||
SCM o = gh_vector_ref($input,gh_ulong2scm(i));
|
||||
SCM o = scm_vector_ref($input,scm_from_ulong(i));
|
||||
if (CHECK(o))
|
||||
(($1_type &)$1)[i] = (T)(CONVERT_FROM(o));
|
||||
else
|
||||
scm_wrong_type_arg(FUNC_NAME, $argnum, $input);
|
||||
}
|
||||
} else if (gh_null_p($input)) {
|
||||
} else if (scm_is_null($input)) {
|
||||
$1 = std::vector<T >();
|
||||
} else if (gh_pair_p($input)) {
|
||||
SCM v = gh_list_to_vector($input);
|
||||
unsigned long size = gh_vector_length(v);
|
||||
} else if (scm_is_pair($input)) {
|
||||
SCM v = scm_vector($input);
|
||||
unsigned long size = scm_c_vector_length(v);
|
||||
$1 = std::vector<T >(size);
|
||||
for (unsigned long i=0; i<size; i++) {
|
||||
SCM o = gh_vector_ref(v,gh_ulong2scm(i));
|
||||
SCM o = scm_vector_ref(v,scm_from_ulong(i));
|
||||
if (CHECK(o))
|
||||
(($1_type &)$1)[i] = (T)(CONVERT_FROM(o));
|
||||
else
|
||||
|
|
@ -260,27 +260,27 @@ namespace std {
|
|||
}
|
||||
%typemap(in) const vector<T>& (std::vector<T> temp),
|
||||
const vector<T>* (std::vector<T> temp) {
|
||||
if (gh_vector_p($input)) {
|
||||
unsigned long size = gh_vector_length($input);
|
||||
if (scm_is_vector($input)) {
|
||||
unsigned long size = scm_c_vector_length($input);
|
||||
temp = std::vector<T >(size);
|
||||
$1 = &temp;
|
||||
for (unsigned long i=0; i<size; i++) {
|
||||
SCM o = gh_vector_ref($input,gh_ulong2scm(i));
|
||||
SCM o = scm_vector_ref($input,scm_from_ulong(i));
|
||||
if (CHECK(o))
|
||||
temp[i] = (T)(CONVERT_FROM(o));
|
||||
else
|
||||
scm_wrong_type_arg(FUNC_NAME, $argnum, $input);
|
||||
}
|
||||
} else if (gh_null_p($input)) {
|
||||
} else if (scm_is_null($input)) {
|
||||
temp = std::vector<T >();
|
||||
$1 = &temp;
|
||||
} else if (gh_pair_p($input)) {
|
||||
SCM v = gh_list_to_vector($input);
|
||||
unsigned long size = gh_vector_length(v);
|
||||
} else if (scm_is_pair($input)) {
|
||||
SCM v = scm_vector($input);
|
||||
unsigned long size = scm_c_vector_length(v);
|
||||
temp = std::vector<T >(size);
|
||||
$1 = &temp;
|
||||
for (unsigned long i=0; i<size; i++) {
|
||||
SCM o = gh_vector_ref(v,gh_ulong2scm(i));
|
||||
SCM o = scm_vector_ref(v,scm_from_ulong(i));
|
||||
if (CHECK(o))
|
||||
temp[i] = (T)(CONVERT_FROM(o));
|
||||
else
|
||||
|
|
@ -291,32 +291,32 @@ namespace std {
|
|||
}
|
||||
}
|
||||
%typemap(out) vector<T> {
|
||||
$result = gh_make_vector(gh_long2scm($1.size()),SCM_UNSPECIFIED);
|
||||
$result = scm_make_vector(scm_from_long($1.size()),SCM_UNSPECIFIED);
|
||||
for (unsigned int i=0; i<$1.size(); i++) {
|
||||
SCM x = CONVERT_TO((($1_type &)$1)[i]);
|
||||
gh_vector_set_x($result,gh_long2scm(i),x);
|
||||
scm_vector_set_x($result,scm_from_long(i),x);
|
||||
}
|
||||
}
|
||||
%typecheck(SWIG_TYPECHECK_VECTOR) vector<T> {
|
||||
/* native sequence? */
|
||||
if (gh_vector_p($input)) {
|
||||
unsigned int size = gh_vector_length($input);
|
||||
if (scm_is_vector($input)) {
|
||||
unsigned int size = scm_c_vector_length($input);
|
||||
if (size == 0) {
|
||||
/* an empty sequence can be of any type */
|
||||
$1 = 1;
|
||||
} else {
|
||||
/* check the first element only */
|
||||
T* x;
|
||||
SCM o = gh_vector_ref($input,gh_ulong2scm(0));
|
||||
SCM o = scm_vector_ref($input,scm_from_ulong(0));
|
||||
$1 = CHECK(o) ? 1 : 0;
|
||||
}
|
||||
} else if (gh_null_p($input)) {
|
||||
} else if (scm_is_null($input)) {
|
||||
/* again, an empty sequence can be of any type */
|
||||
$1 = 1;
|
||||
} else if (gh_pair_p($input)) {
|
||||
} else if (scm_is_pair($input)) {
|
||||
/* check the first element only */
|
||||
T* x;
|
||||
SCM head = gh_car($input);
|
||||
SCM head = SCM_CAR($input);
|
||||
$1 = CHECK(head) ? 1 : 0;
|
||||
} else {
|
||||
/* wrapped vector? */
|
||||
|
|
@ -328,24 +328,24 @@ namespace std {
|
|||
%typecheck(SWIG_TYPECHECK_VECTOR) const vector<T>&,
|
||||
const vector<T>* {
|
||||
/* native sequence? */
|
||||
if (gh_vector_p($input)) {
|
||||
unsigned int size = gh_vector_length($input);
|
||||
if (scm_is_vector($input)) {
|
||||
unsigned int size = scm_c_vector_length($input);
|
||||
if (size == 0) {
|
||||
/* an empty sequence can be of any type */
|
||||
$1 = 1;
|
||||
} else {
|
||||
/* check the first element only */
|
||||
T* x;
|
||||
SCM o = gh_vector_ref($input,gh_ulong2scm(0));
|
||||
SCM o = scm_vector_ref($input,scm_from_ulong(0));
|
||||
$1 = CHECK(o) ? 1 : 0;
|
||||
}
|
||||
} else if (gh_null_p($input)) {
|
||||
} else if (scm_is_null($input)) {
|
||||
/* again, an empty sequence can be of any type */
|
||||
$1 = 1;
|
||||
} else if (gh_pair_p($input)) {
|
||||
} else if (scm_is_pair($input)) {
|
||||
/* check the first element only */
|
||||
T* x;
|
||||
SCM head = gh_car($input);
|
||||
SCM head = SCM_CAR($input);
|
||||
$1 = CHECK(head) ? 1 : 0;
|
||||
} else {
|
||||
/* wrapped vector? */
|
||||
|
|
@ -394,17 +394,17 @@ namespace std {
|
|||
};
|
||||
%enddef
|
||||
|
||||
specialize_stl_vector(bool,gh_boolean_p,gh_scm2bool,SWIG_bool2scm);
|
||||
specialize_stl_vector(char,gh_number_p,gh_scm2long,gh_long2scm);
|
||||
specialize_stl_vector(int,gh_number_p,gh_scm2long,gh_long2scm);
|
||||
specialize_stl_vector(long,gh_number_p,gh_scm2long,gh_long2scm);
|
||||
specialize_stl_vector(short,gh_number_p,gh_scm2long,gh_long2scm);
|
||||
specialize_stl_vector(unsigned char,gh_number_p,gh_scm2ulong,gh_ulong2scm);
|
||||
specialize_stl_vector(unsigned int,gh_number_p,gh_scm2ulong,gh_ulong2scm);
|
||||
specialize_stl_vector(unsigned long,gh_number_p,gh_scm2ulong,gh_ulong2scm);
|
||||
specialize_stl_vector(unsigned short,gh_number_p,gh_scm2ulong,gh_ulong2scm);
|
||||
specialize_stl_vector(float,gh_number_p,gh_scm2double,gh_double2scm);
|
||||
specialize_stl_vector(double,gh_number_p,gh_scm2double,gh_double2scm);
|
||||
specialize_stl_vector(std::string,gh_string_p,SWIG_scm2string,SWIG_string2scm);
|
||||
specialize_stl_vector(bool,scm_is_bool,scm_is_true,SWIG_bool2scm);
|
||||
specialize_stl_vector(char,scm_is_number,scm_to_long,scm_from_long);
|
||||
specialize_stl_vector(int,scm_is_number,scm_to_long,scm_from_long);
|
||||
specialize_stl_vector(long,scm_is_number,scm_to_long,scm_from_long);
|
||||
specialize_stl_vector(short,scm_is_number,scm_to_long,scm_from_long);
|
||||
specialize_stl_vector(unsigned char,scm_is_number,scm_to_ulong,scm_from_ulong);
|
||||
specialize_stl_vector(unsigned int,scm_is_number,scm_to_ulong,scm_from_ulong);
|
||||
specialize_stl_vector(unsigned long,scm_is_number,scm_to_ulong,scm_from_ulong);
|
||||
specialize_stl_vector(unsigned short,scm_is_number,scm_to_ulong,scm_from_ulong);
|
||||
specialize_stl_vector(float,scm_is_number,scm_to_double,scm_from_double);
|
||||
specialize_stl_vector(double,scm_is_number,scm_to_double,scm_from_double);
|
||||
specialize_stl_vector(std::string,scm_is_string,SWIG_scm2string,SWIG_string2scm);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -60,26 +60,26 @@
|
|||
|
||||
%typemap(throws) SWIGTYPE {
|
||||
$<ype temp = new $ltype($1);
|
||||
scm_throw(gh_symbol2scm((char *) "swig-exception"),
|
||||
gh_list(SWIG_NewPointerObj(temp, $&descriptor, 1),
|
||||
scm_throw(scm_str2symbol((char *) "swig-exception"),
|
||||
scm_listify(SWIG_NewPointerObj(temp, $&descriptor, 1),
|
||||
SCM_UNDEFINED));
|
||||
}
|
||||
|
||||
%typemap(throws) SWIGTYPE & {
|
||||
scm_throw(gh_symbol2scm((char *) "swig-exception"),
|
||||
gh_list(SWIG_NewPointerObj(&$1, $descriptor, 1),
|
||||
scm_throw(scm_str2symbol((char *) "swig-exception"),
|
||||
scm_listify(SWIG_NewPointerObj(&$1, $descriptor, 1),
|
||||
SCM_UNDEFINED));
|
||||
}
|
||||
|
||||
%typemap(throws) SWIGTYPE * {
|
||||
scm_throw(gh_symbol2scm((char *) "swig-exception"),
|
||||
gh_list(SWIG_NewPointerObj($1, $descriptor, 1),
|
||||
scm_throw(scm_str2symbol((char *) "swig-exception"),
|
||||
scm_listify(SWIG_NewPointerObj($1, $descriptor, 1),
|
||||
SCM_UNDEFINED));
|
||||
}
|
||||
|
||||
%typemap(throws) SWIGTYPE [] {
|
||||
scm_throw(gh_symbol2scm((char *) "swig-exception"),
|
||||
gh_list(SWIG_NewPointerObj($1, $descriptor, 1),
|
||||
scm_throw(scm_str2symbol((char *) "swig-exception"),
|
||||
scm_listify(SWIG_NewPointerObj($1, $descriptor, 1),
|
||||
SCM_UNDEFINED));
|
||||
}
|
||||
|
||||
|
|
@ -146,7 +146,7 @@
|
|||
|
||||
/* Enums */
|
||||
|
||||
%typemap(in) enum SWIGTYPE { $1 = ($1_type) gh_scm2int($input); }
|
||||
%typemap(in) enum SWIGTYPE { $1 = ($1_type) scm_to_int($input); }
|
||||
/* The complicated construction below needed to deal with anonymous
|
||||
enums, which cannot be cast to. */
|
||||
%typemap(varin) enum SWIGTYPE {
|
||||
|
|
@ -156,13 +156,13 @@
|
|||
(char *) "enum variable '$name' cannot be set",
|
||||
SCM_EOL, SCM_BOOL_F);
|
||||
}
|
||||
* (int *) &($1) = gh_scm2int($input);
|
||||
* (int *) &($1) = scm_to_int($input);
|
||||
}
|
||||
%typemap(out) enum SWIGTYPE { $result = gh_int2scm($1); }
|
||||
%typemap(varout) enum SWIGTYPE { $result = gh_int2scm($1); }
|
||||
%typemap(out) enum SWIGTYPE { $result = scm_from_long($1); }
|
||||
%typemap(varout) enum SWIGTYPE { $result = scm_from_long($1); }
|
||||
%typemap(throws) enum SWIGTYPE {
|
||||
scm_throw(gh_symbol2scm((char *) "swig-exception"),
|
||||
gh_list(gh_int2scm($1), SCM_UNDEFINED));
|
||||
scm_throw(scm_str2symbol((char *) "swig-exception"),
|
||||
scm_listify(scm_from_long($1), SCM_UNDEFINED));
|
||||
}
|
||||
|
||||
/* The SIMPLE_MAP_WITH_EXPR macro below defines the whole set of
|
||||
|
|
@ -210,8 +210,8 @@
|
|||
/* Throw typemap */
|
||||
%typemap(throws) C_NAME {
|
||||
C_NAME swig_c_value = $1;
|
||||
scm_throw(gh_symbol2scm((char *) "swig-exception"),
|
||||
gh_list(C_TO_SCM_EXPR, SCM_UNDEFINED));
|
||||
scm_throw(scm_str2symbol((char *) "swig-exception"),
|
||||
scm_listify(C_TO_SCM_EXPR, SCM_UNDEFINED));
|
||||
}
|
||||
%enddef
|
||||
|
||||
|
|
@ -254,34 +254,34 @@
|
|||
}
|
||||
/* Throw typemap */
|
||||
%typemap(throws) C_NAME {
|
||||
scm_throw(gh_symbol2scm((char *) "swig-exception"),
|
||||
gh_list(C_TO_SCM($1), SCM_UNDEFINED));
|
||||
scm_throw(scm_str2symbol((char *) "swig-exception"),
|
||||
scm_listify(C_TO_SCM($1), SCM_UNDEFINED));
|
||||
}
|
||||
%enddef
|
||||
|
||||
SIMPLE_MAP(bool, gh_scm2bool, gh_bool2scm, boolean);
|
||||
SIMPLE_MAP(char, gh_scm2char, gh_char2scm, char);
|
||||
SIMPLE_MAP(unsigned char, gh_scm2char, gh_char2scm, char);
|
||||
SIMPLE_MAP(signed char, gh_scm2char, gh_char2scm, char);
|
||||
SIMPLE_MAP(int, gh_scm2int, gh_int2scm, integer);
|
||||
SIMPLE_MAP(short, gh_scm2short, gh_int2scm, integer);
|
||||
SIMPLE_MAP(long, gh_scm2long, gh_long2scm, integer);
|
||||
SIMPLE_MAP(ptrdiff_t, gh_scm2long, gh_long2scm, integer);
|
||||
SIMPLE_MAP(unsigned int, gh_scm2uint, gh_ulong2scm, integer);
|
||||
SIMPLE_MAP(unsigned short, gh_scm2ushort, gh_ulong2scm, integer);
|
||||
SIMPLE_MAP(unsigned long, gh_scm2ulong, gh_ulong2scm, integer);
|
||||
SIMPLE_MAP(size_t, gh_scm2ulong, gh_ulong2scm, integer);
|
||||
SIMPLE_MAP(float, gh_scm2double, gh_double2scm, real);
|
||||
SIMPLE_MAP(double, gh_scm2double, gh_double2scm, real);
|
||||
// SIMPLE_MAP(char *, SWIG_scm2str, gh_str02scm, string);
|
||||
// SIMPLE_MAP(const char *, SWIG_scm2str, gh_str02scm, string);
|
||||
SIMPLE_MAP(bool, scm_is_true, scm_from_bool, boolean);
|
||||
SIMPLE_MAP(char, SCM_CHAR, SCM_MAKE_CHAR, char);
|
||||
SIMPLE_MAP(unsigned char, SCM_CHAR, SCM_MAKE_CHAR, char);
|
||||
SIMPLE_MAP(signed char, SCM_CHAR, SCM_MAKE_CHAR, char);
|
||||
SIMPLE_MAP(int, scm_to_int, scm_from_long, integer);
|
||||
SIMPLE_MAP(short, scm_to_short, scm_from_long, integer);
|
||||
SIMPLE_MAP(long, scm_to_long, scm_from_long, integer);
|
||||
SIMPLE_MAP(ptrdiff_t, scm_to_long, scm_from_long, integer);
|
||||
SIMPLE_MAP(unsigned int, scm_to_uint, scm_from_ulong, integer);
|
||||
SIMPLE_MAP(unsigned short, scm_to_ushort, scm_from_ulong, integer);
|
||||
SIMPLE_MAP(unsigned long, scm_to_ulong, scm_from_ulong, integer);
|
||||
SIMPLE_MAP(size_t, scm_to_ulong, scm_from_ulong, integer);
|
||||
SIMPLE_MAP(float, scm_to_double, scm_from_double, real);
|
||||
SIMPLE_MAP(double, scm_to_double, scm_from_double, real);
|
||||
// SIMPLE_MAP(char *, SWIG_scm2str, SWIG_str02scm, string);
|
||||
// SIMPLE_MAP(const char *, SWIG_scm2str, SWIG_str02scm, string);
|
||||
|
||||
/* Define long long typemaps -- uses functions that are only defined
|
||||
in recent versions of Guile, availability also depends on Guile's
|
||||
configuration. */
|
||||
|
||||
SIMPLE_MAP(long long, gh_scm2long_long, gh_long_long2scm, integer);
|
||||
SIMPLE_MAP(unsigned long long, gh_scm2ulong_long, gh_ulong_long2scm, integer);
|
||||
SIMPLE_MAP(long long, scm_to_long_long, scm_from_long_long, integer);
|
||||
SIMPLE_MAP(unsigned long long, scm_to_ulong_long, scm_from_ulong_long, integer);
|
||||
|
||||
/* Strings */
|
||||
|
||||
|
|
@ -290,8 +290,8 @@ SIMPLE_MAP(unsigned long long, gh_scm2ulong_long, gh_ulong_long2scm, integer);
|
|||
must_free = 1;
|
||||
}
|
||||
%typemap (varin, doc="NEW-VALUE is a string") char * {$1 = ($1_ltype)SWIG_scm2str($input);}
|
||||
%typemap (out, doc="<string>") char * {$result = gh_str02scm((const char *)$1);}
|
||||
%typemap (varout, doc="<string>") char * {$result = gh_str02scm($1);}
|
||||
%typemap (out, doc="<string>") char * {$result = SWIG_str02scm((const char *)$1);}
|
||||
%typemap (varout, doc="<string>") char * {$result = SWIG_str02scm($1);}
|
||||
%typemap (in, doc="$NAME is a string") char **INPUT(char * temp, int must_free = 0) {
|
||||
temp = (char *) SWIG_scm2str($input); $1 = &temp;
|
||||
must_free = 1;
|
||||
|
|
@ -299,7 +299,7 @@ SIMPLE_MAP(unsigned long long, gh_scm2ulong_long, gh_ulong_long2scm, integer);
|
|||
%typemap (in,numinputs=0) char **OUTPUT (char * temp)
|
||||
{$1 = &temp;}
|
||||
%typemap (argout,doc="$NAME (a string)") char **OUTPUT
|
||||
{SWIG_APPEND_VALUE(gh_str02scm(*$1));}
|
||||
{SWIG_APPEND_VALUE(SWIG_str02scm(*$1));}
|
||||
%typemap (in) char **BOTH = char **INPUT;
|
||||
%typemap (argout) char **BOTH = char **OUTPUT;
|
||||
%typemap (in) char **INOUT = char **INPUT;
|
||||
|
|
@ -329,8 +329,8 @@ SIMPLE_MAP(unsigned long long, gh_scm2ulong_long, gh_ulong_long2scm, integer);
|
|||
}
|
||||
|
||||
%typemap(throws) char * {
|
||||
scm_throw(gh_symbol2scm((char *) "swig-exception"),
|
||||
gh_list(gh_str02scm($1), SCM_UNDEFINED));
|
||||
scm_throw(scm_str2symbol((char *) "swig-exception"),
|
||||
scm_listify(SWIG_str02scm($1), SCM_UNDEFINED));
|
||||
}
|
||||
|
||||
/* Void */
|
||||
|
|
@ -350,7 +350,7 @@ typedef unsigned long SCM;
|
|||
|
||||
%typemap(in) (char *STRING, int LENGTH), (char *STRING, size_t LENGTH) {
|
||||
size_t temp;
|
||||
$1 = ($1_ltype) gh_scm2newstr($input, &temp);
|
||||
$1 = ($1_ltype) SWIG_Guile_scm2newstr($input, &temp);
|
||||
$2 = ($2_ltype) temp;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -279,7 +279,7 @@ REF_MAP(double, SCHEME_REALP, scheme_real_to_double,
|
|||
|
||||
//%typemap(in) (char *STRING, int LENGTH) {
|
||||
// int temp;
|
||||
// $1 = ($1_ltype) gh_scm2newstr($input, &temp);
|
||||
// $1 = ($1_ltype) SWIG_Guile_scm2newstr($input, &temp);
|
||||
// $2 = ($2_ltype) temp;
|
||||
//}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue