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