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 platform
method of the main process instance:
thisProcess.platform
Currently implemented platforms include: OSXPlatform, LinuxPlatform, WindowsPlatform, UnixPlatform.
Most of Platforms class methods are simply wrappers to thisProcess.platform.method
.
Perform actions depending on the current platform (name), just like Object:switch:
Platform.case( \osx, { "OSX".postln }, \linux, { "Linux".postln }, \windows, { "Windows".postln } );
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.
location of the bundled class library
location of the bundled help files
system application support directory
system extension directory (see Using Extensions)
user home directory
user application support directory
directory for configuration files
user extension directory (see Using Extensions)
platform specific directory for class files (see Using Extensions)
platform specific path separator
platform specific resource directory
platform recordings directory
default directory for temporary files
path |
A path string. |
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.
Evaluate ifFunction if all features are present, otherwise evaluate elseFunction.
Platform.when(#[\Document, \SCWindow], { "yeehah!".postln });
returns the platform name
recompile class library
location of the bundled class library
location of the bundled help files
system application support directory
system extension directory (see Using Extensions)
user home directory
user application support directory
directory for configuration files
user extension directory (see Using Extensions)
platform specific directory for class files (see Using Extensions)
platform specific path separator
platform recordings directory
platform specific resource directory
default directory for temporary files
files to be loaded on startup
(re)load startup files
kill all processes as defined by cmdLineArgs.
cmdLineArgs |
a string containing one or several process names. // e.g. kill all possibly running servers (scsynth or supernova) thisProcess.platform.killAll("scsynth supernova"); |
kill a single process as identified by its process ID.
pid |
an Integer which is the pid of the process to kill. // 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); |
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.
Declare aSymbol to be a feature present in the runtime. Class names and primitive names cannot be declared as features.
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.
thisProcess.platform.hasFeature(\Object); thisProcess.platform.hasFeature('_SCWindow_BeginFullScreen'); thisProcess.platform.hasFeature('_myFuncyPrimitive'); thisProcess.platform.declareFeature('superCrazyCompositionSystem'); thisProcess.platform.hasFeature('superCrazyCompositionSystem');
Evaluate ifFunction if all features are present, otherwise evaluate elseFunction.
thisProcess.platform.when(#[\Document, \SCWindow], { "yeehah!".postln });