diff options
| author | realtradam <[email protected]> | 2023-04-12 15:55:33 -0400 |
|---|---|---|
| committer | realtradam <[email protected]> | 2023-04-12 15:55:33 -0400 |
| commit | 0841165881871ee01b782129be681209aeed2423 (patch) | |
| tree | 8a76b61dcaab381b6b42305201ae8b6259f6b6c0 /include/stc/priv | |
| parent | 554f3e8acf7855b5d6a90cc68cefb7445460b03c (diff) | |
| parent | 0516aa3ae823ed9a22b2c5f776948c8447c32c31 (diff) | |
| download | STC-modified-0841165881871ee01b782129be681209aeed2423.tar.gz STC-modified-0841165881871ee01b782129be681209aeed2423.zip | |
Merge branch 'master' into modified
Diffstat (limited to 'include/stc/priv')
| -rw-r--r-- | include/stc/priv/altnames.h | 4 | ||||
| -rw-r--r-- | include/stc/priv/raii.h | 27 | ||||
| -rw-r--r-- | include/stc/priv/template.h | 76 | ||||
| -rw-r--r-- | include/stc/priv/template2.h | 78 |
4 files changed, 115 insertions, 70 deletions
diff --git a/include/stc/priv/altnames.h b/include/stc/priv/altnames.h index b10c7a11..723b6a66 100644 --- a/include/stc/priv/altnames.h +++ b/include/stc/priv/altnames.h @@ -23,7 +23,6 @@ #define c_FORLIST c_forlist #define c_FORRANGE c_forrange #define c_FOREACH c_foreach -#define c_FORWHILE c_forwhile #define c_FORPAIR c_forpair #define c_FORFILTER c_forfilter #define c_FORMATCH c_formatch @@ -33,6 +32,3 @@ #define c_WITH c_with #define c_SCOPE c_scope #define c_DEFER c_defer -#define c_NEW c_new -#define c_ARRAYLEN c_arraylen -#define c_ARGSV c_SV // [deprecated] diff --git a/include/stc/priv/raii.h b/include/stc/priv/raii.h new file mode 100644 index 00000000..bb41e0d1 --- /dev/null +++ b/include/stc/priv/raii.h @@ -0,0 +1,27 @@ +#define c_defer(...) \ + for (int _i = 1; _i; _i = 0, __VA_ARGS__) + +#define c_with(...) c_MACRO_OVERLOAD(c_with, __VA_ARGS__) +#define c_with_2(declvar, drop) \ + for (declvar, *_i, **_ip = &_i; _ip; _ip = 0, drop) +#define c_with_3(declvar, pred, drop) \ + for (declvar, *_i, **_ip = &_i; _ip && (pred); _ip = 0, drop) + +#define c_scope(...) c_MACRO_OVERLOAD(c_scope, __VA_ARGS__) +#define c_scope_2(init, drop) \ + for (int _i = (init, 1); _i; _i = 0, drop) +#define c_scope_3(init, pred, drop) \ + for (int _i = (init, 1); _i && (pred); _i = 0, drop) + +#define c_auto(...) c_MACRO_OVERLOAD(c_auto, __VA_ARGS__) +#define c_auto_2(C, a) \ + c_with_2(C a = C##_init(), C##_drop(&a)) +#define c_auto_3(C, a, b) \ + c_with_2(c_EXPAND(C a = C##_init(), b = C##_init()), \ + (C##_drop(&b), C##_drop(&a))) +#define c_auto_4(C, a, b, c) \ + c_with_2(c_EXPAND(C a = C##_init(), b = C##_init(), c = C##_init()), \ + (C##_drop(&c), C##_drop(&b), C##_drop(&a))) +#define c_auto_5(C, a, b, c, d) \ + c_with_2(c_EXPAND(C a = C##_init(), b = C##_init(), c = C##_init(), d = C##_init()), \ + (C##_drop(&d), C##_drop(&c), C##_drop(&b), C##_drop(&a))) diff --git a/include/stc/priv/template.h b/include/stc/priv/template.h index e352f488..16ef51af 100644 --- a/include/stc/priv/template.h +++ b/include/stc/priv/template.h @@ -20,28 +20,28 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#ifndef _i_template +#ifdef _i_template + #error template.h already included +#endif #define _i_template #ifndef STC_TEMPLATE_H_INCLUDED #define STC_TEMPLATE_H_INCLUDED - #define _cx_self c_PASTE(_i_prefix, i_tag) + #define _cx_self i_type #define _cx_memb(name) c_PASTE(_cx_self, name) #define _cx_deftypes(macro, SELF, ...) c_EXPAND(macro(SELF, __VA_ARGS__)) #define _cx_value _cx_memb(_value) #define _cx_key _cx_memb(_key) #define _cx_mapped _cx_memb(_mapped) #define _cx_raw _cx_memb(_raw) - #define _cx_rawkey _cx_memb(_rawkey) + #define _cx_keyraw _cx_memb(_keyraw) #define _cx_iter _cx_memb(_iter) #define _cx_result _cx_memb(_result) #define _cx_node _cx_memb(_node) #endif -#ifdef i_type - #define i_tag i_type - #undef _i_prefix - #define _i_prefix +#ifndef i_type + #define i_type c_PASTE(_i_prefix, i_tag) #endif #ifndef i_ssize @@ -96,6 +96,9 @@ #endif #endif +#if c_option(c_is_forward) + #define i_is_forward +#endif #if c_option(c_no_cmp) #define i_no_cmp #endif @@ -289,62 +292,3 @@ #ifndef _i_has_from #define i_no_emplace #endif - -#else // ============================================================ - -#undef i_type -#undef i_tag -#undef i_imp -#undef i_opt -#undef i_less -#undef i_cmp -#undef i_eq -#undef i_hash -#undef i_rawclass -#undef i_capacity -#undef i_ssize - -#undef i_val -#undef i_val_str -#undef i_val_ssv -#undef i_valboxed -#undef i_valclass -#undef i_valraw -#undef i_valclone -#undef i_valfrom -#undef i_valto -#undef i_valdrop - -#undef i_key -#undef i_key_str -#undef i_key_ssv -#undef i_keyboxed -#undef i_keyclass -#undef i_keyraw -#undef i_keyclone -#undef i_keyfrom -#undef i_keyto -#undef i_keydrop - -#undef i_header -#undef i_implement -#undef i_static -#undef i_extern - -#undef i_allocator -#undef i_malloc -#undef i_calloc -#undef i_realloc -#undef i_free - -#undef i_no_cmp -#undef i_no_hash -#undef i_no_clone -#undef i_no_emplace - -#undef _i_prefix -#undef _i_expandby -#undef _i_has_from -#undef _i_has_eq -#undef _i_template -#endif diff --git a/include/stc/priv/template2.h b/include/stc/priv/template2.h new file mode 100644 index 00000000..27c6a890 --- /dev/null +++ b/include/stc/priv/template2.h @@ -0,0 +1,78 @@ +/* MIT License + * + * Copyright (c) 2023 Tyge Løvset + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#undef i_type +#undef i_tag +#undef i_imp +#undef i_opt +#undef i_less +#undef i_cmp +#undef i_eq +#undef i_hash +#undef i_rawclass +#undef i_capacity +#undef i_ssize + +#undef i_val +#undef i_val_str +#undef i_val_ssv +#undef i_valboxed +#undef i_valclass +#undef i_valraw +#undef i_valclone +#undef i_valfrom +#undef i_valto +#undef i_valdrop + +#undef i_key +#undef i_key_str +#undef i_key_ssv +#undef i_keyboxed +#undef i_keyclass +#undef i_keyraw +#undef i_keyclone +#undef i_keyfrom +#undef i_keyto +#undef i_keydrop + +#undef i_header +#undef i_implement +#undef i_static +#undef i_extern + +#undef i_allocator +#undef i_malloc +#undef i_calloc +#undef i_realloc +#undef i_free + +#undef i_no_cmp +#undef i_no_hash +#undef i_no_clone +#undef i_no_emplace +#undef i_is_forward + +#undef _i_prefix +#undef _i_expandby +#undef _i_has_from +#undef _i_has_eq +#undef _i_template |
