Constructs a new ScriptAny based on the value given.
Enumeration of what type is held by a ScriptAny. Note that a function, array, or string can be used as an object, so the best way to check if a ScriptAny is a ScriptObject is to use isObject.
Add a get method to an object
Add a set method to an object
Attempt to assign a field of a complex object. This can be used to assign array indexes if the index is a number.
Overload to ignore the bool
Converts a stored value back into a D value if it is valid, otherwise throws an exception.
Returns true if the value stored is a valid integer, but not a floating point number.
Shorthand for testing if this is a ScriptObject containing a native D object of a specific type.
Returns true if the type is NULL or if it an object or function whose stored value is null. Note that the second condition should be impossible as receiving a null object value sets the type to NULL anyway.
Returns true if the value stored is a numerical type or anything that can be converted into a valid number such as boolean, or even null, which gets converted to 0.
This should always be used instead of checking type==OBJECT because ScriptFunction, ScriptArray, and ScriptString are valid subclasses of ScriptObject.
Returns true if the type is UNDEFINED.
Depending on the type of index, if it is a string it accesses a field of the object, otherwise if it is numerical, attempts to access an index of an array object.
Overload to ignore the bool
Assigns a value.
Implements binary math operations between two ScriptAnys and returns a ScriptAny. For certain operations that make no sense the result will be NaN or UNDEFINED. Addition involving any number of ScriptStrings will always coerce the values to string and perform a concatenation, as per Mildew language semantics.
opCast will now use toValue
The comparison operations.
Tests for equality by casting similar types to the same type and comparing values. If the types are too different to do this, the result is false.
Shorthand to access fields of the complex object types
Shorthand to assign fields of the complex object types
Defines unary math operations for a ScriptAny.
A method so that (undefined || 22) results in 22.
convert a value to raw bytes. Only certain values can be converted. Throws exception if not possible
This implements the '===' and '!==' operators. Objects must be exactly the same in type and value. This operator should not be used on numerical primitives because true === 1 will return false. Same with 1.0 === 1.
This allows ScriptAny to be used as a key index in a table, however the scripting language currently only uses strings. In the future a Map class will take advantage of this.
Shorthand for returning nativeObject from casting this to ScriptObject
Returns a string representation of the stored value
Similar to checkValue except if the type is invalid and doesn't match the template type, a sane default value such as 0 or null is returned instead of throwing an exception.
Returns the read-only type property. This should always be checked before using the toValue or checkValue template to retrieve the stored D value. Unless one is casting to primitives and does not care about the value being 0 or false.
For use with the scripting language's typeof operator
read a ScriptAny from a stream of bytes. if invalid data, throws exception
This should always be used to return an undefined value.
This variant holds primitive values as well as ScriptObject derived complex reference types.