Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions jerry-core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/

#include "jcontext.h"
#include "jerryscript-debugger.h"
#include "jerryscript.h"
#include "jerry-debugger.h"

/**
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 4 additions & 12 deletions jerry-core/jerryscript.h → jerry-core/include/jerryscript-core.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -31,6 +31,7 @@ extern "C"
/* TODO: for other compilers */
#define JERRY_DEPRECATED_API
#endif /* __GNUC__ */

/** \addtogroup jerry Jerry engine interface
* @{
*/
Expand Down Expand Up @@ -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.
*/
Expand All @@ -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 */
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 */
File renamed without changes.
46 changes: 46 additions & 0 deletions jerry-core/include/jerryscript-snapshot.h
Original file line number Diff line number Diff line change
@@ -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 */
23 changes: 23 additions & 0 deletions jerry-core/include/jerryscript.h
Original file line number Diff line number Diff line change
@@ -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 */
2 changes: 1 addition & 1 deletion targets/esp8266/source/jerry_extapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <stdlib.h>
#include <stdio.h>

#include "jerry-core/jerryscript.h"
#include "jerry-core/include/jerryscript.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so deep. What about creating a jerry-include top level directory and put the public api there.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is "user error". The build system of ESP8266 should add "jerry-core/include" to the include path and then #include "jerryscript.h" only. Actually, even before this PR, the ESP8266 build system should have added "jerry-core" to the include path and never ever have anything like #include "jerry-core/xxxxx" in the code. But I did not want to go into rewriting the build systems of any of targets. (Where the build system was correctly written, no changes in the code was necessary -- see particle, riot-stm32f4, zephyr.)

#include "jerry_extapi.h"

#include "native_esp8266.h"
Expand Down
2 changes: 1 addition & 1 deletion targets/esp8266/source/jerry_run.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion targets/esp8266/user/jerry_port.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/**
Expand Down
4 changes: 2 additions & 2 deletions targets/mbed/source/jerry_extapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)))
Expand Down
4 changes: 2 additions & 2 deletions targets/mbed/source/jerry_run.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions targets/mbed/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion targets/mbed/source/port/jerry_port.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include <vector>

#include "jerry-core/jerryscript.h"
#include "jerry-core/include/jerryscript.h"

#include "Callback.h"
#include "mbed_assert.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion targets/mbedos5/source/jerry_port_mbed.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion targets/particle/Makefile.particle
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion targets/riot-stm32f4/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions targets/zephyr/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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