Commit Graph

21434 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
Dave Abrahams
f465e34f88 [stdlib] Generate NSDictionaryBase
We'll need to apply the same tricks we're using for Array to Dictionary
and String, so prepare to generate base classes for those buffers as
well.  Actually generate and use the one for Dictionary, but don't
actually bridge it yet.

Swift SVN r15167
2014-03-17 23:12:19 +00:00
Dave Abrahams
d016db3285 [stdlib] Factor common non-ObjC instance members
Make sure that if the object layout changes, we don't have to update the
stdlib in too many places.

Swift SVN r15166
2014-03-17 23:12:18 +00:00
John McCall
40be8390c3 Factor BlockShims.mm to make it easier to change the
mangling of imported ObjC pointer types.

Swift SVN r15130
2014-03-17 07:02:00 +00:00
Dave Zarzycki
b8d736ffc7 stdlib: NSSwiftArrayBase magic
Swift SVN r15086
2014-03-14 22:34:46 +00:00
Dave Abrahams
bfc6cfa5b6 [stdlib] Give Array bridging a home of its own
Also create a simple NSSwiftArray class that DaveZ can use to test our
bridging strategy.

Swift SVN r15081
2014-03-14 22:07:14 +00:00
Dave Zarzycki
49bee35d1a Runtime: magic numbers are bad
Swift SVN r15012
2014-03-13 23:15:07 +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
Dave Zarzycki
1ef22d5e03 Runtime: make the thread-specific logic work with the public SDK
Swift SVN r15007
2014-03-13 21:32:45 +00:00
Dave Zarzycki
dbd1c1a2bf Runtime: zap dead code
Swift SVN r15005
2014-03-13 21:21:13 +00:00
Jordan Rose
5509605e1d Add a void(^)(NSError*, NSString*) block shim.
Requested by Beto in <rdar://problem/16306097>.

Swift SVN r14986
2014-03-13 00:41:55 +00:00
Dave Abrahams
0aa818f680 [stdlib] Delete obsolete verification functions
These functions were used for runtime assertions that are now being
checked at compile-time.

Swift SVN r14983
2014-03-12 23:59:46 +00:00
Dave Abrahams
6eee8e3205 Move HeapObject into the stdlib shim module
Now that we can read definitions directly from "C" headers, stop trying
to maintain a mirror of the HeapObject struct in Swift code in the
standard library.

Swift SVN r14982
2014-03-12 23:48:31 +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
Jordan Rose
db31ad6b68 [CMake] Add the shims headers as sources for the copy_shim_headers target.
This makes them show up in Xcode.

Swift SVN r14970
2014-03-12 22:17:04 +00:00
Jordan Rose
27d1746467 [CMake] Move the install command for the Clang headers to the shims target too.
For consistency with r14968.

Swift SVN r14969
2014-03-12 22:17:02 +00:00
Jordan Rose
1c4d9b78a4 [CMake] Symlink Clang's headers into lib/swift as part of copy_shim_headers.
Turns out CMake's PRE_BUILD mode for custom commands doesn't work with the
Ninja or Makefile generators (not sure about Xcode). Just do it as part of
an earlier target instead.

Swift SVN r14968
2014-03-12 22:11:26 +00:00
Jordan Rose
0704b7910e Try #include <stdint.h> in shims.h again.
I can't reproduce the failure locally, so I'm going to poke at this on the
buildbot.

Swift SVN r14965
2014-03-12 20:34:11 +00:00
Dave Abrahams
01f4b6d901 [stdlib] Un-revert r14943: "Use the shims module to bridge NewArray"
[This time, shims.h doesn't depend even on a system header; hopefully the
'bot will be happy enough with that until someone fixes the build system
to allow "#include <stdint.h>" to appear in shims.h]

Now we can essentially send an NSRange instance in a message to a
CocoaArray without having loaded foundation.

Swift SVN r14957
2014-03-12 13:08:45 +00:00
Dave Zarzycki
93ac98dfaf Revert r14943: "[stdlib] Use the shims module to bridge NewArray"
Swift SVN r14953
2014-03-12 07:00:27 +00:00
Dave Abrahams
6e409e2a50 [stdlib] Use the shims module to bridge NewArray
Now we can essentially send an NSRange instance in a message to a
CocoaArray without having loaded foundation.

Swift SVN r14943
2014-03-12 00:44:03 +00:00
Dave Abrahams
a73102e9cc [stdlib] Flesh out SwiftShims' build dependencies
Also put a pretty line in CMake output when the shim module is copied

Swift SVN r14942
2014-03-12 00:44:02 +00:00
Ted Kremenek
a31041f9f1 Placate -Wunreachable-code by using #else for alternative code.
Swift SVN r14929
2014-03-11 21:51:50 +00:00
Dave Zarzycki
cde57afc89 stdlib: do not forward malloc_size()
malloc_size() also is used to determine which zone owns a given allocation.

<rdar://problem/16293435> malloc_size is getting called recursively

Swift SVN r14928
2014-03-11 21:48:14 +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
Dave Abrahams
a398607c43 [build] Evil hack to make Make make
CMake's Makefile generator is not very smart about sibling dependencies,
apparently.  See the comment in the commit for more details.

Swift SVN r14909
2014-03-11 05:56:09 +00:00
Dave Abrahams
38f68fcba4 [build] stdlib core depends on SwiftShims
We need to make sure the core standard library is rebuilt when the shims
header changes.

Swift SVN r14906
2014-03-11 03:22:12 +00:00
Jordan Rose
cdcaa4bdc1 [PrintAsObjC] Remove "Swift" prologue module for generated headers.
All of that has been folded into the headers themselves.

Swift SVN r14894
2014-03-10 23:47:25 +00:00
Jordan Rose
dbf3c64b28 Revert "[CMake] Clear the Clang module cache before building the ObjectiveC overlay."
This broke systems where it isn't appropriate to clear the module cache.
The build script already does this when you do a full build; for other
cases, we should just deal with it. (You can still specify a custom
MODULE_CACHE_PATH to make it easier to delete, rather than relying on the
system one.)

This reverts commit r14364.

<rdar://problem/16232176>

Swift SVN r14872
2014-03-10 18:01:01 +00:00
Dave Abrahams
91bed93ca5 stdlib: add a stub ObjC root class to force correct bookkeeping in the compiler
Swift SVN r14864
2014-03-10 07:46:03 +00:00
Dave Abrahams
7a91b9f749 [stdlib] Remove *, /, and % from RandomAccessIndex
Before this commit, RandomAccessIndex was a refinement of
NumericOperations, which forced it to support inappropriate operations
such as multiplication.  Many obvious random-access index types can't
support multiplication (e.g. a StridedIndex adapter, which moves its
underlying index by N positions for each increment).

Along the way:

* the addition and subtraction operations on RandomAccessIndex were
  renamed to advancedBy and distanceTo, which prevents nasty ambiguities
  when a type conforms to both RandomAccessIndex and Integer, and allows
  Index DistanceTypes to actually be signed integers even when the Index
  is unsigned.

* Before this commit, using internal interfaces, it was possible to
  request static checking without also getting dynamic checks when
  static checking is impossible.  Now the relationship between static
  and dynamic checking is built into the core protocols.

* NumericOperations.swift was moved into IntegerArithmetic.swift.gyb,
  correcting missing operators by generating them programmatically and
  in preparation for renaming the protocol to something more appropriate

Fixes

  <rdar://problem/16246927> RandomAccessIndex is over-constrained

and possibly:

  <rdar://problem/15605729> Make all operators generic over
  protocols (in particular, get NumericOperations done)

Swift SVN r14854
2014-03-09 19:56:18 +00:00
Dave Abrahams
469f8629c6 [stdlib] OpaqueString is still an essential source
Swift SVN r14852
2014-03-09 19:56:16 +00:00
Dave Abrahams
6732cc1c4d [stdlib] Bugfix for essential sources check
I was using the wrong variable name in CMakeLists.txt

Swift SVN r14851
2014-03-09 19:56:15 +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
Dave Abrahams
0ec3ead12b [stdlib] Link an essential core library subset
To support layering improvements, add an (optionally built) "essential
core" library containing the minimum set of files required just to link
successfully.  Right now all those object files are linked again into
swift_stdlib_core; it would probably be better to link the essential
core into the core, but my CMake/Swift Driver fu is not strong enough
and this will at least help during development.

Along the way, removed the obsolete SwiftStdlibSources.txt file, as we
only have to support one build system now.

Swift SVN r14792
2014-03-07 21:01:49 +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
da7880b0e4 Drop unnecessary 'swift_compareObjects' and 'swift_hashObject' stubs.
Swift SVN r14769
2014-03-07 03:21:32 +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
3d93acb81b stdlib: Remove the 'Object' class.
It's dead, Jim. Also remove 'ClassNameable' since we don't use it for anything.

Reapply r14647 now that John fixed the serialization issue that scuttled it last time.

Swift SVN r14722
2014-03-06 04:53:25 +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
Chris Lattner
d758e0dfe3 Eliminate more "DynamicLookup" in favor of "AnyObject", this is the
bulk of finishing rdar://13327098.


Swift SVN r14653
2014-03-04 22:15:46 +00:00
Dave Abrahams
b0b08887e1 [stdlib] Remove unused BridgeObjectiveC.mm
Swift SVN r14652
2014-03-04 21:19:53 +00:00
Joe Groff
c572cc222c Revert "stdlib: Push '===' for AnyObject into stdlib/core."
This reverts commit r14646. It exposes an optimizer bug.

Swift SVN r14649
2014-03-04 17:39:15 +00:00
Joe Groff
565f889fe8 Revert "stdlib: Remove the 'Object' class."
This reverts commit r14647. It exposes an optimizer bug.

Swift SVN r14648
2014-03-04 17:39:06 +00:00
Joe Groff
59426904e2 stdlib: Remove the 'Object' class.
It's dead, Jim. Also remove 'ClassNameable' since we don't use it for anything.

Swift SVN r14647
2014-03-04 17:14:27 +00:00
Joe Groff
5634ff5e67 stdlib: Push '===' for AnyObject into stdlib/core.
And drop the 'Identifiable' protocol.

Swift SVN r14646
2014-03-04 17:04:50 +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