Added new 'jerry_binary_operation' API function (#2746)

JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
This commit is contained in:
László Langó
2019-02-06 15:40:54 +01:00
committed by GitHub
parent 5e846c9efa
commit 81ccd6a743
5 changed files with 451 additions and 0 deletions
+75
View File
@@ -276,6 +276,18 @@ An opaque declaration of the JerryScript context structure.
typedef struct jerry_context_t jerry_context_t;
```
## jerry_binary_operation_t
Enum that contains the supported binary operation types
- JERRY_BIN_OP_EQUAL - equal comparison (==)
- JERRY_BIN_OP_STRICT_EQUAL - strict equal comparison (===)
- JERRY_BIN_OP_LESS - less relation (<)
- JERRY_BIN_OP_LESS_EQUAL - less or equal relation (<=)
- JERRY_BIN_OP_GREATER - greater relation (>)
- JERRY_BIN_OP_GREATER_EQUAL - greater or equal relation (>=)
## jerry_property_descriptor_t
**Summary**
@@ -1701,6 +1713,69 @@ jerry_is_feature_enabled (const jerry_feature_t feature);
}
```
**See also**
- [jerry_feature_t](#jerry_feature_t)
# Binary operations
## jerry_binary_operation
**Summary**
Perform binary operation on the given operands (==, ===, <, >, etc.).
**Prototype**
```c
jerry_value_t
jerry_binary_operation (jerry_binary_operation_t op,
const jerry_value_t lhs,
const jerry_value_t rhs);
```
- `op` - binary operation
- `lhs` - left-hand side operand
- `rhs` - right-hand side operand
- return value
- error, if argument has an error flag or operation is unsuccessful or unsupported
- true/false, the result of the binary operation on the given operands otherwise
**Example**
```c
{
jerry_value_t value1;
jerry_value_t value2;
... // create or acquire value
jerry_value_t result = jerry_binary_operation (JERRY_BIN_OP_EQUAL, value1, value2)
if (!jerry_value_is_error (result))
{
if (jerry_get_boolean_value (result))
{
// value1 and value2 are equal
}
else
{
// value1 and value2 are NOT equal
}
}
else
{
... // handle error
}
jerry_release_value (value1);
jerry_release_value (value2);
jerry_release_value (result);
}
```
**See also**
- [jerry_binary_operation_t](#jerry_binary_operation_t)
# Error manipulation functions
## jerry_create_abort_from_value