diff --git a/lib/std/compression/qoi.c3 b/lib/std/compression/qoi.c3 index 3c3358820..a3153de6f 100644 --- a/lib/std/compression/qoi.c3 +++ b/lib/std/compression/qoi.c3 @@ -7,7 +7,7 @@ const uint PIXELS_MAX = 400000000; Purely informative. It will be saved to the file header, but does not affect how chunks are en-/decoded. *> -enum QOIColorspace : const char +const enum QOIColorspace : char { <* sRGB with linear alpha *> SRGB = 0, @@ -21,7 +21,7 @@ enum QOIColorspace : const char AUTO can be used when decoding to automatically determine the channels from the file's header. *> -enum QOIChannels : const inline char +const enum QOIChannels : inline char { AUTO = 0, RGB = 3, diff --git a/lib/std/core/ansi.c3 b/lib/std/core/ansi.c3 index 68ffe7767..a10870b41 100644 --- a/lib/std/core/ansi.c3 +++ b/lib/std/core/ansi.c3 @@ -1,7 +1,7 @@ module std::core::string::ansi; import std::io; -enum Ansi : const inline String +const enum Ansi : inline String { RESET = "\e[0m", BOLD = "\e[1m", diff --git a/lib/std/crypto/aes.c3 b/lib/std/crypto/aes.c3 index b42a8a13d..e918b8d5b 100644 --- a/lib/std/crypto/aes.c3 +++ b/lib/std/crypto/aes.c3 @@ -56,9 +56,9 @@ enum BlockMode <* AES type: 128, 192 or 256 bits *> enum AesType : (AesKey key) { - AES128 = { 128, 16, 176, 4, 10 }, - AES192 = { 192, 24, 208, 6, 12 }, - AES256 = { 256, 32, 240, 8, 14 } + AES128 {{ 128, 16, 176, 4, 10 }}, + AES192 {{ 192, 24, 208, 6, 12 }}, + AES256 {{ 256, 32, 240, 8, 14 }} } struct AesKey diff --git a/lib/std/encoding/codepage.c3 b/lib/std/encoding/codepage.c3 index e3da89a2f..94f930dda 100644 --- a/lib/std/encoding/codepage.c3 +++ b/lib/std/encoding/codepage.c3 @@ -68,47 +68,47 @@ struct CodePageTable enum CodePage : (String name, CodePageTable* table) { - CP1250 = { "cp1250", &codepage::CP1250 }, - CP1251 = { "cp1251", &codepage::CP1251 }, - CP1252 = { "cp1252", &codepage::CP1252 }, - CP1253 = { "cp1253", &codepage::CP1253 }, - CP1254 = { "cp1254", &codepage::CP1254 }, - CP1255 = { "cp1255", &codepage::CP1255 }, - CP1256 = { "cp1256", &codepage::CP1256 }, - CP1257 = { "cp1257", &codepage::CP1257 }, - CP1258 = { "cp1258", &codepage::CP1258 }, - CP437 = { "cp437", &codepage::CP437 }, - CP737 = { "cp737", &codepage::CP737 }, - CP775 = { "cp775", &codepage::CP775 }, - CP850 = { "cp850", &codepage::CP850 }, - CP852 = { "cp852", &codepage::CP852 }, - CP855 = { "cp855", &codepage::CP855 }, - CP857 = { "cp857", &codepage::CP857 }, - CP860 = { "cp860", &codepage::CP860 }, - CP861 = { "cp861", &codepage::CP861 }, - CP862 = { "cp862", &codepage::CP862 }, - CP863 = { "cp863", &codepage::CP863 }, - CP864 = { "cp864", &codepage::CP864 }, - CP865 = { "cp865", &codepage::CP865 }, - CP866 = { "cp866", &codepage::CP866 }, - CP869 = { "cp869", &codepage::CP869 }, - CP874 = { "cp874", &codepage::CP874 }, - ISO_8859_1 = { "iso-8859-1", &codepage::ISO_8859_1 }, - ISO_8859_10 = { "iso-8859-10", &codepage::ISO_8859_10 }, - ISO_8859_11 = { "iso-8859-11", &codepage::ISO_8859_11 }, - ISO_8859_13 = { "iso-8859-13", &codepage::ISO_8859_13 }, - ISO_8859_14 = { "iso-8859-14", &codepage::ISO_8859_14 }, - ISO_8859_15 = { "iso-8859-15", &codepage::ISO_8859_15 }, - ISO_8859_16 = { "iso-8859-16", &codepage::ISO_8859_16 }, - ISO_8859_2 = { "iso-8859-2", &codepage::ISO_8859_2 }, - ISO_8859_3 = { "iso-8859-3", &codepage::ISO_8859_3 }, - ISO_8859_4 = { "iso-8859-4", &codepage::ISO_8859_4 }, - ISO_8859_5 = { "iso-8859-5", &codepage::ISO_8859_5 }, - ISO_8859_6 = { "iso-8859-6", &codepage::ISO_8859_6 }, - ISO_8859_7 = { "iso-8859-7", &codepage::ISO_8859_7 }, - ISO_8859_8 = { "iso-8859-8", &codepage::ISO_8859_8 }, - ISO_8859_9 = { "iso-8859-9", &codepage::ISO_8859_9 }, - US_ASCII = { "us-ascii", &codepage::US_ASCII }, + CP1250 { "cp1250", &codepage::CP1250 }, + CP1251 { "cp1251", &codepage::CP1251 }, + CP1252 { "cp1252", &codepage::CP1252 }, + CP1253 { "cp1253", &codepage::CP1253 }, + CP1254 { "cp1254", &codepage::CP1254 }, + CP1255 { "cp1255", &codepage::CP1255 }, + CP1256 { "cp1256", &codepage::CP1256 }, + CP1257 { "cp1257", &codepage::CP1257 }, + CP1258 { "cp1258", &codepage::CP1258 }, + CP437 { "cp437", &codepage::CP437 }, + CP737 { "cp737", &codepage::CP737 }, + CP775 { "cp775", &codepage::CP775 }, + CP850 { "cp850", &codepage::CP850 }, + CP852 { "cp852", &codepage::CP852 }, + CP855 { "cp855", &codepage::CP855 }, + CP857 { "cp857", &codepage::CP857 }, + CP860 { "cp860", &codepage::CP860 }, + CP861 { "cp861", &codepage::CP861 }, + CP862 { "cp862", &codepage::CP862 }, + CP863 { "cp863", &codepage::CP863 }, + CP864 { "cp864", &codepage::CP864 }, + CP865 { "cp865", &codepage::CP865 }, + CP866 { "cp866", &codepage::CP866 }, + CP869 { "cp869", &codepage::CP869 }, + CP874 { "cp874", &codepage::CP874 }, + ISO_8859_1 { "iso-8859-1", &codepage::ISO_8859_1 }, + ISO_8859_10 { "iso-8859-10", &codepage::ISO_8859_10 }, + ISO_8859_11 { "iso-8859-11", &codepage::ISO_8859_11 }, + ISO_8859_13 { "iso-8859-13", &codepage::ISO_8859_13 }, + ISO_8859_14 { "iso-8859-14", &codepage::ISO_8859_14 }, + ISO_8859_15 { "iso-8859-15", &codepage::ISO_8859_15 }, + ISO_8859_16 { "iso-8859-16", &codepage::ISO_8859_16 }, + ISO_8859_2 { "iso-8859-2", &codepage::ISO_8859_2 }, + ISO_8859_3 { "iso-8859-3", &codepage::ISO_8859_3 }, + ISO_8859_4 { "iso-8859-4", &codepage::ISO_8859_4 }, + ISO_8859_5 { "iso-8859-5", &codepage::ISO_8859_5 }, + ISO_8859_6 { "iso-8859-6", &codepage::ISO_8859_6 }, + ISO_8859_7 { "iso-8859-7", &codepage::ISO_8859_7 }, + ISO_8859_8 { "iso-8859-8", &codepage::ISO_8859_8 }, + ISO_8859_9 { "iso-8859-9", &codepage::ISO_8859_9 }, + US_ASCII { "us-ascii", &codepage::US_ASCII }, } <* diff --git a/lib/std/hash/blake3.c3 b/lib/std/hash/blake3.c3 index a4fc941da..29946680e 100644 --- a/lib/std/hash/blake3.c3 +++ b/lib/std/hash/blake3.c3 @@ -88,7 +88,7 @@ macro @simd_degree() @local } <* Flags used during hash computation based on its state. *> -enum Blake3Flags : const inline char +const enum Blake3Flags : inline char { CHUNK_START = 1 << 0, CHUNK_END = 1 << 1, diff --git a/lib/std/hash/gost/streebog.c3 b/lib/std/hash/gost/streebog.c3 index 98e491c1b..27a6018dc 100644 --- a/lib/std/hash/gost/streebog.c3 +++ b/lib/std/hash/gost/streebog.c3 @@ -8,7 +8,7 @@ module std::hash::streebog; -enum StreebogLength : const inline uint +const enum StreebogLength : inline uint { SIZE_256 = 32, SIZE_512 = 64, diff --git a/lib/std/hash/sha512.c3 b/lib/std/hash/sha512.c3 index 35599a497..8abc311d1 100644 --- a/lib/std/hash/sha512.c3 +++ b/lib/std/hash/sha512.c3 @@ -17,9 +17,9 @@ const HASH_SIZE = 64; struct Sha512 { - ulong length; - ulong[8] hash_state; - char[BLOCK_SIZE] buffer; + ulong length; + ulong[8] hash_state; + char[BLOCK_SIZE] buffer; } alias HmacSha512 = Hmac{Sha512, HASH_SIZE, BLOCK_SIZE}; @@ -36,26 +36,26 @@ macro ulong r0(ulong x) @local => (ror(x, 1) ^ ror(x, 8) ^ (x >> 7)); macro ulong r1(ulong x) @local => (ror(x, 19) ^ ror(x, 61) ^ (x >> 6)); const ulong[80] K @local = { - 0x428a2f98d728ae22, 0x7137449123ef65cd, 0xb5c0fbcfec4d3b2f, 0xe9b5dba58189dbbc, - 0x3956c25bf348b538, 0x59f111f1b605d019, 0x923f82a4af194f9b, 0xab1c5ed5da6d8118, - 0xd807aa98a3030242, 0x12835b0145706fbe, 0x243185be4ee4b28c, 0x550c7dc3d5ffb4e2, - 0x72be5d74f27b896f, 0x80deb1fe3b1696b1, 0x9bdc06a725c71235, 0xc19bf174cf692694, - 0xe49b69c19ef14ad2, 0xefbe4786384f25e3, 0x0fc19dc68b8cd5b5, 0x240ca1cc77ac9c65, - 0x2de92c6f592b0275, 0x4a7484aa6ea6e483, 0x5cb0a9dcbd41fbd4, 0x76f988da831153b5, - 0x983e5152ee66dfab, 0xa831c66d2db43210, 0xb00327c898fb213f, 0xbf597fc7beef0ee4, - 0xc6e00bf33da88fc2, 0xd5a79147930aa725, 0x06ca6351e003826f, 0x142929670a0e6e70, - 0x27b70a8546d22ffc, 0x2e1b21385c26c926, 0x4d2c6dfc5ac42aed, 0x53380d139d95b3df, - 0x650a73548baf63de, 0x766a0abb3c77b2a8, 0x81c2c92e47edaee6, 0x92722c851482353b, - 0xa2bfe8a14cf10364, 0xa81a664bbc423001, 0xc24b8b70d0f89791, 0xc76c51a30654be30, - 0xd192e819d6ef5218, 0xd69906245565a910, 0xf40e35855771202a, 0x106aa07032bbd1b8, - 0x19a4c116b8d2d0c8, 0x1e376c085141ab53, 0x2748774cdf8eeb99, 0x34b0bcb5e19b48a8, - 0x391c0cb3c5c95a63, 0x4ed8aa4ae3418acb, 0x5b9cca4f7763e373, 0x682e6ff3d6b2b8a3, - 0x748f82ee5defb2fc, 0x78a5636f43172f60, 0x84c87814a1f0ab72, 0x8cc702081a6439ec, - 0x90befffa23631e28, 0xa4506cebde82bde9, 0xbef9a3f7b2c67915, 0xc67178f2e372532b, - 0xca273eceea26619c, 0xd186b8c721c0c207, 0xeada7dd6cde0eb1e, 0xf57d4f7fee6ed178, - 0x06f067aa72176fba, 0x0a637dc5a2c898a6, 0x113f9804bef90dae, 0x1b710b35131c471b, - 0x28db77f523047d84, 0x32caab7b40c72493, 0x3c9ebe0a15c9bebc, 0x431d67c49c100d4c, - 0x4cc5d4becb3e42b6, 0x597f299cfc657e2a, 0x5fcb6fab3ad6faec, 0x6c44198c4a475817 + 0x428a2f98d728ae22, 0x7137449123ef65cd, 0xb5c0fbcfec4d3b2f, 0xe9b5dba58189dbbc, + 0x3956c25bf348b538, 0x59f111f1b605d019, 0x923f82a4af194f9b, 0xab1c5ed5da6d8118, + 0xd807aa98a3030242, 0x12835b0145706fbe, 0x243185be4ee4b28c, 0x550c7dc3d5ffb4e2, + 0x72be5d74f27b896f, 0x80deb1fe3b1696b1, 0x9bdc06a725c71235, 0xc19bf174cf692694, + 0xe49b69c19ef14ad2, 0xefbe4786384f25e3, 0x0fc19dc68b8cd5b5, 0x240ca1cc77ac9c65, + 0x2de92c6f592b0275, 0x4a7484aa6ea6e483, 0x5cb0a9dcbd41fbd4, 0x76f988da831153b5, + 0x983e5152ee66dfab, 0xa831c66d2db43210, 0xb00327c898fb213f, 0xbf597fc7beef0ee4, + 0xc6e00bf33da88fc2, 0xd5a79147930aa725, 0x06ca6351e003826f, 0x142929670a0e6e70, + 0x27b70a8546d22ffc, 0x2e1b21385c26c926, 0x4d2c6dfc5ac42aed, 0x53380d139d95b3df, + 0x650a73548baf63de, 0x766a0abb3c77b2a8, 0x81c2c92e47edaee6, 0x92722c851482353b, + 0xa2bfe8a14cf10364, 0xa81a664bbc423001, 0xc24b8b70d0f89791, 0xc76c51a30654be30, + 0xd192e819d6ef5218, 0xd69906245565a910, 0xf40e35855771202a, 0x106aa07032bbd1b8, + 0x19a4c116b8d2d0c8, 0x1e376c085141ab53, 0x2748774cdf8eeb99, 0x34b0bcb5e19b48a8, + 0x391c0cb3c5c95a63, 0x4ed8aa4ae3418acb, 0x5b9cca4f7763e373, 0x682e6ff3d6b2b8a3, + 0x748f82ee5defb2fc, 0x78a5636f43172f60, 0x84c87814a1f0ab72, 0x8cc702081a6439ec, + 0x90befffa23631e28, 0xa4506cebde82bde9, 0xbef9a3f7b2c67915, 0xc67178f2e372532b, + 0xca273eceea26619c, 0xd186b8c721c0c207, 0xeada7dd6cde0eb1e, 0xf57d4f7fee6ed178, + 0x06f067aa72176fba, 0x0a637dc5a2c898a6, 0x113f9804bef90dae, 0x1b710b35131c471b, + 0x28db77f523047d84, 0x32caab7b40c72493, 0x3c9ebe0a15c9bebc, 0x431d67c49c100d4c, + 0x4cc5d4becb3e42b6, 0x597f299cfc657e2a, 0x5fcb6fab3ad6faec, 0x6c44198c4a475817 }; @@ -63,219 +63,211 @@ const ulong[80] K @local = { // All truncation types are simple to add onto the base SHA512 implementation at a (near) future time. enum HashTruncationType : uint (uint truncation_width, ulong[8] initial_state) { - SHA512 = { - 512, - { - 0x6a09e667f3bcc908, - 0xbb67ae8584caa73b, - 0x3c6ef372fe94f82b, - 0xa54ff53a5f1d36f1, - 0x510e527fade682d1, - 0x9b05688c2b3e6c1f, - 0x1f83d9abfb41bd6b, - 0x5be0cd19137e2179 - } - }, - SHA384 = { - 384, - { - 0xcbbb9d5dc1059ed8, - 0x629a292a367cd507, - 0x9159015a3070dd17, - 0x152fecd8f70e5939, - 0x67332667ffc00b31, - 0x8eb44a8768581511, - 0xdb0c2e0d64f98fa7, - 0x47b5481dbefa4fa4 - } - }, - SHA512_224 = { - 224, - { - 0x8C3D37C819544DA2, - 0x73E1996689DCD4D6, - 0x1DFAB7AE32FF9C82, - 0x679DD514582F9FCF, - 0x0F6D2B697BD44DA8, - 0x77E36F7304C48942, - 0x3F9D85A86A1D36C8, - 0x1112E6AD91D692A1 - } - }, - SHA512_256 = { - 256, - { - 0x22312194FC2BF72C, - 0x9F555FA3C84C64C2, - 0x2393B86B6F53B151, - 0x963877195940EABD, - 0x96283EE2A88EFFE3, - 0xBE5E1E2553863992, - 0x2B0199FC2C85B8AA, - 0x0EB72DDC81C52CA2 - } - }, + SHA512 { 512, + { + 0x6a09e667f3bcc908, + 0xbb67ae8584caa73b, + 0x3c6ef372fe94f82b, + 0xa54ff53a5f1d36f1, + 0x510e527fade682d1, + 0x9b05688c2b3e6c1f, + 0x1f83d9abfb41bd6b, + 0x5be0cd19137e2179 + }}, + SHA384 { 384, + { + 0xcbbb9d5dc1059ed8, + 0x629a292a367cd507, + 0x9159015a3070dd17, + 0x152fecd8f70e5939, + 0x67332667ffc00b31, + 0x8eb44a8768581511, + 0xdb0c2e0d64f98fa7, + 0x47b5481dbefa4fa4 + }}, + SHA512_224 { 224, + { + 0x8C3D37C819544DA2, + 0x73E1996689DCD4D6, + 0x1DFAB7AE32FF9C82, + 0x679DD514582F9FCF, + 0x0F6D2B697BD44DA8, + 0x77E36F7304C48942, + 0x3F9D85A86A1D36C8, + 0x1112E6AD91D692A1 + }}, + SHA512_256 { 256, + { + 0x22312194FC2BF72C, + 0x9F555FA3C84C64C2, + 0x2393B86B6F53B151, + 0x963877195940EABD, + 0x96283EE2A88EFFE3, + 0xBE5E1E2553863992, + 0x2B0199FC2C85B8AA, + 0x0EB72DDC81C52CA2 + }}, } <* - @param [in] data + @param [in] data *> fn char[HASH_SIZE] hash(char[] data) { - Sha512 s @noinit; - s.init(); - s.update(data); - return s.final(); + Sha512 s @noinit; + s.init(); + s.update(data); + return s.final(); } fn void Sha512.init(&self) { - *self = { - .hash_state = HashTruncationType.SHA512.initial_state - }; + *self = { + .hash_state = HashTruncationType.SHA512.initial_state + }; } <* - @param [in] data - @require data.len <= ulong.max + @param [in] data + @require data.len <= ulong.max *> fn void Sha512.update(&self, char[] data) { - char* p = data.ptr; - ulong len = data.len; - ulong l; - ulong r = self.length % 128; + char* p = data.ptr; + ulong len = data.len; + ulong l; + ulong r = self.length % 128; - self.length += len; + self.length += len; - if (r) - { - if (len < (128 - r)) - { - for (l = 0; l < len; ++l) self.buffer[r+l] = p[l]; + if (r) + { + if (len < (128 - r)) + { + for (l = 0; l < len; ++l) self.buffer[r+l] = p[l]; - return; - } + return; + } - for (l = 0; l < 128 - r; ++l) self.buffer[r+l] = p[l]; + for (l = 0; l < 128 - r; ++l) self.buffer[r+l] = p[l]; - len -= (128 - r); - p = &p[128 - r]; + len -= (128 - r); + p = &p[128 - r]; - sha512_transform(&self.hash_state, &self.buffer); - } + sha512_transform(&self.hash_state, &self.buffer); + } - for (; len >= 128; len -= 128, p = &p[128]) sha512_transform(&self.hash_state, p); + for (; len >= 128; len -= 128, p = &p[128]) sha512_transform(&self.hash_state, p); - for (l = 0; l < len; ++l) self.buffer[l] = p[l]; + for (l = 0; l < len; ++l) self.buffer[l] = p[l]; } fn char[HASH_SIZE] Sha512.final(&self) { - char[HASH_SIZE] hash; + char[HASH_SIZE] hash; - int i; - ulong r = self.length % 128; + int i; + ulong r = self.length % 128; - self.buffer[r++] = 0x80; + self.buffer[r++] = 0x80; - if (r > 112) - { - for (i = 0; i < 128 - r; ++i) self.buffer[r+i] = 0; + if (r > 112) + { + for (i = 0; i < 128 - r; ++i) self.buffer[r+i] = 0; - r = 0; + r = 0; - sha512_transform(&self.hash_state, &self.buffer); - } + sha512_transform(&self.hash_state, &self.buffer); + } - for (i = 0; i < 120 - r; ++i) self.buffer[r+i] = 0; + for (i = 0; i < 120 - r; ++i) self.buffer[r+i] = 0; - self.length *= 8; + self.length *= 8; - self.buffer[120] = (char)(self.length >> 56); - self.buffer[121] = (char)(self.length >> 48); - self.buffer[122] = (char)(self.length >> 40); - self.buffer[123] = (char)(self.length >> 32); - self.buffer[124] = (char)(self.length >> 24); - self.buffer[125] = (char)(self.length >> 16); - self.buffer[126] = (char)(self.length >> 8); - self.buffer[127] = (char)(self.length); + self.buffer[120] = (char)(self.length >> 56); + self.buffer[121] = (char)(self.length >> 48); + self.buffer[122] = (char)(self.length >> 40); + self.buffer[123] = (char)(self.length >> 32); + self.buffer[124] = (char)(self.length >> 24); + self.buffer[125] = (char)(self.length >> 16); + self.buffer[126] = (char)(self.length >> 8); + self.buffer[127] = (char)(self.length); - sha512_transform(&self.hash_state, &self.buffer); + sha512_transform(&self.hash_state, &self.buffer); - for (i = 0; i < 8; ++i) - { - hash[(8 * i)] = (char)(self.hash_state[i] >> 56); - hash[(8 * i) + 1] = (char)(self.hash_state[i] >> 48); - hash[(8 * i) + 2] = (char)(self.hash_state[i] >> 40); - hash[(8 * i) + 3] = (char)(self.hash_state[i] >> 32); - hash[(8 * i) + 4] = (char)(self.hash_state[i] >> 24); - hash[(8 * i) + 5] = (char)(self.hash_state[i] >> 16); - hash[(8 * i) + 6] = (char)(self.hash_state[i] >> 8); - hash[(8 * i) + 7] = (char)(self.hash_state[i]); - } + for (i = 0; i < 8; ++i) + { + hash[(8 * i)] = (char)(self.hash_state[i] >> 56); + hash[(8 * i) + 1] = (char)(self.hash_state[i] >> 48); + hash[(8 * i) + 2] = (char)(self.hash_state[i] >> 40); + hash[(8 * i) + 3] = (char)(self.hash_state[i] >> 32); + hash[(8 * i) + 4] = (char)(self.hash_state[i] >> 24); + hash[(8 * i) + 5] = (char)(self.hash_state[i] >> 16); + hash[(8 * i) + 6] = (char)(self.hash_state[i] >> 8); + hash[(8 * i) + 7] = (char)(self.hash_state[i]); + } - return hash; + return hash; } <* - @param [&inout] state - @param [&in] buf + @param [&inout] state + @param [&in] buf *> fn void sha512_transform(ulong *state, char *buf) @local { - ulong t1, t2, a, b, c, d, e, f, g, h; - ulong[80] w; - int i; + ulong t1, t2, a, b, c, d, e, f, g, h; + ulong[80] w; + int i; - for (i = 0; i < 16; ++i) - { - w[i] = (ulong)buf[(8 * i)] << 56; - w[i] |= (ulong)buf[(8 * i) + 1] << 48; - w[i] |= (ulong)buf[(8 * i) + 2] << 40; - w[i] |= (ulong)buf[(8 * i) + 3] << 32; - w[i] |= (ulong)buf[(8 * i) + 4] << 24; - w[i] |= (ulong)buf[(8 * i) + 5] << 16; - w[i] |= (ulong)buf[(8 * i) + 6] << 8; - w[i] |= buf[(8 * i) + 7]; - } + for (i = 0; i < 16; ++i) + { + w[i] = (ulong)buf[(8 * i)] << 56; + w[i] |= (ulong)buf[(8 * i) + 1] << 48; + w[i] |= (ulong)buf[(8 * i) + 2] << 40; + w[i] |= (ulong)buf[(8 * i) + 3] << 32; + w[i] |= (ulong)buf[(8 * i) + 4] << 24; + w[i] |= (ulong)buf[(8 * i) + 5] << 16; + w[i] |= (ulong)buf[(8 * i) + 6] << 8; + w[i] |= buf[(8 * i) + 7]; + } - for (; i < 80; ++i) w[i] = r1(w[i - 2]) + w[i - 7] + r0(w[i - 15]) + w[i - 16]; + for (; i < 80; ++i) w[i] = r1(w[i - 2]) + w[i - 7] + r0(w[i - 15]) + w[i - 16]; - a = state[0]; - b = state[1]; - c = state[2]; - d = state[3]; - e = state[4]; - f = state[5]; - g = state[6]; - h = state[7]; + a = state[0]; + b = state[1]; + c = state[2]; + d = state[3]; + e = state[4]; + f = state[5]; + g = state[6]; + h = state[7]; - for (i = 0; i < 80; ++i) - { - t1 = h + s1(e) + ch(e, f, g) + K[i] + w[i]; - t2 = s0(a) + maj(a, b, c); - h = g; - g = f; - f = e; - e = d + t1; - d = c; - c = b; - b = a; - a = t1 + t2; - } + for (i = 0; i < 80; ++i) + { + t1 = h + s1(e) + ch(e, f, g) + K[i] + w[i]; + t2 = s0(a) + maj(a, b, c); + h = g; + g = f; + f = e; + e = d + t1; + d = c; + c = b; + b = a; + a = t1 + t2; + } - state[0] += a; - state[1] += b; - state[2] += c; - state[3] += d; - state[4] += e; - state[5] += f; - state[6] += g; - state[7] += h; + state[0] += a; + state[1] += b; + state[2] += c; + state[3] += d; + state[4] += e; + state[5] += f; + state[6] += g; + state[7] += h; } diff --git a/lib/std/libc/os/posix.c3 b/lib/std/libc/os/posix.c3 index 1924fae1a..83f7b8328 100644 --- a/lib/std/libc/os/posix.c3 +++ b/lib/std/libc/os/posix.c3 @@ -168,13 +168,13 @@ bitstruct Tc_lflags : CUInt bool extproc : 16; } -enum T_nldly : const char +const enum T_nldly : char { NL0 = 0b0, NL1 = 0b1, } -enum T_crdly : const char +const enum T_crdly : char { CR0 = 0b00, CR1 = 0b01, @@ -182,7 +182,7 @@ enum T_crdly : const char CR3 = 0b11, } -enum T_tabdly : const char +const enum T_tabdly : char { TAB0 = 0b00, TAB1 = 0b01, @@ -191,25 +191,25 @@ enum T_tabdly : const char XTABS = TAB3, } -enum T_bsdly : const char +const enum T_bsdly : char { BS0 = 0b0, BS1 = 0b1, } -enum T_ffdly : const char +const enum T_ffdly : char { FF0 = 0b0, FF1 = 0b1, } -enum T_vtdly : const char +const enum T_vtdly : char { VT0 = 0b0, VT1 = 0b1, } -enum T_csize : const char +const enum T_csize : char { CS5 = 0b00, CS6 = 0b01, @@ -217,31 +217,31 @@ enum T_csize : const char CS8 = 0b11, } -enum Speed : const CUInt +const enum Speed : CUInt { - B0 = 0o0000000, - B50 = 0o0000001, - B75 = 0o0000002, - B110 = 0o0000003, - B134 = 0o0000004, - B150 = 0o0000005, - B200 = 0o0000006, - B300 = 0o0000007, - B600 = 0o0000010, - B1200 = 0o0000011, - B1800 = 0o0000012, - B2400 = 0o0000013, - B4800 = 0o0000014, - B9600 = 0o0000015, - B19200 = 0o0000016, - B38400 = 0o0000017, - B57600 = 0o0010001, - B115200 = 0o0010002, - B230400 = 0o0010003, - B460800 = 0o0010004, - B500000 = 0o0010005, - B576000 = 0o0010006, - B921600 = 0o0010007, + B0 = 0o0000000, + B50 = 0o0000001, + B75 = 0o0000002, + B110 = 0o0000003, + B134 = 0o0000004, + B150 = 0o0000005, + B200 = 0o0000006, + B300 = 0o0000007, + B600 = 0o0000010, + B1200 = 0o0000011, + B1800 = 0o0000012, + B2400 = 0o0000013, + B4800 = 0o0000014, + B9600 = 0o0000015, + B19200 = 0o0000016, + B38400 = 0o0000017, + B57600 = 0o0010001, + B115200 = 0o0010002, + B230400 = 0o0010003, + B460800 = 0o0010004, + B500000 = 0o0010005, + B576000 = 0o0010006, + B921600 = 0o0010007, B1000000 = 0o0010010, B1152000 = 0o0010011, B1500000 = 0o0010012, @@ -253,37 +253,37 @@ enum Speed : const CUInt MAX_BAUD = B4000000, } -enum Cc : const inline char +const enum Cc : inline char { - VINTR = 0, - VQUIT = 1, - VERASE = 2, - VKILL = 3, - VEOF = 4, - VTIME = 5, - VMIN = 6, - VSWTC = 7, - VSTART = 8, - VSTOP = 9, - VSUSP = 10, - VEOL = 11, + VINTR = 0, + VQUIT = 1, + VERASE = 2, + VKILL = 3, + VEOF = 4, + VTIME = 5, + VMIN = 6, + VSWTC = 7, + VSTART = 8, + VSTOP = 9, + VSUSP = 10, + VEOL = 11, VREPRINT = 12, VDISCARD = 13, - VWERASE = 14, - VLNEXT = 15, - VEOL2 = 16, + VWERASE = 14, + VLNEXT = 15, + VEOL2 = 16, } -enum Tcactions : const CInt +const enum Tcactions : CInt { - TCOOFF = 0, - TCOON = 1, - TCIOFF = 2, - TCION = 3, - TCIFLUSH = 0, - TCOFLUSH = 1, + TCOOFF = 0, + TCOON = 1, + TCIOFF = 2, + TCION = 3, + TCIFLUSH = 0, + TCOFLUSH = 1, TCIOFLUSH = 2, - TCSANOW = 0, + TCSANOW = 0, TCSADRAIN = 1, TCSAFLUSH = 2, } diff --git a/lib/std/net/inetaddr.c3 b/lib/std/net/inetaddr.c3 index 6e96d0aae..41c293691 100644 --- a/lib/std/net/inetaddr.c3 +++ b/lib/std/net/inetaddr.c3 @@ -3,9 +3,9 @@ import std::io; enum IpProtocol : char (AIFamily ai_family) { - UNSPECIFIED = os::AF_UNSPEC, - IPV4 = os::AF_INET, - IPV6 = os::AF_INET6, + UNSPECIFIED { os::AF_UNSPEC }, + IPV4 { os::AF_INET }, + IPV6 { os::AF_INET6 }, } struct InetAddress (Printable) diff --git a/lib/std/net/socket.c3 b/lib/std/net/socket.c3 index 73d09591e..aa2c0fe18 100644 --- a/lib/std/net/socket.c3 +++ b/lib/std/net/socket.c3 @@ -25,7 +25,7 @@ macro void @loop_over_ai(AddrInfo* ai; @body(NativeSocket fd, AddrInfo* ai)) const Duration POLL_FOREVER = (Duration)-1; -enum PollSubscribe : const ushort +const enum PollSubscribe { ANY_READ = os::POLLIN, PRIO_READ = os::POLLPRI, @@ -44,7 +44,7 @@ const PollSubscribe SUBSCRIBE_ANY_WRITE = (PollSubscribe)os::POLLOUT; const PollSubscribe SUBSCRIBE_OOB_WRITE = (PollSubscribe)os::POLLWRBAND; const PollSubscribe SUBSCRIBE_WRITE = (PollSubscribe)os::POLLWRNORM; -enum PollEvent : const ushort +const enum PollEvent : ushort { READ_PRIO = os::POLLPRI, READ_OOB = os::POLLRDBAND, @@ -109,12 +109,12 @@ macro Socket new_socket(fd, ai) enum SocketOption : char (CInt value) { - REUSEADDR = os::SO_REUSEADDR, - REUSEPORT @if(!env::WIN32) = os::SO_REUSEPORT, - KEEPALIVE = os::SO_KEEPALIVE, - BROADCAST = os::SO_BROADCAST, - OOBINLINE = os::SO_OOBINLINE, - DONTROUTE = os::SO_DONTROUTE, + REUSEADDR { os::SO_REUSEADDR }, + REUSEPORT @if(!env::WIN32) { os::SO_REUSEPORT }, + KEEPALIVE { os::SO_KEEPALIVE }, + BROADCAST { os::SO_BROADCAST }, + OOBINLINE { os::SO_OOBINLINE }, + DONTROUTE { os::SO_DONTROUTE }, } fn bool? Socket.get_broadcast(&self) => self.get_option(BROADCAST); @@ -193,9 +193,9 @@ fn usz? Socket.peek(&self, char[] bytes) @dynamic enum SocketShutdownHow : (CInt native_value) { - RECEIVE = env::WIN32 ??? libc::SD_RECEIVE : libc::SHUT_RD, - SEND = env::WIN32 ??? libc::SD_SEND : libc::SHUT_WR, - BOTH = env::WIN32 ??? libc::SD_BOTH : libc::SHUT_RDWR, + RECEIVE { env::WIN32 ??? libc::SD_RECEIVE : libc::SHUT_RD }, + SEND { env::WIN32 ??? libc::SD_SEND : libc::SHUT_WR }, + BOTH { env::WIN32 ??? libc::SD_BOTH : libc::SHUT_RDWR }, } fn void? Socket.shutdown(&self, SocketShutdownHow how) diff --git a/lib/std/net/url_encoding.c3 b/lib/std/net/url_encoding.c3 index aeaa7e2be..c4d2a46e4 100644 --- a/lib/std/net/url_encoding.c3 +++ b/lib/std/net/url_encoding.c3 @@ -7,12 +7,12 @@ import std::encoding::hex; enum UrlEncodingMode : char (String allowed) { - UNRESERVED = "-_.~", // section 2.3 - PATH = "$&+,/:;=@", // section 3.3 - HOST = "!$&'()*+,;=:[]", // section 3.2.2 (also include ':', '[', ']' for ipv6 hosts) - USERPASS = ";:&=+$,", // section 3.2.1 - QUERY = "", // section 3.4 - FRAGMENT = "$&+,/:;=?@!()*", // section 4.1 + UNRESERVED { "-_.~" }, // section 2.3 + PATH { "$&+,/:;=@" }, // section 3.3 + HOST { "!$&'()*+,;=:[]" }, // section 3.2.2 (also include ':', '[', ']' for ipv6 hosts) + USERPASS { ";:&=+$," }, // section 3.2.1 + QUERY { "" }, // section 3.4 + FRAGMENT { "$&+,/:;=?@!()*" }, // section 4.1 } faultdef INVALID_HEX; diff --git a/lib/std/os/android/log.c3 b/lib/std/os/android/log.c3 index 479f5c5c3..fb756e4b2 100644 --- a/lib/std/os/android/log.c3 +++ b/lib/std/os/android/log.c3 @@ -3,30 +3,30 @@ module std::os::android @if(env::ANDROID); enum AndroidLogPriority : (CInt val) { - ANDROID_LOG_UNKNOWN = 0, - ANDROID_LOG_DEFAULT = 1, - ANDROID_LOG_VERBOSE = 2, - ANDROID_LOG_DEBUG = 3, - ANDROID_LOG_INFO = 4, - ANDROID_LOG_WARN = 5, - ANDROID_LOG_ERROR = 6, - ANDROID_LOG_FATAL = 7, - ANDROID_LOG_SILENT = 8 + ANDROID_LOG_UNKNOWN { 0 }, + ANDROID_LOG_DEFAULT { 1 }, + ANDROID_LOG_VERBOSE { 2 }, + ANDROID_LOG_DEBUG { 3 }, + ANDROID_LOG_INFO { 4 }, + ANDROID_LOG_WARN { 5 }, + ANDROID_LOG_ERROR { 6 }, + ANDROID_LOG_FATAL { 7 }, + ANDROID_LOG_SILENT { 8 } } enum AndroidLogId : (CInt val) { - LOG_ID_MIN = 0, - LOG_ID_MAIN = 0, - LOG_ID_RADIO = 1, - LOG_ID_EVENTS = 2, - LOG_ID_SYSTEM = 3, - LOG_ID_CRASH = 4, - LOG_ID_STATS = 5, - LOG_ID_SECURITY = 6, - LOG_ID_KERNEL = 7, - LOG_ID_MAX = 7, - LOG_ID_DEFAULT = 0x7FFFFFFF + LOG_ID_MIN { 0 }, + LOG_ID_MAIN { 0 }, + LOG_ID_RADIO { 1 }, + LOG_ID_EVENTS { 2 }, + LOG_ID_SYSTEM { 3 }, + LOG_ID_CRASH { 4 }, + LOG_ID_STATS { 5 }, + LOG_ID_SECURITY { 6 }, + LOG_ID_KERNEL { 7 }, + LOG_ID_MAX { 7 }, + LOG_ID_DEFAULT { 0x7FFFFFFF } } struct AndroidLogMessage @packed diff --git a/lib/std/os/linux/epoll.c3 b/lib/std/os/linux/epoll.c3 index 1be60676a..b02efeff8 100644 --- a/lib/std/os/linux/epoll.c3 +++ b/lib/std/os/linux/epoll.c3 @@ -18,23 +18,23 @@ const uint EPOLLWAKEUP = EpollEvents.EPOLLWAKEUP; const uint EPOLLONESHOT = EpollEvents.EPOLLONESHOT; const uint EPOLLET = EpollEvents.EPOLLET; -enum EpollEvents: const inline uint +const enum EpollEvents : inline uint { - EPOLLIN = 0x001, - EPOLLPRI = 0x002, - EPOLLOUT = 0x004, - EPOLLRDNORM = 0x040, - EPOLLRDBAND = 0x080, - EPOLLWRNORM = 0x100, - EPOLLWRBAND = 0x200, - EPOLLMSG = 0x400, - EPOLLERR = 0x008, - EPOLLHUP = 0x010, - EPOLLRDHUP = 0x2000, + EPOLLIN = 0x001, + EPOLLPRI = 0x002, + EPOLLOUT = 0x004, + EPOLLRDNORM = 0x040, + EPOLLRDBAND = 0x080, + EPOLLWRNORM = 0x100, + EPOLLWRBAND = 0x200, + EPOLLMSG = 0x400, + EPOLLERR = 0x008, + EPOLLHUP = 0x010, + EPOLLRDHUP = 0x2000, EPOLLEXCLUSIVE = 1u << 28, - EPOLLWAKEUP = 1u << 29, - EPOLLONESHOT = 1u << 30, - EPOLLET = 1u << 31 + EPOLLWAKEUP = 1u << 29, + EPOLLONESHOT = 1u << 30, + EPOLLET = 1u << 31 } /* Valid opcodes ( "op" parameter ) to issue to epoll_ctl(). */ diff --git a/lib/std/os/macos/core_foundation.c3 b/lib/std/os/macos/core_foundation.c3 index 5474125f9..695be5ba6 100644 --- a/lib/std/os/macos/core_foundation.c3 +++ b/lib/std/os/macos/core_foundation.c3 @@ -40,7 +40,7 @@ extern fn CFTypeRef CFType.retain(&self) @cname("CFRetain"); extern fn void CFType.release(&self) @cname("CFRelease"); extern fn CFIndex CFType.getRetainCount(&self) @cname("CFGetRetainCount"); -enum CFStringEncoding : const uint +const enum CFStringEncoding : uint { INVALID_ID = 0xffffffffU, MAC_ROMAN = 0, diff --git a/lib/std/os/macos/general.c3 b/lib/std/os/macos/general.c3 index 7b942c9e4..0fccbc434 100644 --- a/lib/std/os/macos/general.c3 +++ b/lib/std/os/macos/general.c3 @@ -1,7 +1,7 @@ module std::os::darwin @if(env::DARWIN) @link("Foundation.framework"); import std::os::macos::cf, std::os::macos::objc, std::io; -enum NSSearchPathDomainMask : const NSUInteger +const enum NSSearchPathDomainMask : NSUInteger { USER = 1, LOCAL = 2, @@ -10,7 +10,7 @@ enum NSSearchPathDomainMask : const NSUInteger ALL = 0x0ffff } -enum NSSearchPathDirectory : const NSUInteger +const enum NSSearchPathDirectory : NSUInteger { APPLICATION = 1, DEMO_APPLICATION, @@ -44,8 +44,6 @@ enum NSSearchPathDirectory : const NSUInteger // real signature in Foundation extern fn CFArrayRef nsSearchPathForDirectoriesInDomains(NSSearchPathDirectory directory, NSSearchPathDomainMask domainMask, bool expandTilde) @cname("NSSearchPathForDirectoriesInDomains"); - - fn String? find_first_directory_temp(NSSearchPathDirectory directory, NSSearchPathDomainMask domainMask) { objc::@autoreleasepool() diff --git a/lib/std/os/macos/objc.c3 b/lib/std/os/macos/objc.c3 index cd4ccb8a5..00fd13259 100644 --- a/lib/std/os/macos/objc.c3 +++ b/lib/std/os/macos/objc.c3 @@ -77,18 +77,18 @@ import std::os::macos::cf; enum StatusItemLength : (double val) @deprecated("Use NSStatusItemLength.") { - VARIABLE = -1.0, - SQUARE = -2.0, + VARIABLE { -1.0 }, + SQUARE { -2.0 }, } enum ApplicationActivationPolicy : (int val) @deprecated("Use NSApplicationActivationPolicy.") { - REGULAR = 0, - ACCESSORY = 1, - PROHIBITED = 2, + REGULAR { 0 }, + ACCESSORY { 1 }, + PROHIBITED { 2 }, } -enum NSApplicationActivationPolicy : const inline NSInteger +const enum NSApplicationActivationPolicy : inline NSInteger { REGULAR = 0, ACCESSORY = 1, @@ -97,29 +97,29 @@ enum NSApplicationActivationPolicy : const inline NSInteger enum WindowStyleMask : (int val) @deprecated("Use NSWindowStyleMask.") { - BORDERLESS = 0, - TITLED = 1 << 0, - CLOSABLE = 1 << 1, - MINIATURIZABLE = 1 << 2, - RESIZABLE = 1 << 3, - TEXTURED_BACKGROUND = 1 << 8, - UNIFIED_TITLE_AND_TOOLBAR = 1 << 12, - FULL_SCREEN = 1 << 14, - FULL_SIZE_CONTENT_VIEW = 1 << 15, - UTILITY_WINDOW = 1 << 4, - DOC_MODAL_WINDOW = 1 << 6, - NONACTIVATING_PANEL = 1 << 7, - HUD_WINDOW = 1 << 13 + BORDERLESS { 0 }, + TITLED { 1 << 0 }, + CLOSABLE { 1 << 1 }, + MINIATURIZABLE { 1 << 2 }, + RESIZABLE { 1 << 3 }, + TEXTURED_BACKGROUND { 1 << 8 }, + UNIFIED_TITLE_AND_TOOLBAR { 1 << 12 }, + FULL_SCREEN { 1 << 14 }, + FULL_SIZE_CONTENT_VIEW { 1 << 15 }, + UTILITY_WINDOW { 1 << 4 }, + DOC_MODAL_WINDOW { 1 << 6 }, + NONACTIVATING_PANEL { 1 << 7 }, + HUD_WINDOW { 1 << 13 } } enum BackingStore : (int val) @deprecated("Use NSBackingStoreType.") { - RETAINED = 0, - NONRETAINED = 1, - BUFFERED = 2 + RETAINED { 0 }, + NONRETAINED { 1 }, + BUFFERED { 2 } } -enum NSBackingStoreType : const inline NSUInteger +const enum NSBackingStoreType : inline NSUInteger { RETAINED = 0, NONRETAINED = 1, @@ -128,43 +128,43 @@ enum NSBackingStoreType : const inline NSUInteger enum EventType : (long val) @deprecated("Use NSEventType.") { - LEFT_MOUSE_DOWN = 1, - LEFT_MOUSE_UP = 2, - RIGHT_MOUSE_DOWN = 3, - RIGHT_MOUSE_UP = 4, - MOUSE_MOVED = 5, - LEFT_MOUSE_DRAGGED = 6, - RIGHT_MOUSE_DRAGGED = 7, - MOUSE_ENTERED = 8, - MOUSE_EXITED = 9, - KEY_DOWN = 10, - KEY_UP = 11, - FLAGS_CHANGED = 12, - APPKIT_DEFINED = 13, - SYSTEM_DEFINED = 14, - APPLICATION_DEFINED = 15, - PERIODIC = 16, - CURSOR_UPDATE = 17, - SCROLL_WHEEL = 22, - TABLET_POINT = 23, - TABLET_PROXIMITY = 24, - OTHER_MOUSE_DOWN = 25, - OTHER_MOUSE_UP = 26, - OTHER_MOUSE_DRAGGED = 27, - GESTURE = 29, - MAGNIFY = 30, - SWIPE = 31, - ROTATE = 18, - BEGIN_GESTURE = 19, - END_GESTURE = 20, - SMART_MAGNIFY = 32, - QUICK_LOOK = 33, - PRESSURE = 34, - DIRECT_TOUCH = 37, - CHANGE_MODE = 38, + LEFT_MOUSE_DOWN { 1 }, + LEFT_MOUSE_UP { 2 }, + RIGHT_MOUSE_DOWN { 3 }, + RIGHT_MOUSE_UP { 4 }, + MOUSE_MOVED { 5 }, + LEFT_MOUSE_DRAGGED { 6 }, + RIGHT_MOUSE_DRAGGED { 7 }, + MOUSE_ENTERED { 8 }, + MOUSE_EXITED { 9 }, + KEY_DOWN { 10 }, + KEY_UP { 11 }, + FLAGS_CHANGED { 12 }, + APPKIT_DEFINED { 13 }, + SYSTEM_DEFINED { 14 }, + APPLICATION_DEFINED { 15 }, + PERIODIC { 16 }, + CURSOR_UPDATE { 17 }, + SCROLL_WHEEL { 22 }, + TABLET_POINT { 23 }, + TABLET_PROXIMITY { 24 }, + OTHER_MOUSE_DOWN { 25 }, + OTHER_MOUSE_UP { 26 }, + OTHER_MOUSE_DRAGGED { 27 }, + GESTURE { 29 }, + MAGNIFY { 30 }, + SWIPE { 31 }, + ROTATE { 18 }, + BEGIN_GESTURE { 19 }, + END_GESTURE { 20 }, + SMART_MAGNIFY { 32 }, + QUICK_LOOK { 33 }, + PRESSURE { 34 }, + DIRECT_TOUCH { 37 }, + CHANGE_MODE { 38 }, } -enum NSEventType : const inline NSUInteger +const enum NSEventType : inline NSUInteger { LEFT_MOUSE_DOWN = 1, LEFT_MOUSE_UP = 2, @@ -246,41 +246,41 @@ fn EventType? event_type_from(int val) @deprecated("Use NSEventType directly.") enum EventMask : (long val) @deprecated("Use NSEventMask.") { - LEFT_MOUSE_DOWN = 1 << EventType.LEFT_MOUSE_DOWN.val, - LEFT_MOUSE_UP = 1 << EventType.LEFT_MOUSE_UP.val, - RIGHT_MOUSE_DOWN = 1 << EventType.RIGHT_MOUSE_DOWN.val, - RIGHT_MOUSE_UP = 1 << EventType.RIGHT_MOUSE_UP.val, - MOUSE_MOVED = 1 << EventType.MOUSE_MOVED.val, - LEFT_MOUSE_DRAGGED = 1 << EventType.LEFT_MOUSE_DRAGGED.val, - RIGHT_MOUSE_DRAGGED = 1 << EventType.RIGHT_MOUSE_DRAGGED.val, - MOUSE_ENTERED = 1 << EventType.MOUSE_ENTERED.val, - MOUSE_EXITED = 1 << EventType.MOUSE_EXITED.val, - KEY_DOWN = 1 << EventType.KEY_DOWN.val, - KEY_UP = 1 << EventType.KEY_UP.val, - FLAGS_CHANGED = 1 << EventType.FLAGS_CHANGED.val, - APPKIT_DEFINED = 1 << EventType.APPKIT_DEFINED.val, - SYSTEM_DEFINED = 1 << EventType.SYSTEM_DEFINED.val, - APPLICATION_DEFINED = 1 << EventType.APPLICATION_DEFINED.val, - PERIODIC = 1 << EventType.PERIODIC.val, - CURSOR_UPDATE = 1 << EventType.CURSOR_UPDATE.val, - SCROLL_WHEEL = 1 << EventType.SCROLL_WHEEL.val, - TABLET_POINT = 1 << EventType.TABLET_POINT.val, - TABLET_PROXIMITY = 1 << EventType.TABLET_PROXIMITY.val, - OTHER_MOUSE_DOWN = 1 << EventType.OTHER_MOUSE_DOWN.val, - OTHER_MOUSE_UP = 1 << EventType.OTHER_MOUSE_UP.val, - OTHER_MOUSE_DRAGGED = 1 << EventType.OTHER_MOUSE_DRAGGED.val, - GESTURE = 1 << EventType.GESTURE.val, - MAGNIFY = 1 << EventType.MAGNIFY.val, - SWIPE = 1 << EventType.SWIPE.val, - ROTATE = 1 << EventType.ROTATE.val, - BEGIN_GESTURE = 1 << EventType.BEGIN_GESTURE.val, - END_GESTURE = 1 << EventType.END_GESTURE.val, - SMART_MAGNIFY = 1L << EventType.SMART_MAGNIFY.val, - DIRECT_TOUCH = 1L << EventType.DIRECT_TOUCH.val, - ANY = long.max, + LEFT_MOUSE_DOWN { 1 << EventType.LEFT_MOUSE_DOWN.val }, + LEFT_MOUSE_UP { 1 << EventType.LEFT_MOUSE_UP.val }, + RIGHT_MOUSE_DOWN { 1 << EventType.RIGHT_MOUSE_DOWN.val }, + RIGHT_MOUSE_UP { 1 << EventType.RIGHT_MOUSE_UP.val }, + MOUSE_MOVED { 1 << EventType.MOUSE_MOVED.val }, + LEFT_MOUSE_DRAGGED { 1 << EventType.LEFT_MOUSE_DRAGGED.val }, + RIGHT_MOUSE_DRAGGED { 1 << EventType.RIGHT_MOUSE_DRAGGED.val }, + MOUSE_ENTERED { 1 << EventType.MOUSE_ENTERED.val }, + MOUSE_EXITED { 1 << EventType.MOUSE_EXITED.val }, + KEY_DOWN { 1 << EventType.KEY_DOWN.val }, + KEY_UP { 1 << EventType.KEY_UP.val }, + FLAGS_CHANGED { 1 << EventType.FLAGS_CHANGED.val }, + APPKIT_DEFINED { 1 << EventType.APPKIT_DEFINED.val }, + SYSTEM_DEFINED { 1 << EventType.SYSTEM_DEFINED.val }, + APPLICATION_DEFINED { 1 << EventType.APPLICATION_DEFINED.val }, + PERIODIC { 1 << EventType.PERIODIC.val }, + CURSOR_UPDATE { 1 << EventType.CURSOR_UPDATE.val }, + SCROLL_WHEEL { 1 << EventType.SCROLL_WHEEL.val }, + TABLET_POINT { 1 << EventType.TABLET_POINT.val }, + TABLET_PROXIMITY { 1 << EventType.TABLET_PROXIMITY.val }, + OTHER_MOUSE_DOWN { 1 << EventType.OTHER_MOUSE_DOWN.val }, + OTHER_MOUSE_UP { 1 << EventType.OTHER_MOUSE_UP.val }, + OTHER_MOUSE_DRAGGED { 1 << EventType.OTHER_MOUSE_DRAGGED.val }, + GESTURE { 1 << EventType.GESTURE.val }, + MAGNIFY { 1 << EventType.MAGNIFY.val }, + SWIPE { 1 << EventType.SWIPE.val }, + ROTATE { 1 << EventType.ROTATE.val }, + BEGIN_GESTURE { 1 << EventType.BEGIN_GESTURE.val }, + END_GESTURE { 1 << EventType.END_GESTURE.val }, + SMART_MAGNIFY { 1L << EventType.SMART_MAGNIFY.val }, + DIRECT_TOUCH { 1L << EventType.DIRECT_TOUCH.val }, + ANY { long.max }, } -enum NSEventMask : const inline ulong +const enum NSEventMask : inline ulong { LEFT_MOUSE_DOWN = 1ul << NSEventType.LEFT_MOUSE_DOWN, LEFT_MOUSE_UP = 1ul << NSEventType.LEFT_MOUSE_UP, @@ -323,17 +323,17 @@ fn NSEventMask event_mask_from_type(NSEventType type) => (NSEventMask)1ul << typ enum EventModifierFlag : (int val) @deprecated("Use NSEventModifierFlags.") { - CAPS_LOCK = 1 << 16, - SHIFT = 1 << 17, - CONTROL = 1 << 18, - OPTION = 1 << 19, - COMMAND = 1 << 20, - NUMERIC_PAD = 1 << 21, - FUNCTION = 1 << 23, - HELP = 1 << 22, + CAPS_LOCK { 1 << 16 }, + SHIFT { 1 << 17 }, + CONTROL { 1 << 18 }, + OPTION { 1 << 19 }, + COMMAND { 1 << 20 }, + NUMERIC_PAD { 1 << 21 }, + FUNCTION { 1 << 23 }, + HELP { 1 << 22 }, } -enum NSEventModifierFlags : const inline NSUInteger +const enum NSEventModifierFlags : inline NSUInteger { CAPS_LOCK = 1 << 16, SHIFT = 1 << 17, @@ -346,7 +346,7 @@ enum NSEventModifierFlags : const inline NSUInteger DEVICE_INDEPENDENT_FLAGS_MASK = 0xffff0000UL, } -enum NSWindowCollectionBehavior : const inline NSUInteger +const enum NSWindowCollectionBehavior : inline NSUInteger { DEFAULT = 0, CAN_JOIN_ALL_SPACES = 1 << 0, @@ -366,7 +366,7 @@ enum NSWindowCollectionBehavior : const inline NSUInteger CAN_JOIN_ALL_APPLICATIONS = 1 << 18, } -enum NSWindowLevel : const inline NSInteger +const enum NSWindowLevel : inline NSInteger { NORMAL = 0, FLOATING = 3, @@ -379,7 +379,7 @@ enum NSWindowLevel : const inline NSInteger SCREEN_SAVER = 1000, } -enum NSWindowStyleMask : const inline NSUInteger +const enum NSWindowStyleMask : inline NSUInteger { BORDERLESS = 0, TITLED = 1 << 0, @@ -396,22 +396,22 @@ enum NSWindowStyleMask : const inline NSUInteger HUD_WINDOW = 1 << 13 } -enum NSWindowTabbingMode : const inline NSInteger +const enum NSWindowTabbingMode : inline NSInteger { AUTOMATIC = 0, DISALLOWED = 2, PREFERRED = 1, } -enum NSStatusItemLength : const inline CGFloat +const enum NSStatusItemLength : inline CGFloat { VARIABLE = -1.0, - SQUARE = -2.0 + SQUARE = -2.0 } -enum NSApplicationTerminateReply : const inline NSUInteger +const enum NSApplicationTerminateReply : inline NSUInteger { CANCEL = 0, - NOW = 1, - LATER = 2, + NOW = 1, + LATER = 2, } diff --git a/lib/std/os/win32/console.c3 b/lib/std/os/win32/console.c3 index 8f4507038..39253e73b 100644 --- a/lib/std/os/win32/console.c3 +++ b/lib/std/os/win32/console.c3 @@ -1,159 +1,159 @@ module std::os::win32 @if(env::WIN32); -enum Win32_CODEPAGE : const Win32_UINT +const enum Win32_CODEPAGE : Win32_UINT { - IBM037 = 037, // IBM EBCDIC US-Canada - IBM437 = 437, // OEM United States - IBM500 = 500, // IBM EBCDIC International - ASMO_708 = 708, // Arabic (ASMO 708) - CODEPAGE_709 = 709, // Arabic (ASMO-449+, BCON V4) - CODEPAGE_710 = 710, // Arabic - Transparent Arabic - DOS_720 = 720, // Arabic (Transparent ASMO); Arabic (DOS) - IBM737 = 737, // OEM Greek (formerly 437G); Greek (DOS) - IBM775 = 775, // OEM Baltic; Baltic (DOS) - IBM850 = 850, // OEM Multilingual Latin 1; Western European (DOS) - IBM852 = 852, // OEM Latin 2; Central European (DOS) - IBM855 = 855, // OEM Cyrillic (primarily Russian) - IBM857 = 857, // OEM Turkish; Turkish (DOS) - IBM00858 = 858, // OEM Multilingual Latin 1 + Euro symbol - IBM860 = 860, // OEM Portuguese; Portuguese (DOS) - IBM861 = 861, // OEM Icelandic; Icelandic (DOS) - DOS_862 = 862, // OEM Hebrew; Hebrew (DOS) - IBM863 = 863, // OEM French Canadian; French Canadian (DOS) - IBM864 = 864, // OEM Arabic; Arabic (864) - IBM865 = 865, // OEM Nordic; Nordic (DOS) - CP866 = 866, // OEM Russian; Cyrillic (DOS) - IBM869 = 869, // OEM Modern Greek; Greek, Modern (DOS) - IBM870 = 870, // IBM EBCDIC Multilingual/ROECE (Latin 2); IBM EBCDIC Multilingual Latin 2 - WINDOWS_874 = 874, // Thai (Windows) - CP875 = 875, // IBM EBCDIC Greek Modern - SHIFT_JIS = 932, // ANSI/OEM Japanese; Japanese (Shift-JIS) - GB2312 = 936, // ANSI/OEM Simplified Chinese (PRC, Singapore); Chinese Simplified (GB2312) - KS_C_5601_1987 = 949, // ANSI/OEM Korean (Unified Hangul Code) - BIG5 = 950, // ANSI/OEM Traditional Chinese (Taiwan; Hong Kong SAR, PRC); Chinese Traditional (Big5) - IBM1026 = 1026, // IBM EBCDIC Turkish (Latin 5) - IBM01047 = 1047, // IBM EBCDIC Latin 1/Open System - IBM01140 = 1140, // IBM EBCDIC US-Canada (037 + Euro symbol); IBM EBCDIC (US-Canada-Euro) - IBM01141 = 1141, // IBM EBCDIC Germany (20273 + Euro symbol); IBM EBCDIC (Germany-Euro) - IBM01142 = 1142, // IBM EBCDIC Denmark-Norway (20277 + Euro symbol); IBM EBCDIC (Denmark-Norway-Euro) - IBM01143 = 1143, // IBM EBCDIC Finland-Sweden (20278 + Euro symbol); IBM EBCDIC (Finland-Sweden-Euro) - IBM01144 = 1144, // IBM EBCDIC Italy (20280 + Euro symbol); IBM EBCDIC (Italy-Euro) - IBM01145 = 1145, // IBM EBCDIC Latin America-Spain (20284 + Euro symbol); IBM EBCDIC (Spain-Euro) - IBM01146 = 1146, // IBM EBCDIC United Kingdom (20285 + Euro symbol); IBM EBCDIC (UK-Euro) - IBM01147 = 1147, // IBM EBCDIC France (20297 + Euro symbol); IBM EBCDIC (France-Euro) - IBM01148 = 1148, // IBM EBCDIC International (500 + Euro symbol); IBM EBCDIC (International-Euro) - IBM01149 = 1149, // IBM EBCDIC Icelandic (20871 + Euro symbol); IBM EBCDIC (Icelandic-Euro) - UTF16 = 1200, // Unicode UTF-16, little endian byte order (BMP of ISO 10646); available only to managed applications - UNICODE_FFFE = 1201, // Unicode UTF-16, big endian byte order; available only to managed applications - WINDOWS_1250 = 1250, // ANSI Central European; Central European (Windows) - WINDOWS_1251 = 1251, // ANSI Cyrillic; Cyrillic (Windows) - WINDOWS_1252 = 1252, // ANSI Latin 1; Western European (Windows) - WINDOWS_1253 = 1253, // ANSI Greek; Greek (Windows) - WINDOWS_1254 = 1254, // ANSI Turkish; Turkish (Windows) - WINDOWS_1255 = 1255, // ANSI Hebrew; Hebrew (Windows) - WINDOWS_1256 = 1256, // ANSI Arabic; Arabic (Windows) - WINDOWS_1257 = 1257, // ANSI Baltic; Baltic (Windows) - WINDOWS_1258 = 1258, // ANSI/OEM Vietnamese; Vietnamese (Windows) - JOHAB = 1361, // Korean (Johab) - MACINTOSH = 10000, // MAC Roman; Western European (Mac) - X_MAC_JAPANESE = 10001, // Japanese (Mac) - X_MAC_CHINESETRAD = 10002, // MAC Traditional Chinese (Big5); Chinese Traditional (Mac) - X_MAC_KOREAN = 10003, // Korean (Mac) - X_MAC_ARABIC = 10004, // Arabic (Mac) - X_MAC_HEBREW = 10005, // Hebrew (Mac) - X_MAC_GREEK = 10006, // Greek (Mac) - X_MAC_CYRILLIC = 10007, // Cyrillic (Mac) - X_MAC_CHINESESIMP = 10008, // MAC Simplified Chinese (GB 2312); Chinese Simplified (Mac) - X_MAC_ROMANIAN = 10010, // Romanian (Mac) - X_MAC_UKRANIAN = 10017, // Ukrainian (Mac) - X_MAC_THAI = 10021, // Thai (Mac) - X_MAC_CE = 10029, // MAC Latin 2; Central European (Mac) - X_MAC_ICELANDIC = 10079, // Icelandic (Mac) - X_MAC_TURKISH = 10081, // Turkish (Mac) - X_MAC_CROATIAN = 10082, // Croatian (Mac) - UTF32 = 12000, // Unicode UTF-32, little endian byte order; available only to managed applications - UTF32BE = 12001, // Unicode UTF-32, big endian byte order; available only to managed applications - X_CHINESE_CNS = 20000, // CNS Taiwan; Chinese Traditional (CNS) - X_CP_20001 = 20001, // TCA Taiwan - X_CHINESE_ETEN = 20002, // Eten Taiwan; Chinese Traditional (Eten) - X_CP_20003 = 20003, // IBM5550 Taiwan - X_CP_20004 = 20004, // TeleText Taiwan - X_CP_20005 = 20005, // Wang Taiwan - X_IA5 = 20105, // IA5 (IRV International Alphabet No. 5, 7-bit); Western European (IA5) - X_IA5_GERMAN = 20106, // IA5 German (7-bit) - X_IA5_SWEDISH = 20107, // IA5 Swedish (7-bit) - X_IA5_NORWEGIAN = 20108, // IA5 Norwegian (7-bit) - US_ASCII = 20127, // US-ASCII (7-bit) - X_CP20261 = 20261, // T.61 - X_CP20269 = 20269, // ISO 6937 Non-Spacing Accent - IBM273 = 20273, // IBM EBCDIC Germany - IBM277 = 20277, // IBM EBCDIC Denmark-Norway - IBM278 = 20278, // IBM EBCDIC Finland-Sweden - IBM280 = 20280, // IBM EBCDIC Italy - IBM284 = 20284, // IBM EBCDIC Latin America-Spain - IBM285 = 20285, // IBM EBCDIC United Kingdom - IBM290 = 20290, // IBM EBCDIC Japanese Katakana Extended - IBM297 = 20297, // IBM EBCDIC France - IBM420 = 20420, // IBM EBCDIC Arabic - IBM423 = 20423, // IBM EBCDIC Greek - IBM424 = 20424, // IBM EBCDIC Hebrew + IBM037 = 037, // IBM EBCDIC US-Canada + IBM437 = 437, // OEM United States + IBM500 = 500, // IBM EBCDIC International + ASMO_708 = 708, // Arabic (ASMO 708) + CODEPAGE_709 = 709, // Arabic (ASMO-449+, BCON V4) + CODEPAGE_710 = 710, // Arabic - Transparent Arabic + DOS_720 = 720, // Arabic (Transparent ASMO); Arabic (DOS) + IBM737 = 737, // OEM Greek (formerly 437G); Greek (DOS) + IBM775 = 775, // OEM Baltic; Baltic (DOS) + IBM850 = 850, // OEM Multilingual Latin 1; Western European (DOS) + IBM852 = 852, // OEM Latin 2; Central European (DOS) + IBM855 = 855, // OEM Cyrillic (primarily Russian) + IBM857 = 857, // OEM Turkish; Turkish (DOS) + IBM00858 = 858, // OEM Multilingual Latin 1 + Euro symbol + IBM860 = 860, // OEM Portuguese; Portuguese (DOS) + IBM861 = 861, // OEM Icelandic; Icelandic (DOS) + DOS_862 = 862, // OEM Hebrew; Hebrew (DOS) + IBM863 = 863, // OEM French Canadian; French Canadian (DOS) + IBM864 = 864, // OEM Arabic; Arabic (864) + IBM865 = 865, // OEM Nordic; Nordic (DOS) + CP866 = 866, // OEM Russian; Cyrillic (DOS) + IBM869 = 869, // OEM Modern Greek; Greek, Modern (DOS) + IBM870 = 870, // IBM EBCDIC Multilingual/ROECE (Latin 2); IBM EBCDIC Multilingual Latin 2 + WINDOWS_874 = 874, // Thai (Windows) + CP875 = 875, // IBM EBCDIC Greek Modern + SHIFT_JIS = 932, // ANSI/OEM Japanese; Japanese (Shift-JIS) + GB2312 = 936, // ANSI/OEM Simplified Chinese (PRC, Singapore); Chinese Simplified (GB2312) + KS_C_5601_1987 = 949, // ANSI/OEM Korean (Unified Hangul Code) + BIG5 = 950, // ANSI/OEM Traditional Chinese (Taiwan; Hong Kong SAR, PRC); Chinese Traditional (Big5) + IBM1026 = 1026, // IBM EBCDIC Turkish (Latin 5) + IBM01047 = 1047, // IBM EBCDIC Latin 1/Open System + IBM01140 = 1140, // IBM EBCDIC US-Canada (037 + Euro symbol); IBM EBCDIC (US-Canada-Euro) + IBM01141 = 1141, // IBM EBCDIC Germany (20273 + Euro symbol); IBM EBCDIC (Germany-Euro) + IBM01142 = 1142, // IBM EBCDIC Denmark-Norway (20277 + Euro symbol); IBM EBCDIC (Denmark-Norway-Euro) + IBM01143 = 1143, // IBM EBCDIC Finland-Sweden (20278 + Euro symbol); IBM EBCDIC (Finland-Sweden-Euro) + IBM01144 = 1144, // IBM EBCDIC Italy (20280 + Euro symbol); IBM EBCDIC (Italy-Euro) + IBM01145 = 1145, // IBM EBCDIC Latin America-Spain (20284 + Euro symbol); IBM EBCDIC (Spain-Euro) + IBM01146 = 1146, // IBM EBCDIC United Kingdom (20285 + Euro symbol); IBM EBCDIC (UK-Euro) + IBM01147 = 1147, // IBM EBCDIC France (20297 + Euro symbol); IBM EBCDIC (France-Euro) + IBM01148 = 1148, // IBM EBCDIC International (500 + Euro symbol); IBM EBCDIC (International-Euro) + IBM01149 = 1149, // IBM EBCDIC Icelandic (20871 + Euro symbol); IBM EBCDIC (Icelandic-Euro) + UTF16 = 1200, // Unicode UTF-16, little endian byte order (BMP of ISO 10646); available only to managed applications + UNICODE_FFFE = 1201, // Unicode UTF-16, big endian byte order; available only to managed applications + WINDOWS_1250 = 1250, // ANSI Central European; Central European (Windows) + WINDOWS_1251 = 1251, // ANSI Cyrillic; Cyrillic (Windows) + WINDOWS_1252 = 1252, // ANSI Latin 1; Western European (Windows) + WINDOWS_1253 = 1253, // ANSI Greek; Greek (Windows) + WINDOWS_1254 = 1254, // ANSI Turkish; Turkish (Windows) + WINDOWS_1255 = 1255, // ANSI Hebrew; Hebrew (Windows) + WINDOWS_1256 = 1256, // ANSI Arabic; Arabic (Windows) + WINDOWS_1257 = 1257, // ANSI Baltic; Baltic (Windows) + WINDOWS_1258 = 1258, // ANSI/OEM Vietnamese; Vietnamese (Windows) + JOHAB = 1361, // Korean (Johab) + MACINTOSH = 10000, // MAC Roman; Western European (Mac) + X_MAC_JAPANESE = 10001, // Japanese (Mac) + X_MAC_CHINESETRAD = 10002, // MAC Traditional Chinese (Big5); Chinese Traditional (Mac) + X_MAC_KOREAN = 10003, // Korean (Mac) + X_MAC_ARABIC = 10004, // Arabic (Mac) + X_MAC_HEBREW = 10005, // Hebrew (Mac) + X_MAC_GREEK = 10006, // Greek (Mac) + X_MAC_CYRILLIC = 10007, // Cyrillic (Mac) + X_MAC_CHINESESIMP = 10008, // MAC Simplified Chinese (GB 2312); Chinese Simplified (Mac) + X_MAC_ROMANIAN = 10010, // Romanian (Mac) + X_MAC_UKRANIAN = 10017, // Ukrainian (Mac) + X_MAC_THAI = 10021, // Thai (Mac) + X_MAC_CE = 10029, // MAC Latin 2; Central European (Mac) + X_MAC_ICELANDIC = 10079, // Icelandic (Mac) + X_MAC_TURKISH = 10081, // Turkish (Mac) + X_MAC_CROATIAN = 10082, // Croatian (Mac) + UTF32 = 12000, // Unicode UTF-32, little endian byte order; available only to managed applications + UTF32BE = 12001, // Unicode UTF-32, big endian byte order; available only to managed applications + X_CHINESE_CNS = 20000, // CNS Taiwan; Chinese Traditional (CNS) + X_CP_20001 = 20001, // TCA Taiwan + X_CHINESE_ETEN = 20002, // Eten Taiwan; Chinese Traditional (Eten) + X_CP_20003 = 20003, // IBM5550 Taiwan + X_CP_20004 = 20004, // TeleText Taiwan + X_CP_20005 = 20005, // Wang Taiwan + X_IA5 = 20105, // IA5 (IRV International Alphabet No. 5, 7-bit); Western European (IA5) + X_IA5_GERMAN = 20106, // IA5 German (7-bit) + X_IA5_SWEDISH = 20107, // IA5 Swedish (7-bit) + X_IA5_NORWEGIAN = 20108, // IA5 Norwegian (7-bit) + US_ASCII = 20127, // US-ASCII (7-bit) + X_CP20261 = 20261, // T.61 + X_CP20269 = 20269, // ISO 6937 Non-Spacing Accent + IBM273 = 20273, // IBM EBCDIC Germany + IBM277 = 20277, // IBM EBCDIC Denmark-Norway + IBM278 = 20278, // IBM EBCDIC Finland-Sweden + IBM280 = 20280, // IBM EBCDIC Italy + IBM284 = 20284, // IBM EBCDIC Latin America-Spain + IBM285 = 20285, // IBM EBCDIC United Kingdom + IBM290 = 20290, // IBM EBCDIC Japanese Katakana Extended + IBM297 = 20297, // IBM EBCDIC France + IBM420 = 20420, // IBM EBCDIC Arabic + IBM423 = 20423, // IBM EBCDIC Greek + IBM424 = 20424, // IBM EBCDIC Hebrew X_EBCDIC_KOREAN_EXTENDED = 20833, // IBM EBCDIC Korean Extended - IBM_THAI = 20838, // IBM EBCDIC Thai - KOI8_R = 20866, // Russian (KOI8-R); Cyrillic (KOI8-R) - IBM871 = 20871, // IBM EBCDIC Icelandic - IBM880 = 20880, // IBM EBCDIC Cyrillic Russian - IBM905 = 20905, // IBM EBCDIC Turkish - IBM00924 = 20924, // IBM EBCDIC Latin 1/Open System (1047 + Euro symbol) - EUC_JP = 20932, // Japanese (JIS 0208-1990 and 0212-1990) - X_CP20936 = 20936, // Simplified Chinese (GB2312); Chinese Simplified (GB2312-80) - X_CP20949 = 20949, // Korean Wansung - CP1025 = 21025, // IBM EBCDIC Cyrillic Serbian-Bulgarian - CODEPAGE_21027 = 21027, // (deprecated) - KOI8_U = 21866, // Ukrainian (KOI8-U); Cyrillic (KOI8-U) - ISO_8859_1 = 28591, // ISO 8859-1 Latin 1; Western European (ISO) - ISO_8859_2 = 28592, // ISO 8859-2 Central European; Central European (ISO) - ISO_8859_3 = 28593, // ISO 8859-3 Latin 3 - ISO_8859_4 = 28594, // ISO 8859-4 Baltic - ISO_8859_5 = 28595, // ISO 8859-5 Cyrillic - ISO_8859_6 = 28596, // ISO 8859-6 Arabic - ISO_8859_7 = 28597, // ISO 8859-7 Greek - ISO_8859_8 = 28598, // ISO 8859-8 Hebrew; Hebrew (ISO-Visual) - ISO_8859_9 = 28599, // ISO 8859-9 Turkish - ISO_8859_13 = 28603, // ISO 8859-13 Estonian - ISO_8859_15 = 28605, // ISO 8859-15 Latin 9 - X_EUROPA = 29001, // Europa 3 - ISO_8859_8_I = 38598, // ISO 8859-8 Hebrew; Hebrew (ISO-Logical) - ISO_2022_JP = 50220, // ISO 2022 Japanese with no halfwidth Katakana; Japanese (JIS) - CS_ISO2022JP = 50221, // ISO 2022 Japanese with halfwidth Katakana; Japanese (JIS-Allow 1 byte Kana) - ISO_2022_JP2 = 50222, // ISO 2022 Japanese JIS X 0201-1989; Japanese (JIS-Allow 1 byte Kana - SO/SI) - ISO_2022_KR = 50225, // ISO 2022 Korean - X_CP50227 = 50227, // ISO 2022 Simplified Chinese; Chinese Simplified (ISO 2022) - CODEPAGE_50229 = 50229, // ISO 2022 Traditional Chinese - CODEPAGE_50930 = 50930, // EBCDIC Japanese (Katakana) Extended - CODEPAGE_50931 = 50931, // EBCDIC US-Canada and Japanese - CODEPAGE_50933 = 50933, // EBCDIC Korean Extended and Korean - CODEPAGE_50935 = 50935, // EBCDIC Simplified Chinese Extended and Simplified Chinese - CODEPAGE_50936 = 50936, // EBCDIC Simplified Chinese - CODEPAGE_50937 = 50937, // EBCDIC US-Canada and Traditional Chinese - CODEPAGE_50939 = 50939, // EBCDIC Japanese (Latin) Extended and Japanese - EUC_JP2 = 51932, // EUC Japanese - EUC_CN = 51936, // EUC Simplified Chinese; Chinese Simplified (EUC) - EUC_KR = 51949, // EUC Korean - CODEPAGE_51950 = 51950, // EUC Traditional Chinese - HZ_GB_2312 = 52936, // HZ-GB2312 Simplified Chinese; Chinese Simplified (HZ) - GB18030 = 54936, // Windows XP and later: GB18030 Simplified Chinese (4 byte); Chinese Simplified (GB18030) - X_ISCII_DE = 57002, // ISCII Devanagari - X_ISCII_BE = 57003, // ISCII Bangla - X_ISCII_TA = 57004, // ISCII Tamil - X_ISCII_TE = 57005, // ISCII Telugu - X_ISCII_AS = 57006, // ISCII Assamese - X_ISCII_OR = 57007, // ISCII Odia - X_ISCII_KA = 57008, // ISCII Kannada - X_ISCII_MA = 57009, // ISCII Malayalam - X_ISCII_GU = 57010, // ISCII Gujarati - X_ISCII_PA = 57011, // ISCII Punjabi - UTF7 = 65000, // Unicode (UTF-7) - UTF8 = 65001, // Unicode (UTF-8) + IBM_THAI = 20838, // IBM EBCDIC Thai + KOI8_R = 20866, // Russian (KOI8-R); Cyrillic (KOI8-R) + IBM871 = 20871, // IBM EBCDIC Icelandic + IBM880 = 20880, // IBM EBCDIC Cyrillic Russian + IBM905 = 20905, // IBM EBCDIC Turkish + IBM00924 = 20924, // IBM EBCDIC Latin 1/Open System (1047 + Euro symbol) + EUC_JP = 20932, // Japanese (JIS 0208-1990 and 0212-1990) + X_CP20936 = 20936, // Simplified Chinese (GB2312); Chinese Simplified (GB2312-80) + X_CP20949 = 20949, // Korean Wansung + CP1025 = 21025, // IBM EBCDIC Cyrillic Serbian-Bulgarian + CODEPAGE_21027 = 21027, // (deprecated) + KOI8_U = 21866, // Ukrainian (KOI8-U); Cyrillic (KOI8-U) + ISO_8859_1 = 28591, // ISO 8859-1 Latin 1; Western European (ISO) + ISO_8859_2 = 28592, // ISO 8859-2 Central European; Central European (ISO) + ISO_8859_3 = 28593, // ISO 8859-3 Latin 3 + ISO_8859_4 = 28594, // ISO 8859-4 Baltic + ISO_8859_5 = 28595, // ISO 8859-5 Cyrillic + ISO_8859_6 = 28596, // ISO 8859-6 Arabic + ISO_8859_7 = 28597, // ISO 8859-7 Greek + ISO_8859_8 = 28598, // ISO 8859-8 Hebrew; Hebrew (ISO-Visual) + ISO_8859_9 = 28599, // ISO 8859-9 Turkish + ISO_8859_13 = 28603, // ISO 8859-13 Estonian + ISO_8859_15 = 28605, // ISO 8859-15 Latin 9 + X_EUROPA = 29001, // Europa 3 + ISO_8859_8_I = 38598, // ISO 8859-8 Hebrew; Hebrew (ISO-Logical) + ISO_2022_JP = 50220, // ISO 2022 Japanese with no halfwidth Katakana; Japanese (JIS) + CS_ISO2022JP = 50221, // ISO 2022 Japanese with halfwidth Katakana; Japanese (JIS-Allow 1 byte Kana) + ISO_2022_JP2 = 50222, // ISO 2022 Japanese JIS X 0201-1989; Japanese (JIS-Allow 1 byte Kana - SO/SI) + ISO_2022_KR = 50225, // ISO 2022 Korean + X_CP50227 = 50227, // ISO 2022 Simplified Chinese; Chinese Simplified (ISO 2022) + CODEPAGE_50229 = 50229, // ISO 2022 Traditional Chinese + CODEPAGE_50930 = 50930, // EBCDIC Japanese (Katakana) Extended + CODEPAGE_50931 = 50931, // EBCDIC US-Canada and Japanese + CODEPAGE_50933 = 50933, // EBCDIC Korean Extended and Korean + CODEPAGE_50935 = 50935, // EBCDIC Simplified Chinese Extended and Simplified Chinese + CODEPAGE_50936 = 50936, // EBCDIC Simplified Chinese + CODEPAGE_50937 = 50937, // EBCDIC US-Canada and Traditional Chinese + CODEPAGE_50939 = 50939, // EBCDIC Japanese (Latin) Extended and Japanese + EUC_JP2 = 51932, // EUC Japanese + EUC_CN = 51936, // EUC Simplified Chinese; Chinese Simplified (EUC) + EUC_KR = 51949, // EUC Korean + CODEPAGE_51950 = 51950, // EUC Traditional Chinese + HZ_GB_2312 = 52936, // HZ-GB2312 Simplified Chinese; Chinese Simplified (HZ) + GB18030 = 54936, // Windows XP and later: GB18030 Simplified Chinese (4 byte); Chinese Simplified (GB18030) + X_ISCII_DE = 57002, // ISCII Devanagari + X_ISCII_BE = 57003, // ISCII Bangla + X_ISCII_TA = 57004, // ISCII Tamil + X_ISCII_TE = 57005, // ISCII Telugu + X_ISCII_AS = 57006, // ISCII Assamese + X_ISCII_OR = 57007, // ISCII Odia + X_ISCII_KA = 57008, // ISCII Kannada + X_ISCII_MA = 57009, // ISCII Malayalam + X_ISCII_GU = 57010, // ISCII Gujarati + X_ISCII_PA = 57011, // ISCII Punjabi + UTF7 = 65000, // Unicode (UTF-7) + UTF8 = 65001, // Unicode (UTF-8) } extern fn Win32_BOOL setConsoleOutputCP(Win32_CODEPAGE wCodePageId) @cname("SetConsoleOutputCP"); diff --git a/lib/std/os/win32/memoryapi.c3 b/lib/std/os/win32/memoryapi.c3 index bc498d1a4..0fe7e7321 100644 --- a/lib/std/os/win32/memoryapi.c3 +++ b/lib/std/os/win32/memoryapi.c3 @@ -1,6 +1,6 @@ module std::os::win32 @if(env::WIN32); -enum Win32_AllocationType : const Win32_DWORD +const enum Win32_AllocationType { MEM_COMMIT = 0x00001000, MEM_RESERVE = 0x00002000, @@ -12,7 +12,7 @@ enum Win32_AllocationType : const Win32_DWORD MEM_WRITE_WATCH = 0x00200000 } -enum Win32_Protect : const Win32_DWORD +const enum Win32_Protect : Win32_DWORD { PAGE_EXECUTE = 0x10, PAGE_EXECUTE_READ = 0x20, @@ -29,7 +29,7 @@ enum Win32_Protect : const Win32_DWORD PAGE_WRITECOMBINE = 0x400, } -enum Win32_FreeType : const Win32_DWORD +const enum Win32_FreeType : Win32_DWORD { MEM_DECOMMIT = 0x00004000, MEM_RELEASE = 0x00008000, diff --git a/lib/std/os/win32/winnt.c3 b/lib/std/os/win32/winnt.c3 index 37c437a66..8ebd0aebf 100644 --- a/lib/std/os/win32/winnt.c3 +++ b/lib/std/os/win32/winnt.c3 @@ -13,7 +13,7 @@ enum Win32_MEM_EXTENDED_PARAMETER_TYPE : CInt } alias Win32_PMEM_EXTENDED_PARAMETER_TYPE = Win32_MEM_EXTENDED_PARAMETER_TYPE; -enum Win32_MEM_EXTENDED_PARAMETER_ATTRIBUTE : const Win32_DWORD64 +const enum Win32_MEM_EXTENDED_PARAMETER_ATTRIBUTE : Win32_DWORD64 { <* The allocation is non-pageable. *> NONPAGED = 0x02, diff --git a/lib/std/time/time.c3 b/lib/std/time/time.c3 index 20a22baa3..0d50650ca 100644 --- a/lib/std/time/time.c3 +++ b/lib/std/time/time.c3 @@ -51,29 +51,29 @@ struct TzDateTime enum Weekday : char (String name, String abbrev) { - MONDAY = { "Monday", "Mon" }, - TUESDAY = { "Tuesday", "Tue" }, - WEDNESDAY = { "Wednesday", "Wed" }, - THURSDAY = { "Thursday", "Thu" }, - FRIDAY = { "Friday", "Fri" }, - SATURDAY = { "Saturday", "Sat" }, - SUNDAY = { "Sunday", "Sun" }, + MONDAY { "Monday", "Mon" }, + TUESDAY { "Tuesday", "Tue" }, + WEDNESDAY { "Wednesday", "Wed" }, + THURSDAY { "Thursday", "Thu" }, + FRIDAY { "Friday", "Fri" }, + SATURDAY { "Saturday", "Sat" }, + SUNDAY { "Sunday", "Sun" }, } enum Month : char (String name, String abbrev, int days, bool leap) { - JANUARY = { "January", "Jan", 31, false }, - FEBRUARY = { "February", "Feb", 28, true }, - MARCH = { "March", "Mar", 31, false }, - APRIL = { "April", "Apr", 30, false }, - MAY = { "May", "May", 31, false }, - JUNE = { "June", "Jun", 30, false }, - JULY = { "July", "Jul", 31, false }, - AUGUST = { "August", "Aug", 31, false }, - SEPTEMBER = { "September", "Sep", 30, false }, - OCTOBER = { "October", "Oct", 31, false }, - NOVEMBER = { "November", "Nov", 30, false }, - DECEMBER = { "December", "Dec", 31, false } + JANUARY { "January", "Jan", 31, false }, + FEBRUARY { "February", "Feb", 28, true }, + MARCH { "March", "Mar", 31, false }, + APRIL { "April", "Apr", 30, false }, + MAY { "May", "May", 31, false }, + JUNE { "June", "Jun", 30, false }, + JULY { "July", "Jul", 31, false }, + AUGUST { "August", "Aug", 31, false }, + SEPTEMBER { "September", "Sep", 30, false }, + OCTOBER { "October", "Oct", 31, false }, + NOVEMBER { "November", "Nov", 30, false }, + DECEMBER { "December", "Dec", 31, false } } fn Time now() diff --git a/releasenotes.md b/releasenotes.md index 1bf0b33e2..ea87c6775 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -9,6 +9,8 @@ - Integrated download of the MSVC SDK when compiling for Windows. - For `c3c init` with library templates, provide example exported functions. #2898 - `unsigned % signed` and `unsigned / signed` is no longer allowed without explicit casts, except for const denominators. #2928 +- New const enum declaration syntax. +- New enum associated value syntax. ### Stdlib changes - Summarize sort macros as generic function wrappers to reduce the amount of generated code. #2831 diff --git a/src/compiler/enums.h b/src/compiler/enums.h index ffa47fd67..9d8cb366d 100644 --- a/src/compiler/enums.h +++ b/src/compiler/enums.h @@ -1222,6 +1222,7 @@ typedef enum TOKEN_BREAK, TOKEN_CASE, TOKEN_CATCH, + TOKEN_CENUM, TOKEN_CONST, TOKEN_CONTINUE, TOKEN_DEFAULT, diff --git a/src/compiler/parse_global.c b/src/compiler/parse_global.c index c141d6edd..22cd7074b 100644 --- a/src/compiler/parse_global.c +++ b/src/compiler/parse_global.c @@ -13,6 +13,7 @@ typedef enum FunctionParse_ FUNC_PARSE_INTERFACE, } FunctionParse; +static inline Decl *parse_enum_declaration(ParseContext *c, bool is_const); static inline Decl *parse_func_definition(ParseContext *c, AstId contracts, FunctionParse parse_kind); static inline bool parse_bitstruct_body(ParseContext *c, Decl *decl); static inline bool parse_enum_param_list(ParseContext *c, Decl*** parameters_ref, ArrayIndex *inline_index); @@ -2288,6 +2289,10 @@ static inline Decl *parse_bitstruct_declaration(ParseContext *c) static inline Decl *parse_top_level_const_declaration(ParseContext *c, bool is_extern) { + if (!is_extern && peek(c) == TOKEN_ENUM) + { + return parse_enum_declaration(c, true); + } ASSIGN_DECL_OR_RET(Decl *decl, parse_const_declaration(c, true, is_extern), poisoned_decl); CONSUME_EOS_OR_RET(poisoned_decl); return decl; @@ -2789,6 +2794,7 @@ static inline bool parse_enum_param_list(ParseContext *c, Decl*** parameters_ref static bool parse_enum_values(ParseContext *c, Decl*** values_ref, Visibility visibility, bool is_single_value, bool is_const_enum) { Decl **values = NULL; + bool deprecate_warn = true; while (!try_consume(c, TOKEN_RBRACE)) { if (!parse_element_contract(c, "enum values")) return false; @@ -2810,6 +2816,11 @@ static bool parse_enum_values(ParseContext *c, Decl*** values_ref, Visibility vi if (try_consume(c, TOKEN_EQ)) { Expr **args = NULL; + if (!is_const_enum && deprecate_warn) + { + deprecate_warn = false; + print_deprecation_at(c->prev_span, "Use () declaration of associated values instead."); + } if (is_single_value || !tok_is(c, TOKEN_LBRACE)) { ASSIGN_EXPR_OR_RET(Expr *single, parse_constant_expr(c), false); @@ -2839,8 +2850,7 @@ static bool parse_enum_values(ParseContext *c, Decl*** values_ref, Visibility vi { if (!try_consume(c, TOKEN_RBRACE)) { - PRINT_ERROR_HERE("A comma or a closing brace was expected here."); - return false; + RETURN_PRINT_ERROR_HERE("A comma or a closing brace was expected here."); } break; } @@ -2848,6 +2858,33 @@ static bool parse_enum_values(ParseContext *c, Decl*** values_ref, Visibility vi } enum_const->enum_constant.associated = args; } + else if (!is_const_enum && try_consume(c, TOKEN_LBRACE)) + { + Expr **args = NULL; + while (1) + { + if (try_consume(c, TOKEN_RBRACE)) break; + ASSIGN_EXPR_OR_RET(Expr *arg, parse_expr(c), false); + vec_add(args, arg); + if (tok_is(c, TOKEN_COLON) && arg->expr_kind == EXPR_UNRESOLVED_IDENTIFIER) + { + print_error_at(extend_span_with_token(arg->span, c->span), + "This looks like a named param call, but that style of declaration " + "is not supported for declaring enum associated values."); + return false; + } + + if (!try_consume(c, TOKEN_COMMA)) + { + if (!try_consume(c, TOKEN_RBRACE)) + { + RETURN_PRINT_ERROR_HERE("A comma or a closing brace was expected here."); + } + break; + } + } + enum_const->enum_constant.associated = args; + } NEXT: vec_add(values, enum_const); // Allow trailing ',' @@ -2872,9 +2909,18 @@ NEXT: * enum_body ::= enum_def (',' enum_def)* ','? * enum_def ::= CONST_IDENT ('(' arg_list ')')? */ -static inline Decl *parse_enum_declaration(ParseContext *c) +static inline Decl *parse_enum_declaration(ParseContext *c, bool is_const) { - advance_and_verify(c, TOKEN_ENUM); + if (is_const) advance_and_verify(c, TOKEN_CONST); + if (tok_is(c, TOKEN_CENUM)) + { + advance_and_verify(c, TOKEN_CENUM); + is_const = true; + } + else + { + advance_and_verify(c, TOKEN_ENUM); + } const char *name = symstr(c); SourceSpan span = c->span; @@ -2885,11 +2931,18 @@ static inline Decl *parse_enum_declaration(ParseContext *c) bool val_is_inline = false; ArrayIndex inline_index = -1; - bool is_const_enum = false; + bool is_const_enum = is_const; Decl **param_list = NULL; if (try_consume(c, TOKEN_COLON)) { - is_const_enum = try_consume(c, TOKEN_CONST); + if (!is_const) + { + is_const_enum = try_consume(c, TOKEN_CONST); + if (is_const_enum) + { + print_deprecation_at(c->prev_span, "Declare const enums using 'const enum' instead."); + } + } if (!tok_is(c, TOKEN_LPAREN) && !tok_is(c, TOKEN_LBRACE)) { val_is_inline = try_consume(c, TOKEN_INLINE); @@ -3585,7 +3638,8 @@ Decl *parse_top_level_statement(ParseContext *c, ParseContext **context_out) decl = parse_macro_declaration(c, contracts); break; case TOKEN_ENUM: - decl = parse_enum_declaration(c); + case TOKEN_CENUM: + decl = parse_enum_declaration(c, false); attach_contracts = true; break; case TOKEN_FAULTDEF: diff --git a/src/compiler/parse_stmt.c b/src/compiler/parse_stmt.c index b9f98c1c1..3877e9a99 100644 --- a/src/compiler/parse_stmt.c +++ b/src/compiler/parse_stmt.c @@ -1444,6 +1444,7 @@ Ast *parse_stmt(ParseContext *c) case TOKEN_BIT_AND_ASSIGN: case TOKEN_BIT_OR_ASSIGN: case TOKEN_BIT_XOR_ASSIGN: + case TOKEN_CENUM: case TOKEN_COLON: case TOKEN_COMMA: case TOKEN_CT_CASE: diff --git a/src/compiler/tokens.c b/src/compiler/tokens.c index 6f5abeb04..8d659ba2e 100644 --- a/src/compiler/tokens.c +++ b/src/compiler/tokens.c @@ -199,6 +199,8 @@ const char *token_type_to_string(TokenType type) return "break"; case TOKEN_CASE: return "case"; + case TOKEN_CENUM: + return "cenum"; case TOKEN_CATCH: return "catch"; case TOKEN_CONST: diff --git a/test/test_suite/any/generic_interface_stage.c3t b/test/test_suite/any/generic_interface_stage.c3t index 3d1b35665..371b45e6f 100644 --- a/test/test_suite/any/generic_interface_stage.c3t +++ b/test/test_suite/any/generic_interface_stage.c3t @@ -1,7 +1,7 @@ import std; fn int foo() => 0; alias FooFn = fn int(); -enum Bar : const FooFn +const enum Bar : FooFn { FOO = fn () => (int)(iptr)ExclusiveRange{int}.typeid, BAR = &foo, diff --git a/test/test_suite/attributes/format_check_error.c3 b/test/test_suite/attributes/format_check_error.c3 index 98be46c40..1da7bb7e6 100644 --- a/test/test_suite/attributes/format_check_error.c3 +++ b/test/test_suite/attributes/format_check_error.c3 @@ -3,9 +3,9 @@ import std; const VERSION = "2.0"; enum Subcommand : (String name, String desc, String[] args) { - FOO = {"oekfe", "foek", { "foke", "foekfe"}}, - BAR = {"foek", "foek", { "foekf", "foekfe"}}, - BAZ = {"Foekfef", "foek", { "foke", "foekfe" }} + FOO {"oekfe", "foek", { "foke", "foekfe"}}, + BAR {"foek", "foek", { "foekf", "foekfe"}}, + BAZ {"Foekfef", "foek", { "foke", "foekfe" }} } macro void help (String program_name, bool to_stderr = false) { diff --git a/test/test_suite/compile_time/compile_time_array_bug.c3t b/test/test_suite/compile_time/compile_time_array_bug.c3t index 135ae00c2..b12c519b8 100644 --- a/test/test_suite/compile_time/compile_time_array_bug.c3t +++ b/test/test_suite/compile_time/compile_time_array_bug.c3t @@ -1,10 +1,10 @@ // #target: macos-x64 module test; enum TokenType: char (char token) { - ERROR = 0, - INCP = '>', - DECP = '>', - LOOPS = '[', + ERROR { 0 }, + INCP { '>' }, + DECP { '>' }, + LOOPS { '[' }, } macro populate_token_table() { diff --git a/test/test_suite/compile_time/comptime_array_folding.c3t b/test/test_suite/compile_time/comptime_array_folding.c3t index 0cfd85a0a..429d7ccd2 100644 --- a/test/test_suite/compile_time/comptime_array_folding.c3t +++ b/test/test_suite/compile_time/comptime_array_folding.c3t @@ -25,7 +25,7 @@ struct ThisOtherStruct @TaggedAttr(VALUE_STRUCT) enum Example : int (String str) @TaggedAttr(VALUE_STRUCT) { - FOO = FOO_STR, + FOO {FOO_STR}, } const int[2][1] BAR = { { 1, 2} }; diff --git a/test/test_suite/compile_time_introspection/membersof_enum.c3t b/test/test_suite/compile_time_introspection/membersof_enum.c3t index c7c632f78..45fef8c23 100644 --- a/test/test_suite/compile_time_introspection/membersof_enum.c3t +++ b/test/test_suite/compile_time_introspection/membersof_enum.c3t @@ -4,8 +4,8 @@ import std; enum Foo : (String x, int val) { - ABC = { "Hello", 3 }, - DEF = { "World", -100 }, + ABC { "Hello", 3 }, + DEF { "World", -100 }, } fn int main() diff --git a/test/test_suite/compile_time_introspection/membersof_enum2.c3 b/test/test_suite/compile_time_introspection/membersof_enum2.c3 index 1b0909fd9..c67fd1632 100644 --- a/test/test_suite/compile_time_introspection/membersof_enum2.c3 +++ b/test/test_suite/compile_time_introspection/membersof_enum2.c3 @@ -3,8 +3,8 @@ import std; enum Foo : (String x, int val) { - ABC = { "Hello", 3 }, - DEF = { "World", -100 }, + ABC { "Hello", 3 }, + DEF { "World", -100 }, } fn int main() diff --git a/test/test_suite/enumerations/const_enum.c3 b/test/test_suite/enumerations/const_enum.c3 index fa536247a..7ebf564d2 100644 --- a/test/test_suite/enumerations/const_enum.c3 +++ b/test/test_suite/enumerations/const_enum.c3 @@ -1,6 +1,6 @@ import std::io; -enum MyEnum : const inline CInt +const enum MyEnum : inline CInt { FOO = 1, BAR = 5, diff --git a/test/test_suite/enumerations/const_enum_inline.c3t b/test/test_suite/enumerations/const_enum_inline.c3t index a9ebf4866..d2ab2aba8 100644 --- a/test/test_suite/enumerations/const_enum_inline.c3t +++ b/test/test_suite/enumerations/const_enum_inline.c3t @@ -1,6 +1,6 @@ // #target: macos-x64 module test; -enum Foo : const inline String +const enum Foo : inline String { HELO = "Helo" } diff --git a/test/test_suite/enumerations/const_enum_inline_member.c3t b/test/test_suite/enumerations/const_enum_inline_member.c3t index 0115fe8d6..662a06d52 100644 --- a/test/test_suite/enumerations/const_enum_inline_member.c3t +++ b/test/test_suite/enumerations/const_enum_inline_member.c3t @@ -5,7 +5,7 @@ struct Bar uint x, y, z; } -enum Foo : const inline Bar +const enum Foo : inline Bar { X = {1, 0, 0}, Y = {0, 1, 0}, diff --git a/test/test_suite/enumerations/const_enum_methods.c3t b/test/test_suite/enumerations/const_enum_methods.c3t index 1f2b1cada..b176d0556 100644 --- a/test/test_suite/enumerations/const_enum_methods.c3t +++ b/test/test_suite/enumerations/const_enum_methods.c3t @@ -1,7 +1,7 @@ // #target: macos-x64 module test; -enum Enum : const int +const enum Enum : int { E0, E1 } diff --git a/test/test_suite/enumerations/const_enum_self_ref.c3 b/test/test_suite/enumerations/const_enum_self_ref.c3 index 140b263ad..7a5e8d821 100644 --- a/test/test_suite/enumerations/const_enum_self_ref.c3 +++ b/test/test_suite/enumerations/const_enum_self_ref.c3 @@ -1,4 +1,4 @@ -enum MyEnum : const +const enum MyEnum { VAL1 = VAL3, // #error: Unable to properly resolve enum constant value, this can sometimes happen in recursive definitions VAL2 , diff --git a/test/test_suite/enumerations/const_enum_vector.c3t b/test/test_suite/enumerations/const_enum_vector.c3t index cbcb35aac..307ab99bc 100644 --- a/test/test_suite/enumerations/const_enum_vector.c3t +++ b/test/test_suite/enumerations/const_enum_vector.c3t @@ -2,7 +2,7 @@ module test; import std; -enum Color : const char[<4>] +const enum Color : char[<4>] { LIGHTGRAY = { 200, 200, 200, 255 }, } diff --git a/test/test_suite/enumerations/const_enum_with_function_ptr.c3t b/test/test_suite/enumerations/const_enum_with_function_ptr.c3t index 83729ab90..fdbada087 100644 --- a/test/test_suite/enumerations/const_enum_with_function_ptr.c3t +++ b/test/test_suite/enumerations/const_enum_with_function_ptr.c3t @@ -6,11 +6,11 @@ alias FooFn = fn int(); enum Foo : (FooFn f) { - FOO = fn int() => 0, // allowed - BAR = &foo, // allowed + FOO { fn int() => 0 }, // allowed + BAR { &foo }, // allowed } -enum Bar : const FooFn +const enum Bar : FooFn { FOO = fn int() => 0, // allowed BAR = &foo, // Error: Expected an constant enum value. diff --git a/test/test_suite/enumerations/enum_associated_value.c3t b/test/test_suite/enumerations/enum_associated_value.c3t index 5c5054874..ee6249d03 100644 --- a/test/test_suite/enumerations/enum_associated_value.c3t +++ b/test/test_suite/enumerations/enum_associated_value.c3t @@ -4,8 +4,8 @@ import libc; enum Foo : uint (int val, char* testme) { - A = { 123, "Number A" }, - B = { 333, "Number B" }, + A { 123, "Number A" }, + B { 333, "Number B" }, } fn void main() diff --git a/test/test_suite/enumerations/enum_associated_values_other.c3t b/test/test_suite/enumerations/enum_associated_values_other.c3t index 4c067c6b9..f07dc3f75 100644 --- a/test/test_suite/enumerations/enum_associated_values_other.c3t +++ b/test/test_suite/enumerations/enum_associated_values_other.c3t @@ -18,8 +18,8 @@ int dabc; struct Abc { int x; } enum Foo : int (String val) { - ABC = "hello" , - DEF = "world" + ABC {"hello"}, + DEF {"world"} } /* #expect: abc.ll diff --git a/test/test_suite/enumerations/enum_const.c3t b/test/test_suite/enumerations/enum_const.c3t index acdefd6f9..304867db2 100644 --- a/test/test_suite/enumerations/enum_const.c3t +++ b/test/test_suite/enumerations/enum_const.c3t @@ -2,13 +2,13 @@ module test; import std; -enum Bar : const String +const enum Bar : String { XABC = "foekf", XDEF = "foekfokef" } -enum Foo : const int +const enum Foo : int { ABC = 4, DEF, @@ -18,7 +18,7 @@ enum Foo : const int } -enum Bde2 : const int +const enum Bde2 : int { FOO = 2, BAR = 100 @@ -30,7 +30,7 @@ const BDE3_BAR = 100; -enum Abc2 : const int +const enum Abc2 : int { UP, DOWN, diff --git a/test/test_suite/enumerations/enum_const_inline_interface.c3 b/test/test_suite/enumerations/enum_const_inline_interface.c3 index 5731012de..23bfd8a74 100644 --- a/test/test_suite/enumerations/enum_const_inline_interface.c3 +++ b/test/test_suite/enumerations/enum_const_inline_interface.c3 @@ -12,7 +12,7 @@ fn void Foo.x(&self) @dynamic io::printn("Foo!"); } -enum Tester : const inline Foo +const enum Tester : inline Foo { ABC = 1 } diff --git a/test/test_suite/enumerations/enum_const_resolution_order.c3t b/test/test_suite/enumerations/enum_const_resolution_order.c3t index f7f137428..ea79c2dfb 100644 --- a/test/test_suite/enumerations/enum_const_resolution_order.c3t +++ b/test/test_suite/enumerations/enum_const_resolution_order.c3t @@ -8,7 +8,7 @@ struct Foo module bar; -enum MyEnum : const CInt +const enum MyEnum : CInt { VAL1 = 1, VAL2 = 2, diff --git a/test/test_suite/enumerations/enum_copy.c3t b/test/test_suite/enumerations/enum_copy.c3t index 3c7935144..015de3668 100644 --- a/test/test_suite/enumerations/enum_copy.c3t +++ b/test/test_suite/enumerations/enum_copy.c3t @@ -2,7 +2,7 @@ module generic_module_enum ; enum Foo : char (String s) { - BAR = "bar", + BAR {"bar"}, } module generic_module_enum_test; diff --git a/test/test_suite/enumerations/enum_invalid_param.c3 b/test/test_suite/enumerations/enum_invalid_param.c3 index 3c49e174b..fc46916c5 100644 --- a/test/test_suite/enumerations/enum_invalid_param.c3 +++ b/test/test_suite/enumerations/enum_invalid_param.c3 @@ -1,14 +1,14 @@ enum Test : int (int kindof, int qnameof) { - FOO = {1, 2} + FOO {1, 2} } enum Test2 : (int a, int nameof) // #error: 'nameof' is not a valid parameter name for enums { - FOO = {1, 2} + FOO {1, 2} } enum Test3 : (int a, int ordinal) // #error: 'ordinal' is not a valid parameter name for enums { - FOO = {1, 2} + FOO {1, 2} } diff --git a/test/test_suite/enumerations/enum_no_inline_property.c3 b/test/test_suite/enumerations/enum_no_inline_property.c3 index 943f0db96..c8ddbe20e 100644 --- a/test/test_suite/enumerations/enum_no_inline_property.c3 +++ b/test/test_suite/enumerations/enum_no_inline_property.c3 @@ -1,5 +1,5 @@ module test; -enum MyEnum : const inline short +const enum MyEnum : inline short { ITEM1, ITEM2, diff --git a/test/test_suite/enumerations/enum_parse_arg.c3 b/test/test_suite/enumerations/enum_parse_arg.c3 index 065ef7686..25da11860 100644 --- a/test/test_suite/enumerations/enum_parse_arg.c3 +++ b/test/test_suite/enumerations/enum_parse_arg.c3 @@ -1,4 +1,4 @@ enum Foo : (int x, int y) { - ABC = { 1 2 } // #error: A comma or a closing brace + ABC { 1 2 } // #error: A comma or a closing brace } diff --git a/test/test_suite/enumerations/enum_recursive.c3 b/test/test_suite/enumerations/enum_recursive.c3 index a7dfcf129..5f96388c1 100644 --- a/test/test_suite/enumerations/enum_recursive.c3 +++ b/test/test_suite/enumerations/enum_recursive.c3 @@ -2,13 +2,13 @@ module test; enum Bar : (Foo x) { - ABC = BAR + ABC {BAR} } enum Foo : (Bar b, Foo a) { - FOO = { ABC, BAR }, - BAR = { ABC, BAR } + FOO { ABC, BAR }, + BAR { ABC, BAR } } fn void main() diff --git a/test/test_suite/enumerations/enum_same_param.c3 b/test/test_suite/enumerations/enum_same_param.c3 index 4f1a928fb..1d12f5ba2 100644 --- a/test/test_suite/enumerations/enum_same_param.c3 +++ b/test/test_suite/enumerations/enum_same_param.c3 @@ -1,9 +1,9 @@ enum Test : (int a, int b) { - FOO = { 1, 2 } + FOO { 1, 2 } } enum Test2 : int (int a, int a) // #error: Duplicate parameter name 'a' { - FOO = { 1, 2 } + FOO { 1, 2 } } diff --git a/test/test_suite/enumerations/enum_with_associated_value_decl.c3 b/test/test_suite/enumerations/enum_with_associated_value_decl.c3 index 485fc9489..bea6c7176 100644 --- a/test/test_suite/enumerations/enum_with_associated_value_decl.c3 +++ b/test/test_suite/enumerations/enum_with_associated_value_decl.c3 @@ -1,7 +1,7 @@ enum Test2 : (usz a, usz b) { - FOO = {4, 5, }, + FOO {4, 5, }, } enum Test : (usz a, usz b) { - FOO = {a: 1, b: 1}, // #error: This looks like + FOO {a: 1, b: 1}, // #error: This looks like } \ No newline at end of file diff --git a/test/test_suite/enumerations/enum_with_const.c3t b/test/test_suite/enumerations/enum_with_const.c3t index 3474872a7..3f261f780 100644 --- a/test/test_suite/enumerations/enum_with_const.c3t +++ b/test/test_suite/enumerations/enum_with_const.c3t @@ -6,10 +6,10 @@ const FG_GREEN = "\e[0;38;2;192;255;192m"; const FG_RED = "\e[0;38;2;255;40;40m"; enum SeverityTag : int (String fg, String label) { - INFO = { FG_GREEN, "info" }, - WARN = { FG_YELLOW, "warn" }, - FATAL = { FG_RED, "fatal" }, - FATAL2 = { FG_RED, "fatal2" }, + INFO { FG_GREEN, "info" }, + WARN { FG_YELLOW, "warn" }, + FATAL { FG_RED, "fatal" }, + FATAL2 { FG_RED, "fatal2" }, } fn void main() diff --git a/test/test_suite/enumerations/introspection_data_error.c3t b/test/test_suite/enumerations/introspection_data_error.c3t index 6d642f7f2..9b34221af 100644 --- a/test/test_suite/enumerations/introspection_data_error.c3t +++ b/test/test_suite/enumerations/introspection_data_error.c3t @@ -1,7 +1,7 @@ // #target: macos-x64 module boom; enum Boom: int (String a) { - BOOM = {0} + BOOM {{0}} } module app; diff --git a/test/test_suite/enumerations/lambda_in_enum.c3t b/test/test_suite/enumerations/lambda_in_enum.c3t index 2dd6f337f..791a527ca 100644 --- a/test/test_suite/enumerations/lambda_in_enum.c3t +++ b/test/test_suite/enumerations/lambda_in_enum.c3t @@ -3,7 +3,7 @@ module test; alias SomethingFn = fn void(); enum TestEnum : char (SomethingFn f) { - FOO = fn () {} + FOO {fn () {}} } /* #expect: test.ll diff --git a/test/test_suite/enumerations/recursive_const_enum.c3 b/test/test_suite/enumerations/recursive_const_enum.c3 index 8f1082682..2fc65533b 100644 --- a/test/test_suite/enumerations/recursive_const_enum.c3 +++ b/test/test_suite/enumerations/recursive_const_enum.c3 @@ -2,7 +2,7 @@ module main; faultdef F; -enum Foo : const fault +const enum Foo : fault { F = F // #error: Recursive resolution of expression } diff --git a/test/test_suite/enumerations/too_many_associated.c3 b/test/test_suite/enumerations/too_many_associated.c3 index cab918c8c..4e7f8fd82 100644 --- a/test/test_suite/enumerations/too_many_associated.c3 +++ b/test/test_suite/enumerations/too_many_associated.c3 @@ -1,9 +1,9 @@ enum Baz : (String a, int z) { - BAR = { "123", 1, 3 }, // #error: You're adding too many values, only 2 associated + BAR { "123", 1, 3 }, // #error: You're adding too many values, only 2 associated } enum Baz2 : (String a, int z) { - BAR = { "123" }, // #error: Expected 2 associated values for this enum value + BAR { "123" }, // #error: Expected 2 associated values for this enum value } \ No newline at end of file diff --git a/test/test_suite/expressions/casts/inline_to_underlying.c3t b/test/test_suite/expressions/casts/inline_to_underlying.c3t index a2fd1b893..d17a31682 100644 --- a/test/test_suite/expressions/casts/inline_to_underlying.c3t +++ b/test/test_suite/expressions/casts/inline_to_underlying.c3t @@ -6,7 +6,7 @@ enum Foo : inline int { ABC, } -enum Bar : const inline int +const enum Bar : inline int { HELLO = 1 } diff --git a/test/test_suite/switch/switch_in_defer_macro.c3t b/test/test_suite/switch/switch_in_defer_macro.c3t index 306171773..31ce3dde4 100644 --- a/test/test_suite/switch/switch_in_defer_macro.c3t +++ b/test/test_suite/switch/switch_in_defer_macro.c3t @@ -409,16 +409,16 @@ alias Kind = lexer::Kind{Token, Comment}; enum Token : char (String token) { - KEYWORD1 = "keyword1", - KEYWORD2 = "keyword2", - SINGLE = "//", - MULTI = "/*", + KEYWORD1 { "keyword1" }, + KEYWORD2 { "keyword2" }, + SINGLE { "//" }, + MULTI { "/*" }, } enum Comment : char (Token start, String end) { - SINGLE = { SINGLE, "\n" }, - MULTI = { MULTI, "*/" }, + SINGLE { SINGLE, "\n" }, + MULTI { MULTI, "*/" }, } fn bool is_ident_char(usz i, char c) diff --git a/test/unit/stdlib/collections/linked_map.c3 b/test/unit/stdlib/collections/linked_map.c3 index 1722f8000..edb91be04 100644 --- a/test/unit/stdlib/collections/linked_map.c3 +++ b/test/unit/stdlib/collections/linked_map.c3 @@ -186,7 +186,7 @@ enum Foobar : inline char BAZ } -enum Foobar2 : const inline int +const enum Foobar2 : inline int { ABC = 3, DEF = 5, diff --git a/test/unit/stdlib/collections/map.c3 b/test/unit/stdlib/collections/map.c3 index ab80d2e8c..b04da12c8 100644 --- a/test/unit/stdlib/collections/map.c3 +++ b/test/unit/stdlib/collections/map.c3 @@ -63,7 +63,7 @@ enum Foobar : inline char BAZ } -enum Foobar2 : const inline int +const enum Foobar2 : inline int { ABC = 3, DEF = 5,