1
/* typemaps.i --- guile-specific typemaps -*- c -*-
2
Copyright (C) 2000 Matthias Koeppe <mkoeppe@mail.math.uni-magdeburg.de>
4
$Header: /cvs/projects/SWIG/Lib/guile/typemaps.i,v 1.17.2.6.2.8 2002/01/28 03:39:30 beazley Exp $ */
6
/* (11/24/2001) Note to Matthias:
8
I've replaced all of the documentation related typemaps (indoc, varindoc, outdoc, argoutdoc, ...)
9
with a typemap parameter of "doc". For example:
11
%typemap(in, doc="<integer>") int {
15
This is somewhat more sane to handle when multi-argument typemaps are used. For example:
17
%typemap(in, doc="<buffer>") (char *data, int len) {
21
See guile.cxx for details of how the typemap parameters actually get accessed.
23
Also, it's no longer necessary to specify typemaps for 'const' qualifiers. They
24
now get matched against non-const versions.
26
Feel free to delete this comment after you've read it.
33
%typemap(in) SWIGTYPE * {
34
if (SWIG_Guile_GetPtr($input, (void **) &$1, $descriptor))
35
scm_wrong_type_arg(FUNC_NAME, $argnum, $input);
39
if (SWIG_Guile_GetPtr($input, (void **) &$1, NULL))
40
scm_wrong_type_arg(FUNC_NAME, $argnum, $input);
43
%typemap(varin) SWIGTYPE * {
44
if (SWIG_Guile_GetPtr($input, (void **) &$1, $descriptor))
45
scm_wrong_type_arg(FUNC_NAME, 1, $input);
48
%typemap(varin) void * {
49
if (SWIG_Guile_GetPtr($input, (void **) &$1, NULL))
50
scm_wrong_type_arg(FUNC_NAME, 1, $input);
53
%typemap(out) SWIGTYPE * {
54
$result = SWIG_Guile_MakePtr ($1, $descriptor);
57
%typemap(varout) SWIGTYPE * {
58
$result = SWIG_Guile_MakePtr ($1, $descriptor);
63
%typemap(in) SWIGTYPE($&1_ltype argp) {
64
if (SWIG_Guile_GetPtr($input, (void **) &argp, $1_descriptor))
65
scm_wrong_type_arg(FUNC_NAME,$argnum,$input);
69
%typemap(varin) SWIGTYPE {
71
if (SWIG_Guile_GetPtr($input, (void **) &argp, $1_descriptor))
72
scm_wrong_type_arg(FUNC_NAME,1,$input);
76
%typemap(out) SWIGTYPE
80
resultptr = new $1_ltype($1);
81
$result = SWIG_Guile_MakePtr (resultptr, $&1_descriptor);
86
resultptr = ($&1_ltype) malloc(sizeof($1_type));
87
memmove(resultptr, &$1, sizeof($1_type));
88
$result = SWIG_Guile_MakePtr(resultptr, $&1_descriptor);
92
%typemap(varout) SWIGTYPE
96
resultptr = new $1_ltype($1);
97
$result = SWIG_Guile_MakePtr (resultptr, $&1_descriptor);
102
resultptr = ($&1_ltype) malloc(sizeof($1_type));
103
memmove(resultptr, &$1, sizeof($1_type));
104
$result = SWIG_Guile_MakePtr(resultptr, $&1_descriptor);
112
%typemap(in) SWIGTYPE & {
113
if (SWIG_Guile_GetPtr($input, (void **) &$1, $descriptor)!=0)
114
scm_wrong_type_arg(FUNC_NAME, $argnum, $input);
117
%typemap(out) SWIGTYPE & {
118
$result = SWIG_Guile_MakePtr ($1, $descriptor);
125
%typemap(in) SWIGTYPE[] {
126
if (SWIG_Guile_GetPtr($input, (void **) &$1, $descriptor)!=0)
127
scm_wrong_type_arg(FUNC_NAME, $argnum, $input);
130
%typemap(out) SWIGTYPE[] {
131
$result = SWIG_Guile_MakePtr ($1, $descriptor);
136
%typemap(in) enum SWIGTYPE "$1 = gh_scm2int($input);";
137
%typemap(varin) enum SWIGTYPE "$1 = gh_scm2int($input);";
138
%typemap(out) enum SWIGTYPE "$result = gh_int2scm($1);";
139
%typemap(varout) enum SWIGTYPE "$result = gh_int2scm($1);";
141
/* The SIMPLE_MAP macro below defines the whole set of typemaps needed
144
%define SIMPLE_MAP(C_NAME, SCM_TO_C, C_TO_SCM, SCM_NAME)
145
%typemap (in, doc="($name <" #SCM_NAME ">)") C_NAME {$1 = SCM_TO_C($input);}
146
%typemap (varin, doc="(new-value <" #SCM_NAME ">)") C_NAME {$1 = SCM_TO_C($input);}
147
%typemap (out, doc="<" #SCM_NAME ">") C_NAME {$result = C_TO_SCM($1);}
148
%typemap (varout, doc="<" #SCM_NAME ">") C_NAME {$result = C_TO_SCM($1);}
149
%typemap (in, doc="($name <" #SCM_NAME ">)") C_NAME *INPUT(C_NAME temp) {
150
temp = (C_NAME) SCM_TO_C($input); $1 = &temp;
152
%typemap (ignore) C_NAME *OUTPUT (C_NAME temp)
154
%typemap (argout,doc="($name <" #SCM_NAME ">)") C_NAME *OUTPUT
155
{SWIG_APPEND_VALUE(C_TO_SCM(*$1));}
157
%typemap (in) C_NAME *BOTH = C_NAME *INPUT;
158
%typemap (argout) C_NAME *BOTH = C_NAME *OUTPUT;
159
%typemap (in) C_NAME *INOUT = C_NAME *INPUT;
160
%typemap (argout) C_NAME *INOUT = C_NAME *OUTPUT;
163
SIMPLE_MAP(bool, gh_scm2bool, gh_bool2scm, boolean);
164
SIMPLE_MAP(char, gh_scm2char, gh_char2scm, char);
165
SIMPLE_MAP(unsigned char, gh_scm2char, gh_char2scm, char);
166
SIMPLE_MAP(int, gh_scm2int, gh_int2scm, integer);
167
SIMPLE_MAP(short, gh_scm2int, gh_int2scm, integer);
168
SIMPLE_MAP(long, gh_scm2long, gh_long2scm, integer);
169
SIMPLE_MAP(ptrdiff_t, gh_scm2long, gh_long2scm, integer);
170
SIMPLE_MAP(unsigned int, gh_scm2ulong, gh_ulong2scm, integer);
171
SIMPLE_MAP(unsigned short, gh_scm2ulong, gh_ulong2scm, integer);
172
SIMPLE_MAP(unsigned long, gh_scm2ulong, gh_ulong2scm, integer);
173
SIMPLE_MAP(size_t, gh_scm2ulong, gh_ulong2scm, integer);
174
SIMPLE_MAP(float, gh_scm2double, gh_double2scm, real);
175
SIMPLE_MAP(double, gh_scm2double, gh_double2scm, real);
176
SIMPLE_MAP(char *, SWIG_scm2str, gh_str02scm, string);
177
SIMPLE_MAP(const char *, SWIG_scm2str, gh_str02scm, string);
179
/* GSWIG_scm2str makes a malloc'ed copy of the string, so get rid of it after
180
the function call. */
182
%typemap (freearg) char * "if ($1) scm_must_free($1);";
183
%typemap (freearg) char **OUTPUT, char **BOTH "if (*$1) scm_must_free(*$1);"
185
/* But this shall not apply if we try to pass a single char by
188
%typemap (freearg) char *OUTPUT, char *BOTH "";
190
/* If we set a string variable, delete the old result first. */
192
%typemap (varin) char * {
194
$1 = SWIG_scm2str($input);
199
%typemap (out,doc="") void "gswig_result = GH_UNSPECIFIED;";
201
/* SCM is passed through */
203
typedef unsigned long SCM;
204
%typemap (in) SCM "$1=$input;";
205
%typemap (out) SCM "$result=$1;";
207
/* Some ANSI C typemaps */
209
%apply long { size_t };
211
/* typemaps.i ends here */