-
Notifications
You must be signed in to change notification settings - Fork 686
Add new API function #1161
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 new API function #1161
Conversation
jerry-core/jerry.c
Outdated
| ecma_deref_ecma_string (magic_string_length_p); | ||
| JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (ret_value)); | ||
|
|
||
| return length; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this separate function is needed?
5bfa712 to
cb10d1d
Compare
jerry-core/jerry.c
Outdated
| ECMA_OP_TO_NUMBER_FINALIZE (len_number); | ||
| ECMA_FINALIZE (len_value); | ||
|
|
||
| ecma_deref_ecma_string (magic_string_length_p); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to handle/free the error if we happen to get one. I don't think hoping that people will play by the rules, and only pass valid arrays to this function is enough.
501b6db to
93e6c5a
Compare
|
|
||
| ecma_value_t len_value = ecma_op_object_get ((jerry_object_t *) object_p, magic_string_length_p); | ||
| ecma_deref_ecma_string (magic_string_length_p); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think an intermediate variable is necessary.
93e6c5a to
880fad7
Compare
jerry-core/jerry.c
Outdated
| * Get length of an array object | ||
| * | ||
| * Note: | ||
| * Returns 0, if the given parameter is not an array object or |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it is an array you can always retreive the length. It is an unconfigurable data property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can pass any 'const jerry_object_t *object_p' to this function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am sorry I wasn't clear. So:
if array -> return length, always
if not -> return 0
So the correct comment is:
Returns 0, if the given parameter is not an array object
|
LGTM after these are fixed |
880fad7 to
dd43119
Compare
Implemented 'jerry_is_array' and 'jerry_get_array_length' API functions. JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
dd43119 to
cfa0c94
Compare
|
LGTM |
1 similar comment
|
LGTM |
Implemented 'jerry_is_array' and 'jerry_get_array_length' API functions.
JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com