bzr branch
http://gegoxaren.bato24.eu/bzr/simpletypesystem/trunk
|
1
by Gustav Hartvigsson
Initial Code. |
1 |
/*
|
|
5.2.7
by Gustav Hartvigsson
* Switched licence to a more permisive one. |
2 |
Copyright (c) 2013-2014 Gustav Hartvigsson
|
3 |
||
4 |
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5 |
of this software and associated documentation files (the "Software"), to deal
|
|
6 |
in the Software without restriction, including without limitation the rights
|
|
7 |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8 |
copies of the Software, and to permit persons to whom the Software is
|
|
9 |
furnished to do so, subject to the following conditions:
|
|
10 |
||
11 |
The above copyright notice and this permission notice shall be included in
|
|
12 |
all copies or substantial portions of the Software.
|
|
13 |
||
14 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15 |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16 |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17 |
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18 |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19 |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
20 |
THE SOFTWARE.
|
|
|
1
by Gustav Hartvigsson
Initial Code. |
21 |
*/
|
22 |
||
|
62
by Gustav Hartvigsson
* General documentation clean up. |
23 |
|
24 |
||
|
1
by Gustav Hartvigsson
Initial Code. |
25 |
#ifndef __H_BASE_OBJECT__
|
26 |
#define __H_BASE_OBJECT__
|
|
27 |
||
|
45
by Gustav Hartvigsson
* Fixed indirect dependency in baseobject.h |
28 |
#include "defs.h" |
29 |
#include "utils.h" |
|
|
47
by Gustav Hartvigsson
* Added a few skeletal functions to Callback.h |
30 |
#include "Map.h" |
|
45
by Gustav Hartvigsson
* Fixed indirect dependency in baseobject.h |
31 |
|
|
110
by Gustav Hartvigsson
* added S_ prifix to my macros. I should not be a scrub. |
32 |
S_BEGIN_DECLS
|
|
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
33 |
|
|
5.1.4
by Gustav Hartvigsson
* Added a comment to baseoject.h describing what the file does. |
34 |
/** @file
|
|
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
35 |
* @defgroup SObject SObject
|
36 |
* @addtogroup SObject SObject
|
|
37 |
* @{
|
|
|
5.2.9
by Gustav Hartvigsson
* Added license to files |
38 |
* An SObject represents the base of the Super Simple Type System.
|
|
107
by Gustav Hartvigsson
* Removed depricaded functions from SObject code. |
39 |
*
|
|
5.1.4
by Gustav Hartvigsson
* Added a comment to baseoject.h describing what the file does. |
40 |
* Almost all other data structures in this library are children to this object
|
41 |
* type.
|
|
42 |
*
|
|
|
5.2.9
by Gustav Hartvigsson
* Added license to files |
43 |
* All objects that inherent from SObject get the ability to have
|
|
5.1.4
by Gustav Hartvigsson
* Added a comment to baseoject.h describing what the file does. |
44 |
* reference counting of objects via built in functions.
|
|
62
by Gustav Hartvigsson
* General documentation clean up. |
45 |
*
|
46 |
* @section Signals/Callbacks
|
|
47 |
* @par @c notify
|
|
48 |
* This signal is envoked when a propertiy is changed in an SObject.
|
|
49 |
* @endpar
|
|
|
5.1.4
by Gustav Hartvigsson
* Added a comment to baseoject.h describing what the file does. |
50 |
*/
|
51 |
||
|
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
52 |
/**
|
53 |
* The class holds all the "virtual" functions, also knows as methods
|
|
54 |
* that are to be used with the object.
|
|
|
107
by Gustav Hartvigsson
* Removed depricaded functions from SObject code. |
55 |
*
|
|
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
56 |
*/
|
57 |
typedef struct SObjectClass SObjectClass; |
|
58 |
||
59 |
/**
|
|
60 |
* The instance holds the data that is associated with the object.
|
|
61 |
* it also holds a pointer to the class of the object.
|
|
|
107
by Gustav Hartvigsson
* Removed depricaded functions from SObject code. |
62 |
*
|
|
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
63 |
*/
|
64 |
typedef struct SObject SObject; |
|
65 |
||
|
32
by Gustav Hartvigsson
* Added some compile options to the root CMakeLists.txt |
66 |
/**
|
67 |
*
|
|
68 |
*/
|
|
69 |
typedef void (* FreeMethod)(SObject *); |
|
70 |
||
71 |
/**
|
|
72 |
*
|
|
73 |
*/
|
|
74 |
typedef char * (* ToStringFunc)(SObject *); |
|
75 |
||
76 |
/**
|
|
|
107
by Gustav Hartvigsson
* Removed depricaded functions from SObject code. |
77 |
*
|
|
32
by Gustav Hartvigsson
* Added some compile options to the root CMakeLists.txt |
78 |
*/
|
79 |
typedef void (* MethodFunc)(SObject *); |
|
80 |
||
81 |
/**
|
|
82 |
*
|
|
83 |
*/
|
|
84 |
typedef int (* MethodFuncInt)(SObject *); |
|
85 |
||
|
45
by Gustav Hartvigsson
* Fixed indirect dependency in baseobject.h |
86 |
#define FREE_METHOD(k) (FreeMethod)k
|
87 |
#define TO_STRING_FUNC(k) (ToStringFunc)k
|
|
88 |
#define METHOD_FUNC(k) (MethodFunc)k
|
|
89 |
#define METHOD_FUNC_INT(k) (MethodFuncInt)k
|
|
|
32
by Gustav Hartvigsson
* Added some compile options to the root CMakeLists.txt |
90 |
|
|
23
by Gustav Hartvigsson
* Fixed some of the build warnings. |
91 |
#define S_OBJECT(k) (SObject *)k
|
|
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
92 |
#define S_OBJECT_CLASS(k) (SObjectClass *)k
|
|
23
by Gustav Hartvigsson
* Fixed some of the build warnings. |
93 |
|
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
94 |
struct
|
95 |
SObjectClass { |
|
|
32
by Gustav Hartvigsson
* Added some compile options to the root CMakeLists.txt |
96 |
MethodFunc initialize; |
97 |
MethodFunc deinitialize; |
|
98 |
FreeMethod free; |
|
99 |
MethodFuncInt ref; |
|
100 |
MethodFuncInt unref; |
|
101 |
MethodFuncInt get_refcount; |
|
102 |
ToStringFunc to_string; |
|
|
3
by Gustav Hartvigsson
Fixed a few things... |
103 |
};
|
104 |
||
|
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
105 |
|
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
106 |
struct
|
107 |
SObject { |
|
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
108 |
schar * name; /*< The name of the class.*/ |
|
48
by Gustav Hartvigsson
* Finnished SLinkedList. |
109 |
SObjectClass * base_class; /*< holds the reference to the class. */ |
110 |
SMap * callbacks; /*< This is what holds the callbacks. */ |
|
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
111 |
suint refcount; /*< The reference count. */ |
|
3
by Gustav Hartvigsson
Fixed a few things... |
112 |
};
|
113 |
||
|
1
by Gustav Hartvigsson
Initial Code. |
114 |
|
115 |
/* -----------------
|
|
116 |
* Helper functions...
|
|
117 |
* -----------------
|
|
118 |
*/
|
|
|
77
by Gustav Hartvigsson
* More work on SStream... Requiers Mutex suppert :-) |
119 |
|
|
1
by Gustav Hartvigsson
Initial Code. |
120 |
|
121 |
/**
|
|
|
5.1.1
by Gustav Hartvigsson
* Started work on making the code more prasable by DoxyGen. |
122 |
* This function is used to set the ref method.
|
|
107
by Gustav Hartvigsson
* Removed depricaded functions from SObject code. |
123 |
*
|
|
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
124 |
* @warning DO NOT USE THIS UNLESS YOU KNOW WHAT YOU ARE DOING.
|
|
1
by Gustav Hartvigsson
Initial Code. |
125 |
*/
|
|
119
by Gustav Hartvigsson
* added S_EXPERTED to public functions. |
126 |
S_EXPORTED
|
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
127 |
void
|
128 |
s_object_set_ref_method (SObject * self, MethodFuncInt method); |
|
|
1
by Gustav Hartvigsson
Initial Code. |
129 |
|
130 |
/**
|
|
|
5.1.1
by Gustav Hartvigsson
* Started work on making the code more prasable by DoxyGen. |
131 |
* This function is used to set the unref method.
|
|
107
by Gustav Hartvigsson
* Removed depricaded functions from SObject code. |
132 |
*
|
|
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
133 |
* @warning DO NOT USE THIS UNLESS YOU KNOW WHAT YOU ARE DOING.
|
|
1
by Gustav Hartvigsson
Initial Code. |
134 |
*/
|
|
119
by Gustav Hartvigsson
* added S_EXPERTED to public functions. |
135 |
S_EXPORTED
|
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
136 |
void
|
137 |
s_object_set_unref_method (SObject * self, MethodFuncInt method); |
|
|
1
by Gustav Hartvigsson
Initial Code. |
138 |
|
|
77
by Gustav Hartvigsson
* More work on SStream... Requiers Mutex suppert :-) |
139 |
/**
|
|
5.1.1
by Gustav Hartvigsson
* Started work on making the code more prasable by DoxyGen. |
140 |
* This function is used to set the get_refcount method.
|
|
107
by Gustav Hartvigsson
* Removed depricaded functions from SObject code. |
141 |
*
|
|
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
142 |
* @warning DO NOT USE THIS UNLESS YOU KNOW WHAT YOU ARE DOING.
|
|
1
by Gustav Hartvigsson
Initial Code. |
143 |
*/
|
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
144 |
void
|
145 |
s_object_set_get_refcount_method (SObject * self, MethodFuncInt method); |
|
|
1
by Gustav Hartvigsson
Initial Code. |
146 |
|
|
77
by Gustav Hartvigsson
* More work on SStream... Requiers Mutex suppert :-) |
147 |
/**
|
|
5.1.1
by Gustav Hartvigsson
* Started work on making the code more prasable by DoxyGen. |
148 |
* This function is used to set the to_string method.
|
|
1
by Gustav Hartvigsson
Initial Code. |
149 |
*/
|
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
150 |
void
|
151 |
s_object_set_to_string_method (SObject * self, ToStringFunc method); |
|
|
5.2.9
by Gustav Hartvigsson
* Added license to files |
152 |
|
|
22
by Gustav Hartvigsson
* Made code compile |
153 |
/**
|
154 |
*
|
|
155 |
*/
|
|
|
119
by Gustav Hartvigsson
* added S_EXPERTED to public functions. |
156 |
S_EXPORTED
|
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
157 |
void
|
158 |
s_object_set_free_method (SObject * self, MethodFunc method); |
|
|
22
by Gustav Hartvigsson
* Made code compile |
159 |
|
|
5.2.9
by Gustav Hartvigsson
* Added license to files |
160 |
|
161 |
/* concrete functions are defined in the C file.
|
|
|
1
by Gustav Hartvigsson
Initial Code. |
162 |
*/
|
163 |
||
164 |
/* ----------------------
|
|
165 |
* Base object functions.
|
|
166 |
* ----------------------
|
|
167 |
*/
|
|
168 |
||
|
77
by Gustav Hartvigsson
* More work on SStream... Requiers Mutex suppert :-) |
169 |
/**
|
170 |
* @brief
|
|
|
5.2.9
by Gustav Hartvigsson
* Added license to files |
171 |
* Initializes an SObject
|
|
107
by Gustav Hartvigsson
* Removed depricaded functions from SObject code. |
172 |
*
|
|
5.1.1
by Gustav Hartvigsson
* Started work on making the code more prasable by DoxyGen. |
173 |
* @param self The object to initialize.
|
|
107
by Gustav Hartvigsson
* Removed depricaded functions from SObject code. |
174 |
*
|
|
5.2.9
by Gustav Hartvigsson
* Added license to files |
175 |
* This function initializes an instance of the SObject, it also sets
|
|
5.1.1
by Gustav Hartvigsson
* Started work on making the code more prasable by DoxyGen. |
176 |
* the methods to be used with the object and sets the reference count to one.
|
|
1
by Gustav Hartvigsson
Initial Code. |
177 |
*/
|
|
119
by Gustav Hartvigsson
* added S_EXPERTED to public functions. |
178 |
S_EXPORTED
|
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
179 |
void
|
180 |
s_object_initialize (SObject * self, const char * name); |
|
|
1
by Gustav Hartvigsson
Initial Code. |
181 |
|
|
5.1.1
by Gustav Hartvigsson
* Started work on making the code more prasable by DoxyGen. |
182 |
/** @brief
|
|
1
by Gustav Hartvigsson
Initial Code. |
183 |
* This function creates a new base object.
|
|
107
by Gustav Hartvigsson
* Removed depricaded functions from SObject code. |
184 |
*
|
|
5.2.9
by Gustav Hartvigsson
* Added license to files |
185 |
* @return a new SObject
|
|
1
by Gustav Hartvigsson
Initial Code. |
186 |
*/
|
|
119
by Gustav Hartvigsson
* added S_EXPERTED to public functions. |
187 |
S_EXPORTED
|
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
188 |
SObject * |
189 |
s_object_new (); |
|
|
1
by Gustav Hartvigsson
Initial Code. |
190 |
|
191 |
/**
|
|
|
5.1.1
by Gustav Hartvigsson
* Started work on making the code more prasable by DoxyGen. |
192 |
* This function desensitizes/frees an object even if it is still referenced.
|
|
5.2.9
by Gustav Hartvigsson
* Added license to files |
193 |
* This is usually a bad idea, use s_object_unref () instead.
|
|
1
by Gustav Hartvigsson
Initial Code. |
194 |
*/
|
|
119
by Gustav Hartvigsson
* added S_EXPERTED to public functions. |
195 |
S_EXPORTED
|
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
196 |
void
|
197 |
s_object_free (SObject * self); |
|
|
1
by Gustav Hartvigsson
Initial Code. |
198 |
|
199 |
/**
|
|
200 |
* This function gets the class (which hold the object methods).
|
|
201 |
*/
|
|
|
119
by Gustav Hartvigsson
* added S_EXPERTED to public functions. |
202 |
S_EXPORTED
|
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
203 |
SObjectClass * |
204 |
s_object_get_class (SObject * self); |
|
|
1
by Gustav Hartvigsson
Initial Code. |
205 |
|
206 |
/**
|
|
207 |
* This function sets the instance class of an object.
|
|
208 |
*/
|
|
|
119
by Gustav Hartvigsson
* added S_EXPERTED to public functions. |
209 |
S_EXPORTED
|
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
210 |
void
|
211 |
s_object_set_class (SObject * self, SObjectClass * klass); |
|
|
1
by Gustav Hartvigsson
Initial Code. |
212 |
|
213 |
/**
|
|
214 |
* This function is used to decrese the reference count of an object.
|
|
|
5.1.1
by Gustav Hartvigsson
* Started work on making the code more prasable by DoxyGen. |
215 |
* When an object reaches zero, it will deinitialize the object using the
|
216 |
* objects deinitialize method.
|
|
|
107
by Gustav Hartvigsson
* Removed depricaded functions from SObject code. |
217 |
*
|
|
1
by Gustav Hartvigsson
Initial Code. |
218 |
* It returns the current (after change) reference count.
|
219 |
*/
|
|
|
119
by Gustav Hartvigsson
* added S_EXPERTED to public functions. |
220 |
S_EXPORTED
|
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
221 |
sint
|
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
222 |
s_object_unref (SObject * self); |
|
1
by Gustav Hartvigsson
Initial Code. |
223 |
|
224 |
/**
|
|
|
5.1.1
by Gustav Hartvigsson
* Started work on making the code more prasable by DoxyGen. |
225 |
* This function is used to increase the reference count of an object.
|
|
1
by Gustav Hartvigsson
Initial Code. |
226 |
*
|
227 |
* Returns the current (after change) reference count.
|
|
228 |
*/
|
|
|
119
by Gustav Hartvigsson
* added S_EXPERTED to public functions. |
229 |
S_EXPORTED
|
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
230 |
sint
|
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
231 |
s_object_ref (SObject * self); |
|
1
by Gustav Hartvigsson
Initial Code. |
232 |
|
233 |
/**
|
|
|
5.1.1
by Gustav Hartvigsson
* Started work on making the code more prasable by DoxyGen. |
234 |
* This function returns the current reference count without changing it.
|
|
1
by Gustav Hartvigsson
Initial Code. |
235 |
*/
|
|
119
by Gustav Hartvigsson
* added S_EXPERTED to public functions. |
236 |
S_EXPORTED
|
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
237 |
sint
|
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
238 |
s_object_get_refcount (SObject * self); |
|
1
by Gustav Hartvigsson
Initial Code. |
239 |
|
240 |
/**
|
|
|
5.1.1
by Gustav Hartvigsson
* Started work on making the code more prasable by DoxyGen. |
241 |
* This function returns a textual (string) that represents the object.
|
|
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
242 |
* The method can be set using s_object_set_to_string_method().
|
|
1
by Gustav Hartvigsson
Initial Code. |
243 |
*
|
244 |
* Note: The string that is returned must be freed.
|
|
245 |
*/
|
|
|
119
by Gustav Hartvigsson
* added S_EXPERTED to public functions. |
246 |
S_EXPORTED
|
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
247 |
schar * |
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
248 |
s_object_to_string (SObject * self); |
|
1
by Gustav Hartvigsson
Initial Code. |
249 |
|
|
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
250 |
/**
|
251 |
* @}
|
|
252 |
*/
|
|
253 |
||
|
110
by Gustav Hartvigsson
* added S_ prifix to my macros. I should not be a scrub. |
254 |
S_END_DECLS
|
|
1
by Gustav Hartvigsson
Initial Code. |
255 |
|
256 |
#endif
|