/simpletypesystem/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/simpletypesystem/trunk
5.2.7 by Gustav Hartvigsson
* Switched licence to a more permisive one.
1
/*
2
*/
3
4
#ifndef __H_DEFS__
5
#define __H_DEFS__
6
23 by Gustav Hartvigsson
* Fixed some of the build warnings.
7
#include <limits.h>
48 by Gustav Hartvigsson
* Finnished SLinkedList.
8
#include <stddef.h>
23 by Gustav Hartvigsson
* Fixed some of the build warnings.
9
5.2.7 by Gustav Hartvigsson
* Switched licence to a more permisive one.
10
/** @file
11
 * 
12
 */
13
14
#ifdef __cplusplus
15
#define BEGIN_DECLS extern "C" {
16
#else
17
#define BEGIN_DECLS
18
#endif /*__cplusplus*/
19
20
21
#ifdef __cplusplus
22
#define END_DECLS }
23
#else
24
#define END_DECLS
25
#endif /* __cplusplus */
26
26 by Gustav Hartvigsson
* Added something to config.h.in, still not sure how it cmake works.
27
BEGIN_DECLS
28
57 by Gustav Hartvigsson
* Tested print_backtrace() macro using MingW and Wine... Still needs testing on a real windows system.
29
#include <stdio.h>
30
#include <stdlib.h>
31
32
23 by Gustav Hartvigsson
* Fixed some of the build warnings.
33
#ifndef FALSE
46 by Gustav Hartvigsson
* Renamed DynamicArray to SDynamicArray.
34
/**
35
 * FALSE has the absolute value of 0, it is used in as a way to represet a false
36
 * value. A "not" value.
37
 */
23 by Gustav Hartvigsson
* Fixed some of the build warnings.
38
#define FALSE 0
39
#endif
40
41
#ifndef TRUE
46 by Gustav Hartvigsson
* Renamed DynamicArray to SDynamicArray.
42
 /**
43
  * TRUE represets a value that is true. A value that is "not false".
44
  */
45
#define TRUE (!FALSE)
23 by Gustav Hartvigsson
* Fixed some of the build warnings.
46
#endif
47
53 by Gustav Hartvigsson
* Finnished up s_map_add () ???
48
#define S_POINTER_TO_HASH_T(p) ((hash_t)(unsigned long) p)
49
46 by Gustav Hartvigsson
* Renamed DynamicArray to SDynamicArray.
50
/**
51
 * sboolean is the standard definition of a boolean value in SSTS.
52
 *
53
 * @sa TRUE
54
 * @sa FALSE
55
 *
56
 * @note
57
 * This is the way it is done in GLib, so it is done here too.
58
 */
59
typedef int sboolean;
60
43 by Gustav Hartvigsson
* Code cleanup
61
/** hash type  */
48 by Gustav Hartvigsson
* Finnished SLinkedList.
62
typedef size_t hash_t;
23 by Gustav Hartvigsson
* Fixed some of the build warnings.
63
43 by Gustav Hartvigsson
* Code cleanup
64
/** spointer is a convinience typedef of void * */
23 by Gustav Hartvigsson
* Fixed some of the build warnings.
65
typedef void* spointer;
66
48 by Gustav Hartvigsson
* Finnished SLinkedList.
67
/** sconstpointer is a convinience typedef of const void * */
68
typedef const void* sconstpointer;
46 by Gustav Hartvigsson
* Renamed DynamicArray to SDynamicArray.
69
70
/**
65 by Gustav Hartvigsson
* added uchar to defs.h
71
 * uchar is the representation for use with wide unicode strings and what not.
72
 * 
73
 * The rationell for using char32_t as the unicode wide char instead of
74
 * wchar_t is that wchar_t's size depends on the imprementation, compiler,
75
 * and system.
76
 *
77
 * To make the wide strings actually work as they should, even over network or
78
 * other communication we set this as the standard for the uchar.
79
 */
80
typedef char32_t uchar;
81
82
/**
46 by Gustav Hartvigsson
* Renamed DynamicArray to SDynamicArray.
83
 * Represents different types of objects.
84
 *
85
 * @se STypeName
86
 */
23 by Gustav Hartvigsson
* Fixed some of the build warnings.
87
typedef enum {
43 by Gustav Hartvigsson
* Code cleanup
88
  S_TYPE_NONE = 0,
89
  S_TYPE_INT,
49 by Gustav Hartvigsson
* started work SBox (Untested).
90
  S_TYPE_LONG,
91
  S_TYPE_SHORT,
43 by Gustav Hartvigsson
* Code cleanup
92
  S_TYPE_CHAR,
49 by Gustav Hartvigsson
* started work SBox (Untested).
93
  S_TYPE_WCHAR,
94
  S_TYPE_UINT,
95
  S_TYPE_ULONG,
96
  S_TYPE_USHORT,
43 by Gustav Hartvigsson
* Code cleanup
97
  S_TYPE_BOOLEAN,
49 by Gustav Hartvigsson
* started work SBox (Untested).
98
  S_TYPE_STRING,
99
  S_TYPE_WSTRING,
43 by Gustav Hartvigsson
* Code cleanup
100
  S_TYPE_UNUSED_0,
101
  S_TYPE_UNUSED_1,
102
  S_TYPE_UNUSED_2,
49 by Gustav Hartvigsson
* started work SBox (Untested).
103
  S_TYPE_POINTER,
43 by Gustav Hartvigsson
* Code cleanup
104
  S_TYPE_OBJECT,
105
  S_TYPE_INVALID
106
} SType;
5.2.7 by Gustav Hartvigsson
* Switched licence to a more permisive one.
107
46 by Gustav Hartvigsson
* Renamed DynamicArray to SDynamicArray.
108
/** @brief
109
 * The names of the SType's
49 by Gustav Hartvigsson
* started work SBox (Untested).
110
 *
111
 * 
46 by Gustav Hartvigsson
* Renamed DynamicArray to SDynamicArray.
112
 */
50 by Gustav Hartvigsson
* Added a bindings friendly way of getting the SType name.
113
static char * STypeName[] __attribute__((unused)) = {
46 by Gustav Hartvigsson
* Renamed DynamicArray to SDynamicArray.
114
  "NONE",
115
  "INT",
49 by Gustav Hartvigsson
* started work SBox (Untested).
116
  "LONG",
117
  "SHORT",
46 by Gustav Hartvigsson
* Renamed DynamicArray to SDynamicArray.
118
  "CHAR",
49 by Gustav Hartvigsson
* started work SBox (Untested).
119
  "WCHAR",
120
  "UINT",
121
  "ULONG",
122
  "USHORT"
46 by Gustav Hartvigsson
* Renamed DynamicArray to SDynamicArray.
123
  "BOOLEAN",
49 by Gustav Hartvigsson
* started work SBox (Untested).
124
  "STRING",
125
  "WSTRING",
126
  "UNUSED_0/INVALID",
127
  "UNUSED_1/INVALID",
128
  "UNUSED_2/INVALID",
129
  "POINTER",
46 by Gustav Hartvigsson
* Renamed DynamicArray to SDynamicArray.
130
  "OBJECT",
131
  "INVALID",
132
  0x0,
133
  0x0,
43 by Gustav Hartvigsson
* Code cleanup
134
};
26 by Gustav Hartvigsson
* Added something to config.h.in, still not sure how it cmake works.
135
50 by Gustav Hartvigsson
* Added a bindings friendly way of getting the SType name.
136
/**
137
 * @brief Get the name of the SType.
138
 *
139
 * For use in bindings.
140
 */
61 by Gustav Hartvigsson
* Made the code more easy to read.
141
char *
142
s_type_get_name (SType k);
46 by Gustav Hartvigsson
* Renamed DynamicArray to SDynamicArray.
143
26 by Gustav Hartvigsson
* Added something to config.h.in, still not sure how it cmake works.
144
/* Colour definitions for console prints */
145
#define RESET   "\033[0m"
146
#define BLACK   "\033[30m"      /* Black */
147
#define RED     "\033[31m"      /* Red */
148
#define GREEN   "\033[32m"      /* Green */
149
#define YELLOW  "\033[33m"      /* Yellow */
150
#define BLUE    "\033[34m"      /* Blue */
151
#define MAGENTA "\033[35m"      /* Magenta */
152
#define CYAN    "\033[36m"      /* Cyan */
153
#define WHITE   "\033[37m"      /* White */
154
#define BOLDBLACK   "\033[1m\033[30m"      /* Bold Black */
155
#define BOLDRED     "\033[1m\033[31m"      /* Bold Red */
156
#define BOLDGREEN   "\033[1m\033[32m"      /* Bold Green */
157
#define BOLDYELLOW  "\033[1m\033[33m"      /* Bold Yellow */
158
#define BOLDBLUE    "\033[1m\033[34m"      /* Bold Blue */
159
#define BOLDMAGENTA "\033[1m\033[35m"      /* Bold Magenta */
160
#define BOLDCYAN    "\033[1m\033[36m"      /* Bold Cyan */
161
#define BOLDWHITE   "\033[1m\033[37m"      /* Bold White */
162
33 by Gustav Hartvigsson
* made test_macros.h a lil' bit more portable
163
26 by Gustav Hartvigsson
* Added something to config.h.in, still not sure how it cmake works.
164
END_DECLS
165
5.2.7 by Gustav Hartvigsson
* Switched licence to a more permisive one.
166
#endif