1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
|
/* typemaps.i --- guile-specific typemaps -*- c -*-
Copyright (C) 2000 Matthias Koeppe <mkoeppe@mail.math.uni-magdeburg.de>
$Header: /cvs/projects/SWIG/Lib/guile/typemaps.i,v 1.17.2.6.2.8 2002/01/28 03:39:30 beazley Exp $ */
/* (11/24/2001) Note to Matthias:
I've replaced all of the documentation related typemaps (indoc, varindoc, outdoc, argoutdoc, ...)
with a typemap parameter of "doc". For example:
%typemap(in, doc="<integer>") int {
...
}
This is somewhat more sane to handle when multi-argument typemaps are used. For example:
%typemap(in, doc="<buffer>") (char *data, int len) {
...
}
See guile.cxx for details of how the typemap parameters actually get accessed.
Also, it's no longer necessary to specify typemaps for 'const' qualifiers. They
now get matched against non-const versions.
Feel free to delete this comment after you've read it.
--- Dave
*/
/* Pointers */
%typemap(in) SWIGTYPE * {
if (SWIG_Guile_GetPtr($input, (void **) &$1, $descriptor))
scm_wrong_type_arg(FUNC_NAME, $argnum, $input);
}
%typemap(in) void * {
if (SWIG_Guile_GetPtr($input, (void **) &$1, NULL))
scm_wrong_type_arg(FUNC_NAME, $argnum, $input);
}
%typemap(varin) SWIGTYPE * {
if (SWIG_Guile_GetPtr($input, (void **) &$1, $descriptor))
scm_wrong_type_arg(FUNC_NAME, 1, $input);
}
%typemap(varin) void * {
if (SWIG_Guile_GetPtr($input, (void **) &$1, NULL))
scm_wrong_type_arg(FUNC_NAME, 1, $input);
}
%typemap(out) SWIGTYPE * {
$result = SWIG_Guile_MakePtr ($1, $descriptor);
}
%typemap(varout) SWIGTYPE * {
$result = SWIG_Guile_MakePtr ($1, $descriptor);
}
/* 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);
$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);
$1 = *argp;
}
%typemap(out) SWIGTYPE
#ifdef __cplusplus
{
$&1_ltype resultptr;
resultptr = new $1_ltype($1);
$result = SWIG_Guile_MakePtr (resultptr, $&1_descriptor);
}
#else
{
$&1_ltype resultptr;
resultptr = ($&1_ltype) malloc(sizeof($1_type));
memmove(resultptr, &$1, sizeof($1_type));
$result = SWIG_Guile_MakePtr(resultptr, $&1_descriptor);
}
#endif
%typemap(varout) SWIGTYPE
#ifdef __cplusplus
{
$&1_ltype resultptr;
resultptr = new $1_ltype($1);
$result = SWIG_Guile_MakePtr (resultptr, $&1_descriptor);
}
#else
{
$&1_ltype resultptr;
resultptr = ($&1_ltype) malloc(sizeof($1_type));
memmove(resultptr, &$1, sizeof($1_type));
$result = SWIG_Guile_MakePtr(resultptr, $&1_descriptor);
}
#endif
/* C++ References */
#ifdef __cplusplus
%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);
}
#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 = gh_scm2int($input);";
%typemap(out) enum SWIGTYPE "$result = gh_int2scm($1);";
%typemap(varout) enum SWIGTYPE "$result = gh_int2scm($1);";
/* The SIMPLE_MAP macro below defines the whole set of typemaps needed
for simple types. */
%define SIMPLE_MAP(C_NAME, SCM_TO_C, C_TO_SCM, SCM_NAME)
%typemap (in, doc="($name <" #SCM_NAME ">)") C_NAME {$1 = SCM_TO_C($input);}
%typemap (varin, doc="(new-value <" #SCM_NAME ">)") C_NAME {$1 = SCM_TO_C($input);}
%typemap (out, doc="<" #SCM_NAME ">") C_NAME {$result = C_TO_SCM($1);}
%typemap (varout, doc="<" #SCM_NAME ">") C_NAME {$result = C_TO_SCM($1);}
%typemap (in, doc="($name <" #SCM_NAME ">)") C_NAME *INPUT(C_NAME temp) {
temp = (C_NAME) SCM_TO_C($input); $1 = &temp;
}
%typemap (ignore) C_NAME *OUTPUT (C_NAME temp)
{$1 = &temp;}
%typemap (argout,doc="($name <" #SCM_NAME ">)") 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;
%enddef
SIMPLE_MAP(bool, gh_scm2bool, gh_bool2scm, boolean);
SIMPLE_MAP(char, gh_scm2char, gh_char2scm, char);
SIMPLE_MAP(unsigned char, gh_scm2char, gh_char2scm, char);
SIMPLE_MAP(int, gh_scm2int, gh_int2scm, integer);
SIMPLE_MAP(short, gh_scm2int, gh_int2scm, integer);
SIMPLE_MAP(long, gh_scm2long, gh_long2scm, integer);
SIMPLE_MAP(ptrdiff_t, gh_scm2long, gh_long2scm, integer);
SIMPLE_MAP(unsigned int, gh_scm2ulong, gh_ulong2scm, integer);
SIMPLE_MAP(unsigned short, gh_scm2ulong, gh_ulong2scm, integer);
SIMPLE_MAP(unsigned long, gh_scm2ulong, gh_ulong2scm, integer);
SIMPLE_MAP(size_t, gh_scm2ulong, gh_ulong2scm, integer);
SIMPLE_MAP(float, gh_scm2double, gh_double2scm, real);
SIMPLE_MAP(double, gh_scm2double, gh_double2scm, real);
SIMPLE_MAP(char *, SWIG_scm2str, gh_str02scm, string);
SIMPLE_MAP(const char *, SWIG_scm2str, gh_str02scm, string);
/* GSWIG_scm2str makes a malloc'ed copy of the string, so get rid of it after
the function call. */
%typemap (freearg) char * "if ($1) scm_must_free($1);";
%typemap (freearg) char **OUTPUT, char **BOTH "if (*$1) scm_must_free(*$1);"
/* But this shall not apply if we try to pass a single char by
reference. */
%typemap (freearg) char *OUTPUT, char *BOTH "";
/* If we set a string variable, delete the old result first. */
%typemap (varin) char * {
if ($1) free($1);
$1 = SWIG_scm2str($input);
}
/* Void */
%typemap (out,doc="") void "gswig_result = GH_UNSPECIFIED;";
/* SCM is passed through */
typedef unsigned long SCM;
%typemap (in) SCM "$1=$input;";
%typemap (out) SCM "$result=$1;";
/* Some ANSI C typemaps */
%apply long { size_t };
/* typemaps.i ends here */
|