2 summary:: handle cross-platform differencies
6 The Platform class (along with its subclasses) handles things which differ between operating systems (mac/linux/windows/...), to simplify cross-platform aspects of SuperCollider.
8 Platform is an abstract class encapsulating various platform dependent constants and properties, such as directories, primitive features and startup files. The platform object is accessible through the code::platform:: method of the main process instance:
13 Currently implemented platforms include: OSXPlatform, LinuxPlatform, WindowsPlatform, UnixPlatform.
16 Most of Platforms class methods are simply wrappers to code::thisProcess.platform.method::.
18 subsection:: Platform name and platform dependent actions
21 Perform actions depending on the current platform (name), just like Object:switch:
24 \osx, { "OSX".postln },
25 \linux, { "Linux".postln },
26 \windows, { "Windows".postln }
31 returns a String 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.
33 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".
35 Known IDE names in use are "scapp" (SuperCollider.app on Mac), "scvim" (vim), "scel" (emacs). Others may be used.
37 subsection:: Directories and filesystem stuff
38 method:: classLibraryDir
39 location of the bundled class library
42 location of the bundled help files
44 method:: systemAppSupportDir
45 system application support directory
47 method:: userAppSupportDir
48 user application support directory
50 method:: userConfigDir
51 directory for configuration files
53 method:: systemExtensionDir
54 system extension directory (see link::Guides/UsingExtensions::)
56 method:: userExtensionDir
57 user extension directory (see link::Guides/UsingExtensions::)
60 platform specific directory for class files (see link::Guides/UsingExtensions::)
62 method:: pathSeparator
63 platform specific path separator
66 platform specific resource directory
68 method:: defaultTempDir
69 default directory for temporary files
74 Evaluate ifFunction if all features are present, otherwise evaluate elseFunction.
76 Platform.when(#[\Document, \SCWindow], { "yeehah!".postln });
81 private:: shutdown, startup
84 returns the platform name
87 recompile class library
90 subsection:: Directories and filesystem stuff
91 method:: classLibraryDir
92 location of the bundled class library
95 location of the bundled help files
97 method:: systemAppSupportDir
98 system application support directory
100 method:: userAppSupportDir
101 user application support directory
103 method:: userConfigDir
104 directory for configuration files
106 method:: systemExtensionDir
107 system extension directory (see link::Guides/UsingExtensions::)
109 method:: userExtensionDir
110 user extension directory (see link::Guides/UsingExtensions::)
113 platform specific directory for class files (see link::Guides/UsingExtensions::)
115 method:: pathSeparator
116 platform specific path separator
119 platform specific resource directory
121 method:: recordingsDir
124 method:: defaultTempDir
125 default directory for temporary files
129 subsection:: Startup files
131 method:: startupFiles
132 files to be loaded on startup
134 method:: loadStartupFiles
135 (re)load startup files
137 subsection:: Features
139 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.
141 method:: declareFeature
142 Declare aSymbol to be a feature present in the runtime. Class names and primitive names cannot be declared as features.
145 Return true if the feature aSymbol is present in the runtime system. aSymbol can refer to explicitly declared features as well as class and primitive names.
147 thisProcess.platform.hasFeature(\Object);
148 thisProcess.platform.hasFeature('_SCWindow_BeginFullScreen');
149 thisProcess.platform.hasFeature('_myFuncyPrimitive');
151 thisProcess.platform.declareFeature('superCrazyCompositionSystem');
152 thisProcess.platform.hasFeature('superCrazyCompositionSystem');
156 Evaluate ifFunction if all features are present, otherwise evaluate elseFunction.
158 thisProcess.platform.when(#[\Document, \SCWindow], { "yeehah!".postln });