forked from frsyuki/mpio
-
Notifications
You must be signed in to change notification settings - Fork 1
/
mpl.rb
73 lines (55 loc) · 924 Bytes
/
mpl.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
ARGS_MAX = 16
class VarlenGenerator
def initialize
@n = 1
end
def template
each_join {|i| "typename A#{i}" }
end
def args
each_join {|i| "A#{i} a#{i}" }
end
def args_ptr
each_join {|i| "A#{i}* a#{i}" }
end
def args_ref
each_join {|i| "A#{i}& a#{i}" }
end
def args_const_ref
each_join {|i| "const A#{i}& a#{i}" }
end
def types
each_join {|i| "A#{i}" }
end
def types_ptr
each_join {|i| "A#{i}*" }
end
def types_ref
each_join {|i| "A#{i}&" }
end
def types_const_ref
each_join {|i| "const A#{i}&" }
end
def params
each_join {|i| "a#{i}" }
end
def params_ptr
each_join {|i| "&#{i}*" }
end
def each_join(&block)
Array.new(@n) {|i| block.call(i+1) }.join(', ')
end
def each(&block)
1.upto(@n).each(&block)
nil
end
def run(&block)
ARGS_MAX.times {
block.call(self)
@n += 1
}
end
end
def varlen_each(&block)
VarlenGenerator.new.run(&block)
end