Move jerry-core API implementations and headers into dedicated subdirectories (#1793)

Moved all public API headers under the `jerry-core/include`
directory. This makes installing all the public headers easier.
Also, should we have new public headers in the future, their
installation will be automatic, there will be no need to update the
build files. Moreover, this aligns better with the structure of
other libraries in the project (in those cases, public headers
always reside in `<library>/include`).

Moved all public API implementations under the `jerry-core/api`
directory. This cleans up the root directory of `jerry-core`,
moving all implementation code under "modules", i.e.,
subdirectories. This also makes the future splitting of the big and
monolithic `jerry.c` along features easier, if needed. (Debugger
and snapshot-related functions are already in separate sources.)

Notes:
* `jerryscript.h` is split up to separate header files along
  feature boundaries. These new headers are included by
  `jerryscript.h`, so this is not a breaking change but header
  modularization only.
* `jerry-snapshot.h` is still under `jerry-core/api`, keeping it as
  a non-public header.
* This commit also adapts all targets to the include path change.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
This commit is contained in:
Akos Kiss 2017-05-04 15:28:24 +02:00 committed by GitHub
parent 90efdf9c8b
commit 91e976f8c7
27 changed files with 103 additions and 40 deletions

View File

@ -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)

View File

@ -14,7 +14,7 @@
*/
#include "jcontext.h"
#include "jerryscript-debugger.h"
#include "jerryscript.h"
#include "jerry-debugger.h"
/**

View File

@ -13,8 +13,8 @@
* limitations under the License.
*/
#ifndef JERRYSCRIPT_H
#define JERRYSCRIPT_H
#ifndef JERRYSCRIPT_CORE_H
#define JERRYSCRIPT_CORE_H
#include <stdbool.h>
#include <stddef.h>
@ -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 */

View File

@ -17,18 +17,19 @@
#define JERRYSCRIPT_DEBUGGER_H
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -16,7 +16,7 @@
#include <stdlib.h>
#include <stdio.h>
#include "jerry-core/jerryscript.h"
#include "jerry-core/include/jerryscript.h"
#include "jerry_extapi.h"
#include "native_esp8266.h"

View File

@ -16,7 +16,7 @@
#include <stdlib.h>
#include <stdio.h>
#include "jerry-core/jerryscript.h"
#include "jerry-core/include/jerryscript.h"
#include "jerry_extapi.h"
#include "jerry_run.h"

View File

@ -17,7 +17,7 @@
#include <stdio.h>
#include <stdarg.h>
#include "jerry-core/jerryscript-port.h"
#include "jerry-core/include/jerryscript-port.h"
int ets_putc (int);
/**

View File

@ -16,7 +16,7 @@
#include <stdlib.h>
#include <stdio.h>
#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)))

View File

@ -16,7 +16,7 @@
#include <stdlib.h>
#include <stdio.h>
#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))

View File

@ -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));

View File

@ -18,7 +18,7 @@
#include <stdlib.h>
#include <sys/time.h>
#include "jerry-core/jerryscript-port.h"
#include "jerry-core/include/jerryscript-port.h"
#include "mbed-hal/us_ticker_api.h"

View File

@ -17,7 +17,7 @@
#include <vector>
#include "jerry-core/jerryscript.h"
#include "jerry-core/include/jerryscript.h"
#include "Callback.h"
#include "mbed_assert.h"

View File

@ -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);

View File

@ -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"

View File

@ -17,8 +17,8 @@
#include <stdlib.h>
#include "jerry-core/jerryscript.h"
#include "jerry-core/include/jerryscript.h"
#include "jerryscript-mbed-util/logging.h"
#include "jerryscript-mbed-util/wrappers.h"

View File

@ -18,7 +18,7 @@
#include <stdlib.h>
#include <sys/time.h>
#include "jerry-core/jerryscript-port.h"
#include "jerry-core/include/jerryscript-port.h"
#include "us_ticker_api.h"

View File

@ -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 \

View File

@ -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

View File

@ -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