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

Changeset 1921

Show
Ignore:
Timestamp:
03/16/07 22:51:57 (2 years ago)
Author:
sean
Message:

Cleaned up stdarg implementation. Hopefully I didn't break anything in the process.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/std/c/stdarg.di

    r1919 r1921  
    1414    alias __builtin_va_end  va_end; 
    1515    alias __builtin_va_copy va_copy; 
    16 } 
    17 else 
    18 { 
    19     alias void* va_list; 
    2016 
    21     void va_end(va_list ap
     17    template va_start(T
    2218    { 
     19        void va_start( out va_list ap, inout T parmn ) 
     20        { 
    2321 
    24     } 
    25  
    26     void va_copy( out va_list dest, va_list src ) 
    27     { 
    28         static if ( is( dest T == T[1]) ) 
    29         { 
    30             dest[0] = src[0]; 
    31         } 
    32         else 
    33         { 
    34             dest = src; 
    3522        } 
    3623    } 
    3724 
    38 
    39  
    40 template va_start(T) 
    41 
    42     void va_start( out va_list ap, inout T parmn ) 
     25    template va_arg(T) 
    4326    { 
    44         /* 
    45         ap = cast(va_list)(cast(void*)&parmn + ((T.sizeof + int.sizeof - 1) & ~(int.sizeof - 1))); 
    46         */ 
     27        T va_arg( inout va_list ap ) 
     28        { 
     29            return T.init; 
     30        } 
    4731    } 
    4832} 
    49  
    50 template va_arg(T) 
    51 { 
    52     T va_arg( inout va_list ap ) 
    53     { 
    54         /* 
    55         T arg = *cast(T*)ap; 
    56         ap = cast(va_list)(cast(void*)ap + ((T.sizeof + int.sizeof - 1) & ~(int.sizeof - 1))); 
    57         return arg; 
    58         */ 
    59         T t; 
    60         return t; 
    61     } 
    62 } 
  • trunk/std/stdarg.di

    r1919 r1921  
    1010version( GNU ) 
    1111{ 
    12     // va_list might be a pointer, but assuming so is not portable. 
    1312    private import gcc.builtins; 
    1413    alias __builtin_va_list va_list; 
     14    alias __builtin_va_end  va_end; 
     15    alias __builtin_va_copy va_copy; 
    1516 
    16     // va_arg is handled magically by the compiler 
    17 
    18 else 
    19 
    20     alias void* va_list; 
    21 
     17    template va_start(T) 
     18    { 
     19        void va_start( out va_list ap, inout T parmn ) 
     20        { 
    2221 
    23 template va_arg(T) 
    24 
    25     T va_arg( inout va_list _argptr ) 
     22        } 
     23    } 
     24 
     25    template va_arg(T) 
    2626    { 
    27         /* 
    28         T arg = *cast(T*)_argptr; 
    29         _argptr = _argptr + ((T.sizeof + int.sizeof - 1) & ~(int.sizeof - 1)); 
    30         return arg; 
    31         */ 
    32         T t; return t; 
     27        T va_arg( inout va_list ap ) 
     28        { 
     29            return T.init; 
     30        } 
    3331    } 
    3432} 
    35  
    36 private import std.c.stdarg; 
    37 /* The existence of std.stdarg.va_copy isn't standard.  Prevent 
    38    conflicts by using '__'. */ 
    39 alias std.c.stdarg.va_copy __va_copy;