-
Notifications
You must be signed in to change notification settings - Fork 0
/
makeExtensions.scd
52 lines (50 loc) · 1.53 KB
/
makeExtensions.scd
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
// this script is used to generate Extensions/extFluidBufProc.sc
(
var getSignature = { |m|
var args = m.argNames.as(Array);
var vals = m.prototypeFrame.as(Array);
var removeArgs = [\this, \source, \server, \action] ++
[\features, \indices, \destination].detect(args.includes(_));
removeArgs.collect(args.indexOf(_)).sort.reverse.do { |n|
[vals, args].do(_.removeAt(n))
};
args.collect { |argName, n|
var val = vals[n];
if (val.isNil) { argName } {
argName ++ " = " ++ if (val.isArray) {"#"++val } { val }
}
}.join(", ")
};
var ext = FluidBufProcessor.subclasses
.select { |sc|
var m = sc.class.findMethod(\process);
m.notNil and: {
[\source, \server, \action].every(m.argNames.includes(_))
and: {
[\stats, \features, \indices, \destination].any(m.argNames.includes(_))
}
}
}
.collect { |sc|
var name = sc.name;
var method = sc.class.findMethod(\process);
var signature = getSignature.value(method);
var args = method.argNames.drop(1).as(Array)
.replace(\server, '~src.server')
.replace(\source, '~src')
.replace(\action, '~done');
case
{ args.includes(\stats) } { args = args.replace(\stats, '~dst') }
{ args.includes(\features) } { args = args.replace(\features, '~dst') }
{ args.includes(\indices) } { args = args.replace(\indices, '~dst') }
{ args.includes(\destination) } { args = args.replace(\destination, '~dst') };
"+ % {
\t*chain { |%|
\t\t^this.process(%);
\t}
}".format(name, signature, args.join(", "));
}
.join($\n);
File.use("Classes/Extensions/extFluidBufProc.sc", "w") { |f| f.write(ext) };
0.exit;
)