Update Jerry API

* Removed jerry_string_t and jerry_object_t
* Updated function names
* Updated return values
* Updated function descriptions
* Added new functions
* Added new unittests

JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
This commit is contained in:
László Langó
2016-06-29 08:41:15 +02:00
parent cea3a142ac
commit 9bce5b09a9
19 changed files with 2077 additions and 2112 deletions
+12 -36
View File
@@ -14,6 +14,7 @@
* limitations under the License.
*/
#include "ecma-exceptions.h"
#include "ecma-helpers.h"
#include "ecma-literal-storage.h"
#include "js-parser-internal.h"
@@ -2238,52 +2239,27 @@ parser_set_show_instrs (int show_instrs) /**< flag indicating whether to dump by
* Parse EcamScript source code
*
* Note:
* returned error object should be freed with jerry_release_object
*/
jsp_status_t
parser_parse_script (const jerry_char_t *source_p, /**< source code */
size_t size, /**< size of the source code */
ecma_compiled_code_t **bytecode_data_p, /**< [out] JS bytecode */
jerry_object_t **error_obj_p) /**< [out] error object */
{
parser_error_location parse_error;
*bytecode_data_p = parser_parse_source (source_p, size, false, &parse_error);
if (!*bytecode_data_p)
{
*error_obj_p = jerry_create_error (JERRY_ERROR_SYNTAX,
(const jerry_char_t *) parser_error_to_string (parse_error.error));
return JSP_STATUS_SYNTAX_ERROR;
}
return JSP_STATUS_OK;
} /* parser_parse_script */
/**
* Parse EcamScript eval source code
* returned value must be freed with ecma_free_value
*
* Note:
* returned error object should be freed with jerry_release_object
* @return true - if success
* syntax error - otherwise
*/
jsp_status_t
parser_parse_eval (const jerry_char_t *source_p, /**< source code */
size_t size, /**< size of the source code */
bool is_strict, /**< strict mode */
ecma_compiled_code_t **bytecode_data_p, /**< [out] JS bytecode */
jerry_object_t **error_obj_p) /**< [out] error object */
ecma_value_t
parser_parse_script (const uint8_t *source_p, /**< source code */
size_t size, /**< size of the source code */
bool is_strict, /**< strict mode */
ecma_compiled_code_t **bytecode_data_p) /**< [out] JS bytecode */
{
parser_error_location parse_error;
*bytecode_data_p = parser_parse_source (source_p, size, is_strict, &parse_error);
if (!*bytecode_data_p)
{
*error_obj_p = jerry_create_error (JERRY_ERROR_SYNTAX,
(const jerry_char_t *) parser_error_to_string (parse_error.error));
return JSP_STATUS_SYNTAX_ERROR;
return ecma_raise_syntax_error (parser_error_to_string (parse_error.error));
}
return JSP_STATUS_OK;
} /* parser_parse_eval */
return ecma_make_simple_value (ECMA_SIMPLE_VALUE_TRUE);
} /* parser_parse_script */
/**
* @}