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
@@ -19,6 +19,7 @@
#include "common.h"
#include "byte-code.h"
#include "js-parser.h"
#include "js-parser-limits.h"
#include "js-lexer.h"
+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 */
/**
* @}
+2 -19
View File
@@ -17,7 +17,7 @@
#ifndef JS_PARSER_H
#define JS_PARSER_H
#include "byte-code.h"
#include "ecma-globals.h"
/** \addtogroup parser Parser
* @{
@@ -128,25 +128,8 @@ typedef struct
parser_line_counter_t column; /**< column where the error occured */
} parser_error_location;
/**
* Parser completion status
*/
typedef enum
{
JSP_STATUS_OK, /**< parse finished successfully, no early errors occured */
JSP_STATUS_SYNTAX_ERROR, /**< SyntaxError early error occured */
} jsp_status_t;
/* Note: source must be a valid UTF-8 string */
extern jsp_status_t parser_parse_script (const jerry_char_t *,
size_t,
ecma_compiled_code_t **,
jerry_object_t **);
extern jsp_status_t parser_parse_eval (const jerry_char_t *,
size_t,
bool,
ecma_compiled_code_t **,
jerry_object_t **);
extern ecma_value_t parser_parse_script (const uint8_t *, size_t, bool, ecma_compiled_code_t **);
const char *parser_error_to_string (parser_error_t);