adapt to work with new CVS gtk-doc, leaving the old rules in place caused
[platform/upstream/glib.git] / gobject / gvaluetypes.c
1 /* GObject - GLib Type, Object, Parameter and Signal Library
2  * Copyright (C) 1997, 1998, 1999, 2000 Tim Janik and Red Hat, Inc.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General
15  * Public License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 /*
21  * MT safe
22  */
23
24 #include        "gvaluetypes.h"
25
26 #include        "gvaluecollector.h"
27 #include        <string.h>
28
29
30 /* --- value functions --- */
31 static void
32 value_long0_init (GValue *value)
33 {
34   value->data[0].v_long = 0;
35 }
36
37 static void
38 value_long0_copy (const GValue *src_value,
39                   GValue       *dest_value)
40 {
41   dest_value->data[0].v_long = src_value->data[0].v_long;
42 }
43
44 static gchar*
45 value_char_lcopy_value (const GValue *value,
46                         guint         nth_value,
47                         GType        *collect_type,
48                         GTypeCValue  *collect_value)
49 {
50   gint8 *int8_p = collect_value->v_pointer;
51   
52   if (!int8_p)
53     return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
54   
55   *int8_p = value->data[0].v_int;
56   
57   *collect_type = 0;
58   return NULL;
59 }
60
61 static gchar*
62 value_boolean_lcopy_value (const GValue *value,
63                            guint         nth_value,
64                            GType        *collect_type,
65                            GTypeCValue  *collect_value)
66 {
67   gboolean *bool_p = collect_value->v_pointer;
68   
69   if (!bool_p)
70     return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
71   
72   *bool_p = value->data[0].v_int;
73   
74   *collect_type = 0;
75   return NULL;
76 }
77
78 static gchar*
79 value_int_collect_value (GValue      *value,
80                          guint        nth_value,
81                          GType       *collect_type,
82                          GTypeCValue *collect_value)
83 {
84   value->data[0].v_int = collect_value->v_int;
85   
86   *collect_type = 0;
87   return NULL;
88 }
89
90 static gchar*
91 value_int_lcopy_value (const GValue *value,
92                        guint         nth_value,
93                        GType        *collect_type,
94                        GTypeCValue  *collect_value)
95 {
96   gint *int_p = collect_value->v_pointer;
97   
98   if (!int_p)
99     return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
100   
101   *int_p = value->data[0].v_int;
102   
103   *collect_type = 0;
104   return NULL;
105 }
106
107 static gchar*
108 value_long_collect_value (GValue      *value,
109                           guint        nth_value,
110                           GType       *collect_type,
111                           GTypeCValue *collect_value)
112 {
113   value->data[0].v_long = collect_value->v_long;
114   
115   *collect_type = 0;
116   return NULL;
117 }
118
119 static gchar*
120 value_long_lcopy_value (const GValue *value,
121                         guint         nth_value,
122                         GType        *collect_type,
123                         GTypeCValue  *collect_value)
124 {
125   glong *long_p = collect_value->v_pointer;
126   
127   if (!long_p)
128     return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
129   
130   *long_p = value->data[0].v_long;
131   
132   *collect_type = 0;
133   return NULL;
134 }
135
136 static void
137 value_float_init (GValue *value)
138 {
139   value->data[0].v_float = 0.0;
140 }
141
142 static void
143 value_float_copy (const GValue *src_value,
144                   GValue       *dest_value)
145 {
146   dest_value->data[0].v_float = src_value->data[0].v_float;
147 }
148
149 static gchar*
150 value_float_collect_value (GValue      *value,
151                            guint        nth_value,
152                            GType       *collect_type,
153                            GTypeCValue *collect_value)
154 {
155   value->data[0].v_float = collect_value->v_double;
156   
157   *collect_type = 0;
158   return NULL;
159 }
160
161 static gchar*
162 value_float_lcopy_value (const GValue *value,
163                          guint         nth_value,
164                          GType        *collect_type,
165                          GTypeCValue  *collect_value)
166 {
167   gfloat *float_p = collect_value->v_pointer;
168   
169   if (!float_p)
170     return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
171   
172   *float_p = value->data[0].v_float;
173   
174   *collect_type = 0;
175   return NULL;
176 }
177
178 static void
179 value_double_init (GValue *value)
180 {
181   value->data[0].v_double = 0.0;
182 }
183
184 static void
185 value_double_copy (const GValue *src_value,
186                    GValue       *dest_value)
187 {
188   dest_value->data[0].v_double = src_value->data[0].v_double;
189 }
190
191 static gchar*
192 value_double_collect_value (GValue      *value,
193                             guint        nth_value,
194                             GType       *collect_type,
195                             GTypeCValue *collect_value)
196 {
197   value->data[0].v_double = collect_value->v_double;
198   
199   *collect_type = 0;
200   return NULL;
201 }
202
203 static gchar*
204 value_double_lcopy_value (const GValue *value,
205                           guint         nth_value,
206                           GType        *collect_type,
207                           GTypeCValue  *collect_value)
208 {
209   gdouble *double_p = collect_value->v_pointer;
210   
211   if (!double_p)
212     return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
213   
214   *double_p = value->data[0].v_double;
215   
216   *collect_type = 0;
217   return NULL;
218 }
219
220 static void
221 value_string_init (GValue *value)
222 {
223   value->data[0].v_pointer = NULL;
224 }
225
226 static void
227 value_string_free_value (GValue *value)
228 {
229   if (!(value->data[1].v_uint & G_VALUE_STATIC_TAG))
230     g_free (value->data[0].v_pointer);
231 }
232
233 static void
234 value_string_copy_value (const GValue *src_value,
235                          GValue       *dest_value)
236 {
237   dest_value->data[0].v_pointer = g_strdup (src_value->data[0].v_pointer);
238 }
239
240 static gchar*
241 value_string_collect_value (GValue      *value,
242                             guint        nth_value,
243                             GType       *collect_type,
244                             GTypeCValue *collect_value)
245 {
246   value->data[0].v_pointer = g_strdup (collect_value->v_pointer);
247   
248   *collect_type = 0;
249   return NULL;
250 }
251
252 static gchar*
253 value_string_lcopy_value (const GValue *value,
254                           guint         nth_value,
255                           GType        *collect_type,
256                           GTypeCValue  *collect_value)
257 {
258   gchar **string_p = collect_value->v_pointer;
259   
260   if (!string_p)
261     return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
262   
263   *string_p = g_strdup (value->data[0].v_pointer);
264   
265   *collect_type = 0;
266   return NULL;
267 }
268
269 static void
270 value_pointer_init (GValue *value)
271 {
272   value->data[0].v_pointer = NULL;
273 }
274
275 static void
276 value_pointer_copy (const GValue *src_value,
277                     GValue       *dest_value)
278 {
279   dest_value->data[0].v_pointer = src_value->data[0].v_pointer;
280 }
281
282 static gpointer
283 value_pointer_peek_pointer (const GValue *value)
284 {
285   return value->data[0].v_pointer;
286 }
287
288 static gchar*
289 value_pointer_collect_value (GValue      *value,
290                              guint        nth_value,
291                              GType       *collect_type,
292                              GTypeCValue *collect_value)
293 {
294   value->data[0].v_pointer = collect_value->v_pointer;
295
296   *collect_type = 0;
297   return NULL;
298 }
299
300 static gchar*
301 value_pointer_lcopy_value (const GValue *value,
302                            guint         nth_value,
303                            GType        *collect_type,
304                            GTypeCValue  *collect_value)
305 {
306   gpointer *pointer_p = collect_value->v_pointer;
307
308   if (!pointer_p)
309     return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
310
311   *pointer_p = value->data[0].v_pointer;
312
313   *collect_type = 0;
314   return NULL;
315 }
316
317 static void
318 value_ccallback_init (GValue *value)
319 {
320   value->data[0].v_pointer = NULL;
321   value->data[1].v_pointer = NULL;
322 }
323
324 static void
325 value_ccallback_copy (const GValue *src_value,
326                       GValue       *dest_value)
327 {
328   dest_value->data[0].v_pointer = src_value->data[0].v_pointer;
329   dest_value->data[1].v_pointer = src_value->data[1].v_pointer;
330 }
331
332 static gchar*
333 value_ccallback_collect_value (GValue      *value,
334                                guint        nth_value,
335                                GType       *collect_type,
336                                GTypeCValue *collect_value)
337 {
338   gchar *error = NULL;
339
340   switch (nth_value)
341     {
342     case 0:
343       value->data[0].v_pointer = collect_value->v_pointer;
344       *collect_type = G_VALUE_COLLECT_POINTER;
345       if (!value->data[0].v_pointer)
346         error = g_strconcat ("invalid (NULL) pointer callback function for value type `",
347                              G_VALUE_TYPE_NAME (value),
348                              "'",
349                              NULL);
350       break;
351     case 1:
352       value->data[1].v_pointer = collect_value->v_pointer;
353       *collect_type = 0;
354       break;
355     }
356
357   return error;
358 }
359
360 static gchar*
361 value_ccallback_lcopy_value (const GValue *value,
362                              guint         nth_value,
363                              GType        *collect_type,
364                              GTypeCValue  *collect_value)
365 {
366   gpointer *pointer_p = collect_value->v_pointer;
367
368   if (!pointer_p)
369     return g_strdup_printf ("%s location for `%s' passed as NULL",
370                             nth_value ? "data" : "callback",
371                             G_VALUE_TYPE_NAME (value));
372   switch (nth_value)
373     {
374     case 0:
375       *pointer_p = value->data[0].v_pointer;
376       *collect_type = G_VALUE_COLLECT_POINTER;
377       break;
378     case 1:
379       *pointer_p = value->data[1].v_pointer;
380       *collect_type = 0;
381       break;
382     }
383
384   return NULL;
385 }
386
387
388 /* --- type initialization --- */
389 void
390 g_value_types_init (void)  /* sync with gtype.c */
391 {
392   GTypeInfo info = {
393     0,                          /* class_size */
394     NULL,                       /* base_init */
395     NULL,                       /* base_destroy */
396     NULL,                       /* class_init */
397     NULL,                       /* class_destroy */
398     NULL,                       /* class_data */
399     0,                          /* instance_size */
400     0,                          /* n_preallocs */
401     NULL,                       /* instance_init */
402     NULL,                       /* value_table */
403   };
404   const GTypeFundamentalInfo finfo = { G_TYPE_FLAG_DERIVABLE, };
405   GType type;
406   
407   /* G_TYPE_CHAR / G_TYPE_UCHAR
408    */
409   {
410     static const GTypeValueTable value_table = {
411       value_long0_init,         /* value_init */
412       NULL,                     /* value_free */
413       value_long0_copy,         /* value_copy */
414       NULL,                     /* value_peek_pointer */
415       G_VALUE_COLLECT_INT,      /* collect_type */
416       value_int_collect_value,  /* collect_value */
417       G_VALUE_COLLECT_POINTER,  /* lcopy_type */
418       value_char_lcopy_value,   /* lcopy_value */
419     };
420     info.value_table = &value_table;
421     type = g_type_register_fundamental (G_TYPE_CHAR, "gchar", &info, &finfo, 0);
422     g_assert (type == G_TYPE_CHAR);
423     type = g_type_register_fundamental (G_TYPE_UCHAR, "guchar", &info, &finfo, 0);
424     g_assert (type == G_TYPE_UCHAR);
425   }
426
427   /* G_TYPE_BOOLEAN
428    */
429   {
430     static const GTypeValueTable value_table = {
431       value_long0_init,          /* value_init */
432       NULL,                      /* value_free */
433       value_long0_copy,          /* value_copy */
434       NULL,                      /* value_peek_pointer */
435       G_VALUE_COLLECT_INT,       /* collect_type */
436       value_int_collect_value,   /* collect_value */
437       G_VALUE_COLLECT_POINTER,   /* lcopy_type */
438       value_boolean_lcopy_value, /* lcopy_value */
439     };
440     info.value_table = &value_table;
441     type = g_type_register_fundamental (G_TYPE_BOOLEAN, "gboolean", &info, &finfo, 0);
442     g_assert (type == G_TYPE_BOOLEAN);
443   }
444   
445   /* G_TYPE_INT / G_TYPE_UINT
446    */
447   {
448     static const GTypeValueTable value_table = {
449       value_long0_init,         /* value_init */
450       NULL,                     /* value_free */
451       value_long0_copy,         /* value_copy */
452       NULL,                     /* value_peek_pointer */
453       G_VALUE_COLLECT_INT,      /* collect_type */
454       value_int_collect_value,  /* collect_value */
455       G_VALUE_COLLECT_POINTER,  /* lcopy_type */
456       value_int_lcopy_value,    /* lcopy_value */
457     };
458     info.value_table = &value_table;
459     type = g_type_register_fundamental (G_TYPE_INT, "gint", &info, &finfo, 0);
460     g_assert (type == G_TYPE_INT);
461     type = g_type_register_fundamental (G_TYPE_UINT, "guint", &info, &finfo, 0);
462     g_assert (type == G_TYPE_UINT);
463   }
464
465   /* G_TYPE_LONG / G_TYPE_ULONG
466    */
467   {
468     static const GTypeValueTable value_table = {
469       value_long0_init,         /* value_init */
470       NULL,                     /* value_free */
471       value_long0_copy,         /* value_copy */
472       NULL,                     /* value_peek_pointer */
473       G_VALUE_COLLECT_LONG,     /* collect_type */
474       value_long_collect_value, /* collect_value */
475       G_VALUE_COLLECT_POINTER,  /* lcopy_type */
476       value_long_lcopy_value,   /* lcopy_value */
477     };
478     info.value_table = &value_table;
479     type = g_type_register_fundamental (G_TYPE_LONG, "glong", &info, &finfo, 0);
480     g_assert (type == G_TYPE_LONG);
481     type = g_type_register_fundamental (G_TYPE_ULONG, "gulong", &info, &finfo, 0);
482     g_assert (type == G_TYPE_ULONG);
483   }
484   
485   /* G_TYPE_FLOAT
486    */
487   {
488     static const GTypeValueTable value_table = {
489       value_float_init,          /* value_init */
490       NULL,                      /* value_free */
491       value_float_copy,          /* value_copy */
492       NULL,                      /* value_peek_pointer */
493       G_VALUE_COLLECT_DOUBLE,    /* collect_type */
494       value_float_collect_value, /* collect_value */
495       G_VALUE_COLLECT_POINTER,   /* lcopy_type */
496       value_float_lcopy_value,   /* lcopy_value */
497     };
498     info.value_table = &value_table;
499     type = g_type_register_fundamental (G_TYPE_FLOAT, "gfloat", &info, &finfo, 0);
500     g_assert (type == G_TYPE_FLOAT);
501   }
502   
503   /* G_TYPE_DOUBLE
504    */
505   {
506     static const GTypeValueTable value_table = {
507       value_double_init,          /* value_init */
508       NULL,                       /* value_free */
509       value_double_copy,          /* value_copy */
510       NULL,                       /* value_peek_pointer */
511       G_VALUE_COLLECT_DOUBLE,     /* collect_type */
512       value_double_collect_value, /* collect_value */
513       G_VALUE_COLLECT_POINTER,    /* lcopy_type */
514       value_double_lcopy_value,   /* lcopy_value */
515     };
516     info.value_table = &value_table;
517     type = g_type_register_fundamental (G_TYPE_DOUBLE, "gdouble", &info, &finfo, 0);
518     g_assert (type == G_TYPE_DOUBLE);
519   }
520
521   /* G_TYPE_STRING
522    */
523   {
524     static const GTypeValueTable value_table = {
525       value_string_init,          /* value_init */
526       value_string_free_value,    /* value_free */
527       value_string_copy_value,    /* value_copy */
528       value_pointer_peek_pointer, /* value_peek_pointer */
529       G_VALUE_COLLECT_POINTER,    /* collect_type */
530       value_string_collect_value, /* collect_value */
531       G_VALUE_COLLECT_POINTER,    /* lcopy_type */
532       value_string_lcopy_value,   /* lcopy_value */
533     };
534     info.value_table = &value_table;
535     type = g_type_register_fundamental (G_TYPE_STRING, "gstring", &info, &finfo, 0);
536     g_assert (type == G_TYPE_STRING);
537   }
538
539   /* G_TYPE_POINTER
540    */
541   {
542     static const GTypeValueTable value_table = {
543       value_pointer_init,          /* value_init */
544       NULL,                        /* value_free */
545       value_pointer_copy,          /* value_copy */
546       value_pointer_peek_pointer,  /* value_peek_pointer */
547       G_VALUE_COLLECT_POINTER,     /* collect_type */
548       value_pointer_collect_value, /* collect_value */
549       G_VALUE_COLLECT_POINTER,     /* lcopy_type */
550       value_pointer_lcopy_value,   /* lcopy_value */
551     };
552     info.value_table = &value_table;
553     type = g_type_register_fundamental (G_TYPE_POINTER, "gpointer", &info, &finfo, 0);
554     g_assert (type == G_TYPE_POINTER);
555   }
556
557   /* G_TYPE_CCALLBACK
558    */
559   {
560     static const GTypeValueTable value_table = {
561       value_ccallback_init,          /* value_init */
562       NULL,                          /* value_free */
563       value_ccallback_copy,          /* value_copy */
564       NULL,                          /* value_peek_pointer */
565       G_VALUE_COLLECT_POINTER,       /* collect_type */
566       value_ccallback_collect_value, /* collect_value */
567       G_VALUE_COLLECT_POINTER,       /* lcopy_type */
568       value_ccallback_lcopy_value,   /* lcopy_value */
569     };
570     info.value_table = &value_table;
571     type = g_type_register_fundamental (G_TYPE_CCALLBACK, "GCCallback", &info, &finfo, 0);
572     g_assert (type == G_TYPE_CCALLBACK);
573   }
574 }
575
576
577 /* --- GValue functions --- */
578 void
579 g_value_set_char (GValue *value,
580                   gint8   v_char)
581 {
582   g_return_if_fail (G_IS_VALUE_CHAR (value));
583   
584   value->data[0].v_int = v_char;
585 }
586
587 gint8
588 g_value_get_char (const GValue *value)
589 {
590   g_return_val_if_fail (G_IS_VALUE_CHAR (value), 0);
591   
592   return value->data[0].v_int;
593 }
594
595 void
596 g_value_set_uchar (GValue *value,
597                    guint8  v_uchar)
598 {
599   g_return_if_fail (G_IS_VALUE_UCHAR (value));
600   
601   value->data[0].v_uint = v_uchar;
602 }
603
604 guint8
605 g_value_get_uchar (const GValue *value)
606 {
607   g_return_val_if_fail (G_IS_VALUE_UCHAR (value), 0);
608   
609   return value->data[0].v_uint;
610 }
611
612 void
613 g_value_set_boolean (GValue  *value,
614                      gboolean v_boolean)
615 {
616   g_return_if_fail (G_IS_VALUE_BOOLEAN (value));
617   
618   value->data[0].v_int = v_boolean;
619 }
620
621 gboolean
622 g_value_get_boolean (const GValue *value)
623 {
624   g_return_val_if_fail (G_IS_VALUE_BOOLEAN (value), 0);
625   
626   return value->data[0].v_int;
627 }
628
629 void
630 g_value_set_int (GValue *value,
631                  gint    v_int)
632 {
633   g_return_if_fail (G_IS_VALUE_INT (value));
634   
635   value->data[0].v_int = v_int;
636 }
637
638 gint
639 g_value_get_int (const GValue *value)
640 {
641   g_return_val_if_fail (G_IS_VALUE_INT (value), 0);
642   
643   return value->data[0].v_int;
644 }
645
646 void
647 g_value_set_uint (GValue *value,
648                   guint   v_uint)
649 {
650   g_return_if_fail (G_IS_VALUE_UINT (value));
651   
652   value->data[0].v_uint = v_uint;
653 }
654
655 guint
656 g_value_get_uint (const GValue *value)
657 {
658   g_return_val_if_fail (G_IS_VALUE_UINT (value), 0);
659   
660   return value->data[0].v_uint;
661 }
662
663 void
664 g_value_set_long (GValue *value,
665                   glong   v_long)
666 {
667   g_return_if_fail (G_IS_VALUE_LONG (value));
668   
669   value->data[0].v_long = v_long;
670 }
671
672 glong
673 g_value_get_long (const GValue *value)
674 {
675   g_return_val_if_fail (G_IS_VALUE_LONG (value), 0);
676   
677   return value->data[0].v_long;
678 }
679
680 void
681 g_value_set_ulong (GValue *value,
682                    gulong  v_ulong)
683 {
684   g_return_if_fail (G_IS_VALUE_ULONG (value));
685   
686   value->data[0].v_ulong = v_ulong;
687 }
688
689 gulong
690 g_value_get_ulong (const GValue *value)
691 {
692   g_return_val_if_fail (G_IS_VALUE_ULONG (value), 0);
693   
694   return value->data[0].v_ulong;
695 }
696
697 void
698 g_value_set_float (GValue *value,
699                    gfloat  v_float)
700 {
701   g_return_if_fail (G_IS_VALUE_FLOAT (value));
702   
703   value->data[0].v_float = v_float;
704 }
705
706 gfloat
707 g_value_get_float (const GValue *value)
708 {
709   g_return_val_if_fail (G_IS_VALUE_FLOAT (value), 0);
710   
711   return value->data[0].v_float;
712 }
713
714 void
715 g_value_set_double (GValue *value,
716                     gdouble v_double)
717 {
718   g_return_if_fail (G_IS_VALUE_DOUBLE (value));
719   
720   value->data[0].v_double = v_double;
721 }
722
723 gdouble
724 g_value_get_double (const GValue *value)
725 {
726   g_return_val_if_fail (G_IS_VALUE_DOUBLE (value), 0);
727   
728   return value->data[0].v_double;
729 }
730
731 void
732 g_value_set_string (GValue      *value,
733                     const gchar *v_string)
734 {
735   g_return_if_fail (G_IS_VALUE_STRING (value));
736   
737   if (value->data[1].v_uint & G_VALUE_STATIC_TAG)
738     value->data[1].v_uint = 0;
739   else
740     g_free (value->data[0].v_pointer);
741   value->data[0].v_pointer = g_strdup (v_string);
742 }
743
744 void
745 g_value_set_static_string (GValue      *value,
746                            const gchar *v_string)
747 {
748   g_return_if_fail (G_IS_VALUE_STRING (value));
749   
750   if (!(value->data[1].v_uint & G_VALUE_STATIC_TAG))
751     g_free (value->data[0].v_pointer);
752   value->data[1].v_uint = G_VALUE_STATIC_TAG;
753   value->data[0].v_pointer = (gchar*) v_string;
754 }
755
756 gchar*
757 g_value_get_string (const GValue *value)
758 {
759   g_return_val_if_fail (G_IS_VALUE_STRING (value), NULL);
760   
761   return value->data[0].v_pointer;
762 }
763
764 gchar*
765 g_value_dup_string (const GValue *value)
766 {
767   g_return_val_if_fail (G_IS_VALUE_STRING (value), NULL);
768   
769   return g_strdup (value->data[0].v_pointer);
770 }
771
772 void
773 g_value_set_pointer (GValue  *value,
774                      gpointer v_pointer)
775 {
776   g_return_if_fail (G_IS_VALUE_POINTER (value));
777
778   value->data[0].v_pointer = v_pointer;
779 }
780
781 gpointer
782 g_value_get_pointer (const GValue *value)
783 {
784   g_return_val_if_fail (G_IS_VALUE_POINTER (value), NULL);
785
786   return value->data[0].v_pointer;
787 }
788
789 void
790 g_value_set_ccallback (GValue  *value,
791                        gpointer callback_func,
792                        gpointer callback_data)
793 {
794   g_return_if_fail (G_IS_VALUE_CCALLBACK (value));
795   
796   value->data[0].v_pointer = callback_func;
797   value->data[1].v_pointer = callback_data;
798 }
799
800 void
801 g_value_get_ccallback (const GValue *value,
802                        gpointer     *callback_func,
803                        gpointer     *callback_data)
804 {
805   g_return_if_fail (G_IS_VALUE_CCALLBACK (value));
806
807   if (callback_func)
808     *callback_func = value->data[0].v_pointer;
809   if (callback_data)
810     *callback_data = value->data[1].v_pointer;
811 }