From a0899da505475f4f98e67027d13ffc8da155c201 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Fri, 29 Oct 2021 14:39:12 +0200 Subject: renamed cx_..._t to _cx_..._t, and Self to _cx_self --- include/stc/cstack.h | 80 ++++++++++++++++++++++++++-------------------------- 1 file changed, 40 insertions(+), 40 deletions(-) (limited to 'include/stc/cstack.h') diff --git a/include/stc/cstack.h b/include/stc/cstack.h index e461ca4b..03a9f1d2 100644 --- a/include/stc/cstack.h +++ b/include/stc/cstack.h @@ -34,90 +34,90 @@ #include "template.h" #if !defined i_fwd -cx_deftypes(_c_cstack_types, Self, i_val); +_cx_deftypes(_c_cstack_types, _cx_self, i_val); #endif -typedef i_valraw cx_rawvalue_t; +typedef i_valraw _cx_rawvalue_t; -STC_INLINE Self cx_memb(_init)(void) - { return c_make(Self){0, 0, 0}; } +STC_INLINE _cx_self _cx_memb(_init)(void) + { return c_make(_cx_self){0, 0, 0}; } -STC_INLINE Self cx_memb(_with_capacity)(size_t cap) { - Self out = {(cx_value_t *) c_malloc(cap*sizeof(i_val)), 0, cap}; +STC_INLINE _cx_self _cx_memb(_with_capacity)(size_t cap) { + _cx_self out = {(_cx_value_t *) c_malloc(cap*sizeof(i_val)), 0, cap}; return out; } -STC_INLINE Self cx_memb(_with_size)(size_t size, i_val fill) { - Self out = {(cx_value_t *) c_malloc(size*sizeof fill), size, size}; +STC_INLINE _cx_self _cx_memb(_with_size)(size_t size, i_val fill) { + _cx_self out = {(_cx_value_t *) c_malloc(size*sizeof fill), size, size}; while (size) out.data[--size] = fill; return out; } -STC_INLINE void cx_memb(_clear)(Self* self) { - cx_value_t *p = self->data + self->size; +STC_INLINE void _cx_memb(_clear)(_cx_self* self) { + _cx_value_t *p = self->data + self->size; while (p-- != self->data) i_valdel(p); self->size = 0; } -STC_INLINE void cx_memb(_del)(Self* self) - { cx_memb(_clear)(self); c_free(self->data); } +STC_INLINE void _cx_memb(_del)(_cx_self* self) + { _cx_memb(_clear)(self); c_free(self->data); } -STC_INLINE size_t cx_memb(_size)(Self v) +STC_INLINE size_t _cx_memb(_size)(_cx_self v) { return v.size; } -STC_INLINE bool cx_memb(_empty)(Self v) +STC_INLINE bool _cx_memb(_empty)(_cx_self v) { return !v.size; } -STC_INLINE size_t cx_memb(_capacity)(Self v) +STC_INLINE size_t _cx_memb(_capacity)(_cx_self v) { return v.capacity; } -STC_INLINE cx_value_t* cx_memb(_top)(const Self* self) +STC_INLINE _cx_value_t* _cx_memb(_top)(const _cx_self* self) { return &self->data[self->size - 1]; } -STC_INLINE void cx_memb(_pop)(Self* self) - { cx_value_t* p = &self->data[--self->size]; i_valdel(p); } +STC_INLINE void _cx_memb(_pop)(_cx_self* self) + { _cx_value_t* p = &self->data[--self->size]; i_valdel(p); } -STC_INLINE void cx_memb(_reserve)(Self* self, size_t n) { +STC_INLINE void _cx_memb(_reserve)(_cx_self* self, size_t n) { if (n >= self->size) - self->data = (cx_value_t *)c_realloc(self->data, (self->capacity = n)*sizeof(cx_value_t)); + self->data = (_cx_value_t *)c_realloc(self->data, (self->capacity = n)*sizeof(_cx_value_t)); } -STC_INLINE void cx_memb(_shrink_to_fit)(Self* self) - { cx_memb(_reserve)(self, self->size); } +STC_INLINE void _cx_memb(_shrink_to_fit)(_cx_self* self) + { _cx_memb(_reserve)(self, self->size); } -STC_INLINE cx_value_t* cx_memb(_push)(Self* self, cx_value_t val) { - if (self->size == self->capacity) cx_memb(_reserve)(self, self->size*3/2 + 4); - cx_value_t* vp = self->data + self->size++; +STC_INLINE _cx_value_t* _cx_memb(_push)(_cx_self* self, _cx_value_t val) { + if (self->size == self->capacity) _cx_memb(_reserve)(self, self->size*3/2 + 4); + _cx_value_t* vp = self->data + self->size++; *vp = val; return vp; } -STC_INLINE cx_value_t* cx_memb(_emplace)(Self* self, cx_rawvalue_t raw) - { return cx_memb(_push)(self, i_valfrom(raw)); } +STC_INLINE _cx_value_t* _cx_memb(_emplace)(_cx_self* self, _cx_rawvalue_t raw) + { return _cx_memb(_push)(self, i_valfrom(raw)); } -STC_INLINE cx_value_t* cx_memb(_at)(const Self* self, size_t idx) +STC_INLINE _cx_value_t* _cx_memb(_at)(const _cx_self* self, size_t idx) { assert(idx < self->size); return self->data + idx; } -STC_INLINE Self cx_memb(_clone)(Self v) { - Self out = {(cx_value_t *) c_malloc(v.size*sizeof(cx_value_t)), v.size, v.size}; +STC_INLINE _cx_self _cx_memb(_clone)(_cx_self v) { + _cx_self out = {(_cx_value_t *) c_malloc(v.size*sizeof(_cx_value_t)), v.size, v.size}; for (size_t i = 0; i < v.size; ++i, ++v.data) out.data[i] = i_valfrom(i_valto(v.data)); return out; } -STC_INLINE void cx_memb(_copy)(Self *self, Self other) { +STC_INLINE void _cx_memb(_copy)(_cx_self *self, _cx_self other) { if (self->data == other.data) return; - cx_memb(_del)(self); *self = cx_memb(_clone)(other); + _cx_memb(_del)(self); *self = _cx_memb(_clone)(other); } -STC_INLINE i_val cx_memb(_value_clone)(cx_value_t val) +STC_INLINE i_val _cx_memb(_value_clone)(_cx_value_t val) { return i_valfrom(i_valto(&val)); } -STC_INLINE i_valraw cx_memb(_value_toraw)(cx_value_t* val) +STC_INLINE i_valraw _cx_memb(_value_toraw)(_cx_value_t* val) { return i_valto(val); } -STC_INLINE cx_iter_t cx_memb(_begin)(const Self* self) - { return c_make(cx_iter_t){self->data}; } -STC_INLINE cx_iter_t cx_memb(_end)(const Self* self) - { return c_make(cx_iter_t){self->data + self->size}; } -STC_INLINE void cx_memb(_next)(cx_iter_t* it) { ++it->ref; } -STC_INLINE cx_iter_t cx_memb(_advance)(cx_iter_t it, intptr_t offs) +STC_INLINE _cx_iter_t _cx_memb(_begin)(const _cx_self* self) + { return c_make(_cx_iter_t){self->data}; } +STC_INLINE _cx_iter_t _cx_memb(_end)(const _cx_self* self) + { return c_make(_cx_iter_t){self->data + self->size}; } +STC_INLINE void _cx_memb(_next)(_cx_iter_t* it) { ++it->ref; } +STC_INLINE _cx_iter_t _cx_memb(_advance)(_cx_iter_t it, intptr_t offs) { it.ref += offs; return it; } #include "template.h" -- cgit v1.2.3