Upstream version 1.3.40
[profile/ivi/swig.git] / Lib / guile / guile_gh.swg
1 /* -----------------------------------------------------------------------------
2  * See the LICENSE file for information on copyright, usage and redistribution
3  * of SWIG, and the README file for authors - http://www.swig.org/release.html.
4  *
5  * guile_gh.swg
6  *
7  * This SWIG interface file is processed if the Guile module is run
8  * with gh_ flavor.
9  * ----------------------------------------------------------------------------- */
10
11 #define SWIGGUILE_GH
12
13 %runtime "swigrun.swg"
14 %runtime "guile_gh_run.swg"
15
16 #define SWIG_convert_short(o)                                   \
17   SWIG_convert_integer(o, - (1 << (8 * sizeof(short) - 1)),     \
18                        (1 << (8 * sizeof(short) - 1)) - 1,      \
19                        FUNC_NAME, $argnum)
20 #define SWIG_convert_unsigned_short(o)                  \
21   SWIG_convert_unsigned_integer(o, 0,                           \
22                        (1 << (8 * sizeof(short))) - 1,  \
23                        FUNC_NAME, $argnum)
24 #define SWIG_convert_unsigned_int(o)            \
25   SWIG_convert_unsigned_integer(o, 0, UINT_MAX, \
26                        FUNC_NAME, $argnum)
27
28 #define gh_scm2short(a) SWIG_convert_short(a)
29 #define gh_scm2ushort(a) SWIG_convert_unsigned_short(a)
30 #define gh_scm2uint(a)   SWIG_convert_unsigned_int(a)
31
32 %include <guile.i>
33
34 %runtime %{
35
36 /* scm_values was implemented on C level in 1.4.1, and the prototype
37    is not included in libguile.h, so play safe and lookup `values'... */
38 #define GUILE_MAYBE_VALUES                                              \
39     if (gswig_list_p)                                                   \
40         gswig_result = gh_apply(gh_lookup("values"), gswig_result);
41     
42 #define GUILE_MAYBE_VECTOR                              \
43     if (gswig_list_p)                                   \
44         gswig_result = gh_list_to_vector(gswig_result);
45
46 #define SWIG_APPEND_VALUE(object)                                               \
47     if (gswig_result == SCM_UNSPECIFIED) {              \
48         gswig_result = object;                                                  \
49     } else {                                                                    \
50         if (!gswig_list_p) {                                                    \
51             gswig_list_p = 1;                                                   \
52             gswig_result = gh_list(gswig_result, object, SCM_UNDEFINED);        \
53         }                                                                       \
54         else                                                                    \
55             gswig_result = gh_append2(gswig_result,                             \
56                                       gh_list(object, SCM_UNDEFINED));          \
57     }
58
59 %}
60
61 %init "swiginit.swg"
62
63 %init %{
64 static int _swig_module_smob_tag;
65
66 SWIG_GUILE_INIT_STATIC void
67 SWIG_init(void)
68 {
69
70   SWIG_InitializeModule(0);
71   swig_module.clientdata = (void *) &_swig_module_smob_tag;
72
73   SWIG_Guile_Init(&swig_module);
74 %}