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