os/ossrv/glib/tests/gobject/testmarshal.c
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/glib/tests/gobject/testmarshal.c	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,127 @@
     1.4 +
     1.5 +#include	<glib-object.h>
     1.6 +
     1.7 +
     1.8 +#ifdef G_ENABLE_DEBUG
     1.9 +#define g_marshal_value_peek_boolean(v)  g_value_get_boolean (v)
    1.10 +#define g_marshal_value_peek_char(v)     g_value_get_char (v)
    1.11 +#define g_marshal_value_peek_uchar(v)    g_value_get_uchar (v)
    1.12 +#define g_marshal_value_peek_int(v)      g_value_get_int (v)
    1.13 +#define g_marshal_value_peek_uint(v)     g_value_get_uint (v)
    1.14 +#define g_marshal_value_peek_long(v)     g_value_get_long (v)
    1.15 +#define g_marshal_value_peek_ulong(v)    g_value_get_ulong (v)
    1.16 +#define g_marshal_value_peek_int64(v)    g_value_get_int64 (v)
    1.17 +#define g_marshal_value_peek_uint64(v)   g_value_get_uint64 (v)
    1.18 +#define g_marshal_value_peek_enum(v)     g_value_get_enum (v)
    1.19 +#define g_marshal_value_peek_flags(v)    g_value_get_flags (v)
    1.20 +#define g_marshal_value_peek_float(v)    g_value_get_float (v)
    1.21 +#define g_marshal_value_peek_double(v)   g_value_get_double (v)
    1.22 +#define g_marshal_value_peek_string(v)   (char*) g_value_get_string (v)
    1.23 +#define g_marshal_value_peek_param(v)    g_value_get_param (v)
    1.24 +#define g_marshal_value_peek_boxed(v)    g_value_get_boxed (v)
    1.25 +#define g_marshal_value_peek_pointer(v)  g_value_get_pointer (v)
    1.26 +#define g_marshal_value_peek_object(v)   g_value_get_object (v)
    1.27 +#else /* !G_ENABLE_DEBUG */
    1.28 +/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
    1.29 + *          Do not access GValues directly in your code. Instead, use the
    1.30 + *          g_value_get_*() functions
    1.31 + */
    1.32 +#define g_marshal_value_peek_boolean(v)  (v)->data[0].v_int
    1.33 +#define g_marshal_value_peek_char(v)     (v)->data[0].v_int
    1.34 +#define g_marshal_value_peek_uchar(v)    (v)->data[0].v_uint
    1.35 +#define g_marshal_value_peek_int(v)      (v)->data[0].v_int
    1.36 +#define g_marshal_value_peek_uint(v)     (v)->data[0].v_uint
    1.37 +#define g_marshal_value_peek_long(v)     (v)->data[0].v_long
    1.38 +#define g_marshal_value_peek_ulong(v)    (v)->data[0].v_ulong
    1.39 +#define g_marshal_value_peek_int64(v)    (v)->data[0].v_int64
    1.40 +#define g_marshal_value_peek_uint64(v)   (v)->data[0].v_uint64
    1.41 +#define g_marshal_value_peek_enum(v)     (v)->data[0].v_long
    1.42 +#define g_marshal_value_peek_flags(v)    (v)->data[0].v_ulong
    1.43 +#define g_marshal_value_peek_float(v)    (v)->data[0].v_float
    1.44 +#define g_marshal_value_peek_double(v)   (v)->data[0].v_double
    1.45 +#define g_marshal_value_peek_string(v)   (v)->data[0].v_pointer
    1.46 +#define g_marshal_value_peek_param(v)    (v)->data[0].v_pointer
    1.47 +#define g_marshal_value_peek_boxed(v)    (v)->data[0].v_pointer
    1.48 +#define g_marshal_value_peek_pointer(v)  (v)->data[0].v_pointer
    1.49 +#define g_marshal_value_peek_object(v)   (v)->data[0].v_pointer
    1.50 +#endif /* !G_ENABLE_DEBUG */
    1.51 +
    1.52 +
    1.53 +/* BOOLEAN:INT (./testmarshal.list:2) */
    1.54 +void
    1.55 +test_marshal_BOOLEAN__INT (GClosure     *closure,
    1.56 +                           GValue       *return_value G_GNUC_UNUSED,
    1.57 +                           guint         n_param_values,
    1.58 +                           const GValue *param_values,
    1.59 +                           gpointer      invocation_hint G_GNUC_UNUSED,
    1.60 +                           gpointer      marshal_data)
    1.61 +{
    1.62 +  typedef gboolean (*GMarshalFunc_BOOLEAN__INT) (gpointer     data1,
    1.63 +                                                 gint         arg_1,
    1.64 +                                                 gpointer     data2);
    1.65 +  register GMarshalFunc_BOOLEAN__INT callback;
    1.66 +  register GCClosure *cc = (GCClosure*) closure;
    1.67 +  register gpointer data1, data2;
    1.68 +  gboolean v_return;
    1.69 +
    1.70 +  g_return_if_fail (return_value != NULL);
    1.71 +  g_return_if_fail (n_param_values == 2);
    1.72 +
    1.73 +  if (G_CCLOSURE_SWAP_DATA (closure))
    1.74 +    {
    1.75 +      data1 = closure->data;
    1.76 +      data2 = g_value_peek_pointer (param_values + 0);
    1.77 +    }
    1.78 +  else
    1.79 +    {
    1.80 +      data1 = g_value_peek_pointer (param_values + 0);
    1.81 +      data2 = closure->data;
    1.82 +    }
    1.83 +  callback = (GMarshalFunc_BOOLEAN__INT) (marshal_data ? marshal_data : cc->callback);
    1.84 +
    1.85 +  v_return = callback (data1,
    1.86 +                       g_marshal_value_peek_int (param_values + 1),
    1.87 +                       data2);
    1.88 +
    1.89 +  g_value_set_boolean (return_value, v_return);
    1.90 +}
    1.91 +
    1.92 +/* STRING:INT (./testmarshal.list:3) */
    1.93 +void
    1.94 +test_marshal_STRING__INT (GClosure     *closure,
    1.95 +                          GValue       *return_value G_GNUC_UNUSED,
    1.96 +                          guint         n_param_values,
    1.97 +                          const GValue *param_values,
    1.98 +                          gpointer      invocation_hint G_GNUC_UNUSED,
    1.99 +                          gpointer      marshal_data)
   1.100 +{
   1.101 +  typedef gchar* (*GMarshalFunc_STRING__INT) (gpointer     data1,
   1.102 +                                              gint         arg_1,
   1.103 +                                              gpointer     data2);
   1.104 +  register GMarshalFunc_STRING__INT callback;
   1.105 +  register GCClosure *cc = (GCClosure*) closure;
   1.106 +  register gpointer data1, data2;
   1.107 +  gchar* v_return;
   1.108 +
   1.109 +  g_return_if_fail (return_value != NULL);
   1.110 +  g_return_if_fail (n_param_values == 2);
   1.111 +
   1.112 +  if (G_CCLOSURE_SWAP_DATA (closure))
   1.113 +    {
   1.114 +      data1 = closure->data;
   1.115 +      data2 = g_value_peek_pointer (param_values + 0);
   1.116 +    }
   1.117 +  else
   1.118 +    {
   1.119 +      data1 = g_value_peek_pointer (param_values + 0);
   1.120 +      data2 = closure->data;
   1.121 +    }
   1.122 +  callback = (GMarshalFunc_STRING__INT) (marshal_data ? marshal_data : cc->callback);
   1.123 +
   1.124 +  v_return = callback (data1,
   1.125 +                       g_marshal_value_peek_int (param_values + 1),
   1.126 +                       data2);
   1.127 +
   1.128 +  g_value_take_string (return_value, v_return);
   1.129 +}
   1.130 +