Skip to content

Commit 91e976f

Browse files
authored
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 [email protected]
1 parent 90efdf9 commit 91e976f

File tree

27 files changed

+103
-40
lines changed

27 files changed

+103
-40
lines changed

jerry-core/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,13 @@ message(STATUS "MEM_HEAP_SIZE_KB " ${MEM_HEAP_SIZE_KB})
6161
# Include directories
6262
set(INCLUDE_CORE
6363
"${CMAKE_CURRENT_SOURCE_DIR}"
64+
"${CMAKE_CURRENT_SOURCE_DIR}/api"
6465
"${CMAKE_CURRENT_SOURCE_DIR}/debugger"
6566
"${CMAKE_CURRENT_SOURCE_DIR}/ecma/base"
6667
"${CMAKE_CURRENT_SOURCE_DIR}/ecma/builtin-objects"
6768
"${CMAKE_CURRENT_SOURCE_DIR}/ecma/builtin-objects/typedarray"
6869
"${CMAKE_CURRENT_SOURCE_DIR}/ecma/operations"
70+
"${CMAKE_CURRENT_SOURCE_DIR}/include"
6971
"${CMAKE_CURRENT_SOURCE_DIR}/jcontext"
7072
"${CMAKE_CURRENT_SOURCE_DIR}/jmem"
7173
"${CMAKE_CURRENT_SOURCE_DIR}/jrt"
@@ -76,7 +78,7 @@ set(INCLUDE_CORE
7678

7779
# Sources
7880
# Jerry core
79-
file(GLOB SOURCE_CORE_API *.c)
81+
file(GLOB SOURCE_CORE_API api/*.c)
8082
file(GLOB SOURCE_CORE_DEBUGGER debugger/*.c)
8183
file(GLOB SOURCE_CORE_ECMA_BASE ecma/base/*.c)
8284
file(GLOB SOURCE_CORE_ECMA_BUILTINS ecma/builtin-objects/*.c)
@@ -274,4 +276,4 @@ foreach(EXT_LIB ${EXTERNAL_LINK_LIBS})
274276
endforeach()
275277

276278
install(TARGETS ${JERRY_CORE_NAME} DESTINATION lib)
277-
install(FILES jerryscript.h jerryscript-port.h jerry-api.h jerry-port.h DESTINATION include)
279+
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION include)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515

1616
#include "jcontext.h"
17-
#include "jerryscript-debugger.h"
17+
#include "jerryscript.h"
1818
#include "jerry-debugger.h"
1919

2020
/**
Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
* limitations under the License.
1414
*/
1515

16-
#ifndef JERRYSCRIPT_H
17-
#define JERRYSCRIPT_H
16+
#ifndef JERRYSCRIPT_CORE_H
17+
#define JERRYSCRIPT_CORE_H
1818

1919
#include <stdbool.h>
2020
#include <stddef.h>
@@ -31,6 +31,7 @@ extern "C"
3131
/* TODO: for other compilers */
3232
#define JERRY_DEPRECATED_API
3333
#endif /* __GNUC__ */
34+
3435
/** \addtogroup jerry Jerry engine interface
3536
* @{
3637
*/
@@ -400,15 +401,6 @@ jerry_value_t jerry_resolve_or_reject_promise (jerry_value_t promise, jerry_valu
400401
bool jerry_is_valid_utf8_string (const jerry_char_t *utf8_buf_p, jerry_size_t buf_size);
401402
bool jerry_is_valid_cesu8_string (const jerry_char_t *cesu8_buf_p, jerry_size_t buf_size);
402403

403-
/**
404-
* Snapshot functions.
405-
*/
406-
size_t jerry_parse_and_save_snapshot (const jerry_char_t *source_p, size_t source_size, bool is_for_global,
407-
bool is_strict, uint32_t *buffer_p, size_t buffer_size);
408-
jerry_value_t jerry_exec_snapshot (const uint32_t *snapshot_p, size_t snapshot_size, bool copy_bytecode);
409-
size_t jerry_parse_and_save_literals (const jerry_char_t *source_p, size_t source_size, bool is_strict,
410-
uint32_t *buffer_p, size_t buffer_size, bool is_c_format);
411-
412404
/**
413405
* Miscellaneous functions.
414406
*/
@@ -421,4 +413,4 @@ void jerry_set_vm_exec_stop_callback (jerry_vm_exec_stop_callback_t stop_cb, voi
421413
#ifdef __cplusplus
422414
}
423415
#endif /* __cplusplus */
424-
#endif /* !JERRYSCRIPT_H */
416+
#endif /* !JERRYSCRIPT_CORE_H */
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,19 @@
1717
#define JERRYSCRIPT_DEBUGGER_H
1818

1919
#include <stdbool.h>
20-
#include <stddef.h>
21-
#include <stdint.h>
2220

2321
#ifdef __cplusplus
2422
extern "C"
2523
{
2624
#endif /* __cplusplus */
2725

28-
/** \addtogroup jerry Jerry engine debugger interface
26+
/** \addtogroup jerry-debugger Jerry engine interface - Debugger feature
2927
* @{
3028
*/
3129

30+
/**
31+
* Engine debugger functions.
32+
*/
3233
bool jerry_debugger_is_connected (void);
3334
void jerry_debugger_stop (void);
3435
void jerry_debugger_continue (void);
@@ -41,4 +42,4 @@ void jerry_debugger_stop_at_breakpoint (bool enable_stop_at_breakpoint);
4142
#ifdef __cplusplus
4243
}
4344
#endif /* __cplusplus */
44-
#endif /* !JERRYSCRIPT_H */
45+
#endif /* !JERRYSCRIPT_DEBUGGER_H */

0 commit comments

Comments
 (0)