Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ArrayBuffer detach operations #3208

Merged
merged 1 commit into from
Oct 16, 2019

Conversation

legendecas
Copy link
Contributor

Implement 24.1.1.3 DetachArrayBuffer( arrayBuffer ) operation.

JerryScript-DCO-1.0-Signed-off-by: legendecas [email protected]

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

@dbatyai dbatyai left a comment

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.

@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
Contributor Author

Style fixed :)

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

Copy link
Member

@rerobika rerobika left a comment

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.

docs/02.API-REFERENCE.md Show resolved Hide resolved
jerry_value_t res = jerry_detach_arraybuffer (buffer);

// release buffer as it is not needed after this point
jerry_release_value(res);
Copy link
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
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
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
Member

Choose a reason for hiding this comment

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

Ditto.

docs/02.API-REFERENCE.md Show resolved Hide resolved
docs/02.API-REFERENCE.md Show resolved Hide resolved
docs/02.API-REFERENCE.md Show resolved Hide resolved
{
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("Expects a detachable ArrayBuffer.")));
}
return ECMA_VALUE_UNDEFINED;
Copy link
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
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?


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
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 [email protected]
Copy link
Member

@rerobika rerobika left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@dbatyai dbatyai left a comment

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