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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
|
Nil {
*new { ^this.shouldNotImplement(thisMethod) }
isNil { ^true }
notNil { ^false }
? { arg obj; ^obj }
?? { arg obj; ^obj.value }
!? {}
asBoolean { ^false }
booleanValue { ^false } // TODO in the long-run, deprecate for asBoolean
// support a nil Environment
push { arg function; ^function.value }
appendStream { arg stream; ^stream }
pop {}
// support a nil Plug
source {}
source_ {}
// rate access support
rate { ^nil }
numChannels { ^nil }
isPlaying { ^false }
do {}
reverseDo {}
pairsDo {}
collect {}
select {}
reject {}
detect {}
collectAs {}
selectAs {}
rejectAs {}
collectInPlace {}
collectCopy {}
// dependancy operators are no-ops
dependants {
^IdentitySet.new
}
changed {}
addDependant {}
removeDependant {}
release {}
update {}
// nil Event support
transformEvent { arg event;
^event
}
awake { arg inBeats, inSeconds, inClock;
var temp;
temp = inBeats; // prevent optimization
^nil
}
play {}
nextTimeOnGrid { arg clock; ^clock !? { clock.nextTimeOnGrid } }
asQuant { ^Quant.default } // { ^Quant.new }
swapThisGroup {}
performMsg {}
printOn { arg stream;
stream.putAll("nil");
}
storeOn { arg stream;
stream.putAll("nil");
}
matchItem { ^true } // nil matches anything
// Array support
add { arg value;
// This makes it unecessary to check for array.isNil when doing:
// array = array.add(thing); Instead, it just works.
^[value]
}
addAll { arg array; ^array.asArray }
++ { arg array; ^array }
asCollection { ^[] }
remove {}
// ControlView support
set {}
get { arg prevVal; ^prevVal }
// FunctionList support
addFunc { arg ... functions;
^if(functions.size <= 1) {functions[0] } { FunctionList(functions) }
}
removeFunc { ^this }
replaceFunc { }
// if Main-startup fails then AppClock scheduler may be nil. If that happens an
// endless cascade of doesNotUnderstand messages gets printed in response to each clock tick
// unless we do this.
seconds_ {}
// throwing Nil
throw {}
handleError { arg error;
Error.handling = true;
if (Error.debug) {
{ error.inspect }.defer;
} {
error.reportError
};
Error.handling = false;
this.halt;
}
archiveAsCompileString { ^true }
asSpec {
^ControlSpec.new;
}
superclassesDo {}
}
|