Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Changeset 24

Show
Ignore:
Timestamp:
06/01/06 22:35:25 (3 years ago)
Author:
sean
Message:

Merged in latest Ares changes.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/tango/core/array.d

    r16 r24  
    3535 * This module is the first attempt at developing function interface guidelines 
    3636 * for Ares.  All functions will likely be templates and will be designed with 
    37  * implicit tempalte instantiation and template overloading as required features. 
     37 * implicit template instantiation and template overloading as required features. 
    3838 * The goal here is to provide a useful set of string routines for everyday use 
    3939 * and to use this experience for developing more generalized algorithms later on. 
  • trunk/tango/core/exception.d

    r16 r24  
    4141private 
    4242{ 
    43     import tango.stdc.stdio; 
    44     import tango.stdc.stdlib; 
     43    import tango.stdc.stddef; 
    4544} 
    4645 
     
    191190 *  line = The line number on which this error occurred. 
    192191 */ 
    193 extern (C) void onAssertError( char[] file, uint line ) 
    194 
    195     if( !assertHandler ) 
    196         throw new AssertException( file, line ); 
    197     assertHandler( file, line ); 
    198 
     192extern (C) void onAssertError( char[] file, uint line ); 
    199193 
    200194 
     
    211205 *  Default behavior is to return true. 
    212206 */ 
    213 extern (C) bool onCollectResource( Object obj ) 
    214 
    215     if( !collectHandler ) 
    216         return true; 
    217     return collectHandler( obj ); 
    218 
     207extern (C) bool onCollectResource( Object obj ); 
    219208 
    220209 
     
    235224 *  ArrayBoundsException. 
    236225 */ 
    237 extern (C) void onArrayBoundsError( char[] file, size_t line ) 
    238 
    239     throw new ArrayBoundsException( file, line ); 
    240 
     226extern (C) void onArrayBoundsError( char[] file, size_t line ); 
    241227 
    242228 
     
    250236 *  FinalizeException. 
    251237 */ 
    252 extern (C) void onFinalizeError( ClassInfo info, Exception ex ) 
    253 
    254     throw new FinalizeException( info, ex ); 
    255 
     238extern (C) void onFinalizeError( ClassInfo info, Exception ex ); 
    256239 
    257240 
     
    263246 *  OutOfMemoryException. 
    264247 */ 
    265 extern (C) void onOutOfMemoryError() 
    266 
    267     // NOTE: Since an out of memory condition exists, no allocation must occur 
    268     //       while generating this object. 
    269     throw cast(OutOfMemoryException) cast(void*) OutOfMemoryException.classinfo.init; 
    270 
     248extern (C) void onOutOfMemoryError(); 
    271249 
    272250 
     
    281259 *  SwitchException. 
    282260 */ 
    283 extern (C) void onSwitchError( char[] file, size_t line ) 
    284 
    285     throw new SwitchException( file, line ); 
    286 
     261extern (C) void onSwitchError( char[] file, size_t line ); 
    287262 
    288263 
     
    297272 *  UnicodeException. 
    298273 */ 
    299 extern (C) void onUnicodeError( char[] msg, size_t idx ) 
    300 
    301     throw new UnicodeException( msg, idx ); 
    302 
     274extern (C) void onUnicodeError( char[] msg, size_t idx ); 
  • trunk/tango/core/intrinsic.d

    r16 r24  
    1 // Copyright (c) 1999-2003 by Digital Mars 
    2 // All Rights Reserved 
    3 // written by Walter Bright 
    4 // www.digitalmars.com 
    5 // 
    6 // Documentation written by Sean Kelly <sean@f4.ca> 
    7  
    81/** 
    9  * This module contains functions that the compiler is intended to replace 
    10  * with optimized assembler code at compile-time.  While the instructions 
    11  * provided are based on instructions outlined in the IA-32 spec, it should 
    12  * be easy to emulate such functionality on other architectures, provided 
    13  * there is no directly equivalent function available. 
     2 * These functions are built-in intrinsics to the compiler. 
     3 * 
     4 * Intrinsic functions are functions built in to the compiler, usually to take 
     5 * advantage of specific CPU features that are inefficient to handle via 
     6 * external functions.  The compiler's optimizer and code generator are fully 
     7 * integrated in with intrinsic functions, bringing to bear their full power on 
     8 * them. This can result in some surprising speedups. 
     9 * 
     10 * Authors:   Walter Bright 
     11 * Copyright: Public Domain 
     12 * License:   See about.d 
    1413 */ 
    1514module tango.core.intrinsic; 
     
    1716 
    1817/** 
    19  * 
     18 * Scans the bits in v starting with bit 0, looking 
     19 * for the first set bit. 
     20 * Returns: 
     21 *  The bit number of the first bit set. 
     22 *  The return value is undefined if v is zero. 
    2023 */ 
    2124int bsf( uint v ); 
     
    2326 
    2427/** 
     28 * Scans the bits in v from the most significant bit 
     29 * to the least significant bit, looking 
     30 * for the first set bit. 
     31 * Returns: 
     32 *  The bit number of the first bit set. 
     33 *  The return value is undefined if v is zero. 
     34 * Example: 
     35 * --- 
     36 * import std.intrinsic; 
    2537 * 
     38 * int main() 
     39 * { 
     40 *     uint v; 
     41 *     int x; 
     42 * 
     43 *     v = 0x21; 
     44 *     x = bsf(v); 
     45 *     printf("bsf(x%x) = %d\n", v, x); 
     46 *     x = bsr(v); 
     47 *     printf("bsr(x%x) = %d\n", v, x); 
     48 *     return 0; 
     49 * } 
     50 * --- 
     51 * Output: 
     52 *  bsf(x21) = 0<br> 
     53 *  bsr(x21) = 5 
    2654 */ 
    2755int bsr( uint v ); 
     
    2957 
    3058/** 
    31  * 
     59 * Tests the bit. 
    3260 */ 
    3361int bt( uint* p, uint bitnum ); 
     
    3563 
    3664/** 
    37  * 
     65 * Tests and complements the bit. 
    3866 */ 
    3967int btc( uint* p, uint bitnum ); 
     
    4169 
    4270/** 
    43  * 
     71 * Tests and resets (sets to 0) the bit. 
    4472 */ 
    4573int btr( uint* p, uint bitnum ); 
     
    4775 
    4876/** 
     77 * Tests and sets the bit. 
     78 * Params: 
     79 * p = a non-NULL pointer to an array of uints. 
     80 * index = a bit number, starting with bit 0 of p[0], 
     81 * and progressing. It addresses bits like the expression: 
     82--- 
     83p[index / (uint.sizeof*8)] & (1 << (index & ((uint.sizeof*8) - 1))) 
     84--- 
     85 * Returns: 
     86 *  A non-zero value if the bit was set, and a zero 
     87 *  if it was clear. 
    4988 * 
     89 * Example: 
     90 * --- 
     91import std.intrinsic; 
     92 
     93int main() 
     94{ 
     95    uint array[2]; 
     96 
     97    array[0] = 2; 
     98    array[1] = 0x100; 
     99 
     100    printf("btc(array, 35) = %d\n", <b>btc</b>(array, 35)); 
     101    printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]); 
     102 
     103    printf("btc(array, 35) = %d\n", <b>btc</b>(array, 35)); 
     104    printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]); 
     105 
     106    printf("bts(array, 35) = %d\n", <b>bts</b>(array, 35)); 
     107    printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]); 
     108 
     109    printf("btr(array, 35) = %d\n", <b>btr</b>(array, 35)); 
     110    printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]); 
     111 
     112    printf("bt(array, 1) = %d\n", <b>bt</b>(array, 1)); 
     113    printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]); 
     114 
     115    return 0; 
     116} 
     117 * --- 
     118 * Output: 
     119<pre> 
     120btc(array, 35) = 0 
     121array = [0]:x2, [1]:x108 
     122btc(array, 35) = -1 
     123array = [0]:x2, [1]:x100 
     124bts(array, 35) = 0 
     125array = [0]:x2, [1]:x108 
     126btr(array, 35) = -1 
     127array = [0]:x2, [1]:x100 
     128bt(array, 1) = -1 
     129array = [0]:x2, [1]:x100 
     130</pre> 
    50131 */ 
    51132int bts( uint* p, uint bitnum ); 
     
    53134 
    54135/** 
    55  * 
     136 * Swaps bytes in a 4 byte uint end-to-end, i.e. byte 0 becomes 
     137 * byte 3, byte 1 becomes byte 2, byte 2 becomes byte 1, byte 3 
     138 * becomes byte 0. 
    56139 */ 
    57140uint bswap( uint v ); 
     
    59142 
    60143/** 
    61  * 
     144 * Reads I/O port at port_address. 
    62145 */ 
    63 ubyte inp( uint ); 
     146ubyte inp(uint port_address); 
    64147 
    65148 
    66149/** 
    67  * 
     150 * ditto 
    68151 */ 
    69 ushort inpw( uint ); 
    70  
     152ushort inpw(uint port_address); 
    71153 
    72154 
    73155/** 
    74  * 
     156 * ditto 
    75157 */ 
    76  uint   inpl( uint ); 
     158uint inpl(uint port_address); 
    77159 
    78160 
    79161/** 
    80  * 
     162 * Writes and returns value to I/O port at port_address. 
    81163 */ 
    82 ubyte outp( uint, ubyte ); 
     164ubyte outp(uint port_address, ubyte value); 
    83165 
    84166 
    85167/** 
    86  * 
     168 * ditto 
    87169 */ 
    88 ushort outpw( uint, ushort ); 
     170ushort outpw(uint port_address, ushort value); 
    89171 
    90172 
    91173/** 
    92  * 
     174 * ditto 
    93175 */ 
    94 uint   outpl( uint, uint ); 
     176uint outpl(uint port_address, uint value); 
  • trunk/tango/core/memory.d

    r16 r24  
    173173     * otherwise expected to later reclaim the memory block if it is unused. 
    174174     * If allocation fails, this function will call onOutOfMemory which is 
    175      * expected to throw an OutOfMemoryException. 
     175     * expected to throw an OutOfMemoryException.  If p references memory not 
     176     * originally allocated by this garbage collector, or if it points to the 
     177     * interior of a memory block, no action will be taken. 
    176178     * 
    177179     * Params: 
     
    197199     * occurs.  If p references memory not originally allocated by this 
    198200     * garbage collector, or if it points to the interior of a memory block, 
    199      * the result is undefined
     201     * no action will be taken
    200202     * 
    201203     * Params: 
  • trunk/tango/core/traits.d

    r16 r24  
    7474                               is( T == class )     || 
    7575                               is( T == interface ) || 
    76                                is( T == function )  || isFunctionType!( T ) || 
     76                               isFunctionPointerType!( T ) || 
    7777                               is( T == delegate ); 
    7878} 
     
    8484template isCallableType( T ) 
    8585{ 
    86     const bool isCallableType = is( T == function ) || isFunctionType!( T ) || 
     86    const bool isCallableType = is( T == function ) || isFunctionPointerType!( T ) || 
    8787                                is( T == delegate ) || 
    8888                                is( typeof(T.opCall) == function ); 
     
    9191 
    9292// 
    93 // NOTE: This template is a hack to replace is(T==function) since it's broken. 
     93// NOTE: This template is a hack to use in place of "is(T==function)" since 
     94//       it actually detects a function alias, not a function pointer. 
    9495// 
    95 private template isFunctionType( T ) 
     96private template isFunctionPointerType( T ) 
    9697{ 
    97     const bool isFunctionType = mangleString!(T).length > 2 && 
    98                                 mangleString!(T)[0] == 'P'  && 
    99                                 mangleString!(T)[1] == 'F'; 
     98    const bool isFunctionPointerType = T.mangleof.length > 2 && 
     99                                       T.mangleof[0] == 'P'  && 
     100                                       T.mangleof[1] == 'F'; 
    100101} 
    101  
    102  
    103 // 
    104 // NOTE: Yet another workaround for a compiler bug. 
    105 // 
    106 private template mangleString( T ) 
    107 { 
    108     const char[] mangleString = T.mangleof; 
    109 } 
  • trunk/tango/core/unicode.d

    r16 r24  
    3434 
    3535        History:        Initial version; Oct 2004 
    36         History:        Moved to tango.convert; Nov 2005 
     36        History:        Moved to mango.convert; Nov 2005 
    3737 
    3838        Authors:        Kris 
  • trunk/tango/core/vararg.d

    r16 r24  
    88/** 
    99 * The vararg module is intended to facilitate vararg manipulation in D. 
    10  * It should be interface compatible with the C module of the same name, 
    11  * and the two modules may share a common implementation if possibl
    12  * (as is done here). 
     10 * It should be interface compatible with the C module "stdarg," and the 
     11 * two modules may share a common implementation if possible (as is don
     12 * here). 
    1313 */ 
    1414module tango.core.vararg;