Skip to content

Commit

Permalink
Finish migrating existing types to the new sequence system
Browse files Browse the repository at this point in the history
It might still be missing some, but I *think* I went over all of them.
  • Loading branch information
GrieferAtWork committed May 3, 2024
1 parent 69e0fe7 commit 5df126a
Show file tree
Hide file tree
Showing 10 changed files with 858 additions and 493 deletions.
57 changes: 44 additions & 13 deletions src/deemon/objects/roset.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,9 @@ roset_iter(RoSet *__restrict self) {
return result;
}

PRIVATE WUNUSED NONNULL((1)) DREF DeeObject *DCALL
PRIVATE WUNUSED NONNULL((1)) size_t DCALL
roset_size(RoSet *__restrict self) {
return DeeInt_NewSize(self->rs_size);
return self->rs_size;
}

PRIVATE WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL
Expand Down Expand Up @@ -529,17 +529,48 @@ PRIVATE struct type_cmp roset_cmp = {
};

PRIVATE struct type_seq roset_seq = {
/* .tp_iter = */ (DREF DeeObject *(DCALL *)(DeeObject *__restrict))&roset_iter,
/* .tp_sizeob = */ (DREF DeeObject *(DCALL *)(DeeObject *__restrict))&roset_size,
/* .tp_contains = */ (DREF DeeObject *(DCALL *)(DeeObject *, DeeObject *))&roset_contains,
/* .tp_getitem = */ NULL,
/* .tp_delitem = */ NULL,
/* .tp_setitem = */ NULL,
/* .tp_getrange = */ NULL,
/* .tp_delrange = */ NULL,
/* .tp_setrange = */ NULL,
/* .tp_nsi = */ NULL,
/* .tp_foreach = */ (Dee_ssize_t (DCALL *)(DeeObject *__restrict, Dee_foreach_t, void *))&roset_foreach,
/* .tp_iter = */ (DREF DeeObject *(DCALL *)(DeeObject *__restrict))&roset_iter,
/* .tp_sizeob = */ NULL,
/* .tp_contains = */ (DREF DeeObject *(DCALL *)(DeeObject *, DeeObject *))&roset_contains,
/* .tp_getitem = */ NULL,
/* .tp_delitem = */ NULL,
/* .tp_setitem = */ NULL,
/* .tp_getrange = */ NULL,
/* .tp_delrange = */ NULL,
/* .tp_setrange = */ NULL,
/* .tp_nsi = */ NULL,
/* .tp_foreach = */ (Dee_ssize_t (DCALL *)(DeeObject *__restrict, Dee_foreach_t, void *))&roset_foreach,
/* .tp_foreach_pair = */ NULL,
/* .tp_bounditem = */ NULL,
/* .tp_hasitem = */ NULL,
/* .tp_size = */ (size_t (DCALL *)(DeeObject *__restrict))&roset_size,
/* .tp_size_fast = */ (size_t (DCALL *)(DeeObject *__restrict))&roset_size,
/* .tp_getitem_index = */ NULL,
/* .tp_getitem_index_fast = */ NULL,
/* .tp_delitem_index = */ NULL,
/* .tp_setitem_index = */ NULL,
/* .tp_bounditem_index = */ NULL,
/* .tp_hasitem_index = */ NULL,
/* .tp_getrange_index = */ NULL,
/* .tp_delrange_index = */ NULL,
/* .tp_setrange_index = */ NULL,
/* .tp_getrange_index_n = */ NULL,
/* .tp_delrange_index_n = */ NULL,
/* .tp_setrange_index_n = */ NULL,
/* .tp_trygetitem = */ NULL,
/* .tp_trygetitem_index = */ NULL,
/* .tp_trygetitem_string_hash = */ NULL,
/* .tp_getitem_string_hash = */ NULL,
/* .tp_delitem_string_hash = */ NULL,
/* .tp_setitem_string_hash = */ NULL,
/* .tp_bounditem_string_hash = */ NULL,
/* .tp_hasitem_string_hash = */ NULL,
/* .tp_trygetitem_string_len_hash = */ NULL,
/* .tp_getitem_string_len_hash = */ NULL,
/* .tp_delitem_string_len_hash = */ NULL,
/* .tp_setitem_string_len_hash = */ NULL,
/* .tp_bounditem_string_len_hash = */ NULL,
/* .tp_hasitem_string_len_hash = */ NULL,
};

PRIVATE WUNUSED NONNULL((1)) DREF DeeObject *DCALL
Expand Down
6 changes: 6 additions & 0 deletions src/deemon/objects/set.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,14 @@ invset_printrepr(DeeSetInversionObject *__restrict self,
return DeeFormat_Printf(printer, arg, "~%r", self->si_set);
}

#ifndef CONFIG_EXPERIMENTAL_NEW_SEQUENCE_OPERATORS
PRIVATE WUNUSED NONNULL((1)) DREF DeeObject *DCALL
invset_iterself(DeeSetInversionObject *__restrict self) {
/* Sorry, but it's impossible to enumerate a set containing (almost) everything */
err_unimplemented_operator(Dee_TYPE(self), OPERATOR_ITER);
return NULL;
}
#endif /* !CONFIG_EXPERIMENTAL_NEW_SEQUENCE_OPERATORS */

PRIVATE WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL
invset_tpcontains(DeeSetInversionObject *self, DeeObject *key) {
Expand All @@ -211,7 +213,11 @@ invset_tpcontains(DeeSetInversionObject *self, DeeObject *key) {
}

PRIVATE struct type_seq invset_seq = {
#ifdef CONFIG_EXPERIMENTAL_NEW_SEQUENCE_OPERATORS
/* .tp_iter = */ NULL,
#else /* CONFIG_EXPERIMENTAL_NEW_SEQUENCE_OPERATORS */
/* .tp_iter = */ (DREF DeeObject *(DCALL *)(DeeObject *__restrict))&invset_iterself,
#endif /* !CONFIG_EXPERIMENTAL_NEW_SEQUENCE_OPERATORS */
/* .tp_sizeob = */ NULL,
/* .tp_contains = */ (DREF DeeObject *(DCALL *)(DeeObject *, DeeObject *))&invset_tpcontains,
/* .tp_getitem = */ NULL,
Expand Down
1 change: 1 addition & 0 deletions src/deemon/runtime/operator_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -2052,6 +2052,7 @@ PRIVATE struct type_seq to_seq = {
/* .tp_iter = */ (DREF DeeObject *(DCALL *)(DeeObject *__restrict))&to_iter,
/* .tp_sizeob = */ NULL,
/* .tp_contains = */ (DREF DeeObject *(DCALL *)(DeeObject *, DeeObject *))&to_contains
/* TODO: tp_foreach */
};

PRIVATE struct type_member tpconst to_class_members[] = {
Expand Down
Loading

0 comments on commit 5df126a

Please sign in to comment.