Skip to content
This repository was archived by the owner on Dec 5, 2019. It is now read-only.

Conversation

@woolsweater
Copy link

The new macro allows forwarding of a specified property to a property on another class. This commit includes tests for the new macro, and a doc string.

This necessitated some small changes to the existing internal passthrough_ macro; in particular, a SEL_GETTER must be passed in — this is @selector() when the method name is specified literally, but sel_getUid() for properties, because the property’s accessor method names must be looked up at runtime. The lookup is implemented by two helper functions, which are in EXTRuntimeExtensions. I considered macro-generated functions to cache the accessor names, but it seemed more trouble than it was worth.

This commit is intended to resolve #5. It does so by inserting an @dynamic directive for the named property. This comes with the hitch that both the @property declaration and the @passthrough_property must be in the same "segment" of the class definition -- either the same category, or in the main @interface/@implementation blocks.

@jspahrsummers
Copy link
Owner

Thanks for submitting this! I'm interested to take a look, but libextobjc's experimental branch is honestly kinda low on my list of priorities.

I'll try to get around to it eventually. It's certainly awesome to see someone else hacking on it. 🌟

@woolsweater
Copy link
Author

For sure! Somebody pointed this library out to me a month or two ago, and it seemed like exactly the kind of runtime hacking that I enjoy, so I just looked around for an issue to work on.

Hope it fits the bill whenever you get around to reviewing it, but I'm happy to make changes if necessary too.

… property to a property on another class, along with tests and doc string.

This necessitated some small changes to the existing passthrough_ macro; in particular, a SEL_GETTER must be passed in — this is @selector when the method name is specified literally, but sel_getUid() for properties. A property’s accessor methods must be looked up at runtime. The lookup is implemented by two helper functions, which are in EXTRuntimeExtensions

This commit is intended to resolve jspahrsummers#5.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants