Removing an old, cherished, yet pointless caveat "This documentation is
[supercollider.git] / Help / Platform / Platform.html
blob37afe51d4d5d60da1d5e36bdd72738e74f32b1b2
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <meta http-equiv="Content-Style-Type" content="text/css">
6 <title></title>
7 <meta name="Generator" content="Cocoa HTML Writer">
8 <meta name="CocoaVersion" content="824.48">
9 <style type="text/css">
10 p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica}
11 p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
12 p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
13 p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; color: #0026b4}
14 p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica}
15 p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #0026b4}
16 p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}
17 p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #3d6d1d}
18 p.p9 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}
19 p.p10 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #0026b4; min-height: 12.0px}
20 span.s1 {color: #000000}
21 span.s2 {font: 12.0px Helvetica; color: #000000}
22 span.s3 {color: #3d6d1d}
23 span.s4 {color: #606060}
24 span.s5 {color: #0000ff}
25 span.s6 {text-decoration: underline ; color: #0035db}
26 span.s7 {color: #0026b4}
27 span.Apple-tab-span {white-space:pre}
28 </style>
29 </head>
30 <body>
31 <p class="p1"><b>Platform</b></p>
32 <p class="p2"><br></p>
33 <p class="p3"><b>superclass: Object</b></p>
34 <p class="p2"><br></p>
35 <p class="p3">The Platform class (along with its subclasses) handles things which differ between operating systems (mac/linux/windows/...), to simplify cross-platform aspects of SuperCollider.</p>
36 <p class="p2"><br></p>
37 <p class="p3">Platform is an <i>abstract class</i> encapsulating various platform dependent constants and properties, such as directories, primitive features and startup files. The platform object is accessible through the 'platform' method of the main process instance:</p>
38 <p class="p2"><br></p>
39 <p class="p4"><span class="Apple-tab-span"> </span>thisProcess<span class="s1">.platform</span></p>
40 <p class="p2"><br></p>
41 <p class="p3">Currently implemented platforms include: OSXPlatform, LinuxPlatform, WindowsPlatform, UnixPlatform.</p>
42 <p class="p2"><br></p>
43 <p class="p5"><b>Platform name and platform dependent actions</b></p>
44 <p class="p2"><br></p>
45 <p class="p3"><b>name</b> - returns the platform name</p>
46 <p class="p2"><br></p>
47 <p class="p3"><b>*case</b>(... <b>cases</b>)</p>
48 <p class="p2"><br></p>
49 <p class="p3"><span class="Apple-tab-span"> </span>perform actions depending on the current platform (name), just like Object:switch:</p>
50 <p class="p2"><br></p>
51 <p class="p6"><span class="s2"><span class="Apple-tab-span"> </span></span>Platform<span class="s1">.case(</span></p>
52 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s3">\osx</span>,<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>{ <span class="s4">"OSX"</span>.postln },</p>
53 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s3">\linux</span>,<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>{ <span class="s4">"Linux"</span>.postln },</p>
54 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s3">\windows</span>, <span class="Apple-tab-span"> </span>{ <span class="s4">"Windows"</span>.postln }</p>
55 <p class="p7"><span class="Apple-tab-span"> </span>);</p>
56 <p class="p2"><br></p>
57 <p class="p3"><b>*ideName</b> - returns a <a href="../Collections/String.html"><span class="s5">String</span></a> indicating which IDE the language believes it is running in. (Often this is determined via the "-i" option to the ./sclang executable.) This is determined when sclang starts and cannot be changed dynamically.</p>
58 <p class="p3">The main purpose of this is to include/exclude folders from the class search patch depending on which IDE is in use: for example, if the value of ideName is "scapp" then folders named "scide_scapp" are included and all other folders beginning with "scide_" are excluded. The default value of this is "none". Known IDE names in use are "scapp" (SuperCollider.app on Mac), "scvim" (vim), "scel" (emacs). Others may be used.</p>
59 <p class="p2"><br></p>
60 <p class="p2"><br></p>
61 <p class="p5"><b>Directories and filesystem stuff</b></p>
62 <p class="p2"><br></p>
63 <p class="p3"><b>classLibraryDir</b></p>
64 <p class="p3"><b>*classLibraryDir</b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>- location of the bundled class library</p>
65 <p class="p2"><br></p>
66 <p class="p3"><b>helpDir</b></p>
67 <p class="p3"><b>*helpDir</b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>- location of the bundled help files</p>
68 <p class="p2"><br></p>
69 <p class="p3"><b>systemAppSupportDir</b></p>
70 <p class="p3"><b>*systemAppSupportDir</b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>- system application support directory</p>
71 <p class="p2"><br></p>
72 <p class="p3"><b>userAppSupportDir</b></p>
73 <p class="p3"><b>*userAppSupportDir</b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>- user application support directory</p>
74 <p class="p2"><br></p>
75 <p class="p3"><b>systemExtensionDir</b></p>
76 <p class="p3"><b>*systemExtensionDir<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>- system extension directory (see <a href="../Extending and Customizing SC/Using-Extensions.html"><span class="s6">Using-Extensions</span></a>)</p>
77 <p class="p2"><br></p>
78 <p class="p3"><b>userExtensionDir</b></p>
79 <p class="p3"><b>*userExtensionDir<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>- user extension directory (see <a href="../Extending and Customizing SC/Using-Extensions.html"><span class="s6">Using-Extensions</span></a>)</p>
80 <p class="p2"><br></p>
81 <p class="p3"><b>platformDir</b></p>
82 <p class="p3"><b>*platformDir</b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>- platform specific directory for class files (see <a href="../Extending and Customizing SC/Using-Extensions.html"><span class="s6">Using-Extensions</span></a>)</p>
83 <p class="p2"><br></p>
84 <p class="p3"><b>pathSeparator</b></p>
85 <p class="p3"><b>*pathSeparator</b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>- platform specific path separator</p>
86 <p class="p2"><br></p>
87 <p class="p3"><b>Startup files</b></p>
88 <p class="p2"><br></p>
89 <p class="p3"><b>startupFiles</b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>- files to be loaded on startup</p>
90 <p class="p3"><b>loadStartupFiles</b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>- (re)load startup files</p>
91 <p class="p2"><br></p>
92 <p class="p5"><b>Features</b></p>
93 <p class="p2"><br></p>
94 <p class="p3">Features are abstract symbols that can be declared by extension authors and be checked during runtime in user code. Apart from explicitly declared features, class and primitive names are implicitly declared.</p>
95 <p class="p2"><br></p>
96 <p class="p3"><b>declareFeature(aSymbol)</b></p>
97 <p class="p2"><br></p>
98 <p class="p3"><span class="Apple-tab-span"> </span>Declare <b>aSymbol</b> to be a feature present in the runtime. Class names and primitive names cannot be declared as features.</p>
99 <p class="p2"><br></p>
100 <p class="p3"><b>hasFeature(aSymbol)</b></p>
101 <p class="p2"><br></p>
102 <p class="p3"><b><span class="Apple-tab-span"> </span></b>Return true if the feature <b>aSymbol</b> is present in the runtime system. <b>aSymbol </b>can refer to explicitly declared features as well as class and primitive names.</p>
103 <p class="p2"><span class="Apple-tab-span"> </span></p>
104 <p class="p7"><span class="Apple-tab-span"> </span><span class="s7">thisProcess</span>.platform.hasFeature(<span class="s3">\Object</span>);</p>
105 <p class="p8"><span class="s1"><span class="Apple-tab-span"> </span></span><span class="s7">thisProcess</span><span class="s1">.platform.hasFeature(</span>'_SCWindow_BeginFullScreen'<span class="s1">);</span></p>
106 <p class="p7"><span class="Apple-tab-span"> </span><span class="s7">thisProcess</span>.platform.hasFeature(<span class="s3">'_myFuncyPrimitive'</span>);</p>
107 <p class="p9"><span class="Apple-tab-span"> </span></p>
108 <p class="p8"><span class="s1"><span class="Apple-tab-span"> </span></span><span class="s7">thisProcess</span><span class="s1">.platform.declareFeature(</span>'superCrazyCompositionSystem'<span class="s1">);</span></p>
109 <p class="p8"><span class="s1"><span class="Apple-tab-span"> </span></span><span class="s7">thisProcess</span><span class="s1">.platform.hasFeature(</span>'superCrazyCompositionSystem'<span class="s1">);</span></p>
110 <p class="p10"><br></p>
111 <p class="p3"><b>when(features, ifFunction, elseFunction)</b></p>
112 <p class="p3"><b>*when(features, ifFunction, elseFunction)</b></p>
113 <p class="p2"><br></p>
114 <p class="p3"><b><span class="Apple-tab-span"> </span></b>Evaluate <b>ifFunction</b> if all <b>features</b> are present, otherwise evaluate <b>elseFunction</b>.</p>
115 <p class="p2"><span class="Apple-tab-span"> </span></p>
116 <p class="p7"><span class="Apple-tab-span"> </span><span class="s7">Platform</span>.when(#[<span class="s3">\Document</span>, <span class="s3">\SCWindow</span>], { <span class="s4">"yeehah!"</span>.postln });</p>
117 </body>
118 </html>