diff --git a/docs/03.API-EXAMPLE.md b/docs/03.API-EXAMPLE.md index 040c85f49..c5feb2e3d 100644 --- a/docs/03.API-EXAMPLE.md +++ b/docs/03.API-EXAMPLE.md @@ -6,7 +6,7 @@ This guide is intended to introduce you to JerryScript embedding API through cre ```c #include -#include "jerry-api.h" +#include "jerryscript.h" int main (int argc, char *argv[]) @@ -38,7 +38,7 @@ Here we perform the same actions, as `jerry_run_simple`, while splitting into se ```c #include -#include "jerry-api.h" +#include "jerryscript.h" int main (int argc, char *argv[]) @@ -77,7 +77,7 @@ Our code is more complex now, but it introduces possibilities to interact with J ```c #include -#include "jerry-api.h" +#include "jerryscript.h" int main (int argc, char *argv[]) @@ -119,7 +119,7 @@ This way, we execute two independent script parts in one execution environment. ```c #include -#include "jerry-api.h" +#include "jerryscript.h" int main (int argc, char *argv[]) { @@ -176,7 +176,7 @@ The following example function will output a JavaScript value: #include #include -#include "jerry-api.h" +#include "jerryscript.h" #include "jerry-port.h" static void @@ -246,7 +246,7 @@ Shell operation can be described with the following loop: #include #include -#include "jerry-api.h" +#include "jerryscript.h" #include "jerry-port.h" static void print_value (const jerry_value_t); @@ -324,7 +324,7 @@ In this example we demonstrate how to use native function and structures in Java ```c #include -#include "jerry-api.h" +#include "jerryscript.h" struct my_struct { @@ -410,7 +410,7 @@ Here we create a JS Object with `jerry_eval`, then extend it with a native funct ```c #include -#include "jerry-api.h" +#include "jerryscript.h" /** * Add param to 'this.x' diff --git a/jerry-core/CMakeLists.txt b/jerry-core/CMakeLists.txt index 29ed064ea..eb1238b24 100644 --- a/jerry-core/CMakeLists.txt +++ b/jerry-core/CMakeLists.txt @@ -263,4 +263,4 @@ foreach(EXT_LIB ${EXTERNAL_LINK_LIBS}) endforeach() install(TARGETS ${JERRY_CORE_NAME} DESTINATION lib) -install(FILES jerry-api.h jerry-port.h DESTINATION include) +install(FILES jerry-api.h jerryscript.h jerry-port.h DESTINATION include) diff --git a/jerry-core/jerry-api.h b/jerry-core/jerry-api.h index 76f26b02b..65b8335e2 100644 --- a/jerry-core/jerry-api.h +++ b/jerry-core/jerry-api.h @@ -16,333 +16,8 @@ #ifndef JERRY_API_H #define JERRY_API_H -#include -#include -#include -#include +#pragma message ("using jerry-api.h directly is deprecated, please use jerryscript.h") -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ +#include "jerryscript.h" -/** \addtogroup jerry Jerry engine interface - * @{ - */ - -/** - * Major version of JerryScript API - */ -#define JERRY_API_MAJOR_VERSION 1 - -/** - * Minor version of JerryScript API - */ -#define JERRY_API_MINOR_VERSION 0 - -/** - * Jerry init flags - */ -typedef enum -{ - JERRY_INIT_EMPTY = (0u), /**< empty flag set */ - JERRY_INIT_SHOW_OPCODES = (1u << 0), /**< dump byte-code to log after parse */ - JERRY_INIT_SHOW_REGEXP_OPCODES = (1u << 1), /**< dump regexp byte-code to log after compilation */ - JERRY_INIT_MEM_STATS = (1u << 2), /**< dump memory statistics */ - JERRY_INIT_MEM_STATS_SEPARATE = (1u << 3), /**< dump memory statistics and reset peak values after parse */ - JERRY_INIT_DEBUGGER = (1u << 4), /**< enable all features required by debugging */ -} jerry_init_flag_t; - -/** - * Jerry API Error object types - */ -typedef enum -{ - JERRY_ERROR_COMMON, /**< Error */ - JERRY_ERROR_EVAL, /**< EvalError */ - JERRY_ERROR_RANGE, /**< RangeError */ - JERRY_ERROR_REFERENCE, /**< ReferenceError */ - JERRY_ERROR_SYNTAX, /**< SyntaxError */ - JERRY_ERROR_TYPE, /**< TypeError */ - JERRY_ERROR_URI /**< URIError */ -} jerry_error_t; - -typedef enum -{ - JERRY_FEATURE_CPOINTER_32_BIT, /**< 32 bit compressed pointers */ - JERRY_FEATURE_ERROR_MESSAGES, /**< error messages */ - JERRY_FEATURE_JS_PARSER, /**< js-parser */ - 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 - */ -typedef uint8_t jerry_char_t; - -/** - * Pointer to an array of character values - */ -typedef jerry_char_t *jerry_char_ptr_t; - -/** - * Jerry's size - */ -typedef uint32_t jerry_size_t; - -/** - * Jerry's length - */ -typedef uint32_t jerry_length_t; - -/** - * Description of a JerryScript value - */ -typedef uint32_t jerry_value_t; - - -/** - * Description of ECMA property descriptor - */ -typedef struct -{ - /** Is [[Value]] defined? */ - bool is_value_defined; - - /** Is [[Get]] defined? */ - bool is_get_defined; - - /** Is [[Set]] defined? */ - bool is_set_defined; - - /** Is [[Writable]] defined? */ - bool is_writable_defined; - - /** [[Writable]] */ - bool is_writable; - - /** Is [[Enumerable]] defined? */ - bool is_enumerable_defined; - - /** [[Enumerable]] */ - bool is_enumerable; - - /** Is [[Configurable]] defined? */ - bool is_configurable_defined; - - /** [[Configurable]] */ - bool is_configurable; - - /** [[Value]] */ - jerry_value_t value; - - /** [[Get]] */ - jerry_value_t getter; - - /** [[Set]] */ - jerry_value_t setter; -} jerry_property_descriptor_t; - -/** - * Type of an external function handler - */ -typedef jerry_value_t (*jerry_external_handler_t) (const jerry_value_t function_obj, - const jerry_value_t this_val, - const jerry_value_t args_p[], - const jerry_length_t args_count); - -/** - * Native free callback of an object - */ -typedef void (*jerry_object_free_callback_t) (const uintptr_t native_p); - -/** - * Function type applied for each data property of an object - */ -typedef bool (*jerry_object_property_foreach_t) (const jerry_value_t property_name, - const jerry_value_t property_value, - void *user_data_p); - -/** - * General engine functions - */ -void jerry_init (jerry_init_flag_t flags); -void jerry_cleanup (void); -void jerry_register_magic_strings (const jerry_char_ptr_t *ex_str_items_p, uint32_t count, - const jerry_length_t *str_lengths_p); -void jerry_get_memory_limits (size_t *out_data_bss_brk_limit_p, size_t *out_stack_limit_p); -void jerry_gc (void); - -/** - * Parser and executor functions - */ -bool jerry_run_simple (const jerry_char_t *script_source_p, size_t script_source_size, jerry_init_flag_t flags); -jerry_value_t jerry_parse (const jerry_char_t *source_p, size_t source_size, bool is_strict); -jerry_value_t jerry_parse_named_resource (const jerry_char_t *name_p, size_t name_length, - const jerry_char_t *source_p, size_t source_size, bool is_strict); -jerry_value_t jerry_run (const jerry_value_t func_val); -jerry_value_t jerry_eval (const jerry_char_t *source_p, size_t source_size, bool is_strict); - -/** - * Get the global context - */ -jerry_value_t jerry_get_global_object (void); - -/** - * Checker functions of 'jerry_value_t' - */ -bool jerry_value_is_array (const jerry_value_t value); -bool jerry_value_is_boolean (const jerry_value_t value); -bool jerry_value_is_constructor (const jerry_value_t value); -bool jerry_value_is_function (const jerry_value_t value); -bool jerry_value_is_number (const jerry_value_t value); -bool jerry_value_is_null (const jerry_value_t value); -bool jerry_value_is_object (const jerry_value_t value); -bool jerry_value_is_string (const jerry_value_t value); -bool jerry_value_is_undefined (const jerry_value_t value); - -/** - * Checker function of whether the specified compile feature is enabled - */ -bool jerry_is_feature_enabled (const jerry_feature_t feature); - -/** - * Error flag manipulation functions - */ -bool jerry_value_has_error_flag (const jerry_value_t value); -void jerry_value_clear_error_flag (jerry_value_t *value_p); -void jerry_value_set_error_flag (jerry_value_t *value_p); - -/** - * Getter functions of 'jerry_value_t' - */ -bool jerry_get_boolean_value (const jerry_value_t value); -double jerry_get_number_value (const jerry_value_t value); - -/** - * Functions for string values - */ -jerry_size_t jerry_get_string_size (const jerry_value_t value); -jerry_size_t jerry_get_utf8_string_size (const jerry_value_t value); -jerry_length_t jerry_get_string_length (const jerry_value_t value); -jerry_length_t jerry_get_utf8_string_length (const jerry_value_t value); -jerry_size_t jerry_string_to_char_buffer (const jerry_value_t value, jerry_char_t *buffer_p, jerry_size_t buffer_size); -jerry_size_t jerry_string_to_utf8_char_buffer (const jerry_value_t value, - jerry_char_t *buffer_p, - jerry_size_t buffer_size); -jerry_size_t jerry_substring_to_char_buffer (const jerry_value_t value, - jerry_length_t start_pos, - jerry_length_t end_pos, - jerry_char_t *buffer_p, - jerry_size_t buffer_size); -jerry_size_t jerry_substring_to_utf8_char_buffer (const jerry_value_t value, - jerry_length_t start_pos, - jerry_length_t end_pos, - jerry_char_t *buffer_p, - jerry_size_t buffer_size); - -/** - * Functions for array object values - */ -uint32_t jerry_get_array_length (const jerry_value_t value); - -/** - * Converters of 'jerry_value_t' - */ -bool jerry_value_to_boolean (const jerry_value_t value); -jerry_value_t jerry_value_to_number (const jerry_value_t value); -jerry_value_t jerry_value_to_object (const jerry_value_t value); -jerry_value_t jerry_value_to_primitive (const jerry_value_t value); -jerry_value_t jerry_value_to_string (const jerry_value_t value); - -/** - * Acquire types with reference counter (increase the references) - */ -jerry_value_t jerry_acquire_value (jerry_value_t value); - -/** - * Release the referenced values - */ -void jerry_release_value (jerry_value_t value); - -/** - * Create functions of API values - */ -jerry_value_t jerry_create_array (uint32_t size); -jerry_value_t jerry_create_boolean (bool value); -jerry_value_t jerry_create_error (jerry_error_t error_type, const jerry_char_t *message_p); -jerry_value_t jerry_create_error_sz (jerry_error_t error_type, const jerry_char_t *message_p, - jerry_size_t message_size); -jerry_value_t jerry_create_external_function (jerry_external_handler_t handler_p); -jerry_value_t jerry_create_number (double value); -jerry_value_t jerry_create_number_infinity (bool sign); -jerry_value_t jerry_create_number_nan (void); -jerry_value_t jerry_create_null (void); -jerry_value_t jerry_create_object (void); -jerry_value_t jerry_create_string_from_utf8 (const jerry_char_t *str_p); -jerry_value_t jerry_create_string_sz_from_utf8 (const jerry_char_t *str_p, jerry_size_t str_size); -jerry_value_t jerry_create_string (const jerry_char_t *str_p); -jerry_value_t jerry_create_string_sz (const jerry_char_t *str_p, jerry_size_t str_size); -jerry_value_t jerry_create_undefined (void); - -/** - * General API functions of JS objects - */ -bool jerry_has_property (const jerry_value_t obj_val, const jerry_value_t prop_name_val); -bool jerry_has_own_property (const jerry_value_t obj_val, const jerry_value_t prop_name_val); -bool jerry_delete_property (const jerry_value_t obj_val, const jerry_value_t prop_name_val); - -jerry_value_t jerry_get_property (const jerry_value_t obj_val, const jerry_value_t prop_name_val); -jerry_value_t jerry_get_property_by_index (const jerry_value_t obj_val, uint32_t index); -jerry_value_t jerry_set_property (const jerry_value_t obj_val, const jerry_value_t prop_name_val, - const jerry_value_t value_to_set); -jerry_value_t jerry_set_property_by_index (const jerry_value_t obj_val, uint32_t index, - const jerry_value_t value_to_set); - -void jerry_init_property_descriptor_fields (jerry_property_descriptor_t *prop_desc_p); -jerry_value_t jerry_define_own_property (const jerry_value_t obj_val, - const jerry_value_t prop_name_val, - const jerry_property_descriptor_t *prop_desc_p); - -bool jerry_get_own_property_descriptor (const jerry_value_t obj_val, - const jerry_value_t prop_name_val, - jerry_property_descriptor_t *prop_desc_p); -void jerry_free_property_descriptor_fields (const jerry_property_descriptor_t *prop_desc_p); - -jerry_value_t jerry_call_function (const jerry_value_t func_obj_val, const jerry_value_t this_val, - const jerry_value_t args_p[], jerry_size_t args_count); -jerry_value_t jerry_construct_object (const jerry_value_t func_obj_val, const jerry_value_t args_p[], - jerry_size_t args_count); - -jerry_value_t jerry_get_object_keys (const jerry_value_t obj_val); -jerry_value_t jerry_get_prototype (const jerry_value_t obj_val); -jerry_value_t jerry_set_prototype (const jerry_value_t obj_val, const jerry_value_t proto_obj_val); - -bool jerry_get_object_native_handle (const jerry_value_t obj_val, uintptr_t *out_handle_p); -void jerry_set_object_native_handle (const jerry_value_t obj_val, uintptr_t handle_p, - jerry_object_free_callback_t freecb_p); -bool jerry_foreach_object_property (const jerry_value_t obj_val, jerry_object_property_foreach_t foreach_p, - void *user_data_p); - -/** - * Snapshot functions - */ -size_t jerry_parse_and_save_snapshot (const jerry_char_t *source_p, size_t source_size, bool is_for_global, - bool is_strict, uint8_t *buffer_p, size_t buffer_size); -jerry_value_t jerry_exec_snapshot (const void *snapshot_p, size_t snapshot_size, bool copy_bytecode); -size_t jerry_parse_and_save_literals (const jerry_char_t *source_p, size_t source_size, bool is_strict, - uint8_t *buffer_p, size_t buffer_size, bool is_c_format); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ #endif /* !JERRY_API_H */ diff --git a/jerry-core/jerry-internal.h b/jerry-core/jerry-internal.h index b48bc2570..c1b60d58c 100644 --- a/jerry-core/jerry-internal.h +++ b/jerry-core/jerry-internal.h @@ -21,7 +21,7 @@ #define JERRY_INTERNAL_H #include "ecma-globals.h" -#include "jerry-api.h" +#include "jerryscript.h" ecma_value_t jerry_dispatch_external_function (ecma_object_t *function_object_p, diff --git a/jerry-core/jerry-snapshot.c b/jerry-core/jerry-snapshot.c index 1f8a2ffbf..5fdb46c2d 100644 --- a/jerry-core/jerry-snapshot.c +++ b/jerry-core/jerry-snapshot.c @@ -18,7 +18,7 @@ #include "ecma-helpers.h" #include "ecma-literal-storage.h" #include "jcontext.h" -#include "jerry-api.h" +#include "jerryscript.h" #include "jerry-snapshot.h" #include "js-parser.h" #include "lit-char-helpers.h" diff --git a/jerry-core/jerry.c b/jerry-core/jerry.c index b105f5187..2f51612c9 100644 --- a/jerry-core/jerry.c +++ b/jerry-core/jerry.c @@ -30,7 +30,7 @@ #include "ecma-objects.h" #include "ecma-objects-general.h" #include "jcontext.h" -#include "jerry-api.h" +#include "jerryscript.h" #include "jerry-debugger.h" #include "js-parser.h" #include "re-compiler.h" diff --git a/jerry-core/jerryscript.h b/jerry-core/jerryscript.h new file mode 100644 index 000000000..4a43d1444 --- /dev/null +++ b/jerry-core/jerryscript.h @@ -0,0 +1,348 @@ +/* Copyright JS Foundation and other contributors, http://js.foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef JERRYSCRIPT_H +#define JERRYSCRIPT_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/** \addtogroup jerry Jerry engine interface + * @{ + */ + +/** + * Major version of JerryScript API + */ +#define JERRY_API_MAJOR_VERSION 1 + +/** + * Minor version of JerryScript API + */ +#define JERRY_API_MINOR_VERSION 0 + +/** + * Jerry init flags + */ +typedef enum +{ + JERRY_INIT_EMPTY = (0u), /**< empty flag set */ + JERRY_INIT_SHOW_OPCODES = (1u << 0), /**< dump byte-code to log after parse */ + JERRY_INIT_SHOW_REGEXP_OPCODES = (1u << 1), /**< dump regexp byte-code to log after compilation */ + JERRY_INIT_MEM_STATS = (1u << 2), /**< dump memory statistics */ + JERRY_INIT_MEM_STATS_SEPARATE = (1u << 3), /**< dump memory statistics and reset peak values after parse */ + JERRY_INIT_DEBUGGER = (1u << 4), /**< enable all features required by debugging */ +} jerry_init_flag_t; + +/** + * Jerry API Error object types + */ +typedef enum +{ + JERRY_ERROR_COMMON, /**< Error */ + JERRY_ERROR_EVAL, /**< EvalError */ + JERRY_ERROR_RANGE, /**< RangeError */ + JERRY_ERROR_REFERENCE, /**< ReferenceError */ + JERRY_ERROR_SYNTAX, /**< SyntaxError */ + JERRY_ERROR_TYPE, /**< TypeError */ + JERRY_ERROR_URI /**< URIError */ +} jerry_error_t; + +typedef enum +{ + JERRY_FEATURE_CPOINTER_32_BIT, /**< 32 bit compressed pointers */ + JERRY_FEATURE_ERROR_MESSAGES, /**< error messages */ + JERRY_FEATURE_JS_PARSER, /**< js-parser */ + 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 + */ +typedef uint8_t jerry_char_t; + +/** + * Pointer to an array of character values + */ +typedef jerry_char_t *jerry_char_ptr_t; + +/** + * Jerry's size + */ +typedef uint32_t jerry_size_t; + +/** + * Jerry's length + */ +typedef uint32_t jerry_length_t; + +/** + * Description of a JerryScript value + */ +typedef uint32_t jerry_value_t; + + +/** + * Description of ECMA property descriptor + */ +typedef struct +{ + /** Is [[Value]] defined? */ + bool is_value_defined; + + /** Is [[Get]] defined? */ + bool is_get_defined; + + /** Is [[Set]] defined? */ + bool is_set_defined; + + /** Is [[Writable]] defined? */ + bool is_writable_defined; + + /** [[Writable]] */ + bool is_writable; + + /** Is [[Enumerable]] defined? */ + bool is_enumerable_defined; + + /** [[Enumerable]] */ + bool is_enumerable; + + /** Is [[Configurable]] defined? */ + bool is_configurable_defined; + + /** [[Configurable]] */ + bool is_configurable; + + /** [[Value]] */ + jerry_value_t value; + + /** [[Get]] */ + jerry_value_t getter; + + /** [[Set]] */ + jerry_value_t setter; +} jerry_property_descriptor_t; + +/** + * Type of an external function handler + */ +typedef jerry_value_t (*jerry_external_handler_t) (const jerry_value_t function_obj, + const jerry_value_t this_val, + const jerry_value_t args_p[], + const jerry_length_t args_count); + +/** + * Native free callback of an object + */ +typedef void (*jerry_object_free_callback_t) (const uintptr_t native_p); + +/** + * Function type applied for each data property of an object + */ +typedef bool (*jerry_object_property_foreach_t) (const jerry_value_t property_name, + const jerry_value_t property_value, + void *user_data_p); + +/** + * General engine functions + */ +void jerry_init (jerry_init_flag_t flags); +void jerry_cleanup (void); +void jerry_register_magic_strings (const jerry_char_ptr_t *ex_str_items_p, uint32_t count, + const jerry_length_t *str_lengths_p); +void jerry_get_memory_limits (size_t *out_data_bss_brk_limit_p, size_t *out_stack_limit_p); +void jerry_gc (void); + +/** + * Parser and executor functions + */ +bool jerry_run_simple (const jerry_char_t *script_source_p, size_t script_source_size, jerry_init_flag_t flags); +jerry_value_t jerry_parse (const jerry_char_t *source_p, size_t source_size, bool is_strict); +jerry_value_t jerry_parse_named_resource (const jerry_char_t *name_p, size_t name_length, + const jerry_char_t *source_p, size_t source_size, bool is_strict); +jerry_value_t jerry_run (const jerry_value_t func_val); +jerry_value_t jerry_eval (const jerry_char_t *source_p, size_t source_size, bool is_strict); + +/** + * Get the global context + */ +jerry_value_t jerry_get_global_object (void); + +/** + * Checker functions of 'jerry_value_t' + */ +bool jerry_value_is_array (const jerry_value_t value); +bool jerry_value_is_boolean (const jerry_value_t value); +bool jerry_value_is_constructor (const jerry_value_t value); +bool jerry_value_is_function (const jerry_value_t value); +bool jerry_value_is_number (const jerry_value_t value); +bool jerry_value_is_null (const jerry_value_t value); +bool jerry_value_is_object (const jerry_value_t value); +bool jerry_value_is_string (const jerry_value_t value); +bool jerry_value_is_undefined (const jerry_value_t value); + +/** + * Checker function of whether the specified compile feature is enabled + */ +bool jerry_is_feature_enabled (const jerry_feature_t feature); + +/** + * Error flag manipulation functions + */ +bool jerry_value_has_error_flag (const jerry_value_t value); +void jerry_value_clear_error_flag (jerry_value_t *value_p); +void jerry_value_set_error_flag (jerry_value_t *value_p); + +/** + * Getter functions of 'jerry_value_t' + */ +bool jerry_get_boolean_value (const jerry_value_t value); +double jerry_get_number_value (const jerry_value_t value); + +/** + * Functions for string values + */ +jerry_size_t jerry_get_string_size (const jerry_value_t value); +jerry_size_t jerry_get_utf8_string_size (const jerry_value_t value); +jerry_length_t jerry_get_string_length (const jerry_value_t value); +jerry_length_t jerry_get_utf8_string_length (const jerry_value_t value); +jerry_size_t jerry_string_to_char_buffer (const jerry_value_t value, jerry_char_t *buffer_p, jerry_size_t buffer_size); +jerry_size_t jerry_string_to_utf8_char_buffer (const jerry_value_t value, + jerry_char_t *buffer_p, + jerry_size_t buffer_size); +jerry_size_t jerry_substring_to_char_buffer (const jerry_value_t value, + jerry_length_t start_pos, + jerry_length_t end_pos, + jerry_char_t *buffer_p, + jerry_size_t buffer_size); +jerry_size_t jerry_substring_to_utf8_char_buffer (const jerry_value_t value, + jerry_length_t start_pos, + jerry_length_t end_pos, + jerry_char_t *buffer_p, + jerry_size_t buffer_size); + +/** + * Functions for array object values + */ +uint32_t jerry_get_array_length (const jerry_value_t value); + +/** + * Converters of 'jerry_value_t' + */ +bool jerry_value_to_boolean (const jerry_value_t value); +jerry_value_t jerry_value_to_number (const jerry_value_t value); +jerry_value_t jerry_value_to_object (const jerry_value_t value); +jerry_value_t jerry_value_to_primitive (const jerry_value_t value); +jerry_value_t jerry_value_to_string (const jerry_value_t value); + +/** + * Acquire types with reference counter (increase the references) + */ +jerry_value_t jerry_acquire_value (jerry_value_t value); + +/** + * Release the referenced values + */ +void jerry_release_value (jerry_value_t value); + +/** + * Create functions of API values + */ +jerry_value_t jerry_create_array (uint32_t size); +jerry_value_t jerry_create_boolean (bool value); +jerry_value_t jerry_create_error (jerry_error_t error_type, const jerry_char_t *message_p); +jerry_value_t jerry_create_error_sz (jerry_error_t error_type, const jerry_char_t *message_p, + jerry_size_t message_size); +jerry_value_t jerry_create_external_function (jerry_external_handler_t handler_p); +jerry_value_t jerry_create_number (double value); +jerry_value_t jerry_create_number_infinity (bool sign); +jerry_value_t jerry_create_number_nan (void); +jerry_value_t jerry_create_null (void); +jerry_value_t jerry_create_object (void); +jerry_value_t jerry_create_string_from_utf8 (const jerry_char_t *str_p); +jerry_value_t jerry_create_string_sz_from_utf8 (const jerry_char_t *str_p, jerry_size_t str_size); +jerry_value_t jerry_create_string (const jerry_char_t *str_p); +jerry_value_t jerry_create_string_sz (const jerry_char_t *str_p, jerry_size_t str_size); +jerry_value_t jerry_create_undefined (void); + +/** + * General API functions of JS objects + */ +bool jerry_has_property (const jerry_value_t obj_val, const jerry_value_t prop_name_val); +bool jerry_has_own_property (const jerry_value_t obj_val, const jerry_value_t prop_name_val); +bool jerry_delete_property (const jerry_value_t obj_val, const jerry_value_t prop_name_val); + +jerry_value_t jerry_get_property (const jerry_value_t obj_val, const jerry_value_t prop_name_val); +jerry_value_t jerry_get_property_by_index (const jerry_value_t obj_val, uint32_t index); +jerry_value_t jerry_set_property (const jerry_value_t obj_val, const jerry_value_t prop_name_val, + const jerry_value_t value_to_set); +jerry_value_t jerry_set_property_by_index (const jerry_value_t obj_val, uint32_t index, + const jerry_value_t value_to_set); + +void jerry_init_property_descriptor_fields (jerry_property_descriptor_t *prop_desc_p); +jerry_value_t jerry_define_own_property (const jerry_value_t obj_val, + const jerry_value_t prop_name_val, + const jerry_property_descriptor_t *prop_desc_p); + +bool jerry_get_own_property_descriptor (const jerry_value_t obj_val, + const jerry_value_t prop_name_val, + jerry_property_descriptor_t *prop_desc_p); +void jerry_free_property_descriptor_fields (const jerry_property_descriptor_t *prop_desc_p); + +jerry_value_t jerry_call_function (const jerry_value_t func_obj_val, const jerry_value_t this_val, + const jerry_value_t args_p[], jerry_size_t args_count); +jerry_value_t jerry_construct_object (const jerry_value_t func_obj_val, const jerry_value_t args_p[], + jerry_size_t args_count); + +jerry_value_t jerry_get_object_keys (const jerry_value_t obj_val); +jerry_value_t jerry_get_prototype (const jerry_value_t obj_val); +jerry_value_t jerry_set_prototype (const jerry_value_t obj_val, const jerry_value_t proto_obj_val); + +bool jerry_get_object_native_handle (const jerry_value_t obj_val, uintptr_t *out_handle_p); +void jerry_set_object_native_handle (const jerry_value_t obj_val, uintptr_t handle_p, + jerry_object_free_callback_t freecb_p); +bool jerry_foreach_object_property (const jerry_value_t obj_val, jerry_object_property_foreach_t foreach_p, + void *user_data_p); + +/** + * Snapshot functions + */ +size_t jerry_parse_and_save_snapshot (const jerry_char_t *source_p, size_t source_size, bool is_for_global, + bool is_strict, uint8_t *buffer_p, size_t buffer_size); +jerry_value_t jerry_exec_snapshot (const void *snapshot_p, size_t snapshot_size, bool copy_bytecode); +size_t jerry_parse_and_save_literals (const jerry_char_t *source_p, size_t source_size, bool is_strict, + uint8_t *buffer_p, size_t buffer_size, bool is_c_format); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /* !JERRYSCRIPT_H */ diff --git a/jerry-core/jrt/jrt.h b/jerry-core/jrt/jrt.h index 712a2661a..1f781637c 100644 --- a/jerry-core/jrt/jrt.h +++ b/jerry-core/jrt/jrt.h @@ -19,7 +19,7 @@ #include #include -#include "jerry-api.h" +#include "jerryscript.h" #include "jerry-port.h" #include "jrt-types.h" diff --git a/jerry-main/main-unix-minimal.c b/jerry-main/main-unix-minimal.c index 1dd928957..abe233b2c 100644 --- a/jerry-main/main-unix-minimal.c +++ b/jerry-main/main-unix-minimal.c @@ -15,7 +15,7 @@ #include -#include "jerry-api.h" +#include "jerryscript.h" #include "jerry-port-default.h" /** diff --git a/jerry-main/main-unix.c b/jerry-main/main-unix.c index e28ea0e11..ac7b13dfb 100644 --- a/jerry-main/main-unix.c +++ b/jerry-main/main-unix.c @@ -18,7 +18,7 @@ #include #include -#include "jerry-api.h" +#include "jerryscript.h" #include "jerry-port.h" #include "jerry-port-default.h" diff --git a/targets/curie_bsp/jerry_app/quark/main.c b/targets/curie_bsp/jerry_app/quark/main.c index 1caa7e0e5..25ed48139 100644 --- a/targets/curie_bsp/jerry_app/quark/main.c +++ b/targets/curie_bsp/jerry_app/quark/main.c @@ -29,7 +29,7 @@ /* Watchdog helper */ #include "infra/wdt_helper.h" -#include "jerry-api.h" +#include "jerryscript.h" #include "string.h" #include "jerry-port.h" diff --git a/targets/esp8266/source/jerry_extapi.c b/targets/esp8266/source/jerry_extapi.c index 86f857e4e..453fb6171 100644 --- a/targets/esp8266/source/jerry_extapi.c +++ b/targets/esp8266/source/jerry_extapi.c @@ -16,7 +16,7 @@ #include #include -#include "jerry-core/jerry-api.h" +#include "jerry-core/jerryscript.h" #include "jerry_extapi.h" #include "native_esp8266.h" diff --git a/targets/esp8266/source/jerry_run.c b/targets/esp8266/source/jerry_run.c index 08aab8822..488a56656 100644 --- a/targets/esp8266/source/jerry_run.c +++ b/targets/esp8266/source/jerry_run.c @@ -16,7 +16,7 @@ #include #include -#include "jerry-core/jerry-api.h" +#include "jerry-core/jerryscript.h" #include "jerry_extapi.h" #include "jerry_run.h" diff --git a/targets/mbed/source/jerry_extapi.cpp b/targets/mbed/source/jerry_extapi.cpp index a54d4e50a..cd6a3bdd5 100644 --- a/targets/mbed/source/jerry_extapi.cpp +++ b/targets/mbed/source/jerry_extapi.cpp @@ -16,7 +16,7 @@ #include #include -#include "jerry-core/jerry-api.h" +#include "jerry-core/jerryscript.h" #include "jerry_extapi.h" #include "native_mbed.h" diff --git a/targets/mbed/source/jerry_run.cpp b/targets/mbed/source/jerry_run.cpp index 7b61a9948..c954a3135 100644 --- a/targets/mbed/source/jerry_run.cpp +++ b/targets/mbed/source/jerry_run.cpp @@ -16,7 +16,7 @@ #include #include -#include "jerry-core/jerry-api.h" +#include "jerry-core/jerryscript.h" #include "jerry_extapi.h" #include "jerry_run.h" diff --git a/targets/mbed/source/main.cpp b/targets/mbed/source/main.cpp index 9c2a827fa..7fd7e4839 100644 --- a/targets/mbed/source/main.cpp +++ b/targets/mbed/source/main.cpp @@ -15,7 +15,7 @@ #include "mbed-drivers/mbed.h" -#include "jerry-core/jerry-api.h" +#include "jerry-core/jerryscript.h" #include "jerry_run.h" #include "jerry-targetjs.h" diff --git a/targets/mbedos5/jerryscript-mbed/jerryscript-mbed-event-loop/EventLoop.h b/targets/mbedos5/jerryscript-mbed/jerryscript-mbed-event-loop/EventLoop.h index f230e9914..4bdc006c1 100644 --- a/targets/mbedos5/jerryscript-mbed/jerryscript-mbed-event-loop/EventLoop.h +++ b/targets/mbedos5/jerryscript-mbed/jerryscript-mbed-event-loop/EventLoop.h @@ -17,7 +17,7 @@ #include -#include "jerry-core/jerry-api.h" +#include "jerry-core/jerryscript.h" #include "Callback.h" #include "mbed_assert.h" diff --git a/targets/mbedos5/jerryscript-mbed/jerryscript-mbed-launcher/setup.h b/targets/mbedos5/jerryscript-mbed/jerryscript-mbed-launcher/setup.h index 70ce0f517..248e16038 100644 --- a/targets/mbedos5/jerryscript-mbed/jerryscript-mbed-launcher/setup.h +++ b/targets/mbedos5/jerryscript-mbed/jerryscript-mbed-launcher/setup.h @@ -15,7 +15,7 @@ #ifndef _JERRYSCRIPT_MBED_LAUNCHER_SETUP_H #define _JERRYSCRIPT_MBED_LAUNCHER_SETUP_H -#include "jerry-core/jerry-api.h" +#include "jerry-core/jerryscript.h" void jsmbed_js_load_magic_strings(void); diff --git a/targets/mbedos5/jerryscript-mbed/jerryscript-mbed-launcher/source/launcher.cpp b/targets/mbedos5/jerryscript-mbed/jerryscript-mbed-launcher/source/launcher.cpp index c8075a6df..597aeca6b 100644 --- a/targets/mbedos5/jerryscript-mbed/jerryscript-mbed-launcher/source/launcher.cpp +++ b/targets/mbedos5/jerryscript-mbed/jerryscript-mbed-launcher/source/launcher.cpp @@ -15,7 +15,7 @@ #include "mbed.h" #include "rtos.h" -#include "jerry-core/jerry-api.h" +#include "jerry-core/jerryscript.h" #include "jerryscript-mbed-event-loop/EventLoop.h" diff --git a/targets/mbedos5/jerryscript-mbed/jerryscript-mbed-library-registry/wrap_tools.h b/targets/mbedos5/jerryscript-mbed/jerryscript-mbed-library-registry/wrap_tools.h index cae524af1..7df3e07b9 100644 --- a/targets/mbedos5/jerryscript-mbed/jerryscript-mbed-library-registry/wrap_tools.h +++ b/targets/mbedos5/jerryscript-mbed/jerryscript-mbed-library-registry/wrap_tools.h @@ -17,7 +17,7 @@ #include -#include "jerry-core/jerry-api.h" +#include "jerry-core/jerryscript.h" #include "jerryscript-mbed-util/logging.h" #include "jerryscript-mbed-util/wrappers.h" diff --git a/targets/nuttx-stm32f4/jerry_main.c b/targets/nuttx-stm32f4/jerry_main.c index 328046da3..44bdab760 100644 --- a/targets/nuttx-stm32f4/jerry_main.c +++ b/targets/nuttx-stm32f4/jerry_main.c @@ -18,7 +18,7 @@ #include #include -#include "jerry-api.h" +#include "jerryscript.h" #include "jerry-port.h" /** diff --git a/targets/particle/source/main.cpp b/targets/particle/source/main.cpp index 1d7d8be15..f8463c01e 100644 --- a/targets/particle/source/main.cpp +++ b/targets/particle/source/main.cpp @@ -14,7 +14,7 @@ */ #include "application.h" -#include "jerry-api.h" +#include "jerryscript.h" SYSTEM_MODE (MANUAL); diff --git a/targets/riot-stm32f4/source/main-riotos.c b/targets/riot-stm32f4/source/main-riotos.c index 76fed0f20..d0b5b55a0 100644 --- a/targets/riot-stm32f4/source/main-riotos.c +++ b/targets/riot-stm32f4/source/main-riotos.c @@ -15,7 +15,7 @@ #include #include "shell.h" -#include "jerry-api.h" +#include "jerryscript.h" /** * Jerryscript simple test diff --git a/targets/zephyr/src/main-zephyr.c b/targets/zephyr/src/main-zephyr.c index d59d108b0..2e20633da 100644 --- a/targets/zephyr/src/main-zephyr.c +++ b/targets/zephyr/src/main-zephyr.c @@ -21,7 +21,7 @@ #include #include "getline-zephyr.h" -#include "jerry-api.h" +#include "jerryscript.h" static jerry_value_t print_function; diff --git a/tests/unit/test-api.c b/tests/unit/test-api.c index 94b0e75b2..63aaf1af9 100644 --- a/tests/unit/test-api.c +++ b/tests/unit/test-api.c @@ -14,7 +14,7 @@ */ #include "config.h" -#include "jerry-api.h" +#include "jerryscript.h" #include "test-common.h" diff --git a/tests/unit/test-string-to-number.c b/tests/unit/test-string-to-number.c index 4951c6d00..d39bb47ca 100644 --- a/tests/unit/test-string-to-number.c +++ b/tests/unit/test-string-to-number.c @@ -15,7 +15,7 @@ #include "ecma-globals.h" #include "ecma-helpers.h" -#include "jerry-api.h" +#include "jerryscript.h" #include "test-common.h"