Add a C API binding for Object.defineProperty(): duk_def_prop().
In addition to Object.defineProperty() features, the API call provides a
"force" flag which allows properties to be added to non-extensible objects
and non-configurable properties to be changed (except virtual properties
which are immutable).
Because the name duk_def_prop() conflicts with internal calls, rename them
from duk_def_prop*() to duk_xdef_prop*(). This rename also makes it clearer
that the internal duk_xdef_prop*() calls have non-compliant, internal
semantics.
Also reimplement Object.defineProperty() and Object.defineProperties() (and
duk_def_prop()) so that they share the same internal helpers, and there is
no need for a temporary property descriptor object which is unnecessary churn.
Detailed changes:
- New helper to prepare (validate and normalize) property descriptors
- New helper to implement Object.defineProperty() internals, leaving
out validation of the property descriptor
- Reimplement Object.defineProperty() using the new helpers
- Reimplement Object.defineProperties() using the new helpers
- Reimplement duk_define_property() using the new helpers, so that a
temporary property descriptor object is no longer created
- Add support for "force" flag to Object.defineProperty()
Use DUK_DPRINT instead of DUK_DPRINTF for heap stringtable dumps. This makes
the dump output go to stderr instead of stdout which is useful because it
allows e.g. testcase runs with debugs enabled.
Also fix typo which breaks compilation when using "chain" stringtable and no
pointer compression.
When Object.defineProperties() was used and set/get value was a lightfunc,
duk_to_object() was used for coercion. After the coercion, a previously
looked up duk_tval pointer was still being used; if the property table of
the property descriptor had been reallocated (pretty difficult to achieve
but possible, e.g. a finalizer triggered by GC could add an entry to it)
the duk_tval pointer could have been stale.
Rework the entire sequence a little bit and fix the issue in the process.
Add vararg variants: duk_error_va(), duk_push_error_object_va(), duk_log_va()
(see GH-65).
Also fix duk_push_error_object() problem when variadic macros are not
available (i.e. legacy platforms).
Add API calls:
- duk_error_va()
- duk_push_error_object_va()
- duk_log_va()
Also fix return value issue for duk_push_error_object() when variadic macros
are not available (i.e. legacy environments). The comma expression used by
the macro wasn't parenthesized which doesn't work correctly when the return
value is assigned to a variable.
There are some systems where SIZE_MAX is less than that even when the
platform is a 32-bit one. It's probably not useful to error out because
Duktape only uses SIZE_MAX for assertion(s) (only one assert right now).