2 summary:: handle cross-platform differencies
3 categories:: CrossPlatform
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/Using-Extensions::)
56 method:: userExtensionDir
57 user extension directory (see link::Guides/Using-Extensions::)
60 platform specific directory for class files (see link::Guides/Using-Extensions::)
62 method:: pathSeparator
63 platform specific path separator
68 Evaluate ifFunction if all features are present, otherwise evaluate elseFunction.
70 Platform.when(#[\Document, \SCWindow], { "yeehah!".postln });
76 returns the platform name
78 subsection:: Directories and filesystem stuff
79 method:: classLibraryDir
80 location of the bundled class library
83 location of the bundled help files
85 method:: systemAppSupportDir
86 system application support directory
88 method:: userAppSupportDir
89 user application support directory
91 method:: userConfigDir
92 directory for configuration files
94 method:: systemExtensionDir
95 system extension directory (see link::Guides/Using-Extensions::)
97 method:: userExtensionDir
98 user extension directory (see link::Guides/Using-Extensions::)
101 platform specific directory for class files (see link::Guides/Using-Extensions::)
103 method:: pathSeparator
104 platform specific path separator
106 subsection:: Startup files
108 method:: startupFiles
109 files to be loaded on startup
111 method:: loadStartupFiles
112 (re)load startup files
114 subsection:: Features
116 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.
118 method:: declareFeature
119 Declare aSymbol to be a feature present in the runtime. Class names and primitive names cannot be declared as features.
122 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.
124 thisProcess.platform.hasFeature(\Object);
125 thisProcess.platform.hasFeature('_SCWindow_BeginFullScreen');
126 thisProcess.platform.hasFeature('_myFuncyPrimitive');
128 thisProcess.platform.declareFeature('superCrazyCompositionSystem');
129 thisProcess.platform.hasFeature('superCrazyCompositionSystem');
133 Evaluate ifFunction if all features are present, otherwise evaluate elseFunction.
135 thisProcess.platform.when(#[\Document, \SCWindow], { "yeehah!".postln });