Initial additions.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@4312 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Jonah Beckford 2003-02-15 01:47:12 +00:00
commit 870e6457d1
4 changed files with 1491 additions and 0 deletions

View file

@ -0,0 +1,757 @@
/* -----------------------------------------------------------------------------
* chicken.swg
*
* CHICKEN configuration module.
* ----------------------------------------------------------------------------- */
/* chicken.h has to appear first. */
%insert(runtime) %{
#include "chicken.h"
%}
%insert(runtime) "common.swg"; // Common type-checking code
%insert(runtime) "chickenrun.swg"; // CHICKEN run-time code
/* -----------------------------------------------------------------------------
* standard typemaps
* ----------------------------------------------------------------------------- */
/*
CHICKEN: C
----------
fixnum: int, short, unsigned int, unsigned short, unsigned char,
signed char
char: char
bool: bool
flonum: float, double, long, long long, unsigned long, unsigned long
long
*/
/* --- Primitive types --- */
%include "fragments.i"
%define SIMPLE_TYPEMAP(type_, from_scheme, to_scheme, checker, convtype, storage_)
%typemap(in) type_
%{ if (!checker ($input)) {
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument #$argnum is not of type 'type_'");
}
$1 = ($1_ltype) from_scheme ($input); %}
/* Const primitive references. Passed by value */
%typemap(in) const type_ & (type_ temp)
%{ if (!checker ($input)) {
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument #$argnum is not of type 'type_'");
}
temp = ($*1_ltype) from_scheme ($input);
$1 = &temp; %}
/* --- Variable input --- */
%typemap(varin) type_
%{ if (!checker ($input)) {
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Cannot use '$1_ltype' for variable '$name' of type 'type_'");
}
$1 = ($1_ltype) from_scheme ($input); %}
#if "storage_" == "0"
%typemap(out, fragment="list_output_helper",chicken_words="storage_") type_
%{/*if ONE*/
$result = to_scheme (convtype ($1));
/*else*/
$result = list_output_helper (&known_space, $result, to_scheme (convtype ($1)));
/*endif*/ %}
/* References to primitive types. Return by value */
%typemap(out, fragment="list_output_helper",chicken_words="storage_") const type_ &
%{/*if ONE*/
$result = to_scheme (convtype (*$1));
/*else*/
$result = list_output_helper (&known_space, $result, to_scheme (convtype (*$1)));
/*endif*/ %}
/* --- Variable output --- */
%typemap(varout, fragment="list_output_helper",chicken_words="storage_") type_
%{/*if ONE*/
$result = to_scheme (convtype ($varname));
/*else*/
$result = list_output_helper (&known_space, $result, to_scheme (convtype ($varname)));
/*endif*/ %}
#else
%typemap(out, fragment="list_output_helper",chicken_words="storage_") type_
%{/*if ONE*/
$result = to_scheme (&known_space, convtype ($1));
/*else*/
$result = list_output_helper (&known_space, $result, to_scheme (&known_space, convtype ($1)));
/*endif*/ %}
/* References to primitive types. Return by value */
%typemap(out, fragment="list_output_helper",chicken_words="storage_") const type_ &
%{/*if ONE*/
$result = to_scheme (convtype (*$1));
/*else*/
$result = list_output_helper (&known_space, $result, to_scheme (convtype (*$1)));
/*endif*/ %}
/* --- Variable output --- */
%typemap(varout, fragment="list_output_helper",chicken_words="storage_") type_
%{/*if ONE*/
$result = to_scheme (&known_space, convtype ($varname));
/*else*/
$result = list_output_helper (&known_space, $result, to_scheme (&known_space, convtype ($varname)));
/*endif*/ %}
#endif
/* --- Constants --- */
#if ("type_" == "char") || ("type_" == "unsigned char") || ("type_" == "signed char")
%typemap(constcode) type_
"static const type_ $result = '$value';"
#else
%typemap(constcode) type_
"static const type_ $result = $value;"
#endif
%enddef
SIMPLE_TYPEMAP(int, C_unfix, C_fix, C_swig_is_fixnum, (int), 0);
SIMPLE_TYPEMAP(enum SWIGTYPE, C_unfix, C_fix, C_swig_is_fixnum, (int), 0);
SIMPLE_TYPEMAP(short, C_unfix, C_fix, C_swig_is_fixnum, (int), 0);
SIMPLE_TYPEMAP(long, C_flonum_magnitude, C_flonum, C_swig_is_flonum, (double), WORDS_PER_FLONUM);
SIMPLE_TYPEMAP(long long, C_flonum_magnitude, C_flonum, C_swig_is_flonum, (double), WORDS_PER_FLONUM);
SIMPLE_TYPEMAP(unsigned int, C_unfix, C_fix, C_swig_is_fixnum, (int), 0);
SIMPLE_TYPEMAP(unsigned short, C_unfix, C_fix, C_swig_is_fixnum, (int), 0);
SIMPLE_TYPEMAP(unsigned long, C_flonum_magnitude, C_flonum, C_swig_is_flonum, (double), WORDS_PER_FLONUM);
SIMPLE_TYPEMAP(unsigned long long, C_flonum_magnitude, C_flonum, C_swig_is_flonum, (double), WORDS_PER_FLONUM);
SIMPLE_TYPEMAP(unsigned char, C_unfix, C_fix, C_swig_is_fixnum, (int), 0);
SIMPLE_TYPEMAP(signed char, C_unfix, C_fix, C_swig_is_fixnum, (int), 0);
SIMPLE_TYPEMAP(char, C_character_code, C_make_character, C_swig_is_char, (char), 0);
SIMPLE_TYPEMAP(bool, C_truep, C_mkbool, C_swig_is_bool, (bool), 0);
SIMPLE_TYPEMAP(float, C_flonum_magnitude, C_flonum, C_swig_is_flonum, (double), WORDS_PER_FLONUM);
SIMPLE_TYPEMAP(double, C_flonum_magnitude, C_flonum, C_swig_is_flonum, (double), WORDS_PER_FLONUM);
/* --- Input arguments --- */
/* Strings */
%typemap(in) char *
{ if ($input == C_SCHEME_FALSE) {
$1 = NULL;
}
else {
if (!C_swig_is_string ($input)) {
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument #$argnum is not of type 'char *'");
}
$1 = ($ltype) swig_make_string ($input);
}
}
%typemap(freearg) char * "if ($1 != NULL) { free ($1); }"
/* Pointers, references, and arrays */
%typemap(in) SWIGTYPE *,
SWIGTYPE []
"swig_convert_ptr($input,(void **) &$1, $1_descriptor,SWIG_POINTER_EXCEPTION);"
/* Additional check for null references */
%typemap(in) SWIGTYPE &
"swig_convert_ptr($input,(void **) &$1, $1_descriptor,SWIG_POINTER_EXCEPTION);
if ($1 == NULL) swig_barf (SWIG_BARF1_ARGUMENT_NULL, \"null reference\");"
/* Void pointer. Accepts any kind of pointer */
%typemap(in) void * "swig_convert_ptr($input,(void **) &$1, 0, SWIG_POINTER_EXCEPTION);"
/* Object passed by value. Convert to a pointer */
%typemap(in) SWIGTYPE ($&1_ltype argp) "swig_convert_ptr($input,(void **) &argp, $&1_descriptor,SWIG_POINTER_EXCEPTION);
$1 = *argp; ";
/* Pointer to a class member */
%typemap(in) SWIGTYPE (CLASS::*) "swig_convert_packed($input, (void *) &$1, sizeof($1_type), $1_descriptor,SWIG_POINTER_EXCEPTION);";
/* --- Output values --- */
/* Strings */
%typemap(out,fragment="list_output_helper",chicken_words="0")
char *
{ char *s = (char*) $1;
if ($1 == NULL) {
$result = C_SCHEME_FALSE;
}
else {
int string_len = strlen ($1);
C_word *string_space = C_alloc (C_SIZEOF_STRING (string_len));
/*if ONE*/
$result = C_string (&string_space, string_len, s);
/*else*/
$result = list_output_helper (&known_space, $result, C_string (&string_space, string_len, s));
/*endif*/
}
}
%typemap(varout,fragment="list_output_helper",chicken_words="0")
char *
{ char *s = (char*) $varname;
if ($varname == NULL) {
$result = C_SCHEME_FALSE;
}
else {
int string_len = strlen ($varname);
C_word *string_space = C_alloc (C_SIZEOF_STRING (string_len));
/*if ONE*/
$result = C_string (&string_space, string_len, s);
/*else*/
$result = list_output_helper (&known_space, $result, C_string (&string_space, string_len, s));
/*endif*/
}
}
/* Pointers, references, and arrays */
%typemap(out,chicken_words="SWIG_ALLOCSZ_POINTER($typename)") SWIGTYPE *, SWIGTYPE &, SWIGTYPE []
"$result = swig_new_pointer_obj((void *) $1, &known_space, $1_descriptor);";
/* Dynamic casts */
%typemap(out,chicken_words="SWIG_ALLOCSZ_POINTER($typename)") SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC {
swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor, (void **) &$1);
$result = swig_new_pointer_obj((void *) $1, &known_space, ty);
}
/* Member pointer */
%typemap(out,chicken_words="SWIG_ALLOCSZ_PACKED_OBJ(sizeof($1_type),$typename)") SWIGTYPE (CLASS::*) "$result = swig_new_packed_obj((void *) &$1, &known_space, sizeof($1_type), $1_descriptor);";
/* Void */
%typemap(out,chicken_words="VOID") void
%{
/*if ONE*/
$result = C_SCHEME_UNDEFINED;
/*else*/
/* void return value, no need to be in $result */
/*endif*/
%}
/* Special typemap for character array return values */
%typemap(out,fragment="list_output_helper",chicken_words="0")
char [ANY], const char [ANY]
%{ if ($1 == NULL) {
$result = C_SCHEME_FALSE;
}
else {
const int string_len = strlen ($1);
C_word *string_space = C_alloc (C_SIZEOF_STRING (string_len));
/*if ONE*/
$result = C_string (&string_space, string_len, $1);
/*else*/
$result = list_output_helper (&known_space, $result, C_string (&string_space, string_len, $1));
/*endif*/
} %}
/* Primitive types--return by value */
%typemap(out,chicken_words="SWIG_ALLOCSZ_POINTER($typename)") SWIGTYPE
#ifdef __cplusplus
{
$&1_ltype resultptr;
resultptr = new $1_ltype(($1_ltype &) $1);
$result = swig_new_pointer_obj((void *) resultptr, &known_space, $&1_descriptor);
}
#else
{
$&1_ltype resultptr;
resultptr = ($&1_ltype) malloc(sizeof($1_type));
memmove(resultptr, &$1, sizeof($1_type));
$result = swig_new_pointer_obj((void *) resultptr, &known_space, $&1_descriptor);
}
#endif
/* --- Variable input --- */
/* A string */
#ifdef __cplusplus
%typemap(varin) char * {
if ($input == C_SCHEME_FALSE) {
$1 = NULL;
}
else if (!C_swig_is_string ($input)) {
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "C variable '$name ($1_ltype)'");
}
else {
char *temp = C_c_string ($input);
int len = C_header_size ($input);
if ($1) delete [] $1;
$1 = ($type) new char[len+1];
strncpy((char*)$1, temp, len);
((char*)$1) [len] = 0;
}
}
%typemap(varin,warning="451:Setting const char * variable may leak memory") const char * {
if ($input == C_SCHEME_FALSE) {
$1 = NULL;
}
else if (!C_swig_is_string ($input)) {
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "C variable '$name ($1_ltype)'");
}
else {
char *temp = C_c_string ($input);
int len = C_header_size ($input);
$1 = ($type) new char[len+1];
strncpy((char*)$1,temp,len);
((char*)$1) [len] = 0;
}
}
#else
%typemap(varin) char * {
if ($input == C_SCHEME_FALSE) {
$1 = NULL;
}
else if (!C_swig_is_string ($input)) {
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "C variable '$name ($1_ltype)'");
}
else {
char *temp = C_c_string ($input);
int len = C_header_size ($input);
if ($1) free((char*) $1);
$1 = ($type) malloc(len+1);
strncpy((char*)$1,temp,len);
((char*)$1) [len] = 0;
}
}
%typemap(varin,warning="451:Setting const char * variable may leak memory") const char * {
if ($input == C_SCHEME_FALSE) {
$1 = NULL;
}
else if (!C_swig_is_string ($input)) {
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "C variable '$name ($1_ltype)'");
}
else {
char *temp = C_c_string ($input);
int len = C_header_size ($input);
$1 = ($type) malloc(len+1);
strncpy((char*)$1,temp,len);
((char*)$1) [len] = 0;
}
}
#endif
%typemap(varin) SWIGTYPE [] {
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Variable $name is read-only");
}
/* Special case for string array variables */
%typemap(varin) char [ANY] {
if ($input == C_SCHEME_FALSE) {
$1 = NULL;
}
else if (!C_swig_is_string ($input)) {
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "C variable '$name ($1_ltype)'");
}
else {
char *temp = C_c_string ($input);
strncpy($1,temp,$1_dim0);
}
}
%typemap(varin) SWIGTYPE * {
if ($input == C_SCHEME_FALSE) {
$1 = NULL;
}
else {
void *temp;
swig_convert_ptr($input,(void **) &temp, $1_descriptor, SWIG_POINTER_EXCEPTION);
$1 = ($1_ltype) temp;
}
}
%typemap(varin) SWIGTYPE & {
void *temp;
swig_convert_ptr($input,(void **) &temp, $1_descriptor, SWIG_POINTER_EXCEPTION);
if (temp == NULL) {
swig_barf (SWIG_BARF1_ARGUMENT_NULL, "$name is a null reference");
return 1;
}
$1 = ($1_ltype) temp;
}
%typemap(varin) void * {
void * temp;
swig_convert_ptr($input,(void **) &temp, 0, SWIG_POINTER_EXCEPTION | SWIG_POINTER_DISOWN);
$1 = ($1_ltype) temp;
}
%typemap(varin) SWIGTYPE (CLASS::*) {
char temp[sizeof($1_type)];
swig_convert_packed($input,(void *) temp, sizeof($1_type), $1_descriptor, SWIG_POINTER_EXCEPTION);
memmove((void *) &$1,temp,sizeof($1_type));
}
%typemap(varin) SWIGTYPE {
$&1_ltype temp;
swig_convert_ptr($input, (void **) &temp, $&1_descriptor, SWIG_POINTER_EXCEPTION);
$1 = *(($&1_type) temp);
}
/* --- Variable output --- */
/* Pointers, references, and arrays */
%typemap(varout,chicken_words="SWIG_ALLOCSZ_POINTER($typename)") SWIGTYPE *, SWIGTYPE &, SWIGTYPE []
"$result = swig_new_pointer_obj((void *) $varname, &known_space, $1_descriptor);";
/* Member pointer */
%typemap(varout,chicken_words="SWIG_ALLOCSZ_PACKED_OBJ(sizeof($1_type),$typename)") SWIGTYPE (CLASS::*)
"$result = swig_new_packed_obj((void *) &$varname, sizeof($1_type), &known_space, $1_descriptor);";
/* Void */
%typemap(varout) void "$result = C_SCHEME_UNDEFINED;";
/* Special typemap for character array return values */
%typemap(varout) char [ANY], const char [ANY]
%{ if ($varname == C_SCHEME_FALSE) {
$result = NULL;
}
else if (C_swig_is_string ($varname)) {
$result = swig_make_string ($varname);
}
else {
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument #$argnum is not of type 'string'");
} %}
%typemap(varout,chicken_words="SWIG_ALLOCSZ_POINTER($typename)") SWIGTYPE "$result = swig_new_pointer_obj((void *) &$varname, &known_space, $&1_descriptor);";
/* --- Constants --- */
%typemap(constcode) char *
"static const char *$result = \"$value\";"
%typemap(constcode) SWIGTYPE *, SWIGTYPE &, SWIGTYPE []
"static const void *$result = (void*) $value;"
%typemap(constcode) SWIGTYPE (CLASS::*)
"static const void *$result = (void*) &$value;"
/* ------------------------------------------------------------
* String & length
* ------------------------------------------------------------ */
%typemap(in) (char *STRING, int LENGTH) {
if ($input == C_SCHEME_FALSE) {
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Cannot use a null/#f string for a char*, int arguments");
}
else if (C_swig_is_string ($input)) {
$1 = ($1_ltype) C_c_string ($input);
$2 = ($2_ltype) C_header_size ($input);
}
else {
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument #$argnum is not of type 'string'");
}
}
/* ------------------------------------------------------------
* ANSI C typemaps
* ------------------------------------------------------------ */
%typemap(in) size_t
%{ if (!C_swig_is_flonum ($input)) {
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument #$argnum is not of type 'flonum'");
}
$1 = (size_t) C_flonum_magnitude ($input); %}
%typemap(out) size_t = long;
%typemap(varin) size_t = long;
%typemap(varout) size_t = long;
%typemap(constcode) size_t = long;
/* ------------------------------------------------------------
* CHICKEN types
* ------------------------------------------------------------ */
%typemap(in) C_word "$1 = $input;";
%typemap(out) C_word "$result = $1;";
/* ------------------------------------------------------------
* Typechecking rules
* ------------------------------------------------------------ */
%typecheck(SWIG_TYPECHECK_INTEGER)
bool, const bool &
{
$1 = C_swig_is_bool ($input);
}
%typecheck(SWIG_TYPECHECK_INTEGER)
int, short,
unsigned int, unsigned short,
signed char, unsigned char,
const int &, const short &,
const unsigned int &, const unsigned short &,
enum SWIGTYPE
{
$1 = C_swig_is_fixnum ($input);
}
%typecheck(SWIG_TYPECHECK_INTEGER)
long,
unsigned long,
long long, unsigned long long,
const long &,
const unsigned long &,
const long long &, const unsigned long long &
{
$1 = (C_swig_is_bool ($input) ||
C_swig_is_fixnum ($input) ||
C_swig_is_flonum ($input)) ? 1 : 0;
}
%typecheck(SWIG_TYPECHECK_DOUBLE)
float, double,
const float &, const double &
{
$1 = C_swig_is_flonum ($input);
}
%typecheck(SWIG_TYPECHECK_CHAR) char {
$1 = C_swig_is_string ($input);
}
%typecheck(SWIG_TYPECHECK_STRING) char * {
$1 = C_swig_is_string ($input);
}
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] {
void *ptr;
if (swig_convert_ptr($input, (void **) &ptr, $1_descriptor, 0) == -1) {
$1 = 0;
} else {
$1 = 1;
}
}
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE {
void *ptr;
if (swig_convert_ptr($input, (void **) &ptr, $&1_descriptor, 0) == -1) {
$1 = 0;
} else {
$1 = 1;
}
}
%typecheck(SWIG_TYPECHECK_VOIDPTR) void * {
void *ptr;
if (swig_convert_ptr($input, (void **) &ptr, 0, 0) == -1) {
$1 = 0;
} else {
$1 = 1;
}
}
/* ------------------------------------------------------------
* Exception handling
* ------------------------------------------------------------ */
/* TODO */
/* ------------------------------------------------------------
* Overloaded operator support
* ------------------------------------------------------------ */
#ifdef __cplusplus
%rename(__add__) *::operator+;
%rename(__pos__) *::operator+();
%rename(__pos__) *::operator+() const;
%rename(__sub__) *::operator-;
%rename(__neg__) *::operator-();
%rename(__neg__) *::operator-() const;
%rename(__mul__) *::operator*;
%rename(__div__) *::operator/;
%rename(__mod__) *::operator%;
%rename(__lshift__) *::operator<<;
%rename(__rshift__) *::operator>>;
%rename(__and__) *::operator&;
%rename(__or__) *::operator|;
%rename(__xor__) *::operator^;
%rename(__invert__) *::operator~;
%rename(__iadd__) *::operator+=;
%rename(__isub__) *::operator-=;
%rename(__imul__) *::operator*=;
%rename(__idiv__) *::operator/=;
%rename(__imod__) *::operator%=;
%rename(__ilshift__) *::operator<<=;
%rename(__irshift__) *::operator>>=;
%rename(__iand__) *::operator&=;
%rename(__ior__) *::operator|=;
%rename(__ixor__) *::operator^=;
%rename(__lt__) *::operator<;
%rename(__le__) *::operator<=;
%rename(__gt__) *::operator>;
%rename(__ge__) *::operator>=;
%rename(__eq__) *::operator==;
%rename(__ne__) *::operator!=;
/* Special cases */
%rename(__call__) *::operator();
/* Ignored operators */
%ignorewarn("362:operator= ignored") operator=;
%ignorewarn("383:operator++ ignored") operator++;
%ignorewarn("384:operator-- ignored") operator--;
%ignorewarn("381:operator&& ignored") operator&&;
%ignorewarn("382:operator|| ignored") operator||;
%ignorewarn("386:operator->* ignored") operator->*;
%ignorewarn("389:operator[] ignored (consider using %extend)") operator[];
#endif
/* Warnings for certain CHICKEN keywords. From Section 7.1.1 of
Revised^5 Report on the Algorithmic Language Scheme */
#define CHICKW(x) %namewarn("314:" #x " is a R^5RS syntatic keyword") #x
CHICKW(else);
CHICKW(=>);
CHICKW(define);
CHICKW(unquote);
CHICKW(unquote-splicing);
CHICKW(quote);
CHICKW(lambda);
CHICKW(if);
CHICKW(set!);
CHICKW(begin);
CHICKW(cond);
CHICKW(and);
CHICKW(or);
CHICKW(case);
CHICKW(let);
CHICKW(let*);
CHICKW(letrec);
CHICKW(do);
CHICKW(delay);
CHICKW(quasiquote);
/* TinyCLOS <--> Low-level CHICKEN */
%typemap("clos_in") SIMPLE_CLOS_OBJECT * "(slot-ref $input (quote this))"
%typemap("clos_out") SIMPLE_CLOS_OBJECT * "(make $class (quote this) $1)"
/* VERBATIM CODE INSERTIONS */
%insert(header) %{
#ifdef __cplusplus
extern "C" {
#endif
/* Chicken initialization function */
SWIGEXPORT(void) $module_swig_init(int, C_word, C_word) C_noret;
/* Tag functions */
SWIGEXPORT(int) $module_swig_num_types (void);
SWIGEXPORT(const char*) $module_swig_type_name (int);
SWIGEXPORT(void*) $module_swig_type_ptr (int);
SWIGEXPORT(const char*) $module_swig_type_str (int);
SWIGEXPORT(void) $module_swig_type_tag (int, C_word);
#ifdef __cplusplus
}
#endif
%}
%insert(init) %{
/* CHICKEN initialization function */
SWIGEXPORT(void)
$module_swig_init(int argc, C_word closure, C_word continuation) {
static int typeinit = 0;
int i;
if (!typeinit) {
for (i = 0; swig_types_initial[i]; i++) {
swig_types[i] = SWIG_TypeRegister(swig_types_initial[i]);
}
typeinit = 1;
swig_init_helper (continuation);
}
else {
C_kontinue (continuation, C_SCHEME_FALSE);
}
}
/* Tag functions */
SWIGEXPORT(int)
$module_swig_num_types (void)
{
int i;
for (i=0; swig_types_initial[i]; i++);
return i;
}
SWIGEXPORT(const char*)
$module_swig_type_name (int index)
{
return swig_types[index]->name;
}
SWIGEXPORT(void*)
$module_swig_type_ptr (int index)
{
return (void*) (swig_types[index]);
}
SWIGEXPORT(const char*)
$module_swig_type_str (int index)
{
return swig_types[index]->str;
}
SWIGEXPORT(void)
$module_swig_type_tag (int index, C_word tag)
{
swig_chicken_clientdata *data =
(swig_chicken_clientdata*) malloc (sizeof (swig_chicken_clientdata));
C_mutate (&(data->tag), tag);
data->literal_frame = C_register_lf (&(data->tag), 1);
SWIG_TypeClientData (swig_types[index], (void*) data);
}
%}
%insert(chicken) %{
(declare
(foreign-declare "C_extern int $module_swig_num_types (void);")
(foreign-declare "C_extern char* $module_swig_type_name (int);")
(foreign-declare "C_extern void* $module_swig_type_ptr (int);")
(foreign-declare "C_extern char* $module_swig_type_str (int);")
(foreign-declare "C_extern void $module_swig_type_tag (int, C_word);"))
(define-record swig-$module-tag class name ptr str)
(define-record-printer (swig-$module-tag tag out)
(fprintf out "#<c++ ~S>(~A)" (swig-$module-tag-str tag)
(swig-$module-tag-ptr tag)))
(define swig-$module-tag-num
((foreign-lambda int "$module_swig_num_types")))
(define swig-$module-tags (make-vector swig-$module-tag-num #f))
(letrec
((gen
(lambda (l i)
(if (= i 0) (cons 0 l) (gen (cons i l) (- i 1))))))
(let ((indices (if (<= swig-$module-tag-num 0) (quote ())
(gen (quote ()) (- swig-$module-tag-num 1)))))
(for-each
(lambda (index)
(let
((tag
(make-swig-$module-tag
1000
((foreign-lambda
c-string "$module_swig_type_name" int) index)
((foreign-lambda
c-pointer "$module_swig_type_ptr" int) index)
((foreign-lambda
c-string "$module_swig_type_str" int) index))))
(vector-set! swig-$module-tags index tag)
((foreign-lambda void "$module_swig_type_tag"
int scheme-object) index tag)))
indices)))
%}

View file

@ -0,0 +1,375 @@
/***********************************************************************
* chickenrun.swg
*
* This file contains the runtime support for CHICKEN modules
* and includes code for managing global variables and pointer
* type checking.
*
* Author : Jonah Beckford
* Derived from - file : pyrun.swg
* Derived from - author : David Beazley (beazley@cs.uchicago.edu)
************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifdef C_SIXTY_FOUR
# define WORDS_PER_FLONUM 2
#else
# define WORDS_PER_FLONUM 4
#endif
/* Flags for pointer conversion */
#define SWIG_POINTER_EXCEPTION 0x1
#define C_swig_is_bool(x) C_truep (C_booleanp (x))
#define C_swig_is_char(x) C_truep (C_charp (x))
#define C_swig_is_fixnum(x) C_truep (C_fixnump (x))
#define C_swig_is_flonum(x) (C_truep (C_blockp (x)) && C_truep (C_flonump (x)))
#define C_swig_is_string(x) (C_truep (C_blockp (x)) && C_truep (C_stringp (x)))
#define C_swig_is_vector(x) (C_truep (C_blockp (x)) && C_truep (C_vectorp (x)))
#define C_swig_is_list(x) (C_truep (C_i_listp (x)))
#define C_swig_is_tagged_ptr(x) (C_truep (C_blockp (x)) && C_truep (C_taggedpointerp (x)))
#define C_swig_is_tag_struct(x) (C_truep (C_blockp (x)) && C_truep (C_structurep (x)) && (C_header_size (x) >= 3))
#define C_swig_is_ptr(x) (C_truep (C_blockp (x)) && C_truep (C_pointerp (x)))
enum {
SWIG_BARF1_BAD_ARGUMENT_TYPE /* 1 arg */,
SWIG_BARF1_ARGUMENT_NULL /* 1 arg */
};
typedef struct swig_chicken_clientdata {
void* literal_frame;
C_word tag;
} swig_chicken_clientdata;
#ifdef SWIG_NOINCLUDE
SWIGEXPORT(char *) swig_make_string (C_word string);
SWIGEXPORT(char *) swig_make_string2 (char *data, int len);
SWIGEXPORT(void) swig_barf (int code, C_char *msg, ...) C_noret;
SWIGEXPORT(void) swig_panic (C_char *msg) C_noret;
SWIGEXPORT(int) swig_convert_ptr(C_word , void **,
swig_type_info *, int);
SWIGEXPORT(int) swig_convert_packed(C_word , void *, int sz,
swig_type_info *, int);
SWIGEXPORT(char *) swig_pack_data(char *c, void *, int);
SWIGEXPORT(char *) swig_unpack_data(char *c, void *, int);
SWIGEXPORT(C_word) swig_new_pointer_obj(void *, swig_type_info *,
int own);
SWIGEXPORT(C_word) swig_new_packed_obj(void *, int sz,
swig_type_info *);
#else
/* Allocate a zero-terminated string. No error-checking. */
SWIGRUNTIME(char *)
swig_make_string2 (char *data, int len)
{
char *ret;
if (data == NULL) return NULL;
ret = (char *) malloc (len + 1);
strncpy (ret, data, len);
ret [len] = 0;
return ret;
}
/* Allocate a zero-terminated string. No error-checking. */
SWIGRUNTIME(char *)
swig_make_string (C_word string)
{
return swig_make_string2 (C_c_string (string),
C_header_size (string));
}
SWIGRUNTIME(void) swig_panic (C_char *) C_noret;
SWIGRUNTIME(void)
swig_panic (C_char *msg)
{
C_word *a = C_alloc (C_SIZEOF_STRING (strlen (msg)));
C_word scmmsg = C_string2 (&a, msg);
C_halt (scmmsg);
exit (5); /* should never get here */
}
SWIGRUNTIME(void) swig_barf (int, C_char *, ...) C_noret;
SWIGRUNTIME(void)
swig_barf (int code, C_char *msg, ...)
{
char *errorhook = C_text("\003syserror-hook");
C_word *a = C_alloc (C_SIZEOF_STRING (strlen (errorhook)));
C_word err = C_intern2 (&a, errorhook);
int c = -1;
int i, barfval;
va_list v;
C_temporary_stack = C_temporary_stack_bottom;
err = C_block_item(err, 0);
if(C_immediatep (err))
swig_panic (C_text ("`##sys#error-hook' is not defined"));
switch (code) {
case SWIG_BARF1_BAD_ARGUMENT_TYPE:
barfval = C_BAD_ARGUMENT_TYPE_ERROR;
c = 1;
break;
case SWIG_BARF1_ARGUMENT_NULL:
barfval = C_BAD_ARGUMENT_TYPE_ERROR;
c = 1;
break;
default:
swig_panic (C_text (msg));
};
if(c > 0 && !C_immediatep (err)) {
C_save (C_fix (barfval));
i = c;
if (i) {
C_word *b = C_alloc (C_SIZEOF_STRING (strlen (msg)));
C_word scmmsg = C_string2 (&b, msg);
C_save (scmmsg);
i--;
}
va_start (v, msg);
while(i--)
C_save (va_arg (v, C_word));
va_end (v);
C_do_apply (c + 1, err,
C_SCHEME_UNDEFINED); /* <- no continuation is passed:
'##sys#error-hook' may not
return! */
}
else if (msg) {
swig_panic (msg);
}
else {
swig_panic (C_text ("unspecified panic"));
}
}
/* Pack binary data into a string */
SWIGRUNTIME(char *)
swig_pack_data(char *c, void *ptr, int sz) {
static char hex[17] = "0123456789abcdef";
int i;
unsigned char *u = (unsigned char *) ptr;
register unsigned char uu;
for (i = 0; i < sz; i++,u++) {
uu = *u;
*(c++) = hex[(uu & 0xf0) >> 4];
*(c++) = hex[uu & 0xf];
}
return c;
}
/* Unpack binary data from a string */
SWIGRUNTIME(char *)
swig_unpack_data(char *c, void *ptr, int sz) {
register unsigned char uu = 0;
register int d;
unsigned char *u = (unsigned char *) ptr;
int i;
for (i = 0; i < sz; i++, u++) {
d = *(c++);
if ((d >= '0') && (d <= '9'))
uu = ((d - '0') << 4);
else if ((d >= 'a') && (d <= 'f'))
uu = ((d - ('a'-10)) << 4);
d = *(c++);
if ((d >= '0') && (d <= '9'))
uu |= (d - '0');
else if ((d >= 'a') && (d <= 'f'))
uu |= (d - ('a'-10));
*u = uu;
}
return c;
}
/* Convert a pointer value */
SWIGRUNTIME(int)
swig_convert_ptr(C_word obj, void **ptr, swig_type_info *ty, int flags) {
swig_type_info *tc;
#ifdef SWIG_POINTER_AS_STRING
char *s;
char *c;
if (obj == C_SCHEME_FALSE) {
*ptr = 0;
return 0;
}
c = s = 0;
if (!(C_swig_is_string (obj))) goto type_error;
s = c = swig_make_string (obj);
if (!c) goto type_error;
/* Pointer values must start with leading underscore */
if (*c != '_') goto type_error;
c++;
c = swig_unpack_data (c,ptr,sizeof(void *));
if (ty) {
tc = SWIG_TypeCheck(c,ty);
if (!tc) goto type_error;
*ptr = SWIG_TypeCast(tc,(void*) *ptr);
}
free (s);
#else
C_word tag;
C_word tag_ptr;
if (obj == C_SCHEME_FALSE) {
*ptr = 0;
return 0;
}
if (!(C_swig_is_tagged_ptr (obj))) goto type_error;
*ptr = (void*) C_pointer_address (obj);
if (ty) {
tag = C_block_item (obj, 1);
if (!(C_swig_is_tag_struct (tag))) goto type_error;
tag_ptr = C_block_item (tag, 3);
if (!(C_swig_is_ptr (tag_ptr))) goto type_error;
tc = (swig_type_info *) C_pointer_address (tag_ptr);
if (!tc) goto type_error;
*ptr = SWIG_TypeCast(tc,(void*) *ptr);
}
#endif
return 0;
type_error:
#ifdef SWIG_POINTER_AS_STRING
if (s) { free (s); }
#endif
if (flags & SWIG_POINTER_EXCEPTION) {
if (ty) {
char *temp = (char *) malloc(64+strlen(ty->name));
sprintf(temp,"Type error. Expected %s", ty->name);
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, temp);
free((char *) temp);
} else {
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Expected a pointer");
}
}
return -1;
}
/* Convert a packed value */
SWIGRUNTIME(int)
swig_convert_packed(C_word obj, void *ptr, int sz, swig_type_info *ty, int flags) {
swig_type_info *tc;
char *c;
char *s;
if (!C_swig_is_string (obj)) goto type_error;
s = c = swig_make_string (obj);
/* Pointer values must start with leading underscore */
if (!c || *c != '_') goto type_error;
c++;
c = swig_unpack_data(c,ptr,sz);
if (ty) {
tc = SWIG_TypeCheck(c,ty);
if (!tc) goto type_error;
}
free (s);
return 0;
type_error:
free (s);
if (flags) {
if (ty) {
char *temp = (char *) malloc(64+strlen(ty->name));
sprintf(temp,"Type error. Expected %s", ty->name);
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, temp);
free((char *) temp);
} else {
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Expected a pointer");
}
}
return -1;
}
#define SWIG_STRLEN_PACKED_OBJ(obj_sz,name) (2*obj_sz+1+strlen(name))
#define SWIG_ALLOCSZ_PACKED_OBJ(obj_sz,name) (C_SIZEOF_STRING (SWIG_STRLEN_PACKED_OBJ (obj_sz,name)))
/* #define SWIG_ALLOCSZ_POINTER(name) SWIG_ALLOCSZ_PACKED_OBJ(sizeof(void*),name) */
#define SWIG_ALLOCSZ_POINTER(name) 3
/* Create a new pointer object. 'a' should be a pointer to some
C_alloc result with SWIG_ALLOCSZ_POINTER (type->name) room */
SWIGRUNTIME(C_word)
swig_new_pointer_obj(void *ptr, C_word **a, swig_type_info *type) {
if (ptr == NULL)
return C_SCHEME_FALSE;
#ifdef SWIG_POINTER_AS_STRING
{
char result[1024];
char *r = result;
*(r++) = '_';
r = swig_pack_data(r,&ptr,sizeof(void *));
strcpy(r,type->name);
return C_string2 (a, result);
}
#else
{
/* similar to C_mpointer */
C_word *p = *a,
*p0 = p;
*(p++) = C_TAGGED_POINTER_TAG;
*((void **)(p++)) = ptr;
C_mutate ((C_word*)(p++),
((swig_chicken_clientdata*) type->clientdata)->tag);
*a = p;
return (C_word)p0;
}
#endif
}
/* 'a' should be a pointer to some C_alloc result with
SWIG_ALLOCSZ_PACKED_OBJ (sz,type->name) room */
SWIGRUNTIME(C_word)
swig_new_packed_obj (void *ptr, C_word **a, int sz, swig_type_info *type) {
char result[1024];
char *r = result;
if (SWIG_STRLEN_PACKED_OBJ (sz, type->name) > 1000) return 0;
*(r++) = '_';
r = swig_pack_data(r,ptr,sz);
strcpy(r,type->name);
return C_string2 (a, result);
}
/* Standard Chicken function */
static void C_fcall swig_tr2(C_proc2 k) C_regparm C_noret;
static void C_fcall swig_tr2(C_proc2 k) {
C_word t1=C_pick(0);
C_word t0=C_pick(1);
C_adjust_stack(-2);
(k)(2,t0,t1);
}
/* Standard Chicken function */
static void C_fcall swig_tr2r(C_proc2 k) C_regparm C_noret;
static void C_fcall swig_tr2r(C_proc2 k) {
int n;
C_word *a,t2;
C_word t1=C_pick(0);
C_word t0=C_pick(1);
C_adjust_stack(-2);
n=C_rest_count(0);
a=C_alloc(n*3);
t2=C_restore_rest(a,n);
(k)(t0,t1,t2);
}
#endif
#ifdef __cplusplus
}
#endif

View file

@ -0,0 +1,21 @@
/* Helper function to return tuples.
* Jonah Beckford
*
* Derived from Lib/python/fragments.i; Author: Robin Dunn
*
*
*/
%fragment("list_output_helper","header") %{
static C_word list_output_helper(C_word **ptr, C_word target, C_word o)
/* Prepends 'o' to list 'target'. ptr must be from C_alloc and have
room for 3 C_words. */
{
if (!target || C_truep (C_undefinedp (target))) {
target = C_pair (ptr, o, C_SCHEME_END_OF_LIST);
} else {
target = C_pair (ptr, o, target);
}
return target;
}
%}

338
SWIG/Lib/chicken/typemaps.i Normal file
View file

@ -0,0 +1,338 @@
//
// SWIG Typemap library
// Jonah Beckford
// Nov 22, 2002
// Derived: Dave Beazley (Author); Lib/python/typemaps.i; May 5, 1997
//
// CHICKEN implementation
//
// This library provides standard typemaps for modifying SWIG's behavior.
// With enough entries in this file, I hope that very few people actually
// ever need to write a typemap.
//
// Disclaimer : Unless you really understand how typemaps work, this file
// probably isn't going to make much sense.
//
// ------------------------------------------------------------------------
// Pointer handling
//
// These mappings provide support for input/output arguments and
// common uses for C/C++ pointers. INOUT mappings allow for C/C++
// pointer variables in addition to input/output arguments.
// ------------------------------------------------------------------------
// INPUT typemaps.
// These remap a C pointer to be an "INPUT" value which is passed by value
// instead of reference.
/*
The following methods can be applied to turn a pointer into a simple
"input" value. That is, instead of passing a pointer to an object,
you would use a real value instead.
int *INPUT
short *INPUT
long *INPUT
long long *INPUT
unsigned int *INPUT
unsigned short *INPUT
unsigned long *INPUT
unsigned long long *INPUT
unsigned char *INPUT
char *INPUT
bool *INPUT
float *INPUT
double *INPUT
To use these, suppose you had a C function like this :
double fadd(double *a, double *b) {
return *a+*b;
}
You could wrap it with SWIG as follows :
%include typemaps.i
double fadd(double *INPUT, double *INPUT);
or you can use the %apply directive :
%include typemaps.i
%apply double *INPUT { double *a, double *b };
double fadd(double *a, double *b);
*/
// OUTPUT typemaps. These typemaps are used for parameters that
// are output only. The output value is appended to the result as
// a list element.
/*
The following methods can be applied to turn a pointer into an "output"
value. When calling a function, no input value would be given for
a parameter, but an output value would be returned. In the case of
multiple output values, they are returned in the form of a Scheme list.
int *OUTPUT
short *OUTPUT
long *OUTPUT
long long *OUTPUT
unsigned int *OUTPUT
unsigned short *OUTPUT
unsigned long *OUTPUT
unsigned long long *OUTPUT
unsigned char *OUTPUT
char *OUTPUT
bool *OUTPUT
float *OUTPUT
double *OUTPUT
For example, suppose you were trying to wrap the modf() function in the
C math library which splits x into integral and fractional parts (and
returns the integer part in one of its parameters).K:
double modf(double x, double *ip);
You could wrap it with SWIG as follows :
%include typemaps.i
double modf(double x, double *OUTPUT);
or you can use the %apply directive :
%include typemaps.i
%apply double *OUTPUT { double *ip };
double modf(double x, double *ip);
The CHICKEN output of the function would be a list containing both
output values, in reverse order.
*/
// These typemaps contributed by Robin Dunn
//----------------------------------------------------------------------
//
// T_OUTPUT typemap (and helper function) to return multiple argouts as
// a tuple instead of a list.
//
// Author: Robin Dunn
//----------------------------------------------------------------------
%include "fragments.i"
// Simple types
%define INOUT_TYPEMAP(type_, from_scheme, to_scheme, checker, convtype, storage_)
%typemap(in) type_ *INPUT(type_ temp), type_ &INPUT(type_ temp)
%{ if (!checker ($input)) {
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument #$argnum is not of type 'type_'");
}
temp = from_scheme ($input);
$1 = &temp; %}
%typemap(typecheck) type_ *INPUT = type_;
%typemap(typecheck) type_ &INPUT = type_;
%typemap(in, numinputs=0) type_ *OUTPUT(type_ temp), type_ &OUTPUT(type_ temp)
" $1 = &temp;"
#if "storage_" == "0"
%typemap(argout,fragment="list_output_helper",chicken_words="storage_")
type_ *OUTPUT, type_ &OUTPUT
%{ if ($1 == NULL) {
swig_barf (SWIG_BARF1_ARGUMENT_NULL, "Argument #$argnum must be non-null");
}
/*if ONE*/
$result = to_scheme (convtype (*$1));
/*else*/
$result = list_output_helper (&known_space, $result, to_scheme (convtype (*$1)));
/*endif*/ %}
#else
%typemap(argout,fragment="list_output_helper",chicken_words="storage_")
type_ *OUTPUT, type_ &OUTPUT
%{if ($1 == NULL) {
swig_barf (SWIG_BARF1_ARGUMENT_NULL, "Variable '$1' must be non-null");
}
/*if ONE*/
$result = to_scheme (&known_space, convtype (*$1));
/*else*/
$result = list_output_helper (&known_space, $result, to_scheme (&known_space, convtype (*$1)));
/*endif*/ %}
#endif
%enddef
INOUT_TYPEMAP(int, C_unfix, C_fix, C_swig_is_fixnum, (int), 0);
INOUT_TYPEMAP(enum SWIGTYPE, C_unfix, C_fix, C_swig_is_fixnum, (int), 0);
INOUT_TYPEMAP(short, C_unfix, C_fix, C_swig_is_fixnum, (int), 0);
INOUT_TYPEMAP(long, C_flonum_magnitude, C_flonum, C_swig_is_flonum, (double), WORDS_PER_FLONUM);
INOUT_TYPEMAP(long long, C_flonum_magnitude, C_flonum, C_swig_is_flonum, (double), WORDS_PER_FLONUM);
INOUT_TYPEMAP(unsigned int, C_unfix, C_fix, C_swig_is_fixnum, (int), 0);
INOUT_TYPEMAP(unsigned short, C_unfix, C_fix, C_swig_is_fixnum, (int), 0);
INOUT_TYPEMAP(unsigned long, C_flonum_magnitude, C_flonum, C_swig_is_flonum, (double), WORDS_PER_FLONUM);
INOUT_TYPEMAP(unsigned long long, C_flonum_magnitude, C_flonum, C_swig_is_flonum, (double), WORDS_PER_FLONUM);
INOUT_TYPEMAP(unsigned char, C_unfix, C_fix, C_swig_is_fixnum, (int), 0);
INOUT_TYPEMAP(signed char, C_unfix, C_fix, C_swig_is_fixnum, (int), 0);
INOUT_TYPEMAP(char, C_character_code, C_make_character, C_swig_is_char, (char), 0);
INOUT_TYPEMAP(bool, C_truep, C_mkbool, C_swig_is_bool, (bool), 0);
INOUT_TYPEMAP(float, C_flonum_magnitude, C_flonum, C_swig_is_flonum, (double), WORDS_PER_FLONUM);
INOUT_TYPEMAP(double, C_flonum_magnitude, C_flonum, C_swig_is_flonum, (double), WORDS_PER_FLONUM);
// INOUT
// Mappings for an argument that is both an input and output
// parameter
/*
The following methods can be applied to make a function parameter both
an input and output value. This combines the behavior of both the
"INPUT" and "OUTPUT" methods described earlier. Output values are
returned in the form of a CHICKEN tuple.
int *INOUT
short *INOUT
long *INOUT
long long *INOUT
unsigned int *INOUT
unsigned short *INOUT
unsigned long *INOUT
unsigned long long *INOUT
unsigned char *INOUT
char *INOUT
bool *INOUT
float *INOUT
double *INOUT
For example, suppose you were trying to wrap the following function :
void neg(double *x) {
*x = -(*x);
}
You could wrap it with SWIG as follows :
%include typemaps.i
void neg(double *INOUT);
or you can use the %apply directive :
%include typemaps.i
%apply double *INOUT { double *x };
void neg(double *x);
As well, you can wrap variables with :
%include typemaps.i
%apply double *INOUT { double *y };
extern double *y;
Unlike C, this mapping does not directly modify the input value (since
this makes no sense in CHICKEN). Rather, the modified input value shows
up as the return value of the function. Thus, to apply this function
to a CHICKEN variable you might do this :
x = neg(x)
Note : previous versions of SWIG used the symbol 'BOTH' to mark
input/output arguments. This is still supported, but will be slowly
phased out in future releases.
*/
%typemap(in) int *INOUT = int *INPUT;
%typemap(in) enum SWIGTYPE *INOUT = enum SWIGTYPE *INPUT;
%typemap(in) short *INOUT = short *INPUT;
%typemap(in) long *INOUT = long *INPUT;
%typemap(in) long long *INOUT = long long *INPUT;
%typemap(in) unsigned *INOUT = unsigned *INPUT;
%typemap(in) unsigned short *INOUT = unsigned short *INPUT;
%typemap(in) unsigned long *INOUT = unsigned long *INPUT;
%typemap(in) unsigned long long *INOUT = unsigned long long *INPUT;
%typemap(in) unsigned char *INOUT = unsigned char *INPUT;
%typemap(in) char *INOUT = char *INPUT;
%typemap(in) bool *INOUT = bool *INPUT;
%typemap(in) float *INOUT = float *INPUT;
%typemap(in) double *INOUT = double *INPUT;
%typemap(in) int &INOUT = int &INPUT;
%typemap(in) enum SWIGTYPE &INOUT = enum SWIGTYPE &INPUT;
%typemap(in) short &INOUT = short &INPUT;
%typemap(in) long &INOUT = long &INPUT;
%typemap(in) long long &INOUT = long long &INPUT;
%typemap(in) unsigned &INOUT = unsigned &INPUT;
%typemap(in) unsigned short &INOUT = unsigned short &INPUT;
%typemap(in) unsigned long &INOUT = unsigned long &INPUT;
%typemap(in) unsigned long long &INOUT = unsigned long long &INPUT;
%typemap(in) unsigned char &INOUT = unsigned char &INPUT;
%typemap(in) char &INOUT = char &INPUT;
%typemap(in) bool &INOUT = bool &INPUT;
%typemap(in) float &INOUT = float &INPUT;
%typemap(in) double &INOUT = double &INPUT;
%typemap(argout) int *INOUT = int *OUTPUT;
%typemap(argout) enum SWIGTYPE *INOUT = enum SWIGTYPE *OUTPUT;
%typemap(argout) short *INOUT = short *OUTPUT;
%typemap(argout) long *INOUT = long *OUTPUT;
%typemap(argout) long long *INOUT = long long *OUTPUT;
%typemap(argout) unsigned *INOUT = unsigned *OUTPUT;
%typemap(argout) unsigned short *INOUT = unsigned short *OUTPUT;
%typemap(argout) unsigned long *INOUT = unsigned long *OUTPUT;
%typemap(argout) unsigned long long *INOUT = unsigned long long *OUTPUT;
%typemap(argout) unsigned char *INOUT = unsigned char *OUTPUT;
%typemap(argout) bool *INOUT = bool *OUTPUT;
%typemap(argout) float *INOUT = float *OUTPUT;
%typemap(argout) double *INOUT = double *OUTPUT;
%typemap(argout) int &INOUT = int &OUTPUT;
%typemap(argout) enum SWIGTYPE &INOUT = enum SWIGTYPE &OUTPUT;
%typemap(argout) short &INOUT = short &OUTPUT;
%typemap(argout) long &INOUT = long &OUTPUT;
%typemap(argout) long long &INOUT = long long &OUTPUT;
%typemap(argout) unsigned &INOUT = unsigned &OUTPUT;
%typemap(argout) unsigned short &INOUT = unsigned short &OUTPUT;
%typemap(argout) unsigned long &INOUT = unsigned long &OUTPUT;
%typemap(argout) unsigned long long &INOUT = unsigned long long &OUTPUT;
%typemap(argout) unsigned char &INOUT = unsigned char &OUTPUT;
%typemap(argout) char &INOUT = char &OUTPUT;
%typemap(argout) bool &INOUT = bool &OUTPUT;
%typemap(argout) float &INOUT = float &OUTPUT;
%typemap(argout) double &INOUT = double &OUTPUT;
/* Overloading information */
%typemap(typecheck) double *INOUT = double;
%typemap(typecheck) bool *INOUT = bool;
%typemap(typecheck) char *INOUT = char;
%typemap(typecheck) signed char *INOUT = signed char;
%typemap(typecheck) unsigned char *INOUT = unsigned char;
%typemap(typecheck) unsigned long *INOUT = unsigned long;
%typemap(typecheck) unsigned long long *INOUT = unsigned long long;
%typemap(typecheck) unsigned short *INOUT = unsigned short;
%typemap(typecheck) unsigned int *INOUT = unsigned int;
%typemap(typecheck) long *INOUT = long;
%typemap(typecheck) long long *INOUT = long long;
%typemap(typecheck) short *INOUT = short;
%typemap(typecheck) int *INOUT = int;
%typemap(typecheck) enum SWIGTYPE *INOUT = enum SWIGTYPE;
%typemap(typecheck) float *INOUT = float;
%typemap(typecheck) double &INOUT = double;
%typemap(typecheck) bool &INOUT = bool;
%typemap(typecheck) char &INOUT = char;
%typemap(typecheck) signed char &INOUT = signed char;
%typemap(typecheck) unsigned char &INOUT = unsigned char;
%typemap(typecheck) unsigned long &INOUT = unsigned long;
%typemap(typecheck) unsigned long long &INOUT = unsigned long long;
%typemap(typecheck) unsigned short &INOUT = unsigned short;
%typemap(typecheck) unsigned int &INOUT = unsigned int;
%typemap(typecheck) long &INOUT = long;
%typemap(typecheck) long long &INOUT = long long;
%typemap(typecheck) short &INOUT = short;
%typemap(typecheck) int &INOUT = int;
%typemap(typecheck) enum SWIGTYPE &INOUT = enum SWIGTYPE;
%typemap(typecheck) float &INOUT = float;