-
Notifications
You must be signed in to change notification settings - Fork 676
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
Add new API function #1161
Conversation
JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (ret_value)); | ||
|
||
return length; | ||
} /* jerry_get_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
ECMA_FINALIZE (len_value); | ||
|
||
ecma_deref_ecma_string (magic_string_length_p); | ||
JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (ret_value)); |
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); | ||
|
||
ecma_number_t num_var = ecma_number_make_nan (); |
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
* | ||
* Note: | ||
* Returns 0, if the given parameter is not an array object or | ||
* cannot retrieve the 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.
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ó [email protected]
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ó [email protected]