bzr branch
http://gegoxaren.bato24.eu/bzr/simpletypesystem/trunk
126.1.1
by Gustav Hartvigsson
* Using |
1 |
#pragma once
|
27
by Gustav Hartvigsson
* added skeleton for the SBox type. |
2 |
|
30
by Gustav Hartvigsson
* Made the code compile using CMake. |
3 |
#include <stdlib.h> |
4 |
#include <stdint.h> |
|
27
by Gustav Hartvigsson
* added skeleton for the SBox type. |
5 |
#include "defs.h" |
6 |
||
7 |
/** @file
|
|
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
8 |
* @defgroup Vectors Vectors
|
9 |
* @addtogroup Vectors
|
|
10 |
* @{
|
|
11 |
* Vectors are multi value structures that can be used when doing some types of
|
|
12 |
* maths.
|
|
27
by Gustav Hartvigsson
* added skeleton for the SBox type. |
13 |
*/
|
14 |
||
110
by Gustav Hartvigsson
* added S_ prifix to my macros. I should not be a scrub. |
15 |
S_BEGIN_DECLS
|
27
by Gustav Hartvigsson
* added skeleton for the SBox type. |
16 |
|
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
17 |
/**
|
27
by Gustav Hartvigsson
* added skeleton for the SBox type. |
18 |
* A Vector of three standard int values.
|
19 |
*
|
|
131.1.1
by Gustav Hatvigsson
* Made a generic vec3_new |
20 |
* A Vec3_32 is considerer a primitive type and as such has no ref/unref memory
|
27
by Gustav Hartvigsson
* added skeleton for the SBox type. |
21 |
* management and no vec_free function. You will have to do that yourself.
|
22 |
*
|
|
23 |
* @sa vec3_new
|
|
24 |
* @sa Vec3_16
|
|
25 |
*/
|
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
26 |
typedef struct |
131.1.1
by Gustav Hatvigsson
* Made a generic vec3_new |
27 |
Vec3_32 { |
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
28 |
sint a; |
29 |
sint b; |
|
30 |
sint c; |
|
131.1.1
by Gustav Hatvigsson
* Made a generic vec3_new |
31 |
} Vec3_32; |
27
by Gustav Hartvigsson
* added skeleton for the SBox type. |
32 |
|
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
33 |
/**
|
27
by Gustav Hartvigsson
* added skeleton for the SBox type. |
34 |
* A Vector of three 16 bit int values.
|
35 |
*
|
|
36 |
* @sa vec3_16_new
|
|
37 |
* @sa Vec3
|
|
38 |
*/
|
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
39 |
typedef struct |
40 |
Vec3_16 { |
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
41 |
sshort a; |
42 |
sshort b; |
|
43 |
sshort c; |
|
27
by Gustav Hartvigsson
* added skeleton for the SBox type. |
44 |
} Vec3_16; |
45 |
||
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
46 |
/**
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
47 |
*
|
48 |
* A Vec3_f is a vector of three 32bit precision floating point values.
|
|
49 |
*/
|
|
50 |
typedef struct |
|
51 |
Vec3_f { |
|
52 |
sfloat a; |
|
53 |
sfloat b; |
|
54 |
sfloat c; |
|
55 |
} Vec3_f; |
|
56 |
||
83
by Gustav Hartvigsson
* vec.h: |
57 |
#ifndef __MSC_VER
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
58 |
/**
|
59 |
* Add Vectors together, resulting in a new vector.
|
|
60 |
*
|
|
61 |
* The type of vector that is returned depends on the types that were put in.
|
|
62 |
*
|
|
63 |
* Due to the reflective way of these operations, many may just be inverses of
|
|
131.1.1
by Gustav Hatvigsson
* Made a generic vec3_new |
64 |
* others. IE: `vec3_add (Vec3_32 *, Vec3_16 *)` is the same as
|
65 |
* `vec3_add (Vec3_16 *, Vec3_32 *)`.
|
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
66 |
*/
|
84
by Gustav Hartvigsson
WOOPS! |
67 |
#define vec3_add(x, y) _Generic((x, y)\
|
131.1.1
by Gustav Hatvigsson
* Made a generic vec3_new |
68 |
Vec3_32 *: _Generic((y)\
|
69 |
Vec3_32 *: vec3_32_add_vec3_32\
|
|
70 |
Vec3_16 *: vec3_32_add_vec3_16_32\
|
|
71 |
Vec3_f *: vec3_32_add_vec3_f\
|
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
72 |
)\
|
73 |
Vec3_16 *: _Generic((y)\
|
|
131.1.1
by Gustav Hatvigsson
* Made a generic vec3_new |
74 |
Vec3_32 *: vec3_16_add_vec3_32\
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
75 |
Vec3_16 *: vec3_16_add_vec3_16\
|
76 |
Vec3_f *: vec3_16_add_vec3_f\
|
|
77 |
)\
|
|
78 |
Vec3_f *: _Generic((y)\
|
|
131.1.1
by Gustav Hatvigsson
* Made a generic vec3_new |
79 |
Vec3_32 *: vec3_f_add_vec3_32\
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
80 |
Vec3_16 *: vec3_f_add_vec3_16\
|
81 |
Vec3_f *: vec3_f_add_vec3_f\
|
|
82 |
)\
|
|
83 |
)(x,y)
|
|
131.1.1
by Gustav Hatvigsson
* Made a generic vec3_new |
84 |
|
85 |
||
86 |
/**
|
|
87 |
* A generic macro fo create vectors
|
|
88 |
*/
|
|
89 |
#define vec3_new(x, y) _Generic((x,y)\
|
|
90 |
sint: _Generic ((y)\
|
|
91 |
sint: vec3_32_new\
|
|
92 |
)\
|
|
93 |
sshort: _Generic ((y)\
|
|
94 |
sshort: vec3_16_new\
|
|
95 |
)\
|
|
96 |
sfloat: _Generic ((y)\
|
|
97 |
sfloat: vec_f_new\
|
|
98 |
)(x, y)
|
|
99 |
||
83
by Gustav Hartvigsson
* vec.h: |
100 |
#endif /* __MSC_VER */ |
101 |
||
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
102 |
#define vec_free(x) free (x)
|
103 |
||
104 |
||
105 |
||
106 |
/** @brief
|
|
131.1.1
by Gustav Hatvigsson
* Made a generic vec3_new |
107 |
* allocates and initialises a Vec3_32 pointer.
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
108 |
*
|
109 |
* @sa Vec3
|
|
110 |
*/
|
|
119
by Gustav Hartvigsson
* added S_EXPERTED to public functions. |
111 |
S_EXPORTED
|
131.1.1
by Gustav Hatvigsson
* Made a generic vec3_new |
112 |
Vec3_32 * |
113 |
vec3_32_new (sint a, |
|
114 |
sint b, |
|
115 |
sint c); |
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
116 |
|
117 |
/**
|
|
118 |
* Add Vector a to Vector
|
|
119 |
*/
|
|
119
by Gustav Hartvigsson
* added S_EXPERTED to public functions. |
120 |
S_EXPORTED
|
131.1.1
by Gustav Hatvigsson
* Made a generic vec3_new |
121 |
Vec3_32 * |
122 |
vec3_32_add_Vec3_32 (Vec3_32 * a, |
|
123 |
Vec3_32 * b); |
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
124 |
|
119
by Gustav Hartvigsson
* added S_EXPERTED to public functions. |
125 |
S_EXPORTED
|
131.1.1
by Gustav Hatvigsson
* Made a generic vec3_new |
126 |
Vec3_32 * |
127 |
vec3_32_add_vec3_16 (Vec3_32 * a, |
|
128 |
Vec3_16 * b); |
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
129 |
|
130 |
||
131 |
/**
|
|
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
132 |
* @brief
|
27
by Gustav Hartvigsson
* added skeleton for the SBox type. |
133 |
* allocates and initialises a Vec3_16 pointer.
|
134 |
*
|
|
135 |
* @sa Vec3_16
|
|
136 |
*/
|
|
119
by Gustav Hartvigsson
* added S_EXPERTED to public functions. |
137 |
S_EXPORTED
|
61
by Gustav Hartvigsson
* Made the code more easy to read. |
138 |
Vec3_16 * |
102
by Gustav Hartvigsson
* Finnished the Vectors... For the moment. |
139 |
vec3_16_new (sshort a, |
140 |
sshort b, |
|
141 |
sshort c); |
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
142 |
|
119
by Gustav Hartvigsson
* added S_EXPERTED to public functions. |
143 |
S_EXPORTED
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
144 |
Vec3_16 * |
102
by Gustav Hartvigsson
* Finnished the Vectors... For the moment. |
145 |
vec3_16_add_vec3_16 (Vec3_16 * a, |
146 |
Vec3_16 * b); |
|
147 |
||
119
by Gustav Hartvigsson
* added S_EXPERTED to public functions. |
148 |
S_EXPORTED
|
131.1.1
by Gustav Hatvigsson
* Made a generic vec3_new |
149 |
Vec3_32 * |
102
by Gustav Hartvigsson
* Finnished the Vectors... For the moment. |
150 |
vec3_16_add_vec3(Vec3_16 * a, |
131.1.1
by Gustav Hatvigsson
* Made a generic vec3_new |
151 |
Vec3_32 * b); |
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
152 |
|
153 |
||
154 |
/**
|
|
155 |
* Allocates and initialises a Vec3_f pointer.
|
|
156 |
*/
|
|
119
by Gustav Hartvigsson
* added S_EXPERTED to public functions. |
157 |
S_EXPORTED
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
158 |
Vec3_f * |
102
by Gustav Hartvigsson
* Finnished the Vectors... For the moment. |
159 |
vec3_f_new (sfloat a, |
160 |
sfloat b, |
|
161 |
sfloat c); |
|
162 |
||
119
by Gustav Hartvigsson
* added S_EXPERTED to public functions. |
163 |
S_EXPORTED
|
102
by Gustav Hartvigsson
* Finnished the Vectors... For the moment. |
164 |
Vec3_f * |
165 |
vec3_f_add_vec3_f (Vec3_f * a, |
|
166 |
Vec3_f * b); |
|
167 |
||
119
by Gustav Hartvigsson
* added S_EXPERTED to public functions. |
168 |
S_EXPORTED
|
102
by Gustav Hartvigsson
* Finnished the Vectors... For the moment. |
169 |
Vec3_f * |
131.1.1
by Gustav Hatvigsson
* Made a generic vec3_new |
170 |
vec3_f_add_Vec3_32 (Vec3_f * a, |
171 |
Vec3_32 * b); |
|
102
by Gustav Hartvigsson
* Finnished the Vectors... For the moment. |
172 |
|
119
by Gustav Hartvigsson
* added S_EXPERTED to public functions. |
173 |
S_EXPORTED
|
102
by Gustav Hartvigsson
* Finnished the Vectors... For the moment. |
174 |
Vec3_f * |
175 |
vec3_f_add_vec3_16 (Vec3_f * a, |
|
176 |
Vec3_16 * b); |
|
177 |
||
119
by Gustav Hartvigsson
* added S_EXPERTED to public functions. |
178 |
S_EXPORTED
|
102
by Gustav Hartvigsson
* Finnished the Vectors... For the moment. |
179 |
Vec3_f * |
131.1.1
by Gustav Hatvigsson
* Made a generic vec3_new |
180 |
vec3_add_vec3_f (Vec3_32 * a, |
102
by Gustav Hartvigsson
* Finnished the Vectors... For the moment. |
181 |
Vec3_f * b); |
182 |
||
119
by Gustav Hartvigsson
* added S_EXPERTED to public functions. |
183 |
S_EXPORTED
|
102
by Gustav Hartvigsson
* Finnished the Vectors... For the moment. |
184 |
Vec3_f * |
185 |
vec3_16_add_vec3_f (Vec3_16 * a, |
|
186 |
Vec3_f * b); |
|
83
by Gustav Hartvigsson
* vec.h: |
187 |
|
72
by Gustav Hartvigsson
* Added our own types for stability and shit and giggles. |
188 |
/** @} */
|
189 |
||
44
by Gustav Hartvigsson
* Started to structuce the dectumentation a little better. |
190 |
|
110
by Gustav Hartvigsson
* added S_ prifix to my macros. I should not be a scrub. |
191 |
S_END_DECLS
|