Commit Graph

71 Commits

Author SHA1 Message Date
Joe Groff
dcd47ec879 Reflection: Add QuickLookObject tags for ints and floats.
Playgrounds want to be able to represent numbers different from strings, so provide different tags for types that represent numbers distinct from strings. Set up the Int and Double mirrors to return quick look objects of the appropriate cases, and hook up the magic ObjC mirror to do the same for NSNumbers. <rdar://problem/16360758>

Swift SVN r15219
2014-03-19 02:27:22 +00:00
Joe Groff
589fe7f930 Reflection: Move the less magic parts into Swift.
Only the bits that actually need to grovel metadata really need to be written in C++, so define away hopefully most of the potential for memory safety or corruption bugs from screwing up calling convention matchups by moving most of the magic mirror implementations into pure Swift.

Swift SVN r15180
2014-03-18 01:12:30 +00:00
Joe Groff
3827f6b1af Reflection: Set the metadata of default ObjC quicklook object Anys correctly.
We want the metadata of the ObjC class, not the opaque Builtin.ObjCPointer metadata. This allows the Any to actually be downcast to an expected type on the client side.

Swift SVN r15009
2014-03-13 21:59:44 +00:00
Joe Groff
75da504b42 Reflection: Add more cases to QuickLookObject.
Add 'Sound', 'Color', and 'BezierPath', as requested by Enrico, as well as a '_Raw' case that can be used for internal experimentation.

Swift SVN r14978
2014-03-12 22:42:27 +00:00
Joe Groff
6c576f110b Hide the implementation details of String from MagicMirror.
NFC, just reduce the possibility of forming Strings without going through a stdlib-approved interface.

Swift SVN r14977
2014-03-12 22:42:26 +00:00
Greg Parker
f9d2685a2e Correct a range check. Fix some build warnings.
Swift SVN r14920
2014-03-11 16:04:14 +00:00
Joe Groff
0c55845cc1 Replace Greg's r14771 with a slightly less outrageous hack.
Implicit conversions to and from an unsigned long long enum class give us the calling convention we want for swift_allocBox without totally destroying the API for C callers.

Swift SVN r14919
2014-03-11 16:01:13 +00:00
Joe Groff
2f720aebdb Reflection: Add a 'disposition' property to Mirror.
Playgrounds want to present aggregate-like values with fixed children, such as structs and classes, differently from container-like values with variable amounts of children, like arrays and dictionaries, so add a property to Mirror that describes the disposition of the value being reflected.

Swift SVN r14827
2014-03-08 05:37:56 +00:00
Greg Parker
338cb2b718 Add an outrageous hack to swift_allocBox() to fix arm (rdar://16257592).
Swift SVN r14771
2014-03-07 05:37:14 +00:00
Joe Groff
7405f4bc77 Runtime: Fix layout of Optional<QuickLookObject> to match Swift's.
Damn tail-alignment. Try a little harder to test quickLookObject on the Swift side too.

Swift SVN r14760
2014-03-06 22:56:17 +00:00
Joe Groff
76870a7a8f Reflection: Try an ObjC object as its own debugQuickLookObject.
If the object doesn't respond to -debugQuickLookObject, check if the object itself is a quick look object.

Swift SVN r14673
2014-03-05 05:34:52 +00:00
Joe Groff
024b5c0542 runtime: Use -debugQuickLookObject to get text or image quick look objects.
In response to feedback from the Xcode team, change the 'IDERepresentable' type from a protocol into an enum with a limited set of tags, starting with 'Text' and 'Image' for now. In the ObjC mirror, if the ObjC object has a -debugQuickLookObject method, use it to get an object we can try to map to the enum.

Swift SVN r14632
2014-03-04 04:56:54 +00:00
Joe Groff
c752d4e806 runtime: Include the superclass as a child when reflecting ObjC classes.
And stop walking Classes as regular objects—the "isa" chain just noises up the object graph.

Swift SVN r14631
2014-03-04 03:54:32 +00:00
Joe Groff
5af4e7255b Runtime: Start implementing a default Mirror for ObjC classes.
For ObjC classes, use class_copyIvarList to walk the ivars, and produce the summary string using -debugDescription. Still to come:

- visiting the base class as a child, and
- calling -debugQuickLookObject to get the quicklook object. Still waiting on a final design for the IDERepresentation API.

Swift SVN r14626
2014-03-04 01:42:19 +00:00
Joe Groff
eafc9ef137 Runtime: Have MagicMirror produce object identifiers for class values.
Swift SVN r14608
2014-03-03 21:20:05 +00:00
Joe Groff
98d6fecc99 '.metatype' -> '.Type'
Also, reserve 'type' as a keyword for ensuing syntax changes.

Swift SVN r14375
2014-02-26 04:23:21 +00:00
Dave Zarzycki
a85b2a3d78 Runtime: Rename Alloc.* to HeapObject.* (NFC)
Swift SVN r14228
2014-02-21 20:12:07 +00:00
Joe Groff
56d4f3ef40 runtime: Feed strings back into Swift through a DaveA-certified interface.
Swift SVN r14209
2014-02-21 16:19:26 +00:00
Joe Groff
3c15aff85b Expose unsafeReflect to the stdlib.
A useful unsafe optimization for potential implementations of Mirror that have existing heap storage to share from the value, like for Array or Dictionary.

Swift SVN r14186
2014-02-21 00:09:32 +00:00
Joe Groff
67205668ae runtime: Implement tuple destructuring in the default mirror.
Not quite ready for prime-time. This leaks memory for want of a proper way to copy a C string into a Swift String.

Swift SVN r14168
2014-02-20 21:19:11 +00:00
Joe Groff
73e564428f stdlib/runtime: Stub out a mechanism for introspecting value structure.
Define a "Mirror" protocol with methods for querying the number of children a structured value has, getting the name and mirror for each of those children, and a string and "IDE representation" of the value, as needed by playgrounds and by our planned generic printing facility.

In the runtime, define a "reflect" function that can provide a Mirror for any object, either using a "Reflectable" protocol conformance if available, or falling back to a magic implementation in the runtime that grovels the type metadata. Stub out a bare minimum default implementation.

Swift SVN r14139
2014-02-20 08:26:27 +00:00