diff --git a/jerry-core/CMakeLists.txt b/jerry-core/CMakeLists.txt index 1649a0fd63..c1d37a6a69 100644 --- a/jerry-core/CMakeLists.txt +++ b/jerry-core/CMakeLists.txt @@ -61,11 +61,13 @@ message(STATUS "MEM_HEAP_SIZE_KB " ${MEM_HEAP_SIZE_KB}) # Include directories set(INCLUDE_CORE "${CMAKE_CURRENT_SOURCE_DIR}" + "${CMAKE_CURRENT_SOURCE_DIR}/api" "${CMAKE_CURRENT_SOURCE_DIR}/debugger" "${CMAKE_CURRENT_SOURCE_DIR}/ecma/base" "${CMAKE_CURRENT_SOURCE_DIR}/ecma/builtin-objects" "${CMAKE_CURRENT_SOURCE_DIR}/ecma/builtin-objects/typedarray" "${CMAKE_CURRENT_SOURCE_DIR}/ecma/operations" + "${CMAKE_CURRENT_SOURCE_DIR}/include" "${CMAKE_CURRENT_SOURCE_DIR}/jcontext" "${CMAKE_CURRENT_SOURCE_DIR}/jmem" "${CMAKE_CURRENT_SOURCE_DIR}/jrt" @@ -76,7 +78,7 @@ set(INCLUDE_CORE # Sources # Jerry core -file(GLOB SOURCE_CORE_API *.c) +file(GLOB SOURCE_CORE_API api/*.c) file(GLOB SOURCE_CORE_DEBUGGER debugger/*.c) file(GLOB SOURCE_CORE_ECMA_BASE ecma/base/*.c) file(GLOB SOURCE_CORE_ECMA_BUILTINS ecma/builtin-objects/*.c) @@ -274,4 +276,4 @@ foreach(EXT_LIB ${EXTERNAL_LINK_LIBS}) endforeach() install(TARGETS ${JERRY_CORE_NAME} DESTINATION lib) -install(FILES jerryscript.h jerryscript-port.h jerry-api.h jerry-port.h DESTINATION include) +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION include) diff --git a/jerry-core/jerryscript-debugger.c b/jerry-core/api/jerry-debugger.c similarity index 98% rename from jerry-core/jerryscript-debugger.c rename to jerry-core/api/jerry-debugger.c index e869969e02..cf9f243e8f 100644 --- a/jerry-core/jerryscript-debugger.c +++ b/jerry-core/api/jerry-debugger.c @@ -14,7 +14,7 @@ */ #include "jcontext.h" -#include "jerryscript-debugger.h" +#include "jerryscript.h" #include "jerry-debugger.h" /** diff --git a/jerry-core/jerry-snapshot.c b/jerry-core/api/jerry-snapshot.c similarity index 100% rename from jerry-core/jerry-snapshot.c rename to jerry-core/api/jerry-snapshot.c diff --git a/jerry-core/jerry-snapshot.h b/jerry-core/api/jerry-snapshot.h similarity index 100% rename from jerry-core/jerry-snapshot.h rename to jerry-core/api/jerry-snapshot.h diff --git a/jerry-core/jerry.c b/jerry-core/api/jerry.c similarity index 100% rename from jerry-core/jerry.c rename to jerry-core/api/jerry.c diff --git a/jerry-core/jerry-api.h b/jerry-core/include/jerry-api.h similarity index 100% rename from jerry-core/jerry-api.h rename to jerry-core/include/jerry-api.h diff --git a/jerry-core/jerry-port.h b/jerry-core/include/jerry-port.h similarity index 100% rename from jerry-core/jerry-port.h rename to jerry-core/include/jerry-port.h diff --git a/jerry-core/jerryscript.h b/jerry-core/include/jerryscript-core.h similarity index 96% rename from jerry-core/jerryscript.h rename to jerry-core/include/jerryscript-core.h index f4a9fbc26d..0024b0ca1c 100644 --- a/jerry-core/jerryscript.h +++ b/jerry-core/include/jerryscript-core.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef JERRYSCRIPT_H -#define JERRYSCRIPT_H +#ifndef JERRYSCRIPT_CORE_H +#define JERRYSCRIPT_CORE_H #include #include @@ -31,6 +31,7 @@ extern "C" /* TODO: for other compilers */ #define JERRY_DEPRECATED_API #endif /* __GNUC__ */ + /** \addtogroup jerry Jerry engine interface * @{ */ @@ -400,15 +401,6 @@ jerry_value_t jerry_resolve_or_reject_promise (jerry_value_t promise, jerry_valu bool jerry_is_valid_utf8_string (const jerry_char_t *utf8_buf_p, jerry_size_t buf_size); bool jerry_is_valid_cesu8_string (const jerry_char_t *cesu8_buf_p, jerry_size_t buf_size); -/** - * 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, uint32_t *buffer_p, size_t buffer_size); -jerry_value_t jerry_exec_snapshot (const uint32_t *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, - uint32_t *buffer_p, size_t buffer_size, bool is_c_format); - /** * Miscellaneous functions. */ @@ -421,4 +413,4 @@ void jerry_set_vm_exec_stop_callback (jerry_vm_exec_stop_callback_t stop_cb, voi #ifdef __cplusplus } #endif /* __cplusplus */ -#endif /* !JERRYSCRIPT_H */ +#endif /* !JERRYSCRIPT_CORE_H */ diff --git a/jerry-core/jerryscript-debugger.h b/jerry-core/include/jerryscript-debugger.h similarity index 87% rename from jerry-core/jerryscript-debugger.h rename to jerry-core/include/jerryscript-debugger.h index 1cdcaeac45..4fb99b0ba5 100644 --- a/jerry-core/jerryscript-debugger.h +++ b/jerry-core/include/jerryscript-debugger.h @@ -17,18 +17,19 @@ #define JERRYSCRIPT_DEBUGGER_H #include -#include -#include #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ -/** \addtogroup jerry Jerry engine debugger interface +/** \addtogroup jerry-debugger Jerry engine interface - Debugger feature * @{ */ +/** + * Engine debugger functions. + */ bool jerry_debugger_is_connected (void); void jerry_debugger_stop (void); void jerry_debugger_continue (void); @@ -41,4 +42,4 @@ void jerry_debugger_stop_at_breakpoint (bool enable_stop_at_breakpoint); #ifdef __cplusplus } #endif /* __cplusplus */ -#endif /* !JERRYSCRIPT_H */ +#endif /* !JERRYSCRIPT_DEBUGGER_H */ diff --git a/jerry-core/jerryscript-port.h b/jerry-core/include/jerryscript-port.h similarity index 100% rename from jerry-core/jerryscript-port.h rename to jerry-core/include/jerryscript-port.h diff --git a/jerry-core/include/jerryscript-snapshot.h b/jerry-core/include/jerryscript-snapshot.h new file mode 100644 index 0000000000..62aa8a8d08 --- /dev/null +++ b/jerry-core/include/jerryscript-snapshot.h @@ -0,0 +1,46 @@ +/* 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_SNAPSHOT_H +#define JERRYSCRIPT_SNAPSHOT_H + +#include "jerryscript-core.h" + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +/** \addtogroup jerry-snapshot Jerry engine interface - Snapshot feature + * @{ + */ + +/** + * 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, uint32_t *buffer_p, size_t buffer_size); +jerry_value_t jerry_exec_snapshot (const uint32_t *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, + uint32_t *buffer_p, size_t buffer_size, bool is_c_format); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /* !JERRYSCRIPT_SNAPSHOT_H */ diff --git a/jerry-core/include/jerryscript.h b/jerry-core/include/jerryscript.h new file mode 100644 index 0000000000..041ac7ea37 --- /dev/null +++ b/jerry-core/include/jerryscript.h @@ -0,0 +1,23 @@ +/* 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 "jerryscript-core.h" +#include "jerryscript-debugger.h" +#include "jerryscript-snapshot.h" + +#endif /* !JERRYSCRIPT_H */ diff --git a/targets/esp8266/source/jerry_extapi.c b/targets/esp8266/source/jerry_extapi.c index 453fb61712..ffc9504833 100644 --- a/targets/esp8266/source/jerry_extapi.c +++ b/targets/esp8266/source/jerry_extapi.c @@ -16,7 +16,7 @@ #include #include -#include "jerry-core/jerryscript.h" +#include "jerry-core/include/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 488a56656c..a15850b757 100644 --- a/targets/esp8266/source/jerry_run.c +++ b/targets/esp8266/source/jerry_run.c @@ -16,7 +16,7 @@ #include #include -#include "jerry-core/jerryscript.h" +#include "jerry-core/include/jerryscript.h" #include "jerry_extapi.h" #include "jerry_run.h" diff --git a/targets/esp8266/user/jerry_port.c b/targets/esp8266/user/jerry_port.c index ef9a2d7d34..3101d193c2 100644 --- a/targets/esp8266/user/jerry_port.c +++ b/targets/esp8266/user/jerry_port.c @@ -17,7 +17,7 @@ #include #include -#include "jerry-core/jerryscript-port.h" +#include "jerry-core/include/jerryscript-port.h" int ets_putc (int); /** diff --git a/targets/mbed/source/jerry_extapi.cpp b/targets/mbed/source/jerry_extapi.cpp index cd6a3bdd53..8c2c92cbeb 100644 --- a/targets/mbed/source/jerry_extapi.cpp +++ b/targets/mbed/source/jerry_extapi.cpp @@ -16,7 +16,7 @@ #include #include -#include "jerry-core/jerryscript.h" +#include "jerry-core/include/jerryscript.h" #include "jerry_extapi.h" #include "native_mbed.h" @@ -99,7 +99,7 @@ register_native_function (const char* name, jerry_value_t global_object_val = jerry_get_global_object (); jerry_value_t reg_function = jerry_create_external_function (handler); - bool is_ok = true; + bool is_ok = true; if (!(jerry_value_is_function (reg_function) && jerry_value_is_constructor (reg_function))) diff --git a/targets/mbed/source/jerry_run.cpp b/targets/mbed/source/jerry_run.cpp index c954a3135d..4b8a4b54e0 100644 --- a/targets/mbed/source/jerry_run.cpp +++ b/targets/mbed/source/jerry_run.cpp @@ -16,7 +16,7 @@ #include #include -#include "jerry-core/jerryscript.h" +#include "jerry-core/include/jerryscript.h" #include "jerry_extapi.h" #include "jerry_run.h" @@ -80,7 +80,7 @@ int js_loop (uint32_t ticknow) jerry_value_t global_obj = jerry_get_global_object (); jerry_value_t sys_name = jerry_create_string ((const jerry_char_t *) fn_sys_loop_name); jerry_value_t sysloop_func = jerry_get_property (global_obj, sys_name); - + jerry_release_value (sys_name); if (jerry_value_has_error_flag (sysloop_func)) diff --git a/targets/mbed/source/main.cpp b/targets/mbed/source/main.cpp index 7fd7e48392..39aedb1a31 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/jerryscript.h" +#include "jerry-core/include/jerryscript.h" #include "jerry_run.h" #include "jerry-targetjs.h" @@ -64,7 +64,7 @@ void app_start (int, char**) printf ("\r\nJerryScript in mbed\r\n"); printf ("Version: \t%d.%d\n\n", JERRY_API_MAJOR_VERSION, JERRY_API_MINOR_VERSION); - + if (jerry_task_init () == 0) { minar::Scheduler::postCallback(jerry_loop).period(minar::milliseconds(100)); diff --git a/targets/mbed/source/port/jerry_port.c b/targets/mbed/source/port/jerry_port.c index 5f7ee3ef38..496ee867d6 100644 --- a/targets/mbed/source/port/jerry_port.c +++ b/targets/mbed/source/port/jerry_port.c @@ -18,7 +18,7 @@ #include #include -#include "jerry-core/jerryscript-port.h" +#include "jerry-core/include/jerryscript-port.h" #include "mbed-hal/us_ticker_api.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 4bdc006c1f..6f28b8af3e 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/jerryscript.h" +#include "jerry-core/include/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 248e160382..f87a628c2a 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/jerryscript.h" +#include "jerry-core/include/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 597aeca6bf..4ecfbac550 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/jerryscript.h" +#include "jerry-core/include/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 7df3e07b9f..7a844b760f 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,8 +17,8 @@ #include -#include "jerry-core/jerryscript.h" - +#include "jerry-core/include/jerryscript.h" + #include "jerryscript-mbed-util/logging.h" #include "jerryscript-mbed-util/wrappers.h" diff --git a/targets/mbedos5/source/jerry_port_mbed.c b/targets/mbedos5/source/jerry_port_mbed.c index f42ed9ffe9..adaca5d2f6 100644 --- a/targets/mbedos5/source/jerry_port_mbed.c +++ b/targets/mbedos5/source/jerry_port_mbed.c @@ -18,7 +18,7 @@ #include #include -#include "jerry-core/jerryscript-port.h" +#include "jerry-core/include/jerryscript-port.h" #include "us_ticker_api.h" diff --git a/targets/particle/Makefile.particle b/targets/particle/Makefile.particle index 0f4a2cabbb..637b0f17ab 100644 --- a/targets/particle/Makefile.particle +++ b/targets/particle/Makefile.particle @@ -25,7 +25,7 @@ EXT_CFLAGS += -Wno-error=format= .PHONY: jerrycore jerry-main flash clean PARTICLE_BUILD_CONFIG = \ - INCLUDE_DIRS=$(JERRYDIR)/jerry-core \ + INCLUDE_DIRS=$(JERRYDIR)/jerry-core/include \ LIBS=jerry-core \ PLATFORM=photon \ LIB_DIRS=$(BUILD_DIR)/lib \ diff --git a/targets/riot-stm32f4/Makefile b/targets/riot-stm32f4/Makefile index 66602ef04c..0599c88db6 100644 --- a/targets/riot-stm32f4/Makefile +++ b/targets/riot-stm32f4/Makefile @@ -37,7 +37,7 @@ CFLAGS += -DDEVELHELP # Change this to 0 show compiler invocation lines by default: QUIET ?= 1 -INCLUDES += -I$(JERRYDIR)/jerry-core/ +INCLUDES += -I$(JERRYDIR)/jerry-core/include # Add the shell and some shell commands USEMODULE += shell diff --git a/targets/zephyr/Makefile b/targets/zephyr/Makefile index 895741d5fc..36a40c0929 100644 --- a/targets/zephyr/Makefile +++ b/targets/zephyr/Makefile @@ -34,7 +34,7 @@ ZEPHYRLIB = $(ZEPHYR_BASE)/lib TARGET_ZEPHYR ?= ./targets/zephyr SOURCE_DIR = $(TARGET_ZEPHYR)/src -export JERRY_INCLUDE = $(CURDIR)/jerry-core/ +export JERRY_INCLUDE = $(CURDIR)/jerry-core/include MDEF_FILE = $(realpath $(SOURCE_DIR)/../prj.mdef) CONF_FILE = $(realpath $(SOURCE_DIR)/../prj.conf) @@ -57,7 +57,6 @@ export ALL_LIBS LDFLAGS_zephyr += $(USER_LIB_INCLUDE_DIR) export LDFLAGS_zephyr -include ${ZEPHYR_BASE}/Makefile.inc +include ${ZEPHYR_BASE}/Makefile.inc .PHONY = showconfig -