Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Changeset 1725

Show
Ignore:
Timestamp:
07/04/10 22:09:03 (14 years ago)
Author:
andrei
Message:

Replaced std.contracts with std.exception throughout

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/phobos/std/algorithm.d

    r1718 r1725  
    3939 
    4040Copyright: Andrei Alexandrescu 2008-. 
    4141 
    4242License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0). 
    4343 
    4444Authors:   $(WEB erdani.com, Andrei Alexandrescu) 
    4545 */ 
    4646module std.algorithm; 
    4747 
    4848import std.c.string; 
    49 import std.array, std.container, std.contracts, std.conv, std.date
     49import std.array, std.container, std.conv, std.date, std.exception
    5050    std.functional, std.math, std.metastrings, std.range, std.string, 
    5151    std.traits, std.typecons, std.typetuple; 
    5252 
    5353version(unittest) 
    5454{ 
    5555    import std.random, std.stdio, std.string; 
    5656    mixin(dummyRanges); 
    5757} 
    5858 
    5959/** 
     
    769769{ 
    770770    int[] a = [ 1, 2, 3, 4, 5 ]; 
    771771    int[] b = new int[3]; 
    772772    assert(moveSome(a, b).field[0] is a[3 .. $]); 
    773773    assert(a[0 .. 3] == b); 
    774774    assert(a == [ 1, 2, 3, 4, 5 ]); 
    775775} 
    776776 
    777777// swap 
    778778/** 
    779 Swaps $(D lhs) and $(D rhs). See also $(XREF contracts, pointsTo). 
     779Swaps $(D lhs) and $(D rhs). See also $(XREF exception, pointsTo). 
    780780 
    781781Preconditions: 
    782782 
    783783$(D !pointsTo(lhs, lhs) && !pointsTo(lhs, rhs) && !pointsTo(rhs, lhs) 
    784784&& !pointsTo(rhs, rhs)) 
    785785 */ 
    786786void swap(T)(ref T a, ref T b) if (!is(typeof(T.init.proxySwap(T.init)))) 
    787787{ 
    788788   static if (is(T == struct)) 
    789789   { 
     
    16391639 
    16401640The default predicate for $(D find), which is $(D "a == b"), and the 
    16411641default predicate for $(D assumeSorted), which is $(D "a < b"), 
    16421642already satisfy the relation. 
    16431643 
    16441644If the above condition is satisfied, only $(BIGOH 
    16451645log(haystack.length)) steps are needed to position $(D haystack) at 
    16461646the beginning of the search. Also, once positioned, the search will 
    16471647continue only as long as haystack and the needle start with equal 
    16481648elements. To inform $(D find) that you want to perform a binary 
    1649 search, wrap $(D haystack) with a call to $(XREF contracts
     1649search, wrap $(D haystack) with a call to $(XREF exception
    16501650assumeSorted). Then $(D find) will assume that $(D pred) and $(D less) 
    16511651are in the right relation and also that $(D haystack) is already 
    16521652sorted by $(D less). 
    16531653 
    16541654Example: 
    16551655---- 
    16561656int[] a = [ -1, 0, 1, 2, 3, 4, 5 ]; 
    16571657assert(find(assumeSorted(a), 3) == [ 3, 4, 5 ]); 
    16581658assert(find(assumeSorted(a), [3, 4]) == [ 3, 4, 5 ]); 
    16591659assert(find(assumeSorted(a), [3, 5], [1, 3], 8).empty); 
  • trunk/phobos/std/array.d

    r1715 r1725  
    77 
    88         Copyright Andrei Alexandrescu 2008 - 2009. 
    99Distributed under the Boost Software License, Version 1.0. 
    1010   (See accompanying file LICENSE_1_0.txt or copy at 
    1111         http://www.boost.org/LICENSE_1_0.txt) 
    1212*/ 
    1313module std.array; 
    1414 
    1515import std.c.stdio; 
    1616import core.memory; 
    17 import std.algorithm, std.contracts, std.conv, std.encoding, std.range, 
     17import std.algorithm, std.conv, std.encoding, std.exception, std.range, 
    1818    std.string, std.traits, std.typecons, std.utf; 
    1919version(unittest) private import std.stdio; 
    2020 
    2121/** 
    2222Returns a newly-allocated array consisting of a copy of the input 
    2323range $(D r). 
    2424 
    2525Example: 
    2626 
    2727---- 
  • trunk/phobos/std/boxer.d

    r1343 r1725  
    7171 *          Copyright Burton Radons 2007 - 2009. 
    7272 * Distributed under the Boost Software License, Version 1.0. 
    7373 *    (See accompanying file LICENSE_1_0.txt or copy at 
    7474 *          http://www.boost.org/LICENSE_1_0.txt) 
    7575 */ 
    7676module std.boxer; 
    7777 
    7878private import std.format; 
    7979private import std.string; 
    8080private import std.utf; 
    81 import std.contracts
     81import std.exception
    8282 
    8383 /* These functions and types allow packing objects into generic containers 
    8484  * and recovering them later.  This comes into play in a wide spectrum of 
    8585  * utilities, such as with a scripting language, or as additional user data 
    8686  * for an object. 
    8787  *  
    8888  * Box an object by calling the box function: 
    8989  * 
    9090  *     Box x = box(4); 
    9191  * 
  • trunk/phobos/std/concurrency.d

    r1710 r1725  
    3232    import core.sync.rwmutex; 
    3333    import core.sync.semaphore; 
    3434    import std.variant; 
    3535} 
    3636private 
    3737{ 
    3838    import core.thread; 
    3939    //import core.sync.condition; 
    4040    //import core.sync.mutex; 
    4141    import std.algorithm; 
    42     import std.contracts
     42    import std.exception
    4343    import std.range; 
    4444    import std.stdio; 
    4545    import std.range; 
    4646    import std.traits; 
    4747    import std.typecons; 
    4848    import std.typetuple; 
    4949     
    5050    template isTuple(T) 
    5151    { 
    5252       enum isTuple = __traits(compiles, 
  • trunk/phobos/std/date.d

    r1542 r1725  
    1717 * 
    1818 *          Copyright Digital Mars 2000 - 2009. 
    1919 * Distributed under the Boost Software License, Version 1.0. 
    2020 *    (See accompanying file LICENSE_1_0.txt or copy at 
    2121 *          http://www.boost.org/LICENSE_1_0.txt) 
    2222 */ 
    2323module std.date; 
    2424 
    2525private import std.stdio; 
    2626private import std.dateparse; 
    27 import std.c.stdlib, std.contracts, std.conv
     27import std.c.stdlib, std.conv, std.exception
    2828 
    2929/** 
    3030 * $(D d_time) is a signed arithmetic type giving the time elapsed 
    3131 * since January 1, 1970.  Negative values are for dates preceding 
    3232 * 1970. The time unit used is Ticks.  Ticks are milliseconds or 
    3333 * smaller intervals. 
    3434 * 
    3535 * The usual arithmetic operations can be performed on d_time, such as adding, 
    3636 * subtracting, etc. Elapsed time in Ticks can be computed by subtracting a 
    3737 * starting d_time from an ending d_time. 
  • trunk/phobos/std/demangle.d

    r1390 r1725  
    1717 *          http://www.boost.org/LICENSE_1_0.txt) 
    1818 */ 
    1919module std.demangle; 
    2020 
    2121//debug=demangle;                // uncomment to turn on debugging printf's 
    2222 
    2323private import std.ctype; 
    2424private import std.string; 
    2525import std.conv; 
    2626private import std.utf; 
    27 import std.contracts
     27import std.exception
    2828 
    2929private import std.stdio; 
    3030 
    3131private class MangleException : Exception 
    3232{ 
    3333    this() 
    3434    { 
    3535        super("MangleException"); 
    3636    } 
    3737} 
  • trunk/phobos/std/file.d

    r1708 r1725  
    1313 
    1414         Copyright Digital Mars 2007 - 2009. 
    1515Distributed under the Boost Software License, Version 1.0. 
    1616   (See accompanying file LICENSE_1_0.txt or copy at 
    1717         http://www.boost.org/LICENSE_1_0.txt) 
    1818*/ 
    1919module std.file; 
    2020 
    2121import core.memory; 
    2222import core.stdc.stdio, core.stdc.stdlib, core.stdc.string, 
    23     core.stdc.errno, std.algorithm, std.array,  
    24     std.contracts, std.conv, std.date, std.format, std.path, std.process, 
     23    core.stdc.errno, std.algorithm, std.array, 
     24    std.conv, std.date, std.exception, std.format, std.path, std.process, 
    2525    std.range, std.regexp, std.stdio, std.string, std.traits, std.typecons, 
    2626    std.typetuple, std.utf; 
    2727version (Win32) 
    2828{ 
    2929    import core.sys.windows.windows, std.windows.charset, 
    3030        std.windows.syserror, std.__fileinit; 
    3131/* 
    3232 * Since Win 9x does not support the "W" API's, first convert 
    3333 * to wchar, then convert to multibyte using the current code 
    3434 * page. 
  • trunk/phobos/std/format.d

    r1719 r1725  
    1111 * License:   $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0). 
    1212 * 
    1313 * Authors: $(WEB digitalmars.com, Walter Bright), $(WEB 
    1414 * erdani.com, Andrei Alexandrescu) 
    1515 */ 
    1616module std.format; 
    1717 
    1818//debug=format;                // uncomment to turn on debugging printf's 
    1919 
    2020import core.stdc.stdio, core.stdc.stdlib, core.stdc.string; 
    21 import std.algorithm, std.array, std.bitmanip, std.contracts, std.conv, 
    22     std.ctype, std.functional, std.range, std.stdarg, std.string, std.system
    23     std.traits, std.typetuple, std.utf; 
     21import std.algorithm, std.array, std.bitmanip, std.conv, 
     22    std.ctype, std.exception, std.functional, std.range, std.stdarg
     23    std.string, std.system, std.traits, std.typetuple, std.utf; 
    2424version(unittest) { 
    2525    import std.stdio, std.typecons; 
    2626} 
    2727 
    2828version (Windows) version (DigitalMars) 
    2929{ 
    3030    version = DigitalMarsC; 
    3131} 
    3232 
    3333version (DigitalMarsC) 
  • trunk/phobos/std/functional.d

    r1657 r1725  
    1313 
    1414         Copyright Andrei Alexandrescu 2008 - 2009. 
    1515Distributed under the Boost Software License, Version 1.0. 
    1616   (See accompanying file LICENSE_1_0.txt or copy at 
    1717         http://www.boost.org/LICENSE_1_0.txt) 
    1818*/ 
    1919module std.functional; 
    2020 
    2121import std.metastrings, std.stdio, std.traits, std.typecons, std.typetuple; 
    2222// for making various functions visible in *naryFun 
    23 import std.algorithm, std.contracts, std.conv, std.math, std.range, std.string;  
     23import std.algorithm, std.conv, std.exception, std.math, std.range, std.string; 
    2424 
    2525/** 
    2626Transforms a string representing an expression into a unary 
    2727function. The string must use symbol name $(D a) as the parameter. 
    2828 
    2929Example: 
    3030 
    3131---- 
    3232alias unaryFun!("(a & 1) == 0") isEven; 
    3333assert(isEven(2) && !isEven(1)); 
  • trunk/phobos/std/getopt.d

    r1559 r1725  
    2323                   getopt) infers the expected parameter types from the static types of 
    2424                   the passed-in pointers. 
    2525 
    2626         Copyright Andrei Alexandrescu 2008 - 2009. 
    2727Distributed under the Boost Software License, Version 1.0. 
    2828   (See accompanying file LICENSE_1_0.txt or copy at 
    2929         http://www.boost.org/LICENSE_1_0.txt) 
    3030*/ 
    3131module std.getopt; 
    3232 
    33 private import std.string, std.conv, std.traits, std.contracts, std.bitmanip, 
    34     std.algorithm, std.ctype
     33private import std.string, std.conv, std.traits, std.bitmanip, 
     34    std.algorithm, std.ctype, std.exception
    3535 
    3636//version (unittest) 
    3737//{ 
    3838    import std.stdio; // for testing only 
    3939//} 
    4040 
    4141/** 
    4242 Synopsis: 
    4343 
    4444--------- 
  • trunk/phobos/std/md5.d

    r1390 r1725  
    8080without express or implied warranty of any kind. 
    8181These notices must be retained in any copies of any part of this 
    8282documentation and/or software. 
    8383 */ 
    8484 
    8585module std.md5; 
    8686 
    8787//debug=md5;        // uncomment to turn on debugging printf's 
    8888 
    8989import std.string; 
    90 import std.contracts
     90import std.exception
    9191import std.c.stdio : printf; 
    9292 
    9393/*************************************** 
    9494 * Computes MD5 digest of several arrays of data. 
    9595 */ 
    9696 
    9797void sum(ref ubyte[16] digest, in void[][] data...) 
    9898{ 
    9999    MD5_CTX context; 
    100100    context.start(); 
  • trunk/phobos/std/process.d

    r1500 r1725  
    2121         http://www.boost.org/LICENSE_1_0.txt) 
    2222*/ 
    2323module std.process; 
    2424 
    2525private import std.c.stdlib; 
    2626private import std.c.string; 
    2727private import std.conv; 
    2828private import std.string; 
    2929private import std.c.process; 
    3030private import core.stdc.errno; 
    31 private import std.contracts
     31private import std.exception
    3232version (Windows) 
    3333{ 
    3434    import std.array, std.format, std.random, std.file; 
    3535    private import std.stdio : readln, fclose; 
    3636    private import std.c.windows.windows:GetCurrentProcessId; 
    3737} 
    3838version (Posix) 
    3939{ 
    4040    private import std.stdio; 
    4141} 
  • trunk/phobos/std/random.d

    r1656 r1725  
    4747           random number facility proposed by Jens Maurer and contributed to by 
    4848           researchers at the Fermi laboratory. 
    4949 
    5050         Copyright Andrei Alexandrescu 2008 - 2009. 
    5151Distributed under the Boost Software License, Version 1.0. 
    5252   (See accompanying file LICENSE_1_0.txt or copy at 
    5353         http://www.boost.org/LICENSE_1_0.txt) 
    5454*/ 
    5555module std.random; 
    5656 
    57 import std.algorithm, std.c.time, std.contracts, std.conv, std.date, std.math, 
     57import std.algorithm, std.c.time, std.conv, std.date, std.exception, std.math, 
    5858    std.numeric, std.process, std.range, std.stdio, std.traits, core.thread; 
    5959 
    6060// Segments of the code in this file Copyright (c) 1997 by Rick Booth 
    6161// From "Inner Loops" by Rick Booth, Addison-Wesley 
    6262 
    6363// Work derived from: 
    6464 
    6565/* 
    6666   A C-program for MT19937, with initialization improved 2002/1/26. 
    6767   Coded by Takuji Nishimura and Makoto Matsumoto. 
  • trunk/phobos/std/range.d

    r1720 r1725  
    99 
    1010WIKI = Phobos/StdRange 
    1111 
    1212Copyright: Copyright Andrei Alexandrescu 2008-. 
    1313License:   $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0). 
    1414Authors:   $(WEB erdani.org, Andrei Alexandrescu) 
    1515*/ 
    1616module std.range; 
    1717 
    1818public import std.array; 
    19 import std.contracts
     19import std.exception
    2020import std.traits; 
    2121import std.typecons; 
    2222import std.typetuple; 
    2323import std.algorithm; 
    2424import std.functional; 
    2525import std.conv; 
    2626 
    2727// For testing only.  This code is included in a string literal to be included 
    2828// in whatever module it's needed in, so that each module that uses it can be 
    2929// tested individually, without needing to link to std.range. 
  • trunk/phobos/std/stdio.d

    r1721 r1725  
    1111License:   $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0). 
    1212Authors:   $(WEB digitalmars.com, Walter Bright), 
    1313           $(WEB erdani.org, Andrei Alexandrescu) 
    1414 */ 
    1515module std.stdio; 
    1616 
    1717public import core.stdc.stdio; 
    1818import std.stdiobase; 
    1919import core.memory, core.stdc.errno, core.stdc.stddef, core.stdc.stdlib, 
    2020    core.stdc.string, core.stdc.wchar_; 
    21 import std.algorithm, std.array, std.contracts, std.conv, std.file, std.format, 
     21import std.algorithm, std.array, std.conv, std.exception, std.file, std.format, 
    2222    std.range, std.string, std.traits, std.typecons, 
    2323    std.typetuple, std.utf; 
    2424 
    2525version (DigitalMars) version (Windows) 
    2626{ 
    2727    // Specific to the way Digital Mars C does stdio 
    2828    version = DIGITAL_MARS_STDIO; 
    2929    import std.c.stdio : __fhnd_info, FHND_WCHAR, FHND_TEXT; 
    3030} 
    3131 
  • trunk/phobos/std/string.d

    r1646 r1725  
    2020Distributed under the Boost Software License, Version 1.0. 
    2121   (See accompanying file LICENSE_1_0.txt or copy at 
    2222         http://www.boost.org/LICENSE_1_0.txt) 
    2323 */ 
    2424module std.string; 
    2525 
    2626//debug=string;     // uncomment to turn on debugging printf's 
    2727 
    2828private import core.exception : onRangeError; 
    2929import core.stdc.stdio, core.stdc.stdlib, 
    30     core.stdc.string, std.algorithm, std.array,  
    31     std.contracts, std.conv, std.ctype, std.encoding, std.format, 
     30    core.stdc.string, std.algorithm, std.array, 
     31    std.conv, std.ctype, std.encoding, std.exception, std.format, 
    3232    std.metastrings, std.range, std.regex, std.stdarg, std.stdio, std.traits, 
    3333    std.typetuple, std.uni, std.utf; 
    3434 
    3535public import std.algorithm : startsWith, endsWith; 
    3636 
    3737version(Windows) extern (C) 
    3838{ 
    3939    size_t wcslen(in wchar *); 
    4040    int wcscmp(in wchar *, in wchar *); 
    4141} 
  • trunk/phobos/std/typecons.d

    r1723 r1725  
    4444---- 
    4545 
    4646Copyright: Copyright the respective authors, 2008- 
    4747License:   $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0). 
    4848Authors:   $(WEB erdani.org, Andrei Alexandrescu), 
    4949           $(WEB bartoszmilewski.wordpress.com, Bartosz Milewski), 
    5050           Don Clugston, 
    5151           Shin Fujishiro 
    5252 */ 
    5353module std.typecons; 
    54 import core.stdc.stdlib, std.algorithm, std.array, std.contracts, std.conv, 
    55     std.metastrings, std.traits, std.typetuple, core.memory; 
     54import core.stdc.stdlib, std.algorithm, std.array, std.conv, 
     55    std.exception, std.metastrings, std.traits, std.typetuple, core.memory; 
    5656version(unittest) import std.stdio; 
    5757 
    5858/** 
    5959Encapsulates unique ownership of a resource.  Resource of type T is 
    6060deleted at the end of the scope, unless it is transferred.  The 
    6161transfer can be explicit, by calling $(D release), or implicit, when 
    6262returning Unique from a function. The resource can be a polymorphic 
    6363class object, in which case Unique behaves polymorphically too. 
    6464 
    6565Example: 
  • trunk/phobos/std/uri.d

    r1500 r1725  
    2626module std.uri; 
    2727 
    2828//debug=uri;        // uncomment to turn on debugging printf's 
    2929 
    3030/* ====================== URI Functions ================ */ 
    3131 
    3232private import std.ctype; 
    3333private import std.c.stdlib; 
    3434private import std.utf; 
    3535private import std.stdio; 
    36 import std.contracts
     36import std.exception
    3737 
    3838class URIerror : Error 
    3939{ 
    4040    this() 
    4141    { 
    4242    super("URI error"); 
    4343    } 
    4444} 
    4545 
    4646enum 
  • trunk/phobos/std/utf.d

    r1684 r1725  
    2121 * License:   <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>. 
    2222 * Authors:   $(WEB digitalmars.com, Walter Bright) 
    2323 * 
    2424 *          Copyright Digital Mars 2000 - 2009. 
    2525 * Distributed under the Boost Software License, Version 1.0. 
    2626 *    (See accompanying file LICENSE_1_0.txt or copy at 
    2727 *          http://www.boost.org/LICENSE_1_0.txt) 
    2828 */ 
    2929module std.utf; 
    3030 
    31 import std.contracts, std.conv, std.range, std.traits, std.typecons; 
     31import std.conv, std.exception, std.range, std.traits, std.typecons; 
    3232 
    3333//debug=utf;        // uncomment to turn on debugging printf's 
    3434 
    3535debug (utf) import core.stdc.stdio : printf; 
    3636 
    3737deprecated class UtfError : Error 
    3838{ 
    3939    size_t idx; // index in string of where error occurred 
    4040 
    4141    this(string s, size_t i) 
  • trunk/phobos/std/variant.d

    r1666 r1725  
    4949 * Credits: 
    5050 * 
    5151 * Reviewed by Brad Roberts. Daniel Keep provided a detailed code 
    5252 * review prompting the following improvements: (1) better support for 
    5353 * arrays; (2) support for associative arrays; (3) friendlier behavior 
    5454 * towards the garbage collector. 
    5555 * 
    5656 * Copyright: Copyright Andrei Alexandrescu 2007 - 2009. 
    5757 * License:   <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>. 
    5858 * Authors:   $(WEB erdani.org, Andrei Alexandrescu) 
    59  * Credits:   Brad Roberts came up with the name $(D_PARAM contracts). 
    6059 * 
    6160 *          Copyright Andrei Alexandrescu 2007 - 2009. 
    6261 * Distributed under the Boost Software License, Version 1.0. 
    6362 *    (See accompanying file LICENSE_1_0.txt or copy at 
    6463 *          http://www.boost.org/LICENSE_1_0.txt) 
    6564 */ 
    6665module std.variant; 
    6766 
    6867import std.traits, std.c.string, std.typetuple, std.conv; 
    6968version(unittest) 
    7069{ 
    71     import std.contracts, std.stdio; 
     70    import std.exception, std.stdio; 
    7271} 
    7372 
    7473private template maxSize(T...) 
    7574{ 
    7675    static if (T.length == 1) 
    7776    { 
    7877        enum size_t maxSize = T[0].sizeof; 
    7978    } 
    8079    else 
    8180    {