diff options
| -rw-r--r-- | docs/clist_api.md | 8 | ||||
| -rw-r--r-- | include/stc/clist.h | 4 | ||||
| -rw-r--r-- | misc/examples/intrusive.c | 6 | ||||
| -rw-r--r-- | src/utf8tabs.py | 26 |
4 files changed, 24 insertions, 20 deletions
diff --git a/docs/clist_api.md b/docs/clist_api.md index 9745fcdb..e97d7b5d 100644 --- a/docs/clist_api.md +++ b/docs/clist_api.md @@ -76,15 +76,17 @@ clist_X_iter clist_X_splice_range(clist_X* self, clist_X_iter it, clist_X_iter clist_X_find(const clist_X* self, i_valraw raw); clist_X_iter clist_X_find_in(clist_X_iter it1, clist_X_iter it2, i_valraw raw); -const i_val* clist_X_get(const clist_X* self, i_valraw val); -i_val* clist_X_get_mut(clist_X* self, i_valraw val); +const i_val* clist_X_get(const clist_X* self, i_valraw raw); +i_val* clist_X_get_mut(clist_X* self, i_valraw raw); void clist_X_sort(clist_X* self); void clist_X_reverse(clist_X* self); + // Node API +clist_X_node* clist_X_get_node(clist_X_value* val); // get the enclosing node clist_X_value* clist_X_push_node_back(clist_X* self, clist_X_node* node); clist_X_value* clist_X_insert_node_after(clist_X* self, clist_X_node* ref, clist_X_node* node); -clist_X_node* clist_X_unlink_node_after(clist_X* self, clist_X_node* ref); // return unlinked +clist_X_node* clist_X_unlink_node_after(clist_X* self, clist_X_node* ref); // return the unlinked node void clist_X_erase_node_after(clist_X* self, clist_X_node* node); clist_X_iter clist_X_begin(const clist_X* self); diff --git a/include/stc/clist.h b/include/stc/clist.h index 6f5c44f3..37fa447a 100644 --- a/include/stc/clist.h +++ b/include/stc/clist.h @@ -110,11 +110,11 @@ STC_API _cx_value* _cx_memb(_push_node_back)(_cx_self* self, _cx_node* node STC_API _cx_value* _cx_memb(_insert_node_after)(_cx_self* self, _cx_node* ref, _cx_node* node); STC_API _cx_node* _cx_memb(_unlink_node_after)(_cx_self* self, _cx_node* ref); STC_API void _cx_memb(_erase_node_after)(_cx_self* self, _cx_node* ref); +STC_INLINE _cx_node* _cx_memb(_get_node)(_cx_value* vp) { return _clist_tonode(vp); } #if !defined i_no_clone STC_API _cx_self _cx_memb(_clone)(_cx_self cx); -STC_INLINE i_key _cx_memb(_value_clone)(i_key val) - { return i_keyclone(val); } +STC_INLINE i_key _cx_memb(_value_clone)(i_key val) { return i_keyclone(val); } STC_INLINE void _cx_memb(_copy)(_cx_self *self, const _cx_self* other) { if (self->last == other->last) return; diff --git a/misc/examples/intrusive.c b/misc/examples/intrusive.c index a0ac6095..7e7a7b39 100644 --- a/misc/examples/intrusive.c +++ b/misc/examples/intrusive.c @@ -1,4 +1,4 @@ -// Example of intrusive list by using the node API and typesafe c_CONTAINER_OF(). +// Example of intrusive list by using the node API. #include <stdio.h> @@ -33,7 +33,7 @@ int main() Outer_push_back(&outer, (Inner_node){NULL, *i.ref}); c_FOREACH (i, Outer, outer) - Inner_push_node_back(&inner, c_CONTAINER_OF(&i.ref->value, Inner_node, value)); + Inner_push_node_back(&inner, Inner_get_node(&i.ref->value)); printLists(inner, outer); @@ -47,7 +47,7 @@ int main() if (it1.ref) { Inner_unlink_node_after(&inner, it1.prev); - free(Outer_unlink_node_after(&outer, c_CONTAINER_OF(it1.prev, Outer_node, value))); + free(Outer_unlink_node_after(&outer, Outer_get_node(it1.prev))); } printLists(inner, outer); diff --git a/src/utf8tabs.py b/src/utf8tabs.py index 4a5781f1..7ed5e7ae 100644 --- a/src/utf8tabs.py +++ b/src/utf8tabs.py @@ -2,16 +2,16 @@ import pandas as pd import numpy as np -_UNICODE_DIR = "https://www.unicode.org/Public/14.0.0/ucd" +_UNICODE_DIR = "https://www.unicode.org/Public/15.0.0/ucd" -def read_unidata(casetype='lowcase', category='Lu', big=False): +def read_unidata(casetype='lowcase', category='Lu', range32=False): df = pd.read_csv(_UNICODE_DIR+'/UnicodeData.txt', sep=';', converters={0: lambda x: int(x, base=16)}, names=['code', 'name', 'category', 'canclass', 'bidircat', 'chrdecomp', 'decdig', 'digval', 'numval', 'mirrored', 'uc1name', 'comment', 'upcase', 'lowcase', 'titlecase'], usecols=['code', 'name', 'category', 'bidircat', 'upcase', 'lowcase', 'titlecase']) - if big: + if range32: df = df[df['code'] >= (1<<16)] else: df = df[df['code'] < (1<<16)] @@ -27,11 +27,11 @@ def read_unidata(casetype='lowcase', category='Lu', big=False): return df -def read_casefold(big=False): +def read_casefold(range32=False): df = pd.read_csv(_UNICODE_DIR+'/CaseFolding.txt', engine='python', sep='; #? ?', comment='#', converters={0: lambda x: int(x, base=16)}, names=['code', 'status', 'lowcase', 'name']) # comment => 'name' - if big: + if range32: df = df[df['code'] >= (1<<16)] else: df = df[df['code'] < (1<<16)] @@ -100,11 +100,11 @@ def print_index_table(name, indtab): print('\n};') -def compile_table(casetype='lowcase', category=None): +def compile_table(casetype='lowcase', category=None, range32=False): if category: - df = read_unidata(casetype, category) + df = read_unidata(casetype, category, range32) else: - df = read_casefold() + df = read_casefold(range32) caselist = make_caselist(df, casetype) table = make_table(caselist) return table @@ -113,10 +113,11 @@ def compile_table(casetype='lowcase', category=None): def main(): print('#include <stdint.h>\n') print('struct CaseMapping { uint16_t c1, c2, m2; };\n') + range32 = False - casemappings = compile_table('lowcase') # CaseFolding.txt - upcase = compile_table('lowcase', 'Lu') # UnicodeData.txt uppercase - lowcase = compile_table('upcase', 'Ll') # UnicodeData.txt lowercase + casemappings = compile_table('lowcase', None, range32) # CaseFolding.txt + upcase = compile_table('lowcase', 'Lu', range32) # UnicodeData.txt uppercase + lowcase = compile_table('upcase', 'Ll', range32) # UnicodeData.txt lowercase casefolding_len = len(casemappings) @@ -150,7 +151,8 @@ def main(): print_index_table('upcase_ind', upcase_ind) # lowcase => up. add "missing" SHARP S caused by https://www.unicode.org/policies/stability_policy.html#Case_Pair - lowcase_ind.append(next(i for i,x in enumerate(casemappings) if x[0]==ord('ẞ'))) + if not range32: + lowcase_ind.append(next(i for i,x in enumerate(casemappings) if x[0]==ord('ẞ'))) lowcase_ind.sort(key=lambda i: casemappings[i][2] - (casemappings[i][1] - casemappings[i][0])) print_index_table('lowcase_ind', lowcase_ind) |
