Skip to content

Add ArrayBuffer detach operations - #3208

Merged
dbatyai merged 1 commit into
jerryscript-project:masterfrom
legendecas:arraybuffer-detach
Oct 16, 2019
Merged

dbatyai merged 1 commit into
jerryscript-project:masterfrom
legendecas:arraybuffer-detach

Conversation

@legendecas

Copy link
Copy Markdown
Contributor

Implement 24.1.1.3 DetachArrayBuffer( arrayBuffer ) operation.

JerryScript-DCO-1.0-Signed-off-by: legendecas legendecas@gmail.com

@dbatyai dbatyai added the ES2015 Related to ES2015 features label Oct 8, 2019

@dbatyai dbatyai left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, please fix the style issues reported by Travis.

Comment thread tests/unit-core/test-arraybuffer.c Resolved
@dbatyai dbatyai added the api Related to the public API label Oct 8, 2019
@legendecas
legendecas force-pushed the arraybuffer-detach branch 2 times, most recently from 53d52c6 to 2b5ac1f Compare October 9, 2019 02:23
@legendecas

Copy link
Copy Markdown
Contributor Author

Style fixed :)

But looks like travis failed to install dependencies :( https://travis-ci.org/jerryscript-project/jerryscript/jobs/595415709

@rerobika rerobika left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me after fixing these minor style issues.

Comment thread docs/02.API-REFERENCE.md Resolved
Comment thread docs/02.API-REFERENCE.md Outdated
jerry_value_t res = jerry_detach_arraybuffer (buffer);

// release buffer as it is not needed after this point
jerry_release_value(res);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space before (

/**
* Helper function: check if the target ArrayBuffer is detached
*
*

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 new line is enough

/* in case the arraybuffer has been detached */
return array_p->buffer_p == NULL;
}
else

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO return false; is enough here, the else block is unnecessary.

}
else
{
return false;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

Comment thread docs/02.API-REFERENCE.md Resolved
Comment thread docs/02.API-REFERENCE.md Resolved
Comment thread docs/02.API-REFERENCE.md Resolved
Comment thread jerry-core/api/jerry.c Outdated
{
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("Expects a detachable ArrayBuffer.")));
}
return ECMA_VALUE_UNDEFINED;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to return ECMA_VALUE_TRUE here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked ECMA spec for the return value. It's expecting null. I'll update to be compliant with the spec. Would this be ok with your suggestion?

Comment thread tests/unit-core/test-arraybuffer.c Outdated

jerry_value_t is_detachable = jerry_is_arraybuffer_detachable (arraybuffer);
TEST_ASSERT (!jerry_value_is_error (is_detachable));
TEST_ASSERT (!jerry_value_to_boolean (is_detachable));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we also should test that the type of the return value is ok. By using to_boolean we force a conversion if the return value was not a boolean. We can simply use the jerry_get_boolean_value.

@legendecas
legendecas force-pushed the arraybuffer-detach branch 2 times, most recently from d1aa140 to e5ebaa0 Compare October 15, 2019 15:47
JerryScript-DCO-1.0-Signed-off-by: legendecas legendecas@gmail.com

@rerobika rerobika left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dbatyai dbatyai left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dbatyai
dbatyai merged commit 2e86bda into jerryscript-project:master Oct 16, 2019
@legendecas
legendecas deleted the arraybuffer-detach branch October 16, 2019 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Related to the public API ES2015 Related to ES2015 features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants