Commit Graph

431 Commits

Author SHA1 Message Date
Dave Abrahams
f78b6b125a [stdlib] Conversions to String.Index
Also, hide an initializer on String.Index that was unintentionally
public/visible by giving it an underscored keyword argument.

Testing comes next.

Swift SVN r24069
2014-12-22 15:30:56 +00:00
Dmitri Hrybenko
4f819a9cf7 Remove an NSSet.copyObjectPointers() API that was unintentionally added
Swift SVN r24054
2014-12-20 03:01:34 +00:00
Chris Lattner
b8596ffccb move the stdlib to the new syntax for @autoclosure attribute.
Swift SVN r24048
2014-12-20 00:16:36 +00:00
Dave Abrahams
39efbb5e17 [stdlib] Add a comment
Swift SVN r23948
2014-12-15 22:24:30 +00:00
Dmitri Hrybenko
e87bcff79d stdlib: move String.{lowercaseString,uppercaseString} to the core
library

Swift SVN r23936
2014-12-15 09:47:03 +00:00
Dmitri Hrybenko
397d2fb8c3 stdlib: coding style: when colon specifies is-a relationship, we put
spaces on both sides of it

Swift SVN r23935
2014-12-15 06:55:30 +00:00
Dave Abrahams
9550c02956 [stdlib] String.UTF16View.Index is bidirectional
Rather than expose random access on String.UTF16View to all Swift users,
expose it only when Foundation is loaded.  This effectively decouples
String from a UTF16 representation on non-Mac platforms.

Swift SVN r23929
2014-12-14 17:11:04 +00:00
Joe Groff
cf49e3be1e Fix multi-SDK build for GLKit.
Swift SVN r23898
2014-12-12 22:32:18 +00:00
Joe Groff
a60ae8b8e3 stdlib GLKit overlay: Tweak for better consistency with C interface.
GLKVector2 doesn't have 'r' or 'g' components, unlike the longer vector types, and GLKQuaternion has 'x', 'y', 'z', and 'w' components. Thanks Jordan for pointing these out.

Swift SVN r23895
2014-12-12 21:23:12 +00:00
Joe Groff
1c1535fbcb stdlib: Add an overlay to GLKit with projection accessors.
We can access pretty much all of the GLKit functions now, but still lacked accessors for the individual elements. gyb up some accessors to do dirty bitcasting tricks to expose the elements of GLKVectorN, GLKMatrixN, and GLKQuaternion values.

Swift SVN r23892
2014-12-12 19:19:31 +00:00
Maxwell Swadling
c889977b52 [stdlib] Makes NSSet and NSOrderedSet ArrayLiteralConvertible
Fixes rdar://problem/14661748
Also adds missing SequenceType to NSOrderedSet

Swift SVN r23863
2014-12-11 19:11:37 +00:00
Maxwell Swadling
74aa8b1a3c [stdlib] added safe unchecked comment
Swift SVN r23862
2014-12-11 18:52:21 +00:00
Maxwell Swadling
528661c212 [stdlib] Removed checks in {lower,upper}caseStirng
Swift SVN r23747
2014-12-06 00:01:13 +00:00
Maxwell Swadling
5d01edbb90 [stdlib] clarified comments for ASCII case tables
Swift SVN r23738
2014-12-05 17:47:47 +00:00
Joe Groff
e6d97e8de7 Clang importer: Add a zeroing default initializer to imported structs.
If an imported C struct has no __nonnull pointer fields, then we can give a default initializer that zeroes all of its fields. This becomes a requirement when working with partially-imported types like NSDecimal. NSDecimal has bitfields Swift can't see yet, so it's impossible to DI, but the Foundation functions that work with NSDecimal all emit their result by out parameter, and without access to its fields it is impossible to initialize an NSDecimal for use with one of these functions. Implement the initializer using a builtin that gets lowered by IRGen; this is also made necessary by the fact that Swift has only a partial view of the struct, so we can't form a complete zero initializer until we have the definitive type layout from Clang.

Swift SVN r23727
2014-12-05 05:31:22 +00:00
Maxwell Swadling
77cd08d3ae [stdlib] removed branch in ASCII {upper,lower}casestring
Swift SVN r23706
2014-12-05 00:24:38 +00:00
David Farler
e7506e8eab Remove underscore from _Set<T>
rdar://problem/19132138

Make Set<T> visible by removing the underscore. Also, remove the pesky
${_Self} gyb variable that was for a temporary convenience in hiding Set.

Swift SVN r23699
2014-12-05 00:21:35 +00:00
Maxwell Swadling
1e4b0393f7 [stdlib] Added NSEnumerator to SequenceType
Fixes rdar://problem/17925006

Swift SVN r23497
2014-11-21 00:33:26 +00:00
Maxwell Swadling
530ae1777a Added ASCII fast paths for common string operations
- ==, <, lowercaseString and uppercaseString on String now have ASCII fast paths
- Fixes rdar://problem/17962640

Swift SVN r23494
2014-11-21 00:07:32 +00:00
Maxwell Swadling
d5c6534b1c Removed unnecessary unsafeBitCast
Swift SVN r23386
2014-11-17 21:35:33 +00:00
David Farler
d0718c69fc Prefix Set<T> with underscore for API development
Swift SVN r23263
2014-11-12 07:07:01 +00:00
David Farler
c453eb4c48 Add Set type.
<rdar://problem/14661754> TLF: [data-structure] Set<T> data type + Bridging from NSSet

Swift SVN r23262
2014-11-12 07:07:00 +00:00
Dmitri Hrybenko
75876f531a XCTest: silence the warning about accessing a property that is not declared
Patch by Chris Hanson.

Swift SVN r23248
2014-11-11 22:19:48 +00:00
Maxwell Swadling
e7995d2946 [stdlib] simplified implementation of init(objects elements: AnyObject...)
Swift SVN r23217
2014-11-11 00:24:23 +00:00
Doug Gregor
3df2c11c8a Diagnose Objective-C method overrides not reflected as Swift overrides.
Diagnose cases where the use of @objc will produce Objective-C methods
that end up overriding an Objective-C method in a superclass, when
that override is not properly represented as an override in the Swift
type system. This can happen when the Objective-C methods are produced
by different kinds of entities. For example:

  class Super {
    @objc var property: Int
  }

  class Sub : Super {
    @objc func setProperty(property: Int) { }
  }

In Swift, Sub.setProperty and Super.property are completely
unrelated. However, both produce an Objective-C instance method with
the selector "setProperty:", so we end up with unexpected overriding
behavior. Diagnose this whenever it occurs, regardless of the kind of
@objc entity that produced the Objective-C methods: initializers,
deinitializers, methods, properties, or subscripts.

Implements the rest of the intended functionality of
rdar://problem/18391046, with the caveat that there are two remaining
classes of bugs:
  1) Superclasses defined in a module (or imported from a Clang
  module) aren't handled properly yet; we might not see those methods.
  2) We won't properly detect all of these failures when the methods
  are scattered across different source files in the same module.

Swift SVN r23170
2014-11-08 00:55:45 +00:00
Chris Willmore
2c3e5d0073 Add missing keyword argument following changes for rdar://problem/18778670
Swift SVN r23095
2014-11-04 03:55:22 +00:00
Dmitri Hrybenko
741ba42144 Simplify XCTest CMake code
Swift SVN r23054
2014-11-01 02:52:14 +00:00
Dave Abrahams
d2a7b58f03 [stdlib] Remove all FIXMEs from doc comments
Fixes <rdar://problem/18457701>

Swift SVN r23007
2014-10-29 19:35:25 +00:00
Dave Abrahams
44c0ab4385 [stdlib] Internal protocol renaming
for consistency with earlier moves on NSArray shadow protocols

Swift SVN r22908
2014-10-24 15:48:44 +00:00
Dave Abrahams
ebde372ef9 [stdlib] Add space to Core Graphics type printing
Core Graphics mirrors were emitting textual representations without
spaces following commas separating values.  This commit fixes that
issue.

Swift SVN r22897
2014-10-23 20:50:09 +00:00
Arnold Schwaighofer
f88190ab8b Reapply "stdlib: libm's sqrt and llvm.sqrt are not semantically equivalent""
This reapplies commit r22864 - it is not changing the public api as we initially
thought. sqrt() was never available without importing Darwin.

This change only changes where sqrt() gets "forwarded" to. Before 'sqrt' called
the builtin '_sqrt' defined in BuiltinMath now it just calls the math library's
'sqrt' function.

I also added a stdlib test.

rdar://18371371

Swift SVN r22870
2014-10-21 23:52:37 +00:00
Arnold Schwaighofer
d95b9c9ab8 Revert "stdlib: libm's sqrt and llvm.sqrt are not semantically equivalent"
This reverts commit 22864. The change is under discussion.

Swift SVN r22865
2014-10-21 17:46:24 +00:00
Arnold Schwaighofer
b0e5358624 stdlib: libm's sqrt and llvm.sqrt are not semantically equivalent
llvm.sqrt(-1.0) is undefined, while sqrt(-1.0) is defined as nan.

rdar://18371371

Swift SVN r22864
2014-10-21 17:26:59 +00:00
Dave Abrahams
69194280a7 [stdlib] Nix an unused protocol and rename another
Swift SVN r22791
2014-10-16 03:46:34 +00:00
Erik Eckstein
b51b3ed123 Mark public compiler intrinsics with // COMPILER_INTRINSIC
I followed Joe's example in Process.swift and used COMPILER_INTRINSIC (and not just INTRINSIC)



Swift SVN r22723
2014-10-14 07:32:03 +00:00
Erik Eckstein
60dcb9a435 Make compiler intrinsics public (part 2).
With the changed SILLinkage and dead function removal of internal functions this is necessary.



Swift SVN r22490
2014-10-03 13:58:50 +00:00
Dave Abrahams
156020de19 [stdlib] Rename 'countElements' => 'count'
The name was not only long and unwieldy, but inconsistent with our
conscious decision to avoid the use of "elements" in APIs as mostly
redundant.

Swift SVN r22408
2014-09-30 22:00:26 +00:00
Erik Eckstein
a4c7d89671 fix coding style in stdlib: move non-attribute keywords in same line as function declaration
Swift SVN r22275
2014-09-25 08:43:55 +00:00
Dmitri Hrybenko
f6fb506bb5 stdlib: 'internal'ise an initializer
Swift SVN r22259
2014-09-24 09:15:19 +00:00
Dave Abrahams
d1b6dfa48f [stdlib] pick off more public non-protocol docs
137 undocumented public non-operator APIs remain in core

Swift SVN r22253
2014-09-24 03:58:14 +00:00
Dave Abrahams
795799b0d2 [stdlib] Propagate Hashable docs
202 undocumented public non-operator APIs remain in core

Swift SVN r22241
2014-09-23 23:35:58 +00:00
Dave Abrahams
411bcf2e75 [stdlib] Propagate CVarArgsType docs
211 undocumented public non-operator APIs remain in core

Swift SVN r22240
2014-09-23 23:22:18 +00:00
Dave Abrahams
69470a24ff [stdlib] Propagate Strideable docs
228 undocumented public non-operator APIs remain in core

Swift SVN r22237
2014-09-23 23:13:28 +00:00
Dave Abrahams
dbde275230 [stdlib] Propagate Reflectable docs
230 undocumented public non-operator APIs remain in core

Swift SVN r22236
2014-09-23 23:08:43 +00:00
Dave Abrahams
24fe53ed6c [stdlib] Propagate OutputStream docs
240 undocumented public non-operator APIs remain in core

Note: previous estimates were wrong because my regex was broken.  The
previous commit, for example, had 260 undocumented APIs.

Swift SVN r22234
2014-09-23 22:01:49 +00:00
Erik Eckstein
c16c510167 Set SILLinkage according to visibility.
Now the SILLinkage for functions and global variables is according to the swift visibility (private, internal or public).

In addition, the fact whether a function or global variable is considered as fragile, is kept in a separate flag at SIL level.
Previously the linkage was used for this (e.g. no inlining of less visible functions to more visible functions). But it had no effect,
because everything was public anyway.

For now this isFragile-flag is set for public transparent functions and for everything if a module is compiled with -sil-serialize-all,
i.e. for the stdlib.

For details see <rdar://problem/18201785> Set SILLinkage correctly and better handling of fragile functions.

The benefits of this change are:
*) Enable to eliminate unused private and internal functions
*) It should be possible now to use private in the stdlib
*) The symbol linkage is as one would expect (previously almost all symbols were public).

More details:

Specializations from fragile functions (e.g. from the stdlib) now get linkonce_odr,default
linkage instead of linkonce_odr,hidden, i.e. they have public visibility.
The reason is: if such a function is called from another fragile function (in the same module),
then it has to be visible from a third module, in case the fragile caller is inlined but not
the specialized function.

I had to update lots of test files, because many CHECK-LABEL lines include the linkage, which has changed.

The -sil-serialize-all option is now handled at SILGen and not at the Serializer.
This means that test files in sil format which are compiled with -sil-serialize-all
must have the [fragile] attribute set for all functions and globals.

The -disable-access-control option doesn't help anymore if the accessed module is not compiled
with -sil-serialize-all, because the linker will complain about unresolved symbols.

A final note: I tried to consider all the implications of this change, but it's not a low-risk change.
If you have any comments, please let me know.



Swift SVN r22215
2014-09-23 12:33:18 +00:00
Dave Abrahams
7c9ebaa19f [stdlib] Propagate LiteralConvertible docs
219 undocumented public APIs remain in core

Swift SVN r22213
2014-09-23 11:12:39 +00:00
Erik Eckstein
f8f703083f Make compiler intrinsics public.
Swift SVN r22212
2014-09-23 11:12:18 +00:00
Dave Abrahams
f780a1ce67 [stdlib] Propagate NilLiteralConvertible docs
229 undocumented public APIs remain in core

Swift SVN r22211
2014-09-23 10:49:47 +00:00
Dave Abrahams
f4a7812065 [stdlib] Propagate SequenceType docs to models
235 undocumented public APIs remain in core

Swift SVN r22210
2014-09-23 10:40:37 +00:00