Skip to content

Latest commit

 

History

History
209 lines (176 loc) · 5.66 KB

builtin_objects.md

File metadata and controls

209 lines (176 loc) · 5.66 KB

MOSER builtin objects

string

string of characters (usually utf-8)

length field holding the length of the string, in bytes
add(str,...) appends all strings passed as arguments to this string
substr(start) or substr(start,n) returns the substring starting at zero-based index start. if n is given, return max n bytes of that string
find(str) return the zero-based index of the first occurence of str, or -1
split(str) splits the string on str boundaries and returns an array of the split result.
replace_all(rgxwhat,with) return a new string where all occurences of regex what are replaced by with.
replace(rgxwhat,with) return a new string where the first occurence of regex what is replaced by with.

class

a class is a global object that can be used to procude new object instances of that class.

keys() returns an array with all the properties of this class. class properties are basically static properties belonging to the class instance, not an object instance.
methods() returns an array with all the member function names.

object instance

className field holding the name of the class this object was constructed from.
type field holding a reference to the class instance this object was constructed from
keys() returns an array with all this object's property names.
methods() returns an array with all this object's member function names.

map

Map is like a JavaScript Object.

length a field holding the number of keys in this map
exists(key) returns true if key exists in this map, otherwise false.
keys() returns an array with all the key names of this map.
forEach(visitor) calls function visitor(key,value) callback for each key and value of this map
filter(visitor) calls function visitor(key,value) callback for each key and value of this map. if visitor returns true, this key:value pair will be added to the result map returned by filter.
transform(visitor) calls function visitor(key,value) callback for each key and value of this map. if visitor does not return nil, the return value will be added to the result map.
sort() or sort(compare) returns a new, sorted array. if compare(rhs,lhs) function is specified, it will be called to compare two elements. the compare function should return 0 for equality or -1 and 1 for lower / greater.

array

length fielding holding the number of elements in this array
contains(element) return true if the array contains that element
join(array) adds all elements from array to this array.
pop() pops the last element from this array and returns it
back() returns the last element of the array
add(value) and push(value) adds value to the end of the array
forEach(visitor) calls function visitor(value) callback for each value of this array
filter(visitor) calls function visitor(value) callback for each key and value of this map. if visitor returns true, this value will be added to the result array returned by filter.
transform(visitor) calls function visitor(value) callback for each kvalue of this array. if visitor does not return nil, the return value will be added to the result array.

regex

simple wrapper around c++ regex

suffix field holding the regex suffix
match(str) return nil if this regex does not match str. otherwise it returns an array where the first element is the matched string, and the following elements hold each regex capturing group as a substring
search(str) like match but to be called more than once to find all occurences of rgx in str.
replace(str,with) replacde first occurences of this rgx in str by with.
replace:all(str,with) replacde all occurences of this rgx in str by with.

decorator

a python like decorator around a function.

see here for basic decorator usage.

runtimeproxy

a Java like runtime proxy around a target object. see here for basic decorator usage.

win32 only:

wstring

like string but for Win32 16-bit unicode. wstring does not offer methods or properties, it just exists to call Win32 API functions expecting wide strings.

create a wstring from a string by calling the global wstring(str) function. to convert back, call the global string(wstring) function.

com objects

not meant to be called directly, used by WinRT projection to call WinRT COM objects

see here for basic winRT COM usage.

dispatch object

encapsulates a classic COM Dispatch object aka OLE Automation.

see here for basic COM Dispatch usage