Core library
This library is loaded on initialization and contains the functions and constants necessary to do primary actions:
- execution of additional scripts
- creating and using array, class, dict, map, closure
- converting between variables
- serialization / deserialization
- operation control
- error handling and throwing
- global environment modification
- standard input / output
- data debugging
Functions:
- containers
- array - returns an array containing the specified variables
- dict - returns a key-value map object (string keys) containing the specified variables
- map - returns a key-value map object (many key types) containing the specified variables
- class - returns an index fallback / overloading object, linking both specified variables
- array_filter - returns an array that is filtered with a truth test or the specified function
- array_process - convert all array elements by a function
- dict_filter - returns a dict object that is filtered with a truth test or the specified function
- map_filter - returns a map object that is filtered with a truth test or the specified function
- map_process - convert all dictionary elements by a function
- dict_size - returns the number of items in a dict
- map_size - returns the number of items in a map
- isset - checks if the specified property is available
- unset - unsets the specified property (only for dict/map objects)
- clone - returns the cloned variable or the same if immutable
- get_keys - returns an array of keys from an iterable
- get_values - returns an array of values from an iterable
- get_concat - returns an array with all values from all iterables concatenated together in order
- get_merged - returns a dict with all mappings merged
- get_merged_map - returns a map with all mappings merged
- get_iterator - returns an iterator from the passed object, if it has one
- iter_advance - advances an iterator to the next position, returning if there is any more data to read
- iter_getdata - returns key/value data from iterator
- type info and conversion
- tobool - returns a variable, converted to boolean
- toint - returns a variable, converted to an integer
- toreal - returns a variable, converted to a real value
- tostring - returns a variable, converted to a string
- toptr - returns a variable, converted to pointer
- parseint - try to parse a variable as integer, return the value or null on failure
- parsereal - try to parse a variable as string, return the value or null on failure
- typeof - returns the type string of a variable
- typeid - returns type ID of a variable
- typeptr - returns type interface pointer from object variables
- typeptr_by_name - returns type interface pointer by its name
- is_numeric - returns if variable is a numeric type
- is_callable - returns if variable can be called as a function
- is_array - returns if variable is an array
- is_dict - returns if variable is a dict
- is_map - returns if variable is a map
- input/output
- print, println, printlns, errprint, errprintln, errprintlns - write variables to output callback/stream
- printvar - write variable dumps to output callback/stream
- printvar_ext - write variable dump to output callback/stream, optionally specifying max. recursion depth
- read_stdin - attempt to read from standard input file (stdin)
- operating system
- ftime - returns an always increasing time value, in seconds, as a real value
- utilities
- rand - returns a random integer between 0 and RAND_MAX
- randf - returns a random real value between 0 and 1
- srand - reseed random number generator
- hash_fnv - generate a hash using the FNV-1a algorithm
- hash_crc32 - generate a hash/checksum using the crc32 algorithm
- SGS-specific utilities
- va_get_args - returns an array of all arguments passed to calling function
- va_get_arg - returns one of the arguments passed to calling function
- va_arg_count - returns the number of all arguments passed to calling function
- metaobj_set - sets the meta-object of an object
- metaobj_get - retrieves the meta-object of an object
- metamethods_enable - enables or disables metamethod support for an object
- metamethods_test - retrieves metamethod support state
- mm_getindex_router - routes __getindex to __get_***
- mm_setindex_router - routes __setindex to __set_***
- event - create an event
- pooled_event - create a pooled event (named event, in table)
- end_on - set or unset an event that can stop a thread
- co_create - create a coroutine
- co_resume - start/resume a coroutine
- thread_create - create a managed topmost coroutine (thread)
- subthread_create - create a managed sub-coroutine (subthread)
- yield - suspend current state, return to caller
- abort - stop the execution of the calling SGS function
- sys_apply - call a function/callable even more dynamically (argument count also specified at runtime)
- pcall - do a protected call by trapping all internal messages in the specified callback
- assert - emit an error if a condition does not evaluate to
true
- sym_register - register persistent object by name (for serialization)
- sym_get - map name to a registered variable or variable to name using the symbol table
- eval - compile and run script code, retrieve return values
- eval_file - compile and rune script file, retrieve return values
- compile_sgs - compile script code
- include_library - load a built-in library
- include_file - load a script file
- include_shared - load a dynamically linked library / shared object (.DLL/.SO)
- import_cfunc - load a C function from .DLL/.SO
- find_include_file - find the include file according to SGS_PATH
- include - load many types of files
- sys_curfile - returns the origin file of the calling function
- sys_curfiledir - returns the directory of the origin file of the calling function
- sys_curprocfile - returns the path to current process file
- sys_curprocdir - returns the path to the directory of current process file
- multiply_path_ext_lists - combine prefix/suffix path lists
- sys_backtrace - returns call stack info
- sys_msg - emit a system message
- INFO - emit an INFO message
- WARNING - emit a WARNING message
- ERROR - emit an ERROR message
- app_abort - abort execution of application (exit application immediately with an error)
- app_exit - exit application immediately
- sys_replevel - change the minimum message reporting level
- sys_stat - write info about system state
- errno - return current errno value as number or string
- errno_string - return specified or current errno value as string
- errno_value - return the errno value corresponding to the name
- dumpvar - returns the dump string of variables
- dumpvar_ext - returns the dump string of a variable, optionally specifying max. recursion depth
- gc_collect - run the garbage collector to remove inaccessible objects
- serialize - returns a byte buffer containing info necessary to later recreate variable structure
- unserialize - recreate variable structure from a byte buffer
Objects and their built-in methods:
Constants:
- SGS_*** - error levels
- VT_*** - variable type IDs
- RAND_MAX - maximum value that can be returned by rand
Other:
- _G - environment superglobal, a dict containing all global variable names and values; can be changed
In this section:
- array [function]
- array_sized [function]
- dict [function]
- map [function]
- class [function]
- array_filter [function]
- array_process [function]
- dict_filter [function]
- map_filter [function]
- map_process [function]
- dict_size [function]
- map_size [function]
- isset [function]
- unset [function]
- clone [function]
- get_keys [function]
- get_values [function]
- get_concat [function]
- get_merged [function]
- get_merged_map [function]
- get_iterator [function]
- iter_advance [function]
- iter_getdata [function]
- tobool [function]
- toint [function]
- toreal [function]
- tostring [function]
- toptr [function]
- parseint [function]
- parsereal [function]
- typeof [function]
- typeid [function]
- typeptr [function]
- typeptr_by_name [function]
- is_numeric [function]
- is_callable [function]
- is_array [function]
- is_dict [function]
- is_map [function]
- print, println, printlns, errprint, errprintln, errprintlns [functions]
- printvar_ext [function]
- printvar [function]
- read_stdin [function]
- ftime [function]
- rand [function]
- randf [function]
- srand [function]
- hash_fnv [function]
- hash_crc32 [function]
- va_get_args [function]
- va_get_arg [function]
- va_arg_count [function]
- metaobj_set [function]
- metaobj_get [function]
- metamethods_enable [function]
- metamethods_test [function]
- mm_getindex_router [function]
- mm_setindex_router [function]
- event [function]
- pooled_event [function]
- end_on [function]
- co_create [function]
- co_resume [function]
- thread_create [function]
- subthread_create [function]
- process_threads [function]
- yield [function]
- abort [function]
- sys_apply [function]
- pcall [function]
- assert [function]
- sym_register [function]
- sym_get [function]
- eval [function]
- eval_file [function]
- compile_sgs [function]
- include_library [function]
- include_file [function]
- include_shared [function]
- find_include_file [function]
- include [function]
- import_cfunc [function]
- sys_curfile [function]
- sys_curfiledir [function]
- sys_curprocfile [function]
- sys_curprocdir [function]
- multiply_path_ext_lists [function]
- sys_backtrace [function]
- sys_msg [function]
- INFO [function]
- WARNING [function]
- ERROR [function]
- app_abort [function]
- app_exit [function]
- sys_replevel [function]
- sys_stat [function]
- errno [function]
- errno_string [function]
- errno_value [function]
- dumpvar_ext [function]
- dumpvar [function]
- gc_collect [function]
- serialize [function]
- unserialize [function]
- sgson_encode [function]
- sgson_decode [function]
- SGS_*** [constants]
- VT_*** [constants]
- RAND_MAX [constant]
- _G [superglobal]
- _R [superglobal]
- _F [superglobal]
- _T [superglobal]
- array [object]
- array.push [method]
- array.pop [method]
- array.shift [method]
- array.unshift [method]
- array.insert [method]
- array.erase [method]
- array.part [method]
- array.clear [method]
- array.reverse [method]
- array.resize [method]
- array.reserve [method]
- array.sort [method]
- array.sort_custom [method]
- array.sort_mapped [method]
- array.find [method]
- array.remove [method]
- array.unique [method]
- array.random [method]
- array.shuffle [method]
- dict [object]
- map [object]
- ALL SGScript core functions (A-Z)