1 #ifndef __UTILITY_H__
2 #define __UTILITY_H__
3 
4 #include <glib-object.h>
5 
6 #include "gitestmacros.h"
7 
8 #define UTILITY_TYPE_OBJECT              (utility_object_get_type ())
9 #define UTILITY_OBJECT(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), UTILITY_TYPE_OBJECT, UtilityObject))
10 #define UTILITY_IS_OBJECT(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), UTILITY_TYPE_OBJECT))
11 
12 typedef struct _UtilityObject          UtilityObject;
13 typedef struct _UtilityObjectClass     UtilityObjectClass;
14 
15 struct _UtilityObject
16 {
17   GObject parent_instance;
18 };
19 
20 struct _UtilityObjectClass
21 {
22   GObjectClass parent_class;
23 };
24 
25 /* This one is similar to Pango.Glyph */
26 typedef guint32 UtilityGlyph;
27 
28 typedef struct
29 {
30   int tag;
31   union
32   {
33     gpointer v_pointer;
34     double v_real;
35     long v_integer;
36   } value;
37 } UtilityTaggedValue;
38 
39 typedef union
40 {
41   guint8 value;
42   struct
43   {
44     guint8 first_nibble : 4;
45     guint8 second_nibble : 4;
46   } parts;
47 } UtilityByte;
48 
49 /* This one is similiar to Soup.Buffer */
50 typedef struct
51 {
52   const char *data;
53   gsize       length;
54 } UtilityBuffer;
55 
56 typedef void (*UtilityFileFunc)(const char *path, gpointer user_data);
57 
58 
59 _GI_TEST_EXTERN
60 GType                 utility_object_get_type          (void) G_GNUC_CONST;
61 
62 _GI_TEST_EXTERN
63 void                  utility_object_watch_dir         (UtilityObject *object,
64                                                         const char *path,
65                                                         UtilityFileFunc func,
66                                                         gpointer user_data,
67                                                         GDestroyNotify destroy);
68 
69 typedef enum
70 {
71   UTILITY_ENUM_A,
72   UTILITY_ENUM_B,
73   UTILITY_ENUM_C
74 } UtilityEnumType;
75 
76 /* The shift operators here should imply bitfield */
77 typedef enum
78 {
79   UTILITY_FLAG_A = 1 << 0,
80   UTILITY_FLAG_B = 1 << 1,
81   UTILITY_FLAG_C = 1 << 2
82 } UtilityFlagType;
83 
84 typedef struct
85 {
86   int field;
87   guint bitfield1 : 3;
88   guint bitfield2 : 2;
89   guint8 data[16];
90 } UtilityStruct;
91 
92 typedef union
93 {
94   char *pointer;
95   glong integer;
96   double real;
97 } UtilityUnion;
98 
99 _GI_TEST_EXTERN
100 void utility_dir_foreach (const char *path, UtilityFileFunc func, gpointer user_data);
101 
102 #endif /* __UTILITY_H__ */
103