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 |
||
126.1.1
by Gustav Hartvigsson
* Using |
25 |
#pragma once
|
1
by Gustav Hartvigsson
Initial Code. |
26 |
|
45
by Gustav Hartvigsson
* Fixed indirect dependency in baseobject.h |
27 |
#include "defs.h" |
28 |
#include "utils.h" |
|
47
by Gustav Hartvigsson
* Added a few skeletal functions to Callback.h |
29 |
#include "Map.h" |
45
by Gustav Hartvigsson
* Fixed indirect dependency in baseobject.h |
30 |
|
110
by Gustav Hartvigsson
* added S_ prifix to my macros. I should not be a scrub. |
31 |
S_BEGIN_DECLS
|
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
32 |
|
5.1.4
by Gustav Hartvigsson
* Added a comment to baseoject.h describing what the file does. |
33 |
/** @file
|
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
34 |
* @defgroup SObject SObject
|
35 |
* @addtogroup SObject SObject
|
|
36 |
* @{
|
|
5.2.9
by Gustav Hartvigsson
* Added license to files |
37 |
* An SObject represents the base of the Super Simple Type System.
|
107
by Gustav Hartvigsson
* Removed depricaded functions from SObject code. |
38 |
*
|
5.1.4
by Gustav Hartvigsson
* Added a comment to baseoject.h describing what the file does. |
39 |
* Almost all other data structures in this library are children to this object
|
40 |
* type.
|
|
41 |
*
|
|
5.2.9
by Gustav Hartvigsson
* Added license to files |
42 |
* 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. |
43 |
* reference counting of objects via built in functions.
|
62
by Gustav Hartvigsson
* General documentation clean up. |
44 |
*
|
45 |
* @section Signals/Callbacks
|
|
46 |
* @par @c notify
|
|
47 |
* This signal is envoked when a propertiy is changed in an SObject.
|
|
48 |
* @endpar
|
|
5.1.4
by Gustav Hartvigsson
* Added a comment to baseoject.h describing what the file does. |
49 |
*/
|
50 |
||
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
51 |
/**
|
52 |
* The class holds all the "virtual" functions, also knows as methods
|
|
53 |
* that are to be used with the object.
|
|
107
by Gustav Hartvigsson
* Removed depricaded functions from SObject code. |
54 |
*
|
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
55 |
*/
|
56 |
typedef struct SObjectClass SObjectClass; |
|
57 |
||
58 |
/**
|
|
59 |
* The instance holds the data that is associated with the object.
|
|
60 |
* it also holds a pointer to the class of the object.
|
|
107
by Gustav Hartvigsson
* Removed depricaded functions from SObject code. |
61 |
*
|
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
62 |
*/
|
63 |
typedef struct SObject SObject; |
|
64 |
||
32
by Gustav Hartvigsson
* Added some compile options to the root CMakeLists.txt |
65 |
/**
|
66 |
*
|
|
67 |
*/
|
|
68 |
typedef void (* FreeMethod)(SObject *); |
|
69 |
||
70 |
/**
|
|
71 |
*
|
|
72 |
*/
|
|
73 |
typedef char * (* ToStringFunc)(SObject *); |
|
74 |
||
75 |
/**
|
|
107
by Gustav Hartvigsson
* Removed depricaded functions from SObject code. |
76 |
*
|
32
by Gustav Hartvigsson
* Added some compile options to the root CMakeLists.txt |
77 |
*/
|
78 |
typedef void (* MethodFunc)(SObject *); |
|
79 |
||
80 |
/**
|
|
81 |
*
|
|
82 |
*/
|
|
83 |
typedef int (* MethodFuncInt)(SObject *); |
|
84 |
||
45
by Gustav Hartvigsson
* Fixed indirect dependency in baseobject.h |
85 |
#define FREE_METHOD(k) (FreeMethod)k
|
86 |
#define TO_STRING_FUNC(k) (ToStringFunc)k
|
|
87 |
#define METHOD_FUNC(k) (MethodFunc)k
|
|
88 |
#define METHOD_FUNC_INT(k) (MethodFuncInt)k
|
|
32
by Gustav Hartvigsson
* Added some compile options to the root CMakeLists.txt |
89 |
|
23
by Gustav Hartvigsson
* Fixed some of the build warnings. |
90 |
#define S_OBJECT(k) (SObject *)k
|
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
91 |
#define S_OBJECT_CLASS(k) (SObjectClass *)k
|
23
by Gustav Hartvigsson
* Fixed some of the build warnings. |
92 |
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
93 |
struct
|
94 |
SObjectClass { |
|
32
by Gustav Hartvigsson
* Added some compile options to the root CMakeLists.txt |
95 |
MethodFunc initialize; |
96 |
MethodFunc deinitialize; |
|
97 |
FreeMethod free; |
|
98 |
MethodFuncInt ref; |
|
99 |
MethodFuncInt unref; |
|
100 |
MethodFuncInt get_refcount; |
|
101 |
ToStringFunc to_string; |
|
3
by Gustav Hartvigsson
Fixed a few things... |
102 |
};
|
103 |
||
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
104 |
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
105 |
struct
|
106 |
SObject { |
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
107 |
schar * name; /*< The name of the class.*/ |
48
by Gustav Hartvigsson
* Finnished SLinkedList. |
108 |
SObjectClass * base_class; /*< holds the reference to the class. */ |
109 |
SMap * callbacks; /*< This is what holds the callbacks. */ |
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
110 |
suint refcount; /*< The reference count. */ |
3
by Gustav Hartvigsson
Fixed a few things... |
111 |
};
|
112 |
||
1
by Gustav Hartvigsson
Initial Code. |
113 |
|
114 |
/* -----------------
|
|
115 |
* Helper functions...
|
|
116 |
* -----------------
|
|
117 |
*/
|
|
77
by Gustav Hartvigsson
* More work on SStream... Requiers Mutex suppert :-) |
118 |
|
1
by Gustav Hartvigsson
Initial Code. |
119 |
|
120 |
/**
|
|
5.1.1
by Gustav Hartvigsson
* Started work on making the code more prasable by DoxyGen. |
121 |
* This function is used to set the ref method.
|
107
by Gustav Hartvigsson
* Removed depricaded functions from SObject code. |
122 |
*
|
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
123 |
* @warning DO NOT USE THIS UNLESS YOU KNOW WHAT YOU ARE DOING.
|
1
by Gustav Hartvigsson
Initial Code. |
124 |
*/
|
119
by Gustav Hartvigsson
* added S_EXPERTED to public functions. |
125 |
S_EXPORTED
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
126 |
void
|
127 |
s_object_set_ref_method (SObject * self, MethodFuncInt method); |
|
1
by Gustav Hartvigsson
Initial Code. |
128 |
|
129 |
/**
|
|
5.1.1
by Gustav Hartvigsson
* Started work on making the code more prasable by DoxyGen. |
130 |
* This function is used to set the unref method.
|
107
by Gustav Hartvigsson
* Removed depricaded functions from SObject code. |
131 |
*
|
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
132 |
* @warning DO NOT USE THIS UNLESS YOU KNOW WHAT YOU ARE DOING.
|
1
by Gustav Hartvigsson
Initial Code. |
133 |
*/
|
119
by Gustav Hartvigsson
* added S_EXPERTED to public functions. |
134 |
S_EXPORTED
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
135 |
void
|
136 |
s_object_set_unref_method (SObject * self, MethodFuncInt method); |
|
1
by Gustav Hartvigsson
Initial Code. |
137 |
|
77
by Gustav Hartvigsson
* More work on SStream... Requiers Mutex suppert :-) |
138 |
/**
|
5.1.1
by Gustav Hartvigsson
* Started work on making the code more prasable by DoxyGen. |
139 |
* This function is used to set the get_refcount method.
|
107
by Gustav Hartvigsson
* Removed depricaded functions from SObject code. |
140 |
*
|
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
141 |
* @warning DO NOT USE THIS UNLESS YOU KNOW WHAT YOU ARE DOING.
|
1
by Gustav Hartvigsson
Initial Code. |
142 |
*/
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
143 |
void
|
144 |
s_object_set_get_refcount_method (SObject * self, MethodFuncInt method); |
|
1
by Gustav Hartvigsson
Initial Code. |
145 |
|
77
by Gustav Hartvigsson
* More work on SStream... Requiers Mutex suppert :-) |
146 |
/**
|
5.1.1
by Gustav Hartvigsson
* Started work on making the code more prasable by DoxyGen. |
147 |
* This function is used to set the to_string method.
|
1
by Gustav Hartvigsson
Initial Code. |
148 |
*/
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
149 |
void
|
150 |
s_object_set_to_string_method (SObject * self, ToStringFunc method); |
|
5.2.9
by Gustav Hartvigsson
* Added license to files |
151 |
|
22
by Gustav Hartvigsson
* Made code compile |
152 |
/**
|
153 |
*
|
|
154 |
*/
|
|
119
by Gustav Hartvigsson
* added S_EXPERTED to public functions. |
155 |
S_EXPORTED
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
156 |
void
|
157 |
s_object_set_free_method (SObject * self, MethodFunc method); |
|
22
by Gustav Hartvigsson
* Made code compile |
158 |
|
5.2.9
by Gustav Hartvigsson
* Added license to files |
159 |
|
160 |
/* concrete functions are defined in the C file.
|
|
1
by Gustav Hartvigsson
Initial Code. |
161 |
*/
|
162 |
||
163 |
/* ----------------------
|
|
164 |
* Base object functions.
|
|
165 |
* ----------------------
|
|
166 |
*/
|
|
167 |
||
77
by Gustav Hartvigsson
* More work on SStream... Requiers Mutex suppert :-) |
168 |
/**
|
169 |
* @brief
|
|
5.2.9
by Gustav Hartvigsson
* Added license to files |
170 |
* Initializes an SObject
|
107
by Gustav Hartvigsson
* Removed depricaded functions from SObject code. |
171 |
*
|
5.1.1
by Gustav Hartvigsson
* Started work on making the code more prasable by DoxyGen. |
172 |
* @param self The object to initialize.
|
107
by Gustav Hartvigsson
* Removed depricaded functions from SObject code. |
173 |
*
|
5.2.9
by Gustav Hartvigsson
* Added license to files |
174 |
* 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. |
175 |
* the methods to be used with the object and sets the reference count to one.
|
1
by Gustav Hartvigsson
Initial Code. |
176 |
*/
|
119
by Gustav Hartvigsson
* added S_EXPERTED to public functions. |
177 |
S_EXPORTED
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
178 |
void
|
179 |
s_object_initialize (SObject * self, const char * name); |
|
1
by Gustav Hartvigsson
Initial Code. |
180 |
|
5.1.1
by Gustav Hartvigsson
* Started work on making the code more prasable by DoxyGen. |
181 |
/** @brief
|
1
by Gustav Hartvigsson
Initial Code. |
182 |
* This function creates a new base object.
|
107
by Gustav Hartvigsson
* Removed depricaded functions from SObject code. |
183 |
*
|
5.2.9
by Gustav Hartvigsson
* Added license to files |
184 |
* @return a new SObject
|
1
by Gustav Hartvigsson
Initial Code. |
185 |
*/
|
119
by Gustav Hartvigsson
* added S_EXPERTED to public functions. |
186 |
S_EXPORTED
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
187 |
SObject * |
188 |
s_object_new (); |
|
1
by Gustav Hartvigsson
Initial Code. |
189 |
|
190 |
/**
|
|
5.1.1
by Gustav Hartvigsson
* Started work on making the code more prasable by DoxyGen. |
191 |
* This function desensitizes/frees an object even if it is still referenced.
|
5.2.9
by Gustav Hartvigsson
* Added license to files |
192 |
* This is usually a bad idea, use s_object_unref () instead.
|
1
by Gustav Hartvigsson
Initial Code. |
193 |
*/
|
119
by Gustav Hartvigsson
* added S_EXPERTED to public functions. |
194 |
S_EXPORTED
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
195 |
void
|
196 |
s_object_free (SObject * self); |
|
1
by Gustav Hartvigsson
Initial Code. |
197 |
|
198 |
/**
|
|
199 |
* This function gets the class (which hold the object methods).
|
|
200 |
*/
|
|
119
by Gustav Hartvigsson
* added S_EXPERTED to public functions. |
201 |
S_EXPORTED
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
202 |
SObjectClass * |
203 |
s_object_get_class (SObject * self); |
|
1
by Gustav Hartvigsson
Initial Code. |
204 |
|
205 |
/**
|
|
206 |
* This function sets the instance class of an object.
|
|
207 |
*/
|
|
119
by Gustav Hartvigsson
* added S_EXPERTED to public functions. |
208 |
S_EXPORTED
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
209 |
void
|
210 |
s_object_set_class (SObject * self, SObjectClass * klass); |
|
1
by Gustav Hartvigsson
Initial Code. |
211 |
|
212 |
/**
|
|
213 |
* 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. |
214 |
* When an object reaches zero, it will deinitialize the object using the
|
215 |
* objects deinitialize method.
|
|
107
by Gustav Hartvigsson
* Removed depricaded functions from SObject code. |
216 |
*
|
1
by Gustav Hartvigsson
Initial Code. |
217 |
* It returns the current (after change) reference count.
|
218 |
*/
|
|
119
by Gustav Hartvigsson
* added S_EXPERTED to public functions. |
219 |
S_EXPORTED
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
220 |
sint
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
221 |
s_object_unref (SObject * self); |
1
by Gustav Hartvigsson
Initial Code. |
222 |
|
223 |
/**
|
|
5.1.1
by Gustav Hartvigsson
* Started work on making the code more prasable by DoxyGen. |
224 |
* This function is used to increase the reference count of an object.
|
1
by Gustav Hartvigsson
Initial Code. |
225 |
*
|
226 |
* Returns the current (after change) reference count.
|
|
227 |
*/
|
|
119
by Gustav Hartvigsson
* added S_EXPERTED to public functions. |
228 |
S_EXPORTED
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
229 |
sint
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
230 |
s_object_ref (SObject * self); |
1
by Gustav Hartvigsson
Initial Code. |
231 |
|
232 |
/**
|
|
5.1.1
by Gustav Hartvigsson
* Started work on making the code more prasable by DoxyGen. |
233 |
* This function returns the current reference count without changing it.
|
1
by Gustav Hartvigsson
Initial Code. |
234 |
*/
|
119
by Gustav Hartvigsson
* added S_EXPERTED to public functions. |
235 |
S_EXPORTED
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
236 |
sint
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
237 |
s_object_get_refcount (SObject * self); |
1
by Gustav Hartvigsson
Initial Code. |
238 |
|
239 |
/**
|
|
5.1.1
by Gustav Hartvigsson
* Started work on making the code more prasable by DoxyGen. |
240 |
* This function returns a textual (string) that represents the object.
|
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
241 |
* The method can be set using s_object_set_to_string_method().
|
1
by Gustav Hartvigsson
Initial Code. |
242 |
*
|
243 |
* Note: The string that is returned must be freed.
|
|
244 |
*/
|
|
119
by Gustav Hartvigsson
* added S_EXPERTED to public functions. |
245 |
S_EXPORTED
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
246 |
schar * |
61
by Gustav Hartvigsson
* Made the code more easy to read. |
247 |
s_object_to_string (SObject * self); |
1
by Gustav Hartvigsson
Initial Code. |
248 |
|
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
249 |
/**
|
250 |
* @}
|
|
251 |
*/
|
|
252 |
||
110
by Gustav Hartvigsson
* added S_ prifix to my macros. I should not be a scrub. |
253 |
S_END_DECLS
|