bzr branch
http://gegoxaren.bato24.eu/bzr/simpletypesystem/trunk
|
27
by Gustav Hartvigsson
* added skeleton for the SBox type. |
1 |
#ifndef __H_BOX__
|
2 |
#define __H_BOX__
|
|
3 |
#include "defs.h" |
|
4 |
#include "baseobject.h" |
|
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
5 |
#include "Error.h" |
|
43
by Gustav Hartvigsson
* Code cleanup |
6 |
#include "Func.h" |
|
27
by Gustav Hartvigsson
* added skeleton for the SBox type. |
7 |
|
|
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
8 |
BEGIN_DECLS
|
9 |
||
|
27
by Gustav Hartvigsson
* added skeleton for the SBox type. |
10 |
/** @file
|
|
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
11 |
* @defgroup SBox SBox
|
12 |
* @addtogroup SBox
|
|
13 |
* @{
|
|
|
27
by Gustav Hartvigsson
* added skeleton for the SBox type. |
14 |
* An SBox is a boxed type.
|
15 |
*/
|
|
16 |
||
17 |
||
18 |
/** @brief
|
|
|
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
19 |
* A reference counted box sitting on top of an SObject.
|
|
63
by Gustav Hartvigsson
* Working on SMatrix to finish it off. |
20 |
*
|
21 |
* When creating an SBox use the s_box_new() macro, it expands to the correct
|
|
22 |
* constructor using the C11 _Generic macro.
|
|
23 |
*
|
|
24 |
* When freeing the SBox use s_object_free() function. If you depend
|
|
25 |
* on reference counting use s_object_unref() to do this.
|
|
|
27
by Gustav Hartvigsson
* added skeleton for the SBox type. |
26 |
*/
|
|
43
by Gustav Hartvigsson
* Code cleanup |
27 |
typedef struct SBox SBox; |
28 |
||
29 |
typedef struct SBoxClass SBoxClass; |
|
30 |
||
31 |
typedef struct SBoxPrivate SBoxPrivate; |
|
32 |
||
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
33 |
struct
|
34 |
SBox { |
|
|
27
by Gustav Hartvigsson
* added skeleton for the SBox type. |
35 |
SObject parent; |
36 |
SBoxPrivate * priv; |
|
|
43
by Gustav Hartvigsson
* Code cleanup |
37 |
};
|
|
27
by Gustav Hartvigsson
* added skeleton for the SBox type. |
38 |
|
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
39 |
struct
|
40 |
SBoxClass { |
|
|
27
by Gustav Hartvigsson
* added skeleton for the SBox type. |
41 |
SObjectClass parent_class; |
|
43
by Gustav Hartvigsson
* Code cleanup |
42 |
};
|
43 |
||
|
49
by Gustav Hartvigsson
* started work SBox (Untested). |
44 |
#define S_BOX(o) (SBox *)(o);
|
45 |
#define S_BOX_CLASS(k) (SBoxClass *)(k);
|
|
46 |
||
|
43
by Gustav Hartvigsson
* Code cleanup |
47 |
/**
|
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
48 |
* C11 Generic macro to create object easily.
|
|
62
by Gustav Hartvigsson
* General documentation clean up. |
49 |
*
|
50 |
* This is what is most likely to be used in real code, because it makes life
|
|
51 |
* a lot easier than to remember all the other commands.
|
|
52 |
*
|
|
53 |
* The caveat is that there is no way to construct a macro to do the same
|
|
54 |
* for the s_box_get_ functions.
|
|
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
55 |
*/
|
56 |
#define s_box_new(x) _Generic((x)\
|
|
57 |
spointer: s_box_new_pointer,\
|
|
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
58 |
SObject *: s_box_new_sobject,\
|
59 |
slong: s_box_new_long,\
|
|
60 |
sshort: s_box_new_short,\
|
|
61 |
schar: s_box_new_char,\
|
|
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
62 |
wchar_t: s_box_new_wchar,\
|
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
63 |
suchar: s_box_new_uchar,\
|
64 |
schar *: s_box_new_string,\
|
|
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
65 |
wchar_t *: s_box_new_wstring\
|
66 |
)(x)
|
|
67 |
||
68 |
/**
|
|
|
43
by Gustav Hartvigsson
* Code cleanup |
69 |
* Creates a new SBox object.
|
70 |
*
|
|
71 |
* @param object The object to be boxed.
|
|
72 |
*
|
|
73 |
* @return A new SBox object.
|
|
74 |
*/
|
|
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
75 |
SBox * |
76 |
s_box_new_pointer (spointer object); |
|
77 |
||
|
62
by Gustav Hartvigsson
* General documentation clean up. |
78 |
/**
|
79 |
* @param object the SObject to stored in the Box.
|
|
80 |
*
|
|
81 |
* @return a new SBox object.
|
|
82 |
*/
|
|
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
83 |
SBox * |
84 |
s_box_new_sobject (SObject * object); |
|
85 |
||
|
62
by Gustav Hartvigsson
* General documentation clean up. |
86 |
/**
|
87 |
* @see s_box_get_pointer.
|
|
88 |
*/
|
|
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
89 |
SBox * |
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
90 |
s_box_new_int (sint i); |
91 |
||
92 |
/**
|
|
93 |
* @see s_box_get_pointer.
|
|
94 |
*/
|
|
95 |
SBox * |
|
96 |
s_box_new_long (slong l); |
|
97 |
||
98 |
/**
|
|
99 |
* @see s_box_get_pointer.
|
|
100 |
*/
|
|
101 |
SBox * |
|
102 |
s_box_new_short (sshort s); |
|
103 |
||
104 |
/**
|
|
105 |
* @see s_box_get_pointer.
|
|
106 |
*/
|
|
107 |
SBox * |
|
108 |
s_box_new_char (schar c); |
|
109 |
||
110 |
/**
|
|
111 |
* @deprecated For everyone's sanity.
|
|
112 |
* @see s_box_get_pointer.
|
|
113 |
*/
|
|
114 |
DEPRECATED
|
|
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
115 |
SBox * |
116 |
s_box_new_wchar (wchar_t wc); |
|
117 |
||
|
62
by Gustav Hartvigsson
* General documentation clean up. |
118 |
/**
|
119 |
* @see s_box_get_pointer.
|
|
120 |
*/
|
|
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
121 |
SBox * |
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
122 |
s_box_new_uchar (suchar c); |
123 |
||
124 |
/**
|
|
125 |
* @see s_box_get_pointer.
|
|
126 |
*/
|
|
127 |
SBox * |
|
128 |
s_box_new_uint (suint ui); |
|
129 |
||
130 |
/**
|
|
131 |
* @see s_box_get_pointer.
|
|
132 |
*/
|
|
133 |
SBox * |
|
134 |
s_box_new_ulong (sulong l); |
|
135 |
||
136 |
/**
|
|
137 |
* @see s_box_get_pointer.
|
|
138 |
*/
|
|
139 |
SBox * |
|
140 |
s_box_new_ushort (sushort s); |
|
141 |
||
142 |
/**
|
|
143 |
* @see s_box_get_pointer.
|
|
144 |
*/
|
|
145 |
SBox * |
|
146 |
s_box_new_string (schar * s); |
|
147 |
||
148 |
/**
|
|
149 |
* @see s_box_get_pointer.
|
|
150 |
*/
|
|
151 |
DEPRECATED
|
|
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
152 |
SBox * |
153 |
s_box_new_wstring (wchar_t * ws); |
|
|
43
by Gustav Hartvigsson
* Code cleanup |
154 |
|
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
155 |
|
|
43
by Gustav Hartvigsson
* Code cleanup |
156 |
/**
|
157 |
* Free the an SBox.
|
|
158 |
*
|
|
159 |
* @param box The SBox to be freed.
|
|
160 |
*/
|
|
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
161 |
void
|
162 |
s_box_free (SBox * box); |
|
|
43
by Gustav Hartvigsson
* Code cleanup |
163 |
|
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
164 |
/* *********************
|
165 |
****** Getters ******
|
|
166 |
********************* */
|
|
|
62
by Gustav Hartvigsson
* General documentation clean up. |
167 |
|
168 |
/** |
|
169 |
* @param self The SBox to get the pointer from.
|
|
170 |
*
|
|
171 |
* @return the pointer stored in the SBox.
|
|
172 |
*
|
|
173 |
* @note you must cast to the correct type.
|
|
174 |
*/
|
|
175 |
spointer * |
|
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
176 |
s_box_get_pointer (SBox * self, SError * err); |
|
62
by Gustav Hartvigsson
* General documentation clean up. |
177 |
|
178 |
/** |
|
179 |
* @param self The SBox to get the object from.
|
|
180 |
*
|
|
181 |
* @return the SObject stored in the SBox.
|
|
182 |
*
|
|
183 |
* @note You should cast to the correct SObject derivative type.
|
|
184 |
*/
|
|
185 |
SObject * |
|
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
186 |
s_box_get_sobject (SBox * self, SError * err); |
|
62
by Gustav Hartvigsson
* General documentation clean up. |
187 |
|
188 |
/**
|
|
189 |
* @param self The box to get the int from.
|
|
190 |
*
|
|
191 |
* @return the int that was stored in the
|
|
192 |
*/
|
|
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
193 |
sint
|
194 |
s_box_get_int (SBox * self, SError * err); |
|
|
62
by Gustav Hartvigsson
* General documentation clean up. |
195 |
|
196 |
/**
|
|
197 |
* @param self the box to get the long from.
|
|
198 |
*
|
|
199 |
* @return the long stored in the box.
|
|
200 |
*/
|
|
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
201 |
slong
|
202 |
s_box_get_long (SBox * self, SError * err); |
|
|
62
by Gustav Hartvigsson
* General documentation clean up. |
203 |
|
204 |
/**
|
|
205 |
* @param self the box to get short from.
|
|
206 |
*
|
|
207 |
* @return the short from the box.
|
|
208 |
*/
|
|
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
209 |
sshort
|
210 |
s_box_get_short (SBox * self, SError * err); |
|
|
62
by Gustav Hartvigsson
* General documentation clean up. |
211 |
|
212 |
/**
|
|
213 |
* @param self the box to get the char from.
|
|
214 |
*
|
|
215 |
* @return the char stored in the
|
|
216 |
*/
|
|
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
217 |
schar
|
218 |
s_box_get_char (SBox * self, SError * err); |
|
|
62
by Gustav Hartvigsson
* General documentation clean up. |
219 |
|
220 |
/**
|
|
221 |
* @param self the box to get the wide char from.
|
|
222 |
*
|
|
223 |
* @return the wide char stored in the box.
|
|
224 |
*/
|
|
|
73
by Gustav Hartvigsson
* Derp. |
225 |
DEPRECATED
|
|
62
by Gustav Hartvigsson
* General documentation clean up. |
226 |
wchar_t
|
|
73
by Gustav Hartvigsson
* Derp. |
227 |
s_box_get_wchar (SBox * self, SError * err); |
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
228 |
|
229 |
/**
|
|
230 |
* @param self the box to get the char from.
|
|
231 |
*
|
|
232 |
* @return the char stored in the
|
|
233 |
*/
|
|
234 |
suchar
|
|
235 |
s_box_get_uchar (SBox * self, SError * err); |
|
|
62
by Gustav Hartvigsson
* General documentation clean up. |
236 |
|
237 |
/**
|
|
238 |
* @param self
|
|
239 |
*/
|
|
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
240 |
suint
|
241 |
s_box_get_uint (SBox * self, SError * err); |
|
242 |
||
243 |
sulong
|
|
244 |
s_box_get_ulong (SBox * self, SError * err); |
|
245 |
||
246 |
sushort
|
|
247 |
s_box_get_ushort (SBox * self, SError * err); |
|
248 |
||
249 |
schar * |
|
250 |
s_box_get_string (SBox * self, SError * err); |
|
|
62
by Gustav Hartvigsson
* General documentation clean up. |
251 |
|
|
73
by Gustav Hartvigsson
* Derp. |
252 |
DEPRECATED
|
|
62
by Gustav Hartvigsson
* General documentation clean up. |
253 |
wchar_t * |
|
73
by Gustav Hartvigsson
* Derp. |
254 |
s_box_get_wstring (SBox * self, SError * err); |
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
255 |
|
256 |
suchar * |
|
257 |
s_box_get_ustring (SBox * self, SError * err); |
|
|
43
by Gustav Hartvigsson
* Code cleanup |
258 |
|
259 |
/**
|
|
260 |
* Gets the SType of the object that is stored in the SBox.
|
|
261 |
*/
|
|
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
262 |
SType
|
263 |
s_box_get_type (SBox * box); |
|
|
43
by Gustav Hartvigsson
* Code cleanup |
264 |
|
265 |
/**
|
|
266 |
* Gets the type name of the object.
|
|
267 |
*
|
|
268 |
* @param box The SBox to get the type name from.
|
|
269 |
* @return A String containing the name of the type.
|
|
270 |
*
|
|
|
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
271 |
* @note caller must free the string.
|
|
43
by Gustav Hartvigsson
* Code cleanup |
272 |
*/
|
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
273 |
char * |
274 |
s_box_get_type_name (SBox * box); |
|
|
49
by Gustav Hartvigsson
* started work SBox (Untested). |
275 |
|
|
62
by Gustav Hartvigsson
* General documentation clean up. |
276 |
/**
|
277 |
* Set the free func to be used when the box is freed.
|
|
278 |
*
|
|
279 |
* This will only work on Strings, Pointers and SObjects.
|
|
280 |
*
|
|
281 |
* @param box the SBox to add the free function to.
|
|
282 |
*
|
|
283 |
* @param free_func the function to be used when freeing the data.
|
|
284 |
*/
|
|
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
285 |
void
|
286 |
s_box_set_free_func (SBox * box, FreeFunc free_func); |
|
|
49
by Gustav Hartvigsson
* started work SBox (Untested). |
287 |
|
288 |
/**
|
|
|
62
by Gustav Hartvigsson
* General documentation clean up. |
289 |
* Set whether or not the data should be freed when the box is freed.
|
|
49
by Gustav Hartvigsson
* started work SBox (Untested). |
290 |
*/
|
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
291 |
void
|
292 |
s_box_set_free_data_on_free (SBox * self, sboolean free_data); |
|
|
49
by Gustav Hartvigsson
* started work SBox (Untested). |
293 |
|
|
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
294 |
/** @} */
|
295 |
||
|
27
by Gustav Hartvigsson
* added skeleton for the SBox type. |
296 |
END_DECLS
|
297 |
||
298 |
#endif
|