comparison druntime/src/common/core/vararg.d @ 1458:e0b2d67cfe7c

Added druntime (this should be removed once it works).
author Robert Clipsham <robert@octarineparrot.com>
date Tue, 02 Jun 2009 17:43:06 +0100
parents
children
comparison
equal deleted inserted replaced
1456:7b218ec1044f 1458:e0b2d67cfe7c
1 /**
2 * The vararg module is intended to facilitate vararg manipulation in D.
3 * It should be interface compatible with the C module "stdarg," and the
4 * two modules may share a common implementation if possible (as is done
5 * here).
6 * Copyright: Copyright Digital Mars 2000 - 2009.
7 * License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>.
8 * Authors: Walter Bright, Hauke Duden
9 *
10 * Copyright Digital Mars 2000 - 2009.
11 * Distributed under the Boost Software License, Version 1.0.
12 * (See accompanying file LICENSE_1_0.txt or copy at
13 * http://www.boost.org/LICENSE_1_0.txt)
14 */
15 module core.vararg;
16
17
18 /**
19 * The base vararg list type.
20 */
21 alias void* va_list;
22
23
24 /**
25 * This function initializes the supplied argument pointer for subsequent
26 * use by va_arg and va_end.
27 *
28 * Params:
29 * ap = The argument pointer to initialize.
30 * paramn = The identifier of the rightmost parameter in the function
31 * parameter list.
32 */
33 void va_start(T) ( out va_list ap, inout T parmn )
34 {
35 ap = cast(va_list) ( cast(void*) &parmn + ( ( T.sizeof + int.sizeof - 1 ) & ~( int.sizeof - 1 ) ) );
36 }
37
38 /**
39 * This function returns the next argument in the sequence referenced by
40 * the supplied argument pointer. The argument pointer will be adjusted
41 * to point to the next arggument in the sequence.
42 *
43 * Params:
44 * ap = The argument pointer.
45 *
46 * Returns:
47 * The next argument in the sequence. The result is undefined if ap
48 * does not point to a valid argument.
49 */
50 T va_arg(T) ( inout va_list ap )
51 {
52 T arg = *cast(T*) ap;
53 ap = cast(va_list) ( cast(void*) ap + ( ( T.sizeof + int.sizeof - 1 ) & ~( int.sizeof - 1 ) ) );
54 return arg;
55 }
56
57 /**
58 * This function cleans up any resources allocated by va_start. It is
59 * currently a no-op and exists mostly for syntax compatibility with
60 * the variadric argument functions for C.
61 *
62 * Params:
63 * ap = The argument pointer.
64 */
65 void va_end( va_list ap )
66 {
67
68 }
69
70
71 /**
72 * This function copied the argument pointer src to dst.
73 *
74 * Params:
75 * src = The source pointer.
76 * dst = The destination pointer.
77 */
78 void va_copy( out va_list dst, va_list src )
79 {
80 dst = src;
81 }