os/ossrv/glib/tests/gobject/testmarshal.c
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
sl@0
     2
#include	<glib-object.h>
sl@0
     3
sl@0
     4
sl@0
     5
#ifdef G_ENABLE_DEBUG
sl@0
     6
#define g_marshal_value_peek_boolean(v)  g_value_get_boolean (v)
sl@0
     7
#define g_marshal_value_peek_char(v)     g_value_get_char (v)
sl@0
     8
#define g_marshal_value_peek_uchar(v)    g_value_get_uchar (v)
sl@0
     9
#define g_marshal_value_peek_int(v)      g_value_get_int (v)
sl@0
    10
#define g_marshal_value_peek_uint(v)     g_value_get_uint (v)
sl@0
    11
#define g_marshal_value_peek_long(v)     g_value_get_long (v)
sl@0
    12
#define g_marshal_value_peek_ulong(v)    g_value_get_ulong (v)
sl@0
    13
#define g_marshal_value_peek_int64(v)    g_value_get_int64 (v)
sl@0
    14
#define g_marshal_value_peek_uint64(v)   g_value_get_uint64 (v)
sl@0
    15
#define g_marshal_value_peek_enum(v)     g_value_get_enum (v)
sl@0
    16
#define g_marshal_value_peek_flags(v)    g_value_get_flags (v)
sl@0
    17
#define g_marshal_value_peek_float(v)    g_value_get_float (v)
sl@0
    18
#define g_marshal_value_peek_double(v)   g_value_get_double (v)
sl@0
    19
#define g_marshal_value_peek_string(v)   (char*) g_value_get_string (v)
sl@0
    20
#define g_marshal_value_peek_param(v)    g_value_get_param (v)
sl@0
    21
#define g_marshal_value_peek_boxed(v)    g_value_get_boxed (v)
sl@0
    22
#define g_marshal_value_peek_pointer(v)  g_value_get_pointer (v)
sl@0
    23
#define g_marshal_value_peek_object(v)   g_value_get_object (v)
sl@0
    24
#else /* !G_ENABLE_DEBUG */
sl@0
    25
/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
sl@0
    26
 *          Do not access GValues directly in your code. Instead, use the
sl@0
    27
 *          g_value_get_*() functions
sl@0
    28
 */
sl@0
    29
#define g_marshal_value_peek_boolean(v)  (v)->data[0].v_int
sl@0
    30
#define g_marshal_value_peek_char(v)     (v)->data[0].v_int
sl@0
    31
#define g_marshal_value_peek_uchar(v)    (v)->data[0].v_uint
sl@0
    32
#define g_marshal_value_peek_int(v)      (v)->data[0].v_int
sl@0
    33
#define g_marshal_value_peek_uint(v)     (v)->data[0].v_uint
sl@0
    34
#define g_marshal_value_peek_long(v)     (v)->data[0].v_long
sl@0
    35
#define g_marshal_value_peek_ulong(v)    (v)->data[0].v_ulong
sl@0
    36
#define g_marshal_value_peek_int64(v)    (v)->data[0].v_int64
sl@0
    37
#define g_marshal_value_peek_uint64(v)   (v)->data[0].v_uint64
sl@0
    38
#define g_marshal_value_peek_enum(v)     (v)->data[0].v_long
sl@0
    39
#define g_marshal_value_peek_flags(v)    (v)->data[0].v_ulong
sl@0
    40
#define g_marshal_value_peek_float(v)    (v)->data[0].v_float
sl@0
    41
#define g_marshal_value_peek_double(v)   (v)->data[0].v_double
sl@0
    42
#define g_marshal_value_peek_string(v)   (v)->data[0].v_pointer
sl@0
    43
#define g_marshal_value_peek_param(v)    (v)->data[0].v_pointer
sl@0
    44
#define g_marshal_value_peek_boxed(v)    (v)->data[0].v_pointer
sl@0
    45
#define g_marshal_value_peek_pointer(v)  (v)->data[0].v_pointer
sl@0
    46
#define g_marshal_value_peek_object(v)   (v)->data[0].v_pointer
sl@0
    47
#endif /* !G_ENABLE_DEBUG */
sl@0
    48
sl@0
    49
sl@0
    50
/* BOOLEAN:INT (./testmarshal.list:2) */
sl@0
    51
void
sl@0
    52
test_marshal_BOOLEAN__INT (GClosure     *closure,
sl@0
    53
                           GValue       *return_value G_GNUC_UNUSED,
sl@0
    54
                           guint         n_param_values,
sl@0
    55
                           const GValue *param_values,
sl@0
    56
                           gpointer      invocation_hint G_GNUC_UNUSED,
sl@0
    57
                           gpointer      marshal_data)
sl@0
    58
{
sl@0
    59
  typedef gboolean (*GMarshalFunc_BOOLEAN__INT) (gpointer     data1,
sl@0
    60
                                                 gint         arg_1,
sl@0
    61
                                                 gpointer     data2);
sl@0
    62
  register GMarshalFunc_BOOLEAN__INT callback;
sl@0
    63
  register GCClosure *cc = (GCClosure*) closure;
sl@0
    64
  register gpointer data1, data2;
sl@0
    65
  gboolean v_return;
sl@0
    66
sl@0
    67
  g_return_if_fail (return_value != NULL);
sl@0
    68
  g_return_if_fail (n_param_values == 2);
sl@0
    69
sl@0
    70
  if (G_CCLOSURE_SWAP_DATA (closure))
sl@0
    71
    {
sl@0
    72
      data1 = closure->data;
sl@0
    73
      data2 = g_value_peek_pointer (param_values + 0);
sl@0
    74
    }
sl@0
    75
  else
sl@0
    76
    {
sl@0
    77
      data1 = g_value_peek_pointer (param_values + 0);
sl@0
    78
      data2 = closure->data;
sl@0
    79
    }
sl@0
    80
  callback = (GMarshalFunc_BOOLEAN__INT) (marshal_data ? marshal_data : cc->callback);
sl@0
    81
sl@0
    82
  v_return = callback (data1,
sl@0
    83
                       g_marshal_value_peek_int (param_values + 1),
sl@0
    84
                       data2);
sl@0
    85
sl@0
    86
  g_value_set_boolean (return_value, v_return);
sl@0
    87
}
sl@0
    88
sl@0
    89
/* STRING:INT (./testmarshal.list:3) */
sl@0
    90
void
sl@0
    91
test_marshal_STRING__INT (GClosure     *closure,
sl@0
    92
                          GValue       *return_value G_GNUC_UNUSED,
sl@0
    93
                          guint         n_param_values,
sl@0
    94
                          const GValue *param_values,
sl@0
    95
                          gpointer      invocation_hint G_GNUC_UNUSED,
sl@0
    96
                          gpointer      marshal_data)
sl@0
    97
{
sl@0
    98
  typedef gchar* (*GMarshalFunc_STRING__INT) (gpointer     data1,
sl@0
    99
                                              gint         arg_1,
sl@0
   100
                                              gpointer     data2);
sl@0
   101
  register GMarshalFunc_STRING__INT callback;
sl@0
   102
  register GCClosure *cc = (GCClosure*) closure;
sl@0
   103
  register gpointer data1, data2;
sl@0
   104
  gchar* v_return;
sl@0
   105
sl@0
   106
  g_return_if_fail (return_value != NULL);
sl@0
   107
  g_return_if_fail (n_param_values == 2);
sl@0
   108
sl@0
   109
  if (G_CCLOSURE_SWAP_DATA (closure))
sl@0
   110
    {
sl@0
   111
      data1 = closure->data;
sl@0
   112
      data2 = g_value_peek_pointer (param_values + 0);
sl@0
   113
    }
sl@0
   114
  else
sl@0
   115
    {
sl@0
   116
      data1 = g_value_peek_pointer (param_values + 0);
sl@0
   117
      data2 = closure->data;
sl@0
   118
    }
sl@0
   119
  callback = (GMarshalFunc_STRING__INT) (marshal_data ? marshal_data : cc->callback);
sl@0
   120
sl@0
   121
  v_return = callback (data1,
sl@0
   122
                       g_marshal_value_peek_int (param_values + 1),
sl@0
   123
                       data2);
sl@0
   124
sl@0
   125
  g_value_take_string (return_value, v_return);
sl@0
   126
}
sl@0
   127