Commit Graph

46 Commits

Author SHA1 Message Date
Enrico Granata
720478bf96 Add a URL case to QuickLookObject
This is to be used by playgrounds to provide a better sidebar representation of web pages than simply showing the URL text

Part of rdar://16799088



Swift SVN r17710
2014-05-08 19:15:36 +00:00
Enrico Granata
46780871a8 Add a separate .Sprite quickLookObject type for SpriteKit objects
We still want to send out image data for those, but UI consumers need to be able to differentiate - should they so desire - a true image from a software sprite rendered in pictorial form

Part of the fix for rdar://16806238



Swift SVN r17471
2014-05-05 18:17:12 +00:00
John McCall
bafeb84a56 Generate unique type metadata for foreign classes.
Swift SVN r17430
2014-05-05 06:45:42 +00:00
Enrico Granata
88e841ce10 Mis-ordering of cases - thanks Joe!
Swift SVN r17391
2014-05-04 18:05:46 +00:00
Enrico Granata
cb53af1bd1 Add a View tag to the QuickLookObject enum
This tag is meant to trade in image data, but be explicit about the fact that this is a "screenshot" of a UI view rather than a plain ol' picture

Fixes the swift library part of rdar://16796532



Swift SVN r17390
2014-05-04 18:03:13 +00:00
Enrico Granata
4fb2175901 The default Mirror implementation used to have a special case for NSString-typed things, such that they would quicklook as their own string data
However, this broke for Swift subclasses of NSString because the Swift mirror took precedence over the ObjC NSString choice
Notably, it broke for NSContiguousString

This patch fixes that by explicitly making NSString reflectable, so that its subclasses will automagically do the right thing here

Fixes rdar://16758974



Swift SVN r17059
2014-04-30 00:06:54 +00:00
Enrico Granata
39a45d8004 Add a custom Mirror for NSRange, and export a Range(UInt64, UInt64) as the quicklook object for it
This is the last chunk of stdlib work for rdar://16681498


Swift SVN r17040
2014-04-29 19:11:07 +00:00
Enrico Granata
9ab5cea296 Add a new case to the QuickLookObject enum: Logical(Bool)
This is meant to represent to UI consumers the notion of a logical truth value
Previously, we were using a String case to represent such values, but that loses potentially useful information to UI layers

This fixes rdar://16719431



Swift SVN r17037
2014-04-29 16:36:40 +00:00
Joe Groff
5c2bd67459 Runtime: Sync QuickLookObject in the runtime with recent stdlib additions.
Swift SVN r16823
2014-04-25 15:00:08 +00:00
Greg Parker
b691055649 Fix an incorrect use of Swift metadata in an ObjC class. Add assertions to
catch such uses in the future.


Swift SVN r16695
2014-04-23 08:55:02 +00:00
John McCall
8681963bcb A couple of long-overdue renames.
Builtin.ObjectPointer -> Builtin.NativeObject
Builtin.ObjCPointer -> Builtin.UnknownObject

Swift SVN r16634
2014-04-22 00:17:08 +00:00
Joe Groff
ebe5f4620c Don't include the module in protocol conformance manglings.
The cost of hacks to swift_conformsToProtocol is starting to outweigh any benefit to being principled here. We'll get a linker error now if multiple modules declare a conformance for the same type to the same protocol, but that's arguably a good thing for 1.0 anyway, since we aren't set up to get that right in other ways.

Swift SVN r16554
2014-04-18 23:13:40 +00:00
Joe Groff
e5bb7741f4 #if out function that's unused without objc ivar introspection.
Swift SVN r16533
2014-04-18 17:23:07 +00:00
Joe Groff
a57e955635 Reflection: Disable visiting objc ivars in the default mirror.
We can't do this reliably without crashing, because framework types often lie about their layout and/or leave junk pointers in ivars.

Swift SVN r16491
2014-04-18 03:22:56 +00:00
Dave Zarzycki
211afa943f Runtime: better crash debugging/reporting
Swift SVN r16426
2014-04-16 21:37:16 +00:00
John McCall
862d50ac1c Change the layout of opaque existentials so that
the value buffer comes first.

The motivation for doing this is similar to the
motivation for moving it for class existentials:
it eliminates the need for an offset for the most
common accesses, which is particularly important
for the generic value witnesses.

Also try to hard-code that layout in fewer places,
or at least static_assert the places that have to
do so.

Swift SVN r16279
2014-04-13 07:43:08 +00:00
Joe Groff
d1121a3d86 Reflection: Blacklist NSURL from default mirror functionality.
Its layout information in the ObjC runtime is a complete lie, so we crash if we try to use it to introspect the object. Fixes <rdar://problem/16592777>.

Swift SVN r16228
2014-04-11 21:05:34 +00:00
Joe Groff
f57de31a04 Reflection: Quell some build warnings.
Swift SVN r16172
2014-04-10 22:35:35 +00:00
Joe Groff
3455688cd1 Reflection: Resize our stub Array type.
The new Array is one word, not three. Fixes <rdar://problem/16533371>.

Swift SVN r15993
2014-04-06 01:36:16 +00:00
Joe Groff
18f6e950a6 Reflection: Look through existential containers.
When we reflect an existential container, reflect the contained value as its dynamic type. Implements <rdar://problem/16427022>.

Swift SVN r15952
2014-04-04 20:16:47 +00:00
John McCall
f1180f5e6d in order to work correctly for non-@objc protocols.
Language features like erasing concrete metatype
values are also left for the future.  Still, baby steps.

The singleton ordinary metatype for existential types
is still potentially useful; we allow it to be written
as P.Protocol.

I've been somewhat cavalier in making code accept
AnyMetatypeType instead of a more specific type, and
it's likely that a number of these places can and
should be more restrictive.
When T is an existential type, parse T.Type as an
ExistentialMetatypeType instead of a MetatypeType.

An existential metatype is the formal type
 \exists t:P . (t.Type)
whereas the ordinary metatype is the formal type
 (\exists t:P . t).Type
which is singleton.  Our inability to express that
difference was leading to an ever-increasing cascade
of hacks where information is shadily passed behind
the scenes in order to make various operations with
static members of protocols work correctly.

This patch takes the first step towards fixing that
by splitting out existential metatypes and giving
them a pointer representation.  Eventually, we will
need them to be able to carry protocol witness tables

Swift SVN r15716
2014-04-01 00:38:28 +00:00
Joe Groff
f2ed6dd49b Reflection: Add additional dispositions and an 'AttributedString' QuickLookObject case.
<rdar://problem/16412965> and <rdar://problem/16413366>.

Swift SVN r15438
2014-03-25 02:55:20 +00:00
Joe Groff
002701fd77 Reflection: Implement magic mirror destructuring for classes.
Destructure classes by counting their superclass instance, if any, as their first child, followed by their stored properties.

Swift SVN r15268
2014-03-20 17:43:16 +00:00
Joe Groff
a9c2a7d5b8 Reflection: Implement a magic mirror for structs.
Use the newly-minted field type vector accessors to provide magic mirror destructuring for all structs!

Swift SVN r15261
2014-03-20 02:41:07 +00:00
Joe Groff
c76cb6f6db Reflection: Have 'QuickLookObject.Int' take an Int64, and add a UInt(UInt64) case.
So we can accurately represent all common integer types.

Swift SVN r15237
2014-03-19 15:31:52 +00:00
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