| 1 |
(* varargs.def provides a basic vararg facility for GNU Modula-2. |
| 2 |
|
| 3 |
Copyright (C) 2015-2025 Free Software Foundation, Inc. |
| 4 |
Contributed by Gaius Mulley <[email protected]>. |
| 5 |
|
| 6 |
This file is part of GNU Modula-2. |
| 7 |
|
| 8 |
GNU Modula-2 is free software; you can redistribute it and/or modify |
| 9 |
it under the terms of the GNU General Public License as published by |
| 10 |
the Free Software Foundation; either version 3, or (at your option) |
| 11 |
any later version. |
| 12 |
|
| 13 |
GNU Modula-2 is distributed in the hope that it will be useful, but |
| 14 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 |
General Public License for more details. |
| 17 |
|
| 18 |
You should have received a copy of the GNU General Public License |
| 19 |
along with GNU Modula-2; see the file COPYING3. If not see |
| 20 |
<http://www.gnu.org/licenses/>. *) |
| 21 |
|
| 22 |
DEFINITION MODULE varargs ; |
| 23 |
|
| 24 |
|
| 25 |
FROM SYSTEM IMPORT BYTE ; |
| 26 |
|
| 27 |
|
| 28 |
TYPE |
| 29 |
vararg ; |
| 30 |
|
| 31 |
|
| 32 |
(* |
| 33 |
nargs - returns the number of arguments wrapped in, v. |
| 34 |
*) |
| 35 |
|
| 36 |
PROCEDURE nargs (v: vararg) : CARDINAL ; |
| 37 |
|
| 38 |
|
| 39 |
(* |
| 40 |
arg - fills in, a, with the next argument. The size of, a, must |
| 41 |
be an exact match with the original vararg parameter. |
| 42 |
*) |
| 43 |
|
| 44 |
PROCEDURE arg (v: vararg; VAR a: ARRAY OF BYTE) ; |
| 45 |
|
| 46 |
|
| 47 |
(* |
| 48 |
next - assigns the next arg to be collected as, i. |
| 49 |
*) |
| 50 |
|
| 51 |
PROCEDURE next (v: vararg; i: CARDINAL) ; |
| 52 |
|
| 53 |
|
| 54 |
(* |
| 55 |
copy - returns a copy of, v. |
| 56 |
*) |
| 57 |
|
| 58 |
PROCEDURE copy (v: vararg) : vararg ; |
| 59 |
|
| 60 |
|
| 61 |
(* |
| 62 |
replace - fills the next argument with, a. The size of, a, |
| 63 |
must be an exact match with the original vararg |
| 64 |
parameter. |
| 65 |
*) |
| 66 |
|
| 67 |
PROCEDURE replace (v: vararg; VAR a: ARRAY OF BYTE) ; |
| 68 |
|
| 69 |
|
| 70 |
(* |
| 71 |
end - destructor for vararg, v. |
| 72 |
*) |
| 73 |
|
| 74 |
PROCEDURE end (VAR v: vararg) ; |
| 75 |
|
| 76 |
|
| 77 |
(* |
| 78 |
start1 - wraps up argument, a, into a vararg. |
| 79 |
*) |
| 80 |
|
| 81 |
PROCEDURE start1 (a: ARRAY OF BYTE) : vararg ; |
| 82 |
|
| 83 |
|
| 84 |
(* |
| 85 |
start2 - wraps up arguments, a, b, into a vararg. |
| 86 |
*) |
| 87 |
|
| 88 |
PROCEDURE start2 (a, b: ARRAY OF BYTE) : vararg ; |
| 89 |
|
| 90 |
|
| 91 |
(* |
| 92 |
start3 - wraps up arguments, a, b, c, into a vararg. |
| 93 |
*) |
| 94 |
|
| 95 |
PROCEDURE start3 (a, b, c: ARRAY OF BYTE) : vararg ; |
| 96 |
|
| 97 |
|
| 98 |
(* |
| 99 |
start4 - wraps up arguments, a, b, c, d, into a vararg. |
| 100 |
*) |
| 101 |
|
| 102 |
PROCEDURE start4 (a, b, c, d: ARRAY OF BYTE) : vararg ; |
| 103 |
|
| 104 |
|
| 105 |
END varargs. |