Skip to content

Commit

Permalink
Various fixes/improvements related to rt and seq proxies
Browse files Browse the repository at this point in the history
  • Loading branch information
GrieferAtWork committed Dec 10, 2024
1 parent 456d538 commit d3aaa89
Show file tree
Hide file tree
Showing 23 changed files with 1,394 additions and 280 deletions.
4 changes: 4 additions & 0 deletions include/deemon/class.h
Original file line number Diff line number Diff line change
Expand Up @@ -2775,6 +2775,7 @@ INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeObject_TDefaultTryGetIte
INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeObject_TDefaultTryGetItemIndexWithGetItem(DeeTypeObject *tp_self, DeeObject *self, size_t index);
INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeObject_TDefaultTryGetItemIndexWithErrorRequiresString(DeeTypeObject *tp_self, DeeObject *self, size_t index);
INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeObject_TDefaultTryGetItemIndexWithGetItemIndexDefault(DeeTypeObject *tp_self, DeeObject *self, size_t index);
INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeSeq_TDefaultTryGetItemIndexWithForeachDefault(DeeTypeObject *tp_self, DeeObject *self, size_t index);
INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeMap_TDefaultTryGetItemIndexWithEnumerate(DeeTypeObject *tp_self, DeeObject *self, size_t index);
INTDEF WUNUSED NONNULL((1, 2)) DREF DeeObject *DCALL DeeMap_TDefaultTryGetItemIndexWithEnumerateDefault(DeeTypeObject *tp_self, DeeObject *self, size_t index);
INTDEF WUNUSED NONNULL((1, 2, 3)) DREF DeeObject *DCALL DeeObject_TDefaultTryGetItemStringHashWithTryGetItemStringLenHash(DeeTypeObject *tp_self, DeeObject *self, char const *key, Dee_hash_t hash);
Expand Down Expand Up @@ -3401,6 +3402,7 @@ INTDEF WUNUSED NONNULL((1, 2)) size_t DCALL DeeSeq_TDefaultUnpackExWithForeachDe
(tp_trygetitem_index) == &DeeObject_DefaultTryGetItemIndexWithGetItemIndex ? map(DeeObject_TDefaultTryGetItemIndexWithGetItemIndex) : \
(tp_trygetitem_index) == &DeeObject_DefaultTryGetItemIndexWithGetItem ? map(DeeObject_TDefaultTryGetItemIndexWithGetItem) : \
(tp_trygetitem_index) == &DeeObject_DefaultTryGetItemIndexWithGetItemIndexDefault ? map(DeeObject_TDefaultTryGetItemIndexWithGetItemIndexDefault) : \
(tp_trygetitem_index) == &DeeSeq_DefaultTryGetItemIndexWithForeachDefault ? map(DeeSeq_TDefaultTryGetItemIndexWithForeachDefault) : \
(tp_trygetitem_index) == &DeeMap_DefaultTryGetItemIndexWithEnumerate ? map(DeeMap_TDefaultTryGetItemIndexWithEnumerate) : \
(tp_trygetitem_index) == &DeeMap_DefaultTryGetItemIndexWithEnumerateDefault ? map(DeeMap_TDefaultTryGetItemIndexWithEnumerateDefault) : default)
#define DeeType_MapDefaultTryGetItemStringHash(tp_trygetitem_string_hash, map, default) \
Expand Down Expand Up @@ -4048,6 +4050,7 @@ INTDEF WUNUSED NONNULL((1, 2)) size_t DCALL DeeSeq_TDefaultUnpackExWithForeachDe
(tp_trygetitem_index) == &DeeObject_DefaultTryGetItemIndexWithGetItem || \
(tp_trygetitem_index) == &DeeObject_DefaultTryGetItemIndexWithErrorRequiresString || \
(tp_trygetitem_index) == &DeeObject_DefaultTryGetItemIndexWithGetItemIndexDefault || \
(tp_trygetitem_index) == &DeeSeq_DefaultTryGetItemIndexWithForeachDefault || \
(tp_trygetitem_index) == &DeeMap_DefaultTryGetItemIndexWithEnumerate || \
(tp_trygetitem_index) == &DeeMap_DefaultTryGetItemIndexWithEnumerateDefault)
#define DeeType_IsDefaultTryGetItemStringHash(tp_trygetitem_string_hash) \
Expand Down Expand Up @@ -4768,6 +4771,7 @@ INTDEF WUNUSED NONNULL((1, 2)) size_t DCALL DeeSeq_TDefaultUnpackExWithForeachDe
(tp_trygetitem_index) == &DeeObject_DefaultTryGetItemIndexWithGetItemIndex ? DeeObject_TDefaultTryGetItemIndexWithGetItemIndex(tp_self, self, index) : \
(tp_trygetitem_index) == &DeeObject_DefaultTryGetItemIndexWithGetItem ? DeeObject_TDefaultTryGetItemIndexWithGetItem(tp_self, self, index) : \
(tp_trygetitem_index) == &DeeObject_DefaultTryGetItemIndexWithGetItemIndexDefault ? DeeObject_TDefaultTryGetItemIndexWithGetItemIndexDefault(tp_self, self, index) : \
(tp_trygetitem_index) == &DeeSeq_DefaultTryGetItemIndexWithForeachDefault ? DeeSeq_TDefaultTryGetItemIndexWithForeachDefault(tp_self, self, index) : \
(tp_trygetitem_index) == &DeeMap_DefaultTryGetItemIndexWithEnumerate ? DeeMap_TDefaultTryGetItemIndexWithEnumerate(tp_self, self, index) : \
(tp_trygetitem_index) == &DeeMap_DefaultTryGetItemIndexWithEnumerateDefault ? DeeMap_TDefaultTryGetItemIndexWithEnumerateDefault(tp_self, self, index) : \
default)
Expand Down
2 changes: 1 addition & 1 deletion include/deemon/code.h
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ DeeCode_GetDDIString(DeeObject const *__restrict self, uint16_t id); /* DDI symb
DeeCode_GetDDIString((DeeObject *)Dee_REQUIRES_OBJECT(x), \
((DeeCodeObject *)(x))->co_ddi->d_start.dr_name)

#define DeeDDI_Check(ob) DeeObject_InstanceOfExact(ob, &DeeDDI_Type) /* `_Ddi' is final. */
#define DeeDDI_Check(ob) DeeObject_InstanceOfExact(ob, &DeeDDI_Type) /* `_DDI' is final. */
#define DeeDDI_CheckExact(ob) DeeObject_InstanceOfExact(ob, &DeeDDI_Type)
DDATDEF DeeTypeObject DeeDDI_Type;

Expand Down
4 changes: 2 additions & 2 deletions src/deemon/execute/ddi.c
Original file line number Diff line number Diff line change
Expand Up @@ -737,12 +737,12 @@ PRIVATE WUNUSED NONNULL((1, 2)) dssize_t DCALL
ddi_printrepr(DeeDDIObject *__restrict self,
dformatprinter printer, void *arg) {
(void)self;
return DeeFormat_Printf(printer, arg, "Ddi(TODO)");
return DeeFormat_Printf(printer, arg, "DDI(TODO)");
}

PUBLIC DeeTypeObject DeeDDI_Type = {
OBJECT_HEAD_INIT(&DeeType_Type),
/* .tp_name = */ "_Ddi",
/* .tp_name = */ "_DDI",
/* .tp_doc = */ NULL,
/* .tp_flags = */ TP_FNORMAL | TP_FVARIABLE | TP_FFINAL,
/* .tp_weakrefs = */ 0,
Expand Down
2 changes: 1 addition & 1 deletion src/deemon/execute/dex.c
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ dex_visit(DeeDexObject *__restrict self,

PUBLIC DeeTypeObject DeeDex_Type = {
OBJECT_HEAD_INIT(&DeeType_Type),
/* .tp_name = */ "dex",
/* .tp_name = */ "_DexModule",
/* .tp_doc = */ NULL,
/* .tp_flags = */ TP_FNORMAL | TP_FGC,
/* .tp_weakrefs = */ 0,
Expand Down
7 changes: 4 additions & 3 deletions src/deemon/objects/bool.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ bool_bool(DeeObject *__restrict self) {
}

#if __SIZEOF_INT__ == __SIZEOF_POINTER__
#define bool_hash (*(dhash_t (DCALL *)(DeeObject *__restrict))&bool_bool)
#define bool_hash_PTR ((Dee_hash_t (DCALL *)(DeeObject *__restrict))&bool_bool)
#else /* __SIZEOF_INT__ == __SIZEOF_POINTER__ */
PRIVATE WUNUSED NONNULL((1)) dhash_t DCALL
#define bool_hash_PTR &bool_hash
PRIVATE WUNUSED NONNULL((1)) Dee_hash_t DCALL
bool_hash(DeeObject *__restrict self) {
return DeeBool_IsTrue(self);
}
Expand Down Expand Up @@ -368,7 +369,7 @@ bool_ge(DeeObject *self, DeeObject *other) {
}

PRIVATE struct type_cmp bool_cmp = {
/* .tp_hash = */ &bool_hash,
/* .tp_hash = */ bool_hash_PTR,
/* .tp_compare_eq = */ &bool_compare_eq,
/* .tp_compare = */ &bool_compare,
/* .tp_trycompare_eq = */ NULL,
Expand Down
9 changes: 5 additions & 4 deletions src/deemon/objects/dict.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,9 @@ dict_setitem(Dict *self, DeeObject *key, DeeObject *value);
PRIVATE NONNULL((1)) void DCALL dict_fini(Dict *__restrict self);

#if __SIZEOF_SIZE_T__ == __SIZEOF_INT__
#define dict_insert_sequence_foreach (*(Dee_foreach_pair_t)&dict_setitem)
#define dict_insert_sequence_foreach_PTR ((Dee_foreach_pair_t)&dict_setitem)
#else /* __SIZEOF_SIZE_T__ == __SIZEOF_INT__ */
#define dict_insert_sequence_foreach_PTR &dict_insert_sequence_foreach
PRIVATE WUNUSED NONNULL((1, 2, 3)) Dee_ssize_t DCALL
dict_insert_sequence_foreach(void *arg, DeeObject *key, DeeObject *value) {
return dict_setitem((Dict *)arg, key, value);
Expand Down Expand Up @@ -305,7 +306,7 @@ dict_init_sequence(Dict *__restrict self,
self->d_elem = empty_dict_items;
Dee_atomic_rwlock_init(&self->d_lock);
weakref_support_init(self);
if unlikely(DeeObject_ForeachPair(sequence, &dict_insert_sequence_foreach, self))
if unlikely(DeeObject_ForeachPair(sequence, dict_insert_sequence_foreach_PTR, self))
goto err_self;
return 0;
err_self:
Expand Down Expand Up @@ -2536,7 +2537,7 @@ dict_foreach_pair(Dict *self, Dee_foreach_pair_t proc, void *arg) {
return temp;
}

/* Implemented in `dictproxy.c' */
/* Implemented in `dictproxy.c' */
INTDEF WUNUSED NONNULL((1)) DREF DeeObject *DCALL dict_iter(DeeDictObject *__restrict self);


Expand Down Expand Up @@ -2818,7 +2819,7 @@ dict_mh_popitem(Dict *__restrict self) {

PRIVATE WUNUSED NONNULL((1)) int DCALL
dict_mh_update(Dict *self, DeeObject *items) {
return (int)DeeObject_ForeachPair(items, &dict_insert_sequence_foreach, self);
return (int)DeeObject_ForeachPair(items, dict_insert_sequence_foreach_PTR, self);
}

PRIVATE WUNUSED NONNULL((1)) DREF DeeObject *DCALL
Expand Down
5 changes: 3 additions & 2 deletions src/deemon/objects/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1041,8 +1041,9 @@ PUBLIC WUNUSED NONNULL((1, 2)) int
}

#if __SIZEOF_SIZE_T__ == __SIZEOF_INT__
#define file_printall_sp_foreach_cb (*(Dee_foreach_t)&DeeFile_PrintObjectSp)
#define file_printall_sp_foreach_cb_PTR ((Dee_foreach_t)&DeeFile_PrintObjectSp)
#else /* __SIZEOF_SIZE_T__ == __SIZEOF_INT__ */
#define file_printall_sp_foreach_cb_PTR &file_printall_sp_foreach_cb
PRIVATE WUNUSED NONNULL((2)) Dee_ssize_t DCALL
file_printall_sp_foreach_cb(void *arg, DeeObject *elem) {
return (Dee_ssize_t)DeeFile_PrintObjectSp((DeeObject *)arg, elem);
Expand All @@ -1051,7 +1052,7 @@ file_printall_sp_foreach_cb(void *arg, DeeObject *elem) {

PUBLIC WUNUSED NONNULL((1, 2)) int
(DCALL DeeFile_PrintAllSp)(DeeObject *self, DeeObject *ob) {
return (int)DeeObject_Foreach(ob, &file_printall_sp_foreach_cb, self);
return (int)DeeObject_Foreach(ob, file_printall_sp_foreach_cb_PTR, self);
}

PUBLIC WUNUSED NONNULL((1, 2)) int
Expand Down
5 changes: 3 additions & 2 deletions src/deemon/objects/hashset.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,9 @@ PRIVATE NONNULL((1)) void DCALL
hashset_fini(HashSet *__restrict self);

#if __SIZEOF_SIZE_T__ == __SIZEOF_INT__
#define hashset_insert_sequence_foreach (*(Dee_foreach_t)&DeeHashSet_Insert)
#define hashset_insert_sequence_foreach_PTR ((Dee_foreach_t)&DeeHashSet_Insert)
#else /* __SIZEOF_SIZE_T__ == __SIZEOF_INT__ */
#define hashset_insert_sequence_foreach_PTR &hashset_insert_sequence_foreach
PRIVATE WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL
hashset_insert_sequence_foreach(void *arg, DeeObject *key) {
return DeeHashSet_Insert((DeeObject *)arg, key);
Expand Down Expand Up @@ -270,7 +271,7 @@ hashset_init_sequence(HashSet *__restrict self,
self->hs_elem = empty_hashset_items;
Dee_atomic_rwlock_init(&self->hs_lock);
weakref_support_init(self);
if unlikely(DeeObject_Foreach(sequence, &hashset_insert_sequence_foreach, self) < 0)
if unlikely(DeeObject_Foreach(sequence, hashset_insert_sequence_foreach_PTR, self) < 0)
goto err_self;
return 0;
err_self:
Expand Down
5 changes: 3 additions & 2 deletions src/deemon/objects/rodict.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,9 @@ DeeRoDict_Insert(/*in|out*/ DREF RoDict **__restrict p_self,


#if __SIZEOF_SIZE_T__ == __SIZEOF_INT__
#define DeeRoDict_InsertSequence_foreach (*(Dee_foreach_pair_t)&DeeRoDict_Insert)
#define DeeRoDict_InsertSequence_foreach_PTR ((Dee_foreach_pair_t)&DeeRoDict_Insert)
#else /* __SIZEOF_SIZE_T__ == __SIZEOF_INT__ */
#define DeeRoDict_InsertSequence_foreach_PTR &DeeRoDict_InsertSequence_foreach
PRIVATE WUNUSED NONNULL((2, 3)) Dee_ssize_t DCALL
DeeRoDict_InsertSequence_foreach(void *arg, DeeObject *key, DeeObject *value) {
return DeeRoDict_Insert((RoDict **)arg, key, value);
Expand Down Expand Up @@ -449,7 +450,7 @@ DeeRoDict_FromSequence(DeeObject *__restrict sequence) {
/*result->rd_size = 0;*/
result->rd_mask = mask;
DeeObject_Init(result, &DeeRoDict_Type);
if unlikely(DeeObject_ForeachPair(sequence, &DeeRoDict_InsertSequence_foreach, &result))
if unlikely(DeeObject_ForeachPair(sequence, DeeRoDict_InsertSequence_foreach_PTR, &result))
goto err_r;
}
return (DREF DeeObject *)result;
Expand Down
5 changes: 3 additions & 2 deletions src/deemon/objects/roset.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,9 @@ DeeRoSet_Insert(/*in|out*/ DREF RoSet **__restrict p_self,
}

#if __SIZEOF_SIZE_T__ == __SIZEOF_INT__
#define DeeRoSet_InsertSequence_foreach (*(Dee_foreach_t)&DeeRoSet_Insert)
#define DeeRoSet_InsertSequence_foreach_PTR ((Dee_foreach_t)&DeeRoSet_Insert)
#else /* __SIZEOF_SIZE_T__ == __SIZEOF_INT__ */
#define DeeRoSet_InsertSequence_foreach_PTR &DeeRoSet_InsertSequence_foreach
PRIVATE WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL
DeeRoSet_InsertSequence_foreach(void *arg, DeeObject *elem) {
return DeeRoSet_Insert((RoSet **)arg, elem);
Expand Down Expand Up @@ -345,7 +346,7 @@ DeeRoSet_FromSequence(DeeObject *__restrict sequence) {
/*result->rd_size = 0;*/
result->rs_mask = mask;
DeeObject_Init(result, &DeeRoSet_Type);
if unlikely(DeeObject_Foreach(sequence, &DeeRoSet_InsertSequence_foreach, &result))
if unlikely(DeeObject_Foreach(sequence, DeeRoSet_InsertSequence_foreach_PTR, &result))
goto err_r;
}
return (DREF DeeObject *)result;
Expand Down
Loading

0 comments on commit d3aaa89

Please sign in to comment.