/simpletypesystem/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/simpletypesystem/trunk

« back to all changes in this revision

Viewing changes to src/Box.h

  • Committer: Gustav Hartvigsson
  • Date: 2015-07-12 19:04:18 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20150712190418-yi9rfito5ovnf6dy
* Made the code more easy to read.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
typedef struct SBoxPrivate SBoxPrivate;
25
25
 
26
 
struct SBox {
 
26
struct
 
27
SBox {
27
28
  SObject parent;
28
29
  SBoxPrivate * priv;
29
30
};
30
31
 
31
 
struct SBoxClass {
 
32
struct
 
33
SBoxClass {
32
34
  SObjectClass parent_class;
33
35
  FreeFunc free_func;
34
36
};
37
39
#define S_BOX_CLASS(k) (SBoxClass *)(k);
38
40
 
39
41
/**
 
42
 * C11 Generic macro to create object easily.
 
43
 */
 
44
#define  s_box_new(x) _Generic((x)\
 
45
                               spointer: s_box_new_pointer,\
 
46
                               SObject: s_box_new_object,\
 
47
                               long: s_box_new_long,\
 
48
                               short: s_box_new_short,\
 
49
                               char: s_box_new_char,\
 
50
                               wchar_t: s_box_new_wchar,\
 
51
                               char *: s_box_new_string,\
 
52
                               wchar_t *: s_box_new_wstring\
 
53
                               )(x)
 
54
 
 
55
/**
40
56
 * Creates a new SBox object.
41
57
 * 
42
58
 * @param object The object to be boxed.
44
60
 *
45
61
 * @return A new SBox object.
46
62
 */
47
 
SBox * s_box_new_pointer (spointer object);
48
 
 
49
 
SBox * s_box_new_sobject (SObject * object);
50
 
 
51
 
SBox * s_box_new_int (int i);
52
 
 
53
 
SBox * s_box_new_long (long l);
54
 
 
55
 
SBox * s_box_new_short (short s);
56
 
 
57
 
SBox * s_box_new_char (char c);
58
 
 
59
 
SBox * s_box_new_wchar (wchar_t wc);
60
 
 
61
 
SBox * s_box_new_uint (unsigned int ui);
62
 
 
63
 
SBox * s_box_new_ulong (long l);
64
 
 
65
 
SBox * s_box_new_ushort (short s);
66
 
 
67
 
SBox * s_box_new_string (char * s);
68
 
 
69
 
SBox * s_box_new_wstring (wchar_t * ws);
 
63
SBox *
 
64
s_box_new_pointer (spointer object);
 
65
 
 
66
SBox *
 
67
s_box_new_sobject (SObject * object);
 
68
 
 
69
SBox *
 
70
s_box_new_int (int i);
 
71
 
 
72
SBox *
 
73
s_box_new_long (long l);
 
74
 
 
75
SBox *
 
76
s_box_new_short (short s);
 
77
 
 
78
SBox *
 
79
s_box_new_char (char c);
 
80
 
 
81
SBox *
 
82
s_box_new_wchar (wchar_t wc);
 
83
 
 
84
SBox *
 
85
s_box_new_uint (unsigned int ui);
 
86
 
 
87
SBox *
 
88
s_box_new_ulong (long l);
 
89
 
 
90
SBox *
 
91
s_box_new_ushort (short s);
 
92
 
 
93
SBox *
 
94
s_box_new_string (char * s);
 
95
 
 
96
SBox *
 
97
s_box_new_wstring (wchar_t * ws);
70
98
 
71
99
/**
72
100
 * Free the an SBox.
73
101
 *
74
102
 * @param box The SBox to be freed.
75
103
 */
76
 
void s_box_free (SBox * box);
 
104
void
 
105
s_box_free (SBox * box);
77
106
 
78
107
/**
79
108
 * Get the object that is contained inside the SBox.
82
111
 *
83
112
 * @return a pointer to the object.
84
113
 */
85
 
spointer s_box_get_object (SBox * box);
 
114
spointer
 
115
s_box_get_object (SBox * box);
86
116
 
87
117
/**
88
118
 * Gets the SType of the object that is stored in the SBox.
89
119
 */
90
 
SType s_box_get_type (SBox * box);
 
120
SType
 
121
s_box_get_type (SBox * box);
91
122
 
92
123
/**
93
124
 * Gets the type name of the object.
97
128
 * 
98
129
 * @note caller must free the string.
99
130
 */
100
 
char * s_box_get_type_name (SBox * box);
 
131
char *
 
132
s_box_get_type_name (SBox * box);
101
133
 
102
 
void s_box_set_free_func (SBox * box, FreeFunc free_func);
 
134
void
 
135
s_box_set_free_func (SBox * box, FreeFunc free_func);
103
136
 
104
137
/**
105
138
 * 
106
139
 */
107
 
void s_box_set_free_data_on_free (SBox * self, sboolean free_data);
 
140
void
 
141
s_box_set_free_data_on_free (SBox * self, sboolean free_data);
108
142
 
109
143
 
110
144
/** @} */