GNU Octave
3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
liboctave
util
lo-macros.h
Go to the documentation of this file.
1
/*
2
3
Copyright (C) 2010-2013 VZLU Prague
4
5
This file is part of Octave.
6
7
Octave is free software; you can redistribute it and/or modify it
8
under the terms of the GNU General Public License as published by the
9
Free Software Foundation; either version 3 of the License, or (at your
10
option) any later version.
11
12
Octave is distributed in the hope that it will be useful, but WITHOUT
13
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15
for more details.
16
17
You should have received a copy of the GNU General Public License
18
along with Octave; see the file COPYING. If not, see
19
<http://www.gnu.org/licenses/>.
20
21
*/
22
23
#if !defined (octave_lo_macros_h)
24
#define octave_lo_macros_h 1
25
26
// Core macros. Iteration is supported up to count 10.
27
28
#define OCT_ITERATE_PARAM_MACRO0(MACRO, PARAM)
29
#define OCT_ITERATE_PARAM_MACRO1(MACRO, PARAM) \
30
MACRO(0, PARAM)
31
#define OCT_ITERATE_PARAM_MACRO2(MACRO, PARAM) \
32
MACRO(0, PARAM) MACRO(1, PARAM)
33
#define OCT_ITERATE_PARAM_MACRO3(MACRO, PARAM) \
34
MACRO(0, PARAM) MACRO(1, PARAM) MACRO(2, PARAM)
35
#define OCT_ITERATE_PARAM_MACRO4(MACRO, PARAM) \
36
MACRO(0, PARAM) MACRO(1, PARAM) MACRO(2, PARAM) MACRO(3, PARAM)
37
#define OCT_ITERATE_PARAM_MACRO5(MACRO, PARAM) \
38
MACRO(0, PARAM) MACRO(1, PARAM) MACRO(2, PARAM) MACRO(3, PARAM) MACRO(4, PARAM)
39
#define OCT_ITERATE_PARAM_MACRO6(MACRO, PARAM) \
40
OCT_ITERATE_PARAM_MACRO5(MACRO, PARAM) MACRO(5, PARAM)
41
#define OCT_ITERATE_PARAM_MACRO7(MACRO, PARAM) \
42
OCT_ITERATE_PARAM_MACRO5(MACRO, PARAM) MACRO(5, PARAM) MACRO(6, PARAM)
43
#define OCT_ITERATE_PARAM_MACRO8(MACRO, PARAM) \
44
OCT_ITERATE_PARAM_MACRO5(MACRO, PARAM) MACRO(5, PARAM) MACRO(6, PARAM) MACRO(7, PARAM)
45
#define OCT_ITERATE_PARAM_MACRO9(MACRO, PARAM) \
46
OCT_ITERATE_PARAM_MACRO8(MACRO, PARAM) MACRO(8, PARAM)
47
#define OCT_ITERATE_PARAM_MACRO10(MACRO, PARAM) \
48
OCT_ITERATE_PARAM_MACRO8(MACRO, PARAM) MACRO(8, PARAM) MACRO(9, PARAM)
49
50
// expands to MACRO(0, PARAM) MACRO(1, PARAM) ... MACRO(NUM-1, PARAM)
51
#define OCT_ITERATE_PARAM_MACRO(MACRO, PARAM, NUM) OCT_ITERATE_PARAM_MACRO##NUM(MACRO,PARAM)
52
53
#define OCT_IF_PARAM0(MACRO, PARAM)
54
#define OCT_IF_PARAM1(MACRO, PARAM) MACRO(PARAM)
55
#define OCT_IF_PARAM2(MACRO, PARAM) MACRO(PARAM)
56
#define OCT_IF_PARAM3(MACRO, PARAM) MACRO(PARAM)
57
#define OCT_IF_PARAM4(MACRO, PARAM) MACRO(PARAM)
58
#define OCT_IF_PARAM5(MACRO, PARAM) MACRO(PARAM)
59
#define OCT_IF_PARAM6(MACRO, PARAM) MACRO(PARAM)
60
#define OCT_IF_PARAM7(MACRO, PARAM) MACRO(PARAM)
61
#define OCT_IF_PARAM8(MACRO, PARAM) MACRO(PARAM)
62
#define OCT_IF_PARAM9(MACRO, PARAM) MACRO(PARAM)
63
64
// expands to MACRO(PARAM) if NUM > 0
65
#define OCT_IF_PARAM(NUM, MACRO, PARAM) OCT_IF_PARAM##NUM(MACRO, PARAM)
66
67
// concatenation and reverse concat
68
#define OCT_CONCAT2(ARG1, ARG2) ARG1 ## ARG2
69
#define OCT_CONCAT2_REVERSE(ARG1, ARG2) ARG2 ## ARG1
70
71
#define OCT_IF_HELPER(X) X
72
73
// expands to X if NUM > 0
74
#define OCT_IF(NUM, X) OCT_IF_PARAM(NUM, OCT_IF_HELPER, X)
75
76
#define OCT_ITERATE_MACRO_HELPER(NUM, MACRO) MACRO(NUM)
77
78
// expands to MACRO(0) ... MACRO(NUM-1)
79
#define OCT_ITERATE_MACRO(MACRO, NUM) OCT_ITERATE_PARAM_MACRO(OCT_ITERATE_MACRO_HELPER, MACRO, NUM)
80
81
#define OCT_MAKE_LIST_HELPER1(ARG) ARG,
82
83
// expands to MACRO(0), MACRO(1), ..., MACRO(NUM-1)
84
#define OCT_MAKE_LIST_HELPER(NUM, MACRO) OCT_IF_PARAM(NUM,OCT_MAKE_LIST_HELPER1,) MACRO(NUM)
85
86
#define OCT_MAKE_LIST(MACRO, NUM) OCT_ITERATE_PARAM_MACRO(OCT_MAKE_LIST_HELPER, MACRO, NUM)
87
88
#define OCT_MAKE_DECL_LIST_HELPER(NUM, PREFIX) \
89
OCT_IF_PARAM(NUM,OCT_MAKE_LIST_HELPER1,) OCT_CONCAT2(PREFIX, NUM)
90
91
// expands to TYPE PREFIX0, TYPE PREFIX1, ..., TYPE PREFIX ## (NUM-1)
92
#define OCT_MAKE_DECL_LIST(TYPE, PREFIX, NUM) \
93
OCT_ITERATE_PARAM_MACRO(OCT_MAKE_DECL_LIST_HELPER, TYPE PREFIX, NUM)
94
95
// expands to PREFIX0, PREFIX1, ..., PREFIX ## (NUM-1)
96
#define OCT_MAKE_ARG_LIST(PREFIX, NUM) \
97
OCT_ITERATE_PARAM_MACRO(OCT_MAKE_DECL_LIST_HELPER, PREFIX, NUM)
98
99
#endif
Generated on Mon Dec 30 2013 03:04:54 for GNU Octave by
1.8.1.2