diff --git a/.vs/deemon-v141.sln b/.vs/deemon-v141.sln index f95093391..1da997867 100644 --- a/.vs/deemon-v141.sln +++ b/.vs/deemon-v141.sln @@ -212,6 +212,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "include", "include", "{2360 ..\lib\include\function = ..\lib\include\function ..\lib\include\gc = ..\lib\include\gc ..\lib\include\intrin = ..\lib\include\intrin + ..\lib\include\m_builtins.dee = ..\lib\include\m_builtins.dee ..\lib\include\m_fs.dee = ..\lib\include\m_fs.dee ..\lib\include\m_fs_path.dee = ..\lib\include\m_fs_path.dee ..\lib\include\m_fs_posix.dee = ..\lib\include\m_fs_posix.dee diff --git a/.vs/deemon-v141.vcxproj b/.vs/deemon-v141.vcxproj index c5fab3881..8d4b725b2 100644 --- a/.vs/deemon-v141.vcxproj +++ b/.vs/deemon-v141.vcxproj @@ -269,7 +269,6 @@ - @@ -459,7 +458,6 @@ - diff --git a/.vs/deemon-v141.vcxproj.filters b/.vs/deemon-v141.vcxproj.filters index a2007339f..c286217c8 100644 --- a/.vs/deemon-v141.vcxproj.filters +++ b/.vs/deemon-v141.vcxproj.filters @@ -780,9 +780,6 @@ src\objects\seq - - src\objects\seq - src\objects\seq @@ -1346,9 +1343,6 @@ src\objects\seq - - src\objects\seq - src\objects\seq diff --git a/.vs/deemon-v142.sln b/.vs/deemon-v142.sln index 2259dcd53..06548d006 100644 --- a/.vs/deemon-v142.sln +++ b/.vs/deemon-v142.sln @@ -212,6 +212,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "include", "include", "{2360 ..\lib\include\function = ..\lib\include\function ..\lib\include\gc = ..\lib\include\gc ..\lib\include\intrin = ..\lib\include\intrin + ..\lib\include\m_builtins.dee = ..\lib\include\m_builtins.dee ..\lib\include\m_fs.dee = ..\lib\include\m_fs.dee ..\lib\include\m_fs_path.dee = ..\lib\include\m_fs_path.dee ..\lib\include\m_fs_posix.dee = ..\lib\include\m_fs_posix.dee diff --git a/.vs/deemon-v142.vcxproj b/.vs/deemon-v142.vcxproj index b021f44c2..53c628ef1 100644 --- a/.vs/deemon-v142.vcxproj +++ b/.vs/deemon-v142.vcxproj @@ -269,7 +269,6 @@ - @@ -459,7 +458,6 @@ - diff --git a/.vs/deemon-v142.vcxproj.filters b/.vs/deemon-v142.vcxproj.filters index a2007339f..c286217c8 100644 --- a/.vs/deemon-v142.vcxproj.filters +++ b/.vs/deemon-v142.vcxproj.filters @@ -780,9 +780,6 @@ src\objects\seq - - src\objects\seq - src\objects\seq @@ -1346,9 +1343,6 @@ src\objects\seq - - src\objects\seq - src\objects\seq diff --git a/.vs/dex/rt-v141.vcxproj b/.vs/dex/rt-v141.vcxproj index 5ad9a9d68..2027251bd 100644 --- a/.vs/dex/rt-v141.vcxproj +++ b/.vs/dex/rt-v141.vcxproj @@ -41,6 +41,9 @@ + + + {85DE4E2D-552A-48E3-A320-0000000003E4} rt diff --git a/.vs/dex/rt-v142.vcxproj b/.vs/dex/rt-v142.vcxproj index 06d60eaeb..9923a3bff 100644 --- a/.vs/dex/rt-v142.vcxproj +++ b/.vs/dex/rt-v142.vcxproj @@ -41,6 +41,9 @@ + + + {85DE4E2D-552A-48E3-A320-0000000003E4} rt diff --git a/include/deemon/method-hints.def b/include/deemon/method-hints.def index b7909891a..5b63de788 100644 --- a/include/deemon/method-hints.def +++ b/include/deemon/method-hints.def @@ -165,17 +165,15 @@ Dee_DEFINE_TYPE_METHOD_HINT_FUNC(WUNUSED_T NONNULL_T((1, 2)), int, DCALL, seq_co Dee_DEFINE_TYPE_METHOD_HINT_FUNC(WUNUSED_T NONNULL_T((1, 2, 5)), int, DCALL, seq_contains_with_range_and_key, (DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key)) Dee_DEFINE_TYPE_METHOD_HINT_KWMETHOD(seq_contains, "contains", "(item,start=!0,end:?Dint=!A!Dint!PSIZE_MAX,key:?DCallable=!N)->?Dbool") -Dee_DEFINE_TYPE_METHOD_HINT_FUNC(WUNUSED_T NONNULL_T((1, 2)), DREF DeeObject *, DCALL, seq_locate, (DeeObject *self, DeeObject *item)) -Dee_DEFINE_TYPE_METHOD_HINT_FUNC(WUNUSED_T NONNULL_T((1, 2, 3)), DREF DeeObject *, DCALL, seq_locate_with_key, (DeeObject *self, DeeObject *item, DeeObject *key)) -Dee_DEFINE_TYPE_METHOD_HINT_FUNC(WUNUSED_T NONNULL_T((1, 2)), DREF DeeObject *, DCALL, seq_locate_with_range, (DeeObject *self, DeeObject *item, size_t start, size_t end)) -Dee_DEFINE_TYPE_METHOD_HINT_FUNC(WUNUSED_T NONNULL_T((1, 2, 5)), DREF DeeObject *, DCALL, seq_locate_with_range_and_key, (DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key)) -Dee_DEFINE_TYPE_METHOD_HINT_KWMETHOD(seq_locate, "locate", "(item,start=!0,end:?Dint=!A!Dint!PSIZE_MAX,key:?DCallable=!N)->") - -/*Dee_DEFINE_TYPE_METHOD_HINT_FUNC(WUNUSED_T NONNULL_T((1, 2)), DREF DeeObject *, DCALL, seq_rlocate, (DeeObject *self, DeeObject *item))*/ /* Wouldn't make sense: for reverse, you need indices */ -/*Dee_DEFINE_TYPE_METHOD_HINT_FUNC(WUNUSED_T NONNULL_T((1, 2, 3)), DREF DeeObject *, DCALL, seq_rlocate_with_key, (DeeObject *self, DeeObject *item, DeeObject *key))*/ /* Wouldn't make sense: for reverse, you need indices */ -Dee_DEFINE_TYPE_METHOD_HINT_FUNC(WUNUSED_T NONNULL_T((1, 2)), DREF DeeObject *, DCALL, seq_rlocate_with_range, (DeeObject *self, DeeObject *item, size_t start, size_t end)) -Dee_DEFINE_TYPE_METHOD_HINT_FUNC(WUNUSED_T NONNULL_T((1, 2, 5)), DREF DeeObject *, DCALL, seq_rlocate_with_range_and_key, (DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key)) -Dee_DEFINE_TYPE_METHOD_HINT_KWMETHOD(seq_rlocate, "rlocate", "(item,start=!0,end:?Dint=!A!Dint!PSIZE_MAX,key:?DCallable=!N)->") +/* Returns the first element (within the given range) where `match(elem)' is true. */ +Dee_DEFINE_TYPE_METHOD_HINT_FUNC(WUNUSED_T NONNULL_T((1, 2, 3)), DREF DeeObject *, DCALL, seq_locate, (DeeObject *self, DeeObject *match, DeeObject *def)) +Dee_DEFINE_TYPE_METHOD_HINT_FUNC(WUNUSED_T NONNULL_T((1, 2, 5)), DREF DeeObject *, DCALL, seq_locate_with_range, (DeeObject *self, DeeObject *match, size_t start, size_t end, DeeObject *def)) +Dee_DEFINE_TYPE_METHOD_HINT_KWMETHOD(seq_locate, "locate", "(match,start=!0,end:?Dint=!A!Dint!PSIZE_MAX,def=!N)->?X2?O?Q!Adef]") + +/* Returns the last element (within the given range) where `match(elem)' is true. */ +/*Dee_DEFINE_TYPE_METHOD_HINT_FUNC(WUNUSED_T NONNULL_T((1, 2, 3)), DREF DeeObject *, DCALL, seq_rlocate, (DeeObject *self, DeeObject *match, DeeObject *def))*/ /* Wouldn't make sense: for reverse, you need indices */ +Dee_DEFINE_TYPE_METHOD_HINT_FUNC(WUNUSED_T NONNULL_T((1, 2, 5)), DREF DeeObject *, DCALL, seq_rlocate_with_range, (DeeObject *self, DeeObject *match, size_t start, size_t end, DeeObject *def)) +Dee_DEFINE_TYPE_METHOD_HINT_KWMETHOD(seq_rlocate, "rlocate", "(match,start=!0,end:?Dint=!A!Dint!PSIZE_MAX,def=!N)->?X2?O?Q!Adef]") /* @return: 0 : Does not start with * @return: 1 : Does start with @@ -281,10 +279,6 @@ Dee_DEFINE_TYPE_METHOD_HINT_FUNC(WUNUSED_T NONNULL_T((1, 2, 5)), int, DCALL, seq Dee_DEFINE_TYPE_METHOD_HINT_FUNC(WUNUSED_T NONNULL_T((1, 2, 5, 6)), int, DCALL, seq_brange_with_key, (DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key, size_t result_range[2])) Dee_DEFINE_TYPE_METHOD_HINT_KWMETHOD(seq_brange, "brange", "(item,start=!0,end:?Dint=!A!Dint!PSIZE_MAX,key:?DCallable=!N)->?X2?Dint?Dint") -Dee_DEFINE_TYPE_METHOD_HINT_FUNC(WUNUSED_T NONNULL_T((1, 2)), DREF DeeObject *, DCALL, seq_blocate, (DeeObject *self, DeeObject *item, size_t start, size_t end)) -Dee_DEFINE_TYPE_METHOD_HINT_FUNC(WUNUSED_T NONNULL_T((1, 2, 5)), DREF DeeObject *, DCALL, seq_blocate_with_key, (DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key)) -Dee_DEFINE_TYPE_METHOD_HINT_KWMETHOD(seq_blocate, "blocate", "(item,start=!0,end:?Dint=!A!Dint!PSIZE_MAX,key:?DCallable=!N)->") - /************************************************************************/ diff --git a/include/deemon/method-hints.h b/include/deemon/method-hints.h index 4aad01b8d..7c4ba3514 100644 --- a/include/deemon/method-hints.h +++ b/include/deemon/method-hints.h @@ -342,11 +342,8 @@ INTDEF ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_seq_contains_with_k INTDEF ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_seq_contains_with_range_t DCALL DeeType_RequireSeqContainsWithRange(DeeTypeObject *__restrict self); INTDEF ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_seq_contains_with_range_and_key_t DCALL DeeType_RequireSeqContainsWithRangeAndKey(DeeTypeObject *__restrict self); INTDEF ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_seq_locate_t DCALL DeeType_RequireSeqLocate(DeeTypeObject *__restrict self); -INTDEF ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_seq_locate_with_key_t DCALL DeeType_RequireSeqLocateWithKey(DeeTypeObject *__restrict self); INTDEF ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_seq_locate_with_range_t DCALL DeeType_RequireSeqLocateWithRange(DeeTypeObject *__restrict self); -INTDEF ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_seq_locate_with_range_and_key_t DCALL DeeType_RequireSeqLocateWithRangeAndKey(DeeTypeObject *__restrict self); INTDEF ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_seq_rlocate_with_range_t DCALL DeeType_RequireSeqRLocateWithRange(DeeTypeObject *__restrict self); -INTDEF ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_seq_rlocate_with_range_and_key_t DCALL DeeType_RequireSeqRLocateWithRangeAndKey(DeeTypeObject *__restrict self); INTDEF ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_seq_startswith_t DCALL DeeType_RequireSeqStartsWith(DeeTypeObject *__restrict self); INTDEF ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_seq_startswith_with_key_t DCALL DeeType_RequireSeqStartsWithWithKey(DeeTypeObject *__restrict self); INTDEF ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_seq_startswith_with_range_t DCALL DeeType_RequireSeqStartsWithWithRange(DeeTypeObject *__restrict self); @@ -391,8 +388,6 @@ INTDEF ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_seq_bposition_t DCA INTDEF ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_seq_bposition_with_key_t DCALL DeeType_RequireSeqBPositionWithKey(DeeTypeObject *__restrict self); INTDEF ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_seq_brange_t DCALL DeeType_RequireSeqBRange(DeeTypeObject *__restrict self); INTDEF ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_seq_brange_with_key_t DCALL DeeType_RequireSeqBRangeWithKey(DeeTypeObject *__restrict self); -INTDEF ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_seq_blocate_t DCALL DeeType_RequireSeqBLocate(DeeTypeObject *__restrict self); -INTDEF ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_seq_blocate_with_key_t DCALL DeeType_RequireSeqBLocateWithKey(DeeTypeObject *__restrict self); /* Set functions */ INTDEF ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_set_insert_t DCALL DeeType_RequireSetInsert(DeeTypeObject *__restrict self); @@ -568,11 +563,8 @@ INTDEF ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_map_popitem_t DCALL #define DeeType_RequireSeqContainsWithRange(self) ((Dee_mh_seq_contains_with_range_t)DeeType_GetMethodHint(self, Dee_TMH_seq_contains_with_range)) #define DeeType_RequireSeqContainsWithRangeAndKey(self) ((Dee_mh_seq_contains_with_range_and_key_t)DeeType_GetMethodHint(self, Dee_TMH_seq_contains_with_range_and_key)) #define DeeType_RequireSeqLocate(self) ((Dee_mh_seq_locate_t)DeeType_GetMethodHint(self, Dee_TMH_seq_locate)) -#define DeeType_RequireSeqLocateWithKey(self) ((Dee_mh_seq_locate_with_key_t)DeeType_GetMethodHint(self, Dee_TMH_seq_locate_with_key)) #define DeeType_RequireSeqLocateWithRange(self) ((Dee_mh_seq_locate_with_range_t)DeeType_GetMethodHint(self, Dee_TMH_seq_locate_with_range)) -#define DeeType_RequireSeqLocateWithRangeAndKey(self) ((Dee_mh_seq_locate_with_range_and_key_t)DeeType_GetMethodHint(self, Dee_TMH_seq_locate_with_range_and_key)) #define DeeType_RequireSeqRLocateWithRange(self) ((Dee_mh_seq_rlocate_with_range_t)DeeType_GetMethodHint(self, Dee_TMH_seq_rlocate_with_range)) -#define DeeType_RequireSeqRLocateWithRangeAndKey(self) ((Dee_mh_seq_rlocate_with_range_and_key_t)DeeType_GetMethodHint(self, Dee_TMH_seq_rlocate_with_range_and_key)) #define DeeType_RequireSeqStartsWith(self) ((Dee_mh_seq_startswith_t)DeeType_GetMethodHint(self, Dee_TMH_seq_startswith)) #define DeeType_RequireSeqStartsWithWithKey(self) ((Dee_mh_seq_startswith_with_key_t)DeeType_GetMethodHint(self, Dee_TMH_seq_startswith_with_key)) #define DeeType_RequireSeqStartsWithWithRange(self) ((Dee_mh_seq_startswith_with_range_t)DeeType_GetMethodHint(self, Dee_TMH_seq_startswith_with_range)) @@ -615,8 +607,6 @@ INTDEF ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_map_popitem_t DCALL #define DeeType_RequireSeqBPositionWithKey(self) ((Dee_mh_seq_bposition_with_key_t)DeeType_GetMethodHint(self, Dee_TMH_seq_bposition_with_key)) #define DeeType_RequireSeqBRange(self) ((Dee_mh_seq_brange_t)DeeType_GetMethodHint(self, Dee_TMH_seq_brange)) #define DeeType_RequireSeqBRangeWithKey(self) ((Dee_mh_seq_brange_with_key_t)DeeType_GetMethodHint(self, Dee_TMH_seq_brange_with_key)) -#define DeeType_RequireSeqBLocate(self) ((Dee_mh_seq_blocate_t)DeeType_GetMethodHint(self, Dee_TMH_seq_blocate)) -#define DeeType_RequireSeqBLocateWithKey(self) ((Dee_mh_seq_blocate_with_key_t)DeeType_GetMethodHint(self, Dee_TMH_seq_blocate_with_key)) #define DeeType_RequireSetInsert(self) ((Dee_mh_set_insert_t)DeeType_GetMethodHint(self, Dee_TMH_set_insert)) #define DeeType_RequireSetRemove(self) ((Dee_mh_set_remove_t)DeeType_GetMethodHint(self, Dee_TMH_set_remove)) #define DeeType_RequireSetUnify(self) ((Dee_mh_set_unify_t)DeeType_GetMethodHint(self, Dee_TMH_set_unify)) diff --git a/lib/include/__builtin_util.dee b/lib/include/__builtin_util.dee index bb996206c..a3281df19 100644 --- a/lib/include/__builtin_util.dee +++ b/lib/include/__builtin_util.dee @@ -50,9 +50,11 @@ final local __builtin_seq_index = (Sequence from deemon).operator . ("index"); final local __builtin_seq_rindex = (Sequence from deemon).operator . ("rindex"); final local __builtin_seq_contains = (Sequence from deemon).operator . ("contains"); final local __builtin_seq_count = (Sequence from deemon).operator . ("count"); -final local __builtin_seq_locate = (Sequence from deemon).operator . ("locate"); -final local __builtin_seq_rlocate = (Sequence from deemon).operator . ("rlocate"); -final local __builtin_seq_locate_all = (Sequence from deemon).operator . ("locateall"); +from ".m_builtins" import + __builtin_seq_locate = "seq_locate", + __builtin_seq_rlocate = "seq_rlocate", + __builtin_seq_locate_all = "seq_locateall" +; final local __builtin_seq_transform = (Sequence from deemon).operator . ("transform"); final local __builtin_seq_empty = (Sequence from deemon).operator . ("isempty"); final local __builtin_seq_non_empty = (Sequence from deemon).operator . ("isnonempty"); @@ -63,5 +65,5 @@ final local __builtin_seq_at = (Sequence from deemon).operator . ("at"); final local __builtin_seq_reversed = (Sequence from deemon).operator . ("reversed"); final local __builtin_seq_sorted = (Sequence from deemon).operator . ("sorted"); final local __builtin_seq_segments = (Sequence from deemon).operator . ("segments"); -#pragma pop_macro("from", "util", "import", "Sequence", "deemon", "operator", "final", "local") +#pragma pop_macro("from", "import", "Sequence", "deemon", "operator", "final", "local") diff --git a/lib/include/m_builtins.dee b/lib/include/m_builtins.dee new file mode 100644 index 000000000..b07b26c48 --- /dev/null +++ b/lib/include/m_builtins.dee @@ -0,0 +1,57 @@ +/* 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. * + */ +import * from deemon; +import * from errors; +import identity from functools; + +function seq_locate(seq, item, key = none): Object { + if (key is none) + key = identity; + item = key(item); + for (local elem: seq as Sequence) { + if (equals(item, key(elem))) + return elem; + } + throw ValueError(f"Could not locate item `{item}' in sequence `{seq}'"); +} + +function seq_rlocate(seq, item, key = none): Object { + if (key is none) + key = identity; + item = key(item); + local result; + for (local elem: seq as Sequence) { + if (equals(item, key(elem))) + result = elem; + } + if (result is bound) + return result; + throw ValueError(f"Could not locate item `{item}' in sequence `{seq}'"); +} + +function seq_locateall(seq, item, key = none): {Object...} { + if (key is none) + key = identity; + item = key(item); + for (local elem: seq as Sequence) { + if (equals(item, key(elem))) + yield elem; + } +} diff --git a/lib/rt/builtins.dee b/lib/rt/builtins.dee index 5c67fa09e..5e71ca600 100644 --- a/lib/rt/builtins.dee +++ b/lib/rt/builtins.dee @@ -48,6 +48,7 @@ import compat_util = ..include.m_util; import compat_util_attr = ..include.m_util_attr; import compat_math = ..include.m_math; import compat_gcc = ..include.__builtin_gcc; +import compat_builtins = ..include.m_builtins; import compat_sys = ..include.m_sys; import compat_fs = ..include.m_fs; final local opt_win32 = try import("win32") catch (...) none; @@ -498,9 +499,9 @@ local __objects = deemon.List { /* 0x01b4 */ deemon.Sequence.index, /* 0x01b5 */ deemon.Sequence.rindex, /* 0x01b6 */ deemon.Sequence.count, - /* 0x01b7 */ deemon.Sequence.locate, - /* 0x01b8 */ deemon.Sequence.rlocate, - /* 0x01b9 */ deemon.Sequence.locateall, + /* 0x01b7 */ compat_builtins.seq_locate, + /* 0x01b8 */ compat_builtins.seq_rlocate, + /* 0x01b9 */ compat_builtins.seq_locateall, /* 0x01ba */ deemon.Sequence.transform, /* 0x01bb */ deemon.Sequence.isempty, /* 0x01bc */ deemon.Sequence.isnonempty, diff --git a/src/deemon/linker-scripts/link-deemon-gcc-i386-cygwin.def b/src/deemon/linker-scripts/link-deemon-gcc-i386-cygwin.def index 3f21c7a56..d87ecd080 100644 --- a/src/deemon/linker-scripts/link-deemon-gcc-i386-cygwin.def +++ b/src/deemon/linker-scripts/link-deemon-gcc-i386-cygwin.def @@ -479,7 +479,6 @@ EXPORTS _DeeMH_seq_any@16=DeeMH_seq_any@16 _DeeMH_seq_append@12=DeeMH_seq_append@12 _DeeMH_seq_bfind@16=DeeMH_seq_bfind@16 - _DeeMH_seq_blocate@16=DeeMH_seq_blocate@16 _DeeMH_seq_bposition@16=DeeMH_seq_bposition@16 _DeeMH_seq_brange@16=DeeMH_seq_brange@16 _DeeMH_seq_clear@12=DeeMH_seq_clear@12 @@ -1196,6 +1195,10 @@ EXPORTS _DeeTuple_VPackSymbolic@8=DeeTuple_VPackSymbolic@8 _DeeTuple_VTryPack@8=DeeTuple_VTryPack@8 _DeeTuple_VTryPackSymbolic@8=DeeTuple_VTryPackSymbolic@8 + _DeeTypeMRO_PatchClassGetSet@20=DeeTypeMRO_PatchClassGetSet@20 + _DeeTypeMRO_PatchClassMethod@20=DeeTypeMRO_PatchClassMethod@20 + _DeeTypeMRO_PatchGetSet@20=DeeTypeMRO_PatchGetSet@20 + _DeeTypeMRO_PatchMethod@20=DeeTypeMRO_PatchMethod@20 _DeeTypeType_GetOperatorById@8=DeeTypeType_GetOperatorById@8 _DeeTypeType_GetOperatorByIdEx@12=DeeTypeType_GetOperatorByIdEx@12 _DeeTypeType_GetOperatorByName@12=DeeTypeType_GetOperatorByName@12 diff --git a/src/deemon/linker-scripts/link-deemon-msvc-i386-win32.def b/src/deemon/linker-scripts/link-deemon-msvc-i386-win32.def index 4391845e9..0dee6a5ee 100644 --- a/src/deemon/linker-scripts/link-deemon-msvc-i386-win32.def +++ b/src/deemon/linker-scripts/link-deemon-msvc-i386-win32.def @@ -479,7 +479,6 @@ EXPORTS DeeMH_seq_any@16=_DeeMH_seq_any@16 DeeMH_seq_append@12=_DeeMH_seq_append@12 DeeMH_seq_bfind@16=_DeeMH_seq_bfind@16 - DeeMH_seq_blocate@16=_DeeMH_seq_blocate@16 DeeMH_seq_bposition@16=_DeeMH_seq_bposition@16 DeeMH_seq_brange@16=_DeeMH_seq_brange@16 DeeMH_seq_clear@12=_DeeMH_seq_clear@12 @@ -1196,6 +1195,10 @@ EXPORTS DeeTuple_VPackSymbolic@8=_DeeTuple_VPackSymbolic@8 DeeTuple_VTryPack@8=_DeeTuple_VTryPack@8 DeeTuple_VTryPackSymbolic@8=_DeeTuple_VTryPackSymbolic@8 + DeeTypeMRO_PatchClassGetSet@20=_DeeTypeMRO_PatchClassGetSet@20 + DeeTypeMRO_PatchClassMethod@20=_DeeTypeMRO_PatchClassMethod@20 + DeeTypeMRO_PatchGetSet@20=_DeeTypeMRO_PatchGetSet@20 + DeeTypeMRO_PatchMethod@20=_DeeTypeMRO_PatchMethod@20 DeeTypeType_GetOperatorById@8=_DeeTypeType_GetOperatorById@8 DeeTypeType_GetOperatorByIdEx@12=_DeeTypeType_GetOperatorByIdEx@12 DeeTypeType_GetOperatorByName@12=_DeeTypeType_GetOperatorByName@12 diff --git a/src/deemon/objects/seq.c b/src/deemon/objects/seq.c index b22b31434..2fa503a1c 100644 --- a/src/deemon/objects/seq.c +++ b/src/deemon/objects/seq.c @@ -56,7 +56,6 @@ #include "seq/each.h" #include "seq/filter.h" #include "seq/hashfilter.h" -#include "seq/locateall.h" #include "seq/mapped.h" #include "seq/repeat.h" #include "seq/segments.h" @@ -454,26 +453,6 @@ seq_ubfilter(DeeObject *self, size_t argc, DeeObject *const *argv) { return NULL; } -PRIVATE WUNUSED NONNULL((1)) DREF DeeObject *DCALL -seq_locateall(DeeObject *self, size_t argc, DeeObject *const *argv) { - DeeObject *elem, *key = Dee_None; - DREF DeeObject *result; - if (DeeArg_Unpack(argc, argv, "o|o:locateall", &elem, &key)) - goto err; - if (DeeNone_Check(key)) { - result = DeeSeq_LocateAll(self, elem, NULL); - } else { - elem = DeeObject_Call(key, 1, &elem); - if unlikely(!elem) - goto err; - result = DeeSeq_LocateAll(self, elem, key); - Dee_Decref(elem); - } - return result; -err: - return NULL; -} - PRIVATE WUNUSED NONNULL((1)) DREF DeeObject *DCALL seq_map(DeeObject *self, size_t argc, DeeObject *const *argv) { DeeObject *mapper; @@ -1238,8 +1217,8 @@ INTERN_TPCONST struct type_method tpconst seq_methods[] = { /**/ /**/ "key = key ?? x -\\> x;\n" /**/ /**/ "local result = 0;\n" /**/ /**/ "local keyedItem = key(item);\n" - /**/ /**/ "for (local myItem: this) {\n" - /**/ /**/ " if (deemon.equals(keyedItem, key(myItem)))\n" + /**/ /**/ "for (local item: this) {\n" + /**/ /**/ " if (deemon.equals(keyedItem, key(item)))\n" /**/ /**/ " ++result;\n" /**/ /**/ "}\n" /**/ /**/ "return result;" @@ -1262,114 +1241,76 @@ INTERN_TPCONST struct type_method tpconst seq_methods[] = { /**/ "{²}Only when ?A__seqclass__?DType is ?." "}"), TYPE_KWMETHOD(STR_locate, &DeeMH_seq_locate, - "(item,start=!0,end:?Dint=!A!Dint!PSIZE_MAX,key:?DCallable=!N)->\n" - DOC_param_item - DOC_param_key - DOC_throws_ValueError_if_not_found - "Returns the first item equal to @item\n" + "(match:?DCallable,start=!0,end:?Dint=!A!Dint!PSIZE_MAX,def=!N)->?X2?O?Q!Adef]\n" + "Locate and return the first element such that ${match(elem)} " + /**/ "is true, or @def when no such element exists\n" "#T{Requirements|Implementation~" - /**/ "${function locate}|${" - /**/ /**/ "if (key is none) {\n" - /**/ /**/ " return start != 0 || end != int.SIZE_MAX ? this.locate(item, start, end)\n" - /**/ /**/ " : this.locate(item);\n" - /**/ /**/ "} else if (start != 0 || end != int.SIZE_MAX) {\n" - /**/ /**/ " return this.locate(item, start, end, key);\n" - /**/ /**/ "} else if (type(this).__seqclass__ == Sequence) {\n" - /**/ /**/ " return this.locate(item, 0, int.SIZE_MAX, key);\n" - /**/ /**/ "} else {\n" - /**/ /**/ " return this.locate(item, key);\n" - /**/ /**/ "}\n" - /**/ "}&" + /**/ "${function locate}²|${this.locate(item, start, end, def)}&" + /**/ "${function locate}¹³|${this.locate(item, def)}&" /**/ "${operator iter}¹|${" - /**/ /**/ "key = key ?? x -\\> x;\n" - /**/ /**/ "local keyedItem = key(item);\n" - /**/ /**/ "for (local myItem: this) {\n" - /**/ /**/ " if (deemon.equals(keyedItem, key(myItem)))\n" - /**/ /**/ " return myItem;\n" + /**/ /**/ "for (local item: this) {\n" + /**/ /**/ " if (match(item))\n" + /**/ /**/ " return item;\n" /**/ /**/ "}\n" - /**/ /**/ "throw ValueError(...);" + /**/ /**/ "return def;" /**/ "}&" /**/ "${operator size}, ${operator getitem}²|${" - /**/ /**/ "key = key ?? x -\\> x;\n" - /**/ /**/ "local result = Cell();\n" - /**/ /**/ "local keyedItem = key(item);\n" + /**/ /**/ "local result = Cell(def);\n" /**/ /**/ "local ok = Sequence.enumerate(this, (none, value?) -\\> {\n" - /**/ /**/ " if (value is bound) {\n" - /**/ /**/ " if (deemon.equals(keyedItem, key(value))) {\n" - /**/ /**/ " result.value = value;\n" - /**/ /**/ " return true;\n" - /**/ /**/ " }\n" + /**/ /**/ " if (value is bound && match(value)) {\n" + /**/ /**/ " result.value = value;\n" + /**/ /**/ " return true;\n" /**/ /**/ " }\n" /**/ /**/ "}, start, end);\n" - /**/ /**/ "if (ok !is none)\n" - /**/ /**/ " return result.value;\n" - /**/ /**/ "throw ValueError(...);" + /**/ /**/ "return result.value;" /**/ "}" "}" "#L{" /**/ "{¹}Only when @start/@end aren't given or describe the entire sequence|" - /**/ "{²}Only when ?A__seqclass__?DType is ?." + /**/ "{²}Only when ?A__seqclass__?DType is ?.|" + /**/ "{³}Only when ?A__seqclass__?DType is ?DSet or ?DMapping" "}"), TYPE_KWMETHOD(STR_rlocate, &DeeMH_seq_rlocate, - "(item,start=!0,end:?Dint=!A!Dint!PSIZE_MAX,key:?DCallable=!N)->\n" - DOC_param_item - DOC_param_key - DOC_throws_ValueError_if_not_found - "Returns the last item equal to @item\n" + "(match:?DCallable,start=!0,end:?Dint=!A!Dint!PSIZE_MAX,def=!N)->?X2?O?Q!Adef]\n" + "Locate and return the last element such that ${match(elem)} " + /**/ "is true, or @def when no such element exists\n" "#T{Requirements|Implementation~" - /**/ "${function rlocate}|${" - /**/ /**/ "if (key is none) {\n" - /**/ /**/ " return start != 0 || end != int.SIZE_MAX ? this.rlocate(item, start, end)\n" - /**/ /**/ " : this.rlocate(item);\n" - /**/ /**/ "} else if (start != 0 || end != int.SIZE_MAX) {\n" - /**/ /**/ " return this.rlocate(item, start, end, key);\n" - /**/ /**/ "} else if (type(this).__seqclass__ == Sequence) {\n" - /**/ /**/ " return this.rlocate(item, 0, int.SIZE_MAX, key);\n" - /**/ /**/ "} else {\n" - /**/ /**/ " return this.rlocate(item, key);\n" - /**/ /**/ "}\n" - /**/ "}&" + /**/ "${function locate}²|${this.locate(item, start, end, def)}&" + /**/ "${function locate}¹³|${this.locate(item, def)}&" /**/ "${operator iter}¹|${" - /**/ /**/ "key = key ?? x -\\> x;\n" - /**/ /**/ "local keyedItem = key(item);\n" - /**/ /**/ "local result;\n" - /**/ /**/ "for (local myItem: this) {\n" - /**/ /**/ " if (deemon.equals(keyedItem, key(myItem)))\n" - /**/ /**/ " result = myItem;\n" + /**/ /**/ "local result = def;\n" + /**/ /**/ "for (local item: this) {\n" + /**/ /**/ " if (match(item))\n" + /**/ /**/ " result = item;\n" /**/ /**/ "}\n" - /**/ /**/ "if (result is bound)\n" - /**/ /**/ " return result;\n" - /**/ /**/ "throw ValueError(...);" + /**/ /**/ "return result;" /**/ "}&" /**/ "${operator size}, ${operator getitem}²|${" - /**/ /**/ "key = key ?? x -\\> x;\n" /**/ /**/ "local realSize = ##this;\n" /**/ /**/ "if (end > realSize)\n" /**/ /**/ " end = realSize;\n" /**/ /**/ "if (start > end)\n" /**/ /**/ " start = end;\n" - /**/ /**/ "local result;\n" - /**/ /**/ "local keyedItem = key(item);\n" + /**/ /**/ "local result = def;\n" /**/ /**/ "for (local i: [start: end]) {\n" - /**/ /**/ " local myItem;\n" + /**/ /**/ " local item;\n" /**/ /**/ " try {\n" - /**/ /**/ " myItem = this[index];\n" + /**/ /**/ " item = this[index];\n" /**/ /**/ " } catch (UnboundItem) {\n" /**/ /**/ " continue;\n" /**/ /**/ " } catch (IndexError) {\n" /**/ /**/ " break;\n" /**/ /**/ " }\n" - /**/ /**/ " if (deemon.equals(keyedItem, key(myItem)))\n" - /**/ /**/ " result = myItem;\n" + /**/ /**/ " if (match(item))\n" + /**/ /**/ " result = item;\n" /**/ /**/ "}\n" - /**/ /**/ "if (result is bound)\n" - /**/ /**/ " return result;\n" - /**/ /**/ "throw ValueError(...);" + /**/ /**/ "return result;" /**/ "}" "}" "#L{" /**/ "{¹}Only when @start/@end aren't given or describe the entire sequence|" - /**/ "{²}Only when ?A__seqclass__?DType is ?." + /**/ "{²}Only when ?A__seqclass__?DType is ?.|" + /**/ "{³}Only when ?A__seqclass__?DType is ?DSet or ?DMapping" "}"), TYPE_METHOD("filter", &seq_filter, @@ -1406,29 +1347,6 @@ INTERN_TPCONST struct type_method tpconst seq_methods[] = { /**/ "}" "}"), - TYPE_METHOD("locateall", &seq_locateall, - /* TODO: "(item,start:?Dint,end:?Dint,key:?DCallable=!N)->?S?O\n" */ - "(item,key:?DCallable=!N)->?S?O\n" - DOC_param_item - DOC_param_key - "Returns a Sequence of items equal to @item\n" - "${" - /**/ "function locateall(item: Object, key: Callable): Sequence {\n" - /**/ " import Error from deemon;\n" - /**/ " if (key !is none)\n" - /**/ " item = key(item);\n" - /**/ " for (local x: this) {\n" - /**/ " if (key !is none) {\n" - /**/ " if (item == key(x))\n" - /**/ " yield x;\n" - /**/ " } else {\n" - /**/ " if (item == x)\n" - /**/ " yield x;\n" - /**/ " }\n" - /**/ " }\n" - /**/ "}" - "}"), - TYPE_KWMETHOD(STR_contains, &DeeMH_seq_contains, "(item,start=!0,end:?Dint=!A!Dint!PSIZE_MAX,key:?DCallable=!N)->?Dbool\n" DOC_param_item @@ -1586,13 +1504,6 @@ INTERN_TPCONST struct type_method tpconst seq_methods[] = { /**/ "}" "}"), - /* TODO: locatefirst: "(pred:?DCallable,start=!0,end:?Dint=!A!Dint!PSIZE_MAX,def=!N)->?X2?O?Q!Adef]\n" - * "Locate and return the first element such that ${pred(elem)} is true, or @def when no such element exists" - * XXX: Check if it's possible to just replace "Sequence.locate" with this */ - /* TODO: locatelast: "(pred:?DCallable,start=!0,end:?Dint=!A!Dint!PSIZE_MAX,def=!N)->?X2?O?Q!Adef]\n" - * "Locate and return the last element such that ${pred(elem)} is true, or @def when no such element exists" - * XXX: Check if it's possible to just replace "Sequence.rlocate" with this */ - /* TODO: findall: "(item,start=!0,end:?Dint=!A!Dint!PSIZE_MAX,key:?DCallable=!N)->?S?Dint" * > Find not just the first, but all indices of @item */ /* TODO: findallseq(seq: Sequence, start: int = 0, end: int = -1, key: Callable = none): {int...} */ @@ -1830,13 +1741,6 @@ INTERN_TPCONST struct type_method tpconst seq_methods[] = { "NOTE: The returned tuple is allowed to be an ASP, meaning that its elements may " /**/ "be calculated lazily, and are prone to change as the result of @this changing." ""), /* TODO: Requirements|Implementation table */ - TYPE_KWMETHOD(STR_blocate, &DeeMH_seq_blocate, - "(item,start=!0,end:?Dint=!A!Dint!PSIZE_MAX,key:?DCallable=!N,defl?)->\n" - DOC_param_item - DOC_param_key - "#tValueError{The Sequence does not contain an item matching @item}" - "Same as ?#bfind, but return the matching item, rather than its index" - ""), /* TODO: Requirements|Implementation table */ TYPE_KWMETHOD("blocateall", &seq_blocateall, "(item,start=!0,end:?Dint=!A!Dint!PSIZE_MAX,key:?DCallable=!N)->?S?O\n" diff --git a/src/deemon/objects/seq/default-api-methods-attrproxy-impl.c.inl b/src/deemon/objects/seq/default-api-methods-attrproxy-impl.c.inl index e4821aeb2..6507f070c 100644 --- a/src/deemon/objects/seq/default-api-methods-attrproxy-impl.c.inl +++ b/src/deemon/objects/seq/default-api-methods-attrproxy-impl.c.inl @@ -107,13 +107,10 @@ DECL_BEGIN #define LOCAL_DeeSeq_DefaultContainsWithKeyWithCallAttrContainsForSetOrMap LOCAL_DeeSeq_DefaultFooWithCallAttrBar_(ContainsWithKey, Contains, ForSetOrMap) #define LOCAL_DeeSeq_DefaultContainsWithRangeWithCallAttrContains LOCAL_DeeSeq_DefaultFooWithCallAttrBar(ContainsWithRange, Contains) #define LOCAL_DeeSeq_DefaultContainsWithRangeAndKeyWithCallAttrContains LOCAL_DeeSeq_DefaultFooWithCallAttrBar(ContainsWithRangeAndKey, Contains) -#define LOCAL_DeeSeq_DefaultLocateWithCallAttrLocate LOCAL_DeeSeq_DefaultFooWithCallAttrBar(Locate, Locate) -#define LOCAL_DeeSeq_DefaultLocateWithKeyWithCallAttrLocateForSeq LOCAL_DeeSeq_DefaultFooWithCallAttrBar_(LocateWithKey, Locate, ForSeq) -#define LOCAL_DeeSeq_DefaultLocateWithKeyWithCallAttrLocateForSetOrMap LOCAL_DeeSeq_DefaultFooWithCallAttrBar_(LocateWithKey, Locate, ForSetOrMap) +#define LOCAL_DeeSeq_DefaultLocateWithCallAttrLocateForSeq LOCAL_DeeSeq_DefaultFooWithCallAttrBar_(Locate, Locate, ForSeq) +#define LOCAL_DeeSeq_DefaultLocateWithCallAttrLocateForSetOrMap LOCAL_DeeSeq_DefaultFooWithCallAttrBar_(Locate, Locate, ForSetOrMap) #define LOCAL_DeeSeq_DefaultLocateWithRangeWithCallAttrLocate LOCAL_DeeSeq_DefaultFooWithCallAttrBar(LocateWithRange, Locate) -#define LOCAL_DeeSeq_DefaultLocateWithRangeAndKeyWithCallAttrLocate LOCAL_DeeSeq_DefaultFooWithCallAttrBar(LocateWithRangeAndKey, Locate) #define LOCAL_DeeSeq_DefaultRLocateWithRangeWithCallAttrRLocate LOCAL_DeeSeq_DefaultFooWithCallAttrBar(RLocateWithRange, RLocate) -#define LOCAL_DeeSeq_DefaultRLocateWithRangeAndKeyWithCallAttrRLocate LOCAL_DeeSeq_DefaultFooWithCallAttrBar(RLocateWithRangeAndKey, RLocate) #define LOCAL_DeeSeq_DefaultStartsWithWithCallAttrStartsWith LOCAL_DeeSeq_DefaultFooWithCallAttrBar(StartsWith, StartsWith) #define LOCAL_DeeSeq_DefaultStartsWithWithKeyWithCallAttrStartsWithForSeq LOCAL_DeeSeq_DefaultFooWithCallAttrBar_(StartsWithWithKey, StartsWith, ForSeq) #define LOCAL_DeeSeq_DefaultStartsWithWithKeyWithCallAttrStartsWithForSetOrMap LOCAL_DeeSeq_DefaultFooWithCallAttrBar_(StartsWithWithKey, StartsWith, ForSetOrMap) @@ -159,8 +156,6 @@ DECL_BEGIN #define LOCAL_DeeSeq_DefaultBPositionWithKeyWithCallAttrBPosition LOCAL_DeeSeq_DefaultFooWithCallAttrBar(BPositionWithKey, BPosition) #define LOCAL_DeeSeq_DefaultBRangeWithCallAttrBRange LOCAL_DeeSeq_DefaultFooWithCallAttrBar(BRange, BRange) #define LOCAL_DeeSeq_DefaultBRangeWithKeyWithCallAttrBRange LOCAL_DeeSeq_DefaultFooWithCallAttrBar(BRangeWithKey, BRange) -#define LOCAL_DeeSeq_DefaultBLocateWithCallAttrBLocate LOCAL_DeeSeq_DefaultFooWithCallAttrBar(BLocate, BLocate) -#define LOCAL_DeeSeq_DefaultBLocateWithKeyWithCallAttrBLocate LOCAL_DeeSeq_DefaultFooWithCallAttrBar(BLocateWithKey, BLocate) #define LOCAL_DeeSet_DefaultInsertWithCallAttrInsert LOCAL_DeeSet_DefaultFooWithCallAttrBar(Insert, Insert) #define LOCAL_DeeSet_DefaultRemoveWithCallAttrRemove LOCAL_DeeSet_DefaultFooWithCallAttrBar(Remove, Remove) #define LOCAL_DeeSet_DefaultUnifyWithCallAttrUnify LOCAL_DeeSet_DefaultFooWithCallAttrBar(Unify, Unify) @@ -649,47 +644,32 @@ err: return -1; } -INTERN WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL -LOCAL_DeeSeq_DefaultLocateWithCallAttrLocate(DeeObject *self, DeeObject *item) { - return LOCAL_DeeObject_CallAttr(self, tsc_seq_locate_data, &str_locate, 1, &item); -} - INTERN WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL -LOCAL_DeeSeq_DefaultLocateWithKeyWithCallAttrLocateForSeq(DeeObject *self, DeeObject *item, DeeObject *key) { +LOCAL_DeeSeq_DefaultLocateWithCallAttrLocateForSeq(DeeObject *self, DeeObject *match, DeeObject *def) { DeeObject *args[4]; - args[0] = item; + args[0] = match; args[1] = DeeInt_Zero; args[2] = (DeeObject *)&Dee_int_SIZE_MAX; - args[3] = key; + args[3] = def; return LOCAL_DeeObject_CallAttr(self, tsc_seq_locate_data, &str_locate, 4, args); } INTERN WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL -LOCAL_DeeSeq_DefaultLocateWithKeyWithCallAttrLocateForSetOrMap(DeeObject *self, DeeObject *item, DeeObject *key) { - DeeObject *args[4]; - args[0] = item; - args[1] = key; +LOCAL_DeeSeq_DefaultLocateWithCallAttrLocateForSetOrMap(DeeObject *self, DeeObject *match, DeeObject *def) { + DeeObject *args[2]; + args[0] = match; + args[1] = def; return LOCAL_DeeObject_CallAttr(self, tsc_seq_locate_data, &str_locate, 2, args); } -INTERN WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL -LOCAL_DeeSeq_DefaultLocateWithRangeWithCallAttrLocate(DeeObject *self, DeeObject *item, size_t start, size_t end) { - return LOCAL_DeeObject_CallAttrf(self, tsc_seq_locate_data, &str_locate, "o" PCKuSIZ PCKuSIZ, item, start, end); -} - INTERN WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL -LOCAL_DeeSeq_DefaultLocateWithRangeAndKeyWithCallAttrLocate(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key) { - return LOCAL_DeeObject_CallAttrf(self, tsc_seq_locate_data, &str_locate, "o" PCKuSIZ PCKuSIZ "o", item, start, end, key); -} - -INTERN WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL -LOCAL_DeeSeq_DefaultRLocateWithRangeWithCallAttrRLocate(DeeObject *self, DeeObject *item, size_t start, size_t end) { - return LOCAL_DeeObject_CallAttrf(self, tsc_seq_rlocate_data, &str_rlocate, "o" PCKuSIZ PCKuSIZ, item, start, end); +LOCAL_DeeSeq_DefaultLocateWithRangeWithCallAttrLocate(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *def) { + return LOCAL_DeeObject_CallAttrf(self, tsc_seq_locate_data, &str_locate, "o" PCKuSIZ PCKuSIZ "o", item, start, end, def); } INTERN WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL -LOCAL_DeeSeq_DefaultRLocateWithRangeAndKeyWithCallAttrRLocate(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key) { - return LOCAL_DeeObject_CallAttrf(self, tsc_seq_rlocate_data, &str_rlocate, "o" PCKuSIZ PCKuSIZ "o", item, start, end, key); +LOCAL_DeeSeq_DefaultRLocateWithRangeWithCallAttrRLocate(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *def) { + return LOCAL_DeeObject_CallAttrf(self, tsc_seq_rlocate_data, &str_rlocate, "o" PCKuSIZ PCKuSIZ "o", item, start, end, def); } INTERN WUNUSED NONNULL((1, 2)) int DCALL @@ -1324,18 +1304,6 @@ err: return -1; } -INTERN WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL -LOCAL_DeeSeq_DefaultBLocateWithCallAttrBLocate(DeeObject *self, DeeObject *item, - size_t start, size_t end) { - return LOCAL_DeeObject_CallAttrf(self, tsc_seq_blocate_data, &str_blocate, "o" PCKuSIZ PCKuSIZ, item, start, end); -} - -INTERN WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL -LOCAL_DeeSeq_DefaultBLocateWithKeyWithCallAttrBLocate(DeeObject *self, DeeObject *item, - size_t start, size_t end, DeeObject *key) { - return LOCAL_DeeObject_CallAttrf(self, tsc_seq_blocate_data, &str_blocate, "o" PCKuSIZ PCKuSIZ "o", item, start, end, key); -} - /************************************************************************/ @@ -1669,13 +1637,10 @@ LOCAL_DeeMap_DefaultIterValuesWithCallAttrIterValues(DeeObject *self) { #undef LOCAL_DeeSeq_DefaultContainsWithKeyWithCallAttrContainsForSetOrMap #undef LOCAL_DeeSeq_DefaultContainsWithRangeWithCallAttrContains #undef LOCAL_DeeSeq_DefaultContainsWithRangeAndKeyWithCallAttrContains -#undef LOCAL_DeeSeq_DefaultLocateWithCallAttrLocate -#undef LOCAL_DeeSeq_DefaultLocateWithKeyWithCallAttrLocateForSeq -#undef LOCAL_DeeSeq_DefaultLocateWithKeyWithCallAttrLocateForSetOrMap +#undef LOCAL_DeeSeq_DefaultLocateWithCallAttrLocateForSeq +#undef LOCAL_DeeSeq_DefaultLocateWithCallAttrLocateForSetOrMap #undef LOCAL_DeeSeq_DefaultLocateWithRangeWithCallAttrLocate -#undef LOCAL_DeeSeq_DefaultLocateWithRangeAndKeyWithCallAttrLocate #undef LOCAL_DeeSeq_DefaultRLocateWithRangeWithCallAttrRLocate -#undef LOCAL_DeeSeq_DefaultRLocateWithRangeAndKeyWithCallAttrRLocate #undef LOCAL_DeeSeq_DefaultStartsWithWithCallAttrStartsWith #undef LOCAL_DeeSeq_DefaultStartsWithWithKeyWithCallAttrStartsWithForSeq #undef LOCAL_DeeSeq_DefaultStartsWithWithKeyWithCallAttrStartsWithForSetOrMap @@ -1721,8 +1686,6 @@ LOCAL_DeeMap_DefaultIterValuesWithCallAttrIterValues(DeeObject *self) { #undef LOCAL_DeeSeq_DefaultBPositionWithKeyWithCallAttrBPosition #undef LOCAL_DeeSeq_DefaultBRangeWithCallAttrBRange #undef LOCAL_DeeSeq_DefaultBRangeWithKeyWithCallAttrBRange -#undef LOCAL_DeeSeq_DefaultBLocateWithCallAttrBLocate -#undef LOCAL_DeeSeq_DefaultBLocateWithKeyWithCallAttrBLocate #undef LOCAL_DeeSet_DefaultInsertWithCallAttrInsert #undef LOCAL_DeeSet_DefaultRemoveWithCallAttrRemove #undef LOCAL_DeeSet_DefaultUnifyWithCallAttrUnify diff --git a/src/deemon/objects/seq/default-api-methods-bsearch-impl.c.inl b/src/deemon/objects/seq/default-api-methods-bsearch-impl.c.inl index 3a3d1cbd1..77c708181 100644 --- a/src/deemon/objects/seq/default-api-methods-bsearch-impl.c.inl +++ b/src/deemon/objects/seq/default-api-methods-bsearch-impl.c.inl @@ -25,8 +25,6 @@ //#define DEFINE_DeeSeq_DefaultBPositionWithKeyWithSizeAndTryGetItemIndex //#define DEFINE_DeeSeq_DefaultBRangeWithSizeAndTryGetItemIndex #define DEFINE_DeeSeq_DefaultBRangeWithKeyWithSizeAndTryGetItemIndex -//#define DEFINE_DeeSeq_DefaultBLocateWithSizeAndTryGetItemIndex -//#define DEFINE_DeeSeq_DefaultBLocateWithKeyWithSizeAndTryGetItemIndex #endif /* __INTELLISENSE__ */ #if (defined(DEFINE_DeeSeq_DefaultBFindWithSizeAndTryGetItemIndex) + \ @@ -34,9 +32,7 @@ defined(DEFINE_DeeSeq_DefaultBPositionWithSizeAndTryGetItemIndex) + \ defined(DEFINE_DeeSeq_DefaultBPositionWithKeyWithSizeAndTryGetItemIndex) + \ defined(DEFINE_DeeSeq_DefaultBRangeWithSizeAndTryGetItemIndex) + \ - defined(DEFINE_DeeSeq_DefaultBRangeWithKeyWithSizeAndTryGetItemIndex) + \ - defined(DEFINE_DeeSeq_DefaultBLocateWithSizeAndTryGetItemIndex) + \ - defined(DEFINE_DeeSeq_DefaultBLocateWithKeyWithSizeAndTryGetItemIndex)) != 1 + defined(DEFINE_DeeSeq_DefaultBRangeWithKeyWithSizeAndTryGetItemIndex)) != 1 #error "Must #define exactly one of these macros" #endif /* DEFINE_DeeSeq_DefaultB... */ @@ -64,13 +60,6 @@ DECL_BEGIN #define LOCAL_DeeSeq_DefaultBFind DeeSeq_DefaultBRangeWithKeyWithSizeAndTryGetItemIndex #define LOCAL_IS_RANGE #define LOCAL_HAS_KEY -#elif defined(DEFINE_DeeSeq_DefaultBLocateWithSizeAndTryGetItemIndex) -#define LOCAL_DeeSeq_DefaultBFind DeeSeq_DefaultBLocateWithSizeAndTryGetItemIndex -#define LOCAL_IS_LOCATE -#elif defined(DEFINE_DeeSeq_DefaultBLocateWithKeyWithSizeAndTryGetItemIndex) -#define LOCAL_DeeSeq_DefaultBFind DeeSeq_DefaultBLocateWithKeyWithSizeAndTryGetItemIndex -#define LOCAL_IS_LOCATE -#define LOCAL_HAS_KEY #else /* DEFINE_DeeSeq_DefaultB... */ #error "Invalid configuration" #endif /* !DEFINE_DeeSeq_DefaultB... */ @@ -78,9 +67,6 @@ DECL_BEGIN #if defined(LOCAL_IS_FIND) || defined(LOCAL_IS_POSITION) #define LOCAL_return_t size_t #define LOCAL_return_ERR (size_t)Dee_COMPARE_ERR -#elif defined(LOCAL_IS_LOCATE) -#define LOCAL_return_t DREF DeeObject * -#define LOCAL_return_ERR NULL #else /* LOCAL_IS_FIND || LOCAL_IS_POSITION */ #define LOCAL_return_t int #define LOCAL_return_ERR (-1) @@ -115,9 +101,6 @@ LOCAL_DeeSeq_DefaultBFind(DeeObject *self, DeeObject *item, , size_t result_range[2] #endif /* LOCAL_IS_RANGE */ ) { -#if defined(LOCAL_IS_LOCATE) && defined(LOCAL_HAS_KEY) - DeeObject *orig_item = item; -#endif /* LOCAL_IS_LOCATE && LOCAL_HAS_KEY */ struct type_seq *seq = Dee_TYPE(self)->tp_seq; size_t selfsize = (*seq->tp_size)(self); if unlikely(selfsize == (size_t)-1) @@ -146,15 +129,9 @@ LOCAL_DeeSeq_DefaultBFind(DeeObject *self, DeeObject *item, cmp_result = DeeObject_Compare(item, seq_item); #endif /* !LOCAL_HAS_KEY */ -#ifndef LOCAL_IS_LOCATE Dee_Decref(seq_item); -#endif /* !LOCAL_IS_LOCATE */ - if unlikely(cmp_result == Dee_COMPARE_ERR) { -#ifdef LOCAL_IS_LOCATE - Dee_Decref(seq_item); -#endif /* !LOCAL_IS_LOCATE */ + if unlikely(cmp_result == Dee_COMPARE_ERR) goto err_item; - } } if (cmp_result < 0) { end = mid; @@ -172,11 +149,6 @@ LOCAL_DeeSeq_DefaultBFind(DeeObject *self, DeeObject *item, Dee_Decref(item); #endif /* LOCAL_HAS_KEY */ return mid; -#elif defined(LOCAL_IS_LOCATE) -#ifdef LOCAL_HAS_KEY - Dee_Decref(item); -#endif /* LOCAL_HAS_KEY */ - return seq_item; #elif defined(LOCAL_IS_RANGE) size_t result_range_start = mid; size_t result_range_end = mid + 1; @@ -248,9 +220,6 @@ LOCAL_DeeSeq_DefaultBFind(DeeObject *self, DeeObject *item, #error "Invalid configuration" #endif /* !LOCAL_IS_... */ } -#ifdef LOCAL_IS_LOCATE - Dee_Decref(seq_item); -#endif /* !LOCAL_IS_LOCATE */ /* Since this runs in O(log(N)), there's no need to check for interrupts! */ } while (start < end); @@ -266,14 +235,6 @@ LOCAL_DeeSeq_DefaultBFind(DeeObject *self, DeeObject *item, if unlikely(start == (size_t)-1 || start == (size_t)Dee_COMPARE_ERR) goto err_item_overflow; return start; -#elif defined(LOCAL_IS_LOCATE) -#ifdef LOCAL_HAS_KEY - err_item_not_found(self, orig_item); -#else /* LOCAL_HAS_KEY */ - err_item_not_found(self, item); -#endif /* !LOCAL_HAS_KEY */ - goto err; -#define WANT_err #elif defined(LOCAL_IS_RANGE) result_range[0] = start; result_range[1] = end; @@ -305,7 +266,6 @@ err: #undef LOCAL_IS_FIND #undef LOCAL_IS_POSITION #undef LOCAL_IS_RANGE -#undef LOCAL_IS_LOCATE DECL_END @@ -315,5 +275,3 @@ DECL_END #undef DEFINE_DeeSeq_DefaultBPositionWithKeyWithSizeAndTryGetItemIndex #undef DEFINE_DeeSeq_DefaultBRangeWithSizeAndTryGetItemIndex #undef DEFINE_DeeSeq_DefaultBRangeWithKeyWithSizeAndTryGetItemIndex -#undef DEFINE_DeeSeq_DefaultBLocateWithSizeAndTryGetItemIndex -#undef DEFINE_DeeSeq_DefaultBLocateWithKeyWithSizeAndTryGetItemIndex diff --git a/src/deemon/objects/seq/default-api-methods.c b/src/deemon/objects/seq/default-api-methods.c index c54b7b3dd..d4b856753 100644 --- a/src/deemon/objects/seq/default-api-methods.c +++ b/src/deemon/objects/seq/default-api-methods.c @@ -1973,35 +1973,18 @@ DeeSeq_DefaultContainsWithRangeAndKeyWithSeqEnumerateIndex(DeeObject *self, DeeO PRIVATE WUNUSED NONNULL((2)) Dee_ssize_t DCALL seq_locate_foreach_cb(void *arg, DeeObject *item) { - DeeObject *elem_to_locate = *(DeeObject **)arg; - int temp = DeeObject_TryCompareEq(elem_to_locate, item); - if unlikely(temp == Dee_COMPARE_ERR) - return -1; - if (temp == 0) { - Dee_Incref(item); - *(DeeObject **)arg = item; - return -2; - } - return 0; -} - -struct seq_locate_with_key_data { - DeeObject *gslwk_kelem; /* [1..1] Keyed search element. */ - DeeObject *gslwk_key; /* [1..1][in] Search key predicate - * [1..1][out:DREF] Located element. */ -}; - -PRIVATE WUNUSED NONNULL((2)) Dee_ssize_t DCALL -seq_locate_with_key_foreach_cb(void *arg, DeeObject *item) { - int temp; - struct seq_locate_with_key_data *data; - data = (struct seq_locate_with_key_data *)arg; - temp = DeeObject_TryCompareKeyEq(data->gslwk_kelem, item, data->gslwk_key); - if unlikely(temp == Dee_COMPARE_ERR) + int match_result; + DREF DeeObject *match_result_ob; + DeeObject *match = *(DeeObject **)arg; + match_result_ob = DeeObject_Call(match, 1, &item); + if unlikely(!match_result_ob) goto err; - if (temp == 0) { + match_result = DeeObject_BoolInherited(match_result_ob); + if unlikely(match_result < 0) + goto err; + if (match_result) { Dee_Incref(item); - data->gslwk_key = item; + *(DeeObject **)arg = item; return -2; } return 0; @@ -2010,119 +1993,30 @@ seq_locate_with_key_foreach_cb(void *arg, DeeObject *item) { } PRIVATE WUNUSED Dee_ssize_t DCALL -seq_locate_enumerate_cb(void *arg, size_t index, DeeObject *item) { +seq_locate_enumerate_index_cb(void *arg, size_t index, DeeObject *item) { (void)index; if (!item) return 0; return seq_locate_foreach_cb(arg, item); } -PRIVATE WUNUSED Dee_ssize_t DCALL -seq_locate_with_key_enumerate_cb(void *arg, size_t index, DeeObject *item) { - (void)index; - if (!item) - return 0; - return seq_locate_with_key_foreach_cb(arg, item); -} - -INTERN WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL -DeeSeq_DefaultLocateWithSeqFindAndSeqGetItemIndex(DeeObject *self, DeeObject *item) { - return DeeSeq_DefaultLocateWithRangeWithSeqFindAndSeqGetItemIndex(self, item, 0, (size_t)-1); -} - -INTERN WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL -DeeSeq_DefaultLocateWithSeqForeach(DeeObject *self, DeeObject *item) { - Dee_ssize_t foreach_status; - foreach_status = DeeSeq_OperatorForeach(self, &seq_locate_foreach_cb, &item); - if likely(foreach_status == -2) - return item; - if (foreach_status == 0) - err_item_not_found(self, item); - return NULL; -} - INTERN WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL -DeeSeq_DefaultLocateWithKeyWithSeqFindWithKeyAndSeqGetItemIndex(DeeObject *self, DeeObject *item, DeeObject *key) { - return DeeSeq_DefaultLocateWithRangeAndKeyWithSeqFindWithKeyAndSeqGetItemIndex(self, item, 0, (size_t)-1, key); -} - -INTERN WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL -DeeSeq_DefaultLocateWithKeyWithSeqForeach(DeeObject *self, DeeObject *item, DeeObject *key) { - Dee_ssize_t foreach_status; - struct seq_locate_with_key_data data; - data.gslwk_kelem = DeeObject_Call(key, 1, &item); - if unlikely(!data.gslwk_kelem) - goto err; - data.gslwk_key = key; - foreach_status = DeeSeq_OperatorForeach(self, &seq_locate_with_key_foreach_cb, &data); - Dee_Decref(data.gslwk_kelem); - if likely(foreach_status == -2) - return data.gslwk_key; - if (foreach_status == 0) - err_item_not_found(self, item); -err: - return NULL; -} - -INTERN WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL -DeeSeq_DefaultLocateWithRangeWithSeqFindAndSeqGetItemIndex(DeeObject *self, DeeObject *item, - size_t start, size_t end) { - size_t match = DeeSeq_InvokeFind(self, item, start, end); - if unlikely(match == (size_t)Dee_COMPARE_ERR) - goto err; - if unlikely(match == (size_t)-1) - goto err_not_found; - return DeeSeq_OperatorGetItemIndex(self, match); -err_not_found: - err_item_not_found(self, item); -err: - return NULL; -} - -INTERN WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL -DeeSeq_DefaultLocateWithRangeWithSeqEnumerateIndex(DeeObject *self, DeeObject *item, - size_t start, size_t end) { +DeeSeq_DefaultLocateWithSeqForeach(DeeObject *self, DeeObject *match, DeeObject *def) { Dee_ssize_t foreach_status; - foreach_status = DeeSeq_OperatorEnumerateIndex(self, &seq_locate_enumerate_cb, &item, start, end); + foreach_status = DeeSeq_OperatorForeach(self, &seq_locate_foreach_cb, &match); if likely(foreach_status == -2) - return item; - if (foreach_status == 0) - err_item_not_found(self, item); - return NULL; -} - -INTERN WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL -DeeSeq_DefaultLocateWithRangeAndKeyWithSeqFindWithKeyAndSeqGetItemIndex(DeeObject *self, DeeObject *item, - size_t start, size_t end, DeeObject *key) { - size_t match = DeeSeq_InvokeFindWithKey(self, item, start, end, key); - if unlikely(match == (size_t)Dee_COMPARE_ERR) - goto err; - if unlikely(match == (size_t)-1) - goto err_not_found; - return DeeSeq_OperatorGetItemIndex(self, match); -err_not_found: - err_item_not_found(self, item); -err: - return NULL; + return match; + return_reference_(def); } INTERN WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL -DeeSeq_DefaultLocateWithRangeAndKeyWithSeqEnumerateIndex(DeeObject *self, DeeObject *item, - size_t start, size_t end, DeeObject *key) { +DeeSeq_DefaultLocateWithRangeWithSeqEnumerateIndex(DeeObject *self, DeeObject *match, + size_t start, size_t end, DeeObject *def) { Dee_ssize_t foreach_status; - struct seq_locate_with_key_data data; - data.gslwk_kelem = DeeObject_Call(key, 1, &item); - if unlikely(!data.gslwk_kelem) - goto err; - data.gslwk_key = key; - foreach_status = DeeSeq_OperatorEnumerateIndex(self, &seq_locate_with_key_enumerate_cb, &data, start, end); - Dee_Decref(data.gslwk_kelem); + foreach_status = DeeSeq_OperatorEnumerateIndex(self, &seq_locate_enumerate_index_cb, &match, start, end); if likely(foreach_status == -2) - return data.gslwk_key; - if (foreach_status == 0) - err_item_not_found(self, item); -err: - return NULL; + return match; + return_reference_(def); } @@ -2134,161 +2028,60 @@ DeeSeq_DefaultLocateWithRangeAndKeyWithSeqEnumerateIndex(DeeObject *self, DeeObj /* rlocate() */ /************************************************************************/ struct seq_rlocate_with_foreach_data { - DeeObject *gsrlwf_elem; /* [1..1] Element to search for. */ - DREF DeeObject *gsrlwf_result; /* [0..1] Most recent match. */ + DeeObject *gsrlwf_match; /* [1..1] Matching function. */ + DREF DeeObject *gsrlwf_result; /* [1..1] Match result. */ }; PRIVATE WUNUSED Dee_ssize_t DCALL seq_rlocate_with_enumerate_cb(void *arg, size_t index, DeeObject *item) { - int temp; + int match_result; + DREF DeeObject *match_result_ob; struct seq_rlocate_with_foreach_data *data; (void)index; if (!item) return 0; data = (struct seq_rlocate_with_foreach_data *)arg; - temp = DeeObject_TryCompareEq(data->gsrlwf_elem, item); - if unlikely(temp == Dee_COMPARE_ERR) + match_result_ob = DeeObject_Call(data->gsrlwf_match, 1, &item); + if unlikely(!match_result_ob) goto err; - if (temp == 0) { - Dee_Incref(item); - Dee_XDecref(data->gsrlwf_result); - data->gsrlwf_result = item; - } - return 0; -err: - return -1; -} - -struct seq_rlocate_with_key_and_foreach_data { - DeeObject *gsrlwkf_kelem; /* [1..1] Keyed element to search for. */ - DREF DeeObject *gsrlwkf_result; /* [0..1] Most recent match. */ - DeeObject *gsrlwkf_key; /* [1..1] Search key. */ -}; - -PRIVATE WUNUSED Dee_ssize_t DCALL -seq_rlocate_with_key_and_enumerate_cb(void *arg, size_t index, DeeObject *item) { - int temp; - struct seq_rlocate_with_key_and_foreach_data *data; - (void)index; - if (!item) - return 0; - data = (struct seq_rlocate_with_key_and_foreach_data *)arg; - temp = DeeObject_TryCompareKeyEq(data->gsrlwkf_kelem, item, data->gsrlwkf_key); - if unlikely(temp == Dee_COMPARE_ERR) + match_result = DeeObject_BoolInherited(match_result_ob); + if unlikely(match_result < 0) goto err; - if (temp == 0) { + if (match_result) { Dee_Incref(item); - Dee_XDecref(data->gsrlwkf_result); - data->gsrlwkf_result = item; + Dee_Decref(data->gsrlwf_result); + data->gsrlwf_result = item; } return 0; err: return -1; } - -INTERN WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL -DeeSeq_DefaultRLocateWithRangeWithSeqRFindAndSeqGetItemIndex(DeeObject *self, DeeObject *item, - size_t start, size_t end) { - size_t match = DeeSeq_InvokeRFind(self, item, start, end); - if unlikely(match == (size_t)Dee_COMPARE_ERR) - goto err; - if unlikely(match == (size_t)-1) - goto err_not_found; - return DeeSeq_OperatorGetItemIndex(self, match); -err_not_found: - err_item_not_found(self, item); -err: - return NULL; -} - -INTERN WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL -DeeSeq_DefaultRLocateWithRangeWithSeqEnumerateIndexReverse(DeeObject *self, DeeObject *item, - size_t start, size_t end) { - Dee_ssize_t foreach_status; - Dee_mh_seq_enumerate_index_reverse_t op; - op = DeeType_TryRequireSeqEnumerateIndexReverse(Dee_TYPE(self)); - ASSERT(op); - foreach_status = (*op)(self, &seq_locate_enumerate_cb, &item, start, end); - if likely(foreach_status == -2) - return item; - if (foreach_status == 0) - err_item_not_found(self, item); - return NULL; -} - -INTERN WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL -DeeSeq_DefaultRLocateWithRangeWithSeqEnumerateIndex(DeeObject *self, DeeObject *item, - size_t start, size_t end) { - Dee_ssize_t foreach_status; - struct seq_rlocate_with_foreach_data data; - data.gsrlwf_elem = item; - data.gsrlwf_result = NULL; - foreach_status = DeeSeq_OperatorEnumerateIndex(self, &seq_rlocate_with_enumerate_cb, &data, start, end); - if likely(foreach_status == 0) { - if (data.gsrlwf_result) - return data.gsrlwf_result; - err_item_not_found(self, item); - } - return NULL; -} - INTERN WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL -DeeSeq_DefaultRLocateWithRangeAndKeyWithSeqRFindWithKeyAndSeqGetItemIndex(DeeObject *self, DeeObject *item, - size_t start, size_t end, DeeObject *key) { - size_t match = DeeSeq_InvokeRFindWithKey(self, item, start, end, key); - if unlikely(match == (size_t)Dee_COMPARE_ERR) - goto err; - if unlikely(match == (size_t)-1) - goto err_not_found; - return DeeSeq_OperatorGetItemIndex(self, match); -err_not_found: - err_item_not_found(self, item); -err: - return NULL; -} - -INTERN WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL -DeeSeq_DefaultRLocateWithRangeAndKeyWithSeqEnumerateIndexReverse(DeeObject *self, DeeObject *item, - size_t start, size_t end, DeeObject *key) { +DeeSeq_DefaultRLocateWithRangeWithSeqEnumerateIndexReverse(DeeObject *self, DeeObject *match, + size_t start, size_t end, DeeObject *def) { Dee_ssize_t foreach_status; Dee_mh_seq_enumerate_index_reverse_t op; - struct seq_locate_with_key_data data; - data.gslwk_kelem = DeeObject_Call(key, 1, &item); - if unlikely(!data.gslwk_kelem) - goto err; - data.gslwk_key = key; op = DeeType_TryRequireSeqEnumerateIndexReverse(Dee_TYPE(self)); ASSERT(op); - foreach_status = (*op)(self, &seq_locate_with_key_enumerate_cb, &data, start, end); - Dee_Decref(data.gslwk_kelem); + foreach_status = (*op)(self, &seq_locate_enumerate_index_cb, &match, start, end); if likely(foreach_status == -2) - return data.gslwk_key; - if (foreach_status == 0) - err_item_not_found(self, item); -err: - return NULL; + return match; + return_reference_(def); } INTERN WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL -DeeSeq_DefaultRLocateWithRangeAndKeyWithSeqEnumerateIndex(DeeObject *self, DeeObject *item, - size_t start, size_t end, DeeObject *key) { +DeeSeq_DefaultRLocateWithRangeWithSeqEnumerateIndex(DeeObject *self, DeeObject *match, + size_t start, size_t end, DeeObject *def) { Dee_ssize_t foreach_status; - struct seq_rlocate_with_key_and_foreach_data data; - data.gsrlwkf_kelem = DeeObject_Call(key, 1, &item); - if unlikely(!data.gsrlwkf_kelem) - goto err; - data.gsrlwkf_key = key; - data.gsrlwkf_result = NULL; - foreach_status = DeeSeq_OperatorEnumerateIndex(self, &seq_rlocate_with_key_and_enumerate_cb, - &data, start, end); - Dee_Decref(data.gsrlwkf_kelem); - if likely(foreach_status == 0) { - if (data.gsrlwkf_result) - return data.gsrlwkf_result; - err_item_not_found(self, item); - } -err: + struct seq_rlocate_with_foreach_data data; + data.gsrlwf_match = match; + data.gsrlwf_result = def; + Dee_Incref(def); + foreach_status = DeeSeq_OperatorEnumerateIndex(self, &seq_rlocate_with_enumerate_cb, &data, start, end); + if likely(foreach_status == 0) + return data.gsrlwf_result; + Dee_Decref_unlikely(data.gsrlwf_result); return NULL; } @@ -4999,68 +4792,6 @@ DeeSeq_DefaultBRangeWithKeyWithError(DeeObject *self, DeeObject *item, -/************************************************************************/ -/* blocate() */ -/************************************************************************/ - -INTERN WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL -DeeSeq_DefaultBLocateWithSeqBFindAndGetItemIndex(DeeObject *self, DeeObject *item, - size_t start, size_t end) { - size_t index = DeeSeq_InvokeBFind(self, item, start, end); - if unlikely(index == (size_t)Dee_COMPARE_ERR) - goto err; - if unlikely(index == (size_t)-1) - goto err_not_found; - return (*Dee_TYPE(self)->tp_seq->tp_getitem_index)(self, index); -err_not_found: - err_item_not_found(self, item); -err: - return NULL; -} - -INTERN WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL -DeeSeq_DefaultBLocateWithError(DeeObject *self, DeeObject *item, - size_t start, size_t end) { - err_seq_unsupportedf(self, "blocate(%r, %" PRFuSIZ ", %" PRFuSIZ ")", item, start, end); - return NULL; -} - - - - - - -/************************************************************************/ -/* blocate() (with key) */ -/************************************************************************/ - -INTERN WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL -DeeSeq_DefaultBLocateWithKeyWithSeqBFindWithKeyAndGetItemIndex(DeeObject *self, DeeObject *item, - size_t start, size_t end, DeeObject *key) { - size_t index = DeeSeq_InvokeBFindWithKey(self, item, start, end, key); - if unlikely(index == (size_t)Dee_COMPARE_ERR) - goto err; - if unlikely(index == (size_t)-1) - goto err_not_found; - return (*Dee_TYPE(self)->tp_seq->tp_getitem_index)(self, index); -err_not_found: - err_item_not_found(self, item); -err: - return NULL; -} - -INTERN WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL -DeeSeq_DefaultBLocateWithKeyWithError(DeeObject *self, DeeObject *item, - size_t start, size_t end, DeeObject *key) { - err_seq_unsupportedf(self, "blocate(%r, %" PRFuSIZ ", %" PRFuSIZ ", %r)", item, start, end, key); - return NULL; -} - - - - - - @@ -5270,17 +5001,22 @@ DeeSet_DefaultUnifyWithSetInsertAndSeqForeach(DeeObject *self, DeeObject *key) { } INTERN WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL -DeeSet_DefaultUnifyWithSeqLocateAndSeqAppend(DeeObject *self, DeeObject *key) { - DREF DeeObject *result = DeeSeq_InvokeLocate(self, key); - if (result) - return result; - if unlikely(!DeeError_Catch(&DeeError_ValueError)) - goto err; - if unlikely(DeeSeq_InvokeAppend(self, key)) - goto err; - return_reference_(key); -err: +DeeSet_DefaultUnifyWithSeqAppendAndSeqForeach(DeeObject *self, DeeObject *key) { + /* TODO */ + (void)self; + (void)key; + DeeError_NOTIMPLEMENTED(); return NULL; +// DREF DeeObject *result = DeeSeq_InvokeLocate(self, key); +// if (result) +// return result; +// if unlikely(!DeeError_Catch(&DeeError_ValueError)) +// goto err; +// if unlikely(DeeSeq_InvokeAppend(self, key)) +// goto err; +// return_reference_(key); +//err: +// return NULL; } INTERN WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL @@ -7013,35 +6749,28 @@ DeeMH_seq_contains(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObje PUBLIC WUNUSED NONNULL((1)) DREF DeeObject *DCALL DeeMH_seq_locate(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObject *kw) { - DeeObject *item, *key = Dee_None; + DeeObject *match, *def = Dee_None; size_t start = 0, end = (size_t)-1; - if (DeeArg_UnpackKw(argc, argv, kw, kwlist__item_start_end_key, + if (DeeArg_UnpackKw(argc, argv, kw, kwlist__match_start_end_def, "o|" UNPuSIZ UNPuSIZ "o:locate", - &item, &start, &end, &key)) + &match, &start, &end, &def)) goto err; - if (start == 0 && end == (size_t)-1) { - if (DeeNone_Check(key)) - return DeeSeq_InvokeLocate(self, item); - return DeeSeq_InvokeLocateWithKey(self, item, key); - } - if (DeeNone_Check(key)) - return DeeSeq_InvokeLocateWithRange(self, item, start, end); - return DeeSeq_InvokeLocateWithRangeAndKey(self, item, start, end, key); + if (start == 0 && end == (size_t)-1) + return DeeSeq_InvokeLocate(self, match, def); + return DeeSeq_InvokeLocateWithRange(self, match, start, end, def); err: return NULL; } PUBLIC WUNUSED NONNULL((1)) DREF DeeObject *DCALL DeeMH_seq_rlocate(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObject *kw) { - DeeObject *item, *key = Dee_None; + DeeObject *match, *def = Dee_None; size_t start = 0, end = (size_t)-1; - if (DeeArg_UnpackKw(argc, argv, kw, kwlist__item_start_end_key, + if (DeeArg_UnpackKw(argc, argv, kw, kwlist__match_start_end_def, "o|" UNPuSIZ UNPuSIZ "o:rlocate", - &item, &start, &end, &key)) + &match, &start, &end, &def)) goto err; - if (DeeNone_Check(key)) - return DeeSeq_InvokeRLocateWithRange(self, item, start, end); - return DeeSeq_InvokeRLocateWithRangeAndKey(self, item, start, end, key); + return DeeSeq_InvokeRLocateWithRange(self, match, start, end, def); err: return NULL; } @@ -7476,21 +7205,6 @@ DeeMH_seq_brange(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObject return NULL; } -PUBLIC WUNUSED NONNULL((1)) DREF DeeObject *DCALL -DeeMH_seq_blocate(DeeObject *self, size_t argc, DeeObject *const *argv, DeeObject *kw) { - DeeObject *item, *key = Dee_None; - size_t start = 0, end = (size_t)-1; - if (DeeArg_UnpackKw(argc, argv, kw, kwlist__item_start_end_key, - "o|" UNPuSIZ UNPuSIZ "o:blocate", - &item, &start, &end, &key)) - goto err; - return !DeeNone_Check(key) - ? DeeSeq_InvokeBLocateWithKey(self, item, start, end, key) - : DeeSeq_InvokeBLocate(self, item, start, end); -err: - return NULL; -} - /* Default set function pointers (including ones for mutable sets). */ PUBLIC WUNUSED NONNULL((1)) DREF DeeObject *DCALL @@ -7765,8 +7479,8 @@ PRIVATE struct type_method tpconst DeeMH_seq_methods[] = { TYPE_KWMETHOD(STR_sum, &DeeMH_seq_sum, "(start=!0,end:?Dint=!A!Dint!PSIZE_MAX)->?X2?O?N"), TYPE_KWMETHOD(STR_count, &DeeMH_seq_count, "(item,start=!0,end:?Dint=!A!Dint!PSIZE_MAX,key:?DCallable=!N)->?Dint"), TYPE_KWMETHOD(STR_contains, &DeeMH_seq_contains, "(item,start=!0,end:?Dint=!A!Dint!PSIZE_MAX,key:?DCallable=!N)->?Dbool"), - TYPE_KWMETHOD(STR_locate, &DeeMH_seq_locate, "(item,start=!0,end:?Dint=!A!Dint!PSIZE_MAX,key:?DCallable=!N)->"), - TYPE_KWMETHOD(STR_rlocate, &DeeMH_seq_rlocate, "(item,start=!0,end:?Dint=!A!Dint!PSIZE_MAX,key:?DCallable=!N)->"), + TYPE_KWMETHOD(STR_locate, &DeeMH_seq_locate, "(match,start=!0,end:?Dint=!A!Dint!PSIZE_MAX,def=!N)->?X2?O?Q!Adef]"), + TYPE_KWMETHOD(STR_rlocate, &DeeMH_seq_rlocate, "(match,start=!0,end:?Dint=!A!Dint!PSIZE_MAX,def=!N)->?X2?O?Q!Adef]"), TYPE_KWMETHOD(STR_startswith, &DeeMH_seq_startswith, "(item,start=!0,end:?Dint=!A!Dint!PSIZE_MAX,key:?DCallable=!N)->?Dbool"), TYPE_KWMETHOD(STR_endswith, &DeeMH_seq_endswith, "(item,start=!0,end:?Dint=!A!Dint!PSIZE_MAX,key:?DCallable=!N)->?Dbool"), TYPE_KWMETHOD(STR_find, &DeeMH_seq_find, "(item,start=!0,end:?Dint=!A!Dint!PSIZE_MAX,key:?DCallable=!N)->?Dint"), @@ -7795,7 +7509,6 @@ PRIVATE struct type_method tpconst DeeMH_seq_methods[] = { TYPE_KWMETHOD(STR_bfind, &DeeMH_seq_bfind, "(item,start=!0,end:?Dint=!A!Dint!PSIZE_MAX,key:?DCallable=!N)->?Dint"), TYPE_KWMETHOD(STR_bposition, &DeeMH_seq_bposition, "(item,start=!0,end:?Dint=!A!Dint!PSIZE_MAX,key:?DCallable=!N)->?Dint"), TYPE_KWMETHOD(STR_brange, &DeeMH_seq_brange, "(item,start=!0,end:?Dint=!A!Dint!PSIZE_MAX,key:?DCallable=!N)->?X2?Dint?Dint"), - TYPE_KWMETHOD(STR_blocate, &DeeMH_seq_blocate, "(item,start=!0,end:?Dint=!A!Dint!PSIZE_MAX,key:?DCallable=!N)->"), TYPE_METHOD("__bool__", &default_seq___bool__, "->?Dbool"), TYPE_METHOD("__iter__", &default_seq___iter__, "->?DIterator"), TYPE_METHOD("__size__", &default_seq___size__, "->?Dint"), @@ -7976,10 +7689,6 @@ DECL_END #include "default-api-methods-bsearch-impl.c.inl" #define DEFINE_DeeSeq_DefaultBRangeWithKeyWithSizeAndTryGetItemIndex #include "default-api-methods-bsearch-impl.c.inl" -#define DEFINE_DeeSeq_DefaultBLocateWithSizeAndTryGetItemIndex -#include "default-api-methods-bsearch-impl.c.inl" -#define DEFINE_DeeSeq_DefaultBLocateWithKeyWithSizeAndTryGetItemIndex -#include "default-api-methods-bsearch-impl.c.inl" #endif /* !__INTELLISENSE__ */ /* Define implementations of misc. functions */ diff --git a/src/deemon/objects/seq/default-api-require-method-impl.c.inl b/src/deemon/objects/seq/default-api-require-method-impl.c.inl index b364092e3..1a33ebd31 100644 --- a/src/deemon/objects/seq/default-api-require-method-impl.c.inl +++ b/src/deemon/objects/seq/default-api-require-method-impl.c.inl @@ -64,11 +64,8 @@ //#define DEFINE_DeeType_RequireSeqContainsWithRange //#define DEFINE_DeeType_RequireSeqContainsWithRangeAndKey //#define DEFINE_DeeType_RequireSeqLocate -//#define DEFINE_DeeType_RequireSeqLocateWithKey //#define DEFINE_DeeType_RequireSeqLocateWithRange -//#define DEFINE_DeeType_RequireSeqLocateWithRangeAndKey //#define DEFINE_DeeType_RequireSeqRLocateWithRange -//#define DEFINE_DeeType_RequireSeqRLocateWithRangeAndKey //#define DEFINE_DeeType_RequireSeqStartsWith //#define DEFINE_DeeType_RequireSeqStartsWithWithKey //#define DEFINE_DeeType_RequireSeqStartsWithWithRange @@ -111,8 +108,6 @@ //#define DEFINE_DeeType_RequireSeqBPositionWithKey //#define DEFINE_DeeType_RequireSeqBRange //#define DEFINE_DeeType_RequireSeqBRangeWithKey -//#define DEFINE_DeeType_RequireSeqBLocate -//#define DEFINE_DeeType_RequireSeqBLocateWithKey //#define DEFINE_DeeType_RequireSetInsert //#define DEFINE_DeeType_RequireSetRemove //#define DEFINE_DeeType_RequireSetUnify @@ -182,11 +177,8 @@ defined(DEFINE_DeeType_RequireSeqContainsWithRange) + \ defined(DEFINE_DeeType_RequireSeqContainsWithRangeAndKey) + \ defined(DEFINE_DeeType_RequireSeqLocate) + \ - defined(DEFINE_DeeType_RequireSeqLocateWithKey) + \ defined(DEFINE_DeeType_RequireSeqLocateWithRange) + \ - defined(DEFINE_DeeType_RequireSeqLocateWithRangeAndKey) + \ defined(DEFINE_DeeType_RequireSeqRLocateWithRange) + \ - defined(DEFINE_DeeType_RequireSeqRLocateWithRangeAndKey) + \ defined(DEFINE_DeeType_RequireSeqStartsWith) + \ defined(DEFINE_DeeType_RequireSeqStartsWithWithKey) + \ defined(DEFINE_DeeType_RequireSeqStartsWithWithRange) + \ @@ -229,29 +221,27 @@ defined(DEFINE_DeeType_RequireSeqBPositionWithKey) + \ defined(DEFINE_DeeType_RequireSeqBRange) + \ defined(DEFINE_DeeType_RequireSeqBRangeWithKey) + \ - defined(DEFINE_DeeType_RequireSeqBLocate) + \ - defined(DEFINE_DeeType_RequireSeqBLocateWithKey) + \ - defined(DEFINE_DeeType_RequireSetInsert) + \ - defined(DEFINE_DeeType_RequireSetRemove) + \ - defined(DEFINE_DeeType_RequireSetUnify) + \ - defined(DEFINE_DeeType_RequireSetInsertAll) + \ - defined(DEFINE_DeeType_RequireSetRemoveAll) + \ - defined(DEFINE_DeeType_RequireSetPop) + \ - defined(DEFINE_DeeType_RequireSetPopWithDefault) + \ - defined(DEFINE_DeeType_RequireMapSetOld) + \ - defined(DEFINE_DeeType_RequireMapSetOldEx) + \ - defined(DEFINE_DeeType_RequireMapSetNew) + \ - defined(DEFINE_DeeType_RequireMapSetNewEx) + \ - defined(DEFINE_DeeType_RequireMapSetDefault) + \ - defined(DEFINE_DeeType_RequireMapUpdate) + \ - defined(DEFINE_DeeType_RequireMapRemove) + \ - defined(DEFINE_DeeType_RequireMapRemoveKeys) + \ - defined(DEFINE_DeeType_RequireMapPop) + \ - defined(DEFINE_DeeType_RequireMapPopWithDefault) + \ - defined(DEFINE_DeeType_RequireMapPopItem) + \ - defined(DEFINE_DeeType_RequireMapKeys) + \ - defined(DEFINE_DeeType_RequireMapValues) + \ - defined(DEFINE_DeeType_RequireMapIterKeys) + \ + defined(DEFINE_DeeType_RequireSetInsert) + \ + defined(DEFINE_DeeType_RequireSetRemove) + \ + defined(DEFINE_DeeType_RequireSetUnify) + \ + defined(DEFINE_DeeType_RequireSetInsertAll) + \ + defined(DEFINE_DeeType_RequireSetRemoveAll) + \ + defined(DEFINE_DeeType_RequireSetPop) + \ + defined(DEFINE_DeeType_RequireSetPopWithDefault) + \ + defined(DEFINE_DeeType_RequireMapSetOld) + \ + defined(DEFINE_DeeType_RequireMapSetOldEx) + \ + defined(DEFINE_DeeType_RequireMapSetNew) + \ + defined(DEFINE_DeeType_RequireMapSetNewEx) + \ + defined(DEFINE_DeeType_RequireMapSetDefault) + \ + defined(DEFINE_DeeType_RequireMapUpdate) + \ + defined(DEFINE_DeeType_RequireMapRemove) + \ + defined(DEFINE_DeeType_RequireMapRemoveKeys) + \ + defined(DEFINE_DeeType_RequireMapPop) + \ + defined(DEFINE_DeeType_RequireMapPopWithDefault) + \ + defined(DEFINE_DeeType_RequireMapPopItem) + \ + defined(DEFINE_DeeType_RequireMapKeys) + \ + defined(DEFINE_DeeType_RequireMapValues) + \ + defined(DEFINE_DeeType_RequireMapIterKeys) + \ defined(DEFINE_DeeType_RequireMapIterValues)) != 1 #error "Must #define exactly one of these macros" #endif /* DEFINE_DeeType_RequireSeq... */ @@ -545,12 +535,6 @@ DECL_BEGIN #define LOCAL_foo locate #define LOCAL_Foo Locate #define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultLocateWithSeqForeach -#elif defined(DEFINE_DeeType_RequireSeqLocateWithKey) -#define LOCAL_foo locate_with_key -#define LOCAL_Foo LocateWithKey -#define LOCAL_Attr_foo locate -#define LOCAL_Bar Locate -#define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultLocateWithKeyWithSeqForeach #define LOCAL_HAS_FOR_SEQ_SUFFIX #elif defined(DEFINE_DeeType_RequireSeqLocateWithRange) #define LOCAL_foo locate_with_range @@ -559,13 +543,6 @@ DECL_BEGIN #define LOCAL_Bar Locate #define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultLocateWithRangeWithSeqEnumerateIndex #define LOCAL_ATTR_REQUIRED_SEQCLASS Dee_SEQCLASS_SEQ -#elif defined(DEFINE_DeeType_RequireSeqLocateWithRangeAndKey) -#define LOCAL_foo locate_with_range_and_key -#define LOCAL_Foo LocateWithRangeAndKey -#define LOCAL_Attr_foo locate -#define LOCAL_Bar Locate -#define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultLocateWithRangeAndKeyWithSeqEnumerateIndex -#define LOCAL_ATTR_REQUIRED_SEQCLASS Dee_SEQCLASS_SEQ #elif defined(DEFINE_DeeType_RequireSeqRLocateWithRange) #define LOCAL_foo rlocate_with_range #define LOCAL_Foo RLocateWithRange @@ -573,13 +550,6 @@ DECL_BEGIN #define LOCAL_Bar RLocate #define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultRLocateWithRangeWithSeqEnumerateIndex #define LOCAL_ATTR_REQUIRED_SEQCLASS Dee_SEQCLASS_SEQ -#elif defined(DEFINE_DeeType_RequireSeqRLocateWithRangeAndKey) -#define LOCAL_foo rlocate_with_range_and_key -#define LOCAL_Foo RLocateWithRangeAndKey -#define LOCAL_Attr_foo rlocate -#define LOCAL_Bar RLocate -#define LOCAL_DeeSeq_DefaultFooWithError DeeSeq_DefaultRLocateWithRangeAndKeyWithSeqEnumerateIndex -#define LOCAL_ATTR_REQUIRED_SEQCLASS Dee_SEQCLASS_SEQ #elif defined(DEFINE_DeeType_RequireSeqStartsWith) #define LOCAL_foo startswith #define LOCAL_Foo StartsWith @@ -794,16 +764,6 @@ DECL_BEGIN #define LOCAL_Attr_foo brange #define LOCAL_Bar BRange #define LOCAL_ATTR_REQUIRED_SEQCLASS Dee_SEQCLASS_SEQ -#elif defined(DEFINE_DeeType_RequireSeqBLocate) -#define LOCAL_foo blocate -#define LOCAL_Foo BLocate -#define LOCAL_ATTR_REQUIRED_SEQCLASS Dee_SEQCLASS_SEQ -#elif defined(DEFINE_DeeType_RequireSeqBLocateWithKey) -#define LOCAL_foo blocate_with_key -#define LOCAL_Foo BLocateWithKey -#define LOCAL_Attr_foo blocate -#define LOCAL_Bar BLocate -#define LOCAL_ATTR_REQUIRED_SEQCLASS Dee_SEQCLASS_SEQ #elif defined(DEFINE_DeeType_RequireSetInsert) #define LOCAL_foo insert #define LOCAL_Foo Insert @@ -1522,59 +1482,12 @@ LOCAL_DeeType_RequireSeqFoo_private_uncached(DeeTypeObject *orig_type, DeeTypeOb return &DeeSeq_DefaultContainsWithRangeAndKeyWithSeqFindWithKey; } #elif defined(DEFINE_DeeType_RequireSeqLocate) - if (seqclass == Dee_SEQCLASS_SEQ && DeeType_HasOperator(orig_type, OPERATOR_GETITEM)) { - Dee_mh_seq_find_t mh_seq_find; - mh_seq_find = DeeType_RequireSeqFind_private_uncached(orig_type, self); - if (mh_seq_find != NULL && - mh_seq_find != &DeeSeq_DefaultFindWithSeqEnumerateIndex) - return &DeeSeq_DefaultLocateWithSeqFindAndSeqGetItemIndex; - } -#elif defined(DEFINE_DeeType_RequireSeqLocateWithKey) - if (seqclass == Dee_SEQCLASS_SEQ && DeeType_HasOperator(orig_type, OPERATOR_GETITEM)) { - Dee_mh_seq_find_with_key_t mh_seq_find_with_key; - mh_seq_find_with_key = DeeType_RequireSeqFindWithKey_private_uncached(orig_type, self); - if (mh_seq_find_with_key != NULL && - mh_seq_find_with_key != &DeeSeq_DefaultFindWithKeyWithSeqEnumerateIndex) - return &DeeSeq_DefaultLocateWithKeyWithSeqFindWithKeyAndSeqGetItemIndex; - } + /* ... */ #elif defined(DEFINE_DeeType_RequireSeqLocateWithRange) - if (seqclass == Dee_SEQCLASS_SEQ && DeeType_HasOperator(orig_type, OPERATOR_GETITEM)) { - Dee_mh_seq_find_t mh_seq_find; - mh_seq_find = DeeType_RequireSeqFind_private_uncached(orig_type, self); - if (mh_seq_find != NULL && - mh_seq_find != &DeeSeq_DefaultFindWithSeqEnumerateIndex) - return &DeeSeq_DefaultLocateWithRangeWithSeqFindAndSeqGetItemIndex; - } -#elif defined(DEFINE_DeeType_RequireSeqLocateWithRangeAndKey) - if (seqclass == Dee_SEQCLASS_SEQ && DeeType_HasOperator(orig_type, OPERATOR_GETITEM)) { - Dee_mh_seq_find_with_key_t mh_seq_find_with_key; - mh_seq_find_with_key = DeeType_RequireSeqFindWithKey_private_uncached(orig_type, self); - if (mh_seq_find_with_key != NULL && - mh_seq_find_with_key != &DeeSeq_DefaultFindWithKeyWithSeqEnumerateIndex) - return &DeeSeq_DefaultLocateWithRangeAndKeyWithSeqFindWithKeyAndSeqGetItemIndex; - } + /* ... */ #elif defined(DEFINE_DeeType_RequireSeqRLocateWithRange) - if (seqclass == Dee_SEQCLASS_SEQ && DeeType_HasOperator(orig_type, OPERATOR_GETITEM)) { - Dee_mh_seq_rfind_t mh_seq_rfind; - mh_seq_rfind = DeeType_RequireSeqRFind_private_uncached(orig_type, self); - if (mh_seq_rfind != NULL && - mh_seq_rfind != &DeeSeq_DefaultRFindWithSeqEnumerateIndex && - mh_seq_rfind != &DeeSeq_DefaultRFindWithSeqEnumerateIndexReverse) - return &DeeSeq_DefaultRLocateWithRangeWithSeqRFindAndSeqGetItemIndex; - } if (DeeType_HasPrivateSeqEnumerateIndexReverse(orig_type, self)) return &DeeSeq_DefaultRLocateWithRangeWithSeqEnumerateIndexReverse; -#elif defined(DEFINE_DeeType_RequireSeqRLocateWithRangeAndKey) - if (seqclass == Dee_SEQCLASS_SEQ && DeeType_HasOperator(orig_type, OPERATOR_GETITEM)) { - Dee_mh_seq_rfind_with_key_t mh_seq_rfind_with_key; - mh_seq_rfind_with_key = DeeType_RequireSeqFindWithKey_private_uncached(orig_type, self); - if (mh_seq_rfind_with_key != NULL && - mh_seq_rfind_with_key != &DeeSeq_DefaultRFindWithKeyWithSeqEnumerateIndex && - mh_seq_rfind_with_key != &DeeSeq_DefaultRFindWithKeyWithSeqEnumerateIndexReverse) - return &DeeSeq_DefaultRLocateWithRangeAndKeyWithSeqRFindWithKeyAndSeqGetItemIndex; - } - if (DeeType_HasPrivateSeqEnumerateIndexReverse(orig_type, self)) - return &DeeSeq_DefaultRLocateWithRangeAndKeyWithSeqEnumerateIndexReverse; #elif defined(DEFINE_DeeType_RequireSeqStartsWith) /* ... */ #elif defined(DEFINE_DeeType_RequireSeqStartsWithWithKey) @@ -1830,7 +1743,7 @@ LOCAL_DeeType_RequireSeqFoo_private_uncached(DeeTypeObject *orig_type, DeeTypeOb /* TODO: * >> local true_item; * >> try { - * >> true_item = Sequence.locate(this, item, start, end, key); + * >> true_item = Sequence.locate(this, item, start, end, key); // FIXME: "locate" was changed * >> } catch (ValueError) { * >> return false; * >> } @@ -1845,7 +1758,7 @@ LOCAL_DeeType_RequireSeqFoo_private_uncached(DeeTypeObject *orig_type, DeeTypeOb * >> } * >> local true_item; * >> try { - * >> true_item = Sequence.locate(this, item, start, end, key); + * >> true_item = Sequence.locate(this, item, start, end, key); // FIXME: "locate" was changed * >> } catch (ValueError) { * >> return false; * >> } @@ -2119,28 +2032,6 @@ LOCAL_DeeType_RequireSeqFoo_private_uncached(DeeTypeObject *orig_type, DeeTypeOb DeeType_HasOperator(orig_type, OPERATOR_SIZE)) return &DeeSeq_DefaultBRangeWithKeyWithSizeAndTryGetItemIndex; } -#elif defined(DEFINE_DeeType_RequireSeqBLocate) - { - Dee_mh_seq_bfind_t tsc_seq_bfind; - tsc_seq_bfind = DeeType_RequireSeqBFind_private_uncached(orig_type, self); - if (tsc_seq_bfind != NULL && - tsc_seq_bfind != &DeeSeq_DefaultBFindWithError) { - if (tsc_seq_bfind == &DeeSeq_DefaultBFindWithSizeAndTryGetItemIndex) - return &DeeSeq_DefaultBLocateWithSizeAndTryGetItemIndex; - return &DeeSeq_DefaultBLocateWithSeqBFindAndGetItemIndex; - } - } -#elif defined(DEFINE_DeeType_RequireSeqBLocateWithKey) - { - Dee_mh_seq_bfind_with_key_t tsc_seq_bfind_with_key; - tsc_seq_bfind_with_key = DeeType_RequireSeqBFindWithKey_private_uncached(orig_type, self); - if (tsc_seq_bfind_with_key != NULL && - tsc_seq_bfind_with_key != &DeeSeq_DefaultBFindWithKeyWithError) { - if (tsc_seq_bfind_with_key == &DeeSeq_DefaultBFindWithKeyWithSizeAndTryGetItemIndex) - return &DeeSeq_DefaultBLocateWithKeyWithSizeAndTryGetItemIndex; - return &DeeSeq_DefaultBLocateWithKeyWithSeqBFindWithKeyAndGetItemIndex; - } - } #elif defined(DEFINE_DeeType_RequireSetInsert) if (seqclass == Dee_SEQCLASS_SET) { /* use insertall and "operator #" before/after */ @@ -2212,7 +2103,7 @@ LOCAL_DeeType_RequireSeqFoo_private_uncached(DeeTypeObject *orig_type, DeeTypeOb tsc_append = DeeType_RequireSeqAppend_private_uncached(orig_type, self); if (tsc_append != NULL && tsc_append != &DeeSeq_DefaultAppendWithError) - return &DeeSet_DefaultUnifyWithSeqLocateAndSeqAppend; + return &DeeSet_DefaultUnifyWithSeqAppendAndSeqForeach; } #elif defined(DEFINE_DeeType_RequireSetInsertAll) if (seqclass == Dee_SEQCLASS_SET) { @@ -2652,11 +2543,8 @@ DECL_END #undef DEFINE_DeeType_RequireSeqContainsWithRange #undef DEFINE_DeeType_RequireSeqContainsWithRangeAndKey #undef DEFINE_DeeType_RequireSeqLocate -#undef DEFINE_DeeType_RequireSeqLocateWithKey #undef DEFINE_DeeType_RequireSeqLocateWithRange -#undef DEFINE_DeeType_RequireSeqLocateWithRangeAndKey #undef DEFINE_DeeType_RequireSeqRLocateWithRange -#undef DEFINE_DeeType_RequireSeqRLocateWithRangeAndKey #undef DEFINE_DeeType_RequireSeqStartsWith #undef DEFINE_DeeType_RequireSeqStartsWithWithKey #undef DEFINE_DeeType_RequireSeqStartsWithWithRange @@ -2699,8 +2587,6 @@ DECL_END #undef DEFINE_DeeType_RequireSeqBPositionWithKey #undef DEFINE_DeeType_RequireSeqBRange #undef DEFINE_DeeType_RequireSeqBRangeWithKey -#undef DEFINE_DeeType_RequireSeqBLocate -#undef DEFINE_DeeType_RequireSeqBLocateWithKey #undef DEFINE_DeeType_RequireSetInsert #undef DEFINE_DeeType_RequireSetRemove #undef DEFINE_DeeType_RequireSetUnify diff --git a/src/deemon/objects/seq/default-api.c b/src/deemon/objects/seq/default-api.c index 652b82865..5ecb0dd73 100644 --- a/src/deemon/objects/seq/default-api.c +++ b/src/deemon/objects/seq/default-api.c @@ -89,11 +89,8 @@ PRIVATE ATTR_PURE WUNUSED NONNULL((1, 2)) Dee_mh_seq_contains_with_key_t DCALL D PRIVATE ATTR_PURE WUNUSED NONNULL((1, 2)) Dee_mh_seq_contains_with_range_t DCALL DeeType_RequireSeqContainsWithRange_private_uncached(DeeTypeObject *orig_type, DeeTypeObject *self); PRIVATE ATTR_PURE WUNUSED NONNULL((1, 2)) Dee_mh_seq_contains_with_range_and_key_t DCALL DeeType_RequireSeqContainsWithRangeAndKey_private_uncached(DeeTypeObject *orig_type, DeeTypeObject *self); PRIVATE ATTR_PURE WUNUSED NONNULL((1, 2)) Dee_mh_seq_locate_t DCALL DeeType_RequireSeqLocate_private_uncached(DeeTypeObject *orig_type, DeeTypeObject *self); -PRIVATE ATTR_PURE WUNUSED NONNULL((1, 2)) Dee_mh_seq_locate_with_key_t DCALL DeeType_RequireSeqLocateWithKey_private_uncached(DeeTypeObject *orig_type, DeeTypeObject *self); PRIVATE ATTR_PURE WUNUSED NONNULL((1, 2)) Dee_mh_seq_locate_with_range_t DCALL DeeType_RequireSeqLocateWithRange_private_uncached(DeeTypeObject *orig_type, DeeTypeObject *self); -PRIVATE ATTR_PURE WUNUSED NONNULL((1, 2)) Dee_mh_seq_locate_with_range_and_key_t DCALL DeeType_RequireSeqLocateWithRangeAndKey_private_uncached(DeeTypeObject *orig_type, DeeTypeObject *self); PRIVATE ATTR_PURE WUNUSED NONNULL((1, 2)) Dee_mh_seq_rlocate_with_range_t DCALL DeeType_RequireSeqRLocateWithRange_private_uncached(DeeTypeObject *orig_type, DeeTypeObject *self); -PRIVATE ATTR_PURE WUNUSED NONNULL((1, 2)) Dee_mh_seq_rlocate_with_range_and_key_t DCALL DeeType_RequireSeqRLocateWithRangeAndKey_private_uncached(DeeTypeObject *orig_type, DeeTypeObject *self); PRIVATE ATTR_PURE WUNUSED NONNULL((1, 2)) Dee_mh_seq_startswith_t DCALL DeeType_RequireSeqStartsWith_private_uncached(DeeTypeObject *orig_type, DeeTypeObject *self); PRIVATE ATTR_PURE WUNUSED NONNULL((1, 2)) Dee_mh_seq_startswith_with_key_t DCALL DeeType_RequireSeqStartsWithWithKey_private_uncached(DeeTypeObject *orig_type, DeeTypeObject *self); PRIVATE ATTR_PURE WUNUSED NONNULL((1, 2)) Dee_mh_seq_startswith_with_range_t DCALL DeeType_RequireSeqStartsWithWithRange_private_uncached(DeeTypeObject *orig_type, DeeTypeObject *self); @@ -136,8 +133,6 @@ PRIVATE ATTR_PURE WUNUSED NONNULL((1, 2)) Dee_mh_seq_bposition_t DCALL DeeType_R PRIVATE ATTR_PURE WUNUSED NONNULL((1, 2)) Dee_mh_seq_bposition_with_key_t DCALL DeeType_RequireSeqBPositionWithKey_private_uncached(DeeTypeObject *orig_type, DeeTypeObject *self); PRIVATE ATTR_PURE WUNUSED NONNULL((1, 2)) Dee_mh_seq_brange_t DCALL DeeType_RequireSeqBRange_private_uncached(DeeTypeObject *orig_type, DeeTypeObject *self); PRIVATE ATTR_PURE WUNUSED NONNULL((1, 2)) Dee_mh_seq_brange_with_key_t DCALL DeeType_RequireSeqBRangeWithKey_private_uncached(DeeTypeObject *orig_type, DeeTypeObject *self); -PRIVATE ATTR_PURE WUNUSED NONNULL((1, 2)) Dee_mh_seq_blocate_t DCALL DeeType_RequireSeqBLocate_private_uncached(DeeTypeObject *orig_type, DeeTypeObject *self); -PRIVATE ATTR_PURE WUNUSED NONNULL((1, 2)) Dee_mh_seq_blocate_with_key_t DCALL DeeType_RequireSeqBLocateWithKey_private_uncached(DeeTypeObject *orig_type, DeeTypeObject *self); PRIVATE ATTR_PURE WUNUSED NONNULL((1, 2)) Dee_mh_set_insert_t DCALL DeeType_RequireSetInsert_private_uncached(DeeTypeObject *orig_type, DeeTypeObject *self); PRIVATE ATTR_PURE WUNUSED NONNULL((1, 2)) Dee_mh_set_remove_t DCALL DeeType_RequireSetRemove_private_uncached(DeeTypeObject *orig_type, DeeTypeObject *self); PRIVATE ATTR_PURE WUNUSED NONNULL((1, 2)) Dee_mh_set_unify_t DCALL DeeType_RequireSetUnify_private_uncached(DeeTypeObject *orig_type, DeeTypeObject *self); @@ -204,11 +199,8 @@ PRIVATE ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_seq_contains_with_ PRIVATE ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_seq_contains_with_range_t DCALL DeeType_RequireSeqContainsWithRange_uncached(DeeTypeObject *__restrict self); PRIVATE ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_seq_contains_with_range_and_key_t DCALL DeeType_RequireSeqContainsWithRangeAndKey_uncached(DeeTypeObject *__restrict self); PRIVATE ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_seq_locate_t DCALL DeeType_RequireSeqLocate_uncached(DeeTypeObject *__restrict self); -PRIVATE ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_seq_locate_with_key_t DCALL DeeType_RequireSeqLocateWithKey_uncached(DeeTypeObject *__restrict self); PRIVATE ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_seq_locate_with_range_t DCALL DeeType_RequireSeqLocateWithRange_uncached(DeeTypeObject *__restrict self); -PRIVATE ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_seq_locate_with_range_and_key_t DCALL DeeType_RequireSeqLocateWithRangeAndKey_uncached(DeeTypeObject *__restrict self); PRIVATE ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_seq_rlocate_with_range_t DCALL DeeType_RequireSeqRLocateWithRange_uncached(DeeTypeObject *__restrict self); -PRIVATE ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_seq_rlocate_with_range_and_key_t DCALL DeeType_RequireSeqRLocateWithRangeAndKey_uncached(DeeTypeObject *__restrict self); PRIVATE ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_seq_startswith_t DCALL DeeType_RequireSeqStartsWith_uncached(DeeTypeObject *__restrict self); PRIVATE ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_seq_startswith_with_key_t DCALL DeeType_RequireSeqStartsWithWithKey_uncached(DeeTypeObject *__restrict self); PRIVATE ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_seq_startswith_with_range_t DCALL DeeType_RequireSeqStartsWithWithRange_uncached(DeeTypeObject *__restrict self); @@ -251,8 +243,6 @@ PRIVATE ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_seq_bposition_t DC PRIVATE ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_seq_bposition_with_key_t DCALL DeeType_RequireSeqBPositionWithKey_uncached(DeeTypeObject *__restrict self); PRIVATE ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_seq_brange_t DCALL DeeType_RequireSeqBRange_uncached(DeeTypeObject *__restrict self); PRIVATE ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_seq_brange_with_key_t DCALL DeeType_RequireSeqBRangeWithKey_uncached(DeeTypeObject *__restrict self); -PRIVATE ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_seq_blocate_t DCALL DeeType_RequireSeqBLocate_uncached(DeeTypeObject *__restrict self); -PRIVATE ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_seq_blocate_with_key_t DCALL DeeType_RequireSeqBLocateWithKey_uncached(DeeTypeObject *__restrict self); PRIVATE ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_set_insert_t DCALL DeeType_RequireSetInsert_uncached(DeeTypeObject *__restrict self); PRIVATE ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_set_remove_t DCALL DeeType_RequireSetRemove_uncached(DeeTypeObject *__restrict self); PRIVATE ATTR_PURE ATTR_RETNONNULL WUNUSED NONNULL((1)) Dee_mh_set_unify_t DCALL DeeType_RequireSetUnify_uncached(DeeTypeObject *__restrict self); @@ -454,14 +444,11 @@ Dee_type_seq_cache_destroy(struct Dee_type_seq_cache *__restrict self) { self->tsc_seq_contains_with_range == &DeeSeq_DefaultContainsWithRangeWithCallContainsDataFunction || self->tsc_seq_contains_with_range_and_key == &DeeSeq_DefaultContainsWithRangeAndKeyWithCallContainsDataFunction) Dee_tsc_uslot_fini_function(&self->tsc_seq_contains_data); - if (self->tsc_seq_locate == &DeeSeq_DefaultLocateWithCallLocateDataFunction || - self->tsc_seq_locate_with_key == &DeeSeq_DefaultLocateWithKeyWithCallLocateDataFunctionForSeq || - self->tsc_seq_locate_with_key == &DeeSeq_DefaultLocateWithKeyWithCallLocateDataFunctionForSetOrMap || - self->tsc_seq_locate_with_range == &DeeSeq_DefaultLocateWithRangeWithCallLocateDataFunction || - self->tsc_seq_locate_with_range_and_key == &DeeSeq_DefaultLocateWithRangeAndKeyWithCallLocateDataFunction) + if (self->tsc_seq_locate == &DeeSeq_DefaultLocateWithCallLocateDataFunctionForSeq || + self->tsc_seq_locate == &DeeSeq_DefaultLocateWithCallLocateDataFunctionForSetOrMap || + self->tsc_seq_locate_with_range == &DeeSeq_DefaultLocateWithRangeWithCallLocateDataFunction) Dee_tsc_uslot_fini_function(&self->tsc_seq_locate_data); - if (self->tsc_seq_rlocate_with_range == &DeeSeq_DefaultRLocateWithRangeWithCallRLocateDataFunction || - self->tsc_seq_rlocate_with_range_and_key == &DeeSeq_DefaultRLocateWithRangeAndKeyWithCallRLocateDataFunction) + if (self->tsc_seq_rlocate_with_range == &DeeSeq_DefaultRLocateWithRangeWithCallRLocateDataFunction) Dee_tsc_uslot_fini_function(&self->tsc_seq_rlocate_data); if (self->tsc_seq_startswith == &DeeSeq_DefaultStartsWithWithCallStartsWithDataFunction || self->tsc_seq_startswith_with_key == &DeeSeq_DefaultStartsWithWithKeyWithCallStartsWithDataFunctionForSeq || @@ -1195,16 +1182,10 @@ DECL_END #include "default-api-require-method-impl.c.inl" #define DEFINE_DeeType_RequireSeqLocate #include "default-api-require-method-impl.c.inl" -#define DEFINE_DeeType_RequireSeqLocateWithKey -#include "default-api-require-method-impl.c.inl" #define DEFINE_DeeType_RequireSeqLocateWithRange #include "default-api-require-method-impl.c.inl" -#define DEFINE_DeeType_RequireSeqLocateWithRangeAndKey -#include "default-api-require-method-impl.c.inl" #define DEFINE_DeeType_RequireSeqRLocateWithRange #include "default-api-require-method-impl.c.inl" -#define DEFINE_DeeType_RequireSeqRLocateWithRangeAndKey -#include "default-api-require-method-impl.c.inl" #define DEFINE_DeeType_RequireSeqStartsWith #include "default-api-require-method-impl.c.inl" #define DEFINE_DeeType_RequireSeqStartsWithWithKey @@ -1289,10 +1270,6 @@ DECL_END #include "default-api-require-method-impl.c.inl" #define DEFINE_DeeType_RequireSeqBRangeWithKey #include "default-api-require-method-impl.c.inl" -#define DEFINE_DeeType_RequireSeqBLocate -#include "default-api-require-method-impl.c.inl" -#define DEFINE_DeeType_RequireSeqBLocateWithKey -#include "default-api-require-method-impl.c.inl" #define DEFINE_DeeType_RequireSetInsert #include "default-api-require-method-impl.c.inl" #define DEFINE_DeeType_RequireSetRemove diff --git a/src/deemon/objects/seq/default-api.h b/src/deemon/objects/seq/default-api.h index 3d6858d6f..caa9bdbe2 100644 --- a/src/deemon/objects/seq/default-api.h +++ b/src/deemon/objects/seq/default-api.h @@ -144,7 +144,6 @@ struct Dee_type_seq_cache { union Dee_tsc_uslot tsc_seq_bfind_data; union Dee_tsc_uslot tsc_seq_bposition_data; union Dee_tsc_uslot tsc_seq_brange_data; - union Dee_tsc_uslot tsc_seq_blocate_data; union Dee_tsc_uslot tsc_set_insert_data; union Dee_tsc_uslot tsc_set_remove_data; union Dee_tsc_uslot tsc_set_unify_data; @@ -722,12 +721,9 @@ INTDEF struct type_math DeeMap_OperatorMath; #define DeeSeq_InvokeContainsWithKey(self, item, key) (*DeeType_RequireSeqContainsWithKey(Dee_TYPE(self)))(self, item, key) #define DeeSeq_InvokeContainsWithRange(self, item, start, end) (*DeeType_RequireSeqContainsWithRange(Dee_TYPE(self)))(self, item, start, end) #define DeeSeq_InvokeContainsWithRangeAndKey(self, item, start, end, key) (*DeeType_RequireSeqContainsWithRangeAndKey(Dee_TYPE(self)))(self, item, start, end, key) -#define DeeSeq_InvokeLocate(self, item) (*DeeType_RequireSeqLocate(Dee_TYPE(self)))(self, item) -#define DeeSeq_InvokeLocateWithKey(self, item, key) (*DeeType_RequireSeqLocateWithKey(Dee_TYPE(self)))(self, item, key) -#define DeeSeq_InvokeLocateWithRange(self, item, start, end) (*DeeType_RequireSeqLocateWithRange(Dee_TYPE(self)))(self, item, start, end) -#define DeeSeq_InvokeLocateWithRangeAndKey(self, item, start, end, key) (*DeeType_RequireSeqLocateWithRangeAndKey(Dee_TYPE(self)))(self, item, start, end, key) -#define DeeSeq_InvokeRLocateWithRange(self, item, start, end) (*DeeType_RequireSeqRLocateWithRange(Dee_TYPE(self)))(self, item, start, end) -#define DeeSeq_InvokeRLocateWithRangeAndKey(self, item, start, end, key) (*DeeType_RequireSeqRLocateWithRangeAndKey(Dee_TYPE(self)))(self, item, start, end, key) +#define DeeSeq_InvokeLocate(self, match, def) (*DeeType_RequireSeqLocate(Dee_TYPE(self)))(self, match, def) +#define DeeSeq_InvokeLocateWithRange(self, match, start, end, def) (*DeeType_RequireSeqLocateWithRange(Dee_TYPE(self)))(self, match, start, end, def) +#define DeeSeq_InvokeRLocateWithRange(self, match, start, end, def) (*DeeType_RequireSeqRLocateWithRange(Dee_TYPE(self)))(self, match, start, end, def) #define DeeSeq_InvokeStartsWith(self, item) (*DeeType_RequireSeqStartsWith(Dee_TYPE(self)))(self, item) #define DeeSeq_InvokeStartsWithWithKey(self, item, key) (*DeeType_RequireSeqStartsWithWithKey(Dee_TYPE(self)))(self, item, key) #define DeeSeq_InvokeStartsWithWithRange(self, item, start, end) (*DeeType_RequireSeqStartsWithWithRange(Dee_TYPE(self)))(self, item, start, end) @@ -770,8 +766,6 @@ INTDEF struct type_math DeeMap_OperatorMath; #define DeeSeq_InvokeBPositionWithKey(self, item, start, end, key) (*DeeType_RequireSeqBPositionWithKey(Dee_TYPE(self)))(self, item, start, end, key) #define DeeSeq_InvokeBRange(self, item, start, end, result_range) (*DeeType_RequireSeqBRange(Dee_TYPE(self)))(self, item, start, end, result_range) #define DeeSeq_InvokeBRangeWithKey(self, item, start, end, key, result_range) (*DeeType_RequireSeqBRangeWithKey(Dee_TYPE(self)))(self, item, start, end, key, result_range) -#define DeeSeq_InvokeBLocate(self, item, start, end) (*DeeType_RequireSeqBLocate(Dee_TYPE(self)))(self, item, start, end) -#define DeeSeq_InvokeBLocateWithKey(self, item, start, end, key) (*DeeType_RequireSeqBLocateWithKey(Dee_TYPE(self)))(self, item, start, end, key) /* Set functions */ #define DeeSet_InvokeInsert(self, key) (*DeeType_RequireSetInsert(Dee_TYPE(self)))(self, key) @@ -1533,49 +1527,27 @@ INTDEF WUNUSED NONNULL((1, 2, 5)) int DCALL DeeSeq_DefaultContainsWithRangeAndKe INTDEF WUNUSED NONNULL((1, 2, 5)) int DCALL DeeSeq_DefaultContainsWithRangeAndKeyWithSeqFindWithKey(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); INTDEF WUNUSED NONNULL((1, 2, 5)) int DCALL DeeSeq_DefaultContainsWithRangeAndKeyWithSeqEnumerateIndex(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); -INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithCallAttrLocate(DeeObject *self, DeeObject *item); -INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithCallLocateDataFunction(DeeObject *self, DeeObject *item); -INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithCallLocateDataMethod(DeeObject *self, DeeObject *item); -INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithCallLocateDataKwMethod(DeeObject *self, DeeObject *item); -INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithSeqFindAndSeqGetItemIndex(DeeObject *self, DeeObject *item); -INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithSeqForeach(DeeObject *self, DeeObject *item); -INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithKeyWithCallAttrLocateForSeq(DeeObject *self, DeeObject *item, DeeObject *key); -INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithKeyWithCallLocateDataFunctionForSeq(DeeObject *self, DeeObject *item, DeeObject *key); -INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithKeyWithCallLocateDataMethodForSeq(DeeObject *self, DeeObject *item, DeeObject *key); -INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithKeyWithCallLocateDataKwMethodForSeq(DeeObject *self, DeeObject *item, DeeObject *key); -INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithKeyWithCallAttrLocateForSetOrMap(DeeObject *self, DeeObject *item, DeeObject *key); -INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithKeyWithCallLocateDataFunctionForSetOrMap(DeeObject *self, DeeObject *item, DeeObject *key); -INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithKeyWithCallLocateDataMethodForSetOrMap(DeeObject *self, DeeObject *item, DeeObject *key); -INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithKeyWithCallLocateDataKwMethodForSetOrMap(DeeObject *self, DeeObject *item, DeeObject *key); -INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithKeyWithSeqFindWithKeyAndSeqGetItemIndex(DeeObject *self, DeeObject *item, DeeObject *key); -INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithKeyWithSeqForeach(DeeObject *self, DeeObject *item, DeeObject *key); -INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithRangeWithCallAttrLocate(DeeObject *self, DeeObject *item, size_t start, size_t end); -INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithRangeWithCallLocateDataFunction(DeeObject *self, DeeObject *item, size_t start, size_t end); -INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithRangeWithCallLocateDataMethod(DeeObject *self, DeeObject *item, size_t start, size_t end); -INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithRangeWithCallLocateDataKwMethod(DeeObject *self, DeeObject *item, size_t start, size_t end); -INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithRangeWithSeqFindAndSeqGetItemIndex(DeeObject *self, DeeObject *item, size_t start, size_t end); -INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithRangeWithSeqEnumerateIndex(DeeObject *self, DeeObject *item, size_t start, size_t end); -INTDEF WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithRangeAndKeyWithCallAttrLocate(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); -INTDEF WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithRangeAndKeyWithCallLocateDataFunction(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); -INTDEF WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithRangeAndKeyWithCallLocateDataMethod(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); -INTDEF WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithRangeAndKeyWithCallLocateDataKwMethod(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); -INTDEF WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithRangeAndKeyWithSeqFindWithKeyAndSeqGetItemIndex(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); -INTDEF WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithRangeAndKeyWithSeqEnumerateIndex(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); - -INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_DefaultRLocateWithRangeWithCallAttrRLocate(DeeObject *self, DeeObject *item, size_t start, size_t end); -INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_DefaultRLocateWithRangeWithCallRLocateDataFunction(DeeObject *self, DeeObject *item, size_t start, size_t end); -INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_DefaultRLocateWithRangeWithCallRLocateDataMethod(DeeObject *self, DeeObject *item, size_t start, size_t end); -INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_DefaultRLocateWithRangeWithCallRLocateDataKwMethod(DeeObject *self, DeeObject *item, size_t start, size_t end); -INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_DefaultRLocateWithRangeWithSeqRFindAndSeqGetItemIndex(DeeObject *self, DeeObject *item, size_t start, size_t end); -INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_DefaultRLocateWithRangeWithSeqEnumerateIndexReverse(DeeObject *self, DeeObject *item, size_t start, size_t end); -INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_DefaultRLocateWithRangeWithSeqEnumerateIndex(DeeObject *self, DeeObject *item, size_t start, size_t end); -INTDEF WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL DeeSeq_DefaultRLocateWithRangeAndKeyWithCallAttrRLocate(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); -INTDEF WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL DeeSeq_DefaultRLocateWithRangeAndKeyWithCallRLocateDataFunction(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); -INTDEF WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL DeeSeq_DefaultRLocateWithRangeAndKeyWithCallRLocateDataMethod(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); -INTDEF WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL DeeSeq_DefaultRLocateWithRangeAndKeyWithCallRLocateDataKwMethod(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); -INTDEF WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL DeeSeq_DefaultRLocateWithRangeAndKeyWithSeqRFindWithKeyAndSeqGetItemIndex(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); -INTDEF WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL DeeSeq_DefaultRLocateWithRangeAndKeyWithSeqEnumerateIndexReverse(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); -INTDEF WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL DeeSeq_DefaultRLocateWithRangeAndKeyWithSeqEnumerateIndex(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); +INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithCallAttrLocateForSeq(DeeObject *self, DeeObject *match, DeeObject *def); +INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithCallLocateDataFunctionForSeq(DeeObject *self, DeeObject *match, DeeObject *def); +INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithCallLocateDataMethodForSeq(DeeObject *self, DeeObject *match, DeeObject *def); +INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithCallLocateDataKwMethodForSeq(DeeObject *self, DeeObject *match, DeeObject *def); +INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithCallAttrLocateForSetOrMap(DeeObject *self, DeeObject *match, DeeObject *def); +INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithCallLocateDataFunctionForSetOrMap(DeeObject *self, DeeObject *match, DeeObject *def); +INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithCallLocateDataMethodForSetOrMap(DeeObject *self, DeeObject *match, DeeObject *def); +INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithCallLocateDataKwMethodForSetOrMap(DeeObject *self, DeeObject *match, DeeObject *def); +INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithSeqForeach(DeeObject *self, DeeObject *match, DeeObject *def); +INTDEF WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithRangeWithCallAttrLocate(DeeObject *self, DeeObject *match, size_t start, size_t end, DeeObject *def); +INTDEF WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithRangeWithCallLocateDataFunction(DeeObject *self, DeeObject *match, size_t start, size_t end, DeeObject *def); +INTDEF WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithRangeWithCallLocateDataMethod(DeeObject *self, DeeObject *match, size_t start, size_t end, DeeObject *def); +INTDEF WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithRangeWithCallLocateDataKwMethod(DeeObject *self, DeeObject *match, size_t start, size_t end, DeeObject *def); +INTDEF WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL DeeSeq_DefaultLocateWithRangeWithSeqEnumerateIndex(DeeObject *self, DeeObject *match, size_t start, size_t end, DeeObject *def); + +INTDEF WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL DeeSeq_DefaultRLocateWithRangeWithCallAttrRLocate(DeeObject *self, DeeObject *match, size_t start, size_t end, DeeObject *def); +INTDEF WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL DeeSeq_DefaultRLocateWithRangeWithCallRLocateDataFunction(DeeObject *self, DeeObject *match, size_t start, size_t end, DeeObject *def); +INTDEF WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL DeeSeq_DefaultRLocateWithRangeWithCallRLocateDataMethod(DeeObject *self, DeeObject *match, size_t start, size_t end, DeeObject *def); +INTDEF WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL DeeSeq_DefaultRLocateWithRangeWithCallRLocateDataKwMethod(DeeObject *self, DeeObject *match, size_t start, size_t end, DeeObject *def); +INTDEF WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL DeeSeq_DefaultRLocateWithRangeWithSeqEnumerateIndexReverse(DeeObject *self, DeeObject *match, size_t start, size_t end, DeeObject *def); +INTDEF WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL DeeSeq_DefaultRLocateWithRangeWithSeqEnumerateIndex(DeeObject *self, DeeObject *match, size_t start, size_t end, DeeObject *def); INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeSeq_DefaultStartsWithWithCallAttrStartsWith(DeeObject *self, DeeObject *item); INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeSeq_DefaultStartsWithWithCallStartsWithDataFunction(DeeObject *self, DeeObject *item); @@ -1904,22 +1876,6 @@ INTDEF WUNUSED NONNULL((1, 2, 5, 6)) int DCALL DeeSeq_DefaultBRangeWithKeyWithCa INTDEF WUNUSED NONNULL((1, 2, 5, 6)) int DCALL DeeSeq_DefaultBRangeWithKeyWithSizeAndTryGetItemIndex(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key, size_t result_range[2]); INTDEF WUNUSED NONNULL((1, 2, 5, 6)) int DCALL DeeSeq_DefaultBRangeWithKeyWithError(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key, size_t result_range[2]); -INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_DefaultBLocateWithCallAttrBLocate(DeeObject *self, DeeObject *item, size_t start, size_t end); -INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_DefaultBLocateWithCallBLocateDataFunction(DeeObject *self, DeeObject *item, size_t start, size_t end); -INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_DefaultBLocateWithCallBLocateDataMethod(DeeObject *self, DeeObject *item, size_t start, size_t end); -INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_DefaultBLocateWithCallBLocateDataKwMethod(DeeObject *self, DeeObject *item, size_t start, size_t end); -INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_DefaultBLocateWithSizeAndTryGetItemIndex(DeeObject *self, DeeObject *item, size_t start, size_t end); -INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_DefaultBLocateWithSeqBFindAndGetItemIndex(DeeObject *self, DeeObject *item, size_t start, size_t end); -INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_DefaultBLocateWithError(DeeObject *self, DeeObject *item, size_t start, size_t end); - -INTDEF WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL DeeSeq_DefaultBLocateWithKeyWithCallAttrBLocate(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); -INTDEF WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL DeeSeq_DefaultBLocateWithKeyWithCallBLocateDataFunction(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); -INTDEF WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL DeeSeq_DefaultBLocateWithKeyWithCallBLocateDataMethod(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); -INTDEF WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL DeeSeq_DefaultBLocateWithKeyWithCallBLocateDataKwMethod(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); -INTDEF WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL DeeSeq_DefaultBLocateWithKeyWithSizeAndTryGetItemIndex(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); -INTDEF WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL DeeSeq_DefaultBLocateWithKeyWithSeqBFindWithKeyAndGetItemIndex(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); -INTDEF WUNUSED NONNULL((1, 2, 5)) DREF DeeObject *DCALL DeeSeq_DefaultBLocateWithKeyWithError(DeeObject *self, DeeObject *item, size_t start, size_t end, DeeObject *key); - /************************************************************************/ @@ -1948,7 +1904,7 @@ INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSet_DefaultUnifyWithCall INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSet_DefaultUnifyWithCallUnifyDataMethod(DeeObject *self, DeeObject *key); INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSet_DefaultUnifyWithCallUnifyDataKwMethod(DeeObject *self, DeeObject *key); INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSet_DefaultUnifyWithSetInsertAndSeqForeach(DeeObject *self, DeeObject *key); -INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSet_DefaultUnifyWithSeqLocateAndSeqAppend(DeeObject *self, DeeObject *key); +INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSet_DefaultUnifyWithSeqAppendAndSeqForeach(DeeObject *self, DeeObject *key); INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSet_DefaultUnifyWithError(DeeObject *self, DeeObject *key); INTDEF WUNUSED NONNULL((1, 2)) int DCALL DeeSet_DefaultInsertAllWithCallAttrInsertAll(DeeObject *self, DeeObject *keys); diff --git a/src/deemon/objects/seq/locateall.c b/src/deemon/objects/seq/locateall.c deleted file mode 100644 index 71e6e7334..000000000 --- a/src/deemon/objects/seq/locateall.c +++ /dev/null @@ -1,437 +0,0 @@ -/* 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_LOCATE_ALL_C -#define GUARD_DEEMON_OBJECTS_SEQ_LOCATE_ALL_C 1 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "../../runtime/runtime_error.h" -#include "../../runtime/strings.h" -#include "../generic-proxy.h" -/**/ - -#include "locateall.h" - -DECL_BEGIN - -PRIVATE WUNUSED NONNULL((1)) int DCALL -locatoriter_ctor(LocatorIterator *__restrict self) { - self->li_iter = DeeObject_Iter(Dee_EmptySeq); - if unlikely(!self->li_iter) - goto err; - self->li_elem = Dee_None; - self->li_pred = NULL; - Dee_Incref(Dee_None); - return 0; -err: - return -1; -} - -PRIVATE WUNUSED NONNULL((1, 2)) int DCALL -locatoriter_copy(LocatorIterator *__restrict self, - LocatorIterator *__restrict other) { - self->li_iter = DeeObject_Copy(other->li_iter); - if unlikely(!self->li_iter) - goto err; - self->li_elem = other->li_elem; - self->li_pred = other->li_pred; - Dee_Incref(self->li_elem); - Dee_XIncref(self->li_pred); - return 0; -err: - return -1; -} - -PRIVATE WUNUSED NONNULL((1, 2)) int DCALL -locatoriter_deep(LocatorIterator *__restrict self, - LocatorIterator *__restrict other) { - self->li_iter = DeeObject_DeepCopy(other->li_iter); - if unlikely(!self->li_iter) - goto err; - self->li_elem = DeeObject_DeepCopy(other->li_elem); - if unlikely(!self->li_elem) - goto err_iter; - self->li_pred = NULL; - if (other->li_pred) { - self->li_pred = DeeObject_DeepCopy(other->li_pred); - if unlikely(!self->li_pred) - goto err_elem; - } - return 0; -err_elem: - Dee_Decref_likely(self->li_elem); -err_iter: - Dee_Decref_likely(self->li_iter); -err: - return -1; -} - -PRIVATE WUNUSED NONNULL((1)) int DCALL -locatoriter_init(LocatorIterator *__restrict self, - size_t argc, DeeObject *const *argv) { - Locator *loc; - if (DeeArg_Unpack(argc, argv, "o:_SeqLocatorIterator", &loc)) - goto err; - if (DeeObject_AssertTypeExact(loc, &SeqLocator_Type)) - goto err; - self->li_iter = DeeObject_Iter(loc->l_seq); - if unlikely(!self->li_iter) - goto err; - self->li_elem = loc->l_elem; - self->li_pred = loc->l_pred; - Dee_Incref(self->li_elem); - Dee_XIncref(self->li_pred); - return 0; -err: - return -1; -} - -PRIVATE NONNULL((1)) void DCALL -locatoriter_fini(LocatorIterator *__restrict self) { - Dee_Decref(self->li_iter); - Dee_Decref(self->li_elem); - Dee_XDecref(self->li_pred); -} - -PRIVATE NONNULL((1, 2)) void DCALL -locatoriter_visit(LocatorIterator *__restrict self, dvisit_t proc, void *arg) { - Dee_Visit(self->li_iter); - Dee_Visit(self->li_elem); - Dee_XVisit(self->li_pred); -} - -PRIVATE WUNUSED NONNULL((1)) DREF DeeObject *DCALL -locatoriter_next(LocatorIterator *__restrict self) { - DREF DeeObject *result; - for (;;) { - int temp; - result = DeeObject_IterNext(self->li_iter); - if (!ITER_ISOK(result)) - break; - temp = DeeObject_TryCmpKeyEqAsBool(self->li_elem, result, self->li_pred); - if (temp != 0) { - if unlikely(temp < 0) - goto err_r; - break; /* Found it */ - } - Dee_Decref(result); - if (DeeThread_CheckInterrupt()) - goto err; - } - /* Return the located element. */ - return result; -err_r: - Dee_Decref(result); -err: - return NULL; -} - - -STATIC_ASSERT(offsetof(LocatorIterator, li_iter) == offsetof(ProxyObject, po_obj)); -#define locatoriter_hash generic_proxy_hash_recursive -#define locatoriter_compare generic_proxy_compare_recursive -#define locatoriter_compare_eq generic_proxy_compare_eq_recursive -#define locatoriter_trycompare_eq generic_proxy_trycompare_eq_recursive -#define locatoriter_cmp generic_proxy_cmp_recursive - - -PRIVATE WUNUSED NONNULL((1)) DREF DeeObject *DCALL -locatoriter_seq_get(LocatorIterator *__restrict self) { - DREF DeeObject *inner_seq, *result; - /* Forward access to this attribute to the pointed-to iterator. */ - inner_seq = DeeObject_GetAttr(self->li_iter, (DeeObject *)&str_seq); - if unlikely(!inner_seq) - goto err; - result = DeeSeq_LocateAll(inner_seq, self->li_elem, self->li_pred); - Dee_Decref(inner_seq); - return result; -err: - return NULL; -} - -PRIVATE struct type_getset tpconst locatoriter_getsets[] = { - TYPE_GETTER_F(STR_seq, &locatoriter_seq_get, METHOD_FNOREFESCAPE, "->?Ert:SeqLocator"), - TYPE_GETSET_END -}; - -PRIVATE struct type_member tpconst locatoriter_members[] = { - TYPE_MEMBER_FIELD_DOC("__iter__", STRUCT_OBJECT, offsetof(LocatorIterator, li_iter), "->?DIterator"), - TYPE_MEMBER_FIELD("__elem__", STRUCT_OBJECT, offsetof(LocatorIterator, li_elem)), - TYPE_MEMBER_FIELD_DOC("__pred__", STRUCT_OBJECT_OPT, offsetof(LocatorIterator, li_pred), "->?DCallable"), - TYPE_MEMBER_END -}; - -INTERN DeeTypeObject SeqLocatorIterator_Type = { - OBJECT_HEAD_INIT(&DeeType_Type), - /* .tp_name = */ "_SeqLocatorIterator", - /* .tp_doc = */ DOC("(seq?:?Ert:SeqLocator)"), - /* .tp_flags = */ TP_FNORMAL | TP_FFINAL, - /* .tp_weakrefs = */ 0, - /* .tp_features = */ TF_NONE, - /* .tp_base = */ &DeeIterator_Type, - /* .tp_init = */ { - { - /* .tp_alloc = */ { - /* .tp_ctor = */ (dfunptr_t)&locatoriter_ctor, - /* .tp_copy_ctor = */ (dfunptr_t)&locatoriter_copy, - /* .tp_deep_ctor = */ (dfunptr_t)&locatoriter_deep, - /* .tp_any_ctor = */ (dfunptr_t)&locatoriter_init, - TYPE_FIXED_ALLOCATOR(LocatorIterator) - } - }, - /* .tp_dtor = */ (void (DCALL *)(DeeObject *__restrict))&locatoriter_fini, - /* .tp_assign = */ NULL, - /* .tp_move_assign = */ NULL - }, - /* .tp_cast = */ { - /* .tp_str = */ NULL, - /* .tp_repr = */ NULL, - /* .tp_bool = */ NULL - }, - /* .tp_call = */ NULL, - /* .tp_visit = */ (void (DCALL *)(DeeObject *__restrict, dvisit_t, void *))&locatoriter_visit, - /* .tp_gc = */ NULL, - /* .tp_math = */ NULL, - /* .tp_cmp = */ &locatoriter_cmp, - /* .tp_seq = */ NULL, - /* .tp_iter_next = */ (DREF DeeObject *(DCALL *)(DeeObject *__restrict))&locatoriter_next, - /* .tp_iterator = */ NULL, - /* .tp_attr = */ NULL, - /* .tp_with = */ NULL, - /* .tp_buffer = */ NULL, - /* .tp_methods = */ NULL, - /* .tp_getsets = */ locatoriter_getsets, - /* .tp_members = */ locatoriter_members, - /* .tp_class_methods = */ NULL, - /* .tp_class_getsets = */ NULL, - /* .tp_class_members = */ NULL -}; - -PRIVATE WUNUSED NONNULL((1)) int DCALL -locator_ctor(Locator *__restrict self) { - self->l_seq = Dee_EmptySeq; - self->l_elem = Dee_None; - self->l_pred = NULL; - Dee_Incref(Dee_EmptySeq); - Dee_Incref(Dee_None); - return 0; -} - -PRIVATE WUNUSED NONNULL((1, 2)) int DCALL -locator_copy(Locator *__restrict self, - Locator *__restrict other) { - self->l_seq = other->l_seq; - self->l_elem = other->l_elem; - self->l_pred = other->l_pred; - Dee_Incref(self->l_seq); - Dee_Incref(self->l_elem); - Dee_XIncref(self->l_pred); - return 0; -} - -PRIVATE WUNUSED NONNULL((1, 2)) int DCALL -locator_deep(Locator *__restrict self, - Locator *__restrict other) { - self->l_seq = DeeObject_DeepCopy(other->l_seq); - if unlikely(!self->l_seq) - goto err; - self->l_elem = DeeObject_DeepCopy(other->l_elem); - if unlikely(!self->l_elem) - goto err_seq; - self->l_pred = NULL; - if (other->l_pred) { - self->l_pred = DeeObject_DeepCopy(other->l_pred); - if unlikely(!self->l_pred) - goto err_elem; - } - return 0; -err_elem: - Dee_Decref_likely(self->l_elem); -err_seq: - Dee_Decref_likely(self->l_seq); -err: - return -1; -} - -PRIVATE WUNUSED NONNULL((1)) int DCALL -locator_init(Locator *__restrict self, - size_t argc, DeeObject *const *argv) { - self->l_pred = NULL; - if (DeeArg_Unpack(argc, argv, "oo|o:_SeqLocator", &self->l_seq, &self->l_elem, &self->l_pred)) - goto err; - if (self->l_pred) { - self->l_elem = DeeObject_Call(self->l_pred, 1, &self->l_elem); - if unlikely(!self->l_elem) - goto err; - Dee_Incref(self->l_pred); - } else { - Dee_Incref(self->l_elem); - } - Dee_Incref(self->l_seq); - return 0; -err: - return -1; -} - -PRIVATE NONNULL((1)) void DCALL -locator_fini(Locator *__restrict self) { - Dee_Decref(self->l_seq); - Dee_Decref(self->l_elem); - Dee_XDecref(self->l_pred); -} - -PRIVATE NONNULL((1, 2)) void DCALL -locator_visit(Locator *__restrict self, dvisit_t proc, void *arg) { - Dee_Visit(self->l_seq); - Dee_Visit(self->l_elem); - Dee_XVisit(self->l_pred); -} - -PRIVATE WUNUSED NONNULL((1)) DREF DeeObject *DCALL -locator_iter(Locator *__restrict self) { - DREF LocatorIterator *result; - result = DeeObject_MALLOC(LocatorIterator); - if unlikely(!result) - goto done; - /* Create the underlying iterator. */ - result->li_iter = DeeObject_Iter(self->l_seq); - if unlikely(!result->li_iter) - goto err_r; - /* Assign the locator element & key function. */ - result->li_elem = self->l_elem; - Dee_Incref(self->l_elem); - result->li_pred = self->l_pred; - Dee_XIncref(self->l_pred); - DeeObject_Init(result, &SeqLocatorIterator_Type); -done: - return (DREF DeeObject *)result; -err_r: - DeeObject_FREE(result); - return NULL; -} - -PRIVATE struct type_member tpconst locator_members[] = { - TYPE_MEMBER_FIELD_DOC("__seq__", STRUCT_OBJECT, offsetof(Locator, l_seq), "->?DSequence"), - TYPE_MEMBER_FIELD("__elem__", STRUCT_OBJECT, offsetof(Locator, l_elem)), - TYPE_MEMBER_FIELD_DOC("__pred__", STRUCT_OBJECT_OPT, offsetof(Locator, l_pred), "->?DCallable"), - TYPE_MEMBER_END -}; - -PRIVATE struct type_member tpconst locator_class_members[] = { - TYPE_MEMBER_CONST(STR_Iterator, &SeqLocatorIterator_Type), - TYPE_MEMBER_END -}; - -PRIVATE struct type_seq locator_seq = { - /* .tp_iter = */ (DREF DeeObject *(DCALL *)(DeeObject *__restrict))&locator_iter, - /* .tp_sizeob = */ NULL, - /* .tp_contains = */ NULL, - /* .tp_getitem = */ NULL, - /* .tp_delitem = */ NULL, - /* .tp_setitem = */ NULL, - /* .tp_getrange = */ NULL, - /* .tp_delrange = */ NULL, - /* .tp_setrange = */ NULL -}; - -INTERN DeeTypeObject SeqLocator_Type = { - OBJECT_HEAD_INIT(&DeeType_Type), - /* .tp_name = */ "_SeqLocator", - /* .tp_doc = */ DOC("()\n" - "(seq:?DSequence,elem,pred?:?DCallable)"), - /* .tp_flags = */ TP_FNORMAL | TP_FFINAL, - /* .tp_weakrefs = */ 0, - /* .tp_features = */ TF_NONE, - /* .tp_base = */ &DeeSeq_Type, - /* .tp_init = */ { - { - /* .tp_alloc = */ { - /* .tp_ctor = */ (dfunptr_t)&locator_ctor, - /* .tp_copy_ctor = */ (dfunptr_t)&locator_copy, - /* .tp_deep_ctor = */ (dfunptr_t)&locator_deep, - /* .tp_any_ctor = */ (dfunptr_t)&locator_init, - TYPE_FIXED_ALLOCATOR(Locator) - } - }, - /* .tp_dtor = */ (void (DCALL *)(DeeObject *__restrict))&locator_fini, - /* .tp_assign = */ NULL, - /* .tp_move_assign = */ NULL - }, - /* .tp_cast = */ { - /* .tp_str = */ NULL, - /* .tp_repr = */ NULL, - /* .tp_bool = */ NULL - }, - /* .tp_call = */ NULL, - /* .tp_visit = */ (void (DCALL *)(DeeObject *__restrict, dvisit_t, void *))&locator_visit, - /* .tp_gc = */ NULL, - /* .tp_math = */ NULL, - /* .tp_cmp = */ NULL, - /* .tp_seq = */ &locator_seq, - /* .tp_iter_next = */ NULL, - /* .tp_iterator = */ NULL, - /* .tp_attr = */ NULL, - /* .tp_with = */ NULL, - /* .tp_buffer = */ NULL, - /* .tp_methods = */ NULL, - /* .tp_getsets = */ NULL, - /* .tp_members = */ locator_members, - /* .tp_class_methods = */ NULL, - /* .tp_class_getsets = */ NULL, - /* .tp_class_members = */ locator_class_members -}; - - - -INTERN WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL -DeeSeq_LocateAll(DeeObject *self, - DeeObject *keyed_search_item, - DeeObject *key) { - DREF Locator *result; - /* Create a new locator sequence. */ - result = DeeObject_MALLOC(Locator); - if unlikely(!result) - goto err; - result->l_seq = self; - result->l_elem = keyed_search_item; - result->l_pred = key; - Dee_Incref(self); - Dee_Incref(keyed_search_item); - Dee_XIncref(key); - DeeObject_Init(result, &SeqLocator_Type); - return (DREF DeeObject *)result; -err: - return NULL; -} - -DECL_END - -#endif /* !GUARD_DEEMON_OBJECTS_SEQ_LOCATE_ALL_C */ diff --git a/src/deemon/runtime/kwlist.h b/src/deemon/runtime/kwlist.h index a96680d6c..6b008d129 100644 --- a/src/deemon/runtime/kwlist.h +++ b/src/deemon/runtime/kwlist.h @@ -86,6 +86,7 @@ local kw_lists = { {"item", "start", "end"}, {"item", "start", "end", "key"}, {"item", "start", "end", "max", "key"}, + {"match", "start", "end", "def"}, {"should", "start", "end", "max"}, {"size", "filler"}, {"start", "end", "values"}, @@ -199,6 +200,7 @@ DECLARE_KWLIST(kwlist__length_byteorder_signed, { KEX("length", 0xecef0c1, 0x299 DECLARE_KWLIST(kwlist__lhs_rhs, { KEX("lhs", 0x4778c168, 0x4c6b9df6ea0934de), KEX("rhs", 0xc6d67ad, 0x7f4a7fedc9040cd3), KEND }); DECLARE_KWLIST(kwlist__lookupmode, { KEX("lookupmode", 0x5919ca40, 0x2f6c38dd63e00f55), KEND }); DECLARE_KWLIST(kwlist__mask_max, { KEX("mask", 0xc3b4302b, 0x933f153b40dd4379), KEX("max", 0xc293979b, 0x822bd5c706bd9850), KEND }); +DECLARE_KWLIST(kwlist__match_start_end_def, { KEX("match", 0x69faa058, 0xb0704984f0078f40), KEX("start", 0xa2ed6890, 0x80b621ce3c3982d5), KEX("end", 0x37fb4a05, 0x6de935c204dc3d01), KEX("def", 0xf5797de2, 0x6cea9b604fa07583), KEND }); DECLARE_KWLIST(kwlist__maxbytes_readall, { KEX("maxbytes", 0x3b196fc0, 0x93d3b3615fcacd4a), KEX("readall", 0x331ceae8, 0x8ad608764266c76d), KEND }); DECLARE_KWLIST(kwlist__message_inner, { KEX("message", 0x14820755, 0xbeaa4b97155366df), KEX("inner", 0x20e82985, 0x4f20d07bb803c1fe), KEND }); DECLARE_KWLIST(kwlist__minbytes_maxbytes_offset_nulbytes_readall_mustmmap_mapshared, { KEX("minbytes", 0xa6327ad1, 0x36d31d85046534af), KEX("maxbytes", 0x3b196fc0, 0x93d3b3615fcacd4a), KEX("offset", 0xa97063e7, 0x2381bd4159ebe8a7), KEX("nulbytes", 0xf6256f, 0x164a29d88f8ebaa3), KEX("readall", 0x331ceae8, 0x8ad608764266c76d), KEX("mustmmap", 0x720e751d, 0x10d9f32721af9f8d), KEX("mapshared", 0xcb3dd03e, 0xc9af3c3e0ad0fc85), KEND }); diff --git a/src/deemon/runtime/strings.h b/src/deemon/runtime/strings.h index ecbbdea77..e66d7f21b 100644 --- a/src/deemon/runtime/strings.h +++ b/src/deemon/runtime/strings.h @@ -156,7 +156,6 @@ local STRINGS = { "bfind", "bposition", "brange", - "blocate", "unify", "setold", @@ -599,9 +598,6 @@ DEF_STRING(str_bposition, "bposition", 0xba99f013, 0xc8f6389c9f293cb2) #define Dee_HashStr__brange _Dee_HashSelectC(0xb132222e, 0xfed8bb16d0ac0dd2) DEF_STRING(str_brange, "brange", 0xb132222e, 0xfed8bb16d0ac0dd2) #define STR_brange DeeString_STR(&str_brange) -#define Dee_HashStr__blocate _Dee_HashSelectC(0x7aa979d3, 0xbda91c237d69489e) -DEF_STRING(str_blocate, "blocate", 0x7aa979d3, 0xbda91c237d69489e) -#define STR_blocate DeeString_STR(&str_blocate) #define Dee_HashStr__unify _Dee_HashSelectC(0x3cce686e, 0x4c0c9bdcc8d95cc7) DEF_STRING(str_unify, "unify", 0x3cce686e, 0x4c0c9bdcc8d95cc7) #define STR_unify DeeString_STR(&str_unify) diff --git a/src/dex/rt/librt.c b/src/dex/rt/librt.c index 0e776c386..c385d6c5a 100644 --- a/src/dex/rt/librt.c +++ b/src/dex/rt/librt.c @@ -120,7 +120,6 @@ print define_Dee_HashStr("ubfilter"); print define_Dee_HashStr("findall"); print define_Dee_HashStr("future"); print define_Dee_HashStr("ids"); -print define_Dee_HashStr("locateall"); print define_Dee_HashStr("ordinals"); print define_Dee_HashStr("pending"); print define_Dee_HashStr("permutations"); @@ -181,7 +180,6 @@ print define_Dee_HashStr("__IterWithEnumerateIndexMap__"); #define Dee_HashStr__findall _Dee_HashSelectC(0xa7064666, 0x73bffde4f31b16e5) #define Dee_HashStr__future _Dee_HashSelectC(0x5ca3159c, 0x8ab2926ab5959525) #define Dee_HashStr__ids _Dee_HashSelectC(0x3173a48f, 0x7cd9fae6cf17bb9f) -#define Dee_HashStr__locateall _Dee_HashSelectC(0xd447ec, 0xc6a682da9d9f8345) #define Dee_HashStr__ordinals _Dee_HashSelectC(0x4237d4c5, 0x5459ba3a055d9b9a) #define Dee_HashStr__pending _Dee_HashSelectC(0xa318502a, 0x9f3f699bf5a1e785) #define Dee_HashStr__permutations _Dee_HashSelectC(0x923fbd44, 0x498779abec4910f6) @@ -1030,27 +1028,6 @@ librt_get_SeqHashFilterIterator_f(size_t UNUSED(argc), DeeObject *const *UNUSED( return_cached(get_iterator_of(librt_get_SeqHashFilter_impl_f())); } -PRIVATE WUNUSED DREF DeeObject *DCALL -librt_get_SeqLocator_uncached_impl_f(void) { - DeeObject *argv[] = { Dee_None }; - return get_type_of(DeeObject_CallAttrStringHash(&object_with_size_and_getitem_index, STR_AND_HASH(locateall), 1, argv)); -} - -PRIVATE WUNUSED DREF DeeObject *DCALL -librt_get_SeqLocator_impl_f(void) { - return_cached(librt_get_SeqLocator_uncached_impl_f()); -} - -PRIVATE WUNUSED DREF DeeObject *DCALL -librt_get_SeqLocator_f(size_t UNUSED(argc), DeeObject *const *UNUSED(argv)) { - return librt_get_SeqLocator_impl_f(); -} - -PRIVATE WUNUSED DREF DeeObject *DCALL -librt_get_SeqLocatorIterator_f(size_t UNUSED(argc), DeeObject *const *UNUSED(argv)) { - return_cached(get_iterator_of(librt_get_SeqLocator_impl_f())); -} - PRIVATE WUNUSED DREF DeeObject *DCALL librt_get_SeqMapped_uncached_impl_f(void) { DeeObject *argv[] = { Dee_None }; @@ -3255,8 +3232,6 @@ PRIVATE DEFINE_CMETHOD(librt_get_SeqFilterAsUnbound, &librt_get_SeqFilterAsUnbou PRIVATE DEFINE_CMETHOD(librt_get_SeqFilterIterator, &librt_get_SeqFilterIterator_f, METHOD_FCONSTCALL); PRIVATE DEFINE_CMETHOD(librt_get_SeqHashFilter, &librt_get_SeqHashFilter_f, METHOD_FCONSTCALL); PRIVATE DEFINE_CMETHOD(librt_get_SeqHashFilterIterator, &librt_get_SeqHashFilterIterator_f, METHOD_FCONSTCALL); -PRIVATE DEFINE_CMETHOD(librt_get_SeqLocator, &librt_get_SeqLocator_f, METHOD_FCONSTCALL); -PRIVATE DEFINE_CMETHOD(librt_get_SeqLocatorIterator, &librt_get_SeqLocatorIterator_f, METHOD_FCONSTCALL); PRIVATE DEFINE_CMETHOD(librt_get_SeqMapped, &librt_get_SeqMapped_f, METHOD_FCONSTCALL); PRIVATE DEFINE_CMETHOD(librt_get_SeqMappedIterator, &librt_get_SeqMappedIterator_f, METHOD_FCONSTCALL); PRIVATE DEFINE_CMETHOD(librt_get_SeqRange, &librt_get_SeqRange_f, METHOD_FCONSTCALL); @@ -3626,8 +3601,6 @@ PRIVATE struct dex_symbol symbols[] = { { "SeqFilterIterator", (DeeObject *)&librt_get_SeqFilterIterator, MODSYM_FREADONLY | MODSYM_FPROPERTY | MODSYM_FCONSTEXPR }, /* SeqFilterIterator_Type */ { "SeqHashFilter", (DeeObject *)&librt_get_SeqHashFilter, MODSYM_FREADONLY | MODSYM_FPROPERTY | MODSYM_FCONSTEXPR }, /* SeqHashFilter_Type */ { "SeqHashFilterIterator", (DeeObject *)&librt_get_SeqHashFilterIterator, MODSYM_FREADONLY | MODSYM_FPROPERTY | MODSYM_FCONSTEXPR }, /* SeqHashFilterIterator_Type */ - { "SeqLocator", (DeeObject *)&librt_get_SeqLocator, MODSYM_FREADONLY | MODSYM_FPROPERTY | MODSYM_FCONSTEXPR }, /* SeqLocator_Type */ - { "SeqLocatorIterator", (DeeObject *)&librt_get_SeqLocatorIterator, MODSYM_FREADONLY | MODSYM_FPROPERTY | MODSYM_FCONSTEXPR }, /* SeqLocatorIterator_Type */ { "SeqMapped", (DeeObject *)&librt_get_SeqMapped, MODSYM_FREADONLY | MODSYM_FPROPERTY | MODSYM_FCONSTEXPR }, /* SeqMapped_Type */ { "SeqMappedIterator", (DeeObject *)&librt_get_SeqMappedIterator, MODSYM_FREADONLY | MODSYM_FPROPERTY | MODSYM_FCONSTEXPR }, /* SeqMappedIterator_Type */ { "SeqRange", (DeeObject *)&librt_get_SeqRange, MODSYM_FREADONLY | MODSYM_FPROPERTY | MODSYM_FCONSTEXPR }, /* SeqRange_Type */ diff --git a/util/test/deemon-sequence-bsearch.dee b/util/test/deemon-sequence-bsearch.dee index fb5b4e9a4..21b16585f 100644 --- a/util/test/deemon-sequence-bsearch.dee +++ b/util/test/deemon-sequence-bsearch.dee @@ -79,17 +79,6 @@ assert seq.brange(31) == (8, 9); assert seq.brange(32) == (9, 10); assert seq.brange(33) == (10, 11); -assert seq.blocate(11) == 11; -assert seq.blocate(12) == 12; -assert seq.blocate(13) == 13; -assert seq.blocate(21) == 21; -assert seq.blocate(22) == 22; -assert seq.blocate(23) == 23; -assert (try seq.blocate(24) catch (e...) e) is Error.ValueError; -assert seq.blocate(31) == 31; -assert seq.blocate(32) == 32; -assert seq.blocate(33) == 33; - assert seq.blocateall(11) == [11]; assert seq.blocateall(12) == [12]; assert seq.blocateall(13) == [13]; diff --git a/src/deemon/objects/seq/locateall.h b/util/test/deemon-sequence-locate.dee similarity index 58% rename from src/deemon/objects/seq/locateall.h rename to util/test/deemon-sequence-locate.dee index 3d4f8dca9..f2b623db8 100644 --- a/src/deemon/objects/seq/locateall.h +++ b/util/test/deemon-sequence-locate.dee @@ -1,3 +1,4 @@ +#!/usr/bin/deemon /* Copyright (c) 2018-2024 Griefer@Work * * * * This software is provided 'as-is', without any express or implied * @@ -17,34 +18,28 @@ * misrepresented as being the original software. * * 3. This notice may not be removed or altered from any source distribution. * */ -#ifndef GUARD_DEEMON_OBJECTS_SEQ_LOCATE_ALL_H -#define GUARD_DEEMON_OBJECTS_SEQ_LOCATE_ALL_H 1 -#include -#include -DECL_BEGIN +local x = { 10, 20, 7, 19, 55, 56, 3, 5 }; -typedef struct { - OBJECT_HEAD - DREF DeeObject *l_seq; /* [1..1][const] The sequence being transformed. */ - DREF DeeObject *l_elem; /* [1..1][const] The element being searched. */ - DREF DeeObject *l_pred; /* [0..1][const] The key function invoked to transform elements. */ -} Locator; +assert 55 == x.locate(v -> v >= 30); +assert 56 == x.rlocate(v -> v >= 30); +assert 7 == x.locate(v -> v < 10); +assert 5 == x.rlocate(v -> v < 10); +assert 3 == x.locate(v -> v < 10, start: 3); +assert 3 == x.locate(v -> v < 10, start: 3, end: 7); +assert 3 == x.locate(v -> v < 10, start: 3, end: 8); +assert 5 == x.rlocate(v -> v < 10, start: 3); +assert 3 == x.rlocate(v -> v < 10, start: 3, end: 7); +assert 5 == x.rlocate(v -> v < 10, start: 3, end: 8); -typedef struct { - OBJECT_HEAD - DREF DeeObject *li_iter; /* [1..1][const] The iterator in which items are being located. */ - DREF DeeObject *li_elem; /* [1..1][const] The element being searched. */ - DREF DeeObject *li_pred; /* [0..1][const] The key function invoked to transform elements. */ -} LocatorIterator; +assert x.locate(v -> v > 100) is none; +assert x.rlocate(v -> v > 100) is none; +assert x.locate(v -> v == 10, start: 1) is none; +assert x.rlocate(v -> v == 10, start: 1) is none; +assert "oops" == x.locate(v -> v > 100, def: "oops"); +assert "oops" == x.rlocate(v -> v > 100, def: "oops"); -INTDEF DeeTypeObject SeqLocator_Type; -INTDEF DeeTypeObject SeqLocatorIterator_Type; - -INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_LocateAll(DeeObject *self, DeeObject *keyed_search_item, DeeObject *key); - -DECL_END - -#endif /* !GUARD_DEEMON_OBJECTS_SEQ_LOCATE_ALL_H */ +/* there is no "locateall" because "filter" does the same */ +assert {55, 56} == x.filter(v -> v >= 30); diff --git a/util/test/rt-linkage.dee b/util/test/rt-linkage.dee index f546d1d66..1d0315f80 100644 --- a/util/test/rt-linkage.dee +++ b/util/test/rt-linkage.dee @@ -48,8 +48,6 @@ assertRtTypeName("SeqFilterAsUnbound"); assertRtTypeName("SeqFilterIterator"); assertRtTypeName("SeqHashFilter"); assertRtTypeName("SeqHashFilterIterator"); -assertRtTypeName("SeqLocator"); -assertRtTypeName("SeqLocatorIterator"); assertRtTypeName("SeqMapped"); assertRtTypeName("SeqMappedIterator"); assertRtTypeName("SeqRange");