Add API function to check if the specified feature is enabled. (#1465)

JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
This commit is contained in:
Robert Sipka
2016-12-05 09:26:02 +01:00
committed by GitHub
parent 4c1fc7d789
commit 4ef3c0caa8
3 changed files with 96 additions and 0 deletions
+44
View File
@@ -22,6 +22,18 @@ Possible types of an error:
- JERRY_ERROR_TYPE - type error
- JERRY_ERROR_URI - URI error
## jerry_feature_t
Possible compile time enabled feature types:
- JERRY_FEATURE_ERROR_MESSAGES - error messages
- JERRY_FEATURE_CPOINTER_32_BIT - 32 bit compressed pointers
- JERRY_FEATURE_MEM_STATS - memory statistics
- JERRY_FEATURE_PARSER_DUMP - parser byte-code dumps
- JERRY_FEATURE_REGEXP_DUMP - regexp byte-code dumps
- JERRY_FEATURE_SNAPSHOT_SAVE - saving snapshot files
- JERRY_FEATURE_SNAPSHOT_EXEC - executing snapshot files
## jerry_char_t
**Summary**
@@ -917,6 +929,38 @@ jerry_value_is_undefined (const jerry_value_t value)
- [jerry_release_value](#jerry_release_value)
## jerry_is_feature_enabled
**Summary**
Returns whether the specified compile time feature is enabled.
**Prototype**
```c
bool
jerry_is_feature_enabled (const jerry_feature_t feature);
```
- `feature` - jerry feature
- return value
- true, if the given `jerry_feature_t` is enabled
- false, otherwise
**Example**
```c
{
...
jerry_feature_t feature = JERRY_FEATURE_SNAPSHOT_SAVE;
if (jerry_is_feature_enabled (feature))
{
...
}
}
```
# Error flag manipulation functions
+17
View File
@@ -68,6 +68,18 @@ typedef enum
JERRY_ERROR_URI /**< URIError */
} jerry_error_t;
typedef enum
{
JERRY_FEATURE_ERROR_MESSAGES, /**< error messages */
JERRY_FEATURE_CPOINTER_32_BIT, /**< 32 bit compressed pointers */
JERRY_FEATURE_MEM_STATS, /**< memory statistics */
JERRY_FEATURE_PARSER_DUMP, /**< parser byte-code dumps */
JERRY_FEATURE_REGEXP_DUMP, /**< regexp byte-code dumps */
JERRY_FEATURE_SNAPSHOT_SAVE, /**< saving snapshot files */
JERRY_FEATURE_SNAPSHOT_EXEC, /**< executing snapshot files */
JERRY_FEATURE__COUNT /**< number of features. NOTE: must be at the end of the list */
} jerry_feature_t;
/**
* Jerry's char value
*/
@@ -191,6 +203,11 @@ bool jerry_value_is_object (const jerry_value_t);
bool jerry_value_is_string (const jerry_value_t);
bool jerry_value_is_undefined (const jerry_value_t);
/**
* Checker function of whether the specified compile feature is enabled
*/
bool jerry_is_feature_enabled (const jerry_feature_t);
/**
* Error flag manipulation functions
*/
+35
View File
@@ -518,6 +518,41 @@ jerry_value_is_undefined (const jerry_value_t value) /**< api value */
return ecma_is_value_undefined (value);
} /* jerry_value_is_undefined */
/**
* Check if the specified feature is enabled.
*
* @return true - if the specified feature is enabled,
* false - otherwise.
*/
bool jerry_is_feature_enabled (const jerry_feature_t feature)
{
JERRY_ASSERT (feature < JERRY_FEATURE__COUNT);
return (false
#ifdef JERRY_ENABLE_ERROR_MESSAGES
|| feature == JERRY_FEATURE_ERROR_MESSAGES
#endif /* JERRY_ENABLE_ERROR_MESSAGES */
#ifdef JERRY_CPOINTER_32_BIT
|| feature == JERRY_FEATURE_CPOINTER_32_BIT
#endif /* JERRY_CPOINTER_32_BIT */
#ifdef JMEM_STATS
|| feature == JERRY_FEATURE_MEM_STATS
#endif /* JMEM_STATS */
#ifdef PARSER_DUMP_BYTE_CODE
|| feature == JERRY_FEATURE_PARSER_DUMP
#endif /* PARSER_DUMP_BYTE_CODE */
#ifdef REGEXP_DUMP_BYTE_CODE
|| feature == JERRY_FEATURE_REGEXP_DUMP
#endif /* REGEXP_DUMP_BYTE_CODE */
#ifdef JERRY_ENABLE_SNAPSHOT_SAVE
|| feature == JERRY_FEATURE_SNAPSHOT_SAVE
#endif /* JERRY_ENABLE_SNAPSHOT_SAVE */
#ifdef JERRY_ENABLE_SNAPSHOT_EXEC
|| feature == JERRY_FEATURE_SNAPSHOT_EXEC
#endif /* JERRY_ENABLE_SNAPSHOT_EXEC */
);
} /* jerry_is_feature_enabled */
/**
* Check if the specified value is an error value.
*