Skip to content

refactor: use type data#499

Merged
qqfunc merged 8 commits intomainfrom
refactor/type-data
Apr 25, 2026
Merged

refactor: use type data#499
qqfunc merged 8 commits intomainfrom
refactor/type-data

Conversation

@qqfunc
Copy link
Copy Markdown
Owner

@qqfunc qqfunc commented Apr 25, 2026


📚 Documentation preview 📚: https://objctypes--499.org.readthedocs.build/en/499/

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the Objective-C wrapper types to use CPython “type data” (negative PyType_Spec.basicsize + PyObject_GetTypeData) instead of dedicated ObjC*Object C structs and per-type headers.

Changes:

  • Move wrapper payload fields (e.g., SEL, id, Method, Class, BOOL) into ObjC*Data type-data structs and update implementations to read/write via PyObject_GetTypeData.
  • Simplify cache APIs to return/accept PyObject* rather than per-type ObjC*Object* pointers.
  • Remove now-redundant per-type headers (objcbool.h, objcclass.h, etc.) and consolidate relevant declarations in objctypes_module.h.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
csrc/objctypes_module.h Adds ObjC*Data structs + PyType_Spec externs; adjusts module-state layout and includes runtime types.
csrc/objctypes_cache.h Removes per-type includes; updates cache function signatures to PyObject* (but introduces a duplicate prototype issue).
csrc/objctypes_cache.cc Adapts cache implementation to store/return PyObject* without per-type casts/includes.
csrc/objctypes.c Removes includes of deleted per-type headers; relies on consolidated declarations.
csrc/objcbool.c Switches ObjCBool storage to type data.
csrc/objcclass.c Switches ObjCClass storage to type data; adjusts construction/caching logic.
csrc/objcmetaclass.c Switches ObjCMetaClass storage to type data.
csrc/objcmethod.c Switches ObjCMethod storage to type data.
csrc/objcobject.c Switches ObjCObject storage to type data and updates cache interactions.
csrc/objcselector.c Switches ObjCSelector storage to type data and updates cache interactions.
csrc/objcbool.h Deleted (definitions replaced by type-data approach).
csrc/objcclass.h Deleted (definitions replaced by type-data approach).
csrc/objcmetaclass.h Deleted (definitions replaced by type-data approach).
csrc/objcmethod.h Deleted (definitions replaced by type-data approach).
csrc/objcobject.h Deleted (definitions replaced by type-data approach).
csrc/objcselector.h Deleted (definitions replaced by type-data approach).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread csrc/objcselector.c
Comment thread csrc/objcobject.c
Comment thread csrc/objcclass.c
Comment thread csrc/objcclass.c
Comment thread csrc/objcclass.c
Comment thread csrc/objcobject.c
Comment thread csrc/objctypes_cache.h
Comment thread csrc/objcclass.c
Comment thread csrc/objcselector.c Outdated
Comment thread csrc/objcselector.c
@qqfunc qqfunc merged commit 998ba5b into main Apr 25, 2026
4 checks passed
@qqfunc qqfunc deleted the refactor/type-data branch April 25, 2026 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants