Functions
Arrays
- var array() - creates an empty
array
- var array(const var&) - creates an array of one element
- var array(const var&, const var& …) - creates an array
of the given elements
- template<std::size_t N>
var array(var
(&)[N])
- creates an array from a C-style array
- var array_from(const
var&) - creates an array and populates it with the members
of another container
- template<typename ForwardIterator> var array_it(ForwardIterator
start, ForwardIterator end) - creates an array and
populates it with elements between a pair of C++ iterators
- var fill_array(const
var & size, const var
& item)
- creates an array containing a single item repeated size times
Lists
- var list() - creates an empty list
- var list(const var&) - creates a list with a single element
- var list(const var&, const var& …) - creates a list of the
given elements
- template<std::size_t N>
var list(var
(&)[N])
- creates a list from a C-style array
- var list_from(const
var&) - creates a list populated with members from another
container
- template<typename ForwardIterator> var list_it(ForwardIterator
a, ForwardIterator b) - creates a list
populated with elements between two C++ iterators
- var fill_list(const
var & size, const var
& item)
- creates a list containing one item repeated size times
Maps
- var map() - creates an empty map
- var map(const var&key, const var&value) - creates a map
containing one key-value pair
Sets
- var set() - creates an empty set
- var set(const var&) - creates a set containing one item
- var set(const var&, const var& …) - creates a set of the
given elements
- var set_from(const
var&) - creates a set containing elements from another
container
- template<typename ForwardIterator> var set_it(ForwardIterator
a, ForwardIterator b) - creates a set populated
with elements between two C++ iterators
Containers
- var enumerate(const var & fn) - creates a container by enumerating a function until
it returns null
- var filter(const var & container, const var
& pred) - creates a container which filters the contents of
another container
- var reverse(const var & container) - creates the reverse of a container
- var tail(const var & container) - creates a container with the first element removed
- var transform(const var & container, const var
& fn)
- creates a container by transforming the contents of another container
Sequences
- var range(const var & from, const var
& to)
- creates an inclusive sequence
- var range(const var & from, const var
& to, const var & step) - creates an inclusive
sequence with a specified step size
- var range_ex(const
var & from, const var
& to)
- creates an exclusive sequence
- var range_ex(const
var & from, const var
& to, const var & step) - creates an exclusive
sequence with a specified step size
- var sequence(const var & start, const var
& len) - creates a sequence of a specified size
- var sequence(const var & start, const var
& len, const var
& step)
- creates a sequence of a specified size and step size
Control flow
- foreach( loop_var,
container )
- enumerates an entire container
- finally( fn ) - executes fn at the end of the block, even
when an exception is thrown
Objects
- var bind(const var & fn, ...) - creates a closure by fixing a number of arguments to
a functor
- var dispatcher(const var & object) - creates a dispatcher object
- var object() - creates an empty
object with an empty class name
- var object(const char * class_name) - creates an empty object with the specified class
name
- var varargs(const
var & fn) - creates a functor taking a
variable number of arguments
Threads
- var event() - creates an event
object
- void exec(const var &
exe, const var & args) - executes the
executable with the arguments
- var message_queue(const
var & fn, const var
& threads=1)
- creates a message queue
- var mutex() - creates a mutex object
- var queue() - creates a queue
- var shared(const var & fn) - executes the functor in a
new apartment
- void sleep(const var &
seconds)
- suspends the thread for a given time
- var system(const var & cmd) - executes the system
command
- var thread(const var & fn) - runs the functor in a new
thread
Strings
- var pad(const var & str, const var & size) - truncates a string to a given size, or pads it with
spaces
- var is_not_one_of(var str, var
ch) - returns true if the character ch
is not found in the string str
- var is_one_of(var str, var
ch) - returns true if the character ch
is in the string str
- var is_space(var ch) - returns true if the
character ch is a whitespace character
- var split_chars(const
var & pred, const var & str) - returns an array of
strings with str split into groups or
characters matching pred
- var string_find(const
var & haystack, const var
& needle)
- returns a sequence where needle is in haystack, or null if
not found
- var string_find_all(const
var & haystack, const var
& needle)
- returns an array of sequences where needle is found in haystack
- var string_find_last(const
var & haystack, const var
& needle)
- returns the last sequence where needle is found in haystack
- var string_from(const
var&) - creates a string from the elements in another
container
- template<typename ForwardIterator> var string_it(ForwardIterator, ForwardIterator) - creates a string from the characters between the C++
iterators
- var substring(const var & str, const var & seq) - returns the given
substring of a string
Streams
- var characters(const var & file) - enumerate all of the characters in a file
- enable_pickle(function) - macro to enable a
function to be pickled
- var err() - returns the standard
error stream
- var fstat(const
var & filename) - returns the file
status information
- var in() - returns the standard
input stream
- var lines(const var & file) - enumerate all of the lines in a file
- var mem_file() - creates an in-memory
file
- var open_file(const
var & filename, std::ios_base::openmode) - opens a file with
specified flags
- var out() - returns the standard
output stream
- void pickle_file(const var & filename, const var
& v)
- stores the given value in a file
- var read_file(const
var & filename) - opens a file for
reading
- var readln() - reads a single line
from standard input
- void write(const var&) - writes text to
standard output
- void writeln() - writes a blank line
to standard output
- void writeln(const var&) - writes a single line to standard output
- void write_file(const var & filename) - opens a file for writing
- var unpickle_file(const
var & filename) - retrieves the given
value from a file
Garbage collection
- void gc_disable() - disable garbage
collection for the current heap (can be nested)
- void gc_enable() - enable garbage
collection (nested)
- void gc_force_collect() - perform a full
garbage collect on the current heap (don't use)
- void gc_hint_collect() - hint that the garbage
collector can collect now (use this instead)
- void gc_tune(int factor, int idle, int min) - used to adjust the GC settings
Miscellaneous
- assertx(const var&) - tests a condition and throws an exception if it is
false
- template<typename T>
create()
- creates a var containing any C++ value
- template<typename T>
create(const T&)
- creates a var containing any C++ value
- var global() - access to global
variables
- var global(const var & fn) - executes the given functor
on the global heap
- var max(const var &a, const var &
b) -
returns the larger of a and b
- var min(const var & a, const var &
b) -
returns the smaller of a and b
- null - the null value
- std::string pickle(const var&) - pickles a var
- var run_tests(const
var & tests) - runs all the functors in the map of tests
- var script_main(var args) - the entry point
of the program
- var stack_trace() - returns a snapshot of
the stack
- var timer() - returns the number of
seconds since the start of the program
- var unpickle(const
std::string&) - converts a pickled
string back into a var
- var version() - returns the version
string of the C++Script library.