latest update
[hildon] / hildon-widgets / hildon-marshalers.c
1 /*
2  * This file is part of hildon-libs
3  *
4  * Copyright (C) 2005 Nokia Corporation.
5  *
6  * Contact: Luc Pionchon <luc.pionchon@nokia.com>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation; either version 2.1 of
11  * the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  *
23  */
24
25 #include "hildon-marshalers.h"
26
27 #include        <glib-object.h>
28
29
30 #ifdef G_ENABLE_DEBUG
31 #define g_marshal_value_peek_boolean(v)  g_value_get_boolean (v)
32 #define g_marshal_value_peek_char(v)     g_value_get_char (v)
33 #define g_marshal_value_peek_uchar(v)    g_value_get_uchar (v)
34 #define g_marshal_value_peek_int(v)      g_value_get_int (v)
35 #define g_marshal_value_peek_uint(v)     g_value_get_uint (v)
36 #define g_marshal_value_peek_long(v)     g_value_get_long (v)
37 #define g_marshal_value_peek_ulong(v)    g_value_get_ulong (v)
38 #define g_marshal_value_peek_int64(v)    g_value_get_int64 (v)
39 #define g_marshal_value_peek_uint64(v)   g_value_get_uint64 (v)
40 #define g_marshal_value_peek_enum(v)     g_value_get_enum (v)
41 #define g_marshal_value_peek_flags(v)    g_value_get_flags (v)
42 #define g_marshal_value_peek_float(v)    g_value_get_float (v)
43 #define g_marshal_value_peek_double(v)   g_value_get_double (v)
44 #define g_marshal_value_peek_string(v)   (char*) g_value_get_string (v)
45 #define g_marshal_value_peek_param(v)    g_value_get_param (v)
46 #define g_marshal_value_peek_boxed(v)    g_value_get_boxed (v)
47 #define g_marshal_value_peek_pointer(v)  g_value_get_pointer (v)
48 #define g_marshal_value_peek_object(v)   g_value_get_object (v)
49 #else /* !G_ENABLE_DEBUG */
50 /* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
51  *          Do not access GValues directly in your code. Instead, use the
52  *          g_value_get_*() functions
53  */
54 #define g_marshal_value_peek_boolean(v)  (v)->data[0].v_int
55 #define g_marshal_value_peek_char(v)     (v)->data[0].v_int
56 #define g_marshal_value_peek_uchar(v)    (v)->data[0].v_uint
57 #define g_marshal_value_peek_int(v)      (v)->data[0].v_int
58 #define g_marshal_value_peek_uint(v)     (v)->data[0].v_uint
59 #define g_marshal_value_peek_long(v)     (v)->data[0].v_long
60 #define g_marshal_value_peek_ulong(v)    (v)->data[0].v_ulong
61 #define g_marshal_value_peek_int64(v)    (v)->data[0].v_int64
62 #define g_marshal_value_peek_uint64(v)   (v)->data[0].v_uint64
63 #define g_marshal_value_peek_enum(v)     (v)->data[0].v_long
64 #define g_marshal_value_peek_flags(v)    (v)->data[0].v_ulong
65 #define g_marshal_value_peek_float(v)    (v)->data[0].v_float
66 #define g_marshal_value_peek_double(v)   (v)->data[0].v_double
67 #define g_marshal_value_peek_string(v)   (v)->data[0].v_pointer
68 #define g_marshal_value_peek_param(v)    (v)->data[0].v_pointer
69 #define g_marshal_value_peek_boxed(v)    (v)->data[0].v_pointer
70 #define g_marshal_value_peek_pointer(v)  (v)->data[0].v_pointer
71 #define g_marshal_value_peek_object(v)   (v)->data[0].v_pointer
72 #endif /* !G_ENABLE_DEBUG */
73
74
75 /* BOOLEAN:INT (hildon-marshalers.list:26) */
76 void
77 _hildon_marshal_BOOLEAN__INT (GClosure     *closure,
78                               GValue       *return_value,
79                               guint         n_param_values,
80                               const GValue *param_values,
81                               gpointer      invocation_hint,
82                               gpointer      marshal_data)
83 {
84   typedef gboolean (*GMarshalFunc_BOOLEAN__INT) (gpointer     data1,
85                                                  gint         arg_1,
86                                                  gpointer     data2);
87   register GMarshalFunc_BOOLEAN__INT callback;
88   register GCClosure *cc = (GCClosure*) closure;
89   register gpointer data1, data2;
90   gboolean v_return;
91
92   g_return_if_fail (return_value != NULL);
93   g_return_if_fail (n_param_values == 2);
94
95   if (G_CCLOSURE_SWAP_DATA (closure))
96     {
97       data1 = closure->data;
98       data2 = g_value_peek_pointer (param_values + 0);
99     }
100   else
101     {
102       data1 = g_value_peek_pointer (param_values + 0);
103       data2 = closure->data;
104     }
105   callback = (GMarshalFunc_BOOLEAN__INT) (marshal_data ? marshal_data : cc->callback);
106
107   v_return = callback (data1,
108                        g_marshal_value_peek_int (param_values + 1),
109                        data2);
110
111   g_value_set_boolean (return_value, v_return);
112 }
113
114 /* BOOLEAN:INT,INT,INT (hildon-marshalers.list:27) */
115 void
116 _hildon_marshal_BOOLEAN__INT_INT_INT (GClosure     *closure,
117                                       GValue       *return_value,
118                                       guint         n_param_values,
119                                       const GValue *param_values,
120                                       gpointer      invocation_hint,
121                                       gpointer      marshal_data)
122 {
123   typedef gboolean (*GMarshalFunc_BOOLEAN__INT_INT_INT) (gpointer     data1,
124                                                          gint         arg_1,
125                                                          gint         arg_2,
126                                                          gint         arg_3,
127                                                          gpointer     data2);
128   register GMarshalFunc_BOOLEAN__INT_INT_INT callback;
129   register GCClosure *cc = (GCClosure*) closure;
130   register gpointer data1, data2;
131   gboolean v_return;
132
133   g_return_if_fail (return_value != NULL);
134   g_return_if_fail (n_param_values == 4);
135
136   if (G_CCLOSURE_SWAP_DATA (closure))
137     {
138       data1 = closure->data;
139       data2 = g_value_peek_pointer (param_values + 0);
140     }
141   else
142     {
143       data1 = g_value_peek_pointer (param_values + 0);
144       data2 = closure->data;
145     }
146   callback = (GMarshalFunc_BOOLEAN__INT_INT_INT) (marshal_data ? marshal_data : cc->callback);
147
148   v_return = callback (data1,
149                        g_marshal_value_peek_int (param_values + 1),
150                        g_marshal_value_peek_int (param_values + 2),
151                        g_marshal_value_peek_int (param_values + 3),
152                        data2);
153
154   g_value_set_boolean (return_value, v_return);
155 }
156