Merge pull request #3 from dopefishh/standard-maybe
[CleanReadLine.git] / Clean System Files / Clean.h
1
2 #define Clean(a)
3
4 typedef struct clean_string *CleanString;
5
6 /* a string in Clean is:
7 struct clean_string {
8 size_t clean_string_length;
9 char clean_string_characters[clean_string_length];
10 };
11 The string does not end with a '\0' !
12 */
13
14 #ifndef _WIN64
15
16 /* CleanStringLength(clean_string) returns the length of the clean_string in characters */
17 #define CleanStringLength(clean_string) (*(unsigned long *)(clean_string))
18
19 /* CleanStringCharacters(clean_string) returns a pointer to the characters of the clean_string */
20 #define CleanStringCharacters(clean_string) ((char*)(1+(unsigned long *)(clean_string)))
21
22 /* CleanStringSizeInts(string_length) return size of *CleanString in integers */
23 #define CleanStringSizeInts(string_length) (1+(((unsigned long)(string_length)+(sizeof(unsigned long)-1))>>(1+(sizeof(unsigned long)>>2))))
24
25 /* CleanStringVariable(clean_string,string_length) defines variable clean_string with length string_length,
26 before using the clean_string variable, cast to CleanString, except for the macros above */
27 #define CleanStringVariable(clean_string,string_length) unsigned long clean_string[CleanStringSizeInts(string_length)]
28
29 /* CleanStringSizeBytes(string_length) return size of *CleanString in bytes */
30 #define CleanStringSizeBytes(string_length) ((sizeof(unsigned long)<<1)+(((unsigned long)(string_length)+(sizeof(unsigned long)-1)) & -(sizeof(unsigned long))))
31
32 typedef long *CleanIntArray;
33
34 /* CleanIntArraySize(clean_array) returns the size (number of elements) of the clean_int_array */
35 #define CleanIntArraySize(clean_int_array) (((unsigned long *)(clean_int_array))[-2])
36
37 /* CleanRealArraySize(clean_real_array) returns the size (number of elements) of the clean_real_array */
38 #define CleanRealArraySize(clean_real_array) (((unsigned long *)(clean_real_array))[-2])
39
40 /* CleanCharArraySize(clean_char_array) returns the size (number of elements) of the clean_char_array */
41 #define CleanCharArraySize(clean_char_array) (((unsigned long *)(clean_char_array))[-1])
42
43 #else
44
45 /* CleanStringLength(clean_string) returns length of the clean_string in characters */
46 #define CleanStringLength(clean_string) (*(unsigned __int64 *)(clean_string))
47
48 /* CleanStringCharacters(clean_string) returns a pointer to the characters of the clean_string */
49 #define CleanStringCharacters(clean_string) ((char*)(1+(unsigned __int64 *)(clean_string)))
50
51 /* CleanStringSizeInts(string_length) return size of *CleanString in integers */
52 #define CleanStringSizeInts(string_length) (1+(((unsigned __int64)(string_length)+7)>>3))
53
54 /* CleanStringVariable(clean_string,string_length) defines variable clean_string with length string_length,
55 before using the clean_string variable, cast to CleanString, except for the macros above */
56 #define CleanStringVariable(clean_string,string_length) unsigned __int64 clean_string[CleanStringSizeInts(string_length)]
57
58 /* CleanStringSizeBytes(string_length) return size of *CleanString in bytes */
59 #define CleanStringSizeBytes(string_length) (8+(((unsigned __int64)(string_length)+7) & -8))
60
61 typedef __int64 *CleanIntArray;
62
63 /* CleanIntArraySize(clean_array) returns the size (number of elements) of the clean_int_array */
64 #define CleanIntArraySize(clean_int_array) (((unsigned __int64 *)(clean_int_array))[-2])
65
66 /* CleanRealArraySize(clean_real_array) returns the size (number of elements) of the clean_real_array */
67 #define CleanRealArraySize(clean_real_array) (((unsigned __int64 *)(clean_real_array))[-2])
68
69 /* CleanCharArraySize(clean_char_array) returns the size (number of elements) of the clean_char_array */
70 #define CleanCharArraySize(clean_char_array) (((unsigned __int64 *)(clean_char_array))[-1])
71
72 #endif
73
74 typedef double *CleanRealArray;
75
76 typedef unsigned char *CleanCharArray;