-
Notifications
You must be signed in to change notification settings - Fork 684
Added new 'jerry_value_strict_equal' API function. #2725
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
Conversation
docs/02.API-REFERENCE.md
Outdated
@@ -1630,6 +1630,41 @@ jerry_value_is_undefined (const jerry_value_t value) | |||
|
|||
- [jerry_release_value](#jerry_release_value) | |||
|
|||
|
|||
## jerry_value_strict_equal |
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 we gave strict equal check api, then maybe we should also have the simple logic operators also (<, >, ==
). However that would be another PR if we decide to implement it.
58e047c
to
c811850
Compare
Added new API function to perform strict equality comparison between 'jerry_value_t's from C code. JerryScript-DCO-1.0-Signed-off-by: László Langó [email protected]
c811850
to
9d724db
Compare
I've updated the PR. |
/* | ||
* Comparison functions | ||
*/ | ||
jerry_value_t jerry_strict_equal (const jerry_value_t lhs, const jerry_value_t rhs); |
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 strict comparison is made part of the public API, shouldn't ecma_op_abstract_equality_compare
have its API counterpart, too?
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.
The same was suggested by @galpeter. IMO, It would be nice to add other comparison features to the API as well. I think one new API function/PR is enough. I have two open PRs about this topic, so I do not want to open new similar PRs until these have not been merged.
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.
Hm, I've missed @galpeter 's suggestion. I'm not sure I completely agree with the one function in this PR though. The < and > operators aren't necessarily needed here, but === and == are quite related, so publishing them via API should happen together, IMO.
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.
@akosthekiss To have other comparison api functions was suggested in my post above, but I had another "idea" which was not written down yet: As we introduce more and more api functions for comparisons, does it make sense to have a single function for each of them or is it possible to have a single api function which can be configured to perform different kind of comparisons?
For example something like this (do not take the naming into account just the concept):
enum jerry_binary_operation {
JERRY_OP_STRICT_EQUALS, // lhs === rhs
JERRY_OP_EQUALS, // lhs == rhs
JERRY_OP_NOT_EQUAL, // lhs != rhs
JERRY_OP_LESS, // lhs < rhs
...
JERRY_OP_ADD, // lhs + rhs
};
jerry_value_t
jerry_op (jerry_binary_operation op, jerry_value_t lhs, jerry_value_t rhs);
I'm not sure which approach is better: having api functions for each operation or having a single one. (Maybe this discussion needs its own issue.)
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 like this idea.
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.
@galpeter I like your idea, I will do it.
Added new API function to perform strict equality comparison
between 'jerry_value_t's from C code.
JerryScript-DCO-1.0-Signed-off-by: László Langó [email protected]