bzr branch
http://gegoxaren.bato24.eu/bzr/simpletypesystem/trunk
|
5.2.7
by Gustav Hartvigsson
* Switched licence to a more permisive one. |
1 |
/*
|
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.
|
|
21 |
*/
|
|
|
3
by Gustav Hartvigsson
Fixed a few things... |
22 |
|
23 |
#include "Error.h" |
|
24 |
#include <stdlib.h> |
|
25 |
#include <string.h> |
|
26 |
#include <stdio.h> |
|
|
22
by Gustav Hartvigsson
* Made code compile |
27 |
#include <assert.h> |
|
39
by Gustav Hartvigsson
* Added "check" target for testing. |
28 |
#include "utils.h" |
|
100
by Gustav Hartvigsson
* Fixed README. |
29 |
#include "LinkedList.h" |
|
39
by Gustav Hartvigsson
* Added "check" target for testing. |
30 |
|
|
100
by Gustav Hartvigsson
* Fixed README. |
31 |
typedef struct SErrorItem { |
|
81
by Gustav Hartvigsson
* Re arranged members of structs to prevent struct fragmentation and padding. |
32 |
schar * message; |
|
5.2.2
by Gustav Hartvigsson
Made sure -- using valgrind -- that the SBaseObjectInstance and |
33 |
SErrorType error_type; |
|
100
by Gustav Hartvigsson
* Fixed README. |
34 |
} SErrorItem; |
35 |
||
36 |
struct SError { |
|
37 |
SLinkedList * error_list; /* SLinkedList<SErrorItem *> */ |
|
|
3
by Gustav Hartvigsson
Fixed a few things... |
38 |
};
|
39 |
||
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
40 |
schar * |
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
41 |
error_to_string_method (SObject * self); |
42 |
void
|
|
43 |
error_free_method (SError * self); |
|
|
3
by Gustav Hartvigsson
Fixed a few things... |
44 |
|
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
45 |
SError * |
46 |
s_error_new (SErrorType error, char * message) { |
|
|
5.2.1
by Gustav Hartvigsson
Started work on the Map (SMap) data structure. |
47 |
SError * self = malloc (sizeof (SError)); |
|
100
by Gustav Hartvigsson
* Fixed README. |
48 |
|
49 |
|
|
50 |
|
|
|
3
by Gustav Hartvigsson
Fixed a few things... |
51 |
return self; |
52 |
}
|
|
53 |
||
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
54 |
void
|
|
100
by Gustav Hartvigsson
* Fixed README. |
55 |
error_free (SError * self) { |
|
101
by Gustav Hartvigsson
* Re-Added the inlines... |
56 |
s_linked_list_free (self->error_list, TRUE); |
|
100
by Gustav Hartvigsson
* Fixed README. |
57 |
free (self); |
|
3
by Gustav Hartvigsson
Fixed a few things... |
58 |
}
|
59 |
||
|
100
by Gustav Hartvigsson
* Fixed README. |
60 |
#if 0
|
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
61 |
schar *
|
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
62 |
error_to_string_method (SObject * obj) {
|
|
49
by Gustav Hartvigsson
* started work SBox (Untested). |
63 |
SError * self = S_ERROR (obj);
|
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
64 |
schar * ret_val = NULL;
|
65 |
schar * error_type_str = NULL;
|
|
|
39
by Gustav Hartvigsson
* Added "check" target for testing. |
66 |
error_type_str = s_string_new (SErrorTypeName[self->priv->error_type]);
|
67 |
|
|
68 |
ret_val = s_string_new_fmt ("Error: %s, Message: %s", error_type_str, self->priv->message);
|
|
|
3
by Gustav Hartvigsson
Fixed a few things... |
69 |
free (error_type_str);
|
70 |
return ret_val;
|
|
71 |
}
|
|
|
100
by Gustav Hartvigsson
* Fixed README. |
72 |
#endif
|
|
3
by Gustav Hartvigsson
Fixed a few things... |
73 |
|
74 |
||
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
75 |
schar * |
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
76 |
s_error_get_name (SErrorType k) { |
|
49
by Gustav Hartvigsson
* started work SBox (Untested). |
77 |
return SErrorTypeName[k]; |
78 |
}
|
|
79 |