1 /*
2  * Distributed under the Boost Software License, Version 1.0.
3  *    (See accompanying file LICENSE_1_0.txt or copy at
4  *          http://www.boost.org/LICENSE_1_0.txt)
5  */
6 module gobject.gvalue;
7 
8 import gobject.gtype;
9 import glib;
10 
11 
12 alias G_TYPE_IS_VALUE = g_type_check_is_value_type;
13 //alias G_IS_VALUE = G_TYPE_CHECK_VALUE;
14 auto G_VALUE_TYPE(V)(V val) { return val.g_type; }
15 auto G_VALUE_TYPE_NAME(V)(V val) { return g_type_name(G_VALUE_TYPE(val)); }
16 //auto G_VALUE_HOLDS(V, T)(V v, T t) { return G_TYPE_CHECK_VALUE_TYPE(v, t); }
17 
18 enum G_VALUE_NOCOPY_CONTENTS = 1 << 27;
19 
20 struct GValue
21 {
22   /*< private >*/
23   GType		g_type;
24   data_t [2] data;
25 
26   /* public for GTypeValueTable methods */
27   union data_t {
28     gint	v_int;
29     guint	v_uint;
30     glong	v_long;
31     gulong	v_ulong;
32     gint64      v_int64;
33     guint64     v_uint64;
34     gfloat	v_float;
35     gdouble	v_double;
36     gpointer	v_pointer;
37   }
38 }
39 
40 
41 extern(C) {
42 
43     alias GValueTransform = void function (const(GValue) *src_value,
44                      GValue       *dest_value);
45 
46     /* --- prototypes --- */
47 
48     GValue*         g_value_init	   	(GValue       *value,
49                          GType         g_type);
50 
51     void            g_value_copy    	(const(GValue) *src_value,
52                          GValue       *dest_value);
53 
54     GValue*         g_value_reset   	(GValue       *value);
55 
56     void            g_value_unset   	(GValue       *value);
57 
58     void		g_value_set_instance	(GValue	      *value,
59                          gpointer      instance);
60 
61     void            g_value_init_from_instance   (GValue       *value,
62                                                   gpointer      instance);
63 
64 
65     /* --- private --- */
66 
67     gboolean	g_value_fits_pointer	(const(GValue) *value);
68 
69     gpointer	g_value_peek_pointer	(const(GValue) *value);
70 
71 
72     /* --- implementation details --- */
73 
74     gboolean g_value_type_compatible	(GType		 src_type,
75                          GType		 dest_type);
76 
77     gboolean g_value_type_transformable	(GType           src_type,
78                          GType           dest_type);
79 
80     gboolean g_value_transform		(const(GValue)   *src_value,
81                          GValue         *dest_value);
82 
83     void	g_value_register_transform_func	(GType		 src_type,
84                          GType		 dest_type,
85                          GValueTransform transform_func);
86 
87 }
88