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 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
|
class:: Platform
summary:: handle cross-platform differencies
categories:: Platform
description::
The Platform class (along with its subclasses) handles things which differ between operating systems (mac/linux/windows/...), to simplify cross-platform aspects of SuperCollider.
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:
code::
thisProcess.platform
::
Currently implemented platforms include: OSXPlatform, LinuxPlatform, WindowsPlatform, UnixPlatform.
classmethods::
Most of Platforms class methods are simply wrappers to code::thisProcess.platform.method::.
subsection:: Platform name and platform dependent actions
method:: case
Perform actions depending on the current platform (name), just like Object:switch:
code::
Platform.case(
\osx, { "OSX".postln },
\linux, { "Linux".postln },
\windows, { "Windows".postln }
);
::
method:: ideName
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.
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.
subsection:: Directories and filesystem stuff
method:: classLibraryDir
location of the bundled class library
method:: helpDir
location of the bundled help files
method:: systemAppSupportDir
system application support directory
method:: systemExtensionDir
system extension directory (see link::Guides/UsingExtensions::)
method:: userHomeDir
user home directory
method:: userAppSupportDir
user application support directory
method:: userConfigDir
directory for configuration files
method:: userExtensionDir
user extension directory (see link::Guides/UsingExtensions::)
method:: platformDir
platform specific directory for class files (see link::Guides/UsingExtensions::)
method:: pathSeparator
platform specific path separator
method:: resourceDir
platform specific resource directory
method:: recordingsDir
platform recordings directory
method:: defaultTempDir
default directory for temporary files
method:: hasQt
true if the Qt library is available, false otherwise
method:: hasQtWebEngine
true if the QtWebEngine library is available, false otherwise
method:: architecture
A link::Classes/Symbol:: naming the architecture for which this version of SuperCollider was built.
Returns one of 'AArch32' (32-bit ARM), 'AArch64' (64-bit ARM, introduced in ARMv8), 'Itanium64', 'i386', 'x86_64',
'PowerPC', or 'unknown' if the architecture is unidentifiable.
subsection:: Features
method:: when
Evaluate ifFunction if all features are present, otherwise evaluate elseFunction.
code::
Platform.when(#[\Document, \SCWindow], { "yeehah!".postln });
::
instancemethods::
private:: shutdown, startup
method:: name
returns the platform name
method:: recompile
recompile class library
subsection:: Directories and filesystem stuff
method:: classLibraryDir
location of the bundled class library
method:: helpDir
location of the bundled help files
method:: systemAppSupportDir
system application support directory
method:: systemExtensionDir
system extension directory (see link::Guides/UsingExtensions::)
method:: userHomeDir
user home directory
method:: userAppSupportDir
user application support directory
method:: userConfigDir
directory for configuration files
method:: userExtensionDir
user extension directory (see link::Guides/UsingExtensions::)
method:: platformDir
platform specific directory for class files (see link::Guides/UsingExtensions::)
method:: pathSeparator
platform specific path separator
method:: pathDelimiter
platform specific path delimiter
method:: recordingsDir
platform recordings directory
method:: resourceDir
platform specific resource directory
method:: defaultTempDir
default directory for temporary files
method:: formatPathForCmdLine
argument:: path
A path string.
returns:: The input string formatted as a command-line argument. On Windows this
method quotes the string. On Unix-based systems this method escapes space
characters with a backslash.
subsection:: Startup files
method:: startupFiles
files to be loaded on startup
method:: loadStartupFiles
(re)load startup files
subsection:: System commands
method:: killAll
kill all processes as defined by cmdLineArgs.
argument:: cmdLineArgs
a string containing one or several process names.
code::
// e.g. kill all possibly running servers (scsynth or supernova)
thisProcess.platform.killAll("scsynth supernova");
::
method:: killProcessByID
kill a single process as identified by its process ID.
argument:: pid
an Integer which is the pid of the process to kill.
code::
// start a server program from the cmdLine for testing
~pid = unixCmd(Server.program + s.options.asOptionsString(57100));
// kill just that server program by its pid:
thisProcess.platform.killProcessByID(~pid);
::
subsection:: Features
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.
method:: declareFeature
Declare aSymbol to be a feature present in the runtime. Class names and primitive names cannot be declared as features.
method:: hasFeature
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.
code::
thisProcess.platform.hasFeature(\Object);
thisProcess.platform.hasFeature('_SCWindow_BeginFullScreen');
thisProcess.platform.hasFeature('_myFuncyPrimitive');
thisProcess.platform.declareFeature('superCrazyCompositionSystem');
thisProcess.platform.hasFeature('superCrazyCompositionSystem');
::
method:: when
Evaluate ifFunction if all features are present, otherwise evaluate elseFunction.
code::
thisProcess.platform.when(#[\Document, \SCWindow], { "yeehah!".postln });
::
|