--- Begin Message ---
Package: swig1.3
Version: 1.3.19-1.1
Severity: normal
using the attached swig interface file, a wrapper file is generated
which has $input mis-substituted (search for !!! BUG for my comment)
I used the command:
swig-1.3 -declaremodule -mzscheme swig-test.i
--- swig-test.i start
%module swig_test
%typemap(in) integer *(int i) {
if (SCHEME_INTP($input))
{
i = SCHEME_INT_VAL($input);
$1 = (integer *) &i;
}
else if (SCHEME_BOXP($input) && SCHEME_INTP(SCHEME_BOX_VAL($input)))
{
i = SCHEME_INT_VAL(SCHEME_BOX_VAL($input));
$1 = (integer *) &i;
}
else
scheme_wrong_type("?","integer *",-1,0,&$input);
}
%typemap(argout) integer * {
if (SCHEME_BOXP($input))
{
SCHEME_BOX_VAL($input) = scheme_make_integer(*$1);
}
}
%{
#include <math.h>
#include <g2c.h>
int test_(integer *pi,integer *pj)
{
fprintf(stderr,"test_:%d,%d\n",*pi,*pj);
*pi -= 2;
*pj -= 2;
return 0;
}
%}
/* test */ int test_(integer *pi,integer *pj);
--- swig-test.i end
--- swig output start
/* -*- buffer-read-only: t -*- vi: set ro: */
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 1.3.19
*
* This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not
make
* changes to this file unless you know what you are doing--modify the SWIG
* interface file instead.
*
----------------------------------------------------------------------------- */
/* -*-c-*-
* -----------------------------------------------------------------------
* swig_lib/mzscheme/mzschemedec.swg
* Copyright (C) 2000, 2001 Matthias Koeppe
*
* MzScheme runtime code -- declarations
* ----------------------------------------------------------------------- */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <escheme.h>
#if defined(SWIG_NOINCLUDE)
# define SWIGSTATIC
#elif defined(SWIG_GLOBAL)
# define SWIGSTATIC
#else
# define SWIGSTATIC static
#endif
#ifdef __cplusplus
extern "C" {
#endif
#define MAXVALUES 6
static Scheme_Object *
swig_make_boolean(int b)
{
if (b) return scheme_true;
else return scheme_false;
}
static Scheme_Object *
swig_package_values(int num, Scheme_Object **values);
typedef struct SwigPtrType SwigPtrType;
typedef struct swig_type_info *(*swig_dycast_func)(void **);
typedef struct swig_type_info {
const char *name;
void *(*converter)(void *);
const char *str;
void *clientdata;
SwigPtrType *ptrtype;
swig_dycast_func dcast;
} swig_type_info;
SWIGSTATIC SwigPtrType *
SWIG_RegisterType (const char *type, const char *prettyname);
SWIGSTATIC void
SWIG_RegisterMapping (const char *origtype, const char *newtype, void
*(*cast)(void *));
/* Dynamic pointer casting. Down an inheritance hierarchy */
SWIGSTATIC swig_type_info *
SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr);
SWIGSTATIC Scheme_Object *
SWIG_MakePtr(void *c_pointer, swig_type_info *type);
SWIGSTATIC int
SWIG_GetPtr(Scheme_Object *s, void **result, swig_type_info *type);
SWIGSTATIC void *
SWIG_MustGetPtr_ (Scheme_Object *s, swig_type_info *type,
int argnum, const char *func_name,
int argc, Scheme_Object **argv);
#define SWIG_MustGetPtr(s, type, argnum) \
SWIG_MustGetPtr_(s, type, argnum, FUNC_NAME, argc, argv)
SWIGSTATIC
void SWIG_RegisterTypes(swig_type_info **table,
swig_type_info **init);
#ifdef __cplusplus
}
#endif
/* mzschemedec.swg ends here */
/* -*-c-*- */
/* SWIG pointer structure */
#ifdef __cplusplus
extern "C" {
#endif
struct SwigCast {
struct SwigPtrType *type; /* Type in SwigPtrTbl */
void *(*cast)(void *); /* Pointer casting function */
struct SwigCast *next; /* Linked list pointer */
};
struct SwigPtrType {
const char *name; /* Datatype name */
const char *prettyname; /* Pretty datatype name */
struct SwigCast *cast; /* List of compatible types */
};
struct swig_proxy {
Scheme_Type type;
SwigPtrType *ptrtype;
void *object;
};
/* Pointer table */
static SwigPtrType **SwigPtrTbl = 0; /* Sorted table */
static int SwigPtrMax = 64; /* Max entries that can be held */
/* (may be adjusted dynamically) */
static int SwigPtrN = 0; /* Current number of entries */
static int SwigPtrSort = 0; /* Status flag indicating sort */
/* Sort comparison function */
static int
swigsort (const void *data1, const void *data2)
{
SwigPtrType *type1 = * (SwigPtrType **) data1;
SwigPtrType *type2 = * (SwigPtrType **) data2;
return strcmp(type1->name, type2->name);
}
/* Register a new datatype with the type-checker */
SWIGSTATIC SwigPtrType *
SWIG_RegisterType (const char *type, const char *prettyname)
{
int i;
struct SwigPtrType **t;
/* Allocate the pointer table if necessary */
if (!SwigPtrTbl) {
SwigPtrTbl = (SwigPtrType **) malloc(SwigPtrMax*sizeof(SwigPtrType *));
SwigPtrN = 0;
}
/* Grow the table if necessary */
if (SwigPtrN >= SwigPtrMax) {
SwigPtrMax = 2*SwigPtrMax;
SwigPtrTbl = (SwigPtrType **) realloc((char *) SwigPtrTbl,
SwigPtrMax*sizeof(SwigPtrType *));
}
/* Look up type */
for (i = 0; i < SwigPtrN; i++)
if (strcmp(SwigPtrTbl[i]->name,type) == 0) {
if (prettyname!=NULL)
SwigPtrTbl[i]->prettyname = prettyname;
return SwigPtrTbl[i];
}
t = SwigPtrTbl + SwigPtrN;
*t = (SwigPtrType *) malloc(sizeof(SwigPtrType));
(*t)->name = type;
(*t)->prettyname = prettyname;
(*t)->cast = NULL;
SwigPtrN++;
SwigPtrSort = 0;
return *t;
}
/* Register two data types and their mapping with the type checker. */
SWIGSTATIC void
SWIG_RegisterMapping (const char *origtype, const char *newtype, void
*(*cast)(void *))
{
struct SwigPtrType *t = SWIG_RegisterType(origtype, NULL);
if (newtype!=NULL) {
struct SwigPtrType *t1 = SWIG_RegisterType(newtype, NULL);
struct SwigCast *c;
/* Check for existing cast */
for (c = t->cast; c && c->type!=t1; c=c->next) /* nothing */;
if (c) {
if (cast) c->cast = cast;
}
else {
c = (struct SwigCast *) malloc(sizeof(struct SwigCast));
c->type = t1;
c->cast = cast;
c->next = t->cast;
t->cast = c;
}
}
}
/* Sort table */
static void
SWIG_SortTable (void)
{
qsort ((void *) SwigPtrTbl, SwigPtrN, sizeof(struct SwigPtrTbl *), swigsort);
/* Indicate that everything is sorted */
SwigPtrSort = 1;
}
/* Look up pointer-type entry in table */
static int
swigcmp (const void *key, const void *data)
{
char *k = (char *) key;
SwigPtrType *t = *(SwigPtrType **) data;
return strcmp(k, t->name);
}
static SwigPtrType *
SWIG_GetPtrType (const char *_t)
{
SwigPtrType **result;
if (!SwigPtrSort) SWIG_SortTable();
result = (SwigPtrType **) bsearch(_t, SwigPtrTbl, SwigPtrN,
sizeof(SwigPtrType *), swigcmp);
if (result!=NULL) return *result;
else return NULL;
}
/* Cast a pointer if possible; returns 1 if successful */
static int
SWIG_Cast (void *source, SwigPtrType *source_type,
void **ptr, SwigPtrType *dest_type)
{
if (dest_type != source_type) {
/* We have a type mismatch. Will have to look through our type
mapping table to figure out whether or not we can accept this
datatype. */
struct SwigCast *c;
for (c = dest_type->cast;
c && c->type!=source_type; c = c->next) /* nothing */;
if (c) {
/* Get pointer value. */
if (c->cast) *ptr = (*(c->cast))(source);
else *ptr = source;
return -1;
}
/* Didn't find any sort of match for this data.
Get the pointer value and return false. */
*ptr = source;
return 0;
} else {
/* Found a match on the first try. Return pointer value. */
*ptr = source;
return -1;
}
}
/* Function for getting a pointer value */
static Scheme_Type swig_type;
int swig_initialized_p = 0;
SWIGSTATIC Scheme_Object *
SWIG_MakePtr(void *c_pointer, swig_type_info *type) {
struct swig_proxy *new_proxy;
new_proxy = (struct swig_proxy *) scheme_malloc(sizeof(struct swig_proxy));
new_proxy->type = swig_type;
new_proxy->ptrtype = type->ptrtype;
new_proxy->object = (void *) c_pointer;
return (Scheme_Object *) new_proxy;
}
/* Return 0 if successful. */
SWIGSTATIC int
SWIG_GetPtr(Scheme_Object *s, void **result, swig_type_info *type)
{
if (SCHEME_NULLP(s)) {
*result = NULL;
return 0;
}
else if (SCHEME_TYPE(s) == swig_type) {
struct swig_proxy *proxy = (struct swig_proxy *) s;
if (type) {
return !SWIG_Cast(proxy->object, proxy->ptrtype,
result, type->ptrtype);
}
else {
*result = proxy->object;
return 0;
}
}
return -1;
}
SWIGSTATIC void *
SWIG_MustGetPtr_ (Scheme_Object *s, swig_type_info *type,
int argnum, const char *func_name,
int argc, Scheme_Object **argv)
{
void *result;
if (SWIG_GetPtr(s, &result, type) != 0) {
/* type mismatch */
scheme_wrong_type(func_name, type->str ? type->str : "void *", argnum,
argc, argv);
}
return result;
}
SWIGSTATIC
void SWIG_RegisterTypes(swig_type_info **table,
swig_type_info **init)
{
if (!swig_initialized_p) {
swig_type = scheme_make_type((char *) "swig");
swig_initialized_p = 1;
}
for (; *init; table++, init++) {
swig_type_info *type = *table = *init;
const char *origname = type->name;
/* Register datatype itself and store pointer back */
type->ptrtype = SWIG_RegisterType(origname, type->str);
/* Register compatible types */
for (type++; type->name; type++)
SWIG_RegisterMapping(origname, type->name, type->converter);
}
}
/* Dynamic pointer casting. Down an inheritance hierarchy */
SWIGSTATIC swig_type_info *
SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr)
{
swig_type_info *lastty = ty;
if (!ty || !ty->dcast) return ty;
while (ty && (ty->dcast)) {
ty = (*ty->dcast)(ptr);
if (ty) lastty = ty;
}
return lastty;
}
static Scheme_Object *
swig_package_values(int num, Scheme_Object **values)
{
/* ignore first value if void */
if (num > 0 && SCHEME_VOIDP(values[0]))
num--, values++;
if (num == 0) return scheme_void;
else if (num == 1) return values[0];
else return scheme_values(num, values);
}
static void *
swig_malloc(size_t size, const char *func_name)
{
void *p = malloc(size);
if (p == NULL) {
scheme_signal_error("swig-memory-error");
}
else return p;
}
#ifdef __cplusplus
}
#endif
/* -------- TYPES TABLE (BEGIN) -------- */
#define SWIGTYPE_p_integer swig_types[0]
static swig_type_info *swig_types[2];
/* -------- TYPES TABLE (END) -------- */
#include <math.h>
#include <g2c.h>
int test_(integer *pi,integer *pj)
{
fprintf(stderr,"test_:%d,%d\n",*pi,*pj);
*pi -= 2;
*pj -= 2;
return 0;
}
static Scheme_Object *_wrap_test_ (int argc, Scheme_Object **argv)
{
#define FUNC_NAME "test-"
integer *arg1 = (integer *) 0 ;
integer *arg2 = (integer *) 0 ;
int result;
int i1 ;
int i2 ;
int _len;
int lenv = 1;
Scheme_Object *values[MAXVALUES];
{
if (SCHEME_INTP(argv[0]))
{
i1 = SCHEME_INT_VAL(argv[0]);
arg1 = (integer *) &i1;
}
else if (SCHEME_BOXP(argv[0]) && SCHEME_INTP(SCHEME_BOX_VAL(argv[0])))
{
i1 = SCHEME_INT_VAL(SCHEME_BOX_VAL(argv[0]));
arg1 = (integer *) &i1;
}
else
scheme_wrong_type("?","integer *",-1,0,&argv[0]);
}
{
if (SCHEME_INTP(argv[1]))
{
i2 = SCHEME_INT_VAL(argv[1]);
arg2 = (integer *) &i2;
}
else if (SCHEME_BOXP(argv[1]) && SCHEME_INTP(SCHEME_BOX_VAL(argv[1])))
{
i2 = SCHEME_INT_VAL(SCHEME_BOX_VAL(argv[1]));
arg2 = (integer *) &i2;
}
else
scheme_wrong_type("?","integer *",-1,0,&argv[1]);
}
result = (int)test_(arg1,arg2);
{
values[0] = scheme_make_integer_value(result);
}
{
//!!! BUG _ should be argv[0] in this block below
if (SCHEME_BOXP(argv[1]))
{
SCHEME_BOX_VAL(argv[1]) = scheme_make_integer(*arg1);
}
}
{
if (SCHEME_BOXP(argv[1]))
{
SCHEME_BOX_VAL(argv[1]) = scheme_make_integer(*arg2);
}
}
return swig_package_values(lenv, values);
#undef FUNC_NAME
}
/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
static swig_type_info _swigt__p_integer[] = {{"_p_integer", 0, "integer *",
0},{"_p_integer"},{0}};
static swig_type_info *swig_types_initial[] = {
_swigt__p_integer,
0
};
/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */
Scheme_Object *scheme_reload(Scheme_Env *env) {
Scheme_Env *menv = env;
menv = scheme_primitive_module(scheme_intern_symbol("swig_test"), env);
SWIG_RegisterTypes(swig_types, swig_types_initial);
scheme_add_global("test-",
scheme_make_prim_w_arity(_wrap_test_,"test-",2,2),menv);
scheme_finish_primitive_module(menv);
return scheme_void;
}
Scheme_Object *scheme_initialize(Scheme_Env *env) {
return scheme_reload(env);
}
Scheme_Object *scheme_module_name(void) {
return scheme_intern_symbol((char*)"swig_test");
}
--- swig output end
-- System Information:
Debian Release: testing/unstable
Architecture: i386
Kernel: Linux armadillo 2.6.0-test11 #1 Thu Jan 1 15:10:42 GMT 2004 i686
Locale: LANG=C, LC_CTYPE=C
Versions of packages swig1.3 depends on:
ii libc6 2.3.2.ds1-10 GNU C Library: Shared libraries an
ii libgcc1 1:3.3.3-0pre1 GCC support library
ii libstdc++5 1:3.3.3-0pre1 The GNU Standard C++ Library v3
ii libswig1.3 1.3.19-1.1 Runtime support libraries for swig
-- no debconf information
--- End Message ---