Commit Graph

17 Commits

Author SHA1 Message Date
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
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
ea47b64bcc [stdlib] Propagate IntegerArithmeticType docs
184 undocumented public non-operator APIs remain in core

Swift SVN r22227
2014-09-23 20:16:36 +00:00
Dave Abrahams
5ddf4dca53 [stdlib] doc-comment integer arithmetic protocols
Swift SVN r22043
2014-09-17 21:19:25 +00:00
Chris Lattner
3ad9c58c18 Disallow (with a nice fixit) the infix modifier on func decls, it is just validated
and ignored anyway.  It is still required on operator decls though.


Swift SVN r19978
2014-07-15 16:52:04 +00:00
Chris Lattner
e0b0205cd7 Remove the @assignment attribute entirely. It doesn't do anything except
enforce its own little constraints.  The type checker isn't using it for
anything, and it is just clutter.

This resolves <rdar://problem/16656024> Remove @assignment from operator implementations



Swift SVN r19960
2014-07-14 22:44:25 +00:00
Chris Lattner
f0911fd4ed Update the .gyb file.
Swift SVN r19934
2014-07-14 17:13:36 +00:00
Dave Abrahams
6d1095f44e Protocol names end in "Type," "ible," or "able"
Mechanically add "Type" to the end of any protocol names that don't end
in "Type," "ible," or "able."  Also, drop "Type" from the end of any
associated type names, except for those of the *LiteralConvertible
protocols.

There are obvious improvements to make in some of these names, which can
be handled with separate commits.

Fixes <rdar://problem/17165920> Protocols `Integer` etc should get
uglier names.

Swift SVN r19883
2014-07-12 17:29:57 +00:00
Jordan Rose
da29f099f0 Update stdlib for accessibility modifiers becoming context-sensitive keywords.
Swift SVN r19672
2014-07-08 02:17:46 +00:00
Chris Lattner
7dae30f755 rename the integer 'modulus' methods to 'remainder' methods.
Swift SVN r19433
2014-07-01 22:36:54 +00:00
Dave Abrahams
8e7d45f2c0 [stdlib] Normalize .gyb files
- Follow LLVM conventions for emacs mode specification

- Use local variables suffix to make the output read-only (at least on
  Emacs)

- But drop the admonitions not to edit the generated files;
  line-directive mostly takes care of that problem now.

Swift SVN r19381
2014-06-30 23:24:17 +00:00
Chris Lattner
4ac0f31852 add an 'overflow' label to the second result of the "withoverflow" aritmetic operations,
as suggested by Dmitri



Swift SVN r19251
2014-06-26 21:00:32 +00:00
Chris Lattner
4dcd6cf4d1 implement <rdar://problem/17101613> standard library should provide a way to test for overflow
This just renames the existing "uncheckedAdd" (and related) functions to addWithOverflow.  These
were already "checked" and return the partial result + bool that we want.


Swift SVN r19246
2014-06-26 20:33:17 +00:00
Jordan Rose
cca27d02a0 Tag everything in the standard library with accessibility attributes.
Keep calm: remember that the standard library has many more public exports
than the average target, and that this contains ALL of them at once.
I also deliberately tried to tag nearly every top-level decl, even if that
was just to explicitly mark things @internal, to make sure I didn't miss
something.

This does export more than we might want to, mostly for protocol conformance
reasons, along with our simple-but-limiting typealias rule. I tried to also
mark things private where possible, but it's really going to be up to the
standard library owners to get this right. This is also only validated
against top-level access control; I haven't fully tested against member-level
access control yet, and none of our semantic restrictions are in place.

Along the way I also noticed bits of stdlib cruft; to keep this patch
understandable, I didn't change any of them.

Swift SVN r19145
2014-06-24 21:32:18 +00:00
Arnold Schwaighofer
da6d9152b6 Differentiate between user assertion and preconditions and the like
assert() and fatalError()
These functions are meant to be used in user code. They are enabled in debug
mode and disabled in release or fast mode.

_precondition() and _preconditionFailure()
These functions are meant to be used in library code to check preconditions at
the api boundry. They are enabled in debug mode (with a verbose message) and
release mode (trap). In fast mode they are disabled.

_debugPrecondition() and _debugPreconditionFailure()
These functions are meant to be used in library code to check preconditions that
are not neccesarily comprehensive for safety (UnsafePointer can be null or an
invalid pointer but we can't check both). They are enabled only in debug mode.

_sanityCheck() and _fatalError()
These are meant to be used for internal consistency checks. They are only
enabled when the library is build with -DSWIFT_STDLIB_INTERNAL_CHECKS=ON.

I modified the code in the standard library to the best of my judgement.

rdar://16477198

Swift SVN r18212
2014-05-16 20:49:54 +00:00
Ted Kremenek
fad874708e Adjust test cases.
Swift SVN r17964
2014-05-12 22:01:52 +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