Home Reference Source
import {SCLang} from 'supercolliderjs/src/lang/sclang.js'
public class | source

SCLang

Extends:

EventEmitter → SCLang

Constructor Summary

Public Constructor
public

constructor(options: {})

Member Summary

Public Members
public

log: *

public

options: *

public

process: *

public

Method Summary

Public Methods
public

args(options: *): *

build args for sclang

public

boot

public

executeFile(filename: *): *

executeFile

public

installListeners(subprocess: *, listenToStdin: *)

listen to events from process and pipe stdio to the stateWatcher

public

interpret(code: String, nowExecutingPath: String, asString: Boolean, postErrors: Boolean, getBacktrace: Boolean): Promise

interpret

public

makeSclangConfig

public
public

quit(): *

public

sclangConfigOptions

public

spawnProcess(execPath: string, commandLineOptions: object): Promise

spawnProcess - starts the sclang executable

public

storeSclangConf

public

write(chunk: *, callback: *, noEcho: *)

write

Public Constructors

public constructor(options: {}) source

Params:

NameTypeAttributeDescription
options {}
  • optional
  • default: {}

Public Members

public log: * source

public options: * source

public process: * source

public stateWatcher: * source

Public Methods

public args(options: *): * source

build args for sclang

-d <path> Set runtime directory -D Enter daemon mode (no input) -g <memory-growth>[km] Set heap growth (default 256k) -h Display this message and exit -l <path> Set library configuration file -m <memory-space>[km] Set initial heap size (default 2m) -r Call Main.run on startup -s Call Main.stop on shutdown -u <network-port-number> Set UDP listening port (default 57120) -i <ide-name> Specify IDE name (for enabling IDE-specific class code, default "none") -a Standalone mode

Params:

NameTypeAttributeDescription
options *

Return:

*

public boot(): Promise source

boot

start sclang as a subprocess

Return:

Promise

public executeFile(filename: *): * source

executeFile

Params:

NameTypeAttributeDescription
filename *

Return:

*

public installListeners(subprocess: *, listenToStdin: *) source

listen to events from process and pipe stdio to the stateWatcher

Params:

NameTypeAttributeDescription
subprocess *
listenToStdin *

public interpret(code: String, nowExecutingPath: String, asString: Boolean, postErrors: Boolean, getBacktrace: Boolean): Promise source

interpret

evaluates code in sclang and returns a promise

resolves promise with result or rejects with error as JSON

Params:

NameTypeAttributeDescription
code String

source code to evaluate

nowExecutingPath String

set thisProcess.nowExecutingPath for use in a REPL to evaluate text in a file and let sclang know what file it is executing.

asString Boolean

return result .asString for post window otherwise returns result as a JSON object

postErrors Boolean

call error.reportError on any errors which posts call stack, receiver, args, etc

getBacktrace Boolean

return full backtrace

Return:

Promise

public makeSclangConfig(config: object): Promise source

makeSclangConfig

make sclang_config.yaml as a temporary file with the supplied values

This is the config file that sclang reads, specifying includePaths and excludePaths

Params:

NameTypeAttributeDescription
config object

options to write to file

Return:

Promise

resolving with the path of the temp config file

public makeStateWatcher(): * source

Return:

*

public quit(): * source

Return:

*

public sclangConfigOptions(options: object): object source

sclangConfigOptions

Builds the options that will be written to the config file that is read by sclang If supercolliderjs-conf specifies a sclang_conf path then this is read and any includePaths and excludePaths are merged

throws error if config cannot be read

Params:

NameTypeAttributeDescription
options object

supercolliderJs options

Return:

object

sclang_config variables

public spawnProcess(execPath: string, commandLineOptions: object): Promise source

spawnProcess - starts the sclang executable

sets this.process adds state listeners

Params:

NameTypeAttributeDescription
execPath string

path to sclang

commandLineOptions object

options for the command line filtered with this.args so it will only include values that sclang uses.

Return:

Promise

resolves null on successful boot and compile rejects on failure to boot or failure to compile the class library

public storeSclangConf(): * source

storeSclangConf

Return:

*

public write(chunk: *, callback: *, noEcho: *) source

write

send a raw string to sclang to be interpreted callback is called after write is complete

Params:

NameTypeAttributeDescription
chunk *
callback *
noEcho *