diff --git a/include/deemon/object.h b/include/deemon/object.h index 76d4f27ef..a7f1b95ea 100644 --- a/include/deemon/object.h +++ b/include/deemon/object.h @@ -2103,6 +2103,19 @@ struct Dee_type_seq { WUNUSED_T NONNULL_T((1, 2)) int (DCALL *tp_bounditem_string_len_hash)(DeeObject *self, char const *key, size_t keylen, Dee_hash_t hash); WUNUSED_T NONNULL_T((1, 2)) int (DCALL *tp_hasitem_string_len_hash)(DeeObject *self, char const *key, size_t keylen, Dee_hash_t hash); +#if 0 /* TODO: Do this to allow DEX modules to extend `DeeKw_GetItemNR()' */ + /* All of the following are *always* and *unconditionally* implemented + * when the associated type has the "tp_features & TF_KW" flag set, + * with the exception of `DeeKwds_Type', which has that flag, but does + * not implement these operators. */ + WUNUSED_T NONNULL_T((1, 2)) DeeObject *(DCALL *tp_getitemnr)(DeeObject *__restrict self, /*string*/ DeeObject *__restrict name); + WUNUSED_T NONNULL_T((1, 2)) DeeObject *(DCALL *tp_getitemnr_string_hash)(DeeObject *__restrict self, char const *__restrict name, Dee_hash_t hash); + WUNUSED_T NONNULL_T((1, 2)) DeeObject *(DCALL *tp_getitemnr_string_len_hash)(DeeObject *__restrict self, char const *__restrict name, size_t namelen, Dee_hash_t hash); + WUNUSED_T NONNULL_T((1, 2)) DeeObject *(DCALL *tp_trygetitemnr)(DeeObject *__restrict self, /*string*/ DeeObject *name); + WUNUSED_T NONNULL_T((1, 2)) DeeObject *(DCALL *tp_trygetitemnr_string_hash)(DeeObject *__restrict self, char const *__restrict name, Dee_hash_t hash); + WUNUSED_T NONNULL_T((1, 2)) DeeObject *(DCALL *tp_trygetitemnr_string_len_hash)(DeeObject *__restrict self, char const *__restrict name, size_t namelen, Dee_hash_t hash); +#endif + /* [0..1][owned][lock(WRITE_ONCE)] * Internal cache for how sequence functions are implemented for this type. */ struct Dee_type_seq_cache *_tp_seqcache; diff --git a/include/deemon/seq.h b/include/deemon/seq.h index 8375041ec..8846350aa 100644 --- a/include/deemon/seq.h +++ b/include/deemon/seq.h @@ -451,36 +451,11 @@ struct Dee_type_nsi { * @return: 0: `key' didn't exist and was thus added (*p_oldvalue is left unchanged) * @return: -1: Error. */ WUNUSED_T NONNULL_T((1, 2, 3)) int (DCALL *nsi_insertnew)(DeeObject *self, DeeObject *key, DeeObject *value, DREF DeeObject **p_oldvalue); - -#if 0 /* TODO: Do this to allow DEX modules to extend `DeeKw_GetItemNR()' */ - /* All of the following are *always* and *unconditionally* implemented - * when the associated type has the "tp_features & TF_KW" flag set, - * with the exception of `DeeKwds_Type', which has that flag, but does - * not implement these operators. */ - WUNUSED_T NONNULL_T((1, 2)) DeeObject *(DCALL *nsi_kw_getitemnr)(DeeObject *__restrict self, /*string*/ DeeObject *__restrict name); - WUNUSED_T NONNULL_T((1, 2)) DeeObject *(DCALL *nsi_kw_getitemnr_string_hash)(DeeObject *__restrict self, char const *__restrict name, Dee_hash_t hash); - WUNUSED_T ATTR_INS_T(2, 3) NONNULL_T((1)) DeeObject *(DCALL *nsi_kw_getitemnr_string_len_hash)(DeeObject *__restrict self, char const *__restrict name, size_t namelen, Dee_hash_t hash); - WUNUSED_T NONNULL_T((1, 2, 3)) DeeObject *(DCALL *nsi_kw_getitemnr_def)(DeeObject *__restrict self, /*string*/ DeeObject *name, DeeObject *def); - WUNUSED_T NONNULL_T((1, 2, 4)) DeeObject *(DCALL *nsi_kw_getitemnr_string_hash_def)(DeeObject *__restrict self, char const *__restrict name, Dee_hash_t hash, DeeObject *def); - WUNUSED_T ATTR_INS_T(2, 3) NONNULL_T((1, 5)) DeeObject *(DCALL *nsi_kw_getitemnr_string_len_hash_def)(DeeObject *__restrict self, char const *__restrict name, size_t namelen, Dee_hash_t hash, DeeObject *def); -#endif } nsi_maplike; struct { /* TYPE_SEQX_CLASS_SET */ /* [1..1] ERROR: (size_t)-1 */ WUNUSED_T NONNULL_T((1)) size_t (DCALL *nsi_getsize)(DeeObject *__restrict self); - - /* Insert a new `key' into the set - * @return: 1: The given `key' was inserted. - * @return: 0: A identical key was already apart of the set. - * @return: -1: Error. */ - WUNUSED_T NONNULL_T((1, 2)) int (DCALL *nsi_insert)(DeeObject *self, DeeObject *key); - - /* Remove a given `key' from the set - * @return: 1: The given `key' was removed. - * @return: 0: The given `key' could not be found within the set. - * @return: -1: Error. */ - WUNUSED_T NONNULL_T((1, 2)) int (DCALL *nsi_remove)(DeeObject *self, DeeObject *key); } nsi_setlike; } #ifndef __COMPILER_HAVE_TRANSPARENT_UNION diff --git a/src/deemon/objects/hashset.c b/src/deemon/objects/hashset.c index 2183047ff..7643773eb 100644 --- a/src/deemon/objects/hashset.c +++ b/src/deemon/objects/hashset.c @@ -1853,8 +1853,6 @@ PRIVATE struct type_nsi tpconst hashset_nsi = { { /* .nsi_setlike = */ { /* .nsi_getsize = */ (dfunptr_t)&hashset_size, - /* .nsi_insert = */ (dfunptr_t)&DeeHashSet_Insert, - /* .nsi_remove = */ (dfunptr_t)&DeeHashSet_Remove, } } }; diff --git a/src/dex/collections/bitset.c b/src/dex/collections/bitset.c index a95ae9010..6c843775d 100644 --- a/src/dex/collections/bitset.c +++ b/src/dex/collections/bitset.c @@ -337,35 +337,6 @@ bs_size(Bitset *__restrict self) { return bitset_popcount(self->bs_bitset, self->bs_nbits); } -PRIVATE WUNUSED NONNULL((1)) int DCALL -bs_nsi_insert(Bitset *self, DeeObject *key) { - size_t bitno; - if (DeeObject_AsSize(key, &bitno)) - goto err; - if unlikely(bitno >= self->bs_nbits) - goto err_too_large; - return bitset_atomic_fetchset(self->bs_bitset, bitno) ? 0 : 1; -err_too_large: - return bs_err_bad_index(self, bitno); -err: - return -1; -} - -PRIVATE WUNUSED NONNULL((1)) int DCALL -bs_nsi_remove(Bitset *self, DeeObject *key) { - size_t bitno; - if (DeeObject_AsSize(key, &bitno)) - goto err; - if unlikely(bitno >= self->bs_nbits) - goto err_too_large; - return bitset_atomic_fetchclear(self->bs_bitset, bitno) ? 1 : 0; -err_too_large: - return bs_err_bad_index(self, bitno); -err: - return -1; -} - - PRIVATE WUNUSED NONNULL((1)) dhash_t DCALL bs_hash(Bitset *__restrict self) { size_t bitno; @@ -1580,8 +1551,6 @@ PRIVATE struct type_nsi tpconst bs_nsi = { { /* .nsi_setlike = */ { /* .nsi_getsize = */ (dfunptr_t)&bs_size, - /* .nsi_insert = */ (dfunptr_t)&bs_nsi_insert, - /* .nsi_remove = */ (dfunptr_t)&bs_nsi_remove, } } }; @@ -2574,49 +2543,6 @@ bsv_size(BitsetView *__restrict self) { self->bsv_endbit); } -PRIVATE WUNUSED NONNULL((1)) int DCALL -bsv_nsi_insert(BitsetView *self, DeeObject *key) { - size_t bitno; - if (DeeObject_AsSize(key, &bitno)) - goto err; - if unlikely(bitno >= BitsetView_GetNBits(self)) - goto err_too_large; - if unlikely(!BitsetView_IsWritable(self)) - goto err_readonly; - return bitset_atomic_fetchset(BitsetView_GetBitset(self), - self->bsv_startbit + bitno) - ? 0 - : 1; -err_readonly: - return bsv_err_readonly(self); -err_too_large: - return bsv_err_bad_index(self, bitno); -err: - return -1; -} - -PRIVATE WUNUSED NONNULL((1)) int DCALL -bsv_nsi_remove(BitsetView *self, DeeObject *key) { - size_t bitno; - if (DeeObject_AsSize(key, &bitno)) - goto err; - if unlikely(bitno >= BitsetView_GetNBits(self)) - goto err_too_large; - if unlikely(!BitsetView_IsWritable(self)) - goto err_readonly; - return bitset_atomic_fetchclear(BitsetView_GetBitset(self), - self->bsv_startbit + bitno) - ? 1 - : 0; -err_readonly: - return bsv_err_readonly(self); -err_too_large: - return bsv_err_bad_index(self, bitno); -err: - return -1; -} - - PRIVATE WUNUSED NONNULL((1)) dhash_t DCALL bsv_hash(BitsetView *__restrict self) { size_t bitno; @@ -3913,8 +3839,6 @@ PRIVATE struct type_nsi tpconst bsv_nsi = { { /* .nsi_setlike = */ { /* .nsi_getsize = */ (dfunptr_t)&bsv_size, - /* .nsi_insert = */ (dfunptr_t)&bsv_nsi_insert, - /* .nsi_remove = */ (dfunptr_t)&bsv_nsi_remove, } } }; diff --git a/src/dex/collections/uset.c b/src/dex/collections/uset.c index fcdb142db..0725acb99 100644 --- a/src/dex/collections/uset.c +++ b/src/dex/collections/uset.c @@ -1230,8 +1230,6 @@ PRIVATE struct type_nsi tpconst uset_nsi = { { /* .nsi_setlike = */ { /* .nsi_getsize = */ (dfunptr_t)&uset_size, - /* .nsi_insert = */ (dfunptr_t)&USet_Insert, - /* .nsi_remove = */ (dfunptr_t)&USet_Remove, } } };