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

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 */