Revise the API ArrayBuffer related operations (#4284)

- External ArrayBuffer construction with 0 length should be equivalent to `new ArrayBuffer(0)`
- Internally allocated ArrayBuffers should be detachable
- Externally allocated ArrayBuffers free callback should be called when underlying buffer is detached

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
Robert Fancsik
2020-10-09 15:12:45 +02:00
committed by GitHub
parent 5b9a6deb93
commit e3481d431b
7 changed files with 93 additions and 59 deletions
+5 -1
View File
@@ -9011,7 +9011,9 @@ jerry_get_arraybuffer_pointer (const jerry_value_t value);
- `value` - Array Buffer object.
- return value
- pointer to the Array Buffer's data area.
- NULL if the `value` is not an Array Buffer object.
- NULL if the `value` is:
- not an ArrayBuffer object
- an external ArrayBuffer has been detached
*New in version 2.0*.
@@ -9096,6 +9098,8 @@ jerry_value_t
jerry_detach_arraybuffer (const jerry_value_t value);
```
*Note*: If the ArrayBuffer has been created with `jerry_create_arraybuffer_external` the optional free callback is called on a successful detach operation
- `value` - ArrayBuffer to be detached
- return
- null value if success