Data reflection metadata?


(Jens Alfke) #1

In a recent-ish post on swift-evolution <https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160926/027337.html>, Chris Lattner mentioned:

…the extensive work on data reflection metadata that was put into Swift 3. It is key to enabling the Xcode 8 memory visualization / debugger feature, and is a fundamental building block for a data reflection API. In fact, if I recall correctly, a 3rd party framework already build a custom data reflection API around this metadata already (Zewo?).

Could someone point to some info about this? I’m very interested in it.

(I did look up Zewo — a server-side Swift web framework — but didn’t see anything relevant in it, so Chris may have been thinking of another project.)

—Jens

PS: I’m posting here and not swift-evolution because (a) I don’t subscribe to that list, and (b) this is apparently stuff that exists right now, not in the future.


(Austin Zheng) #2

You probably want to check out this repo: https://github.com/Zewo/Reflection

It's clever stuff. Really, really reliant on implementation details of the runtime to function, so I'd be loathe to use it in any sort of production application, but as a proof of concept it shines.

Hope that helps,
Austin

···

On Oct 13, 2016, at 9:13 AM, Jens Alfke via swift-users <swift-users@swift.org> wrote:

In a recent-ish post on swift-evolution <https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160926/027337.html>, Chris Lattner mentioned:

…the extensive work on data reflection metadata that was put into Swift 3. It is key to enabling the Xcode 8 memory visualization / debugger feature, and is a fundamental building block for a data reflection API. In fact, if I recall correctly, a 3rd party framework already build a custom data reflection API around this metadata already (Zewo?).

Could someone point to some info about this? I’m very interested in it.

(I did look up Zewo — a server-side Swift web framework — but didn’t see anything relevant in it, so Chris may have been thinking of another project.)

—Jens

PS: I’m posting here and not swift-evolution because (a) I don’t subscribe to that list, and (b) this is apparently stuff that exists right now, not in the future.
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


(Joe Groff) #3

https://github.com/apple/swift/blob/master/tools/swift-reflection-test
https://github.com/apple/swift/tree/master/tools/swift-reflection-dump

-Joe

···

On Oct 13, 2016, at 9:19 AM, Austin Zheng via swift-users <swift-users@swift.org> wrote:

You probably want to check out this repo: https://github.com/Zewo/Reflection

It's clever stuff. Really, really reliant on implementation details of the runtime to function, so I'd be loathe to use it in any sort of production application, but as a proof of concept it shines.

From what I've seen, they're groveling our runtime metadata records, which are definitely subject to change without notice. I wouldn't recommend following their example, since we actively want to change the layout of things they're hardcoding. What Chris was referring to was the "remote mirror" library, which is used to support the Xcode 8 memory debugger, and is also in the long-term what we want to migrate in-process reflection facilities like the Mirror type to. The `swift-reflection-test` and `swift-reflection-dump` tools in the Swift compiler codebase might help give you a sense of what's currently available: