diff --git a/.vs/deemon.vcxproj b/.vs/deemon.vcxproj index 4a0449f44..f7c755140 100644 --- a/.vs/deemon.vcxproj +++ b/.vs/deemon.vcxproj @@ -244,6 +244,8 @@ + + @@ -419,6 +421,7 @@ + diff --git a/.vs/deemon.vcxproj.filters b/.vs/deemon.vcxproj.filters index 490d692a4..9026bebf3 100644 --- a/.vs/deemon.vcxproj.filters +++ b/.vs/deemon.vcxproj.filters @@ -705,6 +705,12 @@ src\objects\seq + + src\objects\seq + + + src\objects\seq + src\objects\seq @@ -1226,6 +1232,9 @@ src\objects\seq + + src\objects\seq + src\objects\seq diff --git a/cpp.hint b/cpp.hint index 8cd908722..08deb791d 100644 --- a/cpp.hint +++ b/cpp.hint @@ -1642,3 +1642,6 @@ #define _memval_foreach_obj(...) for(;;) #define memval_foreach_obj(...) for(;;) #define memval_foreach_obj_end + +#define LOCAL_seq_compare__(x) seq_compare__##x +#define LOCAL_seq_docompare__(x) seq_docompare__##x diff --git a/include/deemon/class.h b/include/deemon/class.h index bbaf7432a..ed85fad88 100644 --- a/include/deemon/class.h +++ b/include/deemon/class.h @@ -1372,6 +1372,8 @@ INTDEF WUNUSED NONNULL((1, 2)) dssize_t DCALL instance_enumattr(DeeTypeObject *t : (tp_ge) == &instance_builtin_ge \ ? instance_builtin_tge(tp_self, self, other) \ : (*(tp_ge))(self, other)) +#define DeeType_invoke_cmp_tp_compare_eq_NODEFAULT(tp_self, tp_compare_eq, self, other) (*(tp_compare_eq))(self, other) +#define DeeType_invoke_cmp_tp_compare_NODEFAULT(tp_self, tp_compare, self, other) (*(tp_compare))(self, other) #define DeeType_invoke_seq_tp_iter_NODEFAULT(tp_self, tp_iter, self) \ ((tp_iter) == &instance_iter \ ? instance_titer(tp_self, self) \ @@ -1534,12 +1536,104 @@ INTDEF WUNUSED NONNULL((1)) int DCALL DeeObject_DefaultDecWithInplaceSub(DREF De INTDEF WUNUSED NONNULL((1)) int DCALL DeeObject_DefaultDecWithSub(DREF DeeObject **p_self); /* Default wrappers for implementing ==/!=//>= using their logical inverse. */ + +/* tp_hash */ +INTDEF WUNUSED NONNULL((1)) Dee_hash_t DCALL DeeSeq_DefaultHashWithSizeAndGetItemIndexFast(DeeObject *self); +INTDEF WUNUSED NONNULL((1)) Dee_hash_t DCALL DeeSeq_DefaultHashWithForeach(DeeObject *self); +INTDEF WUNUSED NONNULL((1)) Dee_hash_t DCALL DeeSeq_DefaultHashWithSizeAndTryGetItemIndex(DeeObject *self); +INTDEF WUNUSED NONNULL((1)) Dee_hash_t DCALL DeeSeq_DefaultHashWithSizeAndGetItemIndex(DeeObject *self); +INTDEF WUNUSED NONNULL((1)) Dee_hash_t DCALL DeeSeq_DefaultHashWithSizeObAndGetItem(DeeObject *self); +INTDEF WUNUSED NONNULL((1)) Dee_hash_t DCALL DeeSeq_DefaultHashWithForeachDefault(DeeObject *self); +INTDEF WUNUSED NONNULL((1)) Dee_hash_t DCALL DeeSet_DefaultHashWithForeachDefault(DeeObject *self); +INTDEF WUNUSED NONNULL((1)) Dee_hash_t DCALL DeeMap_DefaultHashWithForeachPairDefault(DeeObject *self); + +/* tp_eq */ +INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeObject_DefaultEqWithCompareEq(DeeObject *self, DeeObject *other); INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeObject_DefaultEqWithNe(DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeObject_DefaultEqWithLoAndGr(DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeObject_DefaultEqWithLeAndGe(DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeObject_DefaultEqWithCompareEqDefault(DeeObject *self, DeeObject *other); + +/* tp_ne */ +INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeObject_DefaultNeWithCompareEq(DeeObject *self, DeeObject *other); INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeObject_DefaultNeWithEq(DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeObject_DefaultNeWithLoAndGr(DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeObject_DefaultNeWithLeAndGe(DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeObject_DefaultNeWithCompareEqDefault(DeeObject *self, DeeObject *other); + +/* tp_lo */ +INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeObject_DefaultLoWithCompare(DeeObject *self, DeeObject *other); INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeObject_DefaultLoWithGe(DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeObject_DefaultLoWithCompareDefault(DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSet_DefaultLoWithForeachDefault(DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeMap_DefaultLoWithForeachPairDefault(DeeObject *self, DeeObject *other); + +/* tp_le */ +INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeObject_DefaultLeWithCompare(DeeObject *self, DeeObject *other); INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeObject_DefaultLeWithGr(DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeObject_DefaultLeWithCompareDefault(DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSet_DefaultLeWithForeachDefault(DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeMap_DefaultLeWithForeachPairDefault(DeeObject *self, DeeObject *other); + +/* tp_gr */ +INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeObject_DefaultGrWithCompare(DeeObject *self, DeeObject *other); INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeObject_DefaultGrWithLe(DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeObject_DefaultGrWithCompareDefault(DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSet_DefaultGrWithForeachDefault(DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeMap_DefaultGrWithForeachPairDefault(DeeObject *self, DeeObject *other); + +/* tp_ge */ +INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeObject_DefaultGeWithCompare(DeeObject *self, DeeObject *other); INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeObject_DefaultGeWithLo(DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeObject_DefaultGeWithCompareDefault(DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSet_DefaultGeWithForeachDefault(DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeMap_DefaultGeWithForeachPairDefault(DeeObject *self, DeeObject *other); + +/* tp_compare_eq */ +INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeObject_DefaultCompareEqWithEq(DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeObject_DefaultCompareEqWithNe(DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeObject_DefaultCompareEqWithLoAndGr(DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeObject_DefaultCompareEqWithLeAndGe(DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeSeq_DefaultCompareEqWithForeachDefault(DeeObject *self, DeeObject *other); /* Also use when non-Default would be usable */ +INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeSeq_DefaultCompareEqWithSizeAndGetItemIndexFast(DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeSeq_DefaultCompareEqWithSizeAndTryGetItemIndex(DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeSeq_DefaultCompareEqWithSizeAndGetItemIndex(DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeSeq_DefaultCompareEqWithSizeObAndGetItem(DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeSet_DefaultCompareEqWithForeachDefault(DeeObject *self, DeeObject *other); /* Also use when non-Default would be usable */ +INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeMap_DefaultCompareEqWithForeachPairDefault(DeeObject *self, DeeObject *other); /* Also use when non-Default would be usable */ + +/* tp_compare */ +INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeObject_DefaultCompareWithEqAndLo(DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeObject_DefaultCompareWithEqAndLe(DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeObject_DefaultCompareWithEqAndGr(DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeObject_DefaultCompareWithEqAndGe(DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeObject_DefaultCompareWithNeAndLo(DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeObject_DefaultCompareWithNeAndLe(DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeObject_DefaultCompareWithNeAndGr(DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeObject_DefaultCompareWithNeAndGe(DeeObject *self, DeeObject *other); +#if 0 +INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeObject_DefaultCompareWithLoAndGr(DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeObject_DefaultCompareWithLeAndGe(DeeObject *self, DeeObject *other); +#endif +#define DeeObject_DefaultCompareWithLoAndGr DeeObject_DefaultCompareEqWithLoAndGr +#define DeeObject_DefaultCompareWithLeAndGe DeeObject_DefaultCompareEqWithLeAndGe +#define DeeObject_TDefaultCompareWithLoAndGr DeeObject_TDefaultCompareEqWithLoAndGr +#define DeeObject_TDefaultCompareWithLeAndGe DeeObject_TDefaultCompareEqWithLeAndGe +INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeSeq_DefaultCompareWithSizeAndGetItemIndexFast(DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeSeq_DefaultCompareWithSizeAndTryGetItemIndex(DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeSeq_DefaultCompareWithSizeAndGetItemIndex(DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeSeq_DefaultCompareWithSizeObAndGetItem(DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeSeq_DefaultCompareWithForeachDefault(DeeObject *self, DeeObject *other); /* Also use when non-Default would be usable */ + + +INTDEF struct type_cmp DeeSeq_DefaultCmpWithSizeAndGetItemIndexFast; +INTDEF struct type_cmp DeeSeq_DefaultCmpWithSizeAndTryGetItemIndex; +INTDEF struct type_cmp DeeSeq_DefaultCmpWithSizeAndGetItemIndex; +INTDEF struct type_cmp DeeSeq_DefaultCmpWithSizeObAndGetItem; +INTDEF struct type_cmp DeeSeq_DefaultCmpWithForeachDefault; +INTDEF struct type_cmp DeeSet_DefaultCmpWithForeachDefault; +INTDEF struct type_cmp DeeMap_DefaultCmpWithForeachPairDefault; + /* Default wrappers for implementing sequence operators. */ @@ -1547,7 +1641,7 @@ INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeObject_DefaultGeWithLo(D INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL DeeObject_DefaultIterWithForeach(DeeObject *__restrict self); INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL DeeObject_DefaultIterWithForeachPair(DeeObject *__restrict self); INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL DeeSeq_DefaultIterWithSizeAndGetItemIndexFast(DeeObject *__restrict self); -INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL DeeSeq_DefaultIterWithTryGetItemIndexAndSize(DeeObject *__restrict self); +INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL DeeSeq_DefaultIterWithSizeAndTryGetItemIndex(DeeObject *__restrict self); INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL DeeSeq_DefaultIterWithSizeAndGetItemIndex(DeeObject *__restrict self); INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL DeeSeq_DefaultIterWithGetItemIndex(DeeObject *__restrict self); INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL DeeSeq_DefaultIterWithSizeObAndGetItem(DeeObject *__restrict self); @@ -1557,8 +1651,9 @@ INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL DeeSeq_DefaultIterWithGetItem( INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL DeeObject_DefaultForeachWithIter(DeeObject *__restrict self, Dee_foreach_t proc, void *arg); INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL DeeObject_DefaultForeachWithForeachPair(DeeObject *__restrict self, Dee_foreach_t proc, void *arg); INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL DeeSeq_DefaultForeachWithSizeAndGetItemIndexFast(DeeObject *__restrict self, Dee_foreach_t proc, void *arg); -INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL DeeSeq_DefaultForeachWithTryGetItemIndexAndSize(DeeObject *__restrict self, Dee_foreach_t proc, void *arg); +INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL DeeSeq_DefaultForeachWithSizeAndTryGetItemIndex(DeeObject *__restrict self, Dee_foreach_t proc, void *arg); INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL DeeSeq_DefaultForeachWithSizeAndGetItemIndex(DeeObject *__restrict self, Dee_foreach_t proc, void *arg); +INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL DeeSeq_DefaultForeachWithSizeObAndGetItem(DeeObject *__restrict self, Dee_foreach_t proc, void *arg); INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL DeeSeq_DefaultForeachWithSizeDefaultAndGetItemIndexDefault(DeeObject *__restrict self, Dee_foreach_t proc, void *arg); /* May call other DEFAULT operators */ INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL DeeSeq_DefaultForeachWithGetItemIndexDefault(DeeObject *__restrict self, Dee_foreach_t proc, void *arg); /* May call other DEFAULT operators */ @@ -1612,8 +1707,8 @@ INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeObject_DefaultGetItemWit INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeObject_DefaultGetItemWithTryGetItemStringLenHash(DeeObject *self, DeeObject *index); INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_DefaultGetItemWithTryGetItemAndSizeOb(DeeObject *self, DeeObject *index); INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_DefaultGetItemWithTryGetItemAndSize(DeeObject *self, DeeObject *index); -INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_DefaultGetItemWithTryGetItemIndexAndSizeOb(DeeObject *self, DeeObject *index); -INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_DefaultGetItemWithTryGetItemIndexAndSize(DeeObject *self, DeeObject *index); +INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_DefaultGetItemWithSizeAndTryGetItemIndexOb(DeeObject *self, DeeObject *index); +INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_DefaultGetItemWithSizeAndTryGetItemIndex(DeeObject *self, DeeObject *index); INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeMap_DefaultGetItemWithForeachPair(DeeObject *__restrict self, DeeObject *index); INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeMap_DefaultGetItemWithForeachPairDefault(DeeObject *__restrict self, DeeObject *index); /* May call other DEFAULT operators */ @@ -1624,8 +1719,8 @@ INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL DeeObject_DefaultGetItemIndexW INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL DeeObject_DefaultGetItemIndexWithTryGetItem(DeeObject *__restrict self, size_t index); INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL DeeObject_DefaultGetItemIndexWithErrorRequiresString(DeeObject *__restrict self, size_t index); INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL DeeObject_DefaultGetItemIndexWithGetItemDefault(DeeObject *__restrict self, size_t index); /* May call other DEFAULT operators */ -INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL DeeSeq_DefaultGetItemIndexWithTryGetItemIndexAndSize(DeeObject *__restrict self, size_t index); -INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL DeeSeq_DefaultGetItemIndexWithTryGetItemIndexAndSizeOb(DeeObject *__restrict self, size_t index); +INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL DeeSeq_DefaultGetItemIndexWithSizeAndTryGetItemIndex(DeeObject *__restrict self, size_t index); +INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL DeeSeq_DefaultGetItemIndexWithSizeAndTryGetItemIndexOb(DeeObject *__restrict self, size_t index); INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL DeeSeq_DefaultGetItemIndexWithTryGetItemAndSize(DeeObject *__restrict self, size_t index); INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL DeeSeq_DefaultGetItemIndexWithTryGetItemAndSizeOb(DeeObject *__restrict self, size_t index); INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL DeeSeq_DefaultGetItemIndexWithForeachDefault(DeeObject *__restrict self, size_t index); /* May call other DEFAULT operators */ @@ -1754,7 +1849,7 @@ INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeObject_DefaultBoundItemWithTryGetIte INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeObject_DefaultBoundItemWithTryGetItemStringLenHashAndHasItemStringLenHash(DeeObject *self, DeeObject *index); INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeObject_DefaultBoundItemWithTryGetItemStringHashAndHasItemStringHash(DeeObject *self, DeeObject *index); INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeSeq_DefaultBoundItemWithTryGetItemAndSizeOb(DeeObject *self, DeeObject *index); -INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeSeq_DefaultBoundItemWithTryGetItemIndexAndSize(DeeObject *self, DeeObject *index); +INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeSeq_DefaultBoundItemWithSizeAndTryGetItemIndex(DeeObject *self, DeeObject *index); INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeObject_DefaultBoundItemWithTryGetItem(DeeObject *self, DeeObject *index); INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeObject_DefaultBoundItemWithTryGetItemIndex(DeeObject *self, DeeObject *index); INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeObject_DefaultBoundItemWithTryGetItemStringLenHash(DeeObject *self, DeeObject *index); @@ -1772,7 +1867,7 @@ INTDEF WUNUSED NONNULL((1)) int DCALL DeeObject_DefaultBoundItemIndexWithGetItem INTDEF WUNUSED NONNULL((1)) int DCALL DeeObject_DefaultBoundItemIndexWithGetItemIndexDefault(DeeObject *__restrict self, size_t index); /* May call other DEFAULT operators */ INTDEF WUNUSED NONNULL((1)) int DCALL DeeObject_DefaultBoundItemIndexWithTryGetItemIndexAndHasItemIndex(DeeObject *__restrict self, size_t index); INTDEF WUNUSED NONNULL((1)) int DCALL DeeObject_DefaultBoundItemIndexWithTryGetItemAndHasItem(DeeObject *__restrict self, size_t index); -INTDEF WUNUSED NONNULL((1)) int DCALL DeeSeq_DefaultBoundItemIndexWithTryGetItemIndexAndSize(DeeObject *__restrict self, size_t index); +INTDEF WUNUSED NONNULL((1)) int DCALL DeeSeq_DefaultBoundItemIndexWithSizeAndTryGetItemIndex(DeeObject *__restrict self, size_t index); INTDEF WUNUSED NONNULL((1)) int DCALL DeeSeq_DefaultBoundItemIndexWithTryGetItemAndSizeOb(DeeObject *__restrict self, size_t index); INTDEF WUNUSED NONNULL((1)) int DCALL DeeObject_DefaultBoundItemIndexWithErrorRequiresString(DeeObject *__restrict self, size_t index); INTDEF WUNUSED NONNULL((1)) int DCALL DeeMap_DefaultBoundItemIndexWithContains(DeeObject *__restrict self, size_t index); @@ -2073,6 +2168,9 @@ function getOperatorPackage(name: string): string { "Le" : "cmp", "Gr" : "cmp", "Ge" : "cmp", + "Hash" : "cmp", + "Compare" : "cmp", + "CompareEq" : "cmp", "Iter" : "seq", "Size" : "seq", "SizeFast" : "seq", @@ -2174,16 +2272,74 @@ INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeObject_TDefaultDecWithInplaceAdd(Dee INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeObject_TDefaultDecWithAdd(DeeTypeObject *tp_self, DREF DeeObject **p_self); INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeObject_TDefaultDecWithInplaceSub(DeeTypeObject *tp_self, DREF DeeObject **p_self); INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeObject_TDefaultDecWithSub(DeeTypeObject *tp_self, DREF DeeObject **p_self); +INTDEF WUNUSED NONNULL((1, 2)) Dee_hash_t DCALL DeeSeq_TDefaultHashWithSizeAndGetItemIndexFast(DeeTypeObject *tp_self, DeeObject *self); +INTDEF WUNUSED NONNULL((1, 2)) Dee_hash_t DCALL DeeSeq_TDefaultHashWithForeach(DeeTypeObject *tp_self, DeeObject *self); +INTDEF WUNUSED NONNULL((1, 2)) Dee_hash_t DCALL DeeSeq_TDefaultHashWithSizeAndTryGetItemIndex(DeeTypeObject *tp_self, DeeObject *self); +INTDEF WUNUSED NONNULL((1, 2)) Dee_hash_t DCALL DeeSeq_TDefaultHashWithSizeAndGetItemIndex(DeeTypeObject *tp_self, DeeObject *self); +INTDEF WUNUSED NONNULL((1, 2)) Dee_hash_t DCALL DeeSeq_TDefaultHashWithSizeObAndGetItem(DeeTypeObject *tp_self, DeeObject *self); +INTDEF WUNUSED NONNULL((1, 2)) Dee_hash_t DCALL DeeSeq_TDefaultHashWithForeachDefault(DeeTypeObject *tp_self, DeeObject *self); +INTDEF WUNUSED NONNULL((1, 2)) Dee_hash_t DCALL DeeSet_TDefaultHashWithForeachDefault(DeeTypeObject *tp_self, DeeObject *self); +INTDEF WUNUSED NONNULL((1, 2)) Dee_hash_t DCALL DeeMap_TDefaultHashWithForeachPairDefault(DeeTypeObject *tp_self, DeeObject *self); +INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeObject_TDefaultEqWithCompareEq(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeObject_TDefaultEqWithNe(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeObject_TDefaultEqWithLoAndGr(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeObject_TDefaultEqWithLeAndGe(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeObject_TDefaultEqWithCompareEqDefault(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeObject_TDefaultNeWithCompareEq(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeObject_TDefaultNeWithEq(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeObject_TDefaultNeWithLoAndGr(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeObject_TDefaultNeWithLeAndGe(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeObject_TDefaultNeWithCompareEqDefault(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeObject_TDefaultLoWithCompare(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeObject_TDefaultLoWithGe(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeObject_TDefaultLoWithCompareDefault(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeSet_TDefaultLoWithForeachDefault(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeMap_TDefaultLoWithForeachPairDefault(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeObject_TDefaultLeWithCompare(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeObject_TDefaultLeWithGr(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeObject_TDefaultLeWithCompareDefault(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeSet_TDefaultLeWithForeachDefault(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeMap_TDefaultLeWithForeachPairDefault(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeObject_TDefaultGrWithCompare(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeObject_TDefaultGrWithLe(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeObject_TDefaultGrWithCompareDefault(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeSet_TDefaultGrWithForeachDefault(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeMap_TDefaultGrWithForeachPairDefault(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeObject_TDefaultGeWithCompare(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeObject_TDefaultGeWithLo(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeObject_TDefaultGeWithCompareDefault(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeSet_TDefaultGeWithForeachDefault(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeMap_TDefaultGeWithForeachPairDefault(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL DeeObject_TDefaultCompareEqWithEq(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL DeeObject_TDefaultCompareEqWithNe(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL DeeObject_TDefaultCompareEqWithLoAndGr(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL DeeObject_TDefaultCompareEqWithLeAndGe(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL DeeSeq_TDefaultCompareEqWithForeachDefault(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL DeeSeq_TDefaultCompareEqWithSizeAndGetItemIndexFast(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL DeeSeq_TDefaultCompareEqWithSizeAndTryGetItemIndex(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL DeeSeq_TDefaultCompareEqWithSizeAndGetItemIndex(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL DeeSeq_TDefaultCompareEqWithSizeObAndGetItem(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL DeeSet_TDefaultCompareEqWithForeachDefault(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL DeeMap_TDefaultCompareEqWithForeachPairDefault(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL DeeObject_TDefaultCompareWithEqAndLo(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL DeeObject_TDefaultCompareWithEqAndLe(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL DeeObject_TDefaultCompareWithEqAndGr(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL DeeObject_TDefaultCompareWithEqAndGe(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL DeeObject_TDefaultCompareWithNeAndLo(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL DeeObject_TDefaultCompareWithNeAndLe(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL DeeObject_TDefaultCompareWithNeAndGr(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL DeeObject_TDefaultCompareWithNeAndGe(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL DeeObject_TDefaultCompareWithLoAndGr(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL DeeObject_TDefaultCompareWithLeAndGe(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL DeeSeq_TDefaultCompareWithSizeAndGetItemIndexFast(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL DeeSeq_TDefaultCompareWithSizeAndTryGetItemIndex(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL DeeSeq_TDefaultCompareWithSizeAndGetItemIndex(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL DeeSeq_TDefaultCompareWithSizeObAndGetItem(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); +INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL DeeSeq_TDefaultCompareWithForeachDefault(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other); INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeObject_TDefaultIterWithForeach(DeeTypeObject *tp_self, DeeObject *self); INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeObject_TDefaultIterWithForeachPair(DeeTypeObject *tp_self, DeeObject *self); INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_TDefaultIterWithSizeAndGetItemIndexFast(DeeTypeObject *tp_self, DeeObject *self); -INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_TDefaultIterWithTryGetItemIndexAndSize(DeeTypeObject *tp_self, DeeObject *self); +INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_TDefaultIterWithSizeAndTryGetItemIndex(DeeTypeObject *tp_self, DeeObject *self); INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_TDefaultIterWithSizeAndGetItemIndex(DeeTypeObject *tp_self, DeeObject *self); INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_TDefaultIterWithGetItemIndex(DeeTypeObject *tp_self, DeeObject *self); INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_TDefaultIterWithSizeObAndGetItem(DeeTypeObject *tp_self, DeeObject *self); @@ -2191,8 +2347,9 @@ INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_TDefaultIterWithGetI INTDEF WUNUSED NONNULL((1, 2, 3)) Dee_ssize_t DCALL DeeObject_TDefaultForeachWithIter(DeeTypeObject *tp_self, DeeObject *self, Dee_foreach_t proc, void *arg); INTDEF WUNUSED NONNULL((1, 2, 3)) Dee_ssize_t DCALL DeeObject_TDefaultForeachWithForeachPair(DeeTypeObject *tp_self, DeeObject *self, Dee_foreach_t proc, void *arg); INTDEF WUNUSED NONNULL((1, 2, 3)) Dee_ssize_t DCALL DeeSeq_TDefaultForeachWithSizeAndGetItemIndexFast(DeeTypeObject *tp_self, DeeObject *self, Dee_foreach_t proc, void *arg); -INTDEF WUNUSED NONNULL((1, 2, 3)) Dee_ssize_t DCALL DeeSeq_TDefaultForeachWithTryGetItemIndexAndSize(DeeTypeObject *tp_self, DeeObject *self, Dee_foreach_t proc, void *arg); +INTDEF WUNUSED NONNULL((1, 2, 3)) Dee_ssize_t DCALL DeeSeq_TDefaultForeachWithSizeAndTryGetItemIndex(DeeTypeObject *tp_self, DeeObject *self, Dee_foreach_t proc, void *arg); INTDEF WUNUSED NONNULL((1, 2, 3)) Dee_ssize_t DCALL DeeSeq_TDefaultForeachWithSizeAndGetItemIndex(DeeTypeObject *tp_self, DeeObject *self, Dee_foreach_t proc, void *arg); +INTDEF WUNUSED NONNULL((1, 2, 3)) Dee_ssize_t DCALL DeeSeq_TDefaultForeachWithSizeObAndGetItem(DeeTypeObject *tp_self, DeeObject *self, Dee_foreach_t proc, void *arg); INTDEF WUNUSED NONNULL((1, 2, 3)) Dee_ssize_t DCALL DeeSeq_TDefaultForeachWithSizeDefaultAndGetItemIndexDefault(DeeTypeObject *tp_self, DeeObject *self, Dee_foreach_t proc, void *arg); INTDEF WUNUSED NONNULL((1, 2, 3)) Dee_ssize_t DCALL DeeSeq_TDefaultForeachWithGetItemIndexDefault(DeeTypeObject *tp_self, DeeObject *self, Dee_foreach_t proc, void *arg); INTDEF WUNUSED NONNULL((1, 2, 3)) Dee_ssize_t DCALL DeeObject_TDefaultForeachPairWithForeach(DeeTypeObject *tp_self, DeeObject *self, Dee_foreach_pair_t proc, void *arg); @@ -2234,8 +2391,8 @@ INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeObject_TDefaultGetIte INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeObject_TDefaultGetItemWithTryGetItemStringLenHash(DeeTypeObject *tp_self, DeeObject *self, DeeObject *index); INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeSeq_TDefaultGetItemWithTryGetItemAndSizeOb(DeeTypeObject *tp_self, DeeObject *self, DeeObject *index); INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeSeq_TDefaultGetItemWithTryGetItemAndSize(DeeTypeObject *tp_self, DeeObject *self, DeeObject *index); -INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeSeq_TDefaultGetItemWithTryGetItemIndexAndSizeOb(DeeTypeObject *tp_self, DeeObject *self, DeeObject *index); -INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeSeq_TDefaultGetItemWithTryGetItemIndexAndSize(DeeTypeObject *tp_self, DeeObject *self, DeeObject *index); +INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeSeq_TDefaultGetItemWithSizeAndTryGetItemIndexOb(DeeTypeObject *tp_self, DeeObject *self, DeeObject *index); +INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeSeq_TDefaultGetItemWithSizeAndTryGetItemIndex(DeeTypeObject *tp_self, DeeObject *self, DeeObject *index); INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeMap_TDefaultGetItemWithForeachPair(DeeTypeObject *tp_self, DeeObject *self, DeeObject *index); INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeMap_TDefaultGetItemWithForeachPairDefault(DeeTypeObject *tp_self, DeeObject *self, DeeObject *index); INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeObject_TDefaultGetItemIndexWithSizeAndGetItemIndexFast(DeeTypeObject *tp_self, DeeObject *self, size_t index); @@ -2244,8 +2401,8 @@ INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeObject_TDefaultGetItemIn INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeObject_TDefaultGetItemIndexWithTryGetItem(DeeTypeObject *tp_self, DeeObject *self, size_t index); INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeObject_TDefaultGetItemIndexWithErrorRequiresString(DeeTypeObject *tp_self, DeeObject *self, size_t index); INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeObject_TDefaultGetItemIndexWithGetItemDefault(DeeTypeObject *tp_self, DeeObject *self, size_t index); -INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_TDefaultGetItemIndexWithTryGetItemIndexAndSize(DeeTypeObject *tp_self, DeeObject *self, size_t index); -INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_TDefaultGetItemIndexWithTryGetItemIndexAndSizeOb(DeeTypeObject *tp_self, DeeObject *self, size_t index); +INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_TDefaultGetItemIndexWithSizeAndTryGetItemIndex(DeeTypeObject *tp_self, DeeObject *self, size_t index); +INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_TDefaultGetItemIndexWithSizeAndTryGetItemIndexOb(DeeTypeObject *tp_self, DeeObject *self, size_t index); INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_TDefaultGetItemIndexWithTryGetItemAndSize(DeeTypeObject *tp_self, DeeObject *self, size_t index); INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_TDefaultGetItemIndexWithTryGetItemAndSizeOb(DeeTypeObject *tp_self, DeeObject *self, size_t index); INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_TDefaultGetItemIndexWithForeachDefault(DeeTypeObject *tp_self, DeeObject *self, size_t index); @@ -2344,7 +2501,7 @@ INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL DeeObject_TDefaultBoundItemWithTryGe INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL DeeObject_TDefaultBoundItemWithTryGetItemStringLenHashAndHasItemStringLenHash(DeeTypeObject *tp_self, DeeObject *self, DeeObject *index); INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL DeeObject_TDefaultBoundItemWithTryGetItemStringHashAndHasItemStringHash(DeeTypeObject *tp_self, DeeObject *self, DeeObject *index); INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL DeeSeq_TDefaultBoundItemWithTryGetItemAndSizeOb(DeeTypeObject *tp_self, DeeObject *self, DeeObject *index); -INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL DeeSeq_TDefaultBoundItemWithTryGetItemIndexAndSize(DeeTypeObject *tp_self, DeeObject *self, DeeObject *index); +INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL DeeSeq_TDefaultBoundItemWithSizeAndTryGetItemIndex(DeeTypeObject *tp_self, DeeObject *self, DeeObject *index); INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL DeeObject_TDefaultBoundItemWithTryGetItem(DeeTypeObject *tp_self, DeeObject *self, DeeObject *index); INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL DeeObject_TDefaultBoundItemWithTryGetItemIndex(DeeTypeObject *tp_self, DeeObject *self, DeeObject *index); INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL DeeObject_TDefaultBoundItemWithTryGetItemStringLenHash(DeeTypeObject *tp_self, DeeObject *self, DeeObject *index); @@ -2360,7 +2517,7 @@ INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeObject_TDefaultBoundItemIndexWithGet INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeObject_TDefaultBoundItemIndexWithGetItemIndexDefault(DeeTypeObject *tp_self, DeeObject *self, size_t index); INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeObject_TDefaultBoundItemIndexWithTryGetItemIndexAndHasItemIndex(DeeTypeObject *tp_self, DeeObject *self, size_t index); INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeObject_TDefaultBoundItemIndexWithTryGetItemAndHasItem(DeeTypeObject *tp_self, DeeObject *self, size_t index); -INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeSeq_TDefaultBoundItemIndexWithTryGetItemIndexAndSize(DeeTypeObject *tp_self, DeeObject *self, size_t index); +INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeSeq_TDefaultBoundItemIndexWithSizeAndTryGetItemIndex(DeeTypeObject *tp_self, DeeObject *self, size_t index); INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeSeq_TDefaultBoundItemIndexWithTryGetItemAndSizeOb(DeeTypeObject *tp_self, DeeObject *self, size_t index); INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeObject_TDefaultBoundItemIndexWithErrorRequiresString(DeeTypeObject *tp_self, DeeObject *self, size_t index); INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeMap_TDefaultBoundItemIndexWithContains(DeeTypeObject *tp_self, DeeObject *self, size_t index); @@ -2600,23 +2757,84 @@ INTDEF WUNUSED NONNULL((1, 2, 4)) int DCALL DeeSeq_TDefaultSetRangeIndexNWithSiz (tp_dec) == &DeeObject_DefaultDecWithAdd ? map(DeeObject_TDefaultDecWithAdd) : \ (tp_dec) == &DeeObject_DefaultDecWithInplaceSub ? map(DeeObject_TDefaultDecWithInplaceSub) : \ (tp_dec) == &DeeObject_DefaultDecWithSub ? map(DeeObject_TDefaultDecWithSub) : default) +#define DeeType_MapDefaultHash(tp_hash, map, default) \ + ((tp_hash) == &DeeSeq_DefaultHashWithSizeAndGetItemIndexFast ? map(DeeSeq_TDefaultHashWithSizeAndGetItemIndexFast) : \ + (tp_hash) == &DeeSeq_DefaultHashWithForeach ? map(DeeSeq_TDefaultHashWithForeach) : \ + (tp_hash) == &DeeSeq_DefaultHashWithSizeAndTryGetItemIndex ? map(DeeSeq_TDefaultHashWithSizeAndTryGetItemIndex) : \ + (tp_hash) == &DeeSeq_DefaultHashWithSizeAndGetItemIndex ? map(DeeSeq_TDefaultHashWithSizeAndGetItemIndex) : \ + (tp_hash) == &DeeSeq_DefaultHashWithSizeObAndGetItem ? map(DeeSeq_TDefaultHashWithSizeObAndGetItem) : \ + (tp_hash) == &DeeSeq_DefaultHashWithForeachDefault ? map(DeeSeq_TDefaultHashWithForeachDefault) : \ + (tp_hash) == &DeeSet_DefaultHashWithForeachDefault ? map(DeeSet_TDefaultHashWithForeachDefault) : \ + (tp_hash) == &DeeMap_DefaultHashWithForeachPairDefault ? map(DeeMap_TDefaultHashWithForeachPairDefault) : default) #define DeeType_MapDefaultEq(tp_eq, map, default) \ - ((tp_eq) == &DeeObject_DefaultEqWithNe ? map(DeeObject_TDefaultEqWithNe) : default) + ((tp_eq) == &DeeObject_DefaultEqWithCompareEq ? map(DeeObject_TDefaultEqWithCompareEq) : \ + (tp_eq) == &DeeObject_DefaultEqWithNe ? map(DeeObject_TDefaultEqWithNe) : \ + (tp_eq) == &DeeObject_DefaultEqWithLoAndGr ? map(DeeObject_TDefaultEqWithLoAndGr) : \ + (tp_eq) == &DeeObject_DefaultEqWithLeAndGe ? map(DeeObject_TDefaultEqWithLeAndGe) : \ + (tp_eq) == &DeeObject_DefaultEqWithCompareEqDefault ? map(DeeObject_TDefaultEqWithCompareEqDefault) : default) #define DeeType_MapDefaultNe(tp_ne, map, default) \ - ((tp_ne) == &DeeObject_DefaultNeWithEq ? map(DeeObject_TDefaultNeWithEq) : default) + ((tp_ne) == &DeeObject_DefaultNeWithCompareEq ? map(DeeObject_TDefaultNeWithCompareEq) : \ + (tp_ne) == &DeeObject_DefaultNeWithEq ? map(DeeObject_TDefaultNeWithEq) : \ + (tp_ne) == &DeeObject_DefaultNeWithLoAndGr ? map(DeeObject_TDefaultNeWithLoAndGr) : \ + (tp_ne) == &DeeObject_DefaultNeWithLeAndGe ? map(DeeObject_TDefaultNeWithLeAndGe) : \ + (tp_ne) == &DeeObject_DefaultNeWithCompareEqDefault ? map(DeeObject_TDefaultNeWithCompareEqDefault) : default) #define DeeType_MapDefaultLo(tp_lo, map, default) \ - ((tp_lo) == &DeeObject_DefaultLoWithGe ? map(DeeObject_TDefaultLoWithGe) : default) + ((tp_lo) == &DeeObject_DefaultLoWithCompare ? map(DeeObject_TDefaultLoWithCompare) : \ + (tp_lo) == &DeeObject_DefaultLoWithGe ? map(DeeObject_TDefaultLoWithGe) : \ + (tp_lo) == &DeeObject_DefaultLoWithCompareDefault ? map(DeeObject_TDefaultLoWithCompareDefault) : \ + (tp_lo) == &DeeSet_DefaultLoWithForeachDefault ? map(DeeSet_TDefaultLoWithForeachDefault) : \ + (tp_lo) == &DeeMap_DefaultLoWithForeachPairDefault ? map(DeeMap_TDefaultLoWithForeachPairDefault) : default) #define DeeType_MapDefaultLe(tp_le, map, default) \ - ((tp_le) == &DeeObject_DefaultLeWithGr ? map(DeeObject_TDefaultLeWithGr) : default) + ((tp_le) == &DeeObject_DefaultLeWithCompare ? map(DeeObject_TDefaultLeWithCompare) : \ + (tp_le) == &DeeObject_DefaultLeWithGr ? map(DeeObject_TDefaultLeWithGr) : \ + (tp_le) == &DeeObject_DefaultLeWithCompareDefault ? map(DeeObject_TDefaultLeWithCompareDefault) : \ + (tp_le) == &DeeSet_DefaultLeWithForeachDefault ? map(DeeSet_TDefaultLeWithForeachDefault) : \ + (tp_le) == &DeeMap_DefaultLeWithForeachPairDefault ? map(DeeMap_TDefaultLeWithForeachPairDefault) : default) #define DeeType_MapDefaultGr(tp_gr, map, default) \ - ((tp_gr) == &DeeObject_DefaultGrWithLe ? map(DeeObject_TDefaultGrWithLe) : default) + ((tp_gr) == &DeeObject_DefaultGrWithCompare ? map(DeeObject_TDefaultGrWithCompare) : \ + (tp_gr) == &DeeObject_DefaultGrWithLe ? map(DeeObject_TDefaultGrWithLe) : \ + (tp_gr) == &DeeObject_DefaultGrWithCompareDefault ? map(DeeObject_TDefaultGrWithCompareDefault) : \ + (tp_gr) == &DeeSet_DefaultGrWithForeachDefault ? map(DeeSet_TDefaultGrWithForeachDefault) : \ + (tp_gr) == &DeeMap_DefaultGrWithForeachPairDefault ? map(DeeMap_TDefaultGrWithForeachPairDefault) : default) #define DeeType_MapDefaultGe(tp_ge, map, default) \ - ((tp_ge) == &DeeObject_DefaultGeWithLo ? map(DeeObject_TDefaultGeWithLo) : default) + ((tp_ge) == &DeeObject_DefaultGeWithCompare ? map(DeeObject_TDefaultGeWithCompare) : \ + (tp_ge) == &DeeObject_DefaultGeWithLo ? map(DeeObject_TDefaultGeWithLo) : \ + (tp_ge) == &DeeObject_DefaultGeWithCompareDefault ? map(DeeObject_TDefaultGeWithCompareDefault) : \ + (tp_ge) == &DeeSet_DefaultGeWithForeachDefault ? map(DeeSet_TDefaultGeWithForeachDefault) : \ + (tp_ge) == &DeeMap_DefaultGeWithForeachPairDefault ? map(DeeMap_TDefaultGeWithForeachPairDefault) : default) +#define DeeType_MapDefaultCompareEq(tp_compare_eq, map, default) \ + ((tp_compare_eq) == &DeeObject_DefaultCompareEqWithEq ? map(DeeObject_TDefaultCompareEqWithEq) : \ + (tp_compare_eq) == &DeeObject_DefaultCompareEqWithNe ? map(DeeObject_TDefaultCompareEqWithNe) : \ + (tp_compare_eq) == &DeeObject_DefaultCompareEqWithLoAndGr ? map(DeeObject_TDefaultCompareEqWithLoAndGr) : \ + (tp_compare_eq) == &DeeObject_DefaultCompareEqWithLeAndGe ? map(DeeObject_TDefaultCompareEqWithLeAndGe) : \ + (tp_compare_eq) == &DeeSeq_DefaultCompareEqWithForeachDefault ? map(DeeSeq_TDefaultCompareEqWithForeachDefault) : \ + (tp_compare_eq) == &DeeSeq_DefaultCompareEqWithSizeAndGetItemIndexFast ? map(DeeSeq_TDefaultCompareEqWithSizeAndGetItemIndexFast) : \ + (tp_compare_eq) == &DeeSeq_DefaultCompareEqWithSizeAndTryGetItemIndex ? map(DeeSeq_TDefaultCompareEqWithSizeAndTryGetItemIndex) : \ + (tp_compare_eq) == &DeeSeq_DefaultCompareEqWithSizeAndGetItemIndex ? map(DeeSeq_TDefaultCompareEqWithSizeAndGetItemIndex) : \ + (tp_compare_eq) == &DeeSeq_DefaultCompareEqWithSizeObAndGetItem ? map(DeeSeq_TDefaultCompareEqWithSizeObAndGetItem) : \ + (tp_compare_eq) == &DeeSet_DefaultCompareEqWithForeachDefault ? map(DeeSet_TDefaultCompareEqWithForeachDefault) : \ + (tp_compare_eq) == &DeeMap_DefaultCompareEqWithForeachPairDefault ? map(DeeMap_TDefaultCompareEqWithForeachPairDefault) : default) +#define DeeType_MapDefaultCompare(tp_compare, map, default) \ + ((tp_compare) == &DeeObject_DefaultCompareWithEqAndLo ? map(DeeObject_TDefaultCompareWithEqAndLo) : \ + (tp_compare) == &DeeObject_DefaultCompareWithEqAndLe ? map(DeeObject_TDefaultCompareWithEqAndLe) : \ + (tp_compare) == &DeeObject_DefaultCompareWithEqAndGr ? map(DeeObject_TDefaultCompareWithEqAndGr) : \ + (tp_compare) == &DeeObject_DefaultCompareWithEqAndGe ? map(DeeObject_TDefaultCompareWithEqAndGe) : \ + (tp_compare) == &DeeObject_DefaultCompareWithNeAndLo ? map(DeeObject_TDefaultCompareWithNeAndLo) : \ + (tp_compare) == &DeeObject_DefaultCompareWithNeAndLe ? map(DeeObject_TDefaultCompareWithNeAndLe) : \ + (tp_compare) == &DeeObject_DefaultCompareWithNeAndGr ? map(DeeObject_TDefaultCompareWithNeAndGr) : \ + (tp_compare) == &DeeObject_DefaultCompareWithNeAndGe ? map(DeeObject_TDefaultCompareWithNeAndGe) : \ + (tp_compare) == &DeeObject_DefaultCompareWithLoAndGr ? map(DeeObject_TDefaultCompareWithLoAndGr) : \ + (tp_compare) == &DeeObject_DefaultCompareWithLeAndGe ? map(DeeObject_TDefaultCompareWithLeAndGe) : \ + (tp_compare) == &DeeSeq_DefaultCompareWithSizeAndGetItemIndexFast ? map(DeeSeq_TDefaultCompareWithSizeAndGetItemIndexFast) : \ + (tp_compare) == &DeeSeq_DefaultCompareWithSizeAndTryGetItemIndex ? map(DeeSeq_TDefaultCompareWithSizeAndTryGetItemIndex) : \ + (tp_compare) == &DeeSeq_DefaultCompareWithSizeAndGetItemIndex ? map(DeeSeq_TDefaultCompareWithSizeAndGetItemIndex) : \ + (tp_compare) == &DeeSeq_DefaultCompareWithSizeObAndGetItem ? map(DeeSeq_TDefaultCompareWithSizeObAndGetItem) : \ + (tp_compare) == &DeeSeq_DefaultCompareWithForeachDefault ? map(DeeSeq_TDefaultCompareWithForeachDefault) : default) #define DeeType_MapDefaultIter(tp_iter, map, default) \ ((tp_iter) == &DeeObject_DefaultIterWithForeach ? map(DeeObject_TDefaultIterWithForeach) : \ (tp_iter) == &DeeObject_DefaultIterWithForeachPair ? map(DeeObject_TDefaultIterWithForeachPair) : \ (tp_iter) == &DeeSeq_DefaultIterWithSizeAndGetItemIndexFast ? map(DeeSeq_TDefaultIterWithSizeAndGetItemIndexFast) : \ - (tp_iter) == &DeeSeq_DefaultIterWithTryGetItemIndexAndSize ? map(DeeSeq_TDefaultIterWithTryGetItemIndexAndSize) : \ + (tp_iter) == &DeeSeq_DefaultIterWithSizeAndTryGetItemIndex ? map(DeeSeq_TDefaultIterWithSizeAndTryGetItemIndex) : \ (tp_iter) == &DeeSeq_DefaultIterWithSizeAndGetItemIndex ? map(DeeSeq_TDefaultIterWithSizeAndGetItemIndex) : \ (tp_iter) == &DeeSeq_DefaultIterWithGetItemIndex ? map(DeeSeq_TDefaultIterWithGetItemIndex) : \ (tp_iter) == &DeeSeq_DefaultIterWithSizeObAndGetItem ? map(DeeSeq_TDefaultIterWithSizeObAndGetItem) : \ @@ -2625,8 +2843,9 @@ INTDEF WUNUSED NONNULL((1, 2, 4)) int DCALL DeeSeq_TDefaultSetRangeIndexNWithSiz ((tp_foreach) == &DeeObject_DefaultForeachWithIter ? map(DeeObject_TDefaultForeachWithIter) : \ (tp_foreach) == &DeeObject_DefaultForeachWithForeachPair ? map(DeeObject_TDefaultForeachWithForeachPair) : \ (tp_foreach) == &DeeSeq_DefaultForeachWithSizeAndGetItemIndexFast ? map(DeeSeq_TDefaultForeachWithSizeAndGetItemIndexFast) : \ - (tp_foreach) == &DeeSeq_DefaultForeachWithTryGetItemIndexAndSize ? map(DeeSeq_TDefaultForeachWithTryGetItemIndexAndSize) : \ + (tp_foreach) == &DeeSeq_DefaultForeachWithSizeAndTryGetItemIndex ? map(DeeSeq_TDefaultForeachWithSizeAndTryGetItemIndex) : \ (tp_foreach) == &DeeSeq_DefaultForeachWithSizeAndGetItemIndex ? map(DeeSeq_TDefaultForeachWithSizeAndGetItemIndex) : \ + (tp_foreach) == &DeeSeq_DefaultForeachWithSizeObAndGetItem ? map(DeeSeq_TDefaultForeachWithSizeObAndGetItem) : \ (tp_foreach) == &DeeSeq_DefaultForeachWithSizeDefaultAndGetItemIndexDefault ? map(DeeSeq_TDefaultForeachWithSizeDefaultAndGetItemIndexDefault) : \ (tp_foreach) == &DeeSeq_DefaultForeachWithGetItemIndexDefault ? map(DeeSeq_TDefaultForeachWithGetItemIndexDefault) : default) #define DeeType_MapDefaultForeachPair(tp_foreach_pair, map, default) \ @@ -2673,8 +2892,8 @@ INTDEF WUNUSED NONNULL((1, 2, 4)) int DCALL DeeSeq_TDefaultSetRangeIndexNWithSiz (tp_getitem) == &DeeObject_DefaultGetItemWithTryGetItemStringLenHash ? map(DeeObject_TDefaultGetItemWithTryGetItemStringLenHash) : \ (tp_getitem) == &DeeSeq_DefaultGetItemWithTryGetItemAndSizeOb ? map(DeeSeq_TDefaultGetItemWithTryGetItemAndSizeOb) : \ (tp_getitem) == &DeeSeq_DefaultGetItemWithTryGetItemAndSize ? map(DeeSeq_TDefaultGetItemWithTryGetItemAndSize) : \ - (tp_getitem) == &DeeSeq_DefaultGetItemWithTryGetItemIndexAndSizeOb ? map(DeeSeq_TDefaultGetItemWithTryGetItemIndexAndSizeOb) : \ - (tp_getitem) == &DeeSeq_DefaultGetItemWithTryGetItemIndexAndSize ? map(DeeSeq_TDefaultGetItemWithTryGetItemIndexAndSize) : \ + (tp_getitem) == &DeeSeq_DefaultGetItemWithSizeAndTryGetItemIndexOb ? map(DeeSeq_TDefaultGetItemWithSizeAndTryGetItemIndexOb) : \ + (tp_getitem) == &DeeSeq_DefaultGetItemWithSizeAndTryGetItemIndex ? map(DeeSeq_TDefaultGetItemWithSizeAndTryGetItemIndex) : \ (tp_getitem) == &DeeMap_DefaultGetItemWithForeachPair ? map(DeeMap_TDefaultGetItemWithForeachPair) : \ (tp_getitem) == &DeeMap_DefaultGetItemWithForeachPairDefault ? map(DeeMap_TDefaultGetItemWithForeachPairDefault) : default) #define DeeType_MapDefaultGetItemIndex(tp_getitem_index, map, default) \ @@ -2683,8 +2902,8 @@ INTDEF WUNUSED NONNULL((1, 2, 4)) int DCALL DeeSeq_TDefaultSetRangeIndexNWithSiz (tp_getitem_index) == &DeeObject_DefaultGetItemIndexWithGetItem ? map(DeeObject_TDefaultGetItemIndexWithGetItem) : \ (tp_getitem_index) == &DeeObject_DefaultGetItemIndexWithTryGetItem ? map(DeeObject_TDefaultGetItemIndexWithTryGetItem) : \ (tp_getitem_index) == &DeeObject_DefaultGetItemIndexWithGetItemDefault ? map(DeeObject_TDefaultGetItemIndexWithGetItemDefault) : \ - (tp_getitem_index) == &DeeSeq_DefaultGetItemIndexWithTryGetItemIndexAndSize ? map(DeeSeq_TDefaultGetItemIndexWithTryGetItemIndexAndSize) : \ - (tp_getitem_index) == &DeeSeq_DefaultGetItemIndexWithTryGetItemIndexAndSizeOb ? map(DeeSeq_TDefaultGetItemIndexWithTryGetItemIndexAndSizeOb) : \ + (tp_getitem_index) == &DeeSeq_DefaultGetItemIndexWithSizeAndTryGetItemIndex ? map(DeeSeq_TDefaultGetItemIndexWithSizeAndTryGetItemIndex) : \ + (tp_getitem_index) == &DeeSeq_DefaultGetItemIndexWithSizeAndTryGetItemIndexOb ? map(DeeSeq_TDefaultGetItemIndexWithSizeAndTryGetItemIndexOb) : \ (tp_getitem_index) == &DeeSeq_DefaultGetItemIndexWithTryGetItemAndSize ? map(DeeSeq_TDefaultGetItemIndexWithTryGetItemAndSize) : \ (tp_getitem_index) == &DeeSeq_DefaultGetItemIndexWithTryGetItemAndSizeOb ? map(DeeSeq_TDefaultGetItemIndexWithTryGetItemAndSizeOb) : \ (tp_getitem_index) == &DeeSeq_DefaultGetItemIndexWithForeachDefault ? map(DeeSeq_TDefaultGetItemIndexWithForeachDefault) : \ @@ -2787,7 +3006,7 @@ INTDEF WUNUSED NONNULL((1, 2, 4)) int DCALL DeeSeq_TDefaultSetRangeIndexNWithSiz (tp_bounditem) == &DeeObject_DefaultBoundItemWithTryGetItemStringLenHashAndHasItemStringLenHash ? map(DeeObject_TDefaultBoundItemWithTryGetItemStringLenHashAndHasItemStringLenHash) : \ (tp_bounditem) == &DeeObject_DefaultBoundItemWithTryGetItemStringHashAndHasItemStringHash ? map(DeeObject_TDefaultBoundItemWithTryGetItemStringHashAndHasItemStringHash) : \ (tp_bounditem) == &DeeSeq_DefaultBoundItemWithTryGetItemAndSizeOb ? map(DeeSeq_TDefaultBoundItemWithTryGetItemAndSizeOb) : \ - (tp_bounditem) == &DeeSeq_DefaultBoundItemWithTryGetItemIndexAndSize ? map(DeeSeq_TDefaultBoundItemWithTryGetItemIndexAndSize) : \ + (tp_bounditem) == &DeeSeq_DefaultBoundItemWithSizeAndTryGetItemIndex ? map(DeeSeq_TDefaultBoundItemWithSizeAndTryGetItemIndex) : \ (tp_bounditem) == &DeeObject_DefaultBoundItemWithTryGetItem ? map(DeeObject_TDefaultBoundItemWithTryGetItem) : \ (tp_bounditem) == &DeeObject_DefaultBoundItemWithTryGetItemIndex ? map(DeeObject_TDefaultBoundItemWithTryGetItemIndex) : \ (tp_bounditem) == &DeeObject_DefaultBoundItemWithTryGetItemStringLenHash ? map(DeeObject_TDefaultBoundItemWithTryGetItemStringLenHash) : \ @@ -2804,7 +3023,7 @@ INTDEF WUNUSED NONNULL((1, 2, 4)) int DCALL DeeSeq_TDefaultSetRangeIndexNWithSiz (tp_bounditem_index) == &DeeObject_DefaultBoundItemIndexWithGetItemIndexDefault ? map(DeeObject_TDefaultBoundItemIndexWithGetItemIndexDefault) : \ (tp_bounditem_index) == &DeeObject_DefaultBoundItemIndexWithTryGetItemIndexAndHasItemIndex ? map(DeeObject_TDefaultBoundItemIndexWithTryGetItemIndexAndHasItemIndex) : \ (tp_bounditem_index) == &DeeObject_DefaultBoundItemIndexWithTryGetItemAndHasItem ? map(DeeObject_TDefaultBoundItemIndexWithTryGetItemAndHasItem) : \ - (tp_bounditem_index) == &DeeSeq_DefaultBoundItemIndexWithTryGetItemIndexAndSize ? map(DeeSeq_TDefaultBoundItemIndexWithTryGetItemIndexAndSize) : \ + (tp_bounditem_index) == &DeeSeq_DefaultBoundItemIndexWithSizeAndTryGetItemIndex ? map(DeeSeq_TDefaultBoundItemIndexWithSizeAndTryGetItemIndex) : \ (tp_bounditem_index) == &DeeSeq_DefaultBoundItemIndexWithTryGetItemAndSizeOb ? map(DeeSeq_TDefaultBoundItemIndexWithTryGetItemAndSizeOb) : \ (tp_bounditem_index) == &DeeMap_DefaultBoundItemIndexWithContains ? map(DeeMap_TDefaultBoundItemIndexWithContains) : \ (tp_bounditem_index) == &DeeMap_DefaultBoundItemIndexWithForeachPair ? map(DeeMap_TDefaultBoundItemIndexWithForeachPair) : \ @@ -3053,23 +3272,84 @@ INTDEF WUNUSED NONNULL((1, 2, 4)) int DCALL DeeSeq_TDefaultSetRangeIndexNWithSiz (tp_dec) == &DeeObject_DefaultDecWithAdd || \ (tp_dec) == &DeeObject_DefaultDecWithInplaceSub || \ (tp_dec) == &DeeObject_DefaultDecWithSub) +#define DeeType_IsDefaultHash(tp_hash) \ + ((tp_hash) == &DeeSeq_DefaultHashWithSizeAndGetItemIndexFast || \ + (tp_hash) == &DeeSeq_DefaultHashWithForeach || \ + (tp_hash) == &DeeSeq_DefaultHashWithSizeAndTryGetItemIndex || \ + (tp_hash) == &DeeSeq_DefaultHashWithSizeAndGetItemIndex || \ + (tp_hash) == &DeeSeq_DefaultHashWithSizeObAndGetItem || \ + (tp_hash) == &DeeSeq_DefaultHashWithForeachDefault || \ + (tp_hash) == &DeeSet_DefaultHashWithForeachDefault || \ + (tp_hash) == &DeeMap_DefaultHashWithForeachPairDefault) #define DeeType_IsDefaultEq(tp_eq) \ - ((tp_eq) == &DeeObject_DefaultEqWithNe) + ((tp_eq) == &DeeObject_DefaultEqWithCompareEq || \ + (tp_eq) == &DeeObject_DefaultEqWithNe || \ + (tp_eq) == &DeeObject_DefaultEqWithLoAndGr || \ + (tp_eq) == &DeeObject_DefaultEqWithLeAndGe || \ + (tp_eq) == &DeeObject_DefaultEqWithCompareEqDefault) #define DeeType_IsDefaultNe(tp_ne) \ - ((tp_ne) == &DeeObject_DefaultNeWithEq) + ((tp_ne) == &DeeObject_DefaultNeWithCompareEq || \ + (tp_ne) == &DeeObject_DefaultNeWithEq || \ + (tp_ne) == &DeeObject_DefaultNeWithLoAndGr || \ + (tp_ne) == &DeeObject_DefaultNeWithLeAndGe || \ + (tp_ne) == &DeeObject_DefaultNeWithCompareEqDefault) #define DeeType_IsDefaultLo(tp_lo) \ - ((tp_lo) == &DeeObject_DefaultLoWithGe) + ((tp_lo) == &DeeObject_DefaultLoWithCompare || \ + (tp_lo) == &DeeObject_DefaultLoWithGe || \ + (tp_lo) == &DeeObject_DefaultLoWithCompareDefault || \ + (tp_lo) == &DeeSet_DefaultLoWithForeachDefault || \ + (tp_lo) == &DeeMap_DefaultLoWithForeachPairDefault) #define DeeType_IsDefaultLe(tp_le) \ - ((tp_le) == &DeeObject_DefaultLeWithGr) + ((tp_le) == &DeeObject_DefaultLeWithCompare || \ + (tp_le) == &DeeObject_DefaultLeWithGr || \ + (tp_le) == &DeeObject_DefaultLeWithCompareDefault || \ + (tp_le) == &DeeSet_DefaultLeWithForeachDefault || \ + (tp_le) == &DeeMap_DefaultLeWithForeachPairDefault) #define DeeType_IsDefaultGr(tp_gr) \ - ((tp_gr) == &DeeObject_DefaultGrWithLe) + ((tp_gr) == &DeeObject_DefaultGrWithCompare || \ + (tp_gr) == &DeeObject_DefaultGrWithLe || \ + (tp_gr) == &DeeObject_DefaultGrWithCompareDefault || \ + (tp_gr) == &DeeSet_DefaultGrWithForeachDefault || \ + (tp_gr) == &DeeMap_DefaultGrWithForeachPairDefault) #define DeeType_IsDefaultGe(tp_ge) \ - ((tp_ge) == &DeeObject_DefaultGeWithLo) + ((tp_ge) == &DeeObject_DefaultGeWithCompare || \ + (tp_ge) == &DeeObject_DefaultGeWithLo || \ + (tp_ge) == &DeeObject_DefaultGeWithCompareDefault || \ + (tp_ge) == &DeeSet_DefaultGeWithForeachDefault || \ + (tp_ge) == &DeeMap_DefaultGeWithForeachPairDefault) +#define DeeType_IsDefaultCompareEq(tp_compare_eq) \ + ((tp_compare_eq) == &DeeObject_DefaultCompareEqWithEq || \ + (tp_compare_eq) == &DeeObject_DefaultCompareEqWithNe || \ + (tp_compare_eq) == &DeeObject_DefaultCompareEqWithLoAndGr || \ + (tp_compare_eq) == &DeeObject_DefaultCompareEqWithLeAndGe || \ + (tp_compare_eq) == &DeeSeq_DefaultCompareEqWithForeachDefault || \ + (tp_compare_eq) == &DeeSeq_DefaultCompareEqWithSizeAndGetItemIndexFast || \ + (tp_compare_eq) == &DeeSeq_DefaultCompareEqWithSizeAndTryGetItemIndex || \ + (tp_compare_eq) == &DeeSeq_DefaultCompareEqWithSizeAndGetItemIndex || \ + (tp_compare_eq) == &DeeSeq_DefaultCompareEqWithSizeObAndGetItem || \ + (tp_compare_eq) == &DeeSet_DefaultCompareEqWithForeachDefault || \ + (tp_compare_eq) == &DeeMap_DefaultCompareEqWithForeachPairDefault) +#define DeeType_IsDefaultCompare(tp_compare) \ + ((tp_compare) == &DeeObject_DefaultCompareWithEqAndLo || \ + (tp_compare) == &DeeObject_DefaultCompareWithEqAndLe || \ + (tp_compare) == &DeeObject_DefaultCompareWithEqAndGr || \ + (tp_compare) == &DeeObject_DefaultCompareWithEqAndGe || \ + (tp_compare) == &DeeObject_DefaultCompareWithNeAndLo || \ + (tp_compare) == &DeeObject_DefaultCompareWithNeAndLe || \ + (tp_compare) == &DeeObject_DefaultCompareWithNeAndGr || \ + (tp_compare) == &DeeObject_DefaultCompareWithNeAndGe || \ + (tp_compare) == &DeeObject_DefaultCompareWithLoAndGr || \ + (tp_compare) == &DeeObject_DefaultCompareWithLeAndGe || \ + (tp_compare) == &DeeSeq_DefaultCompareWithSizeAndGetItemIndexFast || \ + (tp_compare) == &DeeSeq_DefaultCompareWithSizeAndTryGetItemIndex || \ + (tp_compare) == &DeeSeq_DefaultCompareWithSizeAndGetItemIndex || \ + (tp_compare) == &DeeSeq_DefaultCompareWithSizeObAndGetItem || \ + (tp_compare) == &DeeSeq_DefaultCompareWithForeachDefault) #define DeeType_IsDefaultIter(tp_iter) \ ((tp_iter) == &DeeObject_DefaultIterWithForeach || \ (tp_iter) == &DeeObject_DefaultIterWithForeachPair || \ (tp_iter) == &DeeSeq_DefaultIterWithSizeAndGetItemIndexFast || \ - (tp_iter) == &DeeSeq_DefaultIterWithTryGetItemIndexAndSize || \ + (tp_iter) == &DeeSeq_DefaultIterWithSizeAndTryGetItemIndex || \ (tp_iter) == &DeeSeq_DefaultIterWithSizeAndGetItemIndex || \ (tp_iter) == &DeeSeq_DefaultIterWithGetItemIndex || \ (tp_iter) == &DeeSeq_DefaultIterWithSizeObAndGetItem || \ @@ -3078,8 +3358,9 @@ INTDEF WUNUSED NONNULL((1, 2, 4)) int DCALL DeeSeq_TDefaultSetRangeIndexNWithSiz ((tp_foreach) == &DeeObject_DefaultForeachWithIter || \ (tp_foreach) == &DeeObject_DefaultForeachWithForeachPair || \ (tp_foreach) == &DeeSeq_DefaultForeachWithSizeAndGetItemIndexFast || \ - (tp_foreach) == &DeeSeq_DefaultForeachWithTryGetItemIndexAndSize || \ + (tp_foreach) == &DeeSeq_DefaultForeachWithSizeAndTryGetItemIndex || \ (tp_foreach) == &DeeSeq_DefaultForeachWithSizeAndGetItemIndex || \ + (tp_foreach) == &DeeSeq_DefaultForeachWithSizeObAndGetItem || \ (tp_foreach) == &DeeSeq_DefaultForeachWithSizeDefaultAndGetItemIndexDefault || \ (tp_foreach) == &DeeSeq_DefaultForeachWithGetItemIndexDefault) #define DeeType_IsDefaultForeachPair(tp_foreach_pair) \ @@ -3127,8 +3408,8 @@ INTDEF WUNUSED NONNULL((1, 2, 4)) int DCALL DeeSeq_TDefaultSetRangeIndexNWithSiz (tp_getitem) == &DeeObject_DefaultGetItemWithTryGetItemStringLenHash || \ (tp_getitem) == &DeeSeq_DefaultGetItemWithTryGetItemAndSizeOb || \ (tp_getitem) == &DeeSeq_DefaultGetItemWithTryGetItemAndSize || \ - (tp_getitem) == &DeeSeq_DefaultGetItemWithTryGetItemIndexAndSizeOb || \ - (tp_getitem) == &DeeSeq_DefaultGetItemWithTryGetItemIndexAndSize || \ + (tp_getitem) == &DeeSeq_DefaultGetItemWithSizeAndTryGetItemIndexOb || \ + (tp_getitem) == &DeeSeq_DefaultGetItemWithSizeAndTryGetItemIndex || \ (tp_getitem) == &DeeMap_DefaultGetItemWithForeachPair || \ (tp_getitem) == &DeeMap_DefaultGetItemWithForeachPairDefault) #define DeeType_IsDefaultGetItemIndex(tp_getitem_index) \ @@ -3138,8 +3419,8 @@ INTDEF WUNUSED NONNULL((1, 2, 4)) int DCALL DeeSeq_TDefaultSetRangeIndexNWithSiz (tp_getitem_index) == &DeeObject_DefaultGetItemIndexWithTryGetItem || \ (tp_getitem_index) == &DeeObject_DefaultGetItemIndexWithErrorRequiresString || \ (tp_getitem_index) == &DeeObject_DefaultGetItemIndexWithGetItemDefault || \ - (tp_getitem_index) == &DeeSeq_DefaultGetItemIndexWithTryGetItemIndexAndSize || \ - (tp_getitem_index) == &DeeSeq_DefaultGetItemIndexWithTryGetItemIndexAndSizeOb || \ + (tp_getitem_index) == &DeeSeq_DefaultGetItemIndexWithSizeAndTryGetItemIndex || \ + (tp_getitem_index) == &DeeSeq_DefaultGetItemIndexWithSizeAndTryGetItemIndexOb || \ (tp_getitem_index) == &DeeSeq_DefaultGetItemIndexWithTryGetItemAndSize || \ (tp_getitem_index) == &DeeSeq_DefaultGetItemIndexWithTryGetItemAndSizeOb || \ (tp_getitem_index) == &DeeSeq_DefaultGetItemIndexWithForeachDefault || \ @@ -3253,7 +3534,7 @@ INTDEF WUNUSED NONNULL((1, 2, 4)) int DCALL DeeSeq_TDefaultSetRangeIndexNWithSiz (tp_bounditem) == &DeeObject_DefaultBoundItemWithTryGetItemStringLenHashAndHasItemStringLenHash || \ (tp_bounditem) == &DeeObject_DefaultBoundItemWithTryGetItemStringHashAndHasItemStringHash || \ (tp_bounditem) == &DeeSeq_DefaultBoundItemWithTryGetItemAndSizeOb || \ - (tp_bounditem) == &DeeSeq_DefaultBoundItemWithTryGetItemIndexAndSize || \ + (tp_bounditem) == &DeeSeq_DefaultBoundItemWithSizeAndTryGetItemIndex || \ (tp_bounditem) == &DeeObject_DefaultBoundItemWithTryGetItem || \ (tp_bounditem) == &DeeObject_DefaultBoundItemWithTryGetItemIndex || \ (tp_bounditem) == &DeeObject_DefaultBoundItemWithTryGetItemStringLenHash || \ @@ -3270,7 +3551,7 @@ INTDEF WUNUSED NONNULL((1, 2, 4)) int DCALL DeeSeq_TDefaultSetRangeIndexNWithSiz (tp_bounditem_index) == &DeeObject_DefaultBoundItemIndexWithGetItemIndexDefault || \ (tp_bounditem_index) == &DeeObject_DefaultBoundItemIndexWithTryGetItemIndexAndHasItemIndex || \ (tp_bounditem_index) == &DeeObject_DefaultBoundItemIndexWithTryGetItemAndHasItem || \ - (tp_bounditem_index) == &DeeSeq_DefaultBoundItemIndexWithTryGetItemIndexAndSize || \ + (tp_bounditem_index) == &DeeSeq_DefaultBoundItemIndexWithSizeAndTryGetItemIndex || \ (tp_bounditem_index) == &DeeSeq_DefaultBoundItemIndexWithTryGetItemAndSizeOb || \ (tp_bounditem_index) == &DeeObject_DefaultBoundItemIndexWithErrorRequiresString || \ (tp_bounditem_index) == &DeeMap_DefaultBoundItemIndexWithContains || \ @@ -3559,29 +3840,93 @@ INTDEF WUNUSED NONNULL((1, 2, 4)) int DCALL DeeSeq_TDefaultSetRangeIndexNWithSiz (tp_dec) == &DeeObject_DefaultDecWithInplaceSub ? DeeObject_TDefaultDecWithInplaceSub(tp_self, p_self) : \ (tp_dec) == &DeeObject_DefaultDecWithSub ? DeeObject_TDefaultDecWithSub(tp_self, p_self) : \ default) +#define DeeType_invoke_cmp_tp_hash_DEFAULT(tp_self, tp_hash, self, default) \ + ((tp_hash) == &DeeSeq_DefaultHashWithSizeAndGetItemIndexFast ? DeeSeq_TDefaultHashWithSizeAndGetItemIndexFast(tp_self, self) : \ + (tp_hash) == &DeeSeq_DefaultHashWithForeach ? DeeSeq_TDefaultHashWithForeach(tp_self, self) : \ + (tp_hash) == &DeeSeq_DefaultHashWithSizeAndTryGetItemIndex ? DeeSeq_TDefaultHashWithSizeAndTryGetItemIndex(tp_self, self) : \ + (tp_hash) == &DeeSeq_DefaultHashWithSizeAndGetItemIndex ? DeeSeq_TDefaultHashWithSizeAndGetItemIndex(tp_self, self) : \ + (tp_hash) == &DeeSeq_DefaultHashWithSizeObAndGetItem ? DeeSeq_TDefaultHashWithSizeObAndGetItem(tp_self, self) : \ + (tp_hash) == &DeeSeq_DefaultHashWithForeachDefault ? DeeSeq_TDefaultHashWithForeachDefault(tp_self, self) : \ + (tp_hash) == &DeeSet_DefaultHashWithForeachDefault ? DeeSet_TDefaultHashWithForeachDefault(tp_self, self) : \ + (tp_hash) == &DeeMap_DefaultHashWithForeachPairDefault ? DeeMap_TDefaultHashWithForeachPairDefault(tp_self, self) : \ + default) #define DeeType_invoke_cmp_tp_eq_DEFAULT(tp_self, tp_eq, self, other, default) \ - ((tp_eq) == &DeeObject_DefaultEqWithNe ? DeeObject_TDefaultEqWithNe(tp_self, self, other) : \ + ((tp_eq) == &DeeObject_DefaultEqWithCompareEq ? DeeObject_TDefaultEqWithCompareEq(tp_self, self, other) : \ + (tp_eq) == &DeeObject_DefaultEqWithNe ? DeeObject_TDefaultEqWithNe(tp_self, self, other) : \ + (tp_eq) == &DeeObject_DefaultEqWithLoAndGr ? DeeObject_TDefaultEqWithLoAndGr(tp_self, self, other) : \ + (tp_eq) == &DeeObject_DefaultEqWithLeAndGe ? DeeObject_TDefaultEqWithLeAndGe(tp_self, self, other) : \ + (tp_eq) == &DeeObject_DefaultEqWithCompareEqDefault ? DeeObject_TDefaultEqWithCompareEqDefault(tp_self, self, other) : \ default) #define DeeType_invoke_cmp_tp_ne_DEFAULT(tp_self, tp_ne, self, other, default) \ - ((tp_ne) == &DeeObject_DefaultNeWithEq ? DeeObject_TDefaultNeWithEq(tp_self, self, other) : \ + ((tp_ne) == &DeeObject_DefaultNeWithCompareEq ? DeeObject_TDefaultNeWithCompareEq(tp_self, self, other) : \ + (tp_ne) == &DeeObject_DefaultNeWithEq ? DeeObject_TDefaultNeWithEq(tp_self, self, other) : \ + (tp_ne) == &DeeObject_DefaultNeWithLoAndGr ? DeeObject_TDefaultNeWithLoAndGr(tp_self, self, other) : \ + (tp_ne) == &DeeObject_DefaultNeWithLeAndGe ? DeeObject_TDefaultNeWithLeAndGe(tp_self, self, other) : \ + (tp_ne) == &DeeObject_DefaultNeWithCompareEqDefault ? DeeObject_TDefaultNeWithCompareEqDefault(tp_self, self, other) : \ default) #define DeeType_invoke_cmp_tp_lo_DEFAULT(tp_self, tp_lo, self, other, default) \ - ((tp_lo) == &DeeObject_DefaultLoWithGe ? DeeObject_TDefaultLoWithGe(tp_self, self, other) : \ + ((tp_lo) == &DeeObject_DefaultLoWithCompare ? DeeObject_TDefaultLoWithCompare(tp_self, self, other) : \ + (tp_lo) == &DeeObject_DefaultLoWithGe ? DeeObject_TDefaultLoWithGe(tp_self, self, other) : \ + (tp_lo) == &DeeObject_DefaultLoWithCompareDefault ? DeeObject_TDefaultLoWithCompareDefault(tp_self, self, other) : \ + (tp_lo) == &DeeSet_DefaultLoWithForeachDefault ? DeeSet_TDefaultLoWithForeachDefault(tp_self, self, other) : \ + (tp_lo) == &DeeMap_DefaultLoWithForeachPairDefault ? DeeMap_TDefaultLoWithForeachPairDefault(tp_self, self, other) : \ default) #define DeeType_invoke_cmp_tp_le_DEFAULT(tp_self, tp_le, self, other, default) \ - ((tp_le) == &DeeObject_DefaultLeWithGr ? DeeObject_TDefaultLeWithGr(tp_self, self, other) : \ + ((tp_le) == &DeeObject_DefaultLeWithCompare ? DeeObject_TDefaultLeWithCompare(tp_self, self, other) : \ + (tp_le) == &DeeObject_DefaultLeWithGr ? DeeObject_TDefaultLeWithGr(tp_self, self, other) : \ + (tp_le) == &DeeObject_DefaultLeWithCompareDefault ? DeeObject_TDefaultLeWithCompareDefault(tp_self, self, other) : \ + (tp_le) == &DeeSet_DefaultLeWithForeachDefault ? DeeSet_TDefaultLeWithForeachDefault(tp_self, self, other) : \ + (tp_le) == &DeeMap_DefaultLeWithForeachPairDefault ? DeeMap_TDefaultLeWithForeachPairDefault(tp_self, self, other) : \ default) #define DeeType_invoke_cmp_tp_gr_DEFAULT(tp_self, tp_gr, self, other, default) \ - ((tp_gr) == &DeeObject_DefaultGrWithLe ? DeeObject_TDefaultGrWithLe(tp_self, self, other) : \ + ((tp_gr) == &DeeObject_DefaultGrWithCompare ? DeeObject_TDefaultGrWithCompare(tp_self, self, other) : \ + (tp_gr) == &DeeObject_DefaultGrWithLe ? DeeObject_TDefaultGrWithLe(tp_self, self, other) : \ + (tp_gr) == &DeeObject_DefaultGrWithCompareDefault ? DeeObject_TDefaultGrWithCompareDefault(tp_self, self, other) : \ + (tp_gr) == &DeeSet_DefaultGrWithForeachDefault ? DeeSet_TDefaultGrWithForeachDefault(tp_self, self, other) : \ + (tp_gr) == &DeeMap_DefaultGrWithForeachPairDefault ? DeeMap_TDefaultGrWithForeachPairDefault(tp_self, self, other) : \ default) #define DeeType_invoke_cmp_tp_ge_DEFAULT(tp_self, tp_ge, self, other, default) \ - ((tp_ge) == &DeeObject_DefaultGeWithLo ? DeeObject_TDefaultGeWithLo(tp_self, self, other) : \ + ((tp_ge) == &DeeObject_DefaultGeWithCompare ? DeeObject_TDefaultGeWithCompare(tp_self, self, other) : \ + (tp_ge) == &DeeObject_DefaultGeWithLo ? DeeObject_TDefaultGeWithLo(tp_self, self, other) : \ + (tp_ge) == &DeeObject_DefaultGeWithCompareDefault ? DeeObject_TDefaultGeWithCompareDefault(tp_self, self, other) : \ + (tp_ge) == &DeeSet_DefaultGeWithForeachDefault ? DeeSet_TDefaultGeWithForeachDefault(tp_self, self, other) : \ + (tp_ge) == &DeeMap_DefaultGeWithForeachPairDefault ? DeeMap_TDefaultGeWithForeachPairDefault(tp_self, self, other) : \ + default) +#define DeeType_invoke_cmp_tp_compare_eq_DEFAULT(tp_self, tp_compare_eq, self, other, default) \ + ((tp_compare_eq) == &DeeObject_DefaultCompareEqWithEq ? DeeObject_TDefaultCompareEqWithEq(tp_self, self, other) : \ + (tp_compare_eq) == &DeeObject_DefaultCompareEqWithNe ? DeeObject_TDefaultCompareEqWithNe(tp_self, self, other) : \ + (tp_compare_eq) == &DeeObject_DefaultCompareEqWithLoAndGr ? DeeObject_TDefaultCompareEqWithLoAndGr(tp_self, self, other) : \ + (tp_compare_eq) == &DeeObject_DefaultCompareEqWithLeAndGe ? DeeObject_TDefaultCompareEqWithLeAndGe(tp_self, self, other) : \ + (tp_compare_eq) == &DeeSeq_DefaultCompareEqWithForeachDefault ? DeeSeq_TDefaultCompareEqWithForeachDefault(tp_self, self, other) : \ + (tp_compare_eq) == &DeeSeq_DefaultCompareEqWithSizeAndGetItemIndexFast ? DeeSeq_TDefaultCompareEqWithSizeAndGetItemIndexFast(tp_self, self, other) : \ + (tp_compare_eq) == &DeeSeq_DefaultCompareEqWithSizeAndTryGetItemIndex ? DeeSeq_TDefaultCompareEqWithSizeAndTryGetItemIndex(tp_self, self, other) : \ + (tp_compare_eq) == &DeeSeq_DefaultCompareEqWithSizeAndGetItemIndex ? DeeSeq_TDefaultCompareEqWithSizeAndGetItemIndex(tp_self, self, other) : \ + (tp_compare_eq) == &DeeSeq_DefaultCompareEqWithSizeObAndGetItem ? DeeSeq_TDefaultCompareEqWithSizeObAndGetItem(tp_self, self, other) : \ + (tp_compare_eq) == &DeeSet_DefaultCompareEqWithForeachDefault ? DeeSet_TDefaultCompareEqWithForeachDefault(tp_self, self, other) : \ + (tp_compare_eq) == &DeeMap_DefaultCompareEqWithForeachPairDefault ? DeeMap_TDefaultCompareEqWithForeachPairDefault(tp_self, self, other) : \ + default) +#define DeeType_invoke_cmp_tp_compare_DEFAULT(tp_self, tp_compare, self, other, default) \ + ((tp_compare) == &DeeObject_DefaultCompareWithEqAndLo ? DeeObject_TDefaultCompareWithEqAndLo(tp_self, self, other) : \ + (tp_compare) == &DeeObject_DefaultCompareWithEqAndLe ? DeeObject_TDefaultCompareWithEqAndLe(tp_self, self, other) : \ + (tp_compare) == &DeeObject_DefaultCompareWithEqAndGr ? DeeObject_TDefaultCompareWithEqAndGr(tp_self, self, other) : \ + (tp_compare) == &DeeObject_DefaultCompareWithEqAndGe ? DeeObject_TDefaultCompareWithEqAndGe(tp_self, self, other) : \ + (tp_compare) == &DeeObject_DefaultCompareWithNeAndLo ? DeeObject_TDefaultCompareWithNeAndLo(tp_self, self, other) : \ + (tp_compare) == &DeeObject_DefaultCompareWithNeAndLe ? DeeObject_TDefaultCompareWithNeAndLe(tp_self, self, other) : \ + (tp_compare) == &DeeObject_DefaultCompareWithNeAndGr ? DeeObject_TDefaultCompareWithNeAndGr(tp_self, self, other) : \ + (tp_compare) == &DeeObject_DefaultCompareWithNeAndGe ? DeeObject_TDefaultCompareWithNeAndGe(tp_self, self, other) : \ + (tp_compare) == &DeeObject_DefaultCompareWithLoAndGr ? DeeObject_TDefaultCompareWithLoAndGr(tp_self, self, other) : \ + (tp_compare) == &DeeObject_DefaultCompareWithLeAndGe ? DeeObject_TDefaultCompareWithLeAndGe(tp_self, self, other) : \ + (tp_compare) == &DeeSeq_DefaultCompareWithSizeAndGetItemIndexFast ? DeeSeq_TDefaultCompareWithSizeAndGetItemIndexFast(tp_self, self, other) : \ + (tp_compare) == &DeeSeq_DefaultCompareWithSizeAndTryGetItemIndex ? DeeSeq_TDefaultCompareWithSizeAndTryGetItemIndex(tp_self, self, other) : \ + (tp_compare) == &DeeSeq_DefaultCompareWithSizeAndGetItemIndex ? DeeSeq_TDefaultCompareWithSizeAndGetItemIndex(tp_self, self, other) : \ + (tp_compare) == &DeeSeq_DefaultCompareWithSizeObAndGetItem ? DeeSeq_TDefaultCompareWithSizeObAndGetItem(tp_self, self, other) : \ + (tp_compare) == &DeeSeq_DefaultCompareWithForeachDefault ? DeeSeq_TDefaultCompareWithForeachDefault(tp_self, self, other) : \ default) #define DeeType_invoke_seq_tp_iter_DEFAULT(tp_self, tp_iter, self, default) \ ((tp_iter) == &DeeObject_DefaultIterWithForeach ? DeeObject_TDefaultIterWithForeach(tp_self, self) : \ (tp_iter) == &DeeObject_DefaultIterWithForeachPair ? DeeObject_TDefaultIterWithForeachPair(tp_self, self) : \ (tp_iter) == &DeeSeq_DefaultIterWithSizeAndGetItemIndexFast ? DeeSeq_TDefaultIterWithSizeAndGetItemIndexFast(tp_self, self) : \ - (tp_iter) == &DeeSeq_DefaultIterWithTryGetItemIndexAndSize ? DeeSeq_TDefaultIterWithTryGetItemIndexAndSize(tp_self, self) : \ + (tp_iter) == &DeeSeq_DefaultIterWithSizeAndTryGetItemIndex ? DeeSeq_TDefaultIterWithSizeAndTryGetItemIndex(tp_self, self) : \ (tp_iter) == &DeeSeq_DefaultIterWithSizeAndGetItemIndex ? DeeSeq_TDefaultIterWithSizeAndGetItemIndex(tp_self, self) : \ (tp_iter) == &DeeSeq_DefaultIterWithGetItemIndex ? DeeSeq_TDefaultIterWithGetItemIndex(tp_self, self) : \ (tp_iter) == &DeeSeq_DefaultIterWithSizeObAndGetItem ? DeeSeq_TDefaultIterWithSizeObAndGetItem(tp_self, self) : \ @@ -3591,8 +3936,9 @@ INTDEF WUNUSED NONNULL((1, 2, 4)) int DCALL DeeSeq_TDefaultSetRangeIndexNWithSiz ((tp_foreach) == &DeeObject_DefaultForeachWithIter ? DeeObject_TDefaultForeachWithIter(tp_self, self, proc, arg) : \ (tp_foreach) == &DeeObject_DefaultForeachWithForeachPair ? DeeObject_TDefaultForeachWithForeachPair(tp_self, self, proc, arg) : \ (tp_foreach) == &DeeSeq_DefaultForeachWithSizeAndGetItemIndexFast ? DeeSeq_TDefaultForeachWithSizeAndGetItemIndexFast(tp_self, self, proc, arg) : \ - (tp_foreach) == &DeeSeq_DefaultForeachWithTryGetItemIndexAndSize ? DeeSeq_TDefaultForeachWithTryGetItemIndexAndSize(tp_self, self, proc, arg) : \ + (tp_foreach) == &DeeSeq_DefaultForeachWithSizeAndTryGetItemIndex ? DeeSeq_TDefaultForeachWithSizeAndTryGetItemIndex(tp_self, self, proc, arg) : \ (tp_foreach) == &DeeSeq_DefaultForeachWithSizeAndGetItemIndex ? DeeSeq_TDefaultForeachWithSizeAndGetItemIndex(tp_self, self, proc, arg) : \ + (tp_foreach) == &DeeSeq_DefaultForeachWithSizeObAndGetItem ? DeeSeq_TDefaultForeachWithSizeObAndGetItem(tp_self, self, proc, arg) : \ (tp_foreach) == &DeeSeq_DefaultForeachWithSizeDefaultAndGetItemIndexDefault ? DeeSeq_TDefaultForeachWithSizeDefaultAndGetItemIndexDefault(tp_self, self, proc, arg) : \ (tp_foreach) == &DeeSeq_DefaultForeachWithGetItemIndexDefault ? DeeSeq_TDefaultForeachWithGetItemIndexDefault(tp_self, self, proc, arg) : \ default) @@ -3644,8 +3990,8 @@ INTDEF WUNUSED NONNULL((1, 2, 4)) int DCALL DeeSeq_TDefaultSetRangeIndexNWithSiz (tp_getitem) == &DeeObject_DefaultGetItemWithTryGetItemStringLenHash ? DeeObject_TDefaultGetItemWithTryGetItemStringLenHash(tp_self, self, index) : \ (tp_getitem) == &DeeSeq_DefaultGetItemWithTryGetItemAndSizeOb ? DeeSeq_TDefaultGetItemWithTryGetItemAndSizeOb(tp_self, self, index) : \ (tp_getitem) == &DeeSeq_DefaultGetItemWithTryGetItemAndSize ? DeeSeq_TDefaultGetItemWithTryGetItemAndSize(tp_self, self, index) : \ - (tp_getitem) == &DeeSeq_DefaultGetItemWithTryGetItemIndexAndSizeOb ? DeeSeq_TDefaultGetItemWithTryGetItemIndexAndSizeOb(tp_self, self, index) : \ - (tp_getitem) == &DeeSeq_DefaultGetItemWithTryGetItemIndexAndSize ? DeeSeq_TDefaultGetItemWithTryGetItemIndexAndSize(tp_self, self, index) : \ + (tp_getitem) == &DeeSeq_DefaultGetItemWithSizeAndTryGetItemIndexOb ? DeeSeq_TDefaultGetItemWithSizeAndTryGetItemIndexOb(tp_self, self, index) : \ + (tp_getitem) == &DeeSeq_DefaultGetItemWithSizeAndTryGetItemIndex ? DeeSeq_TDefaultGetItemWithSizeAndTryGetItemIndex(tp_self, self, index) : \ (tp_getitem) == &DeeMap_DefaultGetItemWithForeachPair ? DeeMap_TDefaultGetItemWithForeachPair(tp_self, self, index) : \ (tp_getitem) == &DeeMap_DefaultGetItemWithForeachPairDefault ? DeeMap_TDefaultGetItemWithForeachPairDefault(tp_self, self, index) : \ default) @@ -3655,8 +4001,8 @@ INTDEF WUNUSED NONNULL((1, 2, 4)) int DCALL DeeSeq_TDefaultSetRangeIndexNWithSiz (tp_getitem_index) == &DeeObject_DefaultGetItemIndexWithGetItem ? DeeObject_TDefaultGetItemIndexWithGetItem(tp_self, self, index) : \ (tp_getitem_index) == &DeeObject_DefaultGetItemIndexWithTryGetItem ? DeeObject_TDefaultGetItemIndexWithTryGetItem(tp_self, self, index) : \ (tp_getitem_index) == &DeeObject_DefaultGetItemIndexWithGetItemDefault ? DeeObject_TDefaultGetItemIndexWithGetItemDefault(tp_self, self, index) : \ - (tp_getitem_index) == &DeeSeq_DefaultGetItemIndexWithTryGetItemIndexAndSize ? DeeSeq_TDefaultGetItemIndexWithTryGetItemIndexAndSize(tp_self, self, index) : \ - (tp_getitem_index) == &DeeSeq_DefaultGetItemIndexWithTryGetItemIndexAndSizeOb ? DeeSeq_TDefaultGetItemIndexWithTryGetItemIndexAndSizeOb(tp_self, self, index) : \ + (tp_getitem_index) == &DeeSeq_DefaultGetItemIndexWithSizeAndTryGetItemIndex ? DeeSeq_TDefaultGetItemIndexWithSizeAndTryGetItemIndex(tp_self, self, index) : \ + (tp_getitem_index) == &DeeSeq_DefaultGetItemIndexWithSizeAndTryGetItemIndexOb ? DeeSeq_TDefaultGetItemIndexWithSizeAndTryGetItemIndexOb(tp_self, self, index) : \ (tp_getitem_index) == &DeeSeq_DefaultGetItemIndexWithTryGetItemAndSize ? DeeSeq_TDefaultGetItemIndexWithTryGetItemAndSize(tp_self, self, index) : \ (tp_getitem_index) == &DeeSeq_DefaultGetItemIndexWithTryGetItemAndSizeOb ? DeeSeq_TDefaultGetItemIndexWithTryGetItemAndSizeOb(tp_self, self, index) : \ (tp_getitem_index) == &DeeSeq_DefaultGetItemIndexWithForeachDefault ? DeeSeq_TDefaultGetItemIndexWithForeachDefault(tp_self, self, index) : \ @@ -3774,7 +4120,7 @@ INTDEF WUNUSED NONNULL((1, 2, 4)) int DCALL DeeSeq_TDefaultSetRangeIndexNWithSiz (tp_bounditem) == &DeeObject_DefaultBoundItemWithTryGetItemStringLenHashAndHasItemStringLenHash ? DeeObject_TDefaultBoundItemWithTryGetItemStringLenHashAndHasItemStringLenHash(tp_self, self, index) : \ (tp_bounditem) == &DeeObject_DefaultBoundItemWithTryGetItemStringHashAndHasItemStringHash ? DeeObject_TDefaultBoundItemWithTryGetItemStringHashAndHasItemStringHash(tp_self, self, index) : \ (tp_bounditem) == &DeeSeq_DefaultBoundItemWithTryGetItemAndSizeOb ? DeeSeq_TDefaultBoundItemWithTryGetItemAndSizeOb(tp_self, self, index) : \ - (tp_bounditem) == &DeeSeq_DefaultBoundItemWithTryGetItemIndexAndSize ? DeeSeq_TDefaultBoundItemWithTryGetItemIndexAndSize(tp_self, self, index) : \ + (tp_bounditem) == &DeeSeq_DefaultBoundItemWithSizeAndTryGetItemIndex ? DeeSeq_TDefaultBoundItemWithSizeAndTryGetItemIndex(tp_self, self, index) : \ (tp_bounditem) == &DeeObject_DefaultBoundItemWithTryGetItem ? DeeObject_TDefaultBoundItemWithTryGetItem(tp_self, self, index) : \ (tp_bounditem) == &DeeObject_DefaultBoundItemWithTryGetItemIndex ? DeeObject_TDefaultBoundItemWithTryGetItemIndex(tp_self, self, index) : \ (tp_bounditem) == &DeeObject_DefaultBoundItemWithTryGetItemStringLenHash ? DeeObject_TDefaultBoundItemWithTryGetItemStringLenHash(tp_self, self, index) : \ @@ -3792,7 +4138,7 @@ INTDEF WUNUSED NONNULL((1, 2, 4)) int DCALL DeeSeq_TDefaultSetRangeIndexNWithSiz (tp_bounditem_index) == &DeeObject_DefaultBoundItemIndexWithGetItemIndexDefault ? DeeObject_TDefaultBoundItemIndexWithGetItemIndexDefault(tp_self, self, index) : \ (tp_bounditem_index) == &DeeObject_DefaultBoundItemIndexWithTryGetItemIndexAndHasItemIndex ? DeeObject_TDefaultBoundItemIndexWithTryGetItemIndexAndHasItemIndex(tp_self, self, index) : \ (tp_bounditem_index) == &DeeObject_DefaultBoundItemIndexWithTryGetItemAndHasItem ? DeeObject_TDefaultBoundItemIndexWithTryGetItemAndHasItem(tp_self, self, index) : \ - (tp_bounditem_index) == &DeeSeq_DefaultBoundItemIndexWithTryGetItemIndexAndSize ? DeeSeq_TDefaultBoundItemIndexWithTryGetItemIndexAndSize(tp_self, self, index) : \ + (tp_bounditem_index) == &DeeSeq_DefaultBoundItemIndexWithSizeAndTryGetItemIndex ? DeeSeq_TDefaultBoundItemIndexWithSizeAndTryGetItemIndex(tp_self, self, index) : \ (tp_bounditem_index) == &DeeSeq_DefaultBoundItemIndexWithTryGetItemAndSizeOb ? DeeSeq_TDefaultBoundItemIndexWithTryGetItemAndSizeOb(tp_self, self, index) : \ (tp_bounditem_index) == &DeeMap_DefaultBoundItemIndexWithContains ? DeeMap_TDefaultBoundItemIndexWithContains(tp_self, self, index) : \ (tp_bounditem_index) == &DeeMap_DefaultBoundItemIndexWithForeachPair ? DeeMap_TDefaultBoundItemIndexWithForeachPair(tp_self, self, index) : \ @@ -4035,6 +4381,8 @@ INTDEF WUNUSED NONNULL((1, 2, 4)) int DCALL DeeSeq_TDefaultSetRangeIndexNWithSiz DeeType_invoke_math_tp_inc_DEFAULT(tp_self, tp_inc, p_self, DeeType_invoke_math_tp_inc_NODEFAULT(tp_self, tp_inc, p_self)) #define DeeType_invoke_math_tp_dec(tp_self, tp_dec, p_self) \ DeeType_invoke_math_tp_dec_DEFAULT(tp_self, tp_dec, p_self, DeeType_invoke_math_tp_dec_NODEFAULT(tp_self, tp_dec, p_self)) +#define DeeType_invoke_cmp_tp_hash(tp_self, tp_hash, self) \ + DeeType_invoke_cmp_tp_hash_DEFAULT(tp_self, tp_hash, self, DeeType_invoke_cmp_tp_hash_NODEFAULT(tp_self, tp_hash, self)) #define DeeType_invoke_cmp_tp_eq(tp_self, tp_eq, self, other) \ DeeType_invoke_cmp_tp_eq_DEFAULT(tp_self, tp_eq, self, other, DeeType_invoke_cmp_tp_eq_NODEFAULT(tp_self, tp_eq, self, other)) #define DeeType_invoke_cmp_tp_ne(tp_self, tp_ne, self, other) \ @@ -4047,6 +4395,10 @@ INTDEF WUNUSED NONNULL((1, 2, 4)) int DCALL DeeSeq_TDefaultSetRangeIndexNWithSiz DeeType_invoke_cmp_tp_gr_DEFAULT(tp_self, tp_gr, self, other, DeeType_invoke_cmp_tp_gr_NODEFAULT(tp_self, tp_gr, self, other)) #define DeeType_invoke_cmp_tp_ge(tp_self, tp_ge, self, other) \ DeeType_invoke_cmp_tp_ge_DEFAULT(tp_self, tp_ge, self, other, DeeType_invoke_cmp_tp_ge_NODEFAULT(tp_self, tp_ge, self, other)) +#define DeeType_invoke_cmp_tp_compare_eq(tp_self, tp_compare_eq, self, other) \ + DeeType_invoke_cmp_tp_compare_eq_DEFAULT(tp_self, tp_compare_eq, self, other, DeeType_invoke_cmp_tp_compare_eq_NODEFAULT(tp_self, tp_compare_eq, self, other)) +#define DeeType_invoke_cmp_tp_compare(tp_self, tp_compare, self, other) \ + DeeType_invoke_cmp_tp_compare_DEFAULT(tp_self, tp_compare, self, other, DeeType_invoke_cmp_tp_compare_NODEFAULT(tp_self, tp_compare, self, other)) #define DeeType_invoke_seq_tp_iter(tp_self, tp_iter, self) \ DeeType_invoke_seq_tp_iter_DEFAULT(tp_self, tp_iter, self, DeeType_invoke_seq_tp_iter_NODEFAULT(tp_self, tp_iter, self)) #define DeeType_invoke_seq_tp_foreach(tp_self, tp_foreach, self, proc, arg) \ @@ -4152,9 +4504,6 @@ INTDEF WUNUSED NONNULL((1, 2, 4)) int DCALL DeeSeq_TDefaultSetRangeIndexNWithSiz #define DeeType_invoke_math_tp_neg_DEFAULT(tp_self, tp_neg, self, default) default #define DeeType_invoke_math_tp_neg(tp_self, tp_neg, self) \ DeeType_invoke_math_tp_neg_DEFAULT(tp_self, tp_neg, self, DeeType_invoke_math_tp_neg_NODEFAULT(tp_self, tp_neg, self)) -#define DeeType_invoke_cmp_tp_hash_DEFAULT(tp_self, tp_hash, self, default) default -#define DeeType_invoke_cmp_tp_hash(tp_self, tp_hash, self) \ - DeeType_invoke_cmp_tp_hash_DEFAULT(tp_self, tp_hash, self, DeeType_invoke_cmp_tp_hash_NODEFAULT(tp_self, tp_hash, self)) #define DeeType_invoke_attr_tp_getattr_DEFAULT(tp_self, tp_getattr, self, name, default) default #define DeeType_invoke_attr_tp_getattr(tp_self, tp_getattr, self, name) \ DeeType_invoke_attr_tp_getattr_DEFAULT(tp_self, tp_getattr, self, name, DeeType_invoke_attr_tp_getattr_NODEFAULT(tp_self, tp_getattr, self, name)) @@ -4267,6 +4616,10 @@ INTDEF WUNUSED NONNULL((1, 2, 4)) int DCALL DeeSeq_TDefaultSetRangeIndexNWithSiz #define DeeType_InvokeCmpGr_NODEFAULT(tp_self, self, other) DeeType_invoke_cmp_tp_gr_NODEFAULT(tp_self, (tp_self)->tp_cmp->tp_gr, self, other) #define DeeType_InvokeCmpGe(tp_self, self, other) DeeType_invoke_cmp_tp_ge(tp_self, (tp_self)->tp_cmp->tp_ge, self, other) #define DeeType_InvokeCmpGe_NODEFAULT(tp_self, self, other) DeeType_invoke_cmp_tp_ge_NODEFAULT(tp_self, (tp_self)->tp_cmp->tp_ge, self, other) +#define DeeType_InvokeCmpCompareEq(tp_self, self, other) DeeType_invoke_cmp_tp_compare_eq(tp_self, (tp_self)->tp_cmp->tp_compare_eq, self, other) +#define DeeType_InvokeCmpCompareEq_NODEFAULT(tp_self, self, other) DeeType_invoke_cmp_tp_compare_eq_NODEFAULT(tp_self, (tp_self)->tp_cmp->tp_compare_eq, self, other) +#define DeeType_InvokeCmpCompare(tp_self, self, other) DeeType_invoke_cmp_tp_compare(tp_self, (tp_self)->tp_cmp->tp_compare, self, other) +#define DeeType_InvokeCmpCompare_NODEFAULT(tp_self, self, other) DeeType_invoke_cmp_tp_compare_NODEFAULT(tp_self, (tp_self)->tp_cmp->tp_compare, self, other) #define DeeType_InvokeSeqIter(tp_self, self) DeeType_invoke_seq_tp_iter(tp_self, (tp_self)->tp_seq->tp_iter, self) #define DeeType_InvokeSeqIter_NODEFAULT(tp_self, self) DeeType_invoke_seq_tp_iter_NODEFAULT(tp_self, (tp_self)->tp_seq->tp_iter, self) #define DeeType_InvokeSeqSizeOb(tp_self, self) DeeType_invoke_seq_tp_sizeob(tp_self, (tp_self)->tp_seq->tp_sizeob, self) diff --git a/include/deemon/object.h b/include/deemon/object.h index c86bbd522..5b5410217 100644 --- a/include/deemon/object.h +++ b/include/deemon/object.h @@ -1905,6 +1905,13 @@ struct Dee_type_cmp { * them to be ordered with other operators. */ struct Dee_type_nii Dee_tpconst *tp_nii; /* TODO: Deprecated */ + /* Same as "tp_compare", but only needs to support equal/not-equal compare: + * @return: Dee_COMPARE_ERR: An error occurred. + * @return: -1: `lhs != rhs' + * @return: 0: `lhs == rhs' + * @return: 1: `lhs != rhs' */ + WUNUSED_T NONNULL_T((1, 2)) int (DCALL *tp_compare_eq)(DeeObject *self, DeeObject *some_object); + /* Rich-compare operator that can be defined instead * of `tp_eq', `tp_ne', `tp_lo', `tp_le', `tp_gr', `tp_ge' * @return: Dee_COMPARE_ERR: An error occurred. @@ -1912,12 +1919,6 @@ struct Dee_type_cmp { * @return: 0: `lhs == rhs' * @return: 1: `lhs > rhs' */ WUNUSED_T NONNULL_T((1, 2)) int (DCALL *tp_compare)(DeeObject *self, DeeObject *some_object); - /* Same as "tp_compare", but only needs to support equal/not-equal compare: - * @return: Dee_COMPARE_ERR: An error occurred. - * @return: -1: `lhs != rhs' - * @return: 0: `lhs == rhs' - * @return: 1: `lhs != rhs' */ - WUNUSED_T NONNULL_T((1, 2)) int (DCALL *tp_compare_eq)(DeeObject *self, DeeObject *some_object); }; typedef WUNUSED_T NONNULL_T((2)) Dee_ssize_t (DCALL *Dee_foreach_t)(void *arg, DeeObject *elem); @@ -3898,8 +3899,7 @@ INTDEF NONNULL((1)) bool DCALL DeeType_InheritAnd(DeeTypeObject *__restrict self INTDEF NONNULL((1)) bool DCALL DeeType_InheritOr(DeeTypeObject *__restrict self); /* tp_or, tp_inplace_or */ INTDEF NONNULL((1)) bool DCALL DeeType_InheritXor(DeeTypeObject *__restrict self); /* tp_xor, tp_inplace_xor */ INTDEF NONNULL((1)) bool DCALL DeeType_InheritPow(DeeTypeObject *__restrict self); /* tp_pow, tp_inplace_pow */ -INTDEF NONNULL((1)) bool DCALL DeeType_InheritHash(DeeTypeObject *__restrict self); /* tp_hash, tp_eq, tp_ne (in order to inherit "tp_hash", must also inherit "tp_eq" and "tp_ne") */ -INTDEF NONNULL((1)) bool DCALL DeeType_InheritCompare(DeeTypeObject *__restrict self); /* tp_eq, tp_ne, tp_lo, tp_le, tp_gr, tp_ge */ +INTDEF NONNULL((1)) bool DCALL DeeType_InheritCompare(DeeTypeObject *__restrict self); /* tp_hash, tp_eq, tp_ne, tp_lo, tp_le, tp_gr, tp_ge, tp_compare_eq, tp_compare */ INTDEF NONNULL((1)) bool DCALL DeeType_InheritIterNext(DeeTypeObject *__restrict self); /* tp_iter_next */ INTDEF NONNULL((1)) bool DCALL DeeType_InheritIter(DeeTypeObject *__restrict self); /* tp_iter, tp_foreach, tp_foreach_pair */ INTDEF NONNULL((1)) bool DCALL DeeType_InheritSize(DeeTypeObject *__restrict self); /* tp_sizeob, tp_size */ @@ -3934,7 +3934,6 @@ INTDEF NONNULL((1)) bool DCALL DeeType_InheritBuffer(DeeTypeObject *__restrict s #define DeeType_InheritOr(self) DeeType_InheritOperator(self, OPERATOR_OR) #define DeeType_InheritXor(self) DeeType_InheritOperator(self, OPERATOR_XOR) #define DeeType_InheritPow(self) DeeType_InheritOperator(self, OPERATOR_POW) -#define DeeType_InheritHash(self) DeeType_InheritOperator(self, OPERATOR_HASH) #define DeeType_InheritCompare(self) DeeType_InheritOperator(self, OPERATOR_EQ) #define DeeType_InheritIterNext(self) DeeType_InheritOperator(self, OPERATOR_ITERNEXT) #define DeeType_InheritIter(self) DeeType_InheritOperator(self, OPERATOR_ITER) @@ -4473,18 +4472,25 @@ DFUNDEF WUNUSED NONNULL((1, 2)) int (DCALL DeeObject_CompareLe)(DeeObject *self, DFUNDEF WUNUSED NONNULL((1, 2)) int (DCALL DeeObject_CompareGr)(DeeObject *self, DeeObject *some_object); DFUNDEF WUNUSED NONNULL((1, 2)) int (DCALL DeeObject_CompareGe)(DeeObject *self, DeeObject *some_object); -/* @return: == Dee_COMPARE_ERR: An error occurred. - * @return: == -1: `lhs < rhs' +/* @return: == -1: `lhs < rhs' * @return: == 0: `lhs == rhs' - * @return: == 1: `lhs > rhs' */ + * @return: == 1: `lhs > rhs' + * @return: == Dee_COMPARE_ERR: An error occurred. */ DFUNDEF WUNUSED NONNULL((1, 2)) int (DCALL DeeObject_Compare)(DeeObject *lhs, DeeObject *rhs); +/* @return: == -1: `lhs != rhs' + * @return: == 0: `lhs == rhs' + * @return: == 1: `lhs != rhs' + * @return: == Dee_COMPARE_ERR: An error occurred. */ +DFUNDEF WUNUSED NONNULL((1, 2)) int +(DCALL DeeObject_CompareForEquality)(DeeObject *lhs, DeeObject *rhs); + /* Compare a pre-keyed `lhs_keyed' with `rhs' using the given (optional) `key' function - * @return: == Dee_COMPARE_ERR: An error occurred. * @return: == -1: `lhs_keyed < key(rhs)' * @return: == 0: `lhs_keyed == key(rhs)' - * @return: == 1: `lhs_keyed > key(rhs)' */ + * @return: == 1: `lhs_keyed > key(rhs)' + * @return: == Dee_COMPARE_ERR: An error occurred. */ DFUNDEF WUNUSED NONNULL((1, 2)) int (DCALL DeeObject_CompareKey)(DeeObject *lhs_keyed, DeeObject *rhs, /*nullable*/ DeeObject *key); diff --git a/src/deemon/objects/dict.c b/src/deemon/objects/dict.c index cd39a1a3c..0a2e08937 100644 --- a/src/deemon/objects/dict.c +++ b/src/deemon/objects/dict.c @@ -2408,52 +2408,6 @@ dict_printrepr(Dict *__restrict self, return temp; } -PRIVATE WUNUSED NONNULL((1)) dhash_t DCALL -dict_hash(Dict *__restrict self) { - dhash_t result; - struct dict_item *iter, *end; - struct dict_item *vector; - size_t mask; -again: - result = DEE_HASHOF_EMPTY_SEQUENCE; - DeeDict_LockRead(self); - vector = self->d_elem; - mask = self->d_mask; - end = (iter = vector) + (mask + 1); - for (; iter < end; ++iter) { - DREF DeeObject *key, *value; - key = iter->di_key; - if (key == NULL || key == dummy) - continue; - value = iter->di_value; - Dee_Incref(key); - Dee_Incref(value); - DeeDict_LockEndRead(self); - result ^= Dee_HashCombine(DeeObject_Hash(key), - DeeObject_Hash(value)); - Dee_Decref(value); - Dee_Decref(key); - DeeDict_LockRead(self); - if unlikely(self->d_elem != vector || - self->d_mask != mask) { - DeeDict_LockEndRead(self); - goto again; - } - } - DeeDict_LockEndRead(self); - return result; -} - -PRIVATE struct type_cmp dict_cmp = { - /* .tp_hash = */ (dhash_t (DCALL *)(DeeObject *__restrict))&dict_hash, - /* .tp_eq = */ (DREF DeeObject *(DCALL *)(DeeObject *, DeeObject *))NULL, // TODO: &dict_eq, - /* .tp_ne = */ (DREF DeeObject *(DCALL *)(DeeObject *, DeeObject *))NULL, // TODO: &dict_ne, - /* .tp_lo = */ (DREF DeeObject *(DCALL *)(DeeObject *, DeeObject *))NULL, // TODO: &dict_lo, - /* .tp_le = */ (DREF DeeObject *(DCALL *)(DeeObject *, DeeObject *))NULL, // TODO: &dict_le, - /* .tp_gr = */ (DREF DeeObject *(DCALL *)(DeeObject *, DeeObject *))NULL, // TODO: &dict_gr, - /* .tp_ge = */ (DREF DeeObject *(DCALL *)(DeeObject *, DeeObject *))NULL, // TODO: &dict_ge, -}; - PRIVATE WUNUSED NONNULL((1)) int DCALL dict_bool(Dict *__restrict self) { return atomic_read(&self->d_used) != 0; @@ -2834,7 +2788,7 @@ PUBLIC DeeTypeObject DeeDict_Type = { /* .tp_visit = */ (void (DCALL *)(DeeObject *__restrict, dvisit_t, void *))&dict_visit, /* .tp_gc = */ &dict_gc, /* .tp_math = */ NULL, - /* .tp_cmp = */ &dict_cmp, + /* .tp_cmp = */ NULL, /* TODO: &dict_cmp */ /* .tp_seq = */ &dict_seq, /* .tp_iter_next = */ NULL, /* .tp_attr = */ NULL, diff --git a/src/deemon/objects/hashset.c b/src/deemon/objects/hashset.c index d34595945..77f1d31b1 100644 --- a/src/deemon/objects/hashset.c +++ b/src/deemon/objects/hashset.c @@ -1847,38 +1847,6 @@ hashset_printrepr(HashSet *__restrict self, return temp; } -PRIVATE WUNUSED NONNULL((1)) dhash_t DCALL -hashset_hash(HashSet *__restrict self) { - dhash_t result; - struct hashset_item *iter, *end; - struct hashset_item *vector; - size_t mask; -again: - result = DEE_HASHOF_EMPTY_SEQUENCE; - DeeHashSet_LockRead(self); - vector = self->hs_elem; - mask = self->hs_mask; - end = (iter = vector) + (mask + 1); - for (; iter < end; ++iter) { - DREF DeeObject *key; - key = iter->hsi_key; - if (key == NULL || key == dummy) - continue; - Dee_Incref(key); - DeeHashSet_LockEndRead(self); - result ^= DeeObject_Hash(key); - Dee_Decref(key); - DeeHashSet_LockRead(self); - if unlikely(self->hs_elem != vector || - self->hs_mask != mask) { - DeeHashSet_LockEndRead(self); - goto again; - } - } - DeeHashSet_LockEndRead(self); - return result; -} - PRIVATE struct type_nsi tpconst hashset_nsi = { /* .nsi_class = */ TYPE_SEQX_CLASS_SET, /* .nsi_flags = */ TYPE_SEQX_FMUTABLE | TYPE_SEQX_FRESIZABLE, @@ -1891,16 +1859,6 @@ PRIVATE struct type_nsi tpconst hashset_nsi = { } }; -PRIVATE struct type_cmp hashset_cmp = { - /* .tp_hash = */ (dhash_t (DCALL *)(DeeObject *__restrict))&hashset_hash, - /* .tp_eq = */ (DREF DeeObject *(DCALL *)(DeeObject *, DeeObject *))NULL, // TODO: &hashset_eq, - /* .tp_ne = */ (DREF DeeObject *(DCALL *)(DeeObject *, DeeObject *))NULL, // TODO: &hashset_ne, - /* .tp_lo = */ (DREF DeeObject *(DCALL *)(DeeObject *, DeeObject *))NULL, // TODO: &hashset_lo, - /* .tp_le = */ (DREF DeeObject *(DCALL *)(DeeObject *, DeeObject *))NULL, // TODO: &hashset_le, - /* .tp_gr = */ (DREF DeeObject *(DCALL *)(DeeObject *, DeeObject *))NULL, // TODO: &hashset_gr, - /* .tp_ge = */ (DREF DeeObject *(DCALL *)(DeeObject *, DeeObject *))NULL, // TODO: &hashset_ge, -}; - PRIVATE struct type_seq hashset_seq = { /* .tp_iter = */ (DREF DeeObject *(DCALL *)(DeeObject *__restrict))&hashset_iter, /* .tp_sizeob = */ NULL, @@ -2256,7 +2214,7 @@ PUBLIC DeeTypeObject DeeHashSet_Type = { /* .tp_visit = */ (void (DCALL *)(DeeObject *__restrict, dvisit_t, void *))&hashset_visit, /* .tp_gc = */ &hashset_gc, /* .tp_math = */ NULL, - /* .tp_cmp = */ &hashset_cmp, + /* .tp_cmp = */ NULL, /* TODO: &hashset_cmp */ /* .tp_seq = */ &hashset_seq, /* .tp_iter_next = */ NULL, /* .tp_attr = */ NULL, diff --git a/src/deemon/objects/rodict.c b/src/deemon/objects/rodict.c index da4e3856c..f039fe844 100644 --- a/src/deemon/objects/rodict.c +++ b/src/deemon/objects/rodict.c @@ -825,24 +825,6 @@ rodict_printrepr(RoDict *__restrict self, return temp; } -PRIVATE WUNUSED NONNULL((1)) Dee_hash_t DCALL -rodict_hash(RoDict *__restrict self) { - size_t i; - Dee_hash_t result = DEE_HASHOF_EMPTY_SEQUENCE; - for (i = 0; i <= self->rd_mask; ++i) { - if (!self->rd_elem[i].rdi_key) - continue; - /* Note that we still combine the hashes for the key and value, - * thus not only mirroring the behavior of hash of the item (that - * is the tuple `(key, value)', including the order between the - * key and value within the hash, so that swapping the key and - * value would produce a different hash) */ - result ^= Dee_HashCombine(DeeObject_Hash(self->rd_elem[i].rdi_key), - DeeObject_Hash(self->rd_elem[i].rdi_value)); - } - return result; -} - PRIVATE WUNUSED NONNULL((1)) size_t DCALL rodict_size(RoDict *__restrict self) { ASSERT(self->rd_size != (size_t)-1); @@ -1016,16 +998,6 @@ PRIVATE struct type_nsi tpconst rodict_nsi = { }; -PRIVATE struct type_cmp rodict_cmp = { - /* .tp_hash = */ (Dee_hash_t (DCALL *)(DeeObject *__restrict))&rodict_hash, - /* .tp_eq = */ (DREF DeeObject *(DCALL *)(DeeObject *, DeeObject *))NULL, // TODO: &rodict_eq, - /* .tp_ne = */ (DREF DeeObject *(DCALL *)(DeeObject *, DeeObject *))NULL, // TODO: &rodict_ne, - /* .tp_lo = */ (DREF DeeObject *(DCALL *)(DeeObject *, DeeObject *))NULL, // TODO: &rodict_lo, - /* .tp_le = */ (DREF DeeObject *(DCALL *)(DeeObject *, DeeObject *))NULL, // TODO: &rodict_le, - /* .tp_gr = */ (DREF DeeObject *(DCALL *)(DeeObject *, DeeObject *))NULL, // TODO: &rodict_gr, - /* .tp_ge = */ (DREF DeeObject *(DCALL *)(DeeObject *, DeeObject *))NULL, // TODO: &rodict_ge, -}; - PRIVATE struct type_seq rodict_seq = { /* .tp_iter = */ (DREF DeeObject *(DCALL *)(DeeObject *__restrict))&rodict_iter, /* .tp_sizeob = */ NULL, @@ -1235,7 +1207,7 @@ PUBLIC DeeTypeObject DeeRoDict_Type = { /* .tp_visit = */ (void (DCALL *)(DeeObject *__restrict, dvisit_t, void *))&rodict_visit, /* .tp_gc = */ NULL, /* .tp_math = */ NULL, - /* .tp_cmp = */ &rodict_cmp, + /* .tp_cmp = */ NULL, /* TODO: &rodict_cmp */ /* .tp_seq = */ &rodict_seq, /* .tp_iter_next = */ NULL, /* .tp_attr = */ NULL, diff --git a/src/deemon/objects/roset.c b/src/deemon/objects/roset.c index b1ee52ff6..c0cb690bc 100644 --- a/src/deemon/objects/roset.c +++ b/src/deemon/objects/roset.c @@ -488,18 +488,6 @@ roset_printrepr(RoSet *__restrict self, return temp; } -PRIVATE WUNUSED NONNULL((1)) dhash_t DCALL -roset_hash(RoSet *__restrict self) { - size_t i; - dhash_t result = DEE_HASHOF_EMPTY_SEQUENCE; - for (i = 0; i <= self->rs_mask; ++i) { - if (!self->rs_elem[i].rsi_key) - continue; - result ^= DeeObject_Hash(self->rs_elem[i].rsi_key); - } - return result; -} - PRIVATE WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL roset_foreach(RoSet *self, Dee_foreach_t proc, void *arg) { Dee_ssize_t temp, result = 0; @@ -518,16 +506,6 @@ roset_foreach(RoSet *self, Dee_foreach_t proc, void *arg) { return temp; } -PRIVATE struct type_cmp roset_cmp = { - /* .tp_hash = */ (dhash_t (DCALL *)(DeeObject *__restrict))&roset_hash, - /* .tp_eq = */ (DREF DeeObject *(DCALL *)(DeeObject *, DeeObject *))NULL, // TODO: &roset_eq, - /* .tp_ne = */ (DREF DeeObject *(DCALL *)(DeeObject *, DeeObject *))NULL, // TODO: &roset_ne, - /* .tp_lo = */ (DREF DeeObject *(DCALL *)(DeeObject *, DeeObject *))NULL, // TODO: &roset_lo, - /* .tp_le = */ (DREF DeeObject *(DCALL *)(DeeObject *, DeeObject *))NULL, // TODO: &roset_le, - /* .tp_gr = */ (DREF DeeObject *(DCALL *)(DeeObject *, DeeObject *))NULL, // TODO: &roset_gr, - /* .tp_ge = */ (DREF DeeObject *(DCALL *)(DeeObject *, DeeObject *))NULL, // TODO: &roset_ge, -}; - PRIVATE struct type_seq roset_seq = { /* .tp_iter = */ (DREF DeeObject *(DCALL *)(DeeObject *__restrict))&roset_iter, /* .tp_sizeob = */ NULL, @@ -711,7 +689,7 @@ PUBLIC DeeTypeObject DeeRoSet_Type = { /* .tp_visit = */ (void (DCALL *)(DeeObject *__restrict, dvisit_t, void *))&roset_visit, /* .tp_gc = */ NULL, /* .tp_math = */ NULL, - /* .tp_cmp = */ &roset_cmp, + /* .tp_cmp = */ NULL, /* TODO: &roset_cmp */ /* .tp_seq = */ &roset_seq, /* .tp_iter_next = */ NULL, /* .tp_attr = */ NULL, diff --git a/src/deemon/objects/seq/default-compare-impl.c.inl b/src/deemon/objects/seq/default-compare-impl.c.inl new file mode 100644 index 000000000..9a14c142d --- /dev/null +++ b/src/deemon/objects/seq/default-compare-impl.c.inl @@ -0,0 +1,1734 @@ +/* Copyright (c) 2018-2024 Griefer@Work * + * * + * This software is provided 'as-is', without any express or implied * + * warranty. In no event will the authors be held liable for any damages * + * arising from the use of this software. * + * * + * Permission is granted to anyone to use this software for any purpose, * + * including commercial applications, and to alter it and redistribute it * + * freely, subject to the following restrictions: * + * * + * 1. The origin of this software must not be misrepresented; you must not * + * claim that you wrote the original software. If you use this software * + * in a product, an acknowledgement (see the following) in the product * + * documentation is required: * + * Portions Copyright (c) 2018-2024 Griefer@Work * + * 2. Altered source versions must be plainly marked as such, and must not be * + * misrepresented as being the original software. * + * 3. This notice may not be removed or altered from any source distribution. * + */ +#ifdef __INTELLISENSE__ +#include "default-compare.c" +//#define DEFINE_compare +#define DEFINE_compareeq +#endif /* __INTELLISENSE__ */ + +#include +#include + +#if (defined(DEFINE_compare) + defined(DEFINE_compareeq) != 1) +#error "Must #define exactly one of these macros" +#endif + +#ifdef DEFINE_compareeq +#define LOCAL_seq_compare__(x) seq_compareeq__##x +#define LOCAL_seq_docompare__(x) seq_docompareeq__##x +#else /* DEFINE_compareeq */ +#define LOCAL_seq_compare__(x) seq_compare__##x +#define LOCAL_seq_docompare__(x) seq_docompare__##x +#endif /* !DEFINE_compareeq */ + +DECL_BEGIN + +#ifdef DEFINE_compareeq +#define LOCAL_DeeObject_Compare DeeObject_CompareForEquality +#define LOCAL_SEQ_COMPARE_FOREACH_RESULT_EQUAL SEQ_COMPAREEQ_FOREACH_RESULT_EQUAL +#define LOCAL_SEQ_COMPARE_FOREACH_RESULT_ERROR SEQ_COMPAREEQ_FOREACH_RESULT_ERROR +#define LOCAL_SEQ_COMPARE_FOREACH_RESULT_LESS SEQ_COMPAREEQ_FOREACH_RESULT_NOTEQUAL +#define LOCAL_SEQ_COMPARE_FOREACH_RESULT_GREATER SEQ_COMPAREEQ_FOREACH_RESULT_NOTEQUAL +#define LOCAL_SEQ_COMPARE_FOREACH_RESULT_FROMCOMPARE(compare_result) \ + ((compare_result) == 0 ? SEQ_COMPAREEQ_FOREACH_RESULT_ERROR : SEQ_COMPAREEQ_FOREACH_RESULT_NOTEQUAL) +#define LOCAL_SEQ_COMPARE_FOREACH_RESULT_FROMCOMPARE_NE(compare_result) \ + (SEQ_COMPAREEQ_FOREACH_RESULT_NOTEQUAL) +#else /* DEFINE_compareeq */ +#define LOCAL_DeeObject_Compare DeeObject_Compare +#define LOCAL_SEQ_COMPARE_FOREACH_RESULT_EQUAL SEQ_COMPARE_FOREACH_RESULT_EQUAL +#define LOCAL_SEQ_COMPARE_FOREACH_RESULT_ERROR SEQ_COMPARE_FOREACH_RESULT_ERROR +#define LOCAL_SEQ_COMPARE_FOREACH_RESULT_LESS SEQ_COMPARE_FOREACH_RESULT_LESS +#define LOCAL_SEQ_COMPARE_FOREACH_RESULT_GREATER SEQ_COMPARE_FOREACH_RESULT_GREATER +#define LOCAL_SEQ_COMPARE_FOREACH_RESULT_FROMCOMPARE(compare_result) \ + ((compare_result) < 0 ? SEQ_COMPARE_FOREACH_RESULT_LESS : (compare_result) > 0 ? SEQ_COMPARE_FOREACH_RESULT_GREATER : SEQ_COMPARE_FOREACH_RESULT_EQUAL) +#define LOCAL_SEQ_COMPARE_FOREACH_RESULT_FROMCOMPARE_NE(compare_result) \ + ((compare_result) < 0 ? SEQ_COMPARE_FOREACH_RESULT_LESS : SEQ_COMPARE_FOREACH_RESULT_GREATER) +#endif /* !DEFINE_compareeq */ + + +/************************************************************************/ +/* seq_compareforeach__size_and_getitem_index__data */ +/************************************************************************/ +INTERN WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL +LOCAL_seq_compare__(lhs_foreach__rhs_size_and_getitem_index_fast__cb)(void *arg, DeeObject *lhs_elem) { + int temp; + DREF DeeObject *rhs_elem; + struct seq_compareforeach__size_and_getitem_index__data *data; + data = (struct seq_compareforeach__size_and_getitem_index__data *)arg; + if (data->scf_sgi_oindex >= data->scf_sgi_osize) + return LOCAL_SEQ_COMPARE_FOREACH_RESULT_GREATER; /* lhs > rhs */ + rhs_elem = (*data->scf_sgi_ogetitem_index)(data->scf_sgi_other, data->scf_sgi_oindex++); + if unlikely(!rhs_elem) { + /* RHS Unbound item, or premature lhs sequence end */ + return LOCAL_SEQ_COMPARE_FOREACH_RESULT_GREATER; /* lhs > rhs */ + } + temp = LOCAL_DeeObject_Compare(lhs_elem, rhs_elem); + Dee_Decref(rhs_elem); + if unlikely(temp == Dee_COMPARE_ERR) + goto err; + return LOCAL_SEQ_COMPARE_FOREACH_RESULT_FROMCOMPARE(temp); +err: + return LOCAL_SEQ_COMPARE_FOREACH_RESULT_ERROR; +} + +INTERN WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL +LOCAL_seq_compare__(lhs_foreach__rhs_size_and_trygetitem_index__cb)(void *arg, DeeObject *lhs_elem) { + int temp; + DREF DeeObject *rhs_elem; + struct seq_compareforeach__size_and_getitem_index__data *data; + data = (struct seq_compareforeach__size_and_getitem_index__data *)arg; + if (data->scf_sgi_oindex >= data->scf_sgi_osize) + return LOCAL_SEQ_COMPARE_FOREACH_RESULT_GREATER; /* lhs > rhs */ + rhs_elem = (*data->scf_sgi_ogetitem_index)(data->scf_sgi_other, data->scf_sgi_oindex++); + if unlikely(!ITER_ISOK(rhs_elem)) { + if unlikely(!rhs_elem) + goto err; + /* RHS Unbound item, or premature lhs sequence end */ + return LOCAL_SEQ_COMPARE_FOREACH_RESULT_GREATER; /* lhs > rhs */ + } + temp = LOCAL_DeeObject_Compare(lhs_elem, rhs_elem); + Dee_Decref(rhs_elem); + if unlikely(temp == Dee_COMPARE_ERR) + goto err; + return LOCAL_SEQ_COMPARE_FOREACH_RESULT_FROMCOMPARE(temp); +err: + return LOCAL_SEQ_COMPARE_FOREACH_RESULT_ERROR; +} + +INTERN WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL +LOCAL_seq_compare__(lhs_foreach__rhs_size_and_getitem_index__cb)(void *arg, DeeObject *lhs_elem) { + int temp; + DREF DeeObject *rhs_elem; + struct seq_compareforeach__size_and_getitem_index__data *data; + data = (struct seq_compareforeach__size_and_getitem_index__data *)arg; + if (data->scf_sgi_oindex >= data->scf_sgi_osize) + return LOCAL_SEQ_COMPARE_FOREACH_RESULT_GREATER; /* lhs > rhs */ + rhs_elem = (*data->scf_sgi_ogetitem_index)(data->scf_sgi_other, data->scf_sgi_oindex++); + if unlikely(!rhs_elem) { + if (!DeeError_Catch(&DeeError_UnboundItem) && + !DeeError_Catch(&DeeError_IndexError)) + goto err; + /* RHS Unbound item, or premature lhs sequence end */ + return LOCAL_SEQ_COMPARE_FOREACH_RESULT_GREATER; /* lhs > rhs */ + } + temp = LOCAL_DeeObject_Compare(lhs_elem, rhs_elem); + Dee_Decref(rhs_elem); + if unlikely(temp == Dee_COMPARE_ERR) + goto err; + return LOCAL_SEQ_COMPARE_FOREACH_RESULT_FROMCOMPARE(temp); +err: + return LOCAL_SEQ_COMPARE_FOREACH_RESULT_ERROR; +} + +INTERN WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL +LOCAL_seq_compare__(lhs_size_and_getitem_index_fast__rhs_foreach__cb)(void *arg, DeeObject *rhs_elem) { + int temp; + DREF DeeObject *lhs_elem; + struct seq_compareforeach__size_and_getitem_index__data *data; + data = (struct seq_compareforeach__size_and_getitem_index__data *)arg; + if (data->scf_sgi_oindex >= data->scf_sgi_osize) + return LOCAL_SEQ_COMPARE_FOREACH_RESULT_LESS; /* lhs < rhs */ + lhs_elem = (*data->scf_sgi_ogetitem_index)(data->scf_sgi_other, data->scf_sgi_oindex++); + if unlikely(!lhs_elem) { + /* RHS Unbound item, or premature lhs sequence end */ + return LOCAL_SEQ_COMPARE_FOREACH_RESULT_LESS; /* lhs < rhs */ + } + temp = LOCAL_DeeObject_Compare(lhs_elem, rhs_elem); + Dee_Decref(lhs_elem); + if unlikely(temp == Dee_COMPARE_ERR) + goto err; + return LOCAL_SEQ_COMPARE_FOREACH_RESULT_FROMCOMPARE(temp); +err: + return LOCAL_SEQ_COMPARE_FOREACH_RESULT_ERROR; +} + +INTERN WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL +LOCAL_seq_compare__(lhs_size_and_trygetitem_index__rhs_foreach__cb)(void *arg, DeeObject *rhs_elem) { + int temp; + DREF DeeObject *lhs_elem; + struct seq_compareforeach__size_and_getitem_index__data *data; + data = (struct seq_compareforeach__size_and_getitem_index__data *)arg; + if (data->scf_sgi_oindex >= data->scf_sgi_osize) + return LOCAL_SEQ_COMPARE_FOREACH_RESULT_LESS; /* lhs < rhs */ + lhs_elem = (*data->scf_sgi_ogetitem_index)(data->scf_sgi_other, data->scf_sgi_oindex++); + if unlikely(!ITER_ISOK(lhs_elem)) { + if unlikely(!lhs_elem) + goto err; + /* RHS Unbound item, or premature lhs sequence end */ + return LOCAL_SEQ_COMPARE_FOREACH_RESULT_LESS; /* lhs < rhs */ + } + temp = LOCAL_DeeObject_Compare(lhs_elem, rhs_elem); + Dee_Decref(lhs_elem); + if unlikely(temp == Dee_COMPARE_ERR) + goto err; + return LOCAL_SEQ_COMPARE_FOREACH_RESULT_FROMCOMPARE(temp); +err: + return LOCAL_SEQ_COMPARE_FOREACH_RESULT_ERROR; +} + +INTERN WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL +LOCAL_seq_compare__(lhs_size_and_getitem_index__rhs_foreach__cb)(void *arg, DeeObject *rhs_elem) { + int temp; + DREF DeeObject *lhs_elem; + struct seq_compareforeach__size_and_getitem_index__data *data; + data = (struct seq_compareforeach__size_and_getitem_index__data *)arg; + if (data->scf_sgi_oindex >= data->scf_sgi_osize) + return LOCAL_SEQ_COMPARE_FOREACH_RESULT_LESS; /* lhs < rhs */ + lhs_elem = (*data->scf_sgi_ogetitem_index)(data->scf_sgi_other, data->scf_sgi_oindex++); + if unlikely(!lhs_elem) { + if (!DeeError_Catch(&DeeError_UnboundItem) && + !DeeError_Catch(&DeeError_IndexError)) + goto err; + /* RHS Unbound item, or premature lhs sequence end */ + return LOCAL_SEQ_COMPARE_FOREACH_RESULT_LESS; /* lhs < rhs */ + } + temp = LOCAL_DeeObject_Compare(lhs_elem, rhs_elem); + Dee_Decref(lhs_elem); + if unlikely(temp == Dee_COMPARE_ERR) + goto err; + return LOCAL_SEQ_COMPARE_FOREACH_RESULT_FROMCOMPARE(temp); +err: + return LOCAL_SEQ_COMPARE_FOREACH_RESULT_ERROR; +} + + + + + + +/************************************************************************/ +/* seq_compare_foreach__sizeob_and_getitem__data */ +/************************************************************************/ +INTERN WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL +LOCAL_seq_compare__(lhs_foreach__rhs_sizeob_and_getitem__cb)(void *arg, DeeObject *lhs_elem) { + int temp; + DREF DeeObject *rhs_elem; + struct seq_compare_foreach__sizeob_and_getitem__data *data; + data = (struct seq_compare_foreach__sizeob_and_getitem__data *)arg; + temp = DeeObject_CompareGe(data->scf_sg_oindex, data->scf_sg_osize); + if (temp <= 0) { + if unlikely(temp < 0) + goto err; + return LOCAL_SEQ_COMPARE_FOREACH_RESULT_GREATER; /* lhs > rhs */ + } + rhs_elem = (*data->scf_sg_ogetitem)(data->scf_sg_other, data->scf_sg_oindex); + if unlikely(!rhs_elem) { + if (!DeeError_Catch(&DeeError_UnboundItem) && + !DeeError_Catch(&DeeError_IndexError)) + goto err; + /* RHS Unbound item, or premature lhs sequence end */ + return LOCAL_SEQ_COMPARE_FOREACH_RESULT_GREATER; /* lhs > rhs */ + } + if unlikely(DeeObject_Inc(&data->scf_sg_oindex)) + goto err_rhs_elem; + temp = LOCAL_DeeObject_Compare(lhs_elem, rhs_elem); + Dee_Decref(rhs_elem); + if unlikely(temp == Dee_COMPARE_ERR) + goto err; + return LOCAL_SEQ_COMPARE_FOREACH_RESULT_FROMCOMPARE(temp); +err_rhs_elem: + Dee_Decref(rhs_elem); +err: + return LOCAL_SEQ_COMPARE_FOREACH_RESULT_ERROR; +} + +INTERN WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL +LOCAL_seq_compare__(lhs_sizeob_and_getitem__rhs_foreach__cb)(void *arg, DeeObject *rhs_elem) { + int temp; + DREF DeeObject *lhs_elem; + struct seq_compare_foreach__sizeob_and_getitem__data *data; + data = (struct seq_compare_foreach__sizeob_and_getitem__data *)arg; + temp = DeeObject_CompareGe(data->scf_sg_oindex, data->scf_sg_osize); + if (temp <= 0) { + if unlikely(temp < 0) + goto err; + return LOCAL_SEQ_COMPARE_FOREACH_RESULT_LESS; /* lhs < rhs */ + } + lhs_elem = (*data->scf_sg_ogetitem)(data->scf_sg_other, data->scf_sg_oindex); + if unlikely(!lhs_elem) { + if (!DeeError_Catch(&DeeError_UnboundItem) && + !DeeError_Catch(&DeeError_IndexError)) + goto err; + /* RHS Unbound item, or premature lhs sequence end */ + return LOCAL_SEQ_COMPARE_FOREACH_RESULT_LESS; /* lhs < rhs */ + } + if unlikely(DeeObject_Inc(&data->scf_sg_oindex)) + goto err_lhs_elem; + temp = LOCAL_DeeObject_Compare(lhs_elem, rhs_elem); + Dee_Decref(lhs_elem); + if unlikely(temp == Dee_COMPARE_ERR) + goto err; + return LOCAL_SEQ_COMPARE_FOREACH_RESULT_FROMCOMPARE(temp); +err_lhs_elem: + Dee_Decref(lhs_elem); +err: + return LOCAL_SEQ_COMPARE_FOREACH_RESULT_ERROR; +} + + + + + + +/************************************************************************/ +/* seq_compare_foreach__tsizeob_and_getitem__data */ +/************************************************************************/ +INTERN WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL +LOCAL_seq_compare__(tlhs_sizeob_and_getitem__rhs_foreach__cb)(void *arg, DeeObject *rhs_elem) { + int temp; + DREF DeeObject *lhs_elem; + struct seq_compare_foreach__tsizeob_and_getitem__data *data; + data = (struct seq_compare_foreach__tsizeob_and_getitem__data *)arg; + temp = DeeObject_CompareGe(data->scf_tsg_oindex, data->scf_tsg_osize); + if (temp <= 0) { + if unlikely(temp < 0) + goto err; + return LOCAL_SEQ_COMPARE_FOREACH_RESULT_LESS; /* lhs < rhs */ + } + lhs_elem = (*data->scf_tsg_otgetitem)(data->scf_tsg_tpother, + data->scf_tsg_other, + data->scf_tsg_oindex); + if unlikely(!lhs_elem) { + if (!DeeError_Catch(&DeeError_UnboundItem) && + !DeeError_Catch(&DeeError_IndexError)) + goto err; + /* RHS Unbound item, or premature lhs sequence end */ + return LOCAL_SEQ_COMPARE_FOREACH_RESULT_LESS; /* lhs < rhs */ + } + if unlikely(DeeObject_Inc(&data->scf_tsg_oindex)) + goto err_lhs_elem; + temp = LOCAL_DeeObject_Compare(lhs_elem, rhs_elem); + Dee_Decref(lhs_elem); + if unlikely(temp == Dee_COMPARE_ERR) + goto err; + return LOCAL_SEQ_COMPARE_FOREACH_RESULT_FROMCOMPARE(temp); +err_lhs_elem: + Dee_Decref(lhs_elem); +err: + return LOCAL_SEQ_COMPARE_FOREACH_RESULT_ERROR; +} + + + + + + +/************************************************************************/ +/* @param: arg: [1..1] DeeObject *other_iter; */ +/************************************************************************/ +INTERN WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL +LOCAL_seq_compare__(lhs_foreach__rhs_iter__cb)(void *arg, DeeObject *lhs_elem) { + int temp; + DeeObject *rhs_iter = (DeeObject *)arg; + DREF DeeObject *rhs_elem = DeeObject_IterNext(rhs_iter); + if (!ITER_ISOK(rhs_elem)) { + if unlikely(!rhs_elem) + goto err; + return SEQ_COMPARE_FOREACH_RESULT_GREATER; /* lhs > rhs */ + } + temp = LOCAL_DeeObject_Compare(lhs_elem, rhs_elem); + Dee_Decref(rhs_elem); + if unlikely(temp == Dee_COMPARE_ERR) + goto err; + return LOCAL_SEQ_COMPARE_FOREACH_RESULT_FROMCOMPARE(temp); +err: + return LOCAL_SEQ_COMPARE_FOREACH_RESULT_ERROR; +} + +INTERN WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL +LOCAL_seq_compare__(lhs_iter__rhs_foreach__cb)(void *arg, DeeObject *rhs_elem) { + int temp; + DeeObject *lhs_iter = (DeeObject *)arg; + DREF DeeObject *lhs_elem = DeeObject_IterNext(lhs_iter); + if (!ITER_ISOK(lhs_elem)) { + if unlikely(!lhs_elem) + goto err; + return SEQ_COMPARE_FOREACH_RESULT_LESS; /* lhs < rhs */ + } + temp = LOCAL_DeeObject_Compare(lhs_elem, rhs_elem); + Dee_Decref(lhs_elem); + if unlikely(temp == Dee_COMPARE_ERR) + goto err; + return LOCAL_SEQ_COMPARE_FOREACH_RESULT_FROMCOMPARE(temp); +err: + return LOCAL_SEQ_COMPARE_FOREACH_RESULT_ERROR; +} + + +#undef LOCAL_SEQ_COMPARE_FOREACH_RESULT_EQUAL +#undef LOCAL_SEQ_COMPARE_FOREACH_RESULT_ERROR +#undef LOCAL_SEQ_COMPARE_FOREACH_RESULT_LESS +#undef LOCAL_SEQ_COMPARE_FOREACH_RESULT_GREATER +#undef LOCAL_SEQ_COMPARE_FOREACH_RESULT_FROMCOMPARE +#undef LOCAL_SEQ_COMPARE_FOREACH_RESULT_FROMCOMPARE_NE + + + + + + +/************************************************************************/ +/* Implementations when "lhs" should be accessed using size+getitem_index_fast. */ +/************************************************************************/ +INTERN WUNUSED NONNULL((1, 3, 4, 6)) int DCALL +LOCAL_seq_docompare__(lhs_size_and_getitem_index_fast__rhs_size_and_getitem_index_fast)(DeeObject *lhs, size_t lhs_size, DREF DeeObject *(DCALL *lhs_getitem_index_fast)(DeeObject *self, size_t index), + DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_getitem_index_fast)(DeeObject *self, size_t index)) { + size_t i, common_size = lhs_size; +#ifdef DEFINE_compareeq + if (common_size != rhs_size) + return 1; /* not-equal */ +#else /* DEFINE_compareeq */ + if (common_size > rhs_size) + common_size = rhs_size; +#endif /* DEFINE_compareeq */ + for (i = 0; i < common_size; ++i) { + int temp; + DREF DeeObject *lhs_elem, *rhs_elem; + lhs_elem = (*lhs_getitem_index_fast)(lhs, i); + rhs_elem = (*rhs_getitem_index_fast)(rhs, i); + if (!lhs_elem || !rhs_elem) { + if (!lhs_elem && !rhs_elem) + continue; /* Both unbound */ + if (lhs_elem) { + Dee_Decref(lhs_elem); + } else { + Dee_Decref(rhs_elem); + } +#ifdef DEFINE_compareeq + return 1; /* Not-equal */ +#else /* DEFINE_compareeq */ + return lhs_elem ? 1 : -1; +#endif /* !DEFINE_compareeq */ + } + temp = LOCAL_DeeObject_Compare(lhs_elem, rhs_elem); + Dee_Decref(rhs_elem); + Dee_Decref(lhs_elem); + if (temp != 0) + return temp; + } +#ifdef DEFINE_compareeq + return 0; /* Equal */ +#else /* DEFINE_compareeq */ + return Dee_Compare(lhs_size, lhs_size); +#endif /* !DEFINE_compareeq */ +} + +INTERN WUNUSED NONNULL((1, 3, 4, 6)) int DCALL +LOCAL_seq_docompare__(lhs_size_and_getitem_index_fast__rhs_size_and_trygetitem_index)(DeeObject *lhs, size_t lhs_size, DREF DeeObject *(DCALL *lhs_getitem_index_fast)(DeeObject *self, size_t index), + DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_trygetitem_index)(DeeObject *self, size_t index)) { + size_t i, common_size = lhs_size; +#ifdef DEFINE_compareeq + if (common_size != rhs_size) + return 1; /* not-equal */ +#else /* DEFINE_compareeq */ + if (common_size > rhs_size) + common_size = rhs_size; +#endif /* DEFINE_compareeq */ + for (i = 0; i < common_size; ++i) { + int temp; + DREF DeeObject *lhs_elem, *rhs_elem; + rhs_elem = (*rhs_trygetitem_index)(rhs, i); + if unlikely(!rhs_elem) + goto err; + lhs_elem = (*lhs_getitem_index_fast)(lhs, i); + if (!lhs_elem || (rhs_elem == ITER_DONE)) { + if (!lhs_elem && (rhs_elem == ITER_DONE)) + continue; /* Both unbound */ + if (lhs_elem) { + Dee_Decref(lhs_elem); + } else { + Dee_Decref(rhs_elem); + } +#ifdef DEFINE_compareeq + return 1; /* Not-equal */ +#else /* DEFINE_compareeq */ + return lhs_elem ? 1 : -1; +#endif /* !DEFINE_compareeq */ + } + temp = LOCAL_DeeObject_Compare(lhs_elem, rhs_elem); + Dee_Decref(rhs_elem); + Dee_Decref(lhs_elem); + if (temp != 0) + return temp; + } +#ifdef DEFINE_compareeq + return 0; /* Equal */ +#else /* DEFINE_compareeq */ + return Dee_Compare(lhs_size, lhs_size); +#endif /* !DEFINE_compareeq */ +err: + return Dee_COMPARE_ERR; +} + +INTERN WUNUSED NONNULL((1, 3, 4, 6)) int DCALL +LOCAL_seq_docompare__(lhs_size_and_getitem_index_fast__rhs_size_and_getitem_index)(DeeObject *lhs, size_t lhs_size, DREF DeeObject *(DCALL *lhs_getitem_index_fast)(DeeObject *self, size_t index), + DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_getitem_index)(DeeObject *self, size_t index)) { + size_t i, common_size = lhs_size; +#ifdef DEFINE_compareeq + if (common_size != rhs_size) + return 1; /* not-equal */ +#else /* DEFINE_compareeq */ + if (common_size > rhs_size) + common_size = rhs_size; +#endif /* DEFINE_compareeq */ + for (i = 0; i < common_size; ++i) { + int temp; + DREF DeeObject *lhs_elem, *rhs_elem; + rhs_elem = (*rhs_getitem_index)(rhs, i); + if unlikely(!rhs_elem) { + if (DeeError_Catch(&DeeError_UnboundItem)) { + /* Unbound... */ + } else if (DeeError_Catch(&DeeError_IndexError)) { + return 1; /* RHS got smaller... -> lhs > rhs */ + } else { + goto err; + } + } + lhs_elem = (*lhs_getitem_index_fast)(lhs, i); + if (!lhs_elem || !rhs_elem) { + if (!lhs_elem && !rhs_elem) + continue; /* Both unbound */ + if (lhs_elem) { + Dee_Decref(lhs_elem); + } else { + Dee_Decref(rhs_elem); + } +#ifdef DEFINE_compareeq + return 1; /* Not-equal */ +#else /* DEFINE_compareeq */ + return lhs_elem ? 1 : -1; +#endif /* !DEFINE_compareeq */ + } + temp = LOCAL_DeeObject_Compare(lhs_elem, rhs_elem); + Dee_Decref(rhs_elem); + Dee_Decref(lhs_elem); + if (temp != 0) + return temp; + } +#ifdef DEFINE_compareeq + return 0; /* Equal */ +#else /* DEFINE_compareeq */ + return Dee_Compare(lhs_size, lhs_size); +#endif /* !DEFINE_compareeq */ +err: + return Dee_COMPARE_ERR; +} + + +/* @return: (size_t)-1: Error + * @return: (size_t)-2: Size would overflow */ +#ifndef OBJECT_TO_SIZE_WITH_OVERFLOW_HANDLER_DEFINED +#define OBJECT_TO_SIZE_WITH_OVERFLOW_HANDLER_DEFINED +PRIVATE WUNUSED NONNULL((1)) size_t DCALL +object_to_size_with_overflow_handler(DeeObject *sizeob) { + size_t result; + if (DeeInt_Check(sizeob)) { + if (!DeeInt_TryAsSize(sizeob, &result)) + goto overflow; + } else { + if (DeeObject_AsSize(sizeob, &result)) + goto err; + } + if unlikely(result >= (size_t)-2) + goto overflow; + return result; +overflow: + return (size_t)-2; +err: + if (DeeError_Catch(&DeeError_IntegerOverflow)) + goto overflow; + return (size_t)-1; +} +#endif /* !OBJECT_TO_SIZE_WITH_OVERFLOW_HANDLER_DEFINED */ + +INTERN WUNUSED NONNULL((1, 3, 4, 5, 6)) int DCALL +LOCAL_seq_docompare__(lhs_size_and_getitem_index_fast__rhs_sizeob_and_getitem)(DeeObject *lhs, size_t lhs_size, DREF DeeObject *(DCALL *lhs_getitem_index_fast)(DeeObject *self, size_t index), + DeeObject *rhs, DeeObject *rhs_sizeob, DREF DeeObject *(DCALL *rhs_getitem)(DeeObject *self, DeeObject *index)) { + size_t i, common_size = lhs_size; + size_t rhs_size = object_to_size_with_overflow_handler(rhs_sizeob); + if unlikely(rhs_size == (size_t)-1) + goto err; +#ifdef DEFINE_compareeq + if (common_size != rhs_size) + return 1; /* not-equal */ +#else /* DEFINE_compareeq */ + if (common_size > rhs_size) + common_size = rhs_size; +#endif /* DEFINE_compareeq */ + for (i = 0; i < common_size; ++i) { + int temp; + DREF DeeObject *lhs_elem, *rhs_elem; + DREF DeeObject *index_ob; + index_ob = DeeInt_NewSize(i); + if unlikely(!index_ob) + goto err; + rhs_elem = (*rhs_getitem)(rhs, index_ob); + Dee_Decref(index_ob); + if unlikely(!rhs_elem) { + if (DeeError_Catch(&DeeError_UnboundItem)) { + /* Unbound... */ + } else if (DeeError_Catch(&DeeError_IndexError)) { + return 1; /* RHS got smaller... -> lhs > rhs */ + } else { + goto err; + } + } + lhs_elem = (*lhs_getitem_index_fast)(lhs, i); + if (!lhs_elem || !rhs_elem) { + if (!lhs_elem && !rhs_elem) + continue; /* Both unbound */ + if (lhs_elem) { + Dee_Decref(lhs_elem); + } else { + Dee_Decref(rhs_elem); + } +#ifdef DEFINE_compareeq + return 1; /* Not-equal */ +#else /* DEFINE_compareeq */ + return lhs_elem ? 1 : -1; +#endif /* !DEFINE_compareeq */ + } + temp = LOCAL_DeeObject_Compare(lhs_elem, rhs_elem); + Dee_Decref(rhs_elem); + Dee_Decref(lhs_elem); + if (temp != 0) + return temp; + } +#ifdef DEFINE_compareeq + return 0; /* Equal */ +#else /* DEFINE_compareeq */ + return Dee_Compare(lhs_size, lhs_size); +#endif /* !DEFINE_compareeq */ +err: + return Dee_COMPARE_ERR; +} + + + + + + +/************************************************************************/ +/* Implementations when "lhs" should be accessed using size+trygetitem_index. */ +/************************************************************************/ +INTERN WUNUSED NONNULL((1, 3, 4, 6)) int DCALL +LOCAL_seq_docompare__(lhs_size_and_trygetitem_index__rhs_size_and_getitem_index_fast)(DeeObject *lhs, size_t lhs_size, DREF DeeObject *(DCALL *lhs_trygetitem_index)(DeeObject *self, size_t index), + DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_getitem_index_fast)(DeeObject *self, size_t index)) { + size_t i, common_size = lhs_size; +#ifdef DEFINE_compareeq + if (common_size != rhs_size) + return 1; /* not-equal */ +#else /* DEFINE_compareeq */ + if (common_size > rhs_size) + common_size = rhs_size; +#endif /* DEFINE_compareeq */ + for (i = 0; i < common_size; ++i) { + int temp; + DREF DeeObject *lhs_elem, *rhs_elem; + lhs_elem = (*lhs_trygetitem_index)(lhs, i); + if unlikely(!lhs_elem) + goto err; + rhs_elem = (*rhs_getitem_index_fast)(rhs, i); + if ((lhs_elem == ITER_DONE) || !rhs_elem) { + if ((lhs_elem == ITER_DONE) && !rhs_elem) + continue; /* Both unbound */ + if (rhs_elem) { + Dee_Decref(rhs_elem); + } else { + Dee_Decref(lhs_elem); + } +#ifdef DEFINE_compareeq + return 1; /* Not-equal */ +#else /* DEFINE_compareeq */ + return lhs_elem ? 1 : -1; +#endif /* !DEFINE_compareeq */ + } + temp = LOCAL_DeeObject_Compare(lhs_elem, rhs_elem); + Dee_Decref(rhs_elem); + Dee_Decref(lhs_elem); + if (temp != 0) + return temp; + } +#ifdef DEFINE_compareeq + return 0; /* Equal */ +#else /* DEFINE_compareeq */ + return Dee_Compare(lhs_size, lhs_size); +#endif /* !DEFINE_compareeq */ +err: + return Dee_COMPARE_ERR; +} + +INTERN WUNUSED NONNULL((1, 3, 4, 6)) int DCALL +LOCAL_seq_docompare__(lhs_size_and_trygetitem_index__rhs_size_and_trygetitem_index)(DeeObject *lhs, size_t lhs_size, DREF DeeObject *(DCALL *lhs_trygetitem_index)(DeeObject *self, size_t index), + DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_trygetitem_index)(DeeObject *self, size_t index)) { + size_t i, common_size = lhs_size; +#ifdef DEFINE_compareeq + if (common_size != rhs_size) + return 1; /* not-equal */ +#else /* DEFINE_compareeq */ + if (common_size > rhs_size) + common_size = rhs_size; +#endif /* DEFINE_compareeq */ + for (i = 0; i < common_size; ++i) { + int temp; + DREF DeeObject *lhs_elem, *rhs_elem; + lhs_elem = (*lhs_trygetitem_index)(lhs, i); + if unlikely(!lhs_elem) + goto err; + rhs_elem = (*rhs_trygetitem_index)(rhs, i); + if unlikely(!rhs_elem) { + if (lhs_elem != ITER_DONE) + Dee_Decref(lhs_elem); + goto err; + } + if ((lhs_elem == ITER_DONE) || (rhs_elem == ITER_DONE)) { + if ((lhs_elem == ITER_DONE) && (rhs_elem == ITER_DONE)) + continue; /* Both unbound */ + if (rhs_elem != ITER_DONE) { + Dee_Decref(rhs_elem); + } else { + Dee_Decref(lhs_elem); + } +#ifdef DEFINE_compareeq + return 1; /* Not-equal */ +#else /* DEFINE_compareeq */ + return lhs_elem ? 1 : -1; +#endif /* !DEFINE_compareeq */ + } + temp = LOCAL_DeeObject_Compare(lhs_elem, rhs_elem); + Dee_Decref(rhs_elem); + Dee_Decref(lhs_elem); + if (temp != 0) + return temp; + if (DeeThread_CheckInterrupt()) + goto err; + } +#ifdef DEFINE_compareeq + return 0; /* Equal */ +#else /* DEFINE_compareeq */ + return Dee_Compare(lhs_size, lhs_size); +#endif /* !DEFINE_compareeq */ +err: + return Dee_COMPARE_ERR; +} + +INTERN WUNUSED NONNULL((1, 3, 4, 6)) int DCALL +LOCAL_seq_docompare__(lhs_size_and_trygetitem_index__rhs_size_and_getitem_index)(DeeObject *lhs, size_t lhs_size, DREF DeeObject *(DCALL *lhs_trygetitem_index)(DeeObject *self, size_t index), + DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_getitem_index)(DeeObject *self, size_t index)) { + size_t i, common_size = lhs_size; +#ifdef DEFINE_compareeq + if (common_size != rhs_size) + return 1; /* not-equal */ +#else /* DEFINE_compareeq */ + if (common_size > rhs_size) + common_size = rhs_size; +#endif /* DEFINE_compareeq */ + for (i = 0; i < common_size; ++i) { + int temp; + DREF DeeObject *lhs_elem, *rhs_elem; + rhs_elem = (*rhs_getitem_index)(rhs, i); + if unlikely(!rhs_elem) { + if (DeeError_Catch(&DeeError_UnboundItem)) { + /* Unbound... */ + } else if (DeeError_Catch(&DeeError_IndexError)) { + return 1; /* RHS got smaller... -> lhs > rhs */ + } else { + goto err; + } + } + lhs_elem = (*lhs_trygetitem_index)(lhs, i); + if unlikely(!lhs_elem) { + Dee_Decref(rhs_elem); + goto err; + } + if ((lhs_elem == ITER_DONE) || !rhs_elem) { + if ((lhs_elem == ITER_DONE) && !rhs_elem) + continue; /* Both unbound */ + if (rhs_elem) { + Dee_Decref(rhs_elem); + } else { + Dee_Decref(lhs_elem); + } +#ifdef DEFINE_compareeq + return 1; /* Not-equal */ +#else /* DEFINE_compareeq */ + return lhs_elem ? 1 : -1; +#endif /* !DEFINE_compareeq */ + } + temp = LOCAL_DeeObject_Compare(lhs_elem, rhs_elem); + Dee_Decref(rhs_elem); + Dee_Decref(lhs_elem); + if (temp != 0) + return temp; + if (DeeThread_CheckInterrupt()) + goto err; + } +#ifdef DEFINE_compareeq + return 0; /* Equal */ +#else /* DEFINE_compareeq */ + return Dee_Compare(lhs_size, lhs_size); +#endif /* !DEFINE_compareeq */ +err: + return Dee_COMPARE_ERR; +} + +INTERN WUNUSED NONNULL((1, 3, 4, 5, 6)) int DCALL +LOCAL_seq_docompare__(lhs_size_and_trygetitem_index__rhs_sizeob_and_getitem)(DeeObject *lhs, size_t lhs_size, DREF DeeObject *(DCALL *lhs_trygetitem_index)(DeeObject *self, size_t index), + DeeObject *rhs, DeeObject *rhs_sizeob, DREF DeeObject *(DCALL *rhs_getitem)(DeeObject *self, DeeObject *index)) { + size_t i, common_size = lhs_size; + size_t rhs_size = object_to_size_with_overflow_handler(rhs_sizeob); + if unlikely(rhs_size == (size_t)-1) + goto err; +#ifdef DEFINE_compareeq + if (common_size != rhs_size) + return 1; /* not-equal */ +#else /* DEFINE_compareeq */ + if (common_size > rhs_size) + common_size = rhs_size; +#endif /* DEFINE_compareeq */ + for (i = 0; i < common_size; ++i) { + int temp; + DREF DeeObject *lhs_elem, *rhs_elem; + DREF DeeObject *index_ob; + index_ob = DeeInt_NewSize(i); + if unlikely(!index_ob) + goto err; + rhs_elem = (*rhs_getitem)(rhs, index_ob); + Dee_Decref(index_ob); + if unlikely(!rhs_elem) { + if (DeeError_Catch(&DeeError_UnboundItem)) { + /* Unbound... */ + } else if (DeeError_Catch(&DeeError_IndexError)) { + return 1; /* RHS got smaller... -> lhs > rhs */ + } else { + goto err; + } + } + lhs_elem = (*lhs_trygetitem_index)(lhs, i); + if unlikely(!lhs_elem) { + Dee_Decref(rhs_elem); + goto err; + } + if ((lhs_elem == ITER_DONE) || !rhs_elem) { + if ((lhs_elem == ITER_DONE) && !rhs_elem) + continue; /* Both unbound */ + if (lhs_elem) { + Dee_Decref(rhs_elem); + } else { + Dee_Decref(lhs_elem); + } +#ifdef DEFINE_compareeq + return 1; /* Not-equal */ +#else /* DEFINE_compareeq */ + return lhs_elem ? 1 : -1; +#endif /* !DEFINE_compareeq */ + } + temp = LOCAL_DeeObject_Compare(lhs_elem, rhs_elem); + Dee_Decref(rhs_elem); + Dee_Decref(lhs_elem); + if (temp != 0) + return temp; + if (DeeThread_CheckInterrupt()) + goto err; + } +#ifdef DEFINE_compareeq + return 0; /* Equal */ +#else /* DEFINE_compareeq */ + return Dee_Compare(lhs_size, lhs_size); +#endif /* !DEFINE_compareeq */ +err: + return Dee_COMPARE_ERR; +} + + + + + + +/************************************************************************/ +/* Implementations when "lhs" should be accessed using size+getitem_index. */ +/************************************************************************/ +INTERN WUNUSED NONNULL((1, 3, 4, 6)) int DCALL +LOCAL_seq_docompare__(lhs_size_and_getitem_index__rhs_size_and_getitem_index_fast)(DeeObject *lhs, size_t lhs_size, DREF DeeObject *(DCALL *lhs_getitem_index)(DeeObject *self, size_t index), + DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_getitem_index_fast)(DeeObject *self, size_t index)) { + size_t i, common_size = lhs_size; +#ifdef DEFINE_compareeq + if (common_size != rhs_size) + return 1; /* not-equal */ +#else /* DEFINE_compareeq */ + if (common_size > rhs_size) + common_size = rhs_size; +#endif /* DEFINE_compareeq */ + for (i = 0; i < common_size; ++i) { + int temp; + DREF DeeObject *lhs_elem, *rhs_elem; + lhs_elem = (*lhs_getitem_index)(lhs, i); + if unlikely(!lhs_elem) { + if (DeeError_Catch(&DeeError_UnboundItem)) { + /* Unbound... */ + } else if (DeeError_Catch(&DeeError_IndexError)) { + return -1; /* LHS got smaller... -> lhs < rhs */ + } else { + goto err; + } + } + rhs_elem = (*rhs_getitem_index_fast)(rhs, i); + if (!lhs_elem || !rhs_elem) { + if (!lhs_elem && !rhs_elem) + continue; /* Both unbound */ + if (rhs_elem) { + Dee_Decref(rhs_elem); + } else { + Dee_Decref(lhs_elem); + } +#ifdef DEFINE_compareeq + return 1; /* Not-equal */ +#else /* DEFINE_compareeq */ + return lhs_elem ? 1 : -1; +#endif /* !DEFINE_compareeq */ + } + temp = LOCAL_DeeObject_Compare(lhs_elem, rhs_elem); + Dee_Decref(rhs_elem); + Dee_Decref(lhs_elem); + if (temp != 0) + return temp; + } +#ifdef DEFINE_compareeq + return 0; /* Equal */ +#else /* DEFINE_compareeq */ + return Dee_Compare(lhs_size, lhs_size); +#endif /* !DEFINE_compareeq */ +err: + return Dee_COMPARE_ERR; +} + +INTERN WUNUSED NONNULL((1, 3, 4, 6)) int DCALL +LOCAL_seq_docompare__(lhs_size_and_getitem_index__rhs_size_and_trygetitem_index)(DeeObject *lhs, size_t lhs_size, DREF DeeObject *(DCALL *lhs_getitem_index)(DeeObject *self, size_t index), + DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_trygetitem_index)(DeeObject *self, size_t index)) { + size_t i, common_size = lhs_size; +#ifdef DEFINE_compareeq + if (common_size != rhs_size) + return 1; /* not-equal */ +#else /* DEFINE_compareeq */ + if (common_size > rhs_size) + common_size = rhs_size; +#endif /* DEFINE_compareeq */ + for (i = 0; i < common_size; ++i) { + int temp; + DREF DeeObject *lhs_elem, *rhs_elem; + lhs_elem = (*lhs_getitem_index)(lhs, i); + if unlikely(!lhs_elem) { + if (DeeError_Catch(&DeeError_UnboundItem)) { + /* Unbound... */ + } else if (DeeError_Catch(&DeeError_IndexError)) { + return -1; /* LHS got smaller... -> lhs < rhs */ + } else { + goto err; + } + } + rhs_elem = (*rhs_trygetitem_index)(rhs, i); + if unlikely(!rhs_elem) { + Dee_Decref(lhs_elem); + goto err; + } + if (!lhs_elem || (rhs_elem == ITER_DONE)) { + if (!lhs_elem && (rhs_elem == ITER_DONE)) + continue; /* Both unbound */ + if (lhs_elem) { + Dee_Decref(lhs_elem); + } else { + Dee_Decref(rhs_elem); + } +#ifdef DEFINE_compareeq + return 1; /* Not-equal */ +#else /* DEFINE_compareeq */ + return lhs_elem ? 1 : -1; +#endif /* !DEFINE_compareeq */ + } + temp = LOCAL_DeeObject_Compare(lhs_elem, rhs_elem); + Dee_Decref(rhs_elem); + Dee_Decref(lhs_elem); + if (temp != 0) + return temp; + if (DeeThread_CheckInterrupt()) + goto err; + } +#ifdef DEFINE_compareeq + return 0; /* Equal */ +#else /* DEFINE_compareeq */ + return Dee_Compare(lhs_size, lhs_size); +#endif /* !DEFINE_compareeq */ +err: + return Dee_COMPARE_ERR; +} + +INTERN WUNUSED NONNULL((1, 3, 4, 6)) int DCALL +LOCAL_seq_docompare__(lhs_size_and_getitem_index__rhs_size_and_getitem_index)(DeeObject *lhs, size_t lhs_size, DREF DeeObject *(DCALL *lhs_getitem_index)(DeeObject *self, size_t index), + DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_getitem_index)(DeeObject *self, size_t index)) { + size_t i, common_size = lhs_size; +#ifdef DEFINE_compareeq + if (common_size != rhs_size) + return 1; /* not-equal */ +#else /* DEFINE_compareeq */ + if (common_size > rhs_size) + common_size = rhs_size; +#endif /* DEFINE_compareeq */ + for (i = 0; i < common_size; ++i) { + int temp; + DREF DeeObject *lhs_elem, *rhs_elem; + lhs_elem = (*lhs_getitem_index)(lhs, i); + if unlikely(!lhs_elem) { + if (DeeError_Catch(&DeeError_UnboundItem)) { + /* Unbound... */ + } else if (DeeError_Catch(&DeeError_IndexError)) { + return -1; /* LHS got smaller... -> lhs < rhs */ + } else { + goto err; + } + } + rhs_elem = (*rhs_getitem_index)(rhs, i); + if unlikely(!rhs_elem) { + if (DeeError_Catch(&DeeError_UnboundItem)) { + /* Unbound... */ + } else if (DeeError_Catch(&DeeError_IndexError)) { + Dee_XDecref(lhs_elem); + return 1; /* RHS got smaller... -> lhs > rhs */ + } else { + Dee_XDecref(lhs_elem); + goto err; + } + } + if (!lhs_elem || !rhs_elem) { + if (!lhs_elem && !rhs_elem) + continue; /* Both unbound */ + if (rhs_elem) { + Dee_Decref(rhs_elem); + } else { + Dee_Decref(lhs_elem); + } +#ifdef DEFINE_compareeq + return 1; /* Not-equal */ +#else /* DEFINE_compareeq */ + return lhs_elem ? 1 : -1; +#endif /* !DEFINE_compareeq */ + } + temp = LOCAL_DeeObject_Compare(lhs_elem, rhs_elem); + Dee_Decref(rhs_elem); + Dee_Decref(lhs_elem); + if (temp != 0) + return temp; + if (DeeThread_CheckInterrupt()) + goto err; + } +#ifdef DEFINE_compareeq + return 0; /* Equal */ +#else /* DEFINE_compareeq */ + return Dee_Compare(lhs_size, lhs_size); +#endif /* !DEFINE_compareeq */ +err: + return Dee_COMPARE_ERR; +} + +INTERN WUNUSED NONNULL((1, 3, 4, 5, 6)) int DCALL +LOCAL_seq_docompare__(lhs_size_and_getitem_index__rhs_sizeob_and_getitem)(DeeObject *lhs, size_t lhs_size, DREF DeeObject *(DCALL *lhs_getitem_index)(DeeObject *self, size_t index), + DeeObject *rhs, DeeObject *rhs_sizeob, DREF DeeObject *(DCALL *rhs_getitem)(DeeObject *self, DeeObject *index)) { + size_t i, common_size = lhs_size; + size_t rhs_size = object_to_size_with_overflow_handler(rhs_sizeob); + if unlikely(rhs_size == (size_t)-1) + goto err; +#ifdef DEFINE_compareeq + if (common_size != rhs_size) + return 1; /* not-equal */ +#else /* DEFINE_compareeq */ + if (common_size > rhs_size) + common_size = rhs_size; +#endif /* DEFINE_compareeq */ + for (i = 0; i < common_size; ++i) { + int temp; + DREF DeeObject *lhs_elem, *rhs_elem; + DREF DeeObject *index_ob; + index_ob = DeeInt_NewSize(i); + if unlikely(!index_ob) + goto err; + rhs_elem = (*rhs_getitem)(rhs, index_ob); + Dee_Decref(index_ob); + if unlikely(!rhs_elem) { + if (DeeError_Catch(&DeeError_UnboundItem)) { + /* Unbound... */ + } else if (DeeError_Catch(&DeeError_IndexError)) { + return 1; /* RHS got smaller... -> lhs > rhs */ + } else { + goto err; + } + } + lhs_elem = (*lhs_getitem_index)(lhs, i); + if unlikely(!lhs_elem) { + if (DeeError_Catch(&DeeError_UnboundItem)) { + /* Unbound... */ + } else if (DeeError_Catch(&DeeError_IndexError)) { + Dee_XDecref(rhs_elem); + return -1; /* LHS got smaller... -> lhs < rhs */ + } else { + Dee_XDecref(rhs_elem); + goto err; + } + } + if (!lhs_elem || !rhs_elem) { + if (!lhs_elem && !rhs_elem) + continue; /* Both unbound */ + if (rhs_elem) { + Dee_Decref(rhs_elem); + } else { + Dee_Decref(lhs_elem); + } +#ifdef DEFINE_compareeq + return 1; /* Not-equal */ +#else /* DEFINE_compareeq */ + return lhs_elem ? 1 : -1; +#endif /* !DEFINE_compareeq */ + } + temp = LOCAL_DeeObject_Compare(lhs_elem, rhs_elem); + Dee_Decref(rhs_elem); + Dee_Decref(lhs_elem); + if (temp != 0) + return temp; + if (DeeThread_CheckInterrupt()) + goto err; + } +#ifdef DEFINE_compareeq + return 0; /* Equal */ +#else /* DEFINE_compareeq */ + return Dee_Compare(lhs_size, lhs_size); +#endif /* !DEFINE_compareeq */ +err: + return Dee_COMPARE_ERR; +} + + + + + + +/************************************************************************/ +/* Implementations when "lhs" should be accessed using sizeob+getitem. */ +/************************************************************************/ +INTERN WUNUSED NONNULL((1, 2, 3, 4, 6)) int DCALL +LOCAL_seq_docompare__(lhs_sizeob_and_getitem__rhs_size_and_getitem_index_fast)(DeeObject *lhs, DeeObject *lhs_sizeob, DREF DeeObject *(DCALL *lhs_getitem)(DeeObject *self, DeeObject *index), + DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_getitem_index_fast)(DeeObject *self, size_t index)) { + size_t i, common_size = rhs_size; + size_t lhs_size = object_to_size_with_overflow_handler(lhs_sizeob); + if unlikely(lhs_size == (size_t)-1) + goto err; +#ifdef DEFINE_compareeq + if (common_size != lhs_size) + return 1; /* not-equal */ +#else /* DEFINE_compareeq */ + if (common_size > lhs_size) + common_size = lhs_size; +#endif /* DEFINE_compareeq */ + for (i = 0; i < common_size; ++i) { + int temp; + DREF DeeObject *lhs_elem, *rhs_elem; + DREF DeeObject *index_ob; + index_ob = DeeInt_NewSize(i); + if unlikely(!index_ob) + goto err; + lhs_elem = (*lhs_getitem)(lhs, index_ob); + Dee_Decref(index_ob); + if unlikely(!lhs_elem) { + if (DeeError_Catch(&DeeError_UnboundItem)) { + /* Unbound... */ + } else if (DeeError_Catch(&DeeError_IndexError)) { + return 1; /* RHS got smaller... -> lhs > rhs */ + } else { + goto err; + } + } + rhs_elem = (*rhs_getitem_index_fast)(rhs, i); + if (!lhs_elem || !rhs_elem) { + if (!lhs_elem && !rhs_elem) + continue; /* Both unbound */ + if (rhs_elem) { + Dee_Decref(rhs_elem); + } else { + Dee_Decref(lhs_elem); + } +#ifdef DEFINE_compareeq + return 1; /* Not-equal */ +#else /* DEFINE_compareeq */ + return lhs_elem ? 1 : -1; +#endif /* !DEFINE_compareeq */ + } + temp = LOCAL_DeeObject_Compare(lhs_elem, rhs_elem); + Dee_Decref(rhs_elem); + Dee_Decref(lhs_elem); + if (temp != 0) + return temp; + } +#ifdef DEFINE_compareeq + return 0; /* Equal */ +#else /* DEFINE_compareeq */ + return Dee_Compare(lhs_size, lhs_size); +#endif /* !DEFINE_compareeq */ +err: + return Dee_COMPARE_ERR; +} + +INTERN WUNUSED NONNULL((1, 2, 3, 4, 6)) int DCALL +LOCAL_seq_docompare__(lhs_sizeob_and_getitem__rhs_size_and_trygetitem_index)(DeeObject *lhs, DeeObject *lhs_sizeob, DREF DeeObject *(DCALL *lhs_getitem)(DeeObject *self, DeeObject *index), + DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_trygetitem_index)(DeeObject *self, size_t index)) { + size_t i, common_size = rhs_size; + size_t lhs_size = object_to_size_with_overflow_handler(lhs_sizeob); + if unlikely(lhs_size == (size_t)-1) + goto err; +#ifdef DEFINE_compareeq + if (common_size != lhs_size) + return 1; /* not-equal */ +#else /* DEFINE_compareeq */ + if (common_size > lhs_size) + common_size = lhs_size; +#endif /* DEFINE_compareeq */ + for (i = 0; i < common_size; ++i) { + int temp; + DREF DeeObject *lhs_elem, *rhs_elem; + DREF DeeObject *index_ob; + index_ob = DeeInt_NewSize(i); + if unlikely(!index_ob) + goto err; + lhs_elem = (*lhs_getitem)(lhs, index_ob); + Dee_Decref(index_ob); + if unlikely(!lhs_elem) { + if (DeeError_Catch(&DeeError_UnboundItem)) { + /* Unbound... */ + } else if (DeeError_Catch(&DeeError_IndexError)) { + return 1; /* RHS got smaller... -> lhs > rhs */ + } else { + goto err; + } + } + rhs_elem = (*rhs_trygetitem_index)(rhs, i); + if unlikely(!rhs_elem) { + Dee_XDecref(lhs_elem); + goto err; + } + if (!lhs_elem || (rhs_elem == ITER_DONE)) { + if (!lhs_elem && (rhs_elem == ITER_DONE)) + continue; /* Both unbound */ + if (lhs_elem) { + Dee_Decref(lhs_elem); + } else { + Dee_Decref(rhs_elem); + } +#ifdef DEFINE_compareeq + return 1; /* Not-equal */ +#else /* DEFINE_compareeq */ + return lhs_elem ? 1 : -1; +#endif /* !DEFINE_compareeq */ + } + temp = LOCAL_DeeObject_Compare(lhs_elem, rhs_elem); + Dee_Decref(rhs_elem); + Dee_Decref(lhs_elem); + if (temp != 0) + return temp; + if (DeeThread_CheckInterrupt()) + goto err; + } +#ifdef DEFINE_compareeq + return 0; /* Equal */ +#else /* DEFINE_compareeq */ + return Dee_Compare(lhs_size, lhs_size); +#endif /* !DEFINE_compareeq */ +err: + return Dee_COMPARE_ERR; +} + +INTERN WUNUSED NONNULL((1, 2, 3, 4, 6)) int DCALL +LOCAL_seq_docompare__(lhs_sizeob_and_getitem__rhs_size_and_getitem_index)(DeeObject *lhs, DeeObject *lhs_sizeob, DREF DeeObject *(DCALL *lhs_getitem)(DeeObject *self, DeeObject *index), + DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_getitem_index)(DeeObject *self, size_t index)) { + size_t i, common_size = rhs_size; + size_t lhs_size = object_to_size_with_overflow_handler(lhs_sizeob); + if unlikely(lhs_size == (size_t)-1) + goto err; +#ifdef DEFINE_compareeq + if (common_size != lhs_size) + return 1; /* not-equal */ +#else /* DEFINE_compareeq */ + if (common_size > lhs_size) + common_size = lhs_size; +#endif /* DEFINE_compareeq */ + for (i = 0; i < common_size; ++i) { + int temp; + DREF DeeObject *lhs_elem, *rhs_elem; + DREF DeeObject *index_ob; + index_ob = DeeInt_NewSize(i); + if unlikely(!index_ob) + goto err; + lhs_elem = (*lhs_getitem)(lhs, index_ob); + Dee_Decref(index_ob); + if unlikely(!lhs_elem) { + if (DeeError_Catch(&DeeError_UnboundItem)) { + /* Unbound... */ + } else if (DeeError_Catch(&DeeError_IndexError)) { + return 1; /* RHS got smaller... -> lhs > rhs */ + } else { + goto err; + } + } + rhs_elem = (*rhs_getitem_index)(rhs, i); + if unlikely(!rhs_elem) { + if (DeeError_Catch(&DeeError_UnboundItem)) { + /* Unbound... */ + } else if (DeeError_Catch(&DeeError_IndexError)) { + Dee_XDecref(lhs_elem); + return 1; /* RHS got smaller... -> lhs > rhs */ + } else { + Dee_XDecref(lhs_elem); + goto err; + } + } + if (!lhs_elem || !rhs_elem) { + if (!lhs_elem && !rhs_elem) + continue; /* Both unbound */ + if (lhs_elem) { + Dee_Decref(lhs_elem); + } else { + Dee_Decref(rhs_elem); + } +#ifdef DEFINE_compareeq + return 1; /* Not-equal */ +#else /* DEFINE_compareeq */ + return lhs_elem ? 1 : -1; +#endif /* !DEFINE_compareeq */ + } + temp = LOCAL_DeeObject_Compare(lhs_elem, rhs_elem); + Dee_Decref(rhs_elem); + Dee_Decref(lhs_elem); + if (temp != 0) + return temp; + if (DeeThread_CheckInterrupt()) + goto err; + } +#ifdef DEFINE_compareeq + return 0; /* Equal */ +#else /* DEFINE_compareeq */ + return Dee_Compare(lhs_size, lhs_size); +#endif /* !DEFINE_compareeq */ +err: + return Dee_COMPARE_ERR; +} + +INTERN WUNUSED NONNULL((1, 2, 3, 4, 5, 6)) int DCALL +LOCAL_seq_docompare__(lhs_sizeob_and_getitem__rhs_sizeob_and_getitem)(DeeObject *lhs, DeeObject *lhs_sizeob, DREF DeeObject *(DCALL *lhs_getitem)(DeeObject *self, DeeObject *index), + DeeObject *rhs, DeeObject *rhs_sizeob, DREF DeeObject *(DCALL *rhs_getitem)(DeeObject *self, DeeObject *index)) { + int temp; +#ifndef DEFINE_compareeq + bool common_sizeob__is__lhs_sizeob = true; +#endif /* !DEFINE_compareeq */ + DREF DeeObject *index_ob; + DeeObject *common_sizeob = lhs_sizeob; +#ifdef DEFINE_compareeq + temp = DeeObject_CompareEq(common_sizeob, rhs_sizeob); + if unlikely(temp < 0) + goto err; + if (!temp) + return 1; /* Not-equal */ +#else /* DEFINE_compareeq */ + temp = DeeObject_CompareLo(common_sizeob, rhs_sizeob); + if unlikely(temp < 0) + goto err; + if (!temp) { + common_sizeob__is__lhs_sizeob = false; + common_sizeob = rhs_sizeob; + } +#endif /* !DEFINE_compareeq */ + + index_ob = DeeObject_NewDefault(Dee_TYPE(common_sizeob)); + if unlikely(!index_ob) + goto err; + for (;;) { + DREF DeeObject *lhs_elem, *rhs_elem; + temp = DeeObject_CompareLo(index_ob, common_sizeob); + if unlikely(temp < 0) + goto err_index_ob; + if (!temp) + break; + lhs_elem = (*lhs_getitem)(lhs, index_ob); + if unlikely(!lhs_elem) { + if (DeeError_Catch(&DeeError_UnboundItem)) { + /* Unbound... */ + } else if (DeeError_Catch(&DeeError_IndexError)) { + Dee_Decref(index_ob); + return -1; /* LHS got smaller... -> lhs < rhs */ + } else { + goto err_index_ob; + } + } + rhs_elem = (*rhs_getitem)(rhs, index_ob); + if unlikely(!rhs_elem) { + if (DeeError_Catch(&DeeError_UnboundItem)) { + /* Unbound... */ + } else if (DeeError_Catch(&DeeError_IndexError)) { + Dee_Decref(index_ob); + Dee_XDecref(lhs_elem); + return 1; /* RHS got smaller... -> lhs > rhs */ + } else { + Dee_XDecref(lhs_elem); + goto err_index_ob; + } + } + temp = LOCAL_DeeObject_Compare(lhs_elem, rhs_elem); + Dee_Decref(rhs_elem); + Dee_Decref(lhs_elem); + if (temp != 0) { + Dee_Decref(index_ob); + return temp; + } + if (DeeThread_CheckInterrupt()) + goto err_index_ob; + if (DeeObject_Inc(&index_ob)) + goto err_index_ob; + } + Dee_Decref(index_ob); +#ifdef DEFINE_compareeq + return 0; /* Equal */ +#else /* DEFINE_compareeq */ + if (!common_sizeob__is__lhs_sizeob) + return 1; /* lhs_size > rhs_size */ + temp = DeeObject_CompareEq(lhs_sizeob, rhs_sizeob); + if unlikely(temp < 0) + goto err; + return temp ? 0 : -1; +#endif /* !DEFINE_compareeq */ +err_index_ob: + Dee_Decref(index_ob); +err: + return Dee_COMPARE_ERR; +} + + + + + + +/************************************************************************/ +/* Implementations when "lhs" should be accessed using typed sizeob+getitem. */ +/************************************************************************/ +INTERN WUNUSED NONNULL((1, 2, 3, 4, 5, 7)) int DCALL +LOCAL_seq_docompare__(lhs_tsizeob_and_getitem__rhs_size_and_getitem_index_fast)(DeeTypeObject *tp_lhs, DeeObject *lhs, DeeObject *lhs_sizeob, DREF DeeObject *(DCALL *lhs_tgetitem)(DeeTypeObject *tp_self, DeeObject *self, DeeObject *index), + DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_getitem_index_fast)(DeeObject *self, size_t index)) { + size_t i, common_size = rhs_size; + size_t lhs_size = object_to_size_with_overflow_handler(lhs_sizeob); + if unlikely(lhs_size == (size_t)-1) + goto err; +#ifdef DEFINE_compareeq + if (common_size != lhs_size) + return 1; /* not-equal */ +#else /* DEFINE_compareeq */ + if (common_size > lhs_size) + common_size = lhs_size; +#endif /* DEFINE_compareeq */ + for (i = 0; i < common_size; ++i) { + int temp; + DREF DeeObject *lhs_elem, *rhs_elem; + DREF DeeObject *index_ob; + index_ob = DeeInt_NewSize(i); + if unlikely(!index_ob) + goto err; + lhs_elem = (*lhs_tgetitem)(tp_lhs, lhs, index_ob); + Dee_Decref(index_ob); + if unlikely(!lhs_elem) { + if (DeeError_Catch(&DeeError_UnboundItem)) { + /* Unbound... */ + } else if (DeeError_Catch(&DeeError_IndexError)) { + return 1; /* RHS got smaller... -> lhs > rhs */ + } else { + goto err; + } + } + rhs_elem = (*rhs_getitem_index_fast)(rhs, i); + if (!lhs_elem || !rhs_elem) { + if (!lhs_elem && !rhs_elem) + continue; /* Both unbound */ + if (rhs_elem) { + Dee_Decref(rhs_elem); + } else { + Dee_Decref(lhs_elem); + } +#ifdef DEFINE_compareeq + return 1; /* Not-equal */ +#else /* DEFINE_compareeq */ + return lhs_elem ? 1 : -1; +#endif /* !DEFINE_compareeq */ + } + temp = LOCAL_DeeObject_Compare(lhs_elem, rhs_elem); + Dee_Decref(rhs_elem); + Dee_Decref(lhs_elem); + if (temp != 0) + return temp; + } +#ifdef DEFINE_compareeq + return 0; /* Equal */ +#else /* DEFINE_compareeq */ + return Dee_Compare(lhs_size, lhs_size); +#endif /* !DEFINE_compareeq */ +err: + return Dee_COMPARE_ERR; +} + +INTERN WUNUSED NONNULL((1, 2, 3, 4, 5, 7)) int DCALL +LOCAL_seq_docompare__(lhs_tsizeob_and_getitem__rhs_size_and_trygetitem_index)(DeeTypeObject *tp_lhs, DeeObject *lhs, DeeObject *lhs_sizeob, DREF DeeObject *(DCALL *lhs_tgetitem)(DeeTypeObject *tp_self, DeeObject *self, DeeObject *index), + DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_trygetitem_index)(DeeObject *self, size_t index)) { + size_t i, common_size = rhs_size; + size_t lhs_size = object_to_size_with_overflow_handler(lhs_sizeob); + if unlikely(lhs_size == (size_t)-1) + goto err; +#ifdef DEFINE_compareeq + if (common_size != lhs_size) + return 1; /* not-equal */ +#else /* DEFINE_compareeq */ + if (common_size > lhs_size) + common_size = lhs_size; +#endif /* DEFINE_compareeq */ + for (i = 0; i < common_size; ++i) { + int temp; + DREF DeeObject *lhs_elem, *rhs_elem; + DREF DeeObject *index_ob; + index_ob = DeeInt_NewSize(i); + if unlikely(!index_ob) + goto err; + lhs_elem = (*lhs_tgetitem)(tp_lhs, lhs, index_ob); + Dee_Decref(index_ob); + if unlikely(!lhs_elem) { + if (DeeError_Catch(&DeeError_UnboundItem)) { + /* Unbound... */ + } else if (DeeError_Catch(&DeeError_IndexError)) { + return 1; /* RHS got smaller... -> lhs > rhs */ + } else { + goto err; + } + } + rhs_elem = (*rhs_trygetitem_index)(rhs, i); + if unlikely(!rhs_elem) { + Dee_XDecref(lhs_elem); + goto err; + } + if (!lhs_elem || (rhs_elem == ITER_DONE)) { + if (!lhs_elem && (rhs_elem == ITER_DONE)) + continue; /* Both unbound */ + if (lhs_elem) { + Dee_Decref(lhs_elem); + } else { + Dee_Decref(rhs_elem); + } +#ifdef DEFINE_compareeq + return 1; /* Not-equal */ +#else /* DEFINE_compareeq */ + return lhs_elem ? 1 : -1; +#endif /* !DEFINE_compareeq */ + } + temp = LOCAL_DeeObject_Compare(lhs_elem, rhs_elem); + Dee_Decref(rhs_elem); + Dee_Decref(lhs_elem); + if (temp != 0) + return temp; + if (DeeThread_CheckInterrupt()) + goto err; + } +#ifdef DEFINE_compareeq + return 0; /* Equal */ +#else /* DEFINE_compareeq */ + return Dee_Compare(lhs_size, lhs_size); +#endif /* !DEFINE_compareeq */ +err: + return Dee_COMPARE_ERR; +} + +INTERN WUNUSED NONNULL((1, 2, 3, 4, 5, 7)) int DCALL +LOCAL_seq_docompare__(lhs_tsizeob_and_getitem__rhs_size_and_getitem_index)(DeeTypeObject *tp_lhs, DeeObject *lhs, DeeObject *lhs_sizeob, DREF DeeObject *(DCALL *lhs_tgetitem)(DeeTypeObject *tp_self, DeeObject *self, DeeObject *index), + DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_getitem_index)(DeeObject *self, size_t index)) { + size_t i, common_size = rhs_size; + size_t lhs_size = object_to_size_with_overflow_handler(lhs_sizeob); + if unlikely(lhs_size == (size_t)-1) + goto err; +#ifdef DEFINE_compareeq + if (common_size != lhs_size) + return 1; /* not-equal */ +#else /* DEFINE_compareeq */ + if (common_size > lhs_size) + common_size = lhs_size; +#endif /* DEFINE_compareeq */ + for (i = 0; i < common_size; ++i) { + int temp; + DREF DeeObject *lhs_elem, *rhs_elem; + DREF DeeObject *index_ob; + index_ob = DeeInt_NewSize(i); + if unlikely(!index_ob) + goto err; + lhs_elem = (*lhs_tgetitem)(tp_lhs, lhs, index_ob); + Dee_Decref(index_ob); + if unlikely(!lhs_elem) { + if (DeeError_Catch(&DeeError_UnboundItem)) { + /* Unbound... */ + } else if (DeeError_Catch(&DeeError_IndexError)) { + return 1; /* RHS got smaller... -> lhs > rhs */ + } else { + goto err; + } + } + rhs_elem = (*rhs_getitem_index)(rhs, i); + if unlikely(!rhs_elem) { + if (DeeError_Catch(&DeeError_UnboundItem)) { + /* Unbound... */ + } else if (DeeError_Catch(&DeeError_IndexError)) { + Dee_XDecref(lhs_elem); + return 1; /* RHS got smaller... -> lhs > rhs */ + } else { + Dee_XDecref(lhs_elem); + goto err; + } + } + if (!lhs_elem || !rhs_elem) { + if (!lhs_elem && !rhs_elem) + continue; /* Both unbound */ + if (lhs_elem) { + Dee_Decref(lhs_elem); + } else { + Dee_Decref(rhs_elem); + } +#ifdef DEFINE_compareeq + return 1; /* Not-equal */ +#else /* DEFINE_compareeq */ + return lhs_elem ? 1 : -1; +#endif /* !DEFINE_compareeq */ + } + temp = LOCAL_DeeObject_Compare(lhs_elem, rhs_elem); + Dee_Decref(rhs_elem); + Dee_Decref(lhs_elem); + if (temp != 0) + return temp; + if (DeeThread_CheckInterrupt()) + goto err; + } +#ifdef DEFINE_compareeq + return 0; /* Equal */ +#else /* DEFINE_compareeq */ + return Dee_Compare(lhs_size, lhs_size); +#endif /* !DEFINE_compareeq */ +err: + return Dee_COMPARE_ERR; +} + +INTERN WUNUSED NONNULL((1, 2, 3, 4, 5, 6, 7)) int DCALL +LOCAL_seq_docompare__(lhs_tsizeob_and_getitem__rhs_sizeob_and_getitem)(DeeTypeObject *tp_lhs, DeeObject *lhs, DeeObject *lhs_sizeob, DREF DeeObject *(DCALL *lhs_tgetitem)(DeeTypeObject *tp_self, DeeObject *self, DeeObject *index), + DeeObject *rhs, DeeObject *rhs_sizeob, DREF DeeObject *(DCALL *rhs_getitem)(DeeObject *self, DeeObject *index)) { + int temp; +#ifndef DEFINE_compareeq + bool common_sizeob__is__lhs_sizeob = true; +#endif /* !DEFINE_compareeq */ + DREF DeeObject *index_ob; + DeeObject *common_sizeob = lhs_sizeob; +#ifdef DEFINE_compareeq + temp = DeeObject_CompareEq(common_sizeob, rhs_sizeob); + if unlikely(temp < 0) + goto err; + if (!temp) + return 1; /* Not-equal */ +#else /* DEFINE_compareeq */ + temp = DeeObject_CompareLo(common_sizeob, rhs_sizeob); + if unlikely(temp < 0) + goto err; + if (!temp) { + common_sizeob__is__lhs_sizeob = false; + common_sizeob = rhs_sizeob; + } +#endif /* !DEFINE_compareeq */ + + index_ob = DeeObject_NewDefault(Dee_TYPE(common_sizeob)); + if unlikely(!index_ob) + goto err; + for (;;) { + DREF DeeObject *lhs_elem, *rhs_elem; + temp = DeeObject_CompareLo(index_ob, common_sizeob); + if unlikely(temp < 0) + goto err_index_ob; + if (!temp) + break; + lhs_elem = (*lhs_tgetitem)(tp_lhs, lhs, index_ob); + if unlikely(!lhs_elem) { + if (DeeError_Catch(&DeeError_UnboundItem)) { + /* Unbound... */ + } else if (DeeError_Catch(&DeeError_IndexError)) { + Dee_Decref(index_ob); + return -1; /* LHS got smaller... -> lhs < rhs */ + } else { + goto err_index_ob; + } + } + rhs_elem = (*rhs_getitem)(rhs, index_ob); + if unlikely(!rhs_elem) { + if (DeeError_Catch(&DeeError_UnboundItem)) { + /* Unbound... */ + } else if (DeeError_Catch(&DeeError_IndexError)) { + Dee_Decref(index_ob); + Dee_XDecref(lhs_elem); + return 1; /* RHS got smaller... -> lhs > rhs */ + } else { + Dee_XDecref(lhs_elem); + goto err_index_ob; + } + } + temp = LOCAL_DeeObject_Compare(lhs_elem, rhs_elem); + Dee_Decref(rhs_elem); + Dee_Decref(lhs_elem); + if (temp != 0) { + Dee_Decref(index_ob); + return temp; + } + if (DeeThread_CheckInterrupt()) + goto err_index_ob; + if (DeeObject_Inc(&index_ob)) + goto err_index_ob; + } + Dee_Decref(index_ob); +#ifdef DEFINE_compareeq + return 0; /* Equal */ +#else /* DEFINE_compareeq */ + if (!common_sizeob__is__lhs_sizeob) + return 1; /* lhs_size > rhs_size */ + temp = DeeObject_CompareEq(lhs_sizeob, rhs_sizeob); + if unlikely(temp < 0) + goto err; + return temp ? 0 : -1; +#endif /* !DEFINE_compareeq */ +err_index_ob: + Dee_Decref(index_ob); +err: + return Dee_COMPARE_ERR; +} + + +#undef LOCAL_DeeObject_Compare + +DECL_END + +#undef LOCAL_seq_compare__ +#undef LOCAL_seq_docompare__ +#undef DEFINE_compareeq +#undef DEFINE_compare diff --git a/src/deemon/objects/seq/default-compare.c b/src/deemon/objects/seq/default-compare.c new file mode 100644 index 000000000..c141399c0 --- /dev/null +++ b/src/deemon/objects/seq/default-compare.c @@ -0,0 +1,90 @@ +/* Copyright (c) 2018-2024 Griefer@Work * + * * + * This software is provided 'as-is', without any express or implied * + * warranty. In no event will the authors be held liable for any damages * + * arising from the use of this software. * + * * + * Permission is granted to anyone to use this software for any purpose, * + * including commercial applications, and to alter it and redistribute it * + * freely, subject to the following restrictions: * + * * + * 1. The origin of this software must not be misrepresented; you must not * + * claim that you wrote the original software. If you use this software * + * in a product, an acknowledgement (see the following) in the product * + * documentation is required: * + * Portions Copyright (c) 2018-2024 Griefer@Work * + * 2. Altered source versions must be plainly marked as such, and must not be * + * misrepresented as being the original software. * + * 3. This notice may not be removed or altered from any source distribution. * + */ +#ifndef GUARD_DEEMON_OBJECTS_SEQ_DEFAULT_COMPARE_C +#define GUARD_DEEMON_OBJECTS_SEQ_DEFAULT_COMPARE_C 1 + +#include +#include +#include +/**/ + +#include "default-compare.h" + +DECL_BEGIN + +/* @return: 1: "sc_lfr_rhs" does contain "lhs_elem" + * @return: -2: "sc_lfr_rhs" does not contain "lhs_elem" + * @return: -1: Error */ +INTERN WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL +set_compare__lhs_foreach__rhs__cb(void *arg, DeeObject *lhs_elem) { + int contains; + DREF DeeObject *contains_ob; + struct set_compare__lhs_foreach__rhs__data *data; + data = (struct set_compare__lhs_foreach__rhs__data *)arg; + contains_ob = (*data->sc_lfr_rcontains)(data->sc_lfr_rhs, lhs_elem); + if unlikely(!contains_ob) + goto err; + contains = DeeObject_BoolInherited(contains_ob); + if unlikely(contains < 0) + goto err; + if (!contains) + return -2; /* Not contained */ + return 1; +err: + return -1; +} + + +/* @return: 1: "mc_lfr_rhs" does contain "lhs_key" with the same value + * @return: -2: "mc_lfr_rhs" does not contain "lhs_key", or has a different value for it + * @return: -1: Error */ +INTERN WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL +map_compare__lhs_foreach__rhs__cb(void *arg, DeeObject *lhs_key, DeeObject *lhs_value) { + int values_eq; + DREF DeeObject *rhs_value; + struct map_compare__lhs_foreach__rhs__data *data; + data = (struct map_compare__lhs_foreach__rhs__data *)arg; + rhs_value = (*data->mc_lfr_rtrygetitem)(data->mc_lfr_rhs, lhs_key); + if unlikely(!rhs_value) + goto err; + if (rhs_value == ITER_DONE) + return -2; /* Missing key */ + values_eq = DeeObject_CompareEq(lhs_value, rhs_value); + Dee_Decref(rhs_value); + if unlikely(values_eq < 0) + goto err; + if (!values_eq) + return -2; /* Non-equal values */ + return 1; +err: + return -1; +} + + +DECL_END + +#ifndef __INTELLISENSE__ +#define DEFINE_compare +#include "default-compare-impl.c.inl" +#define DEFINE_compareeq +#include "default-compare-impl.c.inl" +#endif /* !__INTELLISENSE__ */ + +#endif /* !GUARD_DEEMON_OBJECTS_SEQ_DEFAULT_COMPARE_C */ diff --git a/src/deemon/objects/seq/default-compare.h b/src/deemon/objects/seq/default-compare.h new file mode 100644 index 000000000..32ab3430c --- /dev/null +++ b/src/deemon/objects/seq/default-compare.h @@ -0,0 +1,169 @@ +/* Copyright (c) 2018-2024 Griefer@Work * + * * + * This software is provided 'as-is', without any express or implied * + * warranty. In no event will the authors be held liable for any damages * + * arising from the use of this software. * + * * + * Permission is granted to anyone to use this software for any purpose, * + * including commercial applications, and to alter it and redistribute it * + * freely, subject to the following restrictions: * + * * + * 1. The origin of this software must not be misrepresented; you must not * + * claim that you wrote the original software. If you use this software * + * in a product, an acknowledgement (see the following) in the product * + * documentation is required: * + * Portions Copyright (c) 2018-2024 Griefer@Work * + * 2. Altered source versions must be plainly marked as such, and must not be * + * misrepresented as being the original software. * + * 3. This notice may not be removed or altered from any source distribution. * + */ +#ifndef GUARD_DEEMON_OBJECTS_SEQ_DEFAULT_COMPARE_H +#define GUARD_DEEMON_OBJECTS_SEQ_DEFAULT_COMPARE_H 1 + +#include +#include + +DECL_BEGIN + +/* Return values for `seq_compareeq__*__cb' callbacks. */ +#define SEQ_COMPAREEQ_FOREACH_RESULT_EQUAL 0 +#define SEQ_COMPAREEQ_FOREACH_RESULT_ERROR (-1) +#define SEQ_COMPAREEQ_FOREACH_RESULT_NOTEQUAL (-2) + +/* Return values for `seq_compare__*__cb' callbacks. */ +#define SEQ_COMPARE_FOREACH_RESULT_EQUAL 0 +#define SEQ_COMPARE_FOREACH_RESULT_ERROR (-1) +#define SEQ_COMPARE_FOREACH_RESULT_LESS (-2) +#define SEQ_COMPARE_FOREACH_RESULT_GREATER (-3) + + +struct seq_compareforeach__size_and_getitem_index__data { + DeeObject *scf_sgi_other; /* [1..1] "other" sequence */ + size_t scf_sgi_osize; /* Size of the "other" sequence */ + size_t scf_sgi_oindex; /* Next index to load the element of */ + /* [1..1] Callback for loading elements of "scf_sgi_other" (convention depends on used callback) */ + WUNUSED_T NONNULL_T((1)) DREF DeeObject *(DCALL *scf_sgi_ogetitem_index)(DeeObject *self, size_t index); +}; +INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL seq_compareeq__lhs_foreach__rhs_size_and_getitem_index_fast__cb(void *arg, DeeObject *lhs_elem); +INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL seq_compareeq__lhs_foreach__rhs_size_and_trygetitem_index__cb(void *arg, DeeObject *lhs_elem); +INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL seq_compareeq__lhs_foreach__rhs_size_and_getitem_index__cb(void *arg, DeeObject *lhs_elem); +INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL seq_compare__lhs_foreach__rhs_size_and_getitem_index_fast__cb(void *arg, DeeObject *lhs_elem); +INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL seq_compare__lhs_foreach__rhs_size_and_trygetitem_index__cb(void *arg, DeeObject *lhs_elem); +INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL seq_compare__lhs_foreach__rhs_size_and_getitem_index__cb(void *arg, DeeObject *lhs_elem); +INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL seq_compareeq__lhs_size_and_getitem_index_fast__rhs_foreach__cb(void *arg, DeeObject *rhs_elem); +INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL seq_compareeq__lhs_size_and_trygetitem_index__rhs_foreach__cb(void *arg, DeeObject *rhs_elem); +INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL seq_compareeq__lhs_size_and_getitem_index__rhs_foreach__cb(void *arg, DeeObject *rhs_elem); +INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL seq_compare__lhs_size_and_getitem_index_fast__rhs_foreach__cb(void *arg, DeeObject *rhs_elem); +INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL seq_compare__lhs_size_and_trygetitem_index__rhs_foreach__cb(void *arg, DeeObject *rhs_elem); +INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL seq_compare__lhs_size_and_getitem_index__rhs_foreach__cb(void *arg, DeeObject *rhs_elem); + +struct seq_compare_foreach__sizeob_and_getitem__data { + DeeObject *scf_sg_other; /* [1..1] "other" sequence */ + DeeObject *scf_sg_osize; /* [1..1] Size of the "other" sequence */ + DREF DeeObject *scf_sg_oindex; /* [1..1] Next index to load the element of */ + /* [1..1] Callback for loading elements of "scf_sg_other" (convention depends on used callback) */ + WUNUSED_T NONNULL_T((1)) DREF DeeObject *(DCALL *scf_sg_ogetitem)(DeeObject *self, DeeObject *index); +}; +INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL seq_compareeq__lhs_foreach__rhs_sizeob_and_getitem__cb(void *arg, DeeObject *lhs_elem); +INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL seq_compare__lhs_foreach__rhs_sizeob_and_getitem__cb(void *arg, DeeObject *lhs_elem); +INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL seq_compareeq__lhs_sizeob_and_getitem__rhs_foreach__cb(void *arg, DeeObject *rhs_elem); +INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL seq_compare__lhs_sizeob_and_getitem__rhs_foreach__cb(void *arg, DeeObject *rhs_elem); + +struct seq_compare_foreach__tsizeob_and_getitem__data { + DeeTypeObject *scf_tsg_tpother; /* [1..1] Effective type for "scf_tsg_other" */ + DeeObject *scf_tsg_other; /* [1..1] "other" sequence */ + DeeObject *scf_tsg_osize; /* [1..1] Size of the "other" sequence */ + DREF DeeObject *scf_tsg_oindex; /* [1..1] Next index to load the element of */ + /* [1..1] Callback for loading elements of "scf_tsg_other" (convention depends on used callback) */ + WUNUSED_T NONNULL_T((1, 2, 3)) DREF DeeObject *(DCALL *scf_tsg_otgetitem)(DeeTypeObject *tp_self, DeeObject *self, DeeObject *index); +}; +/*INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL seq_compareeq__lhs_foreach__trhs_sizeob_and_getitem__cb(void *arg, DeeObject *lhs_elem);*/ +/*INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL seq_compare__lhs_foreach__trhs_sizeob_and_getitem__cb(void *arg, DeeObject *lhs_elem);*/ +INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL seq_compareeq__tlhs_sizeob_and_getitem__rhs_foreach__cb(void *arg, DeeObject *rhs_elem); +INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL seq_compare__tlhs_sizeob_and_getitem__rhs_foreach__cb(void *arg, DeeObject *rhs_elem); + +/* @param: arg: [1..1] DeeObject *other_iter; */ +INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL seq_compareeq__lhs_foreach__rhs_iter__cb(void *arg, DeeObject *lhs_elem); +INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL seq_compare__lhs_foreach__rhs_iter__cb(void *arg, DeeObject *lhs_elem); +/*INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL seq_compareeq__lhs_iter__rhs_foreach__cb(void *arg, DeeObject *rhs_elem);*/ +/*INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL seq_compare__lhs_iter__rhs_foreach__cb(void *arg, DeeObject *rhs_elem);*/ + + +/* Implementations when "lhs" should be accessed using size+getitem_index_fast. */ +INTDEF WUNUSED NONNULL((1, 3, 4, 6)) int DCALL seq_docompareeq__lhs_size_and_getitem_index_fast__rhs_size_and_getitem_index_fast(DeeObject *lhs, size_t lhs_size, DREF DeeObject *(DCALL *lhs_getitem_index_fast)(DeeObject *self, size_t index), DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_getitem_index_fast)(DeeObject *self, size_t index)); +INTDEF WUNUSED NONNULL((1, 3, 4, 6)) int DCALL seq_docompareeq__lhs_size_and_getitem_index_fast__rhs_size_and_trygetitem_index(DeeObject *lhs, size_t lhs_size, DREF DeeObject *(DCALL *lhs_getitem_index_fast)(DeeObject *self, size_t index), DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_trygetitem_index)(DeeObject *self, size_t index)); +INTDEF WUNUSED NONNULL((1, 3, 4, 6)) int DCALL seq_docompareeq__lhs_size_and_getitem_index_fast__rhs_size_and_getitem_index(DeeObject *lhs, size_t lhs_size, DREF DeeObject *(DCALL *lhs_getitem_index_fast)(DeeObject *self, size_t index), DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_getitem_index)(DeeObject *self, size_t index)); +INTDEF WUNUSED NONNULL((1, 3, 4, 5, 6)) int DCALL seq_docompareeq__lhs_size_and_getitem_index_fast__rhs_sizeob_and_getitem(DeeObject *lhs, size_t lhs_size, DREF DeeObject *(DCALL *lhs_getitem_index_fast)(DeeObject *self, size_t index), DeeObject *rhs, DeeObject *rhs_sizeob, DREF DeeObject *(DCALL *rhs_getitem)(DeeObject *self, DeeObject *index)); +INTDEF WUNUSED NONNULL((1, 3, 4, 6)) int DCALL seq_docompare__lhs_size_and_getitem_index_fast__rhs_size_and_getitem_index_fast(DeeObject *lhs, size_t lhs_size, DREF DeeObject *(DCALL *lhs_getitem_index_fast)(DeeObject *self, size_t index), DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_getitem_index_fast)(DeeObject *self, size_t index)); +INTDEF WUNUSED NONNULL((1, 3, 4, 6)) int DCALL seq_docompare__lhs_size_and_getitem_index_fast__rhs_size_and_trygetitem_index(DeeObject *lhs, size_t lhs_size, DREF DeeObject *(DCALL *lhs_getitem_index_fast)(DeeObject *self, size_t index), DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_trygetitem_index)(DeeObject *self, size_t index)); +INTDEF WUNUSED NONNULL((1, 3, 4, 6)) int DCALL seq_docompare__lhs_size_and_getitem_index_fast__rhs_size_and_getitem_index(DeeObject *lhs, size_t lhs_size, DREF DeeObject *(DCALL *lhs_getitem_index_fast)(DeeObject *self, size_t index), DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_getitem_index)(DeeObject *self, size_t index)); +INTDEF WUNUSED NONNULL((1, 3, 4, 5, 6)) int DCALL seq_docompare__lhs_size_and_getitem_index_fast__rhs_sizeob_and_getitem(DeeObject *lhs, size_t lhs_size, DREF DeeObject *(DCALL *lhs_getitem_index_fast)(DeeObject *self, size_t index), DeeObject *rhs, DeeObject *rhs_sizeob, DREF DeeObject *(DCALL *rhs_getitem)(DeeObject *self, DeeObject *index)); + +/* Implementations when "lhs" should be accessed using size+trygetitem_index. */ +INTDEF WUNUSED NONNULL((1, 3, 4, 6)) int DCALL seq_docompareeq__lhs_size_and_trygetitem_index__rhs_size_and_getitem_index_fast(DeeObject *lhs, size_t lhs_size, DREF DeeObject *(DCALL *lhs_trygetitem_index)(DeeObject *self, size_t index), DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_getitem_index_fast)(DeeObject *self, size_t index)); +INTDEF WUNUSED NONNULL((1, 3, 4, 6)) int DCALL seq_docompareeq__lhs_size_and_trygetitem_index__rhs_size_and_trygetitem_index(DeeObject *lhs, size_t lhs_size, DREF DeeObject *(DCALL *lhs_trygetitem_index)(DeeObject *self, size_t index), DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_trygetitem_index)(DeeObject *self, size_t index)); +INTDEF WUNUSED NONNULL((1, 3, 4, 6)) int DCALL seq_docompareeq__lhs_size_and_trygetitem_index__rhs_size_and_getitem_index(DeeObject *lhs, size_t lhs_size, DREF DeeObject *(DCALL *lhs_trygetitem_index)(DeeObject *self, size_t index), DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_getitem_index)(DeeObject *self, size_t index)); +INTDEF WUNUSED NONNULL((1, 3, 4, 5, 6)) int DCALL seq_docompareeq__lhs_size_and_trygetitem_index__rhs_sizeob_and_getitem(DeeObject *lhs, size_t lhs_size, DREF DeeObject *(DCALL *lhs_trygetitem_index)(DeeObject *self, size_t index), DeeObject *rhs, DeeObject *rhs_sizeob, DREF DeeObject *(DCALL *rhs_getitem)(DeeObject *self, DeeObject *index)); +INTDEF WUNUSED NONNULL((1, 3, 4, 6)) int DCALL seq_docompare__lhs_size_and_trygetitem_index__rhs_size_and_getitem_index_fast(DeeObject *lhs, size_t lhs_size, DREF DeeObject *(DCALL *lhs_trygetitem_index)(DeeObject *self, size_t index), DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_getitem_index_fast)(DeeObject *self, size_t index)); +INTDEF WUNUSED NONNULL((1, 3, 4, 6)) int DCALL seq_docompare__lhs_size_and_trygetitem_index__rhs_size_and_trygetitem_index(DeeObject *lhs, size_t lhs_size, DREF DeeObject *(DCALL *lhs_trygetitem_index)(DeeObject *self, size_t index), DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_trygetitem_index)(DeeObject *self, size_t index)); +INTDEF WUNUSED NONNULL((1, 3, 4, 6)) int DCALL seq_docompare__lhs_size_and_trygetitem_index__rhs_size_and_getitem_index(DeeObject *lhs, size_t lhs_size, DREF DeeObject *(DCALL *lhs_trygetitem_index)(DeeObject *self, size_t index), DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_getitem_index)(DeeObject *self, size_t index)); +INTDEF WUNUSED NONNULL((1, 3, 4, 5, 6)) int DCALL seq_docompare__lhs_size_and_trygetitem_index__rhs_sizeob_and_getitem(DeeObject *lhs, size_t lhs_size, DREF DeeObject *(DCALL *lhs_trygetitem_index)(DeeObject *self, size_t index), DeeObject *rhs, DeeObject *rhs_sizeob, DREF DeeObject *(DCALL *rhs_getitem)(DeeObject *self, DeeObject *index)); + +/* Implementations when "lhs" should be accessed using size+getitem_index. */ +INTDEF WUNUSED NONNULL((1, 3, 4, 6)) int DCALL seq_docompareeq__lhs_size_and_getitem_index__rhs_size_and_getitem_index_fast(DeeObject *lhs, size_t lhs_size, DREF DeeObject *(DCALL *lhs_getitem_index)(DeeObject *self, size_t index), DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_getitem_index_fast)(DeeObject *self, size_t index)); +INTDEF WUNUSED NONNULL((1, 3, 4, 6)) int DCALL seq_docompareeq__lhs_size_and_getitem_index__rhs_size_and_trygetitem_index(DeeObject *lhs, size_t lhs_size, DREF DeeObject *(DCALL *lhs_getitem_index)(DeeObject *self, size_t index), DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_trygetitem_index)(DeeObject *self, size_t index)); +INTDEF WUNUSED NONNULL((1, 3, 4, 6)) int DCALL seq_docompareeq__lhs_size_and_getitem_index__rhs_size_and_getitem_index(DeeObject *lhs, size_t lhs_size, DREF DeeObject *(DCALL *lhs_getitem_index)(DeeObject *self, size_t index), DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_getitem_index)(DeeObject *self, size_t index)); +INTDEF WUNUSED NONNULL((1, 3, 4, 5, 6)) int DCALL seq_docompareeq__lhs_size_and_getitem_index__rhs_sizeob_and_getitem(DeeObject *lhs, size_t lhs_size, DREF DeeObject *(DCALL *lhs_getitem_index)(DeeObject *self, size_t index), DeeObject *rhs, DeeObject *rhs_sizeob, DREF DeeObject *(DCALL *rhs_getitem)(DeeObject *self, DeeObject *index)); +INTDEF WUNUSED NONNULL((1, 3, 4, 6)) int DCALL seq_docompare__lhs_size_and_getitem_index__rhs_size_and_getitem_index_fast(DeeObject *lhs, size_t lhs_size, DREF DeeObject *(DCALL *lhs_getitem_index)(DeeObject *self, size_t index), DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_getitem_index_fast)(DeeObject *self, size_t index)); +INTDEF WUNUSED NONNULL((1, 3, 4, 6)) int DCALL seq_docompare__lhs_size_and_getitem_index__rhs_size_and_trygetitem_index(DeeObject *lhs, size_t lhs_size, DREF DeeObject *(DCALL *lhs_getitem_index)(DeeObject *self, size_t index), DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_trygetitem_index)(DeeObject *self, size_t index)); +INTDEF WUNUSED NONNULL((1, 3, 4, 6)) int DCALL seq_docompare__lhs_size_and_getitem_index__rhs_size_and_getitem_index(DeeObject *lhs, size_t lhs_size, DREF DeeObject *(DCALL *lhs_getitem_index)(DeeObject *self, size_t index), DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_getitem_index)(DeeObject *self, size_t index)); +INTDEF WUNUSED NONNULL((1, 3, 4, 5, 6)) int DCALL seq_docompare__lhs_size_and_getitem_index__rhs_sizeob_and_getitem(DeeObject *lhs, size_t lhs_size, DREF DeeObject *(DCALL *lhs_getitem_index)(DeeObject *self, size_t index), DeeObject *rhs, DeeObject *rhs_sizeob, DREF DeeObject *(DCALL *rhs_getitem)(DeeObject *self, DeeObject *index)); + +/* Implementations when "lhs" should be accessed using sizeob+getitem. */ +INTDEF WUNUSED NONNULL((1, 2, 3, 4, 6)) int DCALL seq_docompareeq__lhs_sizeob_and_getitem__rhs_size_and_getitem_index_fast(DeeObject *lhs, DeeObject *lhs_sizeob, DREF DeeObject *(DCALL *lhs_getitem)(DeeObject *self, DeeObject *index), DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_getitem_index_fast)(DeeObject *self, size_t index)); +INTDEF WUNUSED NONNULL((1, 2, 3, 4, 6)) int DCALL seq_docompareeq__lhs_sizeob_and_getitem__rhs_size_and_trygetitem_index(DeeObject *lhs, DeeObject *lhs_sizeob, DREF DeeObject *(DCALL *lhs_getitem)(DeeObject *self, DeeObject *index), DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_trygetitem_index)(DeeObject *self, size_t index)); +INTDEF WUNUSED NONNULL((1, 2, 3, 4, 6)) int DCALL seq_docompareeq__lhs_sizeob_and_getitem__rhs_size_and_getitem_index(DeeObject *lhs, DeeObject *lhs_sizeob, DREF DeeObject *(DCALL *lhs_getitem)(DeeObject *self, DeeObject *index), DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_getitem_index)(DeeObject *self, size_t index)); +INTDEF WUNUSED NONNULL((1, 2, 3, 4, 5, 6)) int DCALL seq_docompareeq__lhs_sizeob_and_getitem__rhs_sizeob_and_getitem(DeeObject *lhs, DeeObject *lhs_sizeob, DREF DeeObject *(DCALL *lhs_getitem)(DeeObject *self, DeeObject *index), DeeObject *rhs, DeeObject *rhs_sizeob, DREF DeeObject *(DCALL *rhs_getitem)(DeeObject *self, DeeObject *index)); +INTDEF WUNUSED NONNULL((1, 2, 3, 4, 6)) int DCALL seq_docompare__lhs_sizeob_and_getitem__rhs_size_and_getitem_index_fast(DeeObject *lhs, DeeObject *lhs_sizeob, DREF DeeObject *(DCALL *lhs_getitem)(DeeObject *self, DeeObject *index), DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_getitem_index_fast)(DeeObject *self, size_t index)); +INTDEF WUNUSED NONNULL((1, 2, 3, 4, 6)) int DCALL seq_docompare__lhs_sizeob_and_getitem__rhs_size_and_trygetitem_index(DeeObject *lhs, DeeObject *lhs_sizeob, DREF DeeObject *(DCALL *lhs_getitem)(DeeObject *self, DeeObject *index), DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_trygetitem_index)(DeeObject *self, size_t index)); +INTDEF WUNUSED NONNULL((1, 2, 3, 4, 6)) int DCALL seq_docompare__lhs_sizeob_and_getitem__rhs_size_and_getitem_index(DeeObject *lhs, DeeObject *lhs_sizeob, DREF DeeObject *(DCALL *lhs_getitem)(DeeObject *self, DeeObject *index), DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_getitem_index)(DeeObject *self, size_t index)); +INTDEF WUNUSED NONNULL((1, 2, 3, 4, 5, 6)) int DCALL seq_docompare__lhs_sizeob_and_getitem__rhs_sizeob_and_getitem(DeeObject *lhs, DeeObject *lhs_sizeob, DREF DeeObject *(DCALL *lhs_getitem)(DeeObject *self, DeeObject *index), DeeObject *rhs, DeeObject *rhs_sizeob, DREF DeeObject *(DCALL *rhs_getitem)(DeeObject *self, DeeObject *index)); + +/* Implementations when "lhs" should be accessed using typed sizeob+getitem. */ +INTDEF WUNUSED NONNULL((1, 2, 3, 4, 5, 7)) int DCALL seq_docompareeq__lhs_tsizeob_and_getitem__rhs_size_and_getitem_index_fast(DeeTypeObject *tp_lhs, DeeObject *lhs, DeeObject *lhs_sizeob, DREF DeeObject *(DCALL *lhs_tgetitem)(DeeTypeObject *tp_self, DeeObject *self, DeeObject *index), DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_getitem_index_fast)(DeeObject *self, size_t index)); +INTDEF WUNUSED NONNULL((1, 2, 3, 4, 5, 7)) int DCALL seq_docompareeq__lhs_tsizeob_and_getitem__rhs_size_and_trygetitem_index(DeeTypeObject *tp_lhs, DeeObject *lhs, DeeObject *lhs_sizeob, DREF DeeObject *(DCALL *lhs_tgetitem)(DeeTypeObject *tp_self, DeeObject *self, DeeObject *index), DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_trygetitem_index)(DeeObject *self, size_t index)); +INTDEF WUNUSED NONNULL((1, 2, 3, 4, 5, 7)) int DCALL seq_docompareeq__lhs_tsizeob_and_getitem__rhs_size_and_getitem_index(DeeTypeObject *tp_lhs, DeeObject *lhs, DeeObject *lhs_sizeob, DREF DeeObject *(DCALL *lhs_tgetitem)(DeeTypeObject *tp_self, DeeObject *self, DeeObject *index), DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_getitem_index)(DeeObject *self, size_t index)); +INTDEF WUNUSED NONNULL((1, 2, 3, 4, 5, 6, 7)) int DCALL seq_docompareeq__lhs_tsizeob_and_getitem__rhs_sizeob_and_getitem(DeeTypeObject *tp_lhs, DeeObject *lhs, DeeObject *lhs_sizeob, DREF DeeObject *(DCALL *lhs_tgetitem)(DeeTypeObject *tp_self, DeeObject *self, DeeObject *index), DeeObject *rhs, DeeObject *rhs_sizeob, DREF DeeObject *(DCALL *rhs_getitem)(DeeObject *self, DeeObject *index)); +INTDEF WUNUSED NONNULL((1, 2, 3, 4, 5, 7)) int DCALL seq_docompare__lhs_tsizeob_and_getitem__rhs_size_and_getitem_index_fast(DeeTypeObject *tp_lhs, DeeObject *lhs, DeeObject *lhs_sizeob, DREF DeeObject *(DCALL *lhs_tgetitem)(DeeTypeObject *tp_self, DeeObject *self, DeeObject *index), DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_getitem_index_fast)(DeeObject *self, size_t index)); +INTDEF WUNUSED NONNULL((1, 2, 3, 4, 5, 7)) int DCALL seq_docompare__lhs_tsizeob_and_getitem__rhs_size_and_trygetitem_index(DeeTypeObject *tp_lhs, DeeObject *lhs, DeeObject *lhs_sizeob, DREF DeeObject *(DCALL *lhs_tgetitem)(DeeTypeObject *tp_self, DeeObject *self, DeeObject *index), DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_trygetitem_index)(DeeObject *self, size_t index)); +INTDEF WUNUSED NONNULL((1, 2, 3, 4, 5, 7)) int DCALL seq_docompare__lhs_tsizeob_and_getitem__rhs_size_and_getitem_index(DeeTypeObject *tp_lhs, DeeObject *lhs, DeeObject *lhs_sizeob, DREF DeeObject *(DCALL *lhs_tgetitem)(DeeTypeObject *tp_self, DeeObject *self, DeeObject *index), DeeObject *rhs, size_t rhs_size, DREF DeeObject *(DCALL *rhs_getitem_index)(DeeObject *self, size_t index)); +INTDEF WUNUSED NONNULL((1, 2, 3, 4, 5, 6, 7)) int DCALL seq_docompare__lhs_tsizeob_and_getitem__rhs_sizeob_and_getitem(DeeTypeObject *tp_lhs, DeeObject *lhs, DeeObject *lhs_sizeob, DREF DeeObject *(DCALL *lhs_tgetitem)(DeeTypeObject *tp_self, DeeObject *self, DeeObject *index), DeeObject *rhs, DeeObject *rhs_sizeob, DREF DeeObject *(DCALL *rhs_getitem)(DeeObject *self, DeeObject *index)); + + + +struct set_compare__lhs_foreach__rhs__data { + DeeObject *sc_lfr_rhs; /* [1..1] The right-hand-side set */ + /* [1..1] The tp_contains-operator for "sc_lfr_rhs" */ + DREF DeeObject *(DCALL *sc_lfr_rcontains)(DeeObject *self, DeeObject *item); +}; +/* @return: 1: "sc_lfr_rhs" does contain "lhs_elem" + * @return: -2: "sc_lfr_rhs" does not contain "lhs_elem" + * @return: -1: Error */ +INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL set_compare__lhs_foreach__rhs__cb(void *arg, DeeObject *lhs_elem); + + +struct map_compare__lhs_foreach__rhs__data { + DeeObject *mc_lfr_rhs; /* [1..1] The right-hand-side set */ + /* [1..1] The tp_trygetitem-operator for "mc_lfr_rhs" */ + DREF DeeObject *(DCALL *mc_lfr_rtrygetitem)(DeeObject *self, DeeObject *key); +}; +/* @return: 1: "mc_lfr_rhs" does contain "lhs_key" with the same value + * @return: -2: "mc_lfr_rhs" does not contain "lhs_key", or has a different value for it + * @return: -1: Error */ +INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL map_compare__lhs_foreach__rhs__cb(void *arg, DeeObject *lhs_key, DeeObject *lhs_value); + + + +DECL_END + +#endif /* !GUARD_DEEMON_OBJECTS_SEQ_DEFAULT_COMPARE_H */ diff --git a/src/deemon/objects/seq/default-iterators.c b/src/deemon/objects/seq/default-iterators.c index 7f101290d..b83f8dd91 100644 --- a/src/deemon/objects/seq/default-iterators.c +++ b/src/deemon/objects/seq/default-iterators.c @@ -36,7 +36,7 @@ DECL_BEGIN /* DefaultIterator_WithGetItemIndex_Type */ /* DefaultIterator_WithSizeAndGetItemIndex_Type */ /* DefaultIterator_WithSizeAndGetItemIndexFast_Type */ -/* DefaultIterator_WithTryGetItemIndexAndSize_Type */ +/* DefaultIterator_WithSizeAndTryGetItemIndex_Type */ /************************************************************************/ STATIC_ASSERT(offsetof(DefaultIterator_WithGetItemIndex, digi_seq) == offsetof(DefaultIterator_WithSizeAndGetItemIndex, disgi_seq)); @@ -232,15 +232,16 @@ di_sgif_setindex(DefaultIterator_WithSizeAndGetItemIndex *self, DeeObject *value #define di_sgif_cmp di_gi_cmp #define di_stgi_cmp di_gi_cmp PRIVATE struct type_cmp di_gi_cmp = { - /* .tp_hash = */ NULL, - /* .tp_eq = */ NULL, - /* .tp_ne = */ NULL, - /* .tp_lo = */ NULL, - /* .tp_le = */ NULL, - /* .tp_gr = */ NULL, - /* .tp_ge = */ NULL, - /* .tp_nii = */ NULL, - /* .tp_compare = */ (int (DCALL *)(DeeObject *, DeeObject *))&di_gi_compare, + /* .tp_hash = */ NULL, + /* .tp_eq = */ NULL, + /* .tp_ne = */ NULL, + /* .tp_lo = */ NULL, + /* .tp_le = */ NULL, + /* .tp_gr = */ NULL, + /* .tp_ge = */ NULL, + /* .tp_nii = */ NULL, + /* .tp_compare_eq = */ (int (DCALL *)(DeeObject *, DeeObject *))&di_gi_compare, + /* .tp_compare = */ (int (DCALL *)(DeeObject *, DeeObject *))&di_gi_compare, }; #define di_stgi_members di_sgi_members @@ -398,9 +399,9 @@ INTERN DeeTypeObject DefaultIterator_WithSizeAndGetItemIndexFast_Type = { /* .tp_class_members = */ NULL }; -INTERN DeeTypeObject DefaultIterator_WithTryGetItemIndexAndSize_Type = { +INTERN DeeTypeObject DefaultIterator_WithSizeAndTryGetItemIndex_Type = { OBJECT_HEAD_INIT(&DeeType_Type), - /* .tp_name = */ "_IterWithTryGetItemIndexAndSize", + /* .tp_name = */ "_IterWithSizeAndTryGetItemIndex", /* .tp_doc = */ NULL, /* .tp_flags = */ TP_FNORMAL | TP_FFINAL, /* .tp_weakrefs = */ 0, @@ -695,15 +696,16 @@ di_tg_iter_next(DefaultIterator_WithTGetItem *__restrict self) { #define di_tg_cmp di_g_cmp PRIVATE struct type_cmp di_g_cmp = { - /* .tp_hash = */ NULL, - /* .tp_eq = */ NULL, - /* .tp_ne = */ NULL, - /* .tp_lo = */ NULL, - /* .tp_le = */ NULL, - /* .tp_gr = */ NULL, - /* .tp_ge = */ NULL, - /* .tp_nii = */ NULL, - /* .tp_compare = */ (int (DCALL *)(DeeObject *, DeeObject *))&di_g_compare, + /* .tp_hash = */ NULL, + /* .tp_eq = */ NULL, + /* .tp_ne = */ NULL, + /* .tp_lo = */ NULL, + /* .tp_le = */ NULL, + /* .tp_gr = */ NULL, + /* .tp_ge = */ NULL, + /* .tp_nii = */ NULL, + /* .tp_compare_eq = */ (int (DCALL *)(DeeObject *, DeeObject *))&di_g_compare, + /* .tp_compare = */ (int (DCALL *)(DeeObject *, DeeObject *))&di_g_compare, }; #define di_tg_members di_g_members @@ -1235,15 +1237,16 @@ di_nl_iter_next(DefaultIterator_WithNextAndLimit *self) { } PRIVATE struct type_cmp di_nl_cmp = { - /* .tp_hash = */ NULL, - /* .tp_eq = */ NULL, - /* .tp_ne = */ NULL, - /* .tp_lo = */ NULL, - /* .tp_le = */ NULL, - /* .tp_gr = */ NULL, - /* .tp_ge = */ NULL, - /* .tp_nii = */ NULL, - /* .tp_compare = */ (int (DCALL *)(DeeObject *, DeeObject *))&di_nl_compare, + /* .tp_hash = */ NULL, + /* .tp_eq = */ NULL, + /* .tp_ne = */ NULL, + /* .tp_lo = */ NULL, + /* .tp_le = */ NULL, + /* .tp_gr = */ NULL, + /* .tp_ge = */ NULL, + /* .tp_nii = */ NULL, + /* .tp_compare_eq = */ (int (DCALL *)(DeeObject *, DeeObject *))&di_nl_compare, + /* .tp_compare = */ (int (DCALL *)(DeeObject *, DeeObject *))&di_nl_compare, }; PRIVATE struct type_member tpconst di_nl_members[] = { diff --git a/src/deemon/objects/seq/default-iterators.h b/src/deemon/objects/seq/default-iterators.h index 503a3d982..008a3336c 100644 --- a/src/deemon/objects/seq/default-iterators.h +++ b/src/deemon/objects/seq/default-iterators.h @@ -127,7 +127,7 @@ typedef struct { INTDEF DeeTypeObject DefaultIterator_WithGetItemIndex_Type; /* DefaultIterator_WithGetItemIndex */ INTDEF DeeTypeObject DefaultIterator_WithSizeAndGetItemIndex_Type; /* DefaultIterator_WithSizeAndGetItemIndex */ INTDEF DeeTypeObject DefaultIterator_WithSizeAndGetItemIndexFast_Type; /* DefaultIterator_WithSizeAndGetItemIndex */ -INTDEF DeeTypeObject DefaultIterator_WithTryGetItemIndexAndSize_Type; /* DefaultIterator_WithSizeAndGetItemIndex */ +INTDEF DeeTypeObject DefaultIterator_WithSizeAndTryGetItemIndex_Type; /* DefaultIterator_WithSizeAndGetItemIndex */ INTDEF DeeTypeObject DefaultIterator_WithGetItem_Type; /* DefaultIterator_WithGetItem */ INTDEF DeeTypeObject DefaultIterator_WithTGetItem_Type; /* DefaultIterator_WithTGetItem */ diff --git a/src/deemon/objects/seq/default-sequences.c b/src/deemon/objects/seq/default-sequences.c index 61e05ab1c..5c161bd07 100644 --- a/src/deemon/objects/seq/default-sequences.c +++ b/src/deemon/objects/seq/default-sequences.c @@ -44,7 +44,7 @@ DECL_BEGIN /************************************************************************/ /* DefaultSequence_WithSizeAndGetItemIndex_Type */ /* DefaultSequence_WithSizeAndGetItemIndexFast_Type */ -/* DefaultSequence_WithTryGetItemIndexAndSize_Type */ +/* DefaultSequence_WithSizeAndTryGetItemIndex_Type */ /************************************************************************/ #define ds_sgif_fini ds_sgi_fini @@ -108,7 +108,7 @@ ds_stgi_iter(DefaultSequence_WithSizeAndGetItemIndex *__restrict self) { result->disgi_tp_getitem_index = self->dssgi_tp_getitem_index; result->disgi_index = self->dssgi_start; result->disgi_end = self->dssgi_end; - DeeObject_Init(result, &DefaultIterator_WithTryGetItemIndexAndSize_Type); + DeeObject_Init(result, &DefaultIterator_WithSizeAndTryGetItemIndex_Type); return result; err: return NULL; @@ -593,7 +593,7 @@ ds_stgi_getrange_index(DefaultSequence_WithSizeAndGetItemIndex *__restrict self, result->dssgi_tp_getitem_index = self->dssgi_tp_getitem_index; result->dssgi_start = self->dssgi_start + range.sr_start; result->dssgi_end = self->dssgi_start + range.sr_end; - DeeObject_Init(result, &DefaultSequence_WithTryGetItemIndexAndSize_Type); + DeeObject_Init(result, &DefaultSequence_WithSizeAndTryGetItemIndex_Type); return result; err: return NULL; @@ -659,7 +659,7 @@ ds_stgi_getrange_index_n(DefaultSequence_WithSizeAndGetItemIndex *__restrict sel result->dssgi_tp_getitem_index = self->dssgi_tp_getitem_index; result->dssgi_start = self->dssgi_start + used_start; result->dssgi_end = self->dssgi_end; - DeeObject_Init(result, &DefaultSequence_WithTryGetItemIndexAndSize_Type); + DeeObject_Init(result, &DefaultSequence_WithSizeAndTryGetItemIndex_Type); return result; err: return NULL; @@ -685,7 +685,7 @@ PRIVATE struct type_member ds_sgif_class_members[] = { }; PRIVATE struct type_member ds_stgi_class_members[] = { - TYPE_MEMBER_CONST(STR_Iterator, &DefaultIterator_WithTryGetItemIndexAndSize_Type), + TYPE_MEMBER_CONST(STR_Iterator, &DefaultIterator_WithSizeAndTryGetItemIndex_Type), TYPE_MEMBER_END }; @@ -915,9 +915,9 @@ INTERN DeeTypeObject DefaultSequence_WithSizeAndGetItemIndexFast_Type = { /* .tp_class_members = */ ds_sgif_class_members }; -INTERN DeeTypeObject DefaultSequence_WithTryGetItemIndexAndSize_Type = { +INTERN DeeTypeObject DefaultSequence_WithSizeAndTryGetItemIndex_Type = { OBJECT_HEAD_INIT(&DeeType_Type), - /* .tp_name = */ "_SeqWithTryGetItemIndexAndSize", + /* .tp_name = */ "_SeqWithSizeAndTryGetItemIndex", /* .tp_doc = */ NULL, /* .tp_flags = */ TP_FNORMAL | TP_FFINAL, /* .tp_weakrefs = */ 0, diff --git a/src/deemon/objects/seq/default-sequences.h b/src/deemon/objects/seq/default-sequences.h index d68dc00d3..11c9a7390 100644 --- a/src/deemon/objects/seq/default-sequences.h +++ b/src/deemon/objects/seq/default-sequences.h @@ -75,7 +75,7 @@ typedef struct { INTDEF DeeTypeObject DefaultSequence_WithSizeAndGetItemIndex_Type; /* DefaultSequence_WithSizeAndGetItemIndex */ INTDEF DeeTypeObject DefaultSequence_WithSizeAndGetItemIndexFast_Type; /* DefaultSequence_WithSizeAndGetItemIndex */ -INTDEF DeeTypeObject DefaultSequence_WithTryGetItemIndexAndSize_Type; /* DefaultSequence_WithSizeAndGetItemIndex */ +INTDEF DeeTypeObject DefaultSequence_WithSizeAndTryGetItemIndex_Type; /* DefaultSequence_WithSizeAndGetItemIndex */ INTDEF DeeTypeObject DefaultSequence_WithSizeAndGetItem_Type; /* DefaultSequence_WithSizeAndGetItem */ INTDEF DeeTypeObject DefaultSequence_WithTSizeAndGetItem_Type; /* DefaultSequence_WithTSizeAndGetItem */ INTDEF DeeTypeObject DefaultSequence_WithIter_Type; /* DefaultSequence_WithIter */ diff --git a/src/deemon/objects/type-operators.c b/src/deemon/objects/type-operators.c index 6d008bfd3..290f0dde0 100644 --- a/src/deemon/objects/type-operators.c +++ b/src/deemon/objects/type-operators.c @@ -109,7 +109,6 @@ DEFINE_TYPE_INHERIT_HOOK(do_DeeType_InheritAnd, DeeType_InheritAnd); DEFINE_TYPE_INHERIT_HOOK(do_DeeType_InheritOr, DeeType_InheritOr); DEFINE_TYPE_INHERIT_HOOK(do_DeeType_InheritXor, DeeType_InheritXor); DEFINE_TYPE_INHERIT_HOOK(do_DeeType_InheritPow, DeeType_InheritPow); -DEFINE_TYPE_INHERIT_HOOK(do_DeeType_InheritHash, DeeType_InheritHash); DEFINE_TYPE_INHERIT_HOOK(do_DeeType_InheritCompare, DeeType_InheritCompare); DEFINE_TYPE_INHERIT_HOOK(do_DeeType_InheritIterNext, DeeType_InheritIterNext); DEFINE_TYPE_INHERIT_HOOK(do_DeeType_InheritIter, DeeType_InheritIter); @@ -234,7 +233,7 @@ DEFINE_OPERATOR_INVOKE(operator_float, &instance_double, &do_DeeType_InheritInt) return NULL; } -DEFINE_OPERATOR_INVOKE(operator_hash, &instance_hash, &do_DeeType_InheritHash) { +DEFINE_OPERATOR_INVOKE(operator_hash, &instance_hash, &do_DeeType_InheritCompare) { dhash_t result; (void)p_self; (void)opname; diff --git a/src/deemon/runtime/operator.c b/src/deemon/runtime/operator.c index ab2e33077..d854dc0f6 100644 --- a/src/deemon/runtime/operator.c +++ b/src/deemon/runtime/operator.c @@ -56,6 +56,7 @@ #include #include "../objects/int_logic.h" +#include "../objects/seq/default-compare.h" #include "../objects/seq/default-iterators.h" #include "../objects/seq/default-sequences.h" #include "../objects/seq/each.h" @@ -312,6 +313,10 @@ DeeSystem_DEFINE_memsetp(dee_memsetp) #define DeeType_INVOKE_GR_NODEFAULT DeeType_InvokeCmpGr_NODEFAULT #define DeeType_INVOKE_GE DeeType_InvokeCmpGe #define DeeType_INVOKE_GE_NODEFAULT DeeType_InvokeCmpGe_NODEFAULT +#define DeeType_INVOKE_COMPARE_EQ DeeType_InvokeCmpCompareEq +#define DeeType_INVOKE_COMPARE_EQ_NODEFAULT DeeType_InvokeCmpCompareEq_NODEFAULT +#define DeeType_INVOKE_COMPARE DeeType_InvokeCmpCompare +#define DeeType_INVOKE_COMPARE_NODEFAULT DeeType_InvokeCmpCompare_NODEFAULT #define DeeType_INVOKE_ITER DeeType_InvokeSeqIter #define DeeType_INVOKE_ITER_NODEFAULT DeeType_InvokeSeqIter_NODEFAULT #define DeeType_INVOKE_SIZEOB DeeType_InvokeSeqSizeOb @@ -451,6 +456,8 @@ DeeSystem_DEFINE_memsetp(dee_memsetp) #define DeeType_INVOKE_LE(tp_self, self, other) (*(tp_self)->tp_cmp->tp_le)(self, other) #define DeeType_INVOKE_GR(tp_self, self, other) (*(tp_self)->tp_cmp->tp_gr)(self, other) #define DeeType_INVOKE_GE(tp_self, self, other) (*(tp_self)->tp_cmp->tp_ge)(self, other) +#define DeeType_INVOKE_COMPARE_EQ(tp_self, self, other) (*(tp_self)->tp_cmp->tp_compare_eq)(self, other) +#define DeeType_INVOKE_COMPARE(tp_self, self, other) (*(tp_self)->tp_cmp->tp_compare)(self, other) #define DeeType_INVOKE_ITER(tp_self, self) (*(tp_self)->tp_seq->tp_iter)(self) #define DeeType_INVOKE_SIZEOB(tp_self, self) (*(tp_self)->tp_seq->tp_sizeob)(self) #define DeeType_INVOKE_CONTAINS(tp_self, self, other) (*(tp_self)->tp_seq->tp_contains)(self, other) @@ -545,6 +552,8 @@ DeeSystem_DEFINE_memsetp(dee_memsetp) #define DeeType_INVOKE_LE_NODEFAULT DeeType_INVOKE_LE #define DeeType_INVOKE_GR_NODEFAULT DeeType_INVOKE_GR #define DeeType_INVOKE_GE_NODEFAULT DeeType_INVOKE_GE +#define DeeType_INVOKE_COMPARE_EQ_NODEFAULT DeeType_INVOKE_COMPARE_EQ +#define DeeType_INVOKE_COMPARE_NODEFAULT DeeType_INVOKE_COMPARE #define DeeType_INVOKE_ITER_NODEFAULT DeeType_INVOKE_ITER #define DeeType_INVOKE_SIZEOB_NODEFAULT DeeType_INVOKE_SIZEOB #define DeeType_INVOKE_CONTAINS_NODEFAULT DeeType_INVOKE_CONTAINS @@ -2252,7 +2261,7 @@ WUNUSED /*ATTR_PURE*/ DEFINE_OPERATOR(dhash_t, Hash, (DeeObject *RESTRICT_IF_NOTYPE self)) { LOAD_TP_SELF; if likely((tp_self->tp_cmp && tp_self->tp_cmp->tp_hash) || - DeeType_InheritHash(tp_self)) { + (DeeType_InheritCompare(tp_self) && tp_self->tp_cmp->tp_hash)) { if likely(!(tp_self->tp_flags & TP_FGC)) { return DeeType_INVOKE_HASH(tp_self, self); } else { @@ -3323,43 +3332,2061 @@ xinvoke_not(/*[0..1],inherit(always)*/ DREF DeeObject *ob) { return ob; } + +INTDEF NONNULL((1)) Dee_hash_t DCALL DeeSeq_HandleHashError(DeeObject *self); +INTDEF NONNULL((1)) Dee_hash_t DCALL DeeSet_HandleHashError(DeeObject *self); +INTDEF NONNULL((1)) Dee_hash_t DCALL DeeMap_HandleHashError(DeeObject *self); + +#ifndef DEFINE_TYPED_OPERATORS +INTERN NONNULL((1)) Dee_hash_t DCALL DeeSeq_HandleHashError(DeeObject *self) { + DeeError_Print("Unhandled error in `Sequence.operator hash'\n", + ERROR_PRINT_DOHANDLE); + return DeeObject_HashGeneric(self); +} + +INTERN NONNULL((1)) Dee_hash_t DCALL DeeSet_HandleHashError(DeeObject *self) { + DeeError_Print("Unhandled error in `Set.operator hash'\n", + ERROR_PRINT_DOHANDLE); + return DeeObject_HashGeneric(self); +} + +INTERN NONNULL((1)) Dee_hash_t DCALL DeeMap_HandleHashError(DeeObject *self) { + DeeError_Print("Unhandled error in `Mapping.operator hash'\n", + ERROR_PRINT_DOHANDLE); + return DeeObject_HashGeneric(self); +} +#endif /* !DEFINE_TYPED_OPERATORS */ + +/* tp_hash */ +DEFINE_INTERNAL_SEQ_OPERATOR(Dee_hash_t, DefaultHashWithSizeAndGetItemIndexFast, (DeeObject *self)) { + Dee_hash_t result; + size_t i, size; + DREF DeeObject *elem; + LOAD_TP_SELF; + size = DeeType_INVOKE_SIZE_NODEFAULT(tp_self, self); + if unlikely(size == (size_t)-1) + goto err; + if (size == 0) + return DEE_HASHOF_EMPTY_SEQUENCE; + elem = (*tp_self->tp_seq->tp_getitem_index_fast)(self, 0); + if unlikely(!elem) { + result = DEE_HASHOF_UNBOUND_ITEM; + } else { + result = DeeObject_Hash(elem); + Dee_Decref(elem); + } + for (i = 1; i < size; ++i) { + Dee_hash_t elem_hash; + elem = (*tp_self->tp_seq->tp_getitem_index_fast)(self, i); + if unlikely(!elem) { + elem_hash = DEE_HASHOF_UNBOUND_ITEM; + } else { + elem_hash = DeeObject_Hash(elem); + Dee_Decref(elem); + } + result = Dee_HashCombine(result, elem_hash); + } + return result; +err: + return DeeSeq_HandleHashError(self); +} + + +struct default_seq_hash_with_foreach_data { + Dee_hash_t sqhwf_result; /* Hash result (or DEE_HASHOF_EMPTY_SEQUENCE when sqhwf_nonempty=false) */ + bool sqhwf_nonempty; /* True after the first element */ +}; + +INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL +default_seq_hash_with_foreach_cb(void *arg, DeeObject *elem); + +#ifndef DEFINE_TYPED_OPERATORS +INTERN WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL +default_seq_hash_with_foreach_cb(void *arg, DeeObject *elem) { + struct default_seq_hash_with_foreach_data *data; + Dee_hash_t elem_hash; + data = (struct default_seq_hash_with_foreach_data *)arg; + elem_hash = DeeObject_Hash(elem); + if (data->sqhwf_nonempty) { + data->sqhwf_result = Dee_HashCombine(data->sqhwf_result, elem_hash); + } else { + data->sqhwf_result = elem_hash; + data->sqhwf_nonempty = true; + } + return 0; +} +#endif /* !DEFINE_TYPED_OPERATORS */ + + +DEFINE_INTERNAL_SEQ_OPERATOR(Dee_hash_t, DefaultHashWithForeach, (DeeObject *self)) { + struct default_seq_hash_with_foreach_data data; + LOAD_TP_SELF; + data.sqhwf_result = DEE_HASHOF_EMPTY_SEQUENCE; + data.sqhwf_nonempty = false; + if unlikely(DeeType_INVOKE_FOREACH_NODEFAULT(tp_self, self, &default_seq_hash_with_foreach_cb, &data)) + goto err; + return data.sqhwf_result; +err: + return DeeSeq_HandleHashError(self); +} + +DEFINE_INTERNAL_SEQ_OPERATOR(Dee_hash_t, DefaultHashWithSizeAndTryGetItemIndex, (DeeObject *self)) { + Dee_hash_t result; + size_t i, size; + DREF DeeObject *elem; + LOAD_TP_SELF; + size = DeeType_INVOKE_SIZE_NODEFAULT(tp_self, self); + if unlikely(size == (size_t)-1) + goto err; + if (size == 0) + return DEE_HASHOF_EMPTY_SEQUENCE; + elem = DeeType_INVOKE_TRYGETITEMINDEX_NODEFAULT(tp_self, self, 0); + if unlikely(!elem) + goto err; + if unlikely(elem == ITER_DONE) { + result = DEE_HASHOF_UNBOUND_ITEM; + } else { + result = DeeObject_Hash(elem); + Dee_Decref(elem); + } + for (i = 1; i < size; ++i) { + Dee_hash_t elem_hash; + elem = DeeType_INVOKE_TRYGETITEMINDEX_NODEFAULT(tp_self, self, i); + if unlikely(elem) + goto err; + if unlikely(elem == ITER_DONE) { + elem_hash = DEE_HASHOF_UNBOUND_ITEM; + } else { + elem_hash = DeeObject_Hash(elem); + Dee_Decref(elem); + } + result = Dee_HashCombine(result, elem_hash); + if (DeeThread_CheckInterrupt()) + goto err; + } + return result; +err: + return DeeSeq_HandleHashError(self); +} + +DEFINE_INTERNAL_SEQ_OPERATOR(Dee_hash_t, DefaultHashWithSizeAndGetItemIndex, (DeeObject *self)) { + Dee_hash_t result; + size_t i, size; + DREF DeeObject *elem; + LOAD_TP_SELF; + size = DeeType_INVOKE_SIZE_NODEFAULT(tp_self, self); + if unlikely(size == (size_t)-1) + goto err; + if (size == 0) + return DEE_HASHOF_EMPTY_SEQUENCE; + elem = DeeType_INVOKE_GETITEMINDEX_NODEFAULT(tp_self, self, 0); + if unlikely(!elem) { + if (!DeeError_Catch(&DeeError_UnboundItem)) + goto err; + result = DEE_HASHOF_UNBOUND_ITEM; + } else { + result = DeeObject_Hash(elem); + Dee_Decref(elem); + } + for (i = 1; i < size; ++i) { + Dee_hash_t elem_hash; + elem = DeeType_INVOKE_GETITEMINDEX_NODEFAULT(tp_self, self, i); + if unlikely(!elem) { + if (!DeeError_Catch(&DeeError_UnboundItem)) + goto err; + elem_hash = DEE_HASHOF_UNBOUND_ITEM; + } else { + elem_hash = DeeObject_Hash(elem); + Dee_Decref(elem); + } + result = Dee_HashCombine(result, elem_hash); + if (DeeThread_CheckInterrupt()) + goto err; + } + return result; +err: + return DeeSeq_HandleHashError(self); +} + +DEFINE_INTERNAL_SEQ_OPERATOR(Dee_hash_t, DefaultHashWithSizeObAndGetItem, (DeeObject *self)) { + int temp; + Dee_hash_t result; + DREF DeeObject *indexob, *sizeob; + DREF DeeObject *elem; + LOAD_TP_SELF; + sizeob = DeeType_INVOKE_SIZEOB_NODEFAULT(tp_self, self); + if unlikely(!sizeob) + goto err; + indexob = DeeObject_NewDefault(Dee_TYPE(sizeob)); + if unlikely(!indexob) + goto err_sizeob; + temp = DeeObject_CompareLo(indexob, sizeob); + if (temp <= 0) { + if unlikely(temp < 0) + goto err_sizeob_indexob; + Dee_Decref(indexob); + Dee_Decref(sizeob); + return DEE_HASHOF_EMPTY_SEQUENCE; + } + elem = DeeType_INVOKE_GETITEM_NODEFAULT(tp_self, self, indexob); + if unlikely(!elem) { + if (!DeeError_Catch(&DeeError_UnboundItem)) + goto err_sizeob_indexob; + result = DEE_HASHOF_UNBOUND_ITEM; + } else { + result = DeeObject_Hash(elem); + Dee_Decref(elem); + } + for (;;) { + Dee_hash_t elem_hash; + if (DeeObject_Inc(&indexob)) + goto err_sizeob_indexob; + temp = DeeObject_CompareLo(indexob, sizeob); + if (temp <= 0) { + if unlikely(temp < 0) + goto err_sizeob_indexob; + break; + } + elem = DeeType_INVOKE_GETITEM_NODEFAULT(tp_self, self, indexob); + if unlikely(!elem) { + if (!DeeError_Catch(&DeeError_UnboundItem)) + goto err_sizeob_indexob; + elem_hash = DEE_HASHOF_UNBOUND_ITEM; + } else { + elem_hash = DeeObject_Hash(elem); + Dee_Decref(elem); + } + result = Dee_HashCombine(result, elem_hash); + if (DeeThread_CheckInterrupt()) + goto err_sizeob_indexob; + } + Dee_Decref(indexob); + Dee_Decref(sizeob); + return result; +err_sizeob_indexob: + Dee_Decref(indexob); +err_sizeob: + Dee_Decref(sizeob); +err: + return DeeSeq_HandleHashError(self); +} + +DEFINE_INTERNAL_SEQ_OPERATOR(Dee_hash_t, DefaultHashWithForeachDefault, (DeeObject *self)) { + struct default_seq_hash_with_foreach_data data; + LOAD_TP_SELF; + data.sqhwf_result = DEE_HASHOF_EMPTY_SEQUENCE; + data.sqhwf_nonempty = false; + if unlikely(DeeType_INVOKE_FOREACH(tp_self, self, &default_seq_hash_with_foreach_cb, &data)) + goto err; + return data.sqhwf_result; +err: + return DeeSeq_HandleHashError(self); +} + +INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL +default_set_hash_with_foreach_cb(void *arg, DeeObject *elem); + +#ifndef DEFINE_TYPED_OPERATORS +INTERN WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL +default_set_hash_with_foreach_cb(void *arg, DeeObject *elem) { + *(Dee_hash_t *)arg ^= DeeObject_Hash(elem); + return 0; +} +#endif /* !DEFINE_TYPED_OPERATORS */ + +DEFINE_INTERNAL_SET_OPERATOR(Dee_hash_t, DefaultHashWithForeachDefault, (DeeObject *self)) { + Dee_hash_t result = DEE_HASHOF_EMPTY_SEQUENCE; + LOAD_TP_SELF; + if unlikely(DeeType_INVOKE_FOREACH(tp_self, self, &default_set_hash_with_foreach_cb, &result)) + goto err; + return result; +err: + return DeeSet_HandleHashError(self); +} + +INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL +default_map_hash_with_foreach_cb(void *arg, DeeObject *key, DeeObject *value); + +#ifndef DEFINE_TYPED_OPERATORS +INTERN WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL +default_map_hash_with_foreach_cb(void *arg, DeeObject *key, DeeObject *value) { + /* Note that we still combine the hashes for the key and value, + * thus not only mirroring the behavior of hash of the item (that + * is the tuple `(key, value)', including the order between the + * key and value within the hash, so that swapping the key and + * value would produce a different hash) */ + *(Dee_hash_t *)arg ^= Dee_HashCombine(DeeObject_Hash(key), + DeeObject_Hash(value)); + return 0; +} +#endif /* !DEFINE_TYPED_OPERATORS */ + +DEFINE_INTERNAL_MAP_OPERATOR(Dee_hash_t, DefaultHashWithForeachPairDefault, (DeeObject *self)) { + Dee_hash_t result = DEE_HASHOF_EMPTY_SEQUENCE; + LOAD_TP_SELF; + if unlikely(DeeType_INVOKE_FOREACH_PAIR(tp_self, self, &default_map_hash_with_foreach_cb, &result)) + goto err; + return result; +err: + return DeeMap_HandleHashError(self); +} + + +/* tp_eq */ +DEFINE_INTERNAL_OPERATOR(DREF DeeObject *, DefaultEqWithCompareEq, + (DeeObject *self, DeeObject *other)) { + int result; + LOAD_TP_SELF; + result = DeeType_INVOKE_COMPARE_EQ_NODEFAULT(tp_self, self, other); + if unlikely(result == Dee_COMPARE_ERR) + goto err; + return_bool_(result == 0); +err: + return NULL; +} + DEFINE_INTERNAL_OPERATOR(DREF DeeObject *, DefaultEqWithNe, (DeeObject *self, DeeObject *other)) { LOAD_TP_SELF; return xinvoke_not(DeeType_INVOKE_NE_NODEFAULT(tp_self, self, other)); } +DEFINE_INTERNAL_OPERATOR(DREF DeeObject *, DefaultEqWithLoAndGr, + (DeeObject *self, DeeObject *other)) { + int temp; + DREF DeeObject *cmp_ob; + LOAD_TP_SELF; + cmp_ob = DeeType_INVOKE_LO_NODEFAULT(tp_self, self, other); + if unlikely(!cmp_ob) + goto err; + temp = DeeObject_BoolInherited(cmp_ob); + if unlikely(temp < 0) + goto err; + if (temp) + goto not_equal; + cmp_ob = DeeType_INVOKE_GR_NODEFAULT(tp_self, self, other); + if unlikely(!cmp_ob) + goto err; + temp = DeeObject_BoolInherited(cmp_ob); + if unlikely(temp < 0) + goto err; + if (temp) + goto not_equal; + return_true; +not_equal: + return_false; +err: + return NULL; +} + +DEFINE_INTERNAL_OPERATOR(DREF DeeObject *, DefaultEqWithLeAndGe, + (DeeObject *self, DeeObject *other)) { + int temp; + DREF DeeObject *cmp_ob; + LOAD_TP_SELF; + cmp_ob = DeeType_INVOKE_LE_NODEFAULT(tp_self, self, other); + if unlikely(!cmp_ob) + goto err; + temp = DeeObject_BoolInherited(cmp_ob); + if unlikely(temp < 0) + goto err; + if (!temp) + goto not_equal; + cmp_ob = DeeType_INVOKE_GE_NODEFAULT(tp_self, self, other); + if unlikely(!cmp_ob) + goto err; + temp = DeeObject_BoolInherited(cmp_ob); + if unlikely(temp < 0) + goto err; + if (!temp) + goto not_equal; + return_true; +not_equal: + return_false; +err: + return NULL; +} + +DEFINE_INTERNAL_OPERATOR(DREF DeeObject *, DefaultEqWithCompareEqDefault, + (DeeObject *self, DeeObject *other)) { + int result; + LOAD_TP_SELF; + result = DeeType_INVOKE_COMPARE_EQ(tp_self, self, other); + if unlikely(result == Dee_COMPARE_ERR) + goto err; + return_bool_(result == 0); +err: + return NULL; +} + + +/* tp_ne */ +DEFINE_INTERNAL_OPERATOR(DREF DeeObject *, DefaultNeWithCompareEq, + (DeeObject *self, DeeObject *other)) { + int result; + LOAD_TP_SELF; + result = DeeType_INVOKE_COMPARE_EQ_NODEFAULT(tp_self, self, other); + if unlikely(result == Dee_COMPARE_ERR) + goto err; + return_bool_(result != 0); +err: + return NULL; +} + DEFINE_INTERNAL_OPERATOR(DREF DeeObject *, DefaultNeWithEq, (DeeObject *self, DeeObject *other)) { LOAD_TP_SELF; return xinvoke_not(DeeType_INVOKE_NE_NODEFAULT(tp_self, self, other)); } -DEFINE_INTERNAL_OPERATOR(DREF DeeObject *, DefaultLoWithGe, +DEFINE_INTERNAL_OPERATOR(DREF DeeObject *, DefaultNeWithLoAndGr, (DeeObject *self, DeeObject *other)) { + int temp; + DREF DeeObject *cmp_ob; LOAD_TP_SELF; - return xinvoke_not(DeeType_INVOKE_GE_NODEFAULT(tp_self, self, other)); + cmp_ob = DeeType_INVOKE_LO_NODEFAULT(tp_self, self, other); + if unlikely(!cmp_ob) + goto err; + temp = DeeObject_BoolInherited(cmp_ob); + if unlikely(temp < 0) + goto err; + if (temp) + goto not_equal; + cmp_ob = DeeType_INVOKE_GR_NODEFAULT(tp_self, self, other); + if unlikely(!cmp_ob) + goto err; + temp = DeeObject_BoolInherited(cmp_ob); + if unlikely(temp < 0) + goto err; + if (temp) + goto not_equal; + return_false; +not_equal: + return_true; +err: + return NULL; } -DEFINE_INTERNAL_OPERATOR(DREF DeeObject *, DefaultLeWithGr, +DEFINE_INTERNAL_OPERATOR(DREF DeeObject *, DefaultNeWithLeAndGe, (DeeObject *self, DeeObject *other)) { + int temp; + DREF DeeObject *cmp_ob; LOAD_TP_SELF; - return xinvoke_not(DeeType_INVOKE_GR_NODEFAULT(tp_self, self, other)); + cmp_ob = DeeType_INVOKE_LE_NODEFAULT(tp_self, self, other); + if unlikely(!cmp_ob) + goto err; + temp = DeeObject_BoolInherited(cmp_ob); + if unlikely(temp < 0) + goto err; + if (!temp) + goto not_equal; + cmp_ob = DeeType_INVOKE_GE_NODEFAULT(tp_self, self, other); + if unlikely(!cmp_ob) + goto err; + temp = DeeObject_BoolInherited(cmp_ob); + if unlikely(temp < 0) + goto err; + if (!temp) + goto not_equal; + return_false; +not_equal: + return_true; +err: + return NULL; } -DEFINE_INTERNAL_OPERATOR(DREF DeeObject *, DefaultGrWithLe, +DEFINE_INTERNAL_OPERATOR(DREF DeeObject *, DefaultNeWithCompareEqDefault, (DeeObject *self, DeeObject *other)) { + int result; LOAD_TP_SELF; - return xinvoke_not(DeeType_INVOKE_LE_NODEFAULT(tp_self, self, other)); + result = DeeType_INVOKE_COMPARE_EQ(tp_self, self, other); + if unlikely(result == Dee_COMPARE_ERR) + goto err; + return_bool_(result != 0); +err: + return NULL; } -DEFINE_INTERNAL_OPERATOR(DREF DeeObject *, DefaultGeWithLo, + +/* tp_lo */ +DEFINE_INTERNAL_OPERATOR(DREF DeeObject *, DefaultLoWithCompare, (DeeObject *self, DeeObject *other)) { + int result; LOAD_TP_SELF; - return xinvoke_not(DeeType_INVOKE_LO_NODEFAULT(tp_self, self, other)); + result = DeeType_INVOKE_COMPARE_NODEFAULT(tp_self, self, other); + if unlikely(result == Dee_COMPARE_ERR) + goto err; + return_bool_(result < 0); +err: + return NULL; +} + +DEFINE_INTERNAL_OPERATOR(DREF DeeObject *, DefaultLoWithGe, + (DeeObject *self, DeeObject *other)) { + LOAD_TP_SELF; + return xinvoke_not(DeeType_INVOKE_GE_NODEFAULT(tp_self, self, other)); +} + +DEFINE_INTERNAL_OPERATOR(DREF DeeObject *, DefaultLoWithCompareDefault, + (DeeObject *self, DeeObject *other)) { + int result; + LOAD_TP_SELF; + result = DeeType_INVOKE_COMPARE(tp_self, self, other); + if unlikely(result == Dee_COMPARE_ERR) + goto err; + return_bool_(result < 0); +err: + return NULL; +} + +DEFINE_INTERNAL_SET_OPERATOR(DREF DeeObject *, DefaultLoWithForeachDefault, + (DeeObject *self, DeeObject *other)) { + size_t rhs_size; + Dee_ssize_t contains_status; + DeeTypeObject *tp_other = Dee_TYPE(other); + struct set_compare__lhs_foreach__rhs__data data; + LOAD_TP_SELF; + if ((!tp_other->tp_seq || !tp_other->tp_seq->tp_contains) && !DeeType_InheritContains(tp_other)) + goto err_other_no_contains; + data.sc_lfr_rhs = other; + data.sc_lfr_rcontains = tp_other->tp_seq->tp_contains; + contains_status = DeeType_INVOKE_FOREACH(tp_self, self, &set_compare__lhs_foreach__rhs__cb, &data); + if unlikely(contains_status == -1) + goto err; + if (contains_status == -2) + goto missing_item; /* "other" is missing some element of "self" */ + rhs_size = DeeObject_Size(other); + if unlikely(rhs_size == (size_t)-1) + goto err; + if ((size_t)contains_status >= rhs_size) + goto missing_item; /* "other" contains element not found in "self" */ + return_true; +missing_item: + return_false; +err_other_no_contains: + err_unimplemented_operator(tp_other, OPERATOR_CONTAINS); +err: + return NULL; +} + +DEFINE_INTERNAL_MAP_OPERATOR(DREF DeeObject *, DefaultLoWithForeachPairDefault, + (DeeObject *self, DeeObject *other)) { + size_t rhs_size; + Dee_ssize_t contains_status; + DeeTypeObject *tp_other = Dee_TYPE(other); + struct map_compare__lhs_foreach__rhs__data data; + LOAD_TP_SELF; + if ((!tp_other->tp_seq || !tp_other->tp_seq->tp_trygetitem) && !DeeType_InheritGetItem(tp_other)) + goto err_other_no_getitem; + data.mc_lfr_rhs = other; + data.mc_lfr_rtrygetitem = tp_other->tp_seq->tp_trygetitem; + contains_status = DeeType_INVOKE_FOREACH_PAIR(tp_self, self, &map_compare__lhs_foreach__rhs__cb, &data); + if unlikely(contains_status == -1) + goto err; + if (contains_status == -2) + goto missing_item; /* "other" is missing some element of "self", or has a different value for it */ + rhs_size = DeeObject_Size(other); + if unlikely(rhs_size == (size_t)-1) + goto err; + if ((size_t)contains_status >= rhs_size) + goto missing_item; /* "other" contains element not found in "self" */ + return_true; +missing_item: + return_false; +err_other_no_getitem: + err_unimplemented_operator(tp_other, OPERATOR_GETITEM); +err: + return NULL; +} + + + + +/* tp_le */ +DEFINE_INTERNAL_OPERATOR(DREF DeeObject *, DefaultLeWithCompare, + (DeeObject *self, DeeObject *other)) { + int result; + LOAD_TP_SELF; + result = DeeType_INVOKE_COMPARE_NODEFAULT(tp_self, self, other); + if unlikely(result == Dee_COMPARE_ERR) + goto err; + return_bool_(result <= 0); +err: + return NULL; +} + +DEFINE_INTERNAL_OPERATOR(DREF DeeObject *, DefaultLeWithGr, + (DeeObject *self, DeeObject *other)) { + LOAD_TP_SELF; + return xinvoke_not(DeeType_INVOKE_GR_NODEFAULT(tp_self, self, other)); +} + +DEFINE_INTERNAL_OPERATOR(DREF DeeObject *, DefaultLeWithCompareDefault, + (DeeObject *self, DeeObject *other)) { + int result; + LOAD_TP_SELF; + result = DeeType_INVOKE_COMPARE(tp_self, self, other); + if unlikely(result == Dee_COMPARE_ERR) + goto err; + return_bool_(result <= 0); +err: + return NULL; +} + +DEFINE_INTERNAL_SET_OPERATOR(DREF DeeObject *, DefaultLeWithForeachDefault, + (DeeObject *self, DeeObject *other)) { + Dee_ssize_t contains_status; + DeeTypeObject *tp_other = Dee_TYPE(other); + struct set_compare__lhs_foreach__rhs__data data; + LOAD_TP_SELF; + if ((!tp_other->tp_seq || !tp_other->tp_seq->tp_contains) && !DeeType_InheritContains(tp_other)) + goto err_other_no_contains; + data.sc_lfr_rhs = other; + data.sc_lfr_rcontains = tp_other->tp_seq->tp_contains; + contains_status = DeeType_INVOKE_FOREACH(tp_self, self, &set_compare__lhs_foreach__rhs__cb, &data); + if unlikely(contains_status == -1) + goto err; + if (contains_status == -2) + goto missing_item; /* "other" is missing some element of "self" */ + return_true; +missing_item: + return_false; +err_other_no_contains: + err_unimplemented_operator(tp_other, OPERATOR_CONTAINS); +err: + return NULL; +} + +DEFINE_INTERNAL_MAP_OPERATOR(DREF DeeObject *, DefaultLeWithForeachPairDefault, + (DeeObject *self, DeeObject *other)) { + Dee_ssize_t contains_status; + DeeTypeObject *tp_other = Dee_TYPE(other); + struct map_compare__lhs_foreach__rhs__data data; + LOAD_TP_SELF; + if ((!tp_other->tp_seq || !tp_other->tp_seq->tp_trygetitem) && !DeeType_InheritGetItem(tp_other)) + goto err_other_no_getitem; + data.mc_lfr_rhs = other; + data.mc_lfr_rtrygetitem = tp_other->tp_seq->tp_trygetitem; + contains_status = DeeType_INVOKE_FOREACH_PAIR(tp_self, self, &map_compare__lhs_foreach__rhs__cb, &data); + if unlikely(contains_status == -1) + goto err; + if (contains_status == -2) + goto missing_item; /* "other" is missing some element of "self", or has a different value for it */ + return_true; +missing_item: + return_false; +err_other_no_getitem: + err_unimplemented_operator(tp_other, OPERATOR_GETITEM); +err: + return NULL; +} + + + +/* tp_gr */ +DEFINE_INTERNAL_OPERATOR(DREF DeeObject *, DefaultGrWithCompare, + (DeeObject *self, DeeObject *other)) { + int result; + LOAD_TP_SELF; + result = DeeType_INVOKE_COMPARE_NODEFAULT(tp_self, self, other); + if unlikely(result == Dee_COMPARE_ERR) + goto err; + return_bool_(result > 0); +err: + return NULL; +} + +DEFINE_INTERNAL_OPERATOR(DREF DeeObject *, DefaultGrWithLe, + (DeeObject *self, DeeObject *other)) { + LOAD_TP_SELF; + return xinvoke_not(DeeType_INVOKE_LE_NODEFAULT(tp_self, self, other)); +} + +DEFINE_INTERNAL_OPERATOR(DREF DeeObject *, DefaultGrWithCompareDefault, + (DeeObject *self, DeeObject *other)) { + int result; + LOAD_TP_SELF; + result = DeeType_INVOKE_COMPARE(tp_self, self, other); + if unlikely(result == Dee_COMPARE_ERR) + goto err; + return_bool_(result > 0); +err: + return NULL; +} + +DEFINE_INTERNAL_SET_OPERATOR(DREF DeeObject *, DefaultGrWithForeachDefault, + (DeeObject *self, DeeObject *other)) { + Dee_ssize_t contains_status; + DeeTypeObject *tp_other = Dee_TYPE(other); + struct set_compare__lhs_foreach__rhs__data data; + LOAD_TP_SELF; + if ((!tp_other->tp_seq || !tp_other->tp_seq->tp_contains) && !DeeType_InheritContains(tp_other)) + goto err_other_no_contains; + data.sc_lfr_rhs = other; + data.sc_lfr_rcontains = tp_other->tp_seq->tp_contains; + contains_status = DeeType_INVOKE_FOREACH(tp_self, self, &set_compare__lhs_foreach__rhs__cb, &data); + if unlikely(contains_status == -1) + goto err; + if (contains_status == -2) + goto missing_item; /* "other" is missing some element of "self" */ + return_false; +missing_item: + return_true; +err_other_no_contains: + err_unimplemented_operator(tp_other, OPERATOR_CONTAINS); +err: + return NULL; +} + +DEFINE_INTERNAL_MAP_OPERATOR(DREF DeeObject *, DefaultGrWithForeachPairDefault, + (DeeObject *self, DeeObject *other)) { + Dee_ssize_t contains_status; + DeeTypeObject *tp_other = Dee_TYPE(other); + struct map_compare__lhs_foreach__rhs__data data; + LOAD_TP_SELF; + if ((!tp_other->tp_seq || !tp_other->tp_seq->tp_trygetitem) && !DeeType_InheritGetItem(tp_other)) + goto err_other_no_getitem; + data.mc_lfr_rhs = other; + data.mc_lfr_rtrygetitem = tp_other->tp_seq->tp_trygetitem; + contains_status = DeeType_INVOKE_FOREACH_PAIR(tp_self, self, &map_compare__lhs_foreach__rhs__cb, &data); + if unlikely(contains_status == -1) + goto err; + if (contains_status == -2) + goto missing_item; /* "other" is missing some element of "self", or has a different value for it */ + return_false; +missing_item: + return_true; +err_other_no_getitem: + err_unimplemented_operator(tp_other, OPERATOR_GETITEM); +err: + return NULL; +} + + + +/* tp_ge */ +DEFINE_INTERNAL_OPERATOR(DREF DeeObject *, DefaultGeWithCompare, + (DeeObject *self, DeeObject *other)) { + int result; + LOAD_TP_SELF; + result = DeeType_INVOKE_COMPARE_NODEFAULT(tp_self, self, other); + if unlikely(result == Dee_COMPARE_ERR) + goto err; + return_bool_(result >= 0); +err: + return NULL; +} + +DEFINE_INTERNAL_OPERATOR(DREF DeeObject *, DefaultGeWithLo, + (DeeObject *self, DeeObject *other)) { + LOAD_TP_SELF; + return xinvoke_not(DeeType_INVOKE_LO_NODEFAULT(tp_self, self, other)); +} + +DEFINE_INTERNAL_OPERATOR(DREF DeeObject *, DefaultGeWithCompareDefault, + (DeeObject *self, DeeObject *other)) { + int result; + LOAD_TP_SELF; + result = DeeType_INVOKE_COMPARE(tp_self, self, other); + if unlikely(result == Dee_COMPARE_ERR) + goto err; + return_bool_(result >= 0); +err: + return NULL; +} + +DEFINE_INTERNAL_SET_OPERATOR(DREF DeeObject *, DefaultGeWithForeachDefault, + (DeeObject *self, DeeObject *other)) { + size_t rhs_size; + Dee_ssize_t contains_status; + DeeTypeObject *tp_other = Dee_TYPE(other); + struct set_compare__lhs_foreach__rhs__data data; + LOAD_TP_SELF; + if ((!tp_other->tp_seq || !tp_other->tp_seq->tp_contains) && !DeeType_InheritContains(tp_other)) + goto err_other_no_contains; + data.sc_lfr_rhs = other; + data.sc_lfr_rcontains = tp_other->tp_seq->tp_contains; + contains_status = DeeType_INVOKE_FOREACH(tp_self, self, &set_compare__lhs_foreach__rhs__cb, &data); + if unlikely(contains_status == -1) + goto err; + if (contains_status == -2) + goto missing_item; /* "other" is missing some element of "self" */ + rhs_size = DeeObject_Size(other); + if unlikely(rhs_size == (size_t)-1) + goto err; + if ((size_t)contains_status >= rhs_size) + goto missing_item; /* "other" contains element not found in "self" */ + return_false; +missing_item: + return_true; +err_other_no_contains: + err_unimplemented_operator(tp_other, OPERATOR_CONTAINS); +err: + return NULL; +} + +DEFINE_INTERNAL_MAP_OPERATOR(DREF DeeObject *, DefaultGeWithForeachPairDefault, + (DeeObject *self, DeeObject *other)) { + size_t rhs_size; + Dee_ssize_t contains_status; + DeeTypeObject *tp_other = Dee_TYPE(other); + struct map_compare__lhs_foreach__rhs__data data; + LOAD_TP_SELF; + if ((!tp_other->tp_seq || !tp_other->tp_seq->tp_trygetitem) && !DeeType_InheritGetItem(tp_other)) + goto err_other_no_getitem; + data.mc_lfr_rhs = other; + data.mc_lfr_rtrygetitem = tp_other->tp_seq->tp_trygetitem; + contains_status = DeeType_INVOKE_FOREACH_PAIR(tp_self, self, &map_compare__lhs_foreach__rhs__cb, &data); + if unlikely(contains_status == -1) + goto err; + if (contains_status == -2) + goto missing_item; /* "other" is missing some element of "self", or has a different value for it */ + rhs_size = DeeObject_Size(other); + if unlikely(rhs_size == (size_t)-1) + goto err; + if ((size_t)contains_status >= rhs_size) + goto missing_item; /* "other" contains element not found in "self" */ + return_false; +missing_item: + return_true; +err_other_no_getitem: + err_unimplemented_operator(tp_other, OPERATOR_GETITEM); +err: + return NULL; +} + + + +/* tp_compare_eq */ +DEFINE_INTERNAL_OPERATOR(int, DefaultCompareEqWithEq, + (DeeObject *self, DeeObject *other)) { + int result; + DREF DeeObject *cmp_ob; + LOAD_TP_SELF; + cmp_ob = DeeType_INVOKE_EQ_NODEFAULT(tp_self, self, other); + if unlikely(!cmp_ob) + goto err; + result = DeeObject_BoolInherited(cmp_ob); + if unlikely(result < 0) + goto err; + return result ? 0 : 1; +err: + return Dee_COMPARE_ERR; +} + +DEFINE_INTERNAL_OPERATOR(int, DefaultCompareEqWithNe, + (DeeObject *self, DeeObject *other)) { + int result; + DREF DeeObject *cmp_ob; + LOAD_TP_SELF; + cmp_ob = DeeType_INVOKE_NE_NODEFAULT(tp_self, self, other); + if unlikely(!cmp_ob) + goto err; + result = DeeObject_BoolInherited(cmp_ob); + if unlikely(result < 0) + goto err; + return result; +err: + return Dee_COMPARE_ERR; +} + +DEFINE_INTERNAL_OPERATOR(int, DefaultCompareEqWithLoAndGr, + (DeeObject *self, DeeObject *other)) { + int temp; + DREF DeeObject *cmp_ob; + LOAD_TP_SELF; + cmp_ob = DeeType_INVOKE_LO_NODEFAULT(tp_self, self, other); + if unlikely(!cmp_ob) + goto err; + temp = DeeObject_BoolInherited(cmp_ob); + if unlikely(temp < 0) + goto err; + if (temp) + return -1; /* Different */ + cmp_ob = DeeType_INVOKE_GR_NODEFAULT(tp_self, self, other); + if unlikely(!cmp_ob) + goto err; + temp = DeeObject_BoolInherited(cmp_ob); + if unlikely(temp < 0) + goto err; + if (temp) + return 1; /* Different */ + return 0; +err: + return Dee_COMPARE_ERR; +} + +DEFINE_INTERNAL_OPERATOR(int, DefaultCompareEqWithLeAndGe, + (DeeObject *self, DeeObject *other)) { + int temp; + DREF DeeObject *cmp_ob; + LOAD_TP_SELF; + cmp_ob = DeeType_INVOKE_LE_NODEFAULT(tp_self, self, other); + if unlikely(!cmp_ob) + goto err; + temp = DeeObject_BoolInherited(cmp_ob); + if unlikely(temp < 0) + goto err; + if (!temp) + return 1; /* Different */ + cmp_ob = DeeType_INVOKE_GR_NODEFAULT(tp_self, self, other); + if unlikely(!cmp_ob) + goto err; + temp = DeeObject_BoolInherited(cmp_ob); + if unlikely(temp < 0) + goto err; + if (!temp) + return -1; /* Different */ + return 0; +err: + return Dee_COMPARE_ERR; +} + +DEFINE_INTERNAL_SEQ_OPERATOR(int, DefaultCompareEqWithForeachDefault, + (DeeObject *self, DeeObject *other)) { + DeeTypeObject *tp_other = Dee_TYPE(other); + Dee_ssize_t (DCALL *other_tp_foreach)(DeeObject *__restrict self, Dee_foreach_t proc, void *arg); + Dee_ssize_t result; + LOAD_TP_SELF; + if ((!tp_other->tp_seq || !tp_other->tp_seq->tp_foreach) && !DeeType_InheritIter(tp_other)) + goto err_other_no_iter; + other_tp_foreach = tp_other->tp_seq->tp_foreach; + ASSERT(other_tp_foreach); + if (other_tp_foreach == &DeeSeq_DefaultForeachWithSizeAndGetItemIndexFast) { + struct seq_compareforeach__size_and_getitem_index__data data; + data.scf_sgi_osize = (*tp_other->tp_seq->tp_size)(other); + if unlikely(data.scf_sgi_osize == (size_t)-1) + goto err; + data.scf_sgi_other = other; + data.scf_sgi_oindex = 0; + data.scf_sgi_ogetitem_index = tp_other->tp_seq->tp_getitem_index_fast; + result = DeeType_INVOKE_FOREACH(tp_self, self, &seq_compareeq__lhs_foreach__rhs_size_and_getitem_index_fast__cb, &data); + if (result == SEQ_COMPAREEQ_FOREACH_RESULT_EQUAL && data.scf_sgi_oindex < data.scf_sgi_osize) + result = SEQ_COMPAREEQ_FOREACH_RESULT_NOTEQUAL; + } else if (other_tp_foreach == &DeeSeq_DefaultForeachWithSizeAndTryGetItemIndex) { + struct seq_compareforeach__size_and_getitem_index__data data; + data.scf_sgi_osize = (*tp_other->tp_seq->tp_size)(other); + if unlikely(data.scf_sgi_osize == (size_t)-1) + goto err; + data.scf_sgi_other = other; + data.scf_sgi_oindex = 0; + data.scf_sgi_ogetitem_index = tp_other->tp_seq->tp_trygetitem_index; + result = DeeType_INVOKE_FOREACH(tp_self, self, &seq_compareeq__lhs_foreach__rhs_size_and_trygetitem_index__cb, &data); + if (result == SEQ_COMPAREEQ_FOREACH_RESULT_EQUAL && data.scf_sgi_oindex < data.scf_sgi_osize) + result = SEQ_COMPAREEQ_FOREACH_RESULT_NOTEQUAL; + } else if (other_tp_foreach == &DeeSeq_DefaultForeachWithSizeAndGetItemIndex || + other_tp_foreach == &DeeSeq_DefaultForeachWithSizeDefaultAndGetItemIndexDefault) { + struct seq_compareforeach__size_and_getitem_index__data data; + data.scf_sgi_osize = (*tp_other->tp_seq->tp_size)(other); + if unlikely(data.scf_sgi_osize == (size_t)-1) + goto err; + data.scf_sgi_other = other; + data.scf_sgi_oindex = 0; + data.scf_sgi_ogetitem_index = tp_other->tp_seq->tp_getitem_index; + result = DeeType_INVOKE_FOREACH(tp_self, self, &seq_compareeq__lhs_foreach__rhs_size_and_getitem_index__cb, &data); + if (result == SEQ_COMPAREEQ_FOREACH_RESULT_EQUAL && data.scf_sgi_oindex < data.scf_sgi_osize) + result = SEQ_COMPAREEQ_FOREACH_RESULT_NOTEQUAL; + } else if (other_tp_foreach == &DeeSeq_DefaultForeachWithSizeObAndGetItem) { + struct seq_compare_foreach__sizeob_and_getitem__data data; + data.scf_sg_osize = (*tp_other->tp_seq->tp_sizeob)(other); + if unlikely(!data.scf_sg_osize) + goto err; + data.scf_sg_oindex = DeeObject_NewDefault(Dee_TYPE(data.scf_sg_osize)); + if unlikely(!data.scf_sg_oindex) { + result = SEQ_COMPAREEQ_FOREACH_RESULT_ERROR; + } else { + data.scf_sg_other = other; + data.scf_sg_ogetitem = tp_other->tp_seq->tp_getitem; + result = DeeType_INVOKE_FOREACH(tp_self, self, &seq_compareeq__lhs_foreach__rhs_sizeob_and_getitem__cb, &data); + if (result == SEQ_COMPAREEQ_FOREACH_RESULT_EQUAL) { + int temp = DeeObject_CompareLo(data.scf_sg_oindex, data.scf_sg_osize); + Dee_Decref(data.scf_sg_oindex); + if unlikely(temp < 0) { + result = SEQ_COMPAREEQ_FOREACH_RESULT_ERROR; + } else if (temp) { + result = SEQ_COMPAREEQ_FOREACH_RESULT_NOTEQUAL; + } + } else { + Dee_Decref(data.scf_sg_oindex); + } + } + Dee_Decref(data.scf_sg_osize); + } else { + DREF DeeObject *rhs_iter; + rhs_iter = (*tp_other->tp_seq->tp_iter)(other); + if unlikely(!rhs_iter) + goto err; + result = DeeType_INVOKE_FOREACH(tp_self, self, &seq_compareeq__lhs_foreach__rhs_iter__cb, rhs_iter); + if (result == SEQ_COMPAREEQ_FOREACH_RESULT_EQUAL) { + DREF DeeObject *next = DeeObject_IterNext(rhs_iter); + Dee_Decref(rhs_iter); + if unlikely(!next) + goto err; + if (next != ITER_DONE) { + Dee_Decref(next); + result = SEQ_COMPAREEQ_FOREACH_RESULT_NOTEQUAL; + } + } else { + Dee_Decref(rhs_iter); + } + } + ASSERT(result == SEQ_COMPAREEQ_FOREACH_RESULT_EQUAL || + result == SEQ_COMPAREEQ_FOREACH_RESULT_ERROR || + result == SEQ_COMPAREEQ_FOREACH_RESULT_NOTEQUAL); + if unlikely(result == SEQ_COMPAREEQ_FOREACH_RESULT_ERROR) + goto err; + if (result == SEQ_COMPAREEQ_FOREACH_RESULT_EQUAL) + return 0; + return 1; +err_other_no_iter: + err_unimplemented_operator(tp_other, OPERATOR_ITER); +err: + return Dee_COMPARE_ERR; +} + +DEFINE_INTERNAL_SEQ_OPERATOR(int, DefaultCompareEqWithSizeAndGetItemIndexFast, + (DeeObject *self, DeeObject *other)) { + int result; + size_t lhs_size; + DeeTypeObject *tp_other = Dee_TYPE(other); + DREF DeeObject *(DCALL *lhs_getitem_index_fast)(DeeObject *self, size_t index); + Dee_ssize_t (DCALL *other_tp_foreach)(DeeObject *__restrict self, Dee_foreach_t proc, void *arg); + LOAD_TP_SELF; + if ((!tp_other->tp_seq || !tp_other->tp_seq->tp_foreach) && !DeeType_InheritIter(tp_other)) + goto err_other_no_iter; + other_tp_foreach = tp_other->tp_seq->tp_foreach; + ASSERT(other_tp_foreach); + lhs_getitem_index_fast = tp_self->tp_seq->tp_getitem_index_fast; + lhs_size = DeeType_INVOKE_SIZE_NODEFAULT(tp_self, self); + if unlikely(lhs_size == (size_t)-1) + goto err; + if (other_tp_foreach == &DeeSeq_DefaultForeachWithSizeAndGetItemIndexFast) { + size_t rhs_size = (*tp_other->tp_seq->tp_size)(other); + if unlikely(rhs_size == (size_t)-1) + goto err; + result = seq_docompareeq__lhs_size_and_getitem_index_fast__rhs_size_and_getitem_index_fast(self, lhs_size, lhs_getitem_index_fast, + other, rhs_size, tp_other->tp_seq->tp_getitem_index_fast); + } else if (other_tp_foreach == &DeeSeq_DefaultForeachWithSizeAndTryGetItemIndex) { + size_t rhs_size = (*tp_other->tp_seq->tp_size)(other); + if unlikely(rhs_size == (size_t)-1) + goto err; + result = seq_docompareeq__lhs_size_and_getitem_index_fast__rhs_size_and_trygetitem_index(self, lhs_size, lhs_getitem_index_fast, + other, rhs_size, tp_other->tp_seq->tp_trygetitem_index); + } else if (other_tp_foreach == &DeeSeq_DefaultForeachWithSizeAndGetItemIndex || + other_tp_foreach == &DeeSeq_DefaultForeachWithSizeDefaultAndGetItemIndexDefault) { + size_t rhs_size = (*tp_other->tp_seq->tp_size)(other); + if unlikely(rhs_size == (size_t)-1) + goto err; + result = seq_docompareeq__lhs_size_and_getitem_index_fast__rhs_size_and_getitem_index(self, lhs_size, lhs_getitem_index_fast, + other, rhs_size, tp_other->tp_seq->tp_getitem_index); + } else if (other_tp_foreach == &DeeSeq_DefaultForeachWithSizeObAndGetItem) { + DREF DeeObject *rhs_sizeob = (*tp_other->tp_seq->tp_sizeob)(other); + if unlikely(!rhs_sizeob) + goto err; + result = seq_docompareeq__lhs_size_and_getitem_index_fast__rhs_sizeob_and_getitem(self, lhs_size, lhs_getitem_index_fast, + other, rhs_sizeob, tp_other->tp_seq->tp_getitem); + Dee_Decref(rhs_sizeob); + } else { + struct seq_compareforeach__size_and_getitem_index__data data; + Dee_ssize_t foreach_result; + data.scf_sgi_other = self; + data.scf_sgi_osize = lhs_size; + data.scf_sgi_oindex = 0; + data.scf_sgi_ogetitem_index = lhs_getitem_index_fast; + foreach_result = (*other_tp_foreach)(other, &seq_compareeq__lhs_size_and_getitem_index_fast__rhs_foreach__cb, &data); + ASSERT(foreach_result == SEQ_COMPAREEQ_FOREACH_RESULT_EQUAL || + foreach_result == SEQ_COMPAREEQ_FOREACH_RESULT_ERROR || + foreach_result == SEQ_COMPAREEQ_FOREACH_RESULT_NOTEQUAL); + if unlikely(foreach_result == SEQ_COMPAREEQ_FOREACH_RESULT_ERROR) + goto err; + if (foreach_result == SEQ_COMPAREEQ_FOREACH_RESULT_EQUAL && + data.scf_sgi_oindex >= data.scf_sgi_osize) { + result = 0; + } else { + result = 1; + } + } + return result; +err_other_no_iter: + err_unimplemented_operator(tp_other, OPERATOR_ITER); +err: + return Dee_COMPARE_ERR; +} + +DEFINE_INTERNAL_SEQ_OPERATOR(int, DefaultCompareEqWithSizeAndTryGetItemIndex, + (DeeObject *self, DeeObject *other)) { + int result; + size_t lhs_size; + DeeTypeObject *tp_other = Dee_TYPE(other); + DREF DeeObject *(DCALL *lhs_trygetitem_index)(DeeObject *self, size_t index); + Dee_ssize_t (DCALL *other_tp_foreach)(DeeObject *__restrict self, Dee_foreach_t proc, void *arg); + LOAD_TP_SELF; + if ((!tp_other->tp_seq || !tp_other->tp_seq->tp_foreach) && !DeeType_InheritIter(tp_other)) + goto err_other_no_iter; + other_tp_foreach = tp_other->tp_seq->tp_foreach; + ASSERT(other_tp_foreach); + lhs_trygetitem_index = tp_self->tp_seq->tp_trygetitem_index; + lhs_size = DeeType_INVOKE_SIZE_NODEFAULT(tp_self, self); + if unlikely(lhs_size == (size_t)-1) + goto err; + if (other_tp_foreach == &DeeSeq_DefaultForeachWithSizeAndGetItemIndexFast) { + size_t rhs_size = (*tp_other->tp_seq->tp_size)(other); + if unlikely(rhs_size == (size_t)-1) + goto err; + result = seq_docompareeq__lhs_size_and_trygetitem_index__rhs_size_and_getitem_index_fast(self, lhs_size, lhs_trygetitem_index, + other, rhs_size, tp_other->tp_seq->tp_getitem_index_fast); + } else if (other_tp_foreach == &DeeSeq_DefaultForeachWithSizeAndTryGetItemIndex) { + size_t rhs_size = (*tp_other->tp_seq->tp_size)(other); + if unlikely(rhs_size == (size_t)-1) + goto err; + result = seq_docompareeq__lhs_size_and_trygetitem_index__rhs_size_and_trygetitem_index(self, lhs_size, lhs_trygetitem_index, + other, rhs_size, tp_other->tp_seq->tp_trygetitem_index); + } else if (other_tp_foreach == &DeeSeq_DefaultForeachWithSizeAndGetItemIndex || + other_tp_foreach == &DeeSeq_DefaultForeachWithSizeDefaultAndGetItemIndexDefault) { + size_t rhs_size = (*tp_other->tp_seq->tp_size)(other); + if unlikely(rhs_size == (size_t)-1) + goto err; + result = seq_docompareeq__lhs_size_and_trygetitem_index__rhs_size_and_getitem_index(self, lhs_size, lhs_trygetitem_index, + other, rhs_size, tp_other->tp_seq->tp_getitem_index); + } else if (other_tp_foreach == &DeeSeq_DefaultForeachWithSizeObAndGetItem) { + DREF DeeObject *rhs_sizeob = (*tp_other->tp_seq->tp_sizeob)(other); + if unlikely(!rhs_sizeob) + goto err; + result = seq_docompareeq__lhs_size_and_trygetitem_index__rhs_sizeob_and_getitem(self, lhs_size, lhs_trygetitem_index, + other, rhs_sizeob, tp_other->tp_seq->tp_getitem); + Dee_Decref(rhs_sizeob); + } else { + struct seq_compareforeach__size_and_getitem_index__data data; + Dee_ssize_t foreach_result; + data.scf_sgi_other = self; + data.scf_sgi_osize = lhs_size; + data.scf_sgi_oindex = 0; + data.scf_sgi_ogetitem_index = lhs_trygetitem_index; + foreach_result = (*other_tp_foreach)(other, &seq_compareeq__lhs_size_and_trygetitem_index__rhs_foreach__cb, &data); + ASSERT(foreach_result == SEQ_COMPAREEQ_FOREACH_RESULT_EQUAL || + foreach_result == SEQ_COMPAREEQ_FOREACH_RESULT_ERROR || + foreach_result == SEQ_COMPAREEQ_FOREACH_RESULT_NOTEQUAL); + if unlikely(foreach_result == SEQ_COMPAREEQ_FOREACH_RESULT_ERROR) + goto err; + if (foreach_result == SEQ_COMPAREEQ_FOREACH_RESULT_EQUAL && + data.scf_sgi_oindex >= data.scf_sgi_osize) { + result = 0; + } else { + result = 1; + } + } + return result; +err_other_no_iter: + err_unimplemented_operator(tp_other, OPERATOR_ITER); +err: + return Dee_COMPARE_ERR; +} + +DEFINE_INTERNAL_SEQ_OPERATOR(int, DefaultCompareEqWithSizeAndGetItemIndex, + (DeeObject *self, DeeObject *other)) { + int result; + size_t lhs_size; + DeeTypeObject *tp_other = Dee_TYPE(other); + DREF DeeObject *(DCALL *lhs_getitem_index)(DeeObject *self, size_t index); + Dee_ssize_t (DCALL *other_tp_foreach)(DeeObject *__restrict self, Dee_foreach_t proc, void *arg); + LOAD_TP_SELF; + if ((!tp_other->tp_seq || !tp_other->tp_seq->tp_foreach) && !DeeType_InheritIter(tp_other)) + goto err_other_no_iter; + other_tp_foreach = tp_other->tp_seq->tp_foreach; + ASSERT(other_tp_foreach); + lhs_getitem_index = tp_self->tp_seq->tp_trygetitem_index; + lhs_size = DeeType_INVOKE_SIZE_NODEFAULT(tp_self, self); + if unlikely(lhs_size == (size_t)-1) + goto err; + if (other_tp_foreach == &DeeSeq_DefaultForeachWithSizeAndGetItemIndexFast) { + size_t rhs_size = (*tp_other->tp_seq->tp_size)(other); + if unlikely(rhs_size == (size_t)-1) + goto err; + result = seq_docompareeq__lhs_size_and_getitem_index__rhs_size_and_getitem_index_fast(self, lhs_size, lhs_getitem_index, + other, rhs_size, tp_other->tp_seq->tp_getitem_index_fast); + } else if (other_tp_foreach == &DeeSeq_DefaultForeachWithSizeAndTryGetItemIndex) { + size_t rhs_size = (*tp_other->tp_seq->tp_size)(other); + if unlikely(rhs_size == (size_t)-1) + goto err; + result = seq_docompareeq__lhs_size_and_getitem_index__rhs_size_and_trygetitem_index(self, lhs_size, lhs_getitem_index, + other, rhs_size, tp_other->tp_seq->tp_trygetitem_index); + } else if (other_tp_foreach == &DeeSeq_DefaultForeachWithSizeAndGetItemIndex || + other_tp_foreach == &DeeSeq_DefaultForeachWithSizeDefaultAndGetItemIndexDefault) { + size_t rhs_size = (*tp_other->tp_seq->tp_size)(other); + if unlikely(rhs_size == (size_t)-1) + goto err; + result = seq_docompareeq__lhs_size_and_getitem_index__rhs_size_and_getitem_index(self, lhs_size, lhs_getitem_index, + other, rhs_size, tp_other->tp_seq->tp_getitem_index); + } else if (other_tp_foreach == &DeeSeq_DefaultForeachWithSizeObAndGetItem) { + DREF DeeObject *rhs_sizeob = (*tp_other->tp_seq->tp_sizeob)(other); + if unlikely(!rhs_sizeob) + goto err; + result = seq_docompareeq__lhs_size_and_getitem_index__rhs_sizeob_and_getitem(self, lhs_size, lhs_getitem_index, + other, rhs_sizeob, tp_other->tp_seq->tp_getitem); + Dee_Decref(rhs_sizeob); + } else { + struct seq_compareforeach__size_and_getitem_index__data data; + Dee_ssize_t foreach_result; + data.scf_sgi_other = self; + data.scf_sgi_osize = lhs_size; + data.scf_sgi_oindex = 0; + data.scf_sgi_ogetitem_index = lhs_getitem_index; + foreach_result = (*other_tp_foreach)(other, &seq_compareeq__lhs_size_and_getitem_index__rhs_foreach__cb, &data); + ASSERT(foreach_result == SEQ_COMPAREEQ_FOREACH_RESULT_EQUAL || + foreach_result == SEQ_COMPAREEQ_FOREACH_RESULT_ERROR || + foreach_result == SEQ_COMPAREEQ_FOREACH_RESULT_NOTEQUAL); + if unlikely(foreach_result == SEQ_COMPAREEQ_FOREACH_RESULT_ERROR) + goto err; + if (foreach_result == SEQ_COMPAREEQ_FOREACH_RESULT_EQUAL && + data.scf_sgi_oindex >= data.scf_sgi_osize) { + result = 0; + } else { + result = 1; + } + } + return result; +err_other_no_iter: + err_unimplemented_operator(tp_other, OPERATOR_ITER); +err: + return Dee_COMPARE_ERR; +} + +DEFINE_INTERNAL_SEQ_OPERATOR(int, DefaultCompareEqWithSizeObAndGetItem, + (DeeObject *self, DeeObject *other)) { + int result; + DREF DeeObject *lhs_sizeob; + DeeTypeObject *tp_other = Dee_TYPE(other); + DREF DeeObject *(DCALL *lhs_getitem)(DeeObject *self, DeeObject *index); +#ifdef DEFINE_TYPED_OPERATORS + DREF DeeObject *(DCALL *lhs_tgetitem)(DeeTypeObject *tp_self, DeeObject *self, DeeObject *index); +#endif /* DEFINE_TYPED_OPERATORS */ + Dee_ssize_t (DCALL *other_tp_foreach)(DeeObject *__restrict self, Dee_foreach_t proc, void *arg); + LOAD_TP_SELF; + if ((!tp_other->tp_seq || !tp_other->tp_seq->tp_foreach) && !DeeType_InheritIter(tp_other)) + goto err_other_no_iter; + other_tp_foreach = tp_other->tp_seq->tp_foreach; + ASSERT(other_tp_foreach); + lhs_getitem = tp_self->tp_seq->tp_getitem; +#ifdef DEFINE_TYPED_OPERATORS + lhs_tgetitem = lhs_getitem == &instance_getitem ? &instance_tgetitem : NULL; +#endif /* DEFINE_TYPED_OPERATORS */ + lhs_sizeob = DeeType_INVOKE_ITER_NODEFAULT(tp_self, self); + if unlikely(!lhs_sizeob) + goto err; + if (other_tp_foreach == &DeeSeq_DefaultForeachWithSizeAndGetItemIndexFast) { + size_t rhs_size = (*tp_other->tp_seq->tp_size)(other); + if unlikely(rhs_size == (size_t)-1) + goto err_lhs_sizeob; +#ifdef DEFINE_TYPED_OPERATORS + if (lhs_tgetitem) { + result = seq_docompareeq__lhs_tsizeob_and_getitem__rhs_size_and_getitem_index_fast(tp_self, self, lhs_sizeob, lhs_tgetitem, other, + rhs_size, tp_other->tp_seq->tp_getitem_index_fast); + } else +#endif /* DEFINE_TYPED_OPERATORS */ + { + result = seq_docompareeq__lhs_sizeob_and_getitem__rhs_size_and_getitem_index_fast(self, lhs_sizeob, lhs_getitem, other, + rhs_size, tp_other->tp_seq->tp_getitem_index_fast); + } + } else if (other_tp_foreach == &DeeSeq_DefaultForeachWithSizeAndTryGetItemIndex) { + size_t rhs_size = (*tp_other->tp_seq->tp_size)(other); + if unlikely(rhs_size == (size_t)-1) + goto err_lhs_sizeob; +#ifdef DEFINE_TYPED_OPERATORS + if (lhs_tgetitem) { + result = seq_docompareeq__lhs_tsizeob_and_getitem__rhs_size_and_trygetitem_index(tp_self, self, lhs_sizeob, lhs_tgetitem, other, + rhs_size, tp_other->tp_seq->tp_trygetitem_index); + } else +#endif /* DEFINE_TYPED_OPERATORS */ + { + result = seq_docompareeq__lhs_sizeob_and_getitem__rhs_size_and_trygetitem_index(self, lhs_sizeob, lhs_getitem, other, + rhs_size, tp_other->tp_seq->tp_trygetitem_index); + } + } else if (other_tp_foreach == &DeeSeq_DefaultForeachWithSizeAndGetItemIndex || + other_tp_foreach == &DeeSeq_DefaultForeachWithSizeDefaultAndGetItemIndexDefault) { + size_t rhs_size = (*tp_other->tp_seq->tp_size)(other); + if unlikely(rhs_size == (size_t)-1) + goto err_lhs_sizeob; +#ifdef DEFINE_TYPED_OPERATORS + if (lhs_tgetitem) { + result = seq_docompareeq__lhs_tsizeob_and_getitem__rhs_size_and_getitem_index(tp_self, self, lhs_sizeob, lhs_tgetitem, other, + rhs_size, tp_other->tp_seq->tp_getitem_index); + } else +#endif /* DEFINE_TYPED_OPERATORS */ + { + result = seq_docompareeq__lhs_sizeob_and_getitem__rhs_size_and_getitem_index(self, lhs_sizeob, lhs_getitem, other, + rhs_size, tp_other->tp_seq->tp_getitem_index); + } + } else if (other_tp_foreach == &DeeSeq_DefaultForeachWithSizeObAndGetItem) { + DREF DeeObject *rhs_sizeob = (*tp_other->tp_seq->tp_sizeob)(other); + if unlikely(!rhs_sizeob) + goto err_lhs_sizeob; +#ifdef DEFINE_TYPED_OPERATORS + if (lhs_tgetitem) { + result = seq_docompareeq__lhs_tsizeob_and_getitem__rhs_sizeob_and_getitem(tp_self, self, lhs_sizeob, lhs_tgetitem, other, + rhs_sizeob, tp_other->tp_seq->tp_getitem); + } else +#endif /* DEFINE_TYPED_OPERATORS */ + { + result = seq_docompareeq__lhs_sizeob_and_getitem__rhs_sizeob_and_getitem(self, lhs_sizeob, lhs_getitem, other, + rhs_sizeob, tp_other->tp_seq->tp_getitem); + } + Dee_Decref(rhs_sizeob); + } else { + Dee_ssize_t foreach_result; + DREF DeeObject *lhs_indexob; + lhs_indexob = DeeObject_NewDefault(Dee_TYPE(lhs_sizeob)); + if unlikely(!lhs_indexob) + goto err_lhs_sizeob; +#ifdef DEFINE_TYPED_OPERATORS + if (lhs_tgetitem) { + struct seq_compare_foreach__tsizeob_and_getitem__data data; + data.scf_tsg_tpother = tp_self; + data.scf_tsg_other = self; + data.scf_tsg_osize = lhs_sizeob; + data.scf_tsg_oindex = lhs_indexob; + data.scf_tsg_otgetitem = lhs_tgetitem; + foreach_result = (*other_tp_foreach)(other, &seq_compareeq__tlhs_sizeob_and_getitem__rhs_foreach__cb, &data); + } else +#endif /* DEFINE_TYPED_OPERATORS */ + { + struct seq_compare_foreach__sizeob_and_getitem__data data; + data.scf_sg_other = self; + data.scf_sg_osize = lhs_sizeob; + data.scf_sg_oindex = lhs_indexob; + data.scf_sg_ogetitem = lhs_getitem; + foreach_result = (*other_tp_foreach)(other, &seq_compareeq__lhs_sizeob_and_getitem__rhs_foreach__cb, &data); + } + Dee_Decref(lhs_indexob); + ASSERT(foreach_result == SEQ_COMPAREEQ_FOREACH_RESULT_EQUAL || + foreach_result == SEQ_COMPAREEQ_FOREACH_RESULT_ERROR || + foreach_result == SEQ_COMPAREEQ_FOREACH_RESULT_NOTEQUAL); + if unlikely(foreach_result == SEQ_COMPAREEQ_FOREACH_RESULT_ERROR) + goto err_lhs_sizeob; + result = foreach_result == SEQ_COMPAREEQ_FOREACH_RESULT_EQUAL ? 0 : 1; + } + Dee_Decref(lhs_sizeob); + return result; +err_lhs_sizeob: + Dee_Decref(lhs_sizeob); + return Dee_COMPARE_ERR; +err_other_no_iter: + err_unimplemented_operator(tp_other, OPERATOR_ITER); +err: + return Dee_COMPARE_ERR; +} + +DEFINE_INTERNAL_SET_OPERATOR(int, DefaultCompareEqWithForeachDefault, + (DeeObject *self, DeeObject *other)) { + size_t rhs_size; + Dee_ssize_t contains_status; + DeeTypeObject *tp_other = Dee_TYPE(other); + struct set_compare__lhs_foreach__rhs__data data; + LOAD_TP_SELF; + if ((!tp_other->tp_seq || !tp_other->tp_seq->tp_contains) && !DeeType_InheritContains(tp_other)) + goto err_other_no_contains; + data.sc_lfr_rhs = other; + data.sc_lfr_rcontains = tp_other->tp_seq->tp_contains; + contains_status = DeeType_INVOKE_FOREACH(tp_self, self, &set_compare__lhs_foreach__rhs__cb, &data); + if unlikely(contains_status == -1) + goto err; + if (contains_status == -2) + return 1; /* "other" is missing some element of "self" */ + rhs_size = DeeObject_Size(other); + if unlikely(rhs_size == (size_t)-1) + goto err; + if ((size_t)contains_status != rhs_size) + return 1; /* Sets have different sizes */ + return 0; +err_other_no_contains: + err_unimplemented_operator(tp_other, OPERATOR_CONTAINS); +err: + return Dee_COMPARE_ERR; +} + +DEFINE_INTERNAL_MAP_OPERATOR(int, DefaultCompareEqWithForeachPairDefault, + (DeeObject *self, DeeObject *other)) { + size_t rhs_size; + Dee_ssize_t contains_status; + DeeTypeObject *tp_other = Dee_TYPE(other); + struct map_compare__lhs_foreach__rhs__data data; + LOAD_TP_SELF; + if ((!tp_other->tp_seq || !tp_other->tp_seq->tp_trygetitem) && !DeeType_InheritGetItem(tp_other)) + goto err_other_no_getitem; + data.mc_lfr_rhs = other; + data.mc_lfr_rtrygetitem = tp_other->tp_seq->tp_trygetitem; + contains_status = DeeType_INVOKE_FOREACH_PAIR(tp_self, self, &map_compare__lhs_foreach__rhs__cb, &data); + if unlikely(contains_status == -1) + goto err; + if (contains_status == -2) + return 1; /* "other" is missing some element of "self", or has a different value for it */ + rhs_size = DeeObject_Size(other); + if unlikely(rhs_size == (size_t)-1) + goto err; + if ((size_t)contains_status != rhs_size) + return 1; /* Maps have different sizes */ + return 0; +err_other_no_getitem: + err_unimplemented_operator(tp_other, OPERATOR_GETITEM); +err: + return Dee_COMPARE_ERR; +} + + +/* tp_compare */ +DEFINE_INTERNAL_OPERATOR(int, DefaultCompareWithEqAndLo, + (DeeObject *self, DeeObject *other)) { + int temp; + DREF DeeObject *cmp_ob; + LOAD_TP_SELF; + cmp_ob = DeeType_INVOKE_EQ(tp_self, self, other); + if unlikely(!cmp_ob) + goto err; + temp = DeeObject_BoolInherited(cmp_ob); + if unlikely(temp < 0) + goto err; + if (temp) + return 0; /* Equal */ + cmp_ob = DeeType_INVOKE_LO(tp_self, self, other); + if unlikely(!cmp_ob) + goto err; + temp = DeeObject_BoolInherited(cmp_ob); + if unlikely(temp < 0) + goto err; + if (temp) + return -1; /* Less */ + return 1; /* Greater */ +err: + return Dee_COMPARE_ERR; +} + +DEFINE_INTERNAL_OPERATOR(int, DefaultCompareWithEqAndLe, + (DeeObject *self, DeeObject *other)) { + int temp; + DREF DeeObject *cmp_ob; + LOAD_TP_SELF; + cmp_ob = DeeType_INVOKE_EQ(tp_self, self, other); + if unlikely(!cmp_ob) + goto err; + temp = DeeObject_BoolInherited(cmp_ob); + if unlikely(temp < 0) + goto err; + if (temp) + return 0; /* Equal */ + cmp_ob = DeeType_INVOKE_LE(tp_self, self, other); + if unlikely(!cmp_ob) + goto err; + temp = DeeObject_BoolInherited(cmp_ob); + if unlikely(temp < 0) + goto err; + if (temp) + return -1; /* Less */ + return 1; /* Greater */ +err: + return Dee_COMPARE_ERR; +} + +DEFINE_INTERNAL_OPERATOR(int, DefaultCompareWithEqAndGr, + (DeeObject *self, DeeObject *other)) { + int temp; + DREF DeeObject *cmp_ob; + LOAD_TP_SELF; + cmp_ob = DeeType_INVOKE_EQ(tp_self, self, other); + if unlikely(!cmp_ob) + goto err; + temp = DeeObject_BoolInherited(cmp_ob); + if unlikely(temp < 0) + goto err; + if (temp) + return 0; /* Equal */ + cmp_ob = DeeType_INVOKE_GR(tp_self, self, other); + if unlikely(!cmp_ob) + goto err; + temp = DeeObject_BoolInherited(cmp_ob); + if unlikely(temp < 0) + goto err; + if (temp) + return 1; /* Greater */ + return -1; /* Less */ +err: + return Dee_COMPARE_ERR; +} + +DEFINE_INTERNAL_OPERATOR(int, DefaultCompareWithEqAndGe, + (DeeObject *self, DeeObject *other)) { + int temp; + DREF DeeObject *cmp_ob; + LOAD_TP_SELF; + cmp_ob = DeeType_INVOKE_EQ(tp_self, self, other); + if unlikely(!cmp_ob) + goto err; + temp = DeeObject_BoolInherited(cmp_ob); + if unlikely(temp < 0) + goto err; + if (temp) + return 0; /* Equal */ + cmp_ob = DeeType_INVOKE_GE(tp_self, self, other); + if unlikely(!cmp_ob) + goto err; + temp = DeeObject_BoolInherited(cmp_ob); + if unlikely(temp < 0) + goto err; + if (temp) + return 1; /* Greater */ + return -1; /* Less */ +err: + return Dee_COMPARE_ERR; +} + +DEFINE_INTERNAL_OPERATOR(int, DefaultCompareWithNeAndLo, + (DeeObject *self, DeeObject *other)) { + int temp; + DREF DeeObject *cmp_ob; + LOAD_TP_SELF; + cmp_ob = DeeType_INVOKE_NE(tp_self, self, other); + if unlikely(!cmp_ob) + goto err; + temp = DeeObject_BoolInherited(cmp_ob); + if unlikely(temp < 0) + goto err; + if (!temp) + return 0; /* Equal */ + cmp_ob = DeeType_INVOKE_LO(tp_self, self, other); + if unlikely(!cmp_ob) + goto err; + temp = DeeObject_BoolInherited(cmp_ob); + if unlikely(temp < 0) + goto err; + if (temp) + return -1; /* Less */ + return 1; /* Greater */ +err: + return Dee_COMPARE_ERR; +} + +DEFINE_INTERNAL_OPERATOR(int, DefaultCompareWithNeAndLe, + (DeeObject *self, DeeObject *other)) { + int temp; + DREF DeeObject *cmp_ob; + LOAD_TP_SELF; + cmp_ob = DeeType_INVOKE_NE(tp_self, self, other); + if unlikely(!cmp_ob) + goto err; + temp = DeeObject_BoolInherited(cmp_ob); + if unlikely(temp < 0) + goto err; + if (!temp) + return 0; /* Equal */ + cmp_ob = DeeType_INVOKE_LE(tp_self, self, other); + if unlikely(!cmp_ob) + goto err; + temp = DeeObject_BoolInherited(cmp_ob); + if unlikely(temp < 0) + goto err; + if (temp) + return -1; /* Less */ + return 1; /* Greater */ +err: + return Dee_COMPARE_ERR; +} + +DEFINE_INTERNAL_OPERATOR(int, DefaultCompareWithNeAndGr, + (DeeObject *self, DeeObject *other)) { + int temp; + DREF DeeObject *cmp_ob; + LOAD_TP_SELF; + cmp_ob = DeeType_INVOKE_NE(tp_self, self, other); + if unlikely(!cmp_ob) + goto err; + temp = DeeObject_BoolInherited(cmp_ob); + if unlikely(temp < 0) + goto err; + if (!temp) + return 0; /* Equal */ + cmp_ob = DeeType_INVOKE_GR(tp_self, self, other); + if unlikely(!cmp_ob) + goto err; + temp = DeeObject_BoolInherited(cmp_ob); + if unlikely(temp < 0) + goto err; + if (temp) + return 1; /* Greater */ + return -1; /* Less */ +err: + return Dee_COMPARE_ERR; +} + +DEFINE_INTERNAL_OPERATOR(int, DefaultCompareWithNeAndGe, + (DeeObject *self, DeeObject *other)) { + int temp; + DREF DeeObject *cmp_ob; + LOAD_TP_SELF; + cmp_ob = DeeType_INVOKE_NE(tp_self, self, other); + if unlikely(!cmp_ob) + goto err; + temp = DeeObject_BoolInherited(cmp_ob); + if unlikely(temp < 0) + goto err; + if (!temp) + return 0; /* Equal */ + cmp_ob = DeeType_INVOKE_GE(tp_self, self, other); + if unlikely(!cmp_ob) + goto err; + temp = DeeObject_BoolInherited(cmp_ob); + if unlikely(temp < 0) + goto err; + if (temp) + return 1; /* Greater */ + return -1; /* Less */ +err: + return Dee_COMPARE_ERR; +} + +DEFINE_INTERNAL_SEQ_OPERATOR(int, DefaultCompareWithForeachDefault, + (DeeObject *self, DeeObject *other)) { + DeeTypeObject *tp_other = Dee_TYPE(other); + Dee_ssize_t (DCALL *other_tp_foreach)(DeeObject *__restrict self, Dee_foreach_t proc, void *arg); + Dee_ssize_t result; + LOAD_TP_SELF; + if ((!tp_other->tp_seq || !tp_other->tp_seq->tp_foreach) && !DeeType_InheritIter(tp_other)) + goto err_other_no_iter; + other_tp_foreach = tp_other->tp_seq->tp_foreach; + ASSERT(other_tp_foreach); + if (other_tp_foreach == &DeeSeq_DefaultForeachWithSizeAndGetItemIndexFast) { + struct seq_compareforeach__size_and_getitem_index__data data; + data.scf_sgi_osize = (*tp_other->tp_seq->tp_size)(other); + if unlikely(data.scf_sgi_osize == (size_t)-1) + goto err; + data.scf_sgi_other = other; + data.scf_sgi_oindex = 0; + data.scf_sgi_ogetitem_index = tp_other->tp_seq->tp_getitem_index_fast; + result = DeeType_INVOKE_FOREACH(tp_self, self, &seq_compare__lhs_foreach__rhs_size_and_getitem_index_fast__cb, &data); + if (result == SEQ_COMPARE_FOREACH_RESULT_EQUAL && data.scf_sgi_oindex < data.scf_sgi_osize) + result = SEQ_COMPARE_FOREACH_RESULT_LESS; + } else if (other_tp_foreach == &DeeSeq_DefaultForeachWithSizeAndTryGetItemIndex) { + struct seq_compareforeach__size_and_getitem_index__data data; + data.scf_sgi_osize = (*tp_other->tp_seq->tp_size)(other); + if unlikely(data.scf_sgi_osize == (size_t)-1) + goto err; + data.scf_sgi_other = other; + data.scf_sgi_oindex = 0; + data.scf_sgi_ogetitem_index = tp_other->tp_seq->tp_trygetitem_index; + result = DeeType_INVOKE_FOREACH(tp_self, self, &seq_compare__lhs_foreach__rhs_size_and_trygetitem_index__cb, &data); + if (result == SEQ_COMPARE_FOREACH_RESULT_EQUAL && data.scf_sgi_oindex < data.scf_sgi_osize) + result = SEQ_COMPARE_FOREACH_RESULT_LESS; + } else if (other_tp_foreach == &DeeSeq_DefaultForeachWithSizeAndGetItemIndex || + other_tp_foreach == &DeeSeq_DefaultForeachWithSizeDefaultAndGetItemIndexDefault) { + struct seq_compareforeach__size_and_getitem_index__data data; + data.scf_sgi_osize = (*tp_other->tp_seq->tp_size)(other); + if unlikely(data.scf_sgi_osize == (size_t)-1) + goto err; + data.scf_sgi_other = other; + data.scf_sgi_oindex = 0; + data.scf_sgi_ogetitem_index = tp_other->tp_seq->tp_getitem_index; + result = DeeType_INVOKE_FOREACH(tp_self, self, &seq_compare__lhs_foreach__rhs_size_and_getitem_index__cb, &data); + if (result == SEQ_COMPARE_FOREACH_RESULT_EQUAL && data.scf_sgi_oindex < data.scf_sgi_osize) + result = SEQ_COMPARE_FOREACH_RESULT_LESS; + } else if (other_tp_foreach == &DeeSeq_DefaultForeachWithSizeObAndGetItem) { + struct seq_compare_foreach__sizeob_and_getitem__data data; + data.scf_sg_osize = (*tp_other->tp_seq->tp_sizeob)(other); + if unlikely(!data.scf_sg_osize) + goto err; + data.scf_sg_oindex = DeeObject_NewDefault(Dee_TYPE(data.scf_sg_osize)); + if unlikely(!data.scf_sg_oindex) { + result = SEQ_COMPARE_FOREACH_RESULT_ERROR; + } else { + data.scf_sg_other = other; + data.scf_sg_ogetitem = tp_other->tp_seq->tp_getitem; + result = DeeType_INVOKE_FOREACH(tp_self, self, &seq_compare__lhs_foreach__rhs_sizeob_and_getitem__cb, &data); + if (result == SEQ_COMPARE_FOREACH_RESULT_EQUAL) { + int temp = DeeObject_CompareLo(data.scf_sg_oindex, data.scf_sg_osize); + Dee_Decref(data.scf_sg_oindex); + if unlikely(temp < 0) { + result = SEQ_COMPARE_FOREACH_RESULT_ERROR; + } else if (temp) { + result = SEQ_COMPARE_FOREACH_RESULT_LESS; + } + } else { + Dee_Decref(data.scf_sg_oindex); + } + } + Dee_Decref(data.scf_sg_osize); + } else { + DREF DeeObject *rhs_iter; + rhs_iter = (*tp_other->tp_seq->tp_iter)(other); + if unlikely(!rhs_iter) + goto err; + result = DeeType_INVOKE_FOREACH(tp_self, self, &seq_compare__lhs_foreach__rhs_iter__cb, rhs_iter); + if (result == SEQ_COMPARE_FOREACH_RESULT_EQUAL) { + DREF DeeObject *next = DeeObject_IterNext(rhs_iter); + Dee_Decref(rhs_iter); + if unlikely(!next) + goto err; + if (next != ITER_DONE) { + Dee_Decref(next); + result = SEQ_COMPARE_FOREACH_RESULT_LESS; + } + } else { + Dee_Decref(rhs_iter); + } + } + ASSERT(result == SEQ_COMPARE_FOREACH_RESULT_EQUAL || + result == SEQ_COMPARE_FOREACH_RESULT_ERROR || + result == SEQ_COMPARE_FOREACH_RESULT_LESS || + result == SEQ_COMPARE_FOREACH_RESULT_GREATER); + if unlikely(result == SEQ_COMPARE_FOREACH_RESULT_ERROR) + goto err; + if (result == SEQ_COMPARE_FOREACH_RESULT_LESS) + return -1; + if (result == SEQ_COMPARE_FOREACH_RESULT_GREATER) + return 1; + return 0; /* Equal */ +err_other_no_iter: + err_unimplemented_operator(tp_other, OPERATOR_ITER); +err: + return Dee_COMPARE_ERR; +} + +DEFINE_INTERNAL_SEQ_OPERATOR(int, DefaultCompareWithSizeAndGetItemIndexFast, + (DeeObject *self, DeeObject *other)) { + int result; + size_t lhs_size; + DeeTypeObject *tp_other = Dee_TYPE(other); + DREF DeeObject *(DCALL *lhs_getitem_index_fast)(DeeObject *self, size_t index); + Dee_ssize_t (DCALL *other_tp_foreach)(DeeObject *__restrict self, Dee_foreach_t proc, void *arg); + LOAD_TP_SELF; + if ((!tp_other->tp_seq || !tp_other->tp_seq->tp_foreach) && !DeeType_InheritIter(tp_other)) + goto err_other_no_iter; + other_tp_foreach = tp_other->tp_seq->tp_foreach; + ASSERT(other_tp_foreach); + lhs_getitem_index_fast = tp_self->tp_seq->tp_getitem_index_fast; + lhs_size = DeeType_INVOKE_SIZE_NODEFAULT(tp_self, self); + if unlikely(lhs_size == (size_t)-1) + goto err; + if (other_tp_foreach == &DeeSeq_DefaultForeachWithSizeAndGetItemIndexFast) { + size_t rhs_size = (*tp_other->tp_seq->tp_size)(other); + if unlikely(rhs_size == (size_t)-1) + goto err; + result = seq_docompare__lhs_size_and_getitem_index_fast__rhs_size_and_getitem_index_fast(self, lhs_size, lhs_getitem_index_fast, + other, rhs_size, tp_other->tp_seq->tp_getitem_index_fast); + } else if (other_tp_foreach == &DeeSeq_DefaultForeachWithSizeAndTryGetItemIndex) { + size_t rhs_size = (*tp_other->tp_seq->tp_size)(other); + if unlikely(rhs_size == (size_t)-1) + goto err; + result = seq_docompare__lhs_size_and_getitem_index_fast__rhs_size_and_trygetitem_index(self, lhs_size, lhs_getitem_index_fast, + other, rhs_size, tp_other->tp_seq->tp_trygetitem_index); + } else if (other_tp_foreach == &DeeSeq_DefaultForeachWithSizeAndGetItemIndex || + other_tp_foreach == &DeeSeq_DefaultForeachWithSizeDefaultAndGetItemIndexDefault) { + size_t rhs_size = (*tp_other->tp_seq->tp_size)(other); + if unlikely(rhs_size == (size_t)-1) + goto err; + result = seq_docompare__lhs_size_and_getitem_index_fast__rhs_size_and_getitem_index(self, lhs_size, lhs_getitem_index_fast, + other, rhs_size, tp_other->tp_seq->tp_getitem_index); + } else if (other_tp_foreach == &DeeSeq_DefaultForeachWithSizeObAndGetItem) { + DREF DeeObject *rhs_sizeob = (*tp_other->tp_seq->tp_sizeob)(other); + if unlikely(!rhs_sizeob) + goto err; + result = seq_docompare__lhs_size_and_getitem_index_fast__rhs_sizeob_and_getitem(self, lhs_size, lhs_getitem_index_fast, + other, rhs_sizeob, tp_other->tp_seq->tp_getitem); + Dee_Decref(rhs_sizeob); + } else { + struct seq_compareforeach__size_and_getitem_index__data data; + Dee_ssize_t foreach_result; + data.scf_sgi_other = self; + data.scf_sgi_osize = lhs_size; + data.scf_sgi_oindex = 0; + data.scf_sgi_ogetitem_index = lhs_getitem_index_fast; + foreach_result = (*other_tp_foreach)(other, &seq_compare__lhs_size_and_getitem_index_fast__rhs_foreach__cb, &data); + ASSERT(foreach_result == SEQ_COMPARE_FOREACH_RESULT_EQUAL || + foreach_result == SEQ_COMPARE_FOREACH_RESULT_ERROR || + foreach_result == SEQ_COMPARE_FOREACH_RESULT_LESS || + foreach_result == SEQ_COMPARE_FOREACH_RESULT_GREATER); + if unlikely(foreach_result == SEQ_COMPARE_FOREACH_RESULT_ERROR) + goto err; + if (foreach_result == SEQ_COMPAREEQ_FOREACH_RESULT_EQUAL) { + result = 0; + } else if (foreach_result == SEQ_COMPARE_FOREACH_RESULT_LESS) { + result = -1; + } else { + result = 1; + } + } + return result; +err_other_no_iter: + err_unimplemented_operator(tp_other, OPERATOR_ITER); +err: + return Dee_COMPARE_ERR; +} + +DEFINE_INTERNAL_SEQ_OPERATOR(int, DefaultCompareWithSizeAndTryGetItemIndex, + (DeeObject *self, DeeObject *other)) { + int result; + size_t lhs_size; + DeeTypeObject *tp_other = Dee_TYPE(other); + DREF DeeObject *(DCALL *lhs_trygetitem_index)(DeeObject *self, size_t index); + Dee_ssize_t (DCALL *other_tp_foreach)(DeeObject *__restrict self, Dee_foreach_t proc, void *arg); + LOAD_TP_SELF; + if ((!tp_other->tp_seq || !tp_other->tp_seq->tp_foreach) && !DeeType_InheritIter(tp_other)) + goto err_other_no_iter; + other_tp_foreach = tp_other->tp_seq->tp_foreach; + ASSERT(other_tp_foreach); + lhs_trygetitem_index = tp_self->tp_seq->tp_trygetitem_index; + lhs_size = DeeType_INVOKE_SIZE_NODEFAULT(tp_self, self); + if unlikely(lhs_size == (size_t)-1) + goto err; + if (other_tp_foreach == &DeeSeq_DefaultForeachWithSizeAndGetItemIndexFast) { + size_t rhs_size = (*tp_other->tp_seq->tp_size)(other); + if unlikely(rhs_size == (size_t)-1) + goto err; + result = seq_docompare__lhs_size_and_trygetitem_index__rhs_size_and_getitem_index_fast(self, lhs_size, lhs_trygetitem_index, + other, rhs_size, tp_other->tp_seq->tp_getitem_index_fast); + } else if (other_tp_foreach == &DeeSeq_DefaultForeachWithSizeAndTryGetItemIndex) { + size_t rhs_size = (*tp_other->tp_seq->tp_size)(other); + if unlikely(rhs_size == (size_t)-1) + goto err; + result = seq_docompare__lhs_size_and_trygetitem_index__rhs_size_and_trygetitem_index(self, lhs_size, lhs_trygetitem_index, + other, rhs_size, tp_other->tp_seq->tp_trygetitem_index); + } else if (other_tp_foreach == &DeeSeq_DefaultForeachWithSizeAndGetItemIndex || + other_tp_foreach == &DeeSeq_DefaultForeachWithSizeDefaultAndGetItemIndexDefault) { + size_t rhs_size = (*tp_other->tp_seq->tp_size)(other); + if unlikely(rhs_size == (size_t)-1) + goto err; + result = seq_docompare__lhs_size_and_trygetitem_index__rhs_size_and_getitem_index(self, lhs_size, lhs_trygetitem_index, + other, rhs_size, tp_other->tp_seq->tp_getitem_index); + } else if (other_tp_foreach == &DeeSeq_DefaultForeachWithSizeObAndGetItem) { + DREF DeeObject *rhs_sizeob = (*tp_other->tp_seq->tp_sizeob)(other); + if unlikely(!rhs_sizeob) + goto err; + result = seq_docompare__lhs_size_and_trygetitem_index__rhs_sizeob_and_getitem(self, lhs_size, lhs_trygetitem_index, + other, rhs_sizeob, tp_other->tp_seq->tp_getitem); + Dee_Decref(rhs_sizeob); + } else { + struct seq_compareforeach__size_and_getitem_index__data data; + Dee_ssize_t foreach_result; + data.scf_sgi_other = self; + data.scf_sgi_osize = lhs_size; + data.scf_sgi_oindex = 0; + data.scf_sgi_ogetitem_index = lhs_trygetitem_index; + foreach_result = (*other_tp_foreach)(other, &seq_compare__lhs_size_and_trygetitem_index__rhs_foreach__cb, &data); + ASSERT(foreach_result == SEQ_COMPARE_FOREACH_RESULT_EQUAL || + foreach_result == SEQ_COMPARE_FOREACH_RESULT_ERROR || + foreach_result == SEQ_COMPARE_FOREACH_RESULT_LESS || + foreach_result == SEQ_COMPARE_FOREACH_RESULT_GREATER); + if unlikely(foreach_result == SEQ_COMPARE_FOREACH_RESULT_ERROR) + goto err; + if (foreach_result == SEQ_COMPAREEQ_FOREACH_RESULT_EQUAL) { + result = 0; + } else if (foreach_result == SEQ_COMPARE_FOREACH_RESULT_LESS) { + result = -1; + } else { + result = 1; + } + } + return result; +err_other_no_iter: + err_unimplemented_operator(tp_other, OPERATOR_ITER); +err: + return Dee_COMPARE_ERR; +} + +DEFINE_INTERNAL_SEQ_OPERATOR(int, DefaultCompareWithSizeAndGetItemIndex, + (DeeObject *self, DeeObject *other)) { + int result; + size_t lhs_size; + DeeTypeObject *tp_other = Dee_TYPE(other); + DREF DeeObject *(DCALL *lhs_getitem_index)(DeeObject *self, size_t index); + Dee_ssize_t (DCALL *other_tp_foreach)(DeeObject *__restrict self, Dee_foreach_t proc, void *arg); + LOAD_TP_SELF; + if ((!tp_other->tp_seq || !tp_other->tp_seq->tp_foreach) && !DeeType_InheritIter(tp_other)) + goto err_other_no_iter; + other_tp_foreach = tp_other->tp_seq->tp_foreach; + ASSERT(other_tp_foreach); + lhs_getitem_index = tp_self->tp_seq->tp_getitem_index; + lhs_size = DeeType_INVOKE_SIZE_NODEFAULT(tp_self, self); + if unlikely(lhs_size == (size_t)-1) + goto err; + if (other_tp_foreach == &DeeSeq_DefaultForeachWithSizeAndGetItemIndexFast) { + size_t rhs_size = (*tp_other->tp_seq->tp_size)(other); + if unlikely(rhs_size == (size_t)-1) + goto err; + result = seq_docompare__lhs_size_and_getitem_index__rhs_size_and_getitem_index_fast(self, lhs_size, lhs_getitem_index, + other, rhs_size, tp_other->tp_seq->tp_getitem_index_fast); + } else if (other_tp_foreach == &DeeSeq_DefaultForeachWithSizeAndTryGetItemIndex) { + size_t rhs_size = (*tp_other->tp_seq->tp_size)(other); + if unlikely(rhs_size == (size_t)-1) + goto err; + result = seq_docompare__lhs_size_and_getitem_index__rhs_size_and_trygetitem_index(self, lhs_size, lhs_getitem_index, + other, rhs_size, tp_other->tp_seq->tp_trygetitem_index); + } else if (other_tp_foreach == &DeeSeq_DefaultForeachWithSizeAndGetItemIndex || + other_tp_foreach == &DeeSeq_DefaultForeachWithSizeDefaultAndGetItemIndexDefault) { + size_t rhs_size = (*tp_other->tp_seq->tp_size)(other); + if unlikely(rhs_size == (size_t)-1) + goto err; + result = seq_docompare__lhs_size_and_getitem_index__rhs_size_and_getitem_index(self, lhs_size, lhs_getitem_index, + other, rhs_size, tp_other->tp_seq->tp_getitem_index); + } else if (other_tp_foreach == &DeeSeq_DefaultForeachWithSizeObAndGetItem) { + DREF DeeObject *rhs_sizeob = (*tp_other->tp_seq->tp_sizeob)(other); + if unlikely(!rhs_sizeob) + goto err; + result = seq_docompare__lhs_size_and_getitem_index__rhs_sizeob_and_getitem(self, lhs_size, lhs_getitem_index, + other, rhs_sizeob, tp_other->tp_seq->tp_getitem); + Dee_Decref(rhs_sizeob); + } else { + struct seq_compareforeach__size_and_getitem_index__data data; + Dee_ssize_t foreach_result; + data.scf_sgi_other = self; + data.scf_sgi_osize = lhs_size; + data.scf_sgi_oindex = 0; + data.scf_sgi_ogetitem_index = lhs_getitem_index; + foreach_result = (*other_tp_foreach)(other, &seq_compare__lhs_size_and_getitem_index__rhs_foreach__cb, &data); + ASSERT(foreach_result == SEQ_COMPARE_FOREACH_RESULT_EQUAL || + foreach_result == SEQ_COMPARE_FOREACH_RESULT_ERROR || + foreach_result == SEQ_COMPARE_FOREACH_RESULT_LESS || + foreach_result == SEQ_COMPARE_FOREACH_RESULT_GREATER); + if unlikely(foreach_result == SEQ_COMPARE_FOREACH_RESULT_ERROR) + goto err; + if (foreach_result == SEQ_COMPAREEQ_FOREACH_RESULT_EQUAL) { + result = 0; + } else if (foreach_result == SEQ_COMPARE_FOREACH_RESULT_LESS) { + result = -1; + } else { + result = 1; + } + } + return result; +err_other_no_iter: + err_unimplemented_operator(tp_other, OPERATOR_ITER); +err: + return Dee_COMPARE_ERR; +} + +DEFINE_INTERNAL_SEQ_OPERATOR(int, DefaultCompareWithSizeObAndGetItem, + (DeeObject *self, DeeObject *other)) { + int result; + DREF DeeObject *lhs_sizeob; + DeeTypeObject *tp_other = Dee_TYPE(other); + DREF DeeObject *(DCALL *lhs_getitem)(DeeObject *self, DeeObject *index); +#ifdef DEFINE_TYPED_OPERATORS + DREF DeeObject *(DCALL *lhs_tgetitem)(DeeTypeObject *tp_self, DeeObject *self, DeeObject *index); +#endif /* DEFINE_TYPED_OPERATORS */ + Dee_ssize_t (DCALL *other_tp_foreach)(DeeObject *__restrict self, Dee_foreach_t proc, void *arg); + LOAD_TP_SELF; + if ((!tp_other->tp_seq || !tp_other->tp_seq->tp_foreach) && !DeeType_InheritIter(tp_other)) + goto err_other_no_iter; + other_tp_foreach = tp_other->tp_seq->tp_foreach; + ASSERT(other_tp_foreach); + lhs_getitem = tp_self->tp_seq->tp_getitem; +#ifdef DEFINE_TYPED_OPERATORS + lhs_tgetitem = lhs_getitem == &instance_getitem ? &instance_tgetitem : NULL; +#endif /* DEFINE_TYPED_OPERATORS */ + lhs_sizeob = DeeType_INVOKE_ITER_NODEFAULT(tp_self, self); + if unlikely(!lhs_sizeob) + goto err; + if (other_tp_foreach == &DeeSeq_DefaultForeachWithSizeAndGetItemIndexFast) { + size_t rhs_size = (*tp_other->tp_seq->tp_size)(other); + if unlikely(rhs_size == (size_t)-1) + goto err_lhs_sizeob; +#ifdef DEFINE_TYPED_OPERATORS + if (lhs_tgetitem) { + result = seq_docompare__lhs_tsizeob_and_getitem__rhs_size_and_getitem_index_fast(tp_self, self, lhs_sizeob, lhs_tgetitem, other, + rhs_size, tp_other->tp_seq->tp_getitem_index_fast); + } else +#endif /* DEFINE_TYPED_OPERATORS */ + { + result = seq_docompare__lhs_sizeob_and_getitem__rhs_size_and_getitem_index_fast(self, lhs_sizeob, lhs_getitem, other, + rhs_size, tp_other->tp_seq->tp_getitem_index_fast); + } + } else if (other_tp_foreach == &DeeSeq_DefaultForeachWithSizeAndTryGetItemIndex) { + size_t rhs_size = (*tp_other->tp_seq->tp_size)(other); + if unlikely(rhs_size == (size_t)-1) + goto err_lhs_sizeob; +#ifdef DEFINE_TYPED_OPERATORS + if (lhs_tgetitem) { + result = seq_docompare__lhs_tsizeob_and_getitem__rhs_size_and_trygetitem_index(tp_self, self, lhs_sizeob, lhs_tgetitem, other, + rhs_size, tp_other->tp_seq->tp_trygetitem_index); + } else +#endif /* DEFINE_TYPED_OPERATORS */ + { + result = seq_docompare__lhs_sizeob_and_getitem__rhs_size_and_trygetitem_index(self, lhs_sizeob, lhs_getitem, other, + rhs_size, tp_other->tp_seq->tp_trygetitem_index); + } + } else if (other_tp_foreach == &DeeSeq_DefaultForeachWithSizeAndGetItemIndex || + other_tp_foreach == &DeeSeq_DefaultForeachWithSizeDefaultAndGetItemIndexDefault) { + size_t rhs_size = (*tp_other->tp_seq->tp_size)(other); + if unlikely(rhs_size == (size_t)-1) + goto err_lhs_sizeob; +#ifdef DEFINE_TYPED_OPERATORS + if (lhs_tgetitem) { + result = seq_docompare__lhs_tsizeob_and_getitem__rhs_size_and_getitem_index(tp_self, self, lhs_sizeob, lhs_tgetitem, other, + rhs_size, tp_other->tp_seq->tp_getitem_index); + } else +#endif /* DEFINE_TYPED_OPERATORS */ + { + result = seq_docompare__lhs_sizeob_and_getitem__rhs_size_and_getitem_index(self, lhs_sizeob, lhs_getitem, other, + rhs_size, tp_other->tp_seq->tp_getitem_index); + } + } else if (other_tp_foreach == &DeeSeq_DefaultForeachWithSizeObAndGetItem) { + DREF DeeObject *rhs_sizeob = (*tp_other->tp_seq->tp_sizeob)(other); + if unlikely(!rhs_sizeob) + goto err_lhs_sizeob; +#ifdef DEFINE_TYPED_OPERATORS + if (lhs_tgetitem) { + result = seq_docompare__lhs_tsizeob_and_getitem__rhs_sizeob_and_getitem(tp_self, self, lhs_sizeob, lhs_tgetitem, other, + rhs_sizeob, tp_other->tp_seq->tp_getitem); + } else +#endif /* DEFINE_TYPED_OPERATORS */ + { + result = seq_docompare__lhs_sizeob_and_getitem__rhs_sizeob_and_getitem(self, lhs_sizeob, lhs_getitem, other, + rhs_sizeob, tp_other->tp_seq->tp_getitem); + } + Dee_Decref(rhs_sizeob); + } else { + Dee_ssize_t foreach_result; + DREF DeeObject *lhs_indexob; + lhs_indexob = DeeObject_NewDefault(Dee_TYPE(lhs_sizeob)); + if unlikely(!lhs_indexob) + goto err_lhs_sizeob; +#ifdef DEFINE_TYPED_OPERATORS + if (lhs_tgetitem) { + struct seq_compare_foreach__tsizeob_and_getitem__data data; + data.scf_tsg_tpother = tp_self; + data.scf_tsg_other = self; + data.scf_tsg_osize = lhs_sizeob; + data.scf_tsg_oindex = lhs_indexob; + data.scf_tsg_otgetitem = lhs_tgetitem; + foreach_result = (*other_tp_foreach)(other, &seq_compare__tlhs_sizeob_and_getitem__rhs_foreach__cb, &data); + } else +#endif /* DEFINE_TYPED_OPERATORS */ + { + struct seq_compare_foreach__sizeob_and_getitem__data data; + data.scf_sg_other = self; + data.scf_sg_osize = lhs_sizeob; + data.scf_sg_oindex = lhs_indexob; + data.scf_sg_ogetitem = lhs_getitem; + foreach_result = (*other_tp_foreach)(other, &seq_compare__lhs_sizeob_and_getitem__rhs_foreach__cb, &data); + } + Dee_Decref(lhs_indexob); + ASSERT(foreach_result == SEQ_COMPAREEQ_FOREACH_RESULT_EQUAL || + foreach_result == SEQ_COMPAREEQ_FOREACH_RESULT_ERROR || + foreach_result == SEQ_COMPAREEQ_FOREACH_RESULT_NOTEQUAL); + if unlikely(foreach_result == SEQ_COMPAREEQ_FOREACH_RESULT_ERROR) + goto err_lhs_sizeob; + result = foreach_result == SEQ_COMPAREEQ_FOREACH_RESULT_EQUAL ? 0 : 1; + } + Dee_Decref(lhs_sizeob); + return result; +err_lhs_sizeob: + Dee_Decref(lhs_sizeob); + return Dee_COMPARE_ERR; +err_other_no_iter: + err_unimplemented_operator(tp_other, OPERATOR_ITER); +err: + return Dee_COMPARE_ERR; } + + + /* Default wrappers for implementing OPERATOR_ITER via `tp_iter <===> tp_foreach <===> tp_foreach_pair' */ DEFINE_INTERNAL_OPERATOR(DREF DeeObject *, DefaultIterWithForeach, (DeeObject *__restrict self)) { LOAD_TP_SELF; @@ -3561,7 +5588,7 @@ DEFINE_INTERNAL_SEQ_OPERATOR(DREF DeeObject *, DefaultIterWithSizeAndGetItemInde return NULL; } -DEFINE_INTERNAL_SEQ_OPERATOR(DREF DeeObject *, DefaultIterWithTryGetItemIndexAndSize, +DEFINE_INTERNAL_SEQ_OPERATOR(DREF DeeObject *, DefaultIterWithSizeAndTryGetItemIndex, (DeeObject *RESTRICT_IF_NOTYPE self)) { size_t size; DREF DefaultIterator_WithSizeAndGetItemIndex *result; @@ -3578,7 +5605,7 @@ DEFINE_INTERNAL_SEQ_OPERATOR(DREF DeeObject *, DefaultIterWithTryGetItemIndexAnd result->disgi_tp_getitem_index = tp_self->tp_seq->tp_trygetitem_index; result->disgi_index = 0; result->disgi_end = size; - DeeObject_Init(result, &DefaultIterator_WithTryGetItemIndexAndSize_Type); + DeeObject_Init(result, &DefaultIterator_WithSizeAndTryGetItemIndex_Type); return (DREF DeeObject *)result; err: return NULL; @@ -3750,7 +5777,7 @@ DEFINE_INTERNAL_SEQ_OPERATOR(Dee_ssize_t, DefaultForeachWithSizeAndGetItemIndexF return -1; } -DEFINE_INTERNAL_SEQ_OPERATOR(Dee_ssize_t, DefaultForeachWithTryGetItemIndexAndSize, +DEFINE_INTERNAL_SEQ_OPERATOR(Dee_ssize_t, DefaultForeachWithSizeAndTryGetItemIndex, (DeeObject *RESTRICT_IF_NOTYPE self, Dee_foreach_t proc, void *arg)) { Dee_ssize_t temp, result = 0; size_t i, size; @@ -3808,6 +5835,54 @@ DEFINE_INTERNAL_SEQ_OPERATOR(Dee_ssize_t, DefaultForeachWithSizeAndGetItemIndex, return -1; } +DEFINE_INTERNAL_SEQ_OPERATOR(Dee_ssize_t, DefaultForeachWithSizeObAndGetItem, + (DeeObject *RESTRICT_IF_NOTYPE self, Dee_foreach_t proc, void *arg)) { + Dee_ssize_t temp, result = 0; + DREF DeeObject *i, *size; + LOAD_TP_SELF; + size = DeeType_INVOKE_SIZEOB_NODEFAULT(tp_self, self); + if unlikely(!size) + goto err; + i = DeeObject_NewDefault(Dee_TYPE(size)); + if unlikely(!i) + goto err_size; + for (;;) { + DREF DeeObject *elem; + int cmp_status; + cmp_status = DeeObject_CompareLo(i, size); + if unlikely(cmp_status < 0) + goto err_size_i; + if (!cmp_status) + break; + elem = DeeType_INVOKE_GETITEM_NODEFAULT(tp_self, self, i); + if unlikely(!elem) { + if (DeeError_Catch(&DeeError_UnboundItem)) + continue; + if (DeeError_Catch(&DeeError_IndexError)) + break; /* In case the sequence's length got truncated since we checked above. */ + goto err_size_i; + } + temp = (*proc)(arg, elem); + Dee_Decref(elem); + if unlikely(temp < 0) { + result = temp; + break; + } + result += temp; + if (DeeObject_Inc(&i)) + goto err_size_i; + } + Dee_Decref(i); + Dee_Decref(size); + return result; +err_size_i: + Dee_Decref(i); +err_size: + Dee_Decref(size); +err: + return -1; +} + DEFINE_INTERNAL_SEQ_OPERATOR(Dee_ssize_t, DefaultForeachWithSizeDefaultAndGetItemIndexDefault, (DeeObject *RESTRICT_IF_NOTYPE self, Dee_foreach_t proc, void *arg)) { Dee_ssize_t temp, result = 0; @@ -4385,7 +6460,7 @@ DEFINE_INTERNAL_SEQ_OPERATOR(DREF DeeObject *, DefaultGetItemWithTryGetItemAndSi return NULL; } -DEFINE_INTERNAL_SEQ_OPERATOR(DREF DeeObject *, DefaultGetItemWithTryGetItemIndexAndSizeOb, +DEFINE_INTERNAL_SEQ_OPERATOR(DREF DeeObject *, DefaultGetItemWithSizeAndTryGetItemIndexOb, (DeeObject *self, DeeObject *index)) { size_t index_value; DREF DeeObject *result; @@ -4416,7 +6491,7 @@ DEFINE_INTERNAL_SEQ_OPERATOR(DREF DeeObject *, DefaultGetItemWithTryGetItemIndex return NULL; } -DEFINE_INTERNAL_SEQ_OPERATOR(DREF DeeObject *, DefaultGetItemWithTryGetItemIndexAndSize, +DEFINE_INTERNAL_SEQ_OPERATOR(DREF DeeObject *, DefaultGetItemWithSizeAndTryGetItemIndex, (DeeObject *self, DeeObject *index)) { size_t index_value; DREF DeeObject *result; @@ -4622,7 +6697,7 @@ default_getitem_index_with_foreach_cb(void *arg, DeeObject *elem) { #endif /* !DEFINE_TYPED_OPERATORS */ -DEFINE_INTERNAL_SEQ_OPERATOR(DREF DeeObject *, DefaultGetItemIndexWithTryGetItemIndexAndSize, +DEFINE_INTERNAL_SEQ_OPERATOR(DREF DeeObject *, DefaultGetItemIndexWithSizeAndTryGetItemIndex, (DeeObject *RESTRICT_IF_NOTYPE self, size_t index)) { DREF DeeObject *result; LOAD_TP_SELF; @@ -4643,7 +6718,7 @@ DEFINE_INTERNAL_SEQ_OPERATOR(DREF DeeObject *, DefaultGetItemIndexWithTryGetItem return NULL; } -DEFINE_INTERNAL_SEQ_OPERATOR(DREF DeeObject *, DefaultGetItemIndexWithTryGetItemIndexAndSizeOb, +DEFINE_INTERNAL_SEQ_OPERATOR(DREF DeeObject *, DefaultGetItemIndexWithSizeAndTryGetItemIndexOb, (DeeObject *RESTRICT_IF_NOTYPE self, size_t index)) { DREF DeeObject *result; LOAD_TP_SELF; @@ -6358,7 +8433,7 @@ DEFINE_INTERNAL_SEQ_OPERATOR(int, DefaultBoundItemWithTryGetItemAndSizeOb, return -1; } -DEFINE_INTERNAL_SEQ_OPERATOR(int, DefaultBoundItemWithTryGetItemIndexAndSize, +DEFINE_INTERNAL_SEQ_OPERATOR(int, DefaultBoundItemWithSizeAndTryGetItemIndex, (DeeObject *self, DeeObject *index)) { DREF DeeObject *value; size_t index_value; @@ -6668,7 +8743,7 @@ DEFINE_INTERNAL_OPERATOR(int, DefaultBoundItemIndexWithTryGetItemAndHasItem, return -1; } -DEFINE_INTERNAL_SEQ_OPERATOR(int, DefaultBoundItemIndexWithTryGetItemIndexAndSize, +DEFINE_INTERNAL_SEQ_OPERATOR(int, DefaultBoundItemIndexWithSizeAndTryGetItemIndex, (DeeObject *RESTRICT_IF_NOTYPE self, size_t index)) { DREF DeeObject *value; LOAD_TP_SELF; @@ -8518,7 +10593,7 @@ DEFINE_INTERNAL_SEQ_OPERATOR(DREF DeeObject *, DefaultGetRangeWithSizeDefaultAnd result->dssgi_tp_getitem_index = tp_self->tp_seq->tp_trygetitem_index; result->dssgi_start = range.sr_start; result->dssgi_end = range.sr_end; - DeeObject_Init(result, &DefaultSequence_WithTryGetItemIndexAndSize_Type); + DeeObject_Init(result, &DefaultSequence_WithSizeAndTryGetItemIndex_Type); return (DREF DeeObject *)result; __builtin_unreachable(); err: @@ -10025,136 +12100,6 @@ DEFINE_MATH_INPLACE_INT_OPERATOR(DeeObject_InplaceXorUInt32, DeeObject_InplaceXo #endif /* !DEFINE_TYPED_OPERATORS */ -#ifndef DEFINE_TYPED_OPERATORS -INTERN NONNULL((1)) bool DCALL -DeeType_InheritHash(DeeTypeObject *__restrict self) { - struct type_cmp *base_cmp; - DeeTypeMRO mro; - DeeTypeObject *base; - base_cmp = self->tp_cmp; - if (base_cmp) { - if (base_cmp->tp_hash) - return true; - if (base_cmp->tp_eq) { - if (base_cmp->tp_ne == NULL) - base_cmp->tp_ne = &DeeObject_DefaultNeWithEq; - return false; /* Cannot inherit "operator hash" when "operator ==" is defined. */ - } else if (base_cmp->tp_ne) { - if (base_cmp->tp_eq == NULL) - base_cmp->tp_eq = &DeeObject_DefaultEqWithNe; - return false; /* Cannot inherit "operator hash" when "operator !=" is defined. */ - } - } - - base = DeeTypeMRO_Init(&mro, self); - while ((base = DeeTypeMRO_NextDirectBase(&mro, base)) != NULL) { - base_cmp = base->tp_cmp; - if (base_cmp == NULL) { - if (!base_cmp->tp_hash) { - if (!DeeType_InheritHash(base)) - continue; - } else { - if (base_cmp->tp_eq || base_cmp->tp_ne) - return false; /* Cannot inherit hash in this case */ - } - base_cmp = base->tp_cmp; - } - ASSERT(base_cmp->tp_hash); - LOG_INHERIT(base, self, "operator hash"); - if (self->tp_cmp) { - DeeTypeObject *origin = DeeType_GetCmpOrigin(self); - if unlikely(origin) - return DeeType_InheritHash(origin); - if (self->tp_cmp->tp_hash == NULL) - self->tp_cmp->tp_hash = base_cmp->tp_hash; - if (self->tp_cmp->tp_eq == NULL && base_cmp->tp_eq) - self->tp_cmp->tp_eq = base_cmp->tp_eq; - if (self->tp_cmp->tp_ne == NULL && base_cmp->tp_ne) - self->tp_cmp->tp_ne = base_cmp->tp_ne; - } else { - self->tp_cmp = base_cmp; - } - return true; - } - return false; -} - -INTERN NONNULL((1)) bool DCALL -DeeType_InheritCompare(DeeTypeObject *__restrict self) { - struct type_cmp *base_cmp; - DeeTypeMRO mro; - DeeTypeObject *base; - base_cmp = self->tp_cmp; - if (base_cmp) { - bool ok = false; - if (base_cmp->tp_eq) { - if (base_cmp->tp_ne == NULL) - base_cmp->tp_ne = &DeeObject_DefaultNeWithEq; - ok = true; - } else if (base_cmp->tp_ne) { - if (base_cmp->tp_eq == NULL) - base_cmp->tp_eq = &DeeObject_DefaultEqWithNe; - ok = true; - } - if (base_cmp->tp_lo) { - if (base_cmp->tp_ge == NULL) - base_cmp->tp_ge = &DeeObject_DefaultGeWithLo; - ok = true; - } else if (base_cmp->tp_ge) { - if (base_cmp->tp_lo == NULL) - base_cmp->tp_lo = &DeeObject_DefaultLoWithGe; - ok = true; - } - if (base_cmp->tp_le) { - if (base_cmp->tp_gr == NULL) - base_cmp->tp_gr = &DeeObject_DefaultGrWithLe; - ok = true; - } else if (base_cmp->tp_le) { - if (base_cmp->tp_gr == NULL) - base_cmp->tp_gr = &DeeObject_DefaultLeWithGr; - ok = true; - } - if (ok) - return true; - } - - base = DeeTypeMRO_Init(&mro, self); - while ((base = DeeTypeMRO_NextDirectBase(&mro, base)) != NULL) { - base_cmp = base->tp_cmp; - if (base_cmp == NULL || - (!base_cmp->tp_eq && !base_cmp->tp_ne && - !base_cmp->tp_lo && !base_cmp->tp_le && - !base_cmp->tp_gr && !base_cmp->tp_ge)) { - if (!DeeType_InheritCompare(base)) - continue; - base_cmp = base->tp_cmp; - } - LOG_INHERIT(base, self, "operator "); - if (self->tp_cmp) { - DeeTypeObject *origin = DeeType_GetCmpOrigin(self); - if unlikely(origin) - return DeeType_InheritCompare(origin); - if (self->tp_cmp->tp_eq == NULL) - self->tp_cmp->tp_eq = base_cmp->tp_eq; - if (self->tp_cmp->tp_ne == NULL) - self->tp_cmp->tp_ne = base_cmp->tp_ne; - if (self->tp_cmp->tp_lo == NULL) - self->tp_cmp->tp_lo = base_cmp->tp_lo; - if (self->tp_cmp->tp_le == NULL) - self->tp_cmp->tp_le = base_cmp->tp_le; - if (self->tp_cmp->tp_gr == NULL) - self->tp_cmp->tp_gr = base_cmp->tp_gr; - if (self->tp_cmp->tp_ge == NULL) - self->tp_cmp->tp_ge = base_cmp->tp_ge; - } else { - self->tp_cmp = base_cmp; - } - return true; - } - return false; -} -#endif /* !DEFINE_TYPED_OPERATORS */ - #define DEFINE_OBJECT_COMPARE_OPERATOR(name, cmp, operator_name, invoke) \ DEFINE_OPERATOR(DREF DeeObject *, name, \ (DeeObject *self, DeeObject *some_object)) { \ @@ -10243,10 +12188,10 @@ INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL super_lo(DeeSuperObject *self, DeeObject *some_object); -/* @return: == Dee_COMPARE_ERR: An error occurred. - * @return: == -1: `lhs < rhs' +/* @return: == -1: `lhs < rhs' * @return: == 0: `lhs == rhs' - * @return: == 1: `lhs > rhs' */ + * @return: == 1: `lhs > rhs' + * @return: == Dee_COMPARE_ERR: An error occurred. */ PUBLIC WUNUSED NONNULL((1, 2)) int DCALL DeeObject_Compare(DeeObject *lhs, DeeObject *rhs) { #if 1 @@ -10333,9 +12278,19 @@ DeeObject_Compare(DeeObject *lhs, DeeObject *rhs) { #endif } +PUBLIC WUNUSED NONNULL((1, 2)) int DCALL +DeeObject_CompareForEquality(DeeObject *lhs, DeeObject *rhs) { + int result = DeeObject_CompareNe(lhs, rhs); + if (result == -1) + result = Dee_COMPARE_ERR; + return result; +} + #endif /* !DEFINE_TYPED_OPERATORS */ + #ifndef DEFINE_TYPED_OPERATORS + INTERN NONNULL((1)) bool DCALL DeeType_InheritIterNext(DeeTypeObject *__restrict self) { DeeTypeMRO mro; @@ -10352,6 +12307,125 @@ DeeType_InheritIterNext(DeeTypeObject *__restrict self) { return false; } +/* Try to substitute default compare operators. */ +PRIVATE NONNULL((1)) void DCALL +DeeType_SubstituteDefaultCompareOperators(struct type_cmp *__restrict cmp) { + bool has_eq = cmp->tp_eq && !DeeType_IsDefaultEq(cmp->tp_eq); + bool has_ne = cmp->tp_ne && !DeeType_IsDefaultNe(cmp->tp_ne); + bool has_lo = cmp->tp_lo && !DeeType_IsDefaultLo(cmp->tp_lo); + bool has_le = cmp->tp_le && !DeeType_IsDefaultLe(cmp->tp_le); + bool has_gr = cmp->tp_gr && !DeeType_IsDefaultGr(cmp->tp_gr); + bool has_ge = cmp->tp_ge && !DeeType_IsDefaultGe(cmp->tp_ge); + bool has_compare_eq = cmp->tp_compare_eq && !DeeType_IsDefaultCompareEq(cmp->tp_compare_eq); + bool has_compare = cmp->tp_compare && !DeeType_IsDefaultCompare(cmp->tp_compare); + + if (!cmp->tp_compare) { + if (has_eq && has_lo) { + cmp->tp_compare = &DeeObject_DefaultCompareWithEqAndLo; + } else if (has_eq && has_le) { + cmp->tp_compare = &DeeObject_DefaultCompareWithEqAndLe; + } else if (has_eq && has_gr) { + cmp->tp_compare = &DeeObject_DefaultCompareWithEqAndGr; + } else if (has_eq && has_ge) { + cmp->tp_compare = &DeeObject_DefaultCompareWithEqAndGe; + } else if (has_ne && has_lo) { + cmp->tp_compare = &DeeObject_DefaultCompareWithNeAndLo; + } else if (has_ne && has_le) { + cmp->tp_compare = &DeeObject_DefaultCompareWithNeAndLe; + } else if (has_ne && has_gr) { + cmp->tp_compare = &DeeObject_DefaultCompareWithNeAndGr; + } else if (has_ne && has_ge) { + cmp->tp_compare = &DeeObject_DefaultCompareWithNeAndGe; + } else if (has_lo && has_gr) { + cmp->tp_compare = &DeeObject_DefaultCompareWithLoAndGr; + } else if (has_le && has_ge) { + cmp->tp_compare = &DeeObject_DefaultCompareWithLeAndGe; + } + } + + if (!cmp->tp_compare_eq) { + if (has_compare) { + cmp->tp_compare_eq = cmp->tp_compare; + } else if (has_eq) { + cmp->tp_compare_eq = &DeeObject_DefaultCompareEqWithEq; + } else if (has_ne) { + cmp->tp_compare_eq = &DeeObject_DefaultCompareEqWithNe; + } else if (has_lo && has_gr) { + cmp->tp_compare_eq = &DeeObject_DefaultCompareEqWithLoAndGr; + } else if (has_le && has_ge) { + cmp->tp_compare_eq = &DeeObject_DefaultCompareEqWithLeAndGe; + } + } + + if (!cmp->tp_eq) { + if (has_compare_eq) { + cmp->tp_eq = &DeeObject_DefaultEqWithCompareEq; + } else if (has_ne) { + cmp->tp_eq = &DeeObject_DefaultEqWithNe; + } else if (has_lo && has_gr) { + cmp->tp_eq = &DeeObject_DefaultEqWithLoAndGr; + } else if (has_le && has_ge) { + cmp->tp_eq = &DeeObject_DefaultEqWithLeAndGe; + } else if (cmp->tp_compare_eq) { + cmp->tp_eq = &DeeObject_DefaultEqWithCompareEqDefault; + } + } + + if (!cmp->tp_ne) { + if (has_compare_eq) { + cmp->tp_ne = &DeeObject_DefaultNeWithCompareEq; + } else if (has_eq) { + cmp->tp_ne = &DeeObject_DefaultNeWithEq; + } else if (has_lo && has_gr) { + cmp->tp_ne = &DeeObject_DefaultNeWithLoAndGr; + } else if (has_le && has_ge) { + cmp->tp_ne = &DeeObject_DefaultNeWithLeAndGe; + } else if (cmp->tp_compare_eq) { + cmp->tp_ne = &DeeObject_DefaultNeWithCompareEqDefault; + } + } + + if (!cmp->tp_lo) { + if (has_compare) { + cmp->tp_lo = &DeeObject_DefaultLoWithCompare; + } else if (has_ge) { + cmp->tp_lo = &DeeObject_DefaultLoWithGe; + } else if (cmp->tp_compare) { + cmp->tp_lo = &DeeObject_DefaultLoWithCompareDefault; + } + } + + if (!cmp->tp_le) { + if (has_compare) { + cmp->tp_le = &DeeObject_DefaultLeWithCompare; + } else if (has_gr) { + cmp->tp_le = &DeeObject_DefaultLeWithGr; + } else if (cmp->tp_compare) { + cmp->tp_le = &DeeObject_DefaultLeWithCompareDefault; + } + } + + if (!cmp->tp_gr) { + if (has_compare) { + cmp->tp_gr = &DeeObject_DefaultGrWithCompare; + } else if (has_le) { + cmp->tp_gr = &DeeObject_DefaultGrWithLe; + } else if (cmp->tp_compare) { + cmp->tp_gr = &DeeObject_DefaultGrWithCompareDefault; + } + } + + if (!cmp->tp_ge) { + if (has_compare) { + cmp->tp_ge = &DeeObject_DefaultGeWithCompare; + } else if (has_lo) { + cmp->tp_ge = &DeeObject_DefaultGeWithLo; + } else if (cmp->tp_compare) { + cmp->tp_ge = &DeeObject_DefaultGeWithCompareDefault; + } + } +} + /* Sequence feature flags. */ enum seq_feature { FEAT_tp_iter, @@ -10518,7 +12592,7 @@ DeeSeqType_SubstituteDefaultOperators(DeeTypeObject *self, seq_featureset_t feat seq->tp_iter = &DeeSeq_DefaultIterWithSizeAndGetItemIndexFast; } else if (seq_featureset_test(features, FEAT_tp_size) && seq_featureset_test(features, FEAT_tp_trygetitem_index) && seqclass == Dee_SEQCLASS_SEQ) { - seq->tp_iter = &DeeSeq_DefaultIterWithTryGetItemIndexAndSize; + seq->tp_iter = &DeeSeq_DefaultIterWithSizeAndTryGetItemIndex; } else if (seq_featureset_test(features, FEAT_tp_size) && seq_featureset_test(features, FEAT_tp_getitem_index) && seqclass == Dee_SEQCLASS_SEQ) { seq->tp_iter = &DeeSeq_DefaultIterWithSizeAndGetItemIndex; @@ -10538,6 +12612,28 @@ DeeSeqType_SubstituteDefaultOperators(DeeTypeObject *self, seq_featureset_t feat } } + /* tp_size */ + if (!seq->tp_size) { + if (seq_featureset_test(features, FEAT_tp_sizeob)) { + seq->tp_size = &DeeObject_DefaultSizeWithSizeOb; + } else if (seq_featureset_test(features, FEAT_tp_foreach)) { + seq->tp_size = &DeeSeq_DefaultSizeWithForeach; + } else if (seq_featureset_test(features, FEAT_tp_foreach_pair)) { + seq->tp_size = &DeeSeq_DefaultSizeWithForeachPair; + } else if (seq_featureset_test(features, FEAT_tp_iter)) { + seq->tp_size = &DeeSeq_DefaultSizeWithIter; + } + } + + /* tp_sizeob */ + if (!seq->tp_sizeob) { + if (seq_featureset_test(features, FEAT_tp_size)) { + seq->tp_sizeob = &DeeObject_DefaultSizeObWithSize; + } else if (seq->tp_size) { + seq->tp_sizeob = &DeeObject_DefaultSizeObWithSizeDefault; + } + } + /* tp_foreach */ if (!seq->tp_foreach) { if (seq_featureset_test(features, FEAT_tp_foreach_pair)) { @@ -10546,13 +12642,16 @@ DeeSeqType_SubstituteDefaultOperators(DeeTypeObject *self, seq_featureset_t feat seq->tp_foreach = &DeeSeq_DefaultForeachWithSizeAndGetItemIndexFast; } else if (seq_featureset_test(features, FEAT_tp_size) && seq_featureset_test(features, FEAT_tp_trygetitem_index) && seqclass == Dee_SEQCLASS_SEQ) { - seq->tp_foreach = &DeeSeq_DefaultForeachWithTryGetItemIndexAndSize; + seq->tp_foreach = &DeeSeq_DefaultForeachWithSizeAndTryGetItemIndex; } else if (seq_featureset_test(features, FEAT_tp_size) && seq_featureset_test(features, FEAT_tp_getitem_index) && seqclass == Dee_SEQCLASS_SEQ) { seq->tp_foreach = &DeeSeq_DefaultForeachWithSizeAndGetItemIndex; + } else if (seq_featureset_test(features, FEAT_tp_sizeob) && + seq_featureset_test(features, FEAT_tp_getitem) && seqclass == Dee_SEQCLASS_SEQ) { + seq->tp_foreach = &DeeSeq_DefaultForeachWithSizeObAndGetItem; } else if (seq_featureset_test(features, FEAT_tp_iter)) { seq->tp_foreach = &DeeObject_DefaultForeachWithIter; - } else if ((seq_featureset_test(features, FEAT_tp_sizeob) || seq_featureset_test(features, FEAT_tp_size)) && + } else if (seq->tp_size && (seq_featureset_test(features, FEAT_tp_getitem) || seq_featureset_test(features, FEAT_tp_getitem_index) || seq_featureset_test(features, FEAT_tp_trygetitem)) && @@ -10565,28 +12664,6 @@ DeeSeqType_SubstituteDefaultOperators(DeeTypeObject *self, seq_featureset_t feat } } - /* tp_size */ - if (!seq->tp_size) { - if (seq_featureset_test(features, FEAT_tp_sizeob)) { - seq->tp_size = &DeeObject_DefaultSizeWithSizeOb; - } else if (seq_featureset_test(features, FEAT_tp_foreach)) { - seq->tp_size = &DeeSeq_DefaultSizeWithForeach; - } else if (seq_featureset_test(features, FEAT_tp_foreach_pair)) { - seq->tp_size = &DeeSeq_DefaultSizeWithForeachPair; - } else if (seq_featureset_test(features, FEAT_tp_iter)) { - seq->tp_size = &DeeSeq_DefaultSizeWithIter; - } - } - - /* tp_sizeob */ - if (!seq->tp_sizeob) { - if (seq_featureset_test(features, FEAT_tp_size)) { - seq->tp_sizeob = &DeeObject_DefaultSizeObWithSize; - } else if (seq->tp_size) { - seq->tp_sizeob = &DeeObject_DefaultSizeObWithSizeDefault; - } - } - /* tp_contains (for maps) */ if (!seq->tp_contains && seqclass == Dee_SEQCLASS_MAP) { if (seq_featureset_test(features, FEAT_tp_hasitem)) { @@ -10640,10 +12717,10 @@ DeeSeqType_SubstituteDefaultOperators(DeeTypeObject *self, seq_featureset_t feat seq->tp_getitem = &DeeSeq_DefaultGetItemWithTryGetItemAndSize; } else if (seq_featureset_test(features, FEAT_tp_sizeob) && seq_featureset_test(features, FEAT_tp_trygetitem_index) && seqclass == Dee_SEQCLASS_SEQ) { - seq->tp_getitem = &DeeSeq_DefaultGetItemWithTryGetItemIndexAndSizeOb; + seq->tp_getitem = &DeeSeq_DefaultGetItemWithSizeAndTryGetItemIndexOb; } else if (seq_featureset_test(features, FEAT_tp_size) && seq_featureset_test(features, FEAT_tp_trygetitem_index) && seqclass == Dee_SEQCLASS_SEQ) { - seq->tp_getitem = &DeeSeq_DefaultGetItemWithTryGetItemIndexAndSize; + seq->tp_getitem = &DeeSeq_DefaultGetItemWithSizeAndTryGetItemIndex; } else if (seq_featureset_test(features, FEAT_tp_getitem_index)) { seq->tp_getitem = &DeeObject_DefaultGetItemWithGetItemIndex; } else if (seq_featureset_test(features, FEAT_tp_getitem_string_hash)) { @@ -10671,10 +12748,10 @@ DeeSeqType_SubstituteDefaultOperators(DeeTypeObject *self, seq_featureset_t feat seq->tp_getitem_index = &DeeObject_DefaultGetItemIndexWithSizeAndGetItemIndexFast; } else if (seq_featureset_test(features, FEAT_tp_trygetitem_index) && seq_featureset_test(features, FEAT_tp_size) && seqclass == Dee_SEQCLASS_SEQ) { - seq->tp_getitem_index = &DeeSeq_DefaultGetItemIndexWithTryGetItemIndexAndSize; + seq->tp_getitem_index = &DeeSeq_DefaultGetItemIndexWithSizeAndTryGetItemIndex; } else if (seq_featureset_test(features, FEAT_tp_trygetitem_index) && seq_featureset_test(features, FEAT_tp_sizeob) && seqclass == Dee_SEQCLASS_SEQ) { - seq->tp_getitem_index = &DeeSeq_DefaultGetItemIndexWithTryGetItemIndexAndSizeOb; + seq->tp_getitem_index = &DeeSeq_DefaultGetItemIndexWithSizeAndTryGetItemIndexOb; } else if (seq_featureset_test(features, FEAT_tp_trygetitem) && seq_featureset_test(features, FEAT_tp_size) && seqclass == Dee_SEQCLASS_SEQ) { seq->tp_getitem_index = &DeeSeq_DefaultGetItemIndexWithTryGetItemAndSize; @@ -10997,7 +13074,7 @@ DeeSeqType_SubstituteDefaultOperators(DeeTypeObject *self, seq_featureset_t feat } else if (seq_featureset_test(features, FEAT_tp_trygetitem) && seq_featureset_test(features, FEAT_tp_hasitem)) { seq->tp_bounditem_index = &DeeObject_DefaultBoundItemIndexWithTryGetItemAndHasItem; } else if (seq_featureset_test(features, FEAT_tp_trygetitem_index) && seq_featureset_test(features, FEAT_tp_size) && seqclass == Dee_SEQCLASS_SEQ) { - seq->tp_bounditem_index = &DeeSeq_DefaultBoundItemIndexWithTryGetItemIndexAndSize; + seq->tp_bounditem_index = &DeeSeq_DefaultBoundItemIndexWithSizeAndTryGetItemIndex; } else if (seq_featureset_test(features, FEAT_tp_trygetitem) && seq_featureset_test(features, FEAT_tp_sizeob) && seqclass == Dee_SEQCLASS_SEQ) { seq->tp_bounditem_index = &DeeSeq_DefaultBoundItemIndexWithTryGetItemAndSizeOb; } else if (seq_featureset_test(features, FEAT_tp_foreach_pair) && seqclass == Dee_SEQCLASS_MAP) { @@ -11051,7 +13128,7 @@ DeeSeqType_SubstituteDefaultOperators(DeeTypeObject *self, seq_featureset_t feat } else if (seq_featureset_test(features, FEAT_tp_trygetitem) && seq_featureset_test(features, FEAT_tp_sizeob) && seqclass == Dee_SEQCLASS_SEQ) { seq->tp_bounditem = &DeeSeq_DefaultBoundItemWithTryGetItemAndSizeOb; } else if (seq_featureset_test(features, FEAT_tp_trygetitem_index) && seq_featureset_test(features, FEAT_tp_size) && seqclass == Dee_SEQCLASS_SEQ) { - seq->tp_bounditem = &DeeSeq_DefaultBoundItemWithTryGetItemIndexAndSize; + seq->tp_bounditem = &DeeSeq_DefaultBoundItemWithSizeAndTryGetItemIndex; } else if (seq_featureset_test(features, FEAT_tp_trygetitem)) { seq->tp_bounditem = &DeeObject_DefaultBoundItemWithTryGetItem; } else if (seq_featureset_test(features, FEAT_tp_trygetitem_index)) { @@ -11506,8 +13583,208 @@ DeeSeqType_SubstituteDefaultOperators(DeeTypeObject *self, seq_featureset_t feat /* tp_size_fast (simply set to return `(size_t)-1') */ if (!seq->tp_size_fast) seq->tp_size_fast = &DeeObject_DefaultSizeFastWithErrorNotFast; + + /* Fill in compare operators. */ + if (self->tp_cmp) { + struct type_cmp *cmp = self->tp_cmp; + DeeType_SubstituteDefaultCompareOperators(cmp); + if (!cmp->tp_compare || !cmp->tp_compare_eq) { + switch (seqclass) { + case Dee_SEQCLASS_SEQ: + if (!cmp->tp_hash) { + if (seq_featureset_test(features, FEAT_tp_size) && seq->tp_getitem_index_fast) { + cmp->tp_hash = &DeeSeq_DefaultHashWithSizeAndGetItemIndexFast; + } else if (seq_featureset_test(features, FEAT_tp_foreach)) { + cmp->tp_hash = &DeeSeq_DefaultHashWithForeach; + } else if (seq_featureset_test(features, FEAT_tp_size) && seq_featureset_test(features, FEAT_tp_trygetitem_index)) { + cmp->tp_hash = &DeeSeq_DefaultHashWithSizeAndTryGetItemIndex; + } else if (seq_featureset_test(features, FEAT_tp_size) && seq_featureset_test(features, FEAT_tp_getitem_index)) { + cmp->tp_hash = &DeeSeq_DefaultHashWithSizeAndGetItemIndex; + } else if (seq_featureset_test(features, FEAT_tp_sizeob) && seq_featureset_test(features, FEAT_tp_getitem)) { + cmp->tp_hash = &DeeSeq_DefaultHashWithSizeObAndGetItem; + } else if (seq->tp_foreach) { + cmp->tp_hash = &DeeSeq_DefaultHashWithForeachDefault; + } + } + if (!cmp->tp_compare) { + if (seq_featureset_test(features, FEAT_tp_size) && seq->tp_getitem_index_fast) { + cmp->tp_compare = &DeeSeq_DefaultCompareWithSizeAndGetItemIndexFast; + } else if (seq_featureset_test(features, FEAT_tp_size) && seq_featureset_test(features, FEAT_tp_trygetitem_index)) { + cmp->tp_compare = &DeeSeq_DefaultCompareWithSizeAndTryGetItemIndex; + } else if (seq_featureset_test(features, FEAT_tp_size) && seq_featureset_test(features, FEAT_tp_getitem_index)) { + cmp->tp_compare = &DeeSeq_DefaultCompareWithSizeAndGetItemIndex; + } else if (seq_featureset_test(features, FEAT_tp_sizeob) && seq_featureset_test(features, FEAT_tp_getitem)) { + cmp->tp_compare = &DeeSeq_DefaultCompareWithSizeObAndGetItem; + } else if (seq->tp_foreach) { + cmp->tp_compare = &DeeSeq_DefaultCompareWithForeachDefault; + } + } + if (!cmp->tp_compare_eq) { + if (seq_featureset_test(features, FEAT_tp_size) && seq->tp_getitem_index_fast) { + cmp->tp_compare_eq = &DeeSeq_DefaultCompareEqWithSizeAndGetItemIndexFast; + } else if (seq_featureset_test(features, FEAT_tp_size) && seq_featureset_test(features, FEAT_tp_trygetitem_index)) { + cmp->tp_compare_eq = &DeeSeq_DefaultCompareEqWithSizeAndTryGetItemIndex; + } else if (seq_featureset_test(features, FEAT_tp_size) && seq_featureset_test(features, FEAT_tp_getitem_index)) { + cmp->tp_compare_eq = &DeeSeq_DefaultCompareEqWithSizeAndGetItemIndex; + } else if (seq_featureset_test(features, FEAT_tp_sizeob) && seq_featureset_test(features, FEAT_tp_getitem)) { + cmp->tp_compare_eq = &DeeSeq_DefaultCompareEqWithSizeObAndGetItem; + } else if (seq->tp_foreach) { + cmp->tp_compare_eq = &DeeSeq_DefaultCompareEqWithForeachDefault; + } + } + break; + case Dee_SEQCLASS_SET: + if (seq->tp_foreach) { + if (!cmp->tp_hash) + cmp->tp_hash = &DeeSet_DefaultHashWithForeachDefault; + if (!cmp->tp_compare_eq) + cmp->tp_compare_eq = &DeeSet_DefaultCompareEqWithForeachDefault; + if (!cmp->tp_lo) + cmp->tp_lo = &DeeSet_DefaultLoWithForeachDefault; + if (!cmp->tp_le) + cmp->tp_le = &DeeSet_DefaultLeWithForeachDefault; + if (!cmp->tp_gr) + cmp->tp_gr = &DeeSet_DefaultGrWithForeachDefault; + if (!cmp->tp_ge) + cmp->tp_ge = &DeeSet_DefaultGeWithForeachDefault; + } + break; + case Dee_SEQCLASS_MAP: + if (seq->tp_foreach_pair) { + if (!cmp->tp_hash) + cmp->tp_hash = &DeeMap_DefaultHashWithForeachPairDefault; + if (!cmp->tp_compare_eq) + cmp->tp_compare_eq = &DeeMap_DefaultCompareEqWithForeachPairDefault; + if (!cmp->tp_lo) + cmp->tp_lo = &DeeMap_DefaultLoWithForeachPairDefault; + if (!cmp->tp_le) + cmp->tp_le = &DeeMap_DefaultLeWithForeachPairDefault; + if (!cmp->tp_gr) + cmp->tp_gr = &DeeMap_DefaultGrWithForeachPairDefault; + if (!cmp->tp_ge) + cmp->tp_ge = &DeeMap_DefaultGeWithForeachPairDefault; + } + break; + default: __builtin_unreachable(); + } + DeeType_SubstituteDefaultCompareOperators(cmp); + } + } else { + /* No user-provided compare operators -> use a default group. */ + + switch (seqclass) { + case Dee_SEQCLASS_SEQ: + if (seq_featureset_test(features, FEAT_tp_size) && seq->tp_getitem_index_fast) { + self->tp_cmp = &DeeSeq_DefaultCmpWithSizeAndGetItemIndexFast; + } else if (seq_featureset_test(features, FEAT_tp_size) && seq_featureset_test(features, FEAT_tp_trygetitem_index)) { + self->tp_cmp = &DeeSeq_DefaultCmpWithSizeAndTryGetItemIndex; + } else if (seq_featureset_test(features, FEAT_tp_size) && seq_featureset_test(features, FEAT_tp_getitem_index)) { + self->tp_cmp = &DeeSeq_DefaultCmpWithSizeAndGetItemIndex; + } else if (seq_featureset_test(features, FEAT_tp_sizeob) && seq_featureset_test(features, FEAT_tp_getitem)) { + self->tp_cmp = &DeeSeq_DefaultCmpWithSizeObAndGetItem; + } else if (seq->tp_foreach) { + self->tp_cmp = &DeeSeq_DefaultCmpWithForeachDefault; + } + break; + case Dee_SEQCLASS_SET: + if (seq->tp_foreach) + self->tp_cmp = &DeeSet_DefaultCmpWithForeachDefault; + break; + case Dee_SEQCLASS_MAP: + if (seq->tp_foreach_pair) + self->tp_cmp = &DeeMap_DefaultCmpWithForeachPairDefault; + break; + default: __builtin_unreachable(); + } + } } +#ifndef DEFINE_TYPED_OPERATORS +INTERN struct type_cmp DeeSeq_DefaultCmpWithSizeAndGetItemIndexFast = { + /* .tp_hash = */ &DeeSeq_DefaultHashWithSizeAndGetItemIndexFast, + /* .tp_eq = */ &DeeObject_DefaultEqWithCompareEqDefault, + /* .tp_ne = */ &DeeObject_DefaultNeWithCompareEqDefault, + /* .tp_lo = */ &DeeObject_DefaultLoWithCompareDefault, + /* .tp_le = */ &DeeObject_DefaultLeWithCompareDefault, + /* .tp_gr = */ &DeeObject_DefaultGrWithCompareDefault, + /* .tp_ge = */ &DeeObject_DefaultGeWithCompareDefault, + /* .tp_nii = */ NULL, + /* .tp_compare_eq = */ &DeeSeq_DefaultCompareEqWithSizeAndGetItemIndexFast, + /* .tp_compare = */ &DeeSeq_DefaultCompareWithSizeAndGetItemIndexFast, +}; +INTERN struct type_cmp DeeSeq_DefaultCmpWithSizeAndTryGetItemIndex = { + /* .tp_hash = */ &DeeSeq_DefaultHashWithSizeAndTryGetItemIndex, + /* .tp_eq = */ &DeeObject_DefaultEqWithCompareEqDefault, + /* .tp_ne = */ &DeeObject_DefaultNeWithCompareEqDefault, + /* .tp_lo = */ &DeeObject_DefaultLoWithCompareDefault, + /* .tp_le = */ &DeeObject_DefaultLeWithCompareDefault, + /* .tp_gr = */ &DeeObject_DefaultGrWithCompareDefault, + /* .tp_ge = */ &DeeObject_DefaultGeWithCompareDefault, + /* .tp_nii = */ NULL, + /* .tp_compare_eq = */ &DeeSeq_DefaultCompareEqWithSizeAndTryGetItemIndex, + /* .tp_compare = */ &DeeSeq_DefaultCompareWithSizeAndTryGetItemIndex, +}; +INTERN struct type_cmp DeeSeq_DefaultCmpWithSizeAndGetItemIndex = { + /* .tp_hash = */ &DeeSeq_DefaultHashWithSizeAndGetItemIndex, + /* .tp_eq = */ &DeeObject_DefaultEqWithCompareEqDefault, + /* .tp_ne = */ &DeeObject_DefaultNeWithCompareEqDefault, + /* .tp_lo = */ &DeeObject_DefaultLoWithCompareDefault, + /* .tp_le = */ &DeeObject_DefaultLeWithCompareDefault, + /* .tp_gr = */ &DeeObject_DefaultGrWithCompareDefault, + /* .tp_ge = */ &DeeObject_DefaultGeWithCompareDefault, + /* .tp_nii = */ NULL, + /* .tp_compare_eq = */ &DeeSeq_DefaultCompareEqWithSizeAndGetItemIndex, + /* .tp_compare = */ &DeeSeq_DefaultCompareWithSizeAndGetItemIndex, +}; +INTERN struct type_cmp DeeSeq_DefaultCmpWithSizeObAndGetItem = { + /* .tp_hash = */ &DeeSeq_DefaultHashWithSizeObAndGetItem, + /* .tp_eq = */ &DeeObject_DefaultEqWithCompareEqDefault, + /* .tp_ne = */ &DeeObject_DefaultNeWithCompareEqDefault, + /* .tp_lo = */ &DeeObject_DefaultLoWithCompareDefault, + /* .tp_le = */ &DeeObject_DefaultLeWithCompareDefault, + /* .tp_gr = */ &DeeObject_DefaultGrWithCompareDefault, + /* .tp_ge = */ &DeeObject_DefaultGeWithCompareDefault, + /* .tp_nii = */ NULL, + /* .tp_compare_eq = */ &DeeSeq_DefaultCompareEqWithSizeObAndGetItem, + /* .tp_compare = */ &DeeSeq_DefaultCompareWithSizeObAndGetItem, +}; +INTERN struct type_cmp DeeSeq_DefaultCmpWithForeachDefault = { + /* .tp_hash = */ &DeeSeq_DefaultHashWithForeachDefault, + /* .tp_eq = */ &DeeObject_DefaultEqWithCompareEqDefault, + /* .tp_ne = */ &DeeObject_DefaultNeWithCompareEqDefault, + /* .tp_lo = */ &DeeObject_DefaultLoWithCompareDefault, + /* .tp_le = */ &DeeObject_DefaultLeWithCompareDefault, + /* .tp_gr = */ &DeeObject_DefaultGrWithCompareDefault, + /* .tp_ge = */ &DeeObject_DefaultGeWithCompareDefault, + /* .tp_nii = */ NULL, + /* .tp_compare_eq = */ &DeeSeq_DefaultCompareEqWithForeachDefault, + /* .tp_compare = */ &DeeSeq_DefaultCompareWithForeachDefault, +}; +INTERN struct type_cmp DeeSet_DefaultCmpWithForeachDefault = { + /* .tp_hash = */ &DeeSet_DefaultHashWithForeachDefault, + /* .tp_eq = */ &DeeObject_DefaultEqWithCompareEqDefault, + /* .tp_ne = */ &DeeObject_DefaultNeWithCompareEqDefault, + /* .tp_lo = */ &DeeObject_DefaultLoWithCompareDefault, + /* .tp_le = */ &DeeObject_DefaultLeWithCompareDefault, + /* .tp_gr = */ &DeeObject_DefaultGrWithCompareDefault, + /* .tp_ge = */ &DeeObject_DefaultGeWithCompareDefault, + /* .tp_nii = */ NULL, + /* .tp_compare_eq = */ &DeeSet_DefaultCompareEqWithForeachDefault, + /* .tp_compare = */ NULL, +}; +INTERN struct type_cmp DeeMap_DefaultCmpWithForeachPairDefault = { + /* .tp_hash = */ &DeeMap_DefaultHashWithForeachPairDefault, + /* .tp_eq = */ &DeeObject_DefaultEqWithCompareEqDefault, + /* .tp_ne = */ &DeeObject_DefaultNeWithCompareEqDefault, + /* .tp_lo = */ &DeeObject_DefaultLoWithCompareDefault, + /* .tp_le = */ &DeeObject_DefaultLeWithCompareDefault, + /* .tp_gr = */ &DeeObject_DefaultGrWithCompareDefault, + /* .tp_ge = */ &DeeObject_DefaultGeWithCompareDefault, + /* .tp_nii = */ NULL, + /* .tp_compare_eq = */ &DeeMap_DefaultCompareEqWithForeachPairDefault, + /* .tp_compare = */ NULL, +}; +#endif /* !DEFINE_TYPED_OPERATORS */ /* Inherit OPERATOR_ITER, OPERATOR_SIZE and OPERTOR_GETITEM for * a type with `DeeType_GetSeqClass(self) == Dee_SEQCLASS_SEQ' */ @@ -11587,6 +13864,24 @@ DeeType_InheritSeqOperators(DeeTypeObject *__restrict self, unsigned int seqclas } else { self->tp_seq = base_seq; } + if (self->tp_cmp && base->tp_cmp) { + DeeTypeObject *origin = DeeType_GetSeqOrigin(self); + if unlikely(origin) { + DeeType_InheritCompare(origin); + } else { + self->tp_cmp->tp_hash = base->tp_cmp->tp_hash; + self->tp_cmp->tp_eq = base->tp_cmp->tp_eq; + self->tp_cmp->tp_ne = base->tp_cmp->tp_ne; + self->tp_cmp->tp_lo = base->tp_cmp->tp_lo; + self->tp_cmp->tp_le = base->tp_cmp->tp_le; + self->tp_cmp->tp_gr = base->tp_cmp->tp_gr; + self->tp_cmp->tp_ge = base->tp_cmp->tp_ge; + self->tp_cmp->tp_compare_eq = base->tp_cmp->tp_compare_eq; + self->tp_cmp->tp_compare = base->tp_cmp->tp_compare; + } + } else { + self->tp_cmp = base->tp_cmp; + } return true; } return false; @@ -12681,8 +14976,69 @@ DeeType_InheritSetRange(DeeTypeObject *__restrict self) { } return false; } + + +INTERN NONNULL((1)) bool DCALL +DeeType_InheritCompare(DeeTypeObject *__restrict self) { + struct type_cmp *base_cmp; + DeeTypeMRO mro; + DeeTypeObject *base; + + /* Special case when it's a sequence type. */ + { + unsigned int seqclass = DeeType_GetSeqClass(self); + if (seqclass != Dee_SEQCLASS_NONE) { + return (DeeType_InheritSeqOperators(self, seqclass) && + self->tp_cmp && (self->tp_cmp->tp_compare_eq || self->tp_cmp->tp_hash)); + } + } + + base_cmp = self->tp_cmp; + if (base_cmp) { + DeeType_SubstituteDefaultCompareOperators(base_cmp); + if (base_cmp->tp_hash || base_cmp->tp_eq || base_cmp->tp_lo || base_cmp->tp_le) + return true; + } + + base = DeeTypeMRO_Init(&mro, self); + while ((base = DeeTypeMRO_NextDirectBase(&mro, base)) != NULL) { + base_cmp = base->tp_cmp; + if (base_cmp == NULL || + (!base_cmp->tp_hash || + !base_cmp->tp_eq || !base_cmp->tp_ne || + !base_cmp->tp_lo || !base_cmp->tp_le || + !base_cmp->tp_gr || !base_cmp->tp_ge || + !base_cmp->tp_compare_eq || !base_cmp->tp_compare)) { + if (!DeeType_InheritCompare(base)) + continue; + base_cmp = base->tp_cmp; + } + LOG_INHERIT(base, self, "operator "); + if (self->tp_cmp) { + DeeTypeObject *origin = DeeType_GetCmpOrigin(self); + if unlikely(origin) + return DeeType_InheritCompare(origin); + self->tp_cmp->tp_hash = base_cmp->tp_hash; + self->tp_cmp->tp_eq = base_cmp->tp_eq; + self->tp_cmp->tp_ne = base_cmp->tp_ne; + self->tp_cmp->tp_lo = base_cmp->tp_lo; + self->tp_cmp->tp_le = base_cmp->tp_le; + self->tp_cmp->tp_gr = base_cmp->tp_gr; + self->tp_cmp->tp_ge = base_cmp->tp_ge; + self->tp_cmp->tp_compare_eq = base_cmp->tp_compare_eq; + self->tp_cmp->tp_compare = base_cmp->tp_compare; + } else { + self->tp_cmp = base_cmp; + } + return true; + } + return false; +} #endif /* !DEFINE_TYPED_OPERATORS */ + + + DEFINE_OPERATOR(DREF DeeObject *, Iter, (DeeObject *RESTRICT_IF_NOTYPE self)) { LOAD_TP_SELF; if likely((tp_self->tp_seq && tp_self->tp_seq->tp_iter) || @@ -14686,10 +17042,10 @@ PUBLIC WUNUSED ATTR_OUTS(3, 2) NONNULL((1)) int /* Compare a pre-keyed `lhs_keyed' with `rhs' using the given (optional) `key' function - * @return: == -2: An error occurred. * @return: == -1: `lhs_keyed < key(rhs)' * @return: == 0: `lhs_keyed == key(rhs)' - * @return: == 1: `lhs_keyed > key(rhs)' */ + * @return: == 1: `lhs_keyed > key(rhs)' + * @return: == Dee_COMPARE_ERR: An error occurred. */ PUBLIC WUNUSED NONNULL((1, 2)) int (DCALL DeeObject_CompareKey)(DeeObject *lhs_keyed, DeeObject *rhs, /*nullable*/ DeeObject *key) { @@ -14703,7 +17059,7 @@ PUBLIC WUNUSED NONNULL((1, 2)) int Dee_Decref(rhs); return result; err: - return -2; + return Dee_COMPARE_ERR; } diff --git a/src/deemon/runtime/operator_info.c b/src/deemon/runtime/operator_info.c index 742c917d6..90d13ceca 100644 --- a/src/deemon/runtime/operator_info.c +++ b/src/deemon/runtime/operator_info.c @@ -1293,7 +1293,8 @@ DeeType_InheritOperator(DeeTypeObject *__restrict self, Dee_operator_t name) { case OPERATOR_INPLACE_POW: return (self->tp_math && (self->tp_math->tp_pow || self->tp_math->tp_inplace_pow)) || DeeType_InheritPow(self); case OPERATOR_HASH: - return (self->tp_cmp && self->tp_cmp->tp_hash) || DeeType_InheritHash(self); + return (self->tp_cmp && self->tp_cmp->tp_hash) || + (DeeType_InheritCompare(self) && self->tp_cmp->tp_hash); case OPERATOR_EQ: case OPERATOR_NE: return (self->tp_cmp && self->tp_cmp->tp_eq) ||