Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Root Classes #4

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Support Root Classes #4

wants to merge 5 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Sep 29, 2010

These changes are rather extensive, and change some return types and semantics, breaking backward compatibility.

Why did RTMethodSendingAdditions called the rt_class method instead of the NSObject's class method?

Randy Becker added 5 commits September 28, 2010 22:26
These changes started out as something simple: get an NSArray with the
root classes.  Unfortunately, collections, including NSArray, crash if
they can't call -retain on their contents, so you can't make an NSArray
of the root classes, because some of them do not implement the NSObject
protocol. rdar://8487380  This is a not an issue in a garbage-collected
environment, since objc_msgsend() eats calls to -retain, but we clearly
need to support non-garbage-collected runtimes.

So, we need a wrapper for the Class type.  Then, the issue was what to
do about metaclasses.  Even the C API seems to be of two minds about
the degree to which metaclasses are an implementation detail, e.g.
there are separate class_getClass*() and classGetInstance*() functions,
but only one class_copy*List(), which only returns things defined on
the normal class, not the metaclass.  I talked with @rentzsch and
@jemmons, and we agreed that Objective-C coders, even if they know
about metaclasses, don't think in terms of them, e.g. there is *one*
conceptual NSObject class, and it has both instance and class methods.
These changes both make the runtime wrapper more and less true to the
underlying API.  Most importantly, they introduce a new RTClass class
that wraps Class types.  While you can get away with treating a Class
like an Objective-C object, they are distinct structs in the headers.

These changes also enable you to more easily manipulate root classes,
including those that don't inherit from NSObject, e.g. NSProxy.  They
even help with those that don't conform to the NSObject protocol, e.g.
NSMessageBuilder, NSZombie, and Object.
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.

0 participants