Merged first chunk of Guile changes contributed by John Lenz.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4858 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Matthias Köppe 2003-06-03 22:12:50 +00:00
commit e5ac3696bc
22 changed files with 1061 additions and 460 deletions

32
Lib/guile/ghinterface.i Normal file
View file

@ -0,0 +1,32 @@
#define gh_append2(a, b) scm_append(scm_listify(a, b, SCM_UNDEFINED))
#define gh_apply(a, b) scm_apply(a, b, SCM_EOL)
#define gh_bool2scm SCM_BOOL
#define gh_boolean_p SCM_BOOLP
#define gh_car SCM_CAR
#define gh_cdr SCM_CDR
#define gh_cons scm_cons
#define gh_double2scm scm_make_real
#define gh_int2scm scm_long2num
#define gh_length(lst) scm_num2ulong(scm_length(lst), SCM_ARG1, FUNC_NAME)
#define gh_list scm_listify
#define gh_list_to_vector scm_vector
#define gh_make_vector scm_make_vector
#define gh_null_p SCM_NULLP
#define gh_number_p SCM_NUMBERP
#define gh_pair_p SCM_CONSP
#define gh_scm2bool SCM_NFALSEP
#define gh_scm2char SCM_CHAR
#define gh_scm2double(a) scm_num2dbl(a, FUNC_NAME)
#define gh_scm2int(a) scm_num2int(a, SCM_ARG1, FUNC_NAME)
#define gh_scm2long(a) scm_num2long(a, SCM_ARG1, FUNC_NAME)
#define gh_scm2newstr SWIG_scm2newstr
#define gh_scm2ulong(a) scm_num2ulong(a, SCM_ARG1, FUNC_NAME)
#define gh_ulong2scm scm_ulong2num
#define gh_long2scm scm_long2num
#define gh_str02scm scm_makfrom0str
#define gh_string_p SCM_STRINGP
#define gh_vector_length SCM_VECTOR_LENGTH
#define gh_vector_p SCM_VECTORP
#define gh_vector_ref scm_vector_ref
#define gh_vector_set_x scm_vector_set_x
#define gh_char2scm SCM_MAKE_CHAR

View file

@ -1,13 +1,4 @@
/* SWIG Configuration File for Guile. -*-c-*-
This file is parsed by SWIG before reading any other interface
file. */
/* Include headers */
%insert(runtime) "guiledec.swg"
#ifndef SWIG_NOINCLUDE
%insert(runtime) "guile.swg"
#endif
/* SWIG Configuration File for Guile. -*-c-*-*/
/* Macro for inserting Scheme code into the stub */
#define %scheme %insert("scheme")
@ -32,20 +23,6 @@
%pragma(guile) return_multi_doc = "Returns $num_values values: $values."
%enddef
/* The following definitions are supposed to provide a common API for
the supported Scheme dialects, so that typemaps may be shared. I
also plan to adopt Guile's high-level interface (GH) for this
purpose. */
#define SWIG_malloc(size) \
SCM_MUST_MALLOC(size)
#define SWIG_free(mem) \
scm_must_free(mem)
#define SWIG_GetPtr(s, result, type) \
SWIG_Guile_GetPtr(s, result, type)
#define SWIG_MustGetPtr(s, type, argnum) \
SWIG_Guile_MustGetPtr(s, type, argnum, FUNC_NAME)
#define SWIG_MakePtr(ptr, type) \
SWIG_Guile_MakePtr(ptr, type)
#define GUILE_APPEND_RESULT SWIG_APPEND_VALUE
/* Read in standard typemaps. */
%include "typemaps.i"

24
Lib/guile/guile_gh.swg Normal file
View file

@ -0,0 +1,24 @@
%runtime %{
#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_GetPtr(s, result, type)
#define SWIG_MustGetPtr(s, type, argnum, flags) \
SWIG_Guile_MustGetPtr(s, type, argnum, FUNC_NAME)
#define SWIG_NewPointerObj(ptr, type, owner) \
SWIG_Guile_MakePtr((void*)ptr, type)
%}
%runtime "guile_gh_run.swg"
%include "guile.i"
%init %{
static int _swig_init = 0;
if (!_swig_init) {
SWIG_Guile_RegisterTypes(swig_types, swig_types_initial);
_swig_init = 1;
}
%}

View file

@ -1,10 +1,161 @@
/* -*- c -*-
* -----------------------------------------------------------------------
* swig_lib/guile/guile.swg
* Lib/guile/guile_gh_run.swg
*
* Guile configuration file.
* Guile GH runtime file
* Copyright (C) 2000 Matthias Koeppe
* ----------------------------------------------------------------------- */
#include "guile/gh.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
#if defined(SWIG_NOINCLUDE)
# define SWIGSTATIC
#elif defined(SWIG_GLOBAL)
# define SWIGSTATIC
#else
# define SWIGSTATIC static
#endif
#define GH_NOT_PASSED SCM_UNDEFINED
#define GH_UNSPECIFIED SCM_UNSPECIFIED
#define SWIG_APPEND_VALUE(object) \
if (gswig_result == GH_UNSPECIFIED) \
gswig_result = object; \
else { \
if (!gswig_list_p) { \
gswig_list_p = 1; \
gswig_result = gh_list(gswig_result, object, GH_NOT_PASSED); \
} \
else \
gswig_result = gh_append2(gswig_result, \
gh_list(object, GH_NOT_PASSED)); \
}
#define GUILE_APPEND_RESULT SWIG_APPEND_VALUE
/* 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);
static char *
SWIG_scm2str (SCM s)
{
return gh_scm2newstr (s, NULL);
}
#define GSWIG_scm2str SWIG_scm2str
/* 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 */
static 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
/* 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
/* Type system */
typedef void *(*swig_converter_func)(void *);
typedef struct swig_type_info *(*swig_dycast_func)(void **);
typedef struct SwigPtrType SwigPtrType;
typedef struct swig_type_info {
const char *name;
swig_converter_func converter;
const char *str;
void *clientdata;
size_t tag;
swig_dycast_func dcast;
} swig_type_info;
SWIGSTATIC void
SWIG_Guile_RegisterTypes (swig_type_info **table,
swig_type_info **init);
/* Register a new type-mapping with the type-checker. origtype is the
original datatype and newtype is an equivalent type. cast is optional
pointer to a function to cast pointer values between types (this is
typically used to cast pointers from derived classes to base classes in
C++). */
SWIGSTATIC void
SWIG_RegisterMapping (const char *origtype, const char *newtype,
swig_converter_func cast);
/* Dynamic pointer casting. Down an inheritance hierarchy */
SWIGSTATIC swig_type_info *
SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr);
/* Register SWIG smobs with Guile. */
SWIGSTATIC void
SWIG_Guile_Init();
/* Initialization function for this SWIG module; actually renamed by a
#define */
/* extern void SWIG_init(); */
/* Get a pointer value from a smob. If there is a type-mismatch,
return nonzero; on success, return 0. */
SWIGSTATIC int
SWIG_Guile_GetPtr (SCM s, void **result, swig_type_info *type);
/* Get a pointer value from a smob. If there is a type-mismatch,
signal a wrong-type-arg error for the given argument number. */
SWIGSTATIC void *
SWIG_Guile_MustGetPtr (SCM s, swig_type_info *type,
int argnum, const char *func_name);
/* Make a smob from a pointer and typeinfo. */
SWIGSTATIC SCM
SWIG_Guile_MakePtr (void *ptr, swig_type_info *type);
/* Get arguments from an argument list */
SWIGSTATIC int
SWIG_Guile_GetArgs (SCM *dest, SCM rest,
int reqargs, int optargs,
const char *procname);
typedef SCM (*swig_guile_proc)();
#ifdef __cplusplus
}
#endif
/* guiledec.swg ends here */
#ifndef SWIG_NOINCLUDE
/* SWIG pointer structure */
#ifdef __cplusplus
@ -318,3 +469,5 @@ SWIG_Guile_GetArgs (SCM *dest, SCM rest,
#endif
/* guile.swg ends here */
#endif

57
Lib/guile/guile_scm.swg Normal file
View file

@ -0,0 +1,57 @@
%runtime %{
#define SWIG_malloc(size) \
SCM_MUST_MALLOC(size)
#define SWIG_free(mem) \
scm_must_free(mem)
#define SWIG_ConvertPtr(s, result, type, flags) \
SWIG_Guile_ConvertPtr(s, result, type, flags)
#define SWIG_MustGetPtr(s, type, argnum, flags) \
SWIG_Guile_MustGetPtr(s, type, argnum, flags, FUNC_NAME)
#define SWIG_NewPointerObj(ptr, type, owner) \
SWIG_Guile_NewPointerObj((void*)ptr, type, owner)
%}
%runtime "common.swg"
%runtime "guile_scm_run.swg"
%include "ghinterface.i"
%include "guile.i"
%runtime %{
#define GUILE_MAYBE_VALUES \
if (gswig_list_p) gswig_result = scm_values(gswig_result);
#define GUILE_MAYBE_VECTOR \
if (gswig_list_p) gswig_result = scm_vector(gswig_result);
#define SWIG_APPEND_VALUE(object) \
if (gswig_result == SCM_UNSPECIFIED) \
gswig_result = object; \
else { \
if (!gswig_list_p) { \
gswig_list_p = 1; \
gswig_result = scm_listify(gswig_result, object, SCM_UNDEFINED); \
} \
else \
gswig_result = scm_append(scm_listify(gswig_result, scm_listify(object, SCM_UNDEFINED), SCM_UNDEFINED)); \
}
/* used by Lib/exception.i */
#define gh_symbol2scm scm_str2symbol
/* useb by Lib/cdata.i */
#define gh_str2scm scm_mem2string
%}
%init %{
static int _swig_init = 0;
if (!_swig_init) {
int i;
for (i = 0; swig_types_initial[i]; i++) {
swig_types[i] = SWIG_TypeRegister(swig_types_initial[i]);
}
_swig_init = 1;
}
SWIG_Guile_Init();
%}

220
Lib/guile/guile_scm_run.swg Normal file
View file

@ -0,0 +1,220 @@
/* -*- c -*-
* -----------------------------------------------------------------------
* swig_lib/guile/guile_scm_run.swg
*
* Author: John Lenz <jelenz@students.wisc.edu>
* ----------------------------------------------------------------------- */
#include <libguile.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef SCM (*swig_guile_proc)();
typedef SCM (*guile_destructor)(SCM);
#define SWIG_scm2str(s) SWIG_scm2newstr(s, NULL)
#ifdef SWIG_NOINCLUDE
/* Interface helper function */
SWIGIMPORT(char *) SWIG_scm2newstr(SCM str, size_t *len);
/* Register SWIG smobs with Guile. */
SWIGIMPORT(void) SWIG_Guile_Init();
/* Get a pointer value from a smob. If there is a type-mismatch,
return nonzero; on success, return 0. */
SWIGIMPORT(int) SWIG_Guile_ConvertPtr(SCM s, void **result, swig_type_info *type, int flags);
/* Get a pointer value from a smob. If there is a type-mismatch,
signal a wrong-type-arg error for the given argument number. */
SWIGIMPORT(void *) SWIG_Guile_MustGetPtr(SCM s, swig_type_info *type, int argnum, int flags, const char *func_name);
/* Make a smob from a pointer and typeinfo. */
SWIGIMPORT(SCM) SWIG_Guile_NewPointerObj(void *ptr, swig_type_info *type, int owner);
/* Get arguments from an argument list */
SWIGIMPORT(int) SWIG_Guile_GetArgs(SCM *dest, SCM rest, int reqargs, int optargs, const char *procname);
#else
SWIGRUNTIME(char *)
SWIG_scm2newstr(SCM str, size_t *len) {
#define FUNC_NAME "swig_scm2newstr"
char *ret;
size_t l;
l = SCM_STRING_LENGTH(str);
ret = (char *) SWIG_malloc( (l + 1) * sizeof(char));
if (!ret) return NULL;
memcpy(ret, SCM_STRING_CHARS(str), l);
ret[l] = '\0';
if (len) *len = l;
return ret;
#undef FUNC_NAME
}
static scm_t_bits swig_tag = 0;
static scm_t_bits swig_collected_tag = 0;
SWIGRUNTIME(SCM)
SWIG_Guile_NewPointerObj(void *ptr, swig_type_info *type, int owner)
{
if (owner)
SCM_RETURN_NEWSMOB2(swig_collected_tag, ptr, (void *) type);
else
SCM_RETURN_NEWSMOB2(swig_tag, ptr, (void *) type);
}
/* Return 0 if successful. */
SWIGRUNTIME(int)
SWIG_Guile_ConvertPtr(SCM s, void **result, swig_type_info *type, int flags)
{
swig_type_info *cast;
swig_type_info *from;
if (SCM_NULLP(s)) {
*result = NULL;
return 0;
} else if (SCM_SMOB_PREDICATE(swig_tag, s) || SCM_SMOB_PREDICATE(swig_collected_tag, s)) {
from = (swig_type_info *) SCM_CELL_WORD_2(s);
if (!from) return 1;
if (type) {
cast = SWIG_TypeCheck((char*)from->name, type);
if (cast) {
*result = SWIG_TypeCast(cast, (void *) SCM_CELL_WORD_1(s));
return 0;
} else {
return 1;
}
} else {
*result = (void *) SCM_CELL_WORD_1(s);
return 0;
}
}
return 1;
}
SWIGRUNTIME(void *)
SWIG_Guile_MustGetPtr (SCM s, swig_type_info *type,
int argnum, int flags, const char *func_name)
{
void *result;
if (SWIG_Guile_ConvertPtr(s, &result, type, flags)) {
/* type mismatch */
scm_wrong_type_arg((char *) func_name, argnum, s);
}
return result;
}
/* Init */
static int
print_swig (SCM swig_smob, SCM port, scm_print_state *pstate)
{
swig_type_info *type = (swig_type_info *) SCM_CELL_WORD_2(swig_smob);
if (type) {
scm_puts((char *) "#<swig ", port);
if (type->str != NULL)
scm_puts(type->str, port);
else
scm_puts(type->name, 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;
}
}
static int
print_collected_swig (SCM swig_smob, SCM port, scm_print_state *pstate)
{
swig_type_info *type = (swig_type_info *) SCM_CELL_WORD_2(swig_smob);
if (type) {
scm_puts((char *) "#<collected swig ", port);
if (type->str != NULL)
scm_puts(type->str, port);
else
scm_puts(type->name, 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;
}
}
static SCM
equalp_swig (SCM A, SCM B)
{
if (SCM_CAR(A) == SCM_CAR(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;
}
static size_t
free_swig(SCM A)
{
swig_type_info *type = (swig_type_info *) SCM_CELL_WORD_2(A);
if (type) {
if (type->clientdata)
((guile_destructor)type->clientdata)(A);
}
return 0;
}
SWIGRUNTIME(void)
SWIG_Guile_Init ()
{
if (!swig_tag) {
swig_tag = scm_make_smob_type("swig", 0);
scm_set_smob_print(swig_tag, print_swig);
scm_set_smob_equalp(swig_tag, equalp_swig);
}
if (!swig_collected_tag) {
swig_collected_tag = scm_make_smob_type("collected swig", 0);
scm_set_smob_print(swig_collected_tag, print_collected_swig);
scm_set_smob_equalp(swig_collected_tag, equalp_swig);
scm_set_smob_free(swig_collected_tag, free_swig);
}
}
SWIGRUNTIME(int)
SWIG_Guile_GetArgs (SCM *dest, SCM rest,
int reqargs, int optargs,
const char *procname)
{
int i;
int num_args_passed = 0;
for (i = 0; i<reqargs; i++) {
if (!SCM_CONSP(rest))
scm_wrong_num_args(scm_makfrom0str((char *) procname));
*dest++ = SCM_CAR(rest);
rest = SCM_CDR(rest);
num_args_passed++;
}
for (i = 0; i<optargs && SCM_CONSP(rest); i++) {
*dest++ = SCM_CAR(rest);
rest = SCM_CDR(rest);
num_args_passed++;
}
for (; i<optargs; i++)
*dest++ = SCM_UNDEFINED;
if (!SCM_NULLP(rest))
scm_wrong_num_args(scm_makfrom0str((char *) procname));
return num_args_passed;
}
#endif
#ifdef __cplusplus
}
#endif

View file

@ -1,157 +0,0 @@
/* -*- c -*-
* -----------------------------------------------------------------------
* swig_lib/guile/guiledec.swg
* Copyright (C) 2000 Matthias Koeppe
*
* Guile configuration file -- declarations
* ----------------------------------------------------------------------- */
#define SWIGGUILE
#include "guile/gh.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
#if defined(SWIG_NOINCLUDE)
# define SWIGSTATIC
#elif defined(SWIG_GLOBAL)
# define SWIGSTATIC
#else
# define SWIGSTATIC static
#endif
#define GH_NOT_PASSED SCM_UNDEFINED
#define GH_UNSPECIFIED SCM_UNSPECIFIED
#define SWIG_APPEND_VALUE(object) \
if (gswig_result == GH_UNSPECIFIED) \
gswig_result = object; \
else { \
if (!gswig_list_p) { \
gswig_list_p = 1; \
gswig_result = gh_list(gswig_result, object, GH_NOT_PASSED); \
} \
else \
gswig_result = gh_append2(gswig_result, \
gh_list(object, GH_NOT_PASSED)); \
}
#define GUILE_APPEND_RESULT SWIG_APPEND_VALUE
/* 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);
static char *
SWIG_scm2str (SCM s)
{
return gh_scm2newstr (s, NULL);
}
#define GSWIG_scm2str SWIG_scm2str
/* 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 */
static 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
/* 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
/* Type system */
typedef void *(*swig_converter_func)(void *);
typedef struct swig_type_info *(*swig_dycast_func)(void **);
typedef struct SwigPtrType SwigPtrType;
typedef struct swig_type_info {
const char *name;
swig_converter_func converter;
const char *str;
void *clientdata;
size_t tag;
swig_dycast_func dcast;
} swig_type_info;
SWIGSTATIC void
SWIG_Guile_RegisterTypes (swig_type_info **table,
swig_type_info **init);
/* Register a new type-mapping with the type-checker. origtype is the
original datatype and newtype is an equivalent type. cast is optional
pointer to a function to cast pointer values between types (this is
typically used to cast pointers from derived classes to base classes in
C++). */
SWIGSTATIC void
SWIG_RegisterMapping (const char *origtype, const char *newtype,
swig_converter_func cast);
/* Dynamic pointer casting. Down an inheritance hierarchy */
SWIGSTATIC swig_type_info *
SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr);
/* Register SWIG smobs with Guile. */
SWIGSTATIC void
SWIG_Guile_Init();
/* Initialization function for this SWIG module; actually renamed by a
#define */
/* extern void SWIG_init(); */
/* Get a pointer value from a smob. If there is a type-mismatch,
return nonzero; on success, return 0. */
SWIGSTATIC int
SWIG_Guile_GetPtr (SCM s, void **result, swig_type_info *type);
/* Get a pointer value from a smob. If there is a type-mismatch,
signal a wrong-type-arg error for the given argument number. */
SWIGSTATIC void *
SWIG_Guile_MustGetPtr (SCM s, swig_type_info *type,
int argnum, const char *func_name);
/* Make a smob from a pointer and typeinfo. */
SWIGSTATIC SCM
SWIG_Guile_MakePtr (void *ptr, swig_type_info *type);
/* Get arguments from an argument list */
SWIGSTATIC int
SWIG_Guile_GetArgs (SCM *dest, SCM rest,
int reqargs, int optargs,
const char *procname);
typedef SCM (*swig_guile_proc)();
#ifdef __cplusplus
}
#endif
/* guiledec.swg ends here */

View file

@ -66,7 +66,7 @@
$1 = gh_vector_length($input);
if ($1 > 0) {
$1_ltype i;
$2 = SWIG_malloc(sizeof(C_TYPE) * $1);
$2 = (C_TYPE *) SWIG_malloc(sizeof(C_TYPE) * $1);
for (i = 0; i<$1; i++) {
SCM swig_scm_value = gh_vector_ref($input, gh_int2scm(i));
$2[i] = SCM_TO_C_EXPR;
@ -84,7 +84,7 @@
if ($1 > 0) {
$1_ltype i;
SCM rest;
$2 = SWIG_malloc(sizeof(C_TYPE) * $1);
$2 = (C_TYPE *) SWIG_malloc(sizeof(C_TYPE) * $1);
for (i = 0, rest = $input;
i<$1;
i++, rest = gh_cdr(rest)) {
@ -278,7 +278,7 @@ TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, gh_str02scm, string
*_global_vector_length = gh_vector_length($input);
if (*_global_vector_length > 0) {
int i;
$1 = SWIG_malloc(sizeof(C_TYPE)
$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));
@ -297,7 +297,7 @@ TYPEMAP_LIST_VECTOR_INPUT_OUTPUT(const char *, SWIG_scm2str, gh_str02scm, string
if (*_global_list_length > 0) {
int i;
SCM rest;
$1 = SWIG_malloc(sizeof(C_TYPE)
$1 = (C_TYPE *) SWIG_malloc(sizeof(C_TYPE)
* (*_global_list_length));
for (i = 0, rest = $input;
i<*_global_list_length;

View file

@ -36,7 +36,7 @@
%typemap(in, doc="$NAME is of type <" #SCM_TYPE ">") PTRTYPE *INPUT(PTRTYPE temp)
{
if (SWIG_Guile_GetPtr($input, (void **) &temp, $*descriptor)) {
if (SWIG_ConvertPtr($input, (void **) &temp, $*descriptor, 0)) {
scm_wrong_type_arg(FUNC_NAME, $argnum, $input);
}
$1 = &temp;
@ -46,7 +46,7 @@
"$1 = &temp;";
%typemap(argout, doc="<" #SCM_TYPE ">") PTRTYPE *OUTPUT
"SWIG_APPEND_VALUE(SWIG_Guile_MakePtr(*$1, $*descriptor));";
"SWIG_APPEND_VALUE(SWIG_NewPointerObj(*$1, $*descriptor, 1));";
%typemap(in) PTRTYPE *BOTH = PTRTYPE *INPUT;
%typemap(argout) PTRTYPE *BOTH = PTRTYPE *OUTPUT;
@ -57,12 +57,12 @@
SCM_TYPE to the standard pointer typemaps */
%typemap(in, doc="$NAME is of type <" #SCM_TYPE ">") PTRTYPE {
if (SWIG_Guile_GetPtr($input, (void **) &$1, $descriptor))
if (SWIG_ConvertPtr($input, (void **) &$1, $descriptor, 0))
scm_wrong_type_arg(FUNC_NAME, $argnum, $input);
}
%typemap(out, doc="<" #SCM_TYPE ">") PTRTYPE {
$result = SWIG_Guile_MakePtr ($1, $descriptor);
$result = SWIG_NewPointerObj ($1, $descriptor, $owner);
}
%enddef

View file

@ -5,22 +5,17 @@
//
// Guile implementation
#define SWIG_bool2scm(b) gh_bool2scm(b ? 1 : 0)
#define SWIG_string2scm(s) gh_str02scm(s.c_str())
%{
#include <string>
SCM SWIG_bool2scm(bool b) {
int i = b ? 1 : 0;
return gh_bool2scm(i);
}
std::string SWIG_scm2string(SCM x) {
inline std::string SWIG_scm2string(SCM x) {
char* temp;
std::string s;
temp = gh_scm2newstr(x, NULL);
s = std::string(temp);
if (temp) scm_must_free(temp);
temp = SWIG_scm2str(x);
std::string s(temp);
if (temp) SWIG_free(temp);
return s;
}
SCM SWIG_string2scm(const std::string& s) {
return gh_str02scm(s.c_str());
}
%}

View file

@ -74,20 +74,20 @@ namespace std {
SWIG_exception(SWIG_TypeError,"alist expected");
key = gh_car(entry);
val = gh_cdr(entry);
k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum);
if (SWIG_GetPtr(val,(void**) &x,
$descriptor(T *)) != 0) {
k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0);
if (SWIG_ConvertPtr(val,(void**) &x,
$descriptor(T *), 0) != 0) {
if (!gh_pair_p(val))
SWIG_exception(SWIG_TypeError,"alist expected");
val = gh_car(val);
x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum);
x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0);
}
(($1_type &)$1)[*k] = *x;
alist = gh_cdr(alist);
}
} else {
$1 = *(($&1_type)
SWIG_MustGetPtr($input,$&1_descriptor,$argnum));
SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0));
}
}
%typemap(in) const map<K,T>& (std::map<K,T> temp,
@ -110,19 +110,19 @@ namespace std {
SWIG_exception(SWIG_TypeError,"alist expected");
key = gh_car(entry);
val = gh_cdr(entry);
k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum);
if (SWIG_GetPtr(val,(void**) &x,
$descriptor(T *)) != 0) {
k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0);
if (SWIG_ConvertPtr(val,(void**) &x,
$descriptor(T *), 0) != 0) {
if (!gh_pair_p(val))
SWIG_exception(SWIG_TypeError,"alist expected");
val = gh_car(val);
x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum);
x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0);
}
temp[*k] = *x;
alist = gh_cdr(alist);
}
} else {
$1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum);
$1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0);
}
}
%typemap(out) map<K,T> {
@ -131,8 +131,8 @@ namespace std {
i!=$1.rend(); ++i) {
K* key = new K(i->first);
T* val = new T(i->second);
SCM k = SWIG_MakePtr(key,$descriptor(K *));
SCM x = SWIG_MakePtr(val,$descriptor(T *));
SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1);
SCM x = SWIG_NewPointerObj(val,$descriptor(T *), 1);
SCM entry = gh_cons(k,x);
alist = gh_cons(entry,alist);
}
@ -151,17 +151,17 @@ namespace std {
if (gh_pair_p(head)) {
SCM key = gh_car(head);
SCM val = gh_cdr(head);
if (SWIG_GetPtr(key,(void**) &k,
$descriptor(K *)) != 0) {
if (SWIG_ConvertPtr(key,(void**) &k,
$descriptor(K *), 0) != 0) {
$1 = 0;
} else {
if (SWIG_GetPtr(val,(void**) &x,
$descriptor(T *)) == 0) {
if (SWIG_ConvertPtr(val,(void**) &x,
$descriptor(T *), 0) == 0) {
$1 = 1;
} else if (gh_pair_p(val)) {
val = gh_car(val);
if (SWIG_GetPtr(val,(void**) &x,
$descriptor(T *)) == 0)
if (SWIG_ConvertPtr(val,(void**) &x,
$descriptor(T *), 0) == 0)
$1 = 1;
else
$1 = 0;
@ -175,8 +175,8 @@ namespace std {
} else {
/* wrapped map? */
std::map<K,T >* m;
if (SWIG_GetPtr($input,(void **) &m,
$&1_descriptor) == 0)
if (SWIG_ConvertPtr($input,(void **) &m,
$&1_descriptor, 0) == 0)
$1 = 1;
else
$1 = 0;
@ -196,17 +196,17 @@ namespace std {
if (gh_pair_p(head)) {
SCM key = gh_car(head);
SCM val = gh_cdr(head);
if (SWIG_GetPtr(key,(void**) &k,
$descriptor(K *)) != 0) {
if (SWIG_ConvertPtr(key,(void**) &k,
$descriptor(K *), 0) != 0) {
$1 = 0;
} else {
if (SWIG_GetPtr(val,(void**) &x,
$descriptor(T *)) == 0) {
if (SWIG_ConvertPtr(val,(void**) &x,
$descriptor(T *), 0) == 0) {
$1 = 1;
} else if (gh_pair_p(val)) {
val = gh_car(val);
if (SWIG_GetPtr(val,(void**) &x,
$descriptor(T *)) == 0)
if (SWIG_ConvertPtr(val,(void**) &x,
$descriptor(T *), 0) == 0)
$1 = 1;
else
$1 = 0;
@ -220,8 +220,8 @@ namespace std {
} else {
/* wrapped map? */
std::map<K,T >* m;
if (SWIG_GetPtr($input,(void **) &m,
$1_descriptor) == 0)
if (SWIG_ConvertPtr($input,(void **) &m,
$1_descriptor, 0) == 0)
$1 = 1;
else
$1 = 0;
@ -268,7 +268,7 @@ namespace std {
for (std::map<K,T >::reverse_iterator i=$1.rbegin();
i!=$1.rend(); ++i) {
K* key = new K(i->first);
SCM k = SWIG_MakePtr(key,$descriptor(K *));
SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1);
result = gh_cons(k,result);
}
return result;
@ -299,19 +299,19 @@ namespace std {
if (!CHECK(key))
SWIG_exception(SWIG_TypeError,
"map<" #K "," #T "> expected");
if (SWIG_GetPtr(val,(void**) &x,
$descriptor(T *)) != 0) {
if (SWIG_ConvertPtr(val,(void**) &x,
$descriptor(T *), 0) != 0) {
if (!gh_pair_p(val))
SWIG_exception(SWIG_TypeError,"alist expected");
val = gh_car(val);
x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum);
x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0);
}
(($1_type &)$1)[CONVERT_FROM(key)] = *x;
alist = gh_cdr(alist);
}
} else {
$1 = *(($&1_type)
SWIG_MustGetPtr($input,$&1_descriptor,$argnum));
SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0));
}
}
%typemap(in) const map<K,T>& (std::map<K,T> temp,
@ -336,18 +336,18 @@ namespace std {
if (!CHECK(key))
SWIG_exception(SWIG_TypeError,
"map<" #K "," #T "> expected");
if (SWIG_GetPtr(val,(void**) &x,
$descriptor(T *)) != 0) {
if (SWIG_ConvertPtr(val,(void**) &x,
$descriptor(T *), 0) != 0) {
if (!gh_pair_p(val))
SWIG_exception(SWIG_TypeError,"alist expected");
val = gh_car(val);
x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum);
x = (T*) SWIG_MustGetPtr(val,$descriptor(T *),$argnum, 0);
}
temp[CONVERT_FROM(key)] = *x;
alist = gh_cdr(alist);
}
} else {
$1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum);
$1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0);
}
}
%typemap(out) map<K,T> {
@ -356,7 +356,7 @@ namespace std {
i!=$1.rend(); ++i) {
T* val = new T(i->second);
SCM k = CONVERT_TO(i->first);
SCM x = SWIG_MakePtr(val,$descriptor(T *));
SCM x = SWIG_NewPointerObj(val,$descriptor(T *), 1);
SCM entry = gh_cons(k,x);
alist = gh_cons(entry,alist);
}
@ -377,13 +377,13 @@ namespace std {
if (!CHECK(key)) {
$1 = 0;
} else {
if (SWIG_GetPtr(val,(void**) &x,
$descriptor(T *)) == 0) {
if (SWIG_ConvertPtr(val,(void**) &x,
$descriptor(T *), 0) == 0) {
$1 = 1;
} else if (gh_pair_p(val)) {
val = gh_car(val);
if (SWIG_GetPtr(val,(void**) &x,
$descriptor(T *)) == 0)
if (SWIG_ConvertPtr(val,(void**) &x,
$descriptor(T *), 0) == 0)
$1 = 1;
else
$1 = 0;
@ -397,8 +397,8 @@ namespace std {
} else {
// wrapped map?
std::map<K,T >* m;
if (SWIG_GetPtr($input,(void **) &m,
$&1_descriptor) == 0)
if (SWIG_ConvertPtr($input,(void **) &m,
$&1_descriptor, 0) == 0)
$1 = 1;
else
$1 = 0;
@ -420,13 +420,13 @@ namespace std {
if (!CHECK(key)) {
$1 = 0;
} else {
if (SWIG_GetPtr(val,(void**) &x,
$descriptor(T *)) == 0) {
if (SWIG_ConvertPtr(val,(void**) &x,
$descriptor(T *), 0) == 0) {
$1 = 1;
} else if (gh_pair_p(val)) {
val = gh_car(val);
if (SWIG_GetPtr(val,(void**) &x,
$descriptor(T *)) == 0)
if (SWIG_ConvertPtr(val,(void**) &x,
$descriptor(T *), 0) == 0)
$1 = 1;
else
$1 = 0;
@ -440,8 +440,8 @@ namespace std {
} else {
// wrapped map?
std::map<K,T >* m;
if (SWIG_GetPtr($input,(void **) &m,
$1_descriptor) == 0)
if (SWIG_ConvertPtr($input,(void **) &m,
$1_descriptor, 0) == 0)
$1 = 1;
else
$1 = 0;
@ -512,7 +512,7 @@ namespace std {
SWIG_exception(SWIG_TypeError,"alist expected");
key = gh_car(entry);
val = gh_cdr(entry);
k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum);
k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0);
if (!CHECK(val)) {
if (!gh_pair_p(val))
SWIG_exception(SWIG_TypeError,"alist expected");
@ -526,7 +526,7 @@ namespace std {
}
} else {
$1 = *(($&1_type)
SWIG_MustGetPtr($input,$&1_descriptor,$argnum));
SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0));
}
}
%typemap(in) const map<K,T>& (std::map<K,T> temp,
@ -548,7 +548,7 @@ namespace std {
SWIG_exception(SWIG_TypeError,"alist expected");
key = gh_car(entry);
val = gh_cdr(entry);
k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum);
k = (K*) SWIG_MustGetPtr(key,$descriptor(K *),$argnum, 0);
if (!CHECK(val)) {
if (!gh_pair_p(val))
SWIG_exception(SWIG_TypeError,"alist expected");
@ -561,7 +561,7 @@ namespace std {
alist = gh_cdr(alist);
}
} else {
$1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum);
$1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0);
}
}
%typemap(out) map<K,T> {
@ -569,7 +569,7 @@ namespace std {
for (std::map<K,T >::reverse_iterator i=$1.rbegin();
i!=$1.rend(); ++i) {
K* key = new K(i->first);
SCM k = SWIG_MakePtr(key,$descriptor(K *));
SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1);
SCM x = CONVERT_TO(i->second);
SCM entry = gh_cons(k,x);
alist = gh_cons(entry,alist);
@ -588,8 +588,8 @@ namespace std {
if (gh_pair_p(head)) {
SCM key = gh_car(head);
SCM val = gh_cdr(head);
if (SWIG_GetPtr(val,(void **) &k,
$descriptor(K *)) != 0) {
if (SWIG_ConvertPtr(val,(void **) &k,
$descriptor(K *), 0) != 0) {
$1 = 0;
} else {
if (CHECK(val)) {
@ -610,8 +610,8 @@ namespace std {
} else {
// wrapped map?
std::map<K,T >* m;
if (SWIG_GetPtr($input,(void **) &m,
$&1_descriptor) == 0)
if (SWIG_ConvertPtr($input,(void **) &m,
$&1_descriptor, 0) == 0)
$1 = 1;
else
$1 = 0;
@ -630,8 +630,8 @@ namespace std {
if (gh_pair_p(head)) {
SCM key = gh_car(head);
SCM val = gh_cdr(head);
if (SWIG_GetPtr(val,(void **) &k,
$descriptor(K *)) != 0) {
if (SWIG_ConvertPtr(val,(void **) &k,
$descriptor(K *), 0) != 0) {
$1 = 0;
} else {
if (CHECK(val)) {
@ -652,8 +652,8 @@ namespace std {
} else {
// wrapped map?
std::map<K,T >* m;
if (SWIG_GetPtr($input,(void **) &m,
$1_descriptor) == 0)
if (SWIG_ConvertPtr($input,(void **) &m,
$1_descriptor, 0) == 0)
$1 = 1;
else
$1 = 0;
@ -700,7 +700,7 @@ namespace std {
for (std::map<K,T >::reverse_iterator i=$1.rbegin();
i!=$1.rend(); ++i) {
K* key = new K(i->first);
SCM k = SWIG_MakePtr(key,$descriptor(K *));
SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1);
result = gh_cons(k,result);
}
return result;
@ -742,7 +742,7 @@ namespace std {
}
} else {
$1 = *(($&1_type)
SWIG_MustGetPtr($input,$&1_descriptor,$argnum));
SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0));
}
}
%typemap(in) const map<K,T>& (std::map<K,T> temp,
@ -778,7 +778,7 @@ namespace std {
alist = gh_cdr(alist);
}
} else {
$1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum);
$1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0);
}
}
%typemap(out) map<K,T> {
@ -824,8 +824,8 @@ namespace std {
} else {
// wrapped map?
std::map<K,T >* m;
if (SWIG_GetPtr($input,(void **) &m,
$&1_descriptor) == 0)
if (SWIG_ConvertPtr($input,(void **) &m,
$&1_descriptor, 0) == 0)
$1 = 1;
else
$1 = 0;
@ -864,8 +864,8 @@ namespace std {
} else {
// wrapped map?
std::map<K,T >* m;
if (SWIG_GetPtr($input,(void **) &m,
$1_descriptor) == 0)
if (SWIG_ConvertPtr($input,(void **) &m,
$1_descriptor, 0) == 0)
$1 = 1;
else
$1 = 0;

View file

@ -27,9 +27,9 @@ namespace std {
%typemap(in) string (char* tempptr) {
if (gh_string_p($input)) {
tempptr = gh_scm2newstr($input, NULL);
tempptr = SWIG_scm2str($input);
$1 = std::string(tempptr);
if (tempptr) scm_must_free(tempptr);
if (tempptr) SWIG_free(tempptr);
} else {
SWIG_exception(SWIG_TypeError, "string expected");
}
@ -38,9 +38,9 @@ namespace std {
%typemap(in) const string & (std::string temp,
char* tempptr) {
if (gh_string_p($input)) {
tempptr = gh_scm2newstr($input, NULL);
tempptr = SWIG_scm2str($input);
temp = std::string(tempptr);
if (tempptr) scm_must_free(tempptr);
if (tempptr) SWIG_free(tempptr);
$1 = &temp;
} else {
SWIG_exception(SWIG_TypeError, "string expected");

View file

@ -75,7 +75,7 @@ namespace std {
for (unsigned long i=0; i<size; i++) {
SCM o = gh_vector_ref($input,gh_ulong2scm(i));
(($1_type &)$1)[i] =
*((T*) SWIG_MustGetPtr(o,$descriptor(T *),$argnum));
*((T*) SWIG_MustGetPtr(o,$descriptor(T *),$argnum, 0));
}
} else if (gh_null_p($input)) {
$1 = std::vector<T >();
@ -86,13 +86,13 @@ namespace std {
while (!gh_null_p(tail)) {
head = gh_car(tail);
tail = gh_cdr(tail);
$1.push_back(*((T*) SWIG_MustGetPtr(head,
$descriptor(T *),
$argnum)));
$1.push_back(*((T*)SWIG_MustGetPtr(head,
$descriptor(T *),
$argnum, 0)));
}
} else {
$1 = *(($&1_type)
SWIG_MustGetPtr($input,$&1_descriptor,$argnum));
SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0));
}
}
%typemap(in) const vector<T>& (std::vector<T> temp),
@ -105,7 +105,7 @@ namespace std {
SCM o = gh_vector_ref($input,gh_ulong2scm(i));
temp[i] = *((T*) SWIG_MustGetPtr(o,
$descriptor(T *),
$argnum));
$argnum, 0));
}
} else if (gh_null_p($input)) {
temp = std::vector<T >();
@ -120,10 +120,10 @@ namespace std {
tail = gh_cdr(tail);
temp.push_back(*((T*) SWIG_MustGetPtr(head,
$descriptor(T *),
$argnum)));
$argnum, 0)));
}
} else {
$1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum);
$1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0);
}
}
%typemap(out) vector<T> {
@ -131,7 +131,7 @@ namespace std {
for (unsigned int i=0; i<$1.size(); i++) {
T* x = new T((($1_type &)$1)[i]);
gh_vector_set_x($result,gh_long2scm(i),
SWIG_MakePtr(x,$descriptor(T *)));
SWIG_NewPointerObj(x, $descriptor(T *), 1));
}
}
%typecheck(SWIG_TYPECHECK_VECTOR) vector<T> {
@ -145,8 +145,8 @@ namespace std {
/* check the first element only */
SCM o = gh_vector_ref($input,gh_ulong2scm(0));
T* x;
if (SWIG_GetPtr(o,(void**) &x,
$descriptor(T *)) == 0)
if (SWIG_ConvertPtr(o,(void**) &x,
$descriptor(T *), 0) != -1)
$1 = 1;
else
$1 = 0;
@ -158,16 +158,16 @@ namespace std {
/* check the first element only */
T* x;
SCM head = gh_car($input);
if (SWIG_GetPtr(head,(void**) &x,
$descriptor(T *)) == 0)
if (SWIG_ConvertPtr(head,(void**) &x,
$descriptor(T *), 0) != -1)
$1 = 1;
else
$1 = 0;
} else {
/* wrapped vector? */
std::vector<T >* v;
if (SWIG_GetPtr($input,(void **) &v,
$&1_descriptor) == 0)
if (SWIG_ConvertPtr($input,(void **) &v,
$&1_descriptor, 0) != -1)
$1 = 1;
else
$1 = 0;
@ -185,8 +185,8 @@ namespace std {
/* check the first element only */
T* x;
SCM o = gh_vector_ref($input,gh_ulong2scm(0));
if (SWIG_GetPtr(o,(void**) &x,
$descriptor(T *)) == 0)
if (SWIG_ConvertPtr(o,(void**) &x,
$descriptor(T *), 0) != -1)
$1 = 1;
else
$1 = 0;
@ -198,16 +198,16 @@ namespace std {
/* check the first element only */
T* x;
SCM head = gh_car($input);
if (SWIG_GetPtr(head,(void**) &x,
$descriptor(T *)) == 0)
if (SWIG_ConvertPtr(head,(void**) &x,
$descriptor(T *), 0) != -1)
$1 = 1;
else
$1 = 0;
} else {
/* wrapped vector? */
std::vector<T >* v;
if (SWIG_GetPtr($input,(void **) &v,
$1_descriptor) == 0)
if (SWIG_ConvertPtr($input,(void **) &v,
$1_descriptor, 0) != -1)
$1 = 1;
else
$1 = 0;
@ -282,7 +282,7 @@ namespace std {
}
} else {
$1 = *(($&1_type)
SWIG_MustGetPtr($input,$&1_descriptor,$argnum));
SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0));
}
}
%typemap(in) const vector<T>& (std::vector<T> temp),
@ -314,8 +314,7 @@ namespace std {
scm_wrong_type_arg(FUNC_NAME, $argnum, $input);
}
} else {
$1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,
$argnum);
$1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0);
}
}
%typemap(out) vector<T> {
@ -349,8 +348,8 @@ namespace std {
} else {
/* wrapped vector? */
std::vector<T >* v;
$1 = (SWIG_GetPtr($input,(void **) &v,
$&1_descriptor) == 0) ? 1 : 0;
$1 = (SWIG_ConvertPtr($input,(void **) &v,
$&1_descriptor, 0) != -1) ? 1 : 0;
}
}
%typecheck(SWIG_TYPECHECK_VECTOR) const vector<T>&,
@ -378,8 +377,8 @@ namespace std {
} else {
/* wrapped vector? */
std::vector<T >* v;
$1 = (SWIG_GetPtr($input,(void **) &v,
$1_descriptor) == 0) ? 1 : 0;
$1 = (SWIG_ConvertPtr($input,(void **) &v,
$1_descriptor, 0) != -1) ? 1 : 0;
}
}
public:
@ -428,12 +427,9 @@ namespace std {
specialize_stl_vector(short,gh_number_p,gh_scm2long,gh_long2scm);
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(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(std::string,gh_string_p,SWIG_scm2string,SWIG_string2scm);
}

View file

@ -30,51 +30,66 @@
/* Pointers */
%typemap(in) SWIGTYPE * {
if (SWIG_Guile_GetPtr($input, (void **) &$1, $descriptor))
scm_wrong_type_arg(FUNC_NAME, $argnum, $input);
%typemap(in) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] {
$1 = ($1_ltype)SWIG_MustGetPtr($input, $descriptor, $argnum, 0);
}
%typemap(in) void * {
if (SWIG_Guile_GetPtr($input, (void **) &$1, NULL))
scm_wrong_type_arg(FUNC_NAME, $argnum, $input);
$1 = SWIG_MustGetPtr($input, NULL, $argnum, 0);
}
%typemap(varin) SWIGTYPE * {
if (SWIG_Guile_GetPtr($input, (void **) &$1, $descriptor))
scm_wrong_type_arg(FUNC_NAME, 1, $input);
$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 * {
if (SWIG_Guile_GetPtr($input, (void **) &$1, NULL))
scm_wrong_type_arg(FUNC_NAME, 1, $input);
$1 = SWIG_MustGetPtr($input, NULL, 1, 0);
}
%typemap(out) SWIGTYPE * {
$result = SWIG_Guile_MakePtr ($1, $descriptor);
%typemap(out) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] {
$result = SWIG_NewPointerObj ($1, $descriptor, $owner);
}
%typemap(out) SWIGTYPE *DYNAMIC {
swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor,(void **) &$1);
$result = SWIG_Guile_MakePtr ($1, ty);
%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 * {
$result = SWIG_Guile_MakePtr ($1, $descriptor);
%typemap(varout) SWIGTYPE *, SWIGTYPE [] {
$result = SWIG_NewPointerObj ($1, $descriptor, 0);
}
%typemap(varout) SWIGTYPE & {
$result = SWIG_NewPointerObj((void *) &$1, $1_descriptor, 0);
}
/* Pass-by-value */
%typemap(in) SWIGTYPE($&1_ltype argp) {
if (SWIG_Guile_GetPtr($input, (void **) &argp, $&1_descriptor))
scm_wrong_type_arg(FUNC_NAME,$argnum,$input);
argp = ($&1_ltype)SWIG_MustGetPtr($input, $&1_descriptor, $argnum, 0);
$1 = *argp;
}
%typemap(varin) SWIGTYPE {
$&1_ltype argp;
if (SWIG_Guile_GetPtr($input, (void **) &argp, $&1_descriptor))
scm_wrong_type_arg(FUNC_NAME,1,$input);
argp = ($&1_ltype)SWIG_MustGetPtr($input, $&1_descriptor, 1, 0);
$1 = *argp;
}
@ -83,14 +98,14 @@
{
$&1_ltype resultptr;
resultptr = new $1_ltype(($1_ltype &) $1);
$result = SWIG_Guile_MakePtr (resultptr, $&1_descriptor);
$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_Guile_MakePtr(resultptr, $&1_descriptor);
$result = SWIG_NewPointerObj(resultptr, $&1_descriptor, 1);
}
#endif
@ -99,54 +114,23 @@
{
$&1_ltype resultptr;
resultptr = new $1_ltype(($1_ltype&) $1);
$result = SWIG_Guile_MakePtr (resultptr, $&1_descriptor);
$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_Guile_MakePtr(resultptr, $&1_descriptor);
$result = SWIG_NewPointerObj(resultptr, $&1_descriptor, 0);
}
#endif
/* C++ References */
#ifdef __cplusplus
%typemap(in) SWIGTYPE &, const SWIGTYPE & {
if (SWIG_Guile_GetPtr($input, (void **) &$1, $descriptor)!=0 || $1 == NULL)
scm_wrong_type_arg(FUNC_NAME, $argnum, $input);
}
%typemap(out) SWIGTYPE &, const SWIGTYPE & {
$result = SWIG_Guile_MakePtr ($1, $descriptor);
}
%typemap(out) SWIGTYPE &DYNAMIC {
swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor,(void **) &$1);
$result = SWIG_Guile_MakePtr ($1, ty);
}
#endif
/* Arrays */
%typemap(in) SWIGTYPE[] {
if (SWIG_Guile_GetPtr($input, (void **) &$1, $descriptor)!=0)
scm_wrong_type_arg(FUNC_NAME, $argnum, $input);
}
%typemap(out) SWIGTYPE[] {
$result = SWIG_Guile_MakePtr ($1, $descriptor);
}
/* Enums */
%typemap(in) enum SWIGTYPE "$1 = gh_scm2int($input);";
%typemap(varin) enum SWIGTYPE "$1 = ($1_type) gh_scm2int($input);";
%typemap(out) enum SWIGTYPE "$result = gh_int2scm($1);";
%typemap(varout) enum SWIGTYPE "$result = gh_int2scm($1);";
%typemap(in) enum SWIGTYPE { $1 = gh_scm2int($input); }
%typemap(varin) enum SWIGTYPE { $1 = ($1_type) gh_scm2int($input); }
%typemap(out) enum SWIGTYPE { $result = gh_int2scm($1); }
%typemap(varout) enum SWIGTYPE { $result = gh_int2scm($1); }
/* The SIMPLE_MAP_WITH_EXPR macro below defines the whole set of
typemaps needed for simple types.
@ -208,17 +192,19 @@
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), 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)
%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
%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);
@ -232,6 +218,7 @@
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_scm2int, gh_int2scm, integer);
SIMPLE_MAP(long, gh_scm2long, gh_long2scm, integer);
@ -267,12 +254,12 @@
%typemap (in) char * *INOUT = char * *INPUT;
%typemap (argout) char * *INOUT = char * *OUTPUT;
/* GSWIG_scm2str makes a malloc'ed copy of the string, so get rid of it after
/* 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) scm_must_free($1);";
%typemap (freearg) char **INPUT, char **BOTH "if (must_free$argnum && (*$1)) scm_must_free(*$1);"
%typemap (freearg) char **OUTPUT "scm_must_free(*$1);"
%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. */
@ -288,7 +275,7 @@
/* Void */
%typemap (out,doc="") void "gswig_result = GH_UNSPECIFIED;";
%typemap (out,doc="") void "gswig_result = SCM_UNSPECIFIED;";
/* SCM is passed through */
@ -353,17 +340,12 @@ typedef unsigned long SCM;
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] {
void *ptr;
$1 = !SWIG_Guile_GetPtr($input, &ptr, $1_descriptor);
$1 = !SWIG_ConvertPtr($input, &ptr, $1_descriptor, 0);
}
%typecheck(SWIG_TYPECHECK_VOIDPTR) void * {
void *ptr;
$1 = !SWIG_Guile_GetPtr($input, &ptr, 0);
$1 = !SWIG_ConvertPtr($input, &ptr, 0, 0);
}
/* typemaps.i ends here */