Follow the API & build system update in mbed targets
- Update the API changes in mbed targets - Build fix for mbed target after the build system patch. JerryScript-DCO-1.0-Signed-off-by: Levente Orban orbanl@inf.u-szeged.hu
This commit is contained in:
+18
-19
@@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
# use TAB-8
|
# use TAB-8
|
||||||
|
|
||||||
TYPE = release
|
|
||||||
TARGET_LIST = k64f stm32f4 stm32f429i nucleo
|
TARGET_LIST = k64f stm32f4 stm32f429i nucleo
|
||||||
JERRYHEAP ?= 16
|
JERRYHEAP ?= 16
|
||||||
|
|
||||||
@@ -33,10 +32,9 @@ else ifeq ($(TARGET), nucleo)
|
|||||||
TARGET_DIR ?= /media/$(USER)/NODE_F401RE
|
TARGET_DIR ?= /media/$(USER)/NODE_F401RE
|
||||||
endif
|
endif
|
||||||
|
|
||||||
UPPERC_TARGET = $(shell echo $(TARGET) | tr a-z A-Z)
|
BUILD_DIR ?= build/mbed
|
||||||
INTERM = build/obj-mbed-$(TARGET)
|
UPPERC_TARGET ?= $(shell echo $(TARGET) | tr a-z A-Z)
|
||||||
OUTPUT = build/bin/$(TYPE).mbed$(TARGET)
|
COPYTARGET ?= targets/mbed/libjerry
|
||||||
COPYTARGET = targets/mbed/libjerry
|
|
||||||
|
|
||||||
else
|
else
|
||||||
$(error This board ($(board)) is not supported!)
|
$(error This board ($(board)) is not supported!)
|
||||||
@@ -53,25 +51,26 @@ EXT_PORT_DIR := ""
|
|||||||
all: jerry js2c yotta
|
all: jerry js2c yotta
|
||||||
|
|
||||||
jerry:
|
jerry:
|
||||||
mkdir -p $(INTERM)
|
|
||||||
mkdir -p $(OUTPUT)
|
|
||||||
mkdir -p $(COPYTARGET)
|
mkdir -p $(COPYTARGET)
|
||||||
cmake -B$(INTERM) -H./ \
|
mkdir -p $(BUILD_DIR)
|
||||||
|
cmake -B$(BUILD_DIR) -H./ \
|
||||||
-DENABLE_LTO=OFF \
|
-DENABLE_LTO=OFF \
|
||||||
-DENABLE_VALGRIND=OFF \
|
-DFEATURE_VALGRIND=OFF \
|
||||||
-DCMAKE_TOOLCHAIN_FILE=build/configs/toolchain_external.cmake \
|
-DCMAKE_TOOLCHAIN_FILE=cmake/toolchain_external.cmake \
|
||||||
|
-DJERRY_LIBC=OFF \
|
||||||
|
-DJERRY_CMDLINE=OFF \
|
||||||
-DCOMPILER_DEFAULT_LIBC=ON \
|
-DCOMPILER_DEFAULT_LIBC=ON \
|
||||||
-DEXTERNAL_CMAKE_SYSTEM_PROCESSOR=arm7-m \
|
-DENABLE_ALL_IN_ONE=OFF \
|
||||||
|
-DEXTERNAL_CMAKE_SYSTEM_PROCESSOR=armv7l-hf \
|
||||||
-DEXTERNAL_CMAKE_C_COMPILER=arm-none-eabi-gcc \
|
-DEXTERNAL_CMAKE_C_COMPILER=arm-none-eabi-gcc \
|
||||||
-DEXTERNAL_CMAKE_C_COMPILER_ID=GNU \
|
-DEXTERNAL_CMAKE_C_COMPILER_ID=GNU \
|
||||||
-DEXTERNAL_COMPILE_FLAGS="$(EXT_CFLAGS)" \
|
-DEXTERNAL_COMPILE_FLAGS="$(EXT_CFLAGS)" \
|
||||||
-DEXTERNAL_MEM_HEAP_SIZE_KB=$(JERRYHEAP) \
|
-DMEM_HEAP_SIZE_KB=$(JERRYHEAP) \
|
||||||
-DEXTERNAL_PORT_DIR=$(EXT_PORT_DIR)
|
|
||||||
|
|
||||||
make -C $(INTERM) $(TYPE).external
|
make -C$(BUILD_DIR) jerry-core
|
||||||
cp `cat $(INTERM)/$(TYPE).external/list` $(OUTPUT)/.
|
make -C$(BUILD_DIR) jerry-libm
|
||||||
cp $(OUTPUT)/lib$(TYPE).jerry-core.a $(COPYTARGET)/libjerrycore.a
|
cp $(BUILD_DIR)/lib/libjerry-core.a $(COPYTARGET)/libjerrycore.a
|
||||||
cp $(OUTPUT)/lib$(TYPE).jerry-libm.lib.a $(COPYTARGET)/libjerrylibm.a
|
cp $(BUILD_DIR)/lib/libjerry-libm.a $(COPYTARGET)/libjerrylibm.a
|
||||||
|
|
||||||
js2c:
|
js2c:
|
||||||
cd targets/mbed; ../tools/js2c.py;
|
cd targets/mbed; ../tools/js2c.py;
|
||||||
@@ -83,7 +82,7 @@ yotta:
|
|||||||
|
|
||||||
flash:
|
flash:
|
||||||
ifndef TARGET_DIR
|
ifndef TARGET_DIR
|
||||||
st-flash write targets/mbed/build/$(YOTTA_TARGET)/source/jerry.bin 0x08000000
|
st-flash write targets/mbed/build/$(YOTTA_TARGET)/source/jerry.bin 0x08000000
|
||||||
else
|
else
|
||||||
@if [ ! -d "${TARGET_DIR}" ] ; then \
|
@if [ ! -d "${TARGET_DIR}" ] ; then \
|
||||||
echo "The board not mounted at ${TARGET_DIR}"; \
|
echo "The board not mounted at ${TARGET_DIR}"; \
|
||||||
@@ -95,6 +94,6 @@ flash:
|
|||||||
@echo "Wait till LED flashing stops..."
|
@echo "Wait till LED flashing stops..."
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(INTERM)
|
rm -rf $(COPYTARGET)
|
||||||
rm -rf $(OUTPUT)
|
rm -rf $(OUTPUT)
|
||||||
rm -rf targets/mbed/build
|
rm -rf targets/mbed/build
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
|
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
|
||||||
|
* Copyright 2016 University of Szeged.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -16,9 +17,9 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "jerry-core/jerry.h"
|
#include "jerry-core/jerry-api.h"
|
||||||
#include "jerry_extapi.h"
|
#include "jerry_extapi.h"
|
||||||
|
|
||||||
#include "native_mbed.h"
|
#include "native_mbed.h"
|
||||||
|
|
||||||
#ifndef MIN
|
#ifndef MIN
|
||||||
@@ -30,12 +31,11 @@
|
|||||||
#define __UNSED__ __attribute__((unused))
|
#define __UNSED__ __attribute__((unused))
|
||||||
|
|
||||||
#define DECLARE_HANDLER(NAME) \
|
#define DECLARE_HANDLER(NAME) \
|
||||||
static bool \
|
static jerry_value_t \
|
||||||
NAME ## _handler (const jerry_api_object_t * function_obj_p __UNSED__, \
|
NAME ## _handler (const jerry_value_t func_value __UNSED__, \
|
||||||
const jerry_api_value_t * this_p __UNSED__, \
|
const jerry_value_t this_value __UNSED__, \
|
||||||
jerry_api_value_t * ret_val_p __UNSED__, \
|
const jerry_value_t args[], \
|
||||||
const jerry_api_value_t args_p[], \
|
const jerry_length_t args_cnt )
|
||||||
const jerry_api_length_t args_cnt)
|
|
||||||
|
|
||||||
#define REGISTER_HANDLER(NAME) \
|
#define REGISTER_HANDLER(NAME) \
|
||||||
register_native_function ( # NAME, NAME ## _handler)
|
register_native_function ( # NAME, NAME ## _handler)
|
||||||
@@ -45,39 +45,50 @@ NAME ## _handler (const jerry_api_object_t * function_obj_p __UNSED__, \
|
|||||||
DECLARE_HANDLER(assert)
|
DECLARE_HANDLER(assert)
|
||||||
{
|
{
|
||||||
if (args_cnt == 1
|
if (args_cnt == 1
|
||||||
&& args_p[0].type == JERRY_API_DATA_TYPE_BOOLEAN
|
&& jerry_value_is_boolean (args[0])
|
||||||
&& args_p[0].u.v_bool == true)
|
&& jerry_get_boolean_value (args[0]))
|
||||||
{
|
{
|
||||||
printf (">> Jerry assert true\r\n");
|
printf (">> Jerry assert true\r\n");
|
||||||
return true;
|
return jerry_create_boolean (true);
|
||||||
}
|
}
|
||||||
printf ("ERROR: Script assertion failed\n");
|
printf ("ERROR: Script assertion failed\n");
|
||||||
exit (JERRY_STANDALONE_EXIT_CODE_FAIL);
|
exit (JERRY_STANDALONE_EXIT_CODE_FAIL);
|
||||||
return false;
|
return jerry_create_boolean (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
DECLARE_HANDLER(led)
|
DECLARE_HANDLER(led)
|
||||||
{
|
{
|
||||||
|
jerry_value_t ret_val;
|
||||||
|
|
||||||
if (args_cnt < 2)
|
if (args_cnt < 2)
|
||||||
{
|
{
|
||||||
return false;
|
ret_val = jerry_create_boolean (false);
|
||||||
|
printf ("Error: invalid arguments number!\r\n");
|
||||||
|
return ret_val;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(jerry_value_is_number (args[0])
|
||||||
|
&& jerry_value_is_number (args[1])))
|
||||||
|
{
|
||||||
|
ret_val = jerry_create_boolean (false);
|
||||||
|
printf ("Error: arguments must be numbers!\r\n");
|
||||||
|
return ret_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
int port, value;
|
int port, value;
|
||||||
port = (int)JS_VALUE_TO_NUMBER (&args_p[0]);
|
port = (int) jerry_get_number_value (args[0]);
|
||||||
value = (int)JS_VALUE_TO_NUMBER (&args_p[1]);
|
value = (int) jerry_get_number_value (args[1]);
|
||||||
|
|
||||||
ret_val_p->type = JERRY_API_DATA_TYPE_BOOLEAN;
|
if (port >= 0 && port <= 3)
|
||||||
if (port >=0 && port <= 3)
|
|
||||||
{
|
{
|
||||||
native_led(port, value);
|
native_led (port, value);
|
||||||
ret_val_p->u.v_bool = true;
|
ret_val = jerry_create_boolean (true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ret_val_p->u.v_bool = false;
|
ret_val = jerry_create_boolean (false);
|
||||||
}
|
}
|
||||||
return true;
|
return ret_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -86,41 +97,49 @@ static bool
|
|||||||
register_native_function (const char* name,
|
register_native_function (const char* name,
|
||||||
jerry_external_handler_t handler)
|
jerry_external_handler_t handler)
|
||||||
{
|
{
|
||||||
jerry_api_object_t *global_obj_p;
|
jerry_value_t global_object_val = jerry_get_global_object ();
|
||||||
jerry_api_object_t *reg_func_p;
|
jerry_value_t reg_function = jerry_create_external_function (handler);
|
||||||
jerry_api_value_t reg_value;
|
|
||||||
bool bok;
|
|
||||||
|
|
||||||
global_obj_p = jerry_api_get_global ();
|
bool is_ok = true;
|
||||||
reg_func_p = jerry_api_create_external_function (handler);
|
|
||||||
|
|
||||||
if (!(reg_func_p != NULL
|
if (!(jerry_value_is_function (reg_function)
|
||||||
&& jerry_api_is_function (reg_func_p)
|
&& jerry_value_is_constructor (reg_function)))
|
||||||
&& jerry_api_is_constructor (reg_func_p)))
|
|
||||||
{
|
{
|
||||||
|
is_ok = false;
|
||||||
printf ("Error: create_external_function failed !!!\r\n");
|
printf ("Error: create_external_function failed !!!\r\n");
|
||||||
jerry_api_release_object (global_obj_p);
|
jerry_release_value (global_object_val);
|
||||||
return false;
|
jerry_release_value (reg_function);
|
||||||
|
return is_ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
jerry_api_acquire_object (reg_func_p);
|
if (jerry_value_has_error_flag (reg_function))
|
||||||
reg_value.type = JERRY_API_DATA_TYPE_OBJECT;
|
|
||||||
reg_value.u.v_object = reg_func_p;
|
|
||||||
|
|
||||||
bok = jerry_api_set_object_field_value (global_obj_p,
|
|
||||||
(jerry_api_char_t *) name,
|
|
||||||
®_value);
|
|
||||||
|
|
||||||
jerry_api_release_value (®_value);
|
|
||||||
jerry_api_release_object (reg_func_p);
|
|
||||||
jerry_api_release_object (global_obj_p);
|
|
||||||
|
|
||||||
if (!bok)
|
|
||||||
{
|
{
|
||||||
|
is_ok = false;
|
||||||
|
printf ("Error: create_external_function has error flag! \n\r");
|
||||||
|
jerry_release_value (global_object_val);
|
||||||
|
jerry_release_value (reg_function);
|
||||||
|
return is_ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
jerry_value_t jerry_name = jerry_create_string ((jerry_char_t *) name);
|
||||||
|
|
||||||
|
jerry_value_t set_result = jerry_set_property (global_object_val,
|
||||||
|
jerry_name,
|
||||||
|
reg_function);
|
||||||
|
|
||||||
|
|
||||||
|
if (jerry_value_has_error_flag (set_result))
|
||||||
|
{
|
||||||
|
is_ok = false;
|
||||||
printf ("Error: register_native_function failed: [%s]\r\n", name);
|
printf ("Error: register_native_function failed: [%s]\r\n", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return bok;
|
jerry_release_value (jerry_name);
|
||||||
|
jerry_release_value (global_object_val);
|
||||||
|
jerry_release_value (reg_function);
|
||||||
|
jerry_release_value (set_result);
|
||||||
|
|
||||||
|
return is_ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
void js_register_functions (void)
|
void js_register_functions (void)
|
||||||
|
|||||||
@@ -19,20 +19,6 @@
|
|||||||
#define JERRY_STANDALONE_EXIT_CODE_OK (0)
|
#define JERRY_STANDALONE_EXIT_CODE_OK (0)
|
||||||
#define JERRY_STANDALONE_EXIT_CODE_FAIL (1)
|
#define JERRY_STANDALONE_EXIT_CODE_FAIL (1)
|
||||||
|
|
||||||
#define API_DATA_IS_OBJECT(val_p) \
|
|
||||||
((val_p)->type == JERRY_API_DATA_TYPE_OBJECT)
|
|
||||||
|
|
||||||
#define API_DATA_IS_FUNCTION(val_p) \
|
|
||||||
(API_DATA_IS_OBJECT (val_p) && \
|
|
||||||
jerry_api_is_function ((val_p)->u.v_object))
|
|
||||||
|
|
||||||
#define JS_VALUE_TO_NUMBER(val_p) \
|
|
||||||
((val_p)->type == JERRY_API_DATA_TYPE_FLOAT32 ? \
|
|
||||||
static_cast<double>((val_p)->u.v_float32) : \
|
|
||||||
(val_p)->type == JERRY_API_DATA_TYPE_FLOAT64 ? \
|
|
||||||
static_cast<double>((val_p)->u.v_float64) : \
|
|
||||||
static_cast<double>((val_p)->u.v_uint32))
|
|
||||||
|
|
||||||
void js_register_functions (void);
|
void js_register_functions (void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "jerry-core/jerry.h"
|
#include "jerry-core/jerry-api.h"
|
||||||
#include "jerry_extapi.h"
|
#include "jerry_extapi.h"
|
||||||
#include "jerry_run.h"
|
#include "jerry_run.h"
|
||||||
|
|
||||||
@@ -25,101 +25,101 @@ static const char* fn_sys_loop_name = "sysloop";
|
|||||||
|
|
||||||
int js_entry (const char *source_p, const size_t source_size)
|
int js_entry (const char *source_p, const size_t source_size)
|
||||||
{
|
{
|
||||||
const jerry_api_char_t *jerry_src = (const jerry_api_char_t *) source_p;
|
const jerry_char_t *jerry_src = (const jerry_char_t *) source_p;
|
||||||
jerry_completion_code_t ret_code = JERRY_COMPLETION_CODE_OK;
|
jerry_init (JERRY_INIT_EMPTY);
|
||||||
jerry_flag_t flags = JERRY_FLAG_EMPTY;
|
uint8_t ret_code = 0;
|
||||||
jerry_api_object_t *err_obj_p = NULL;
|
|
||||||
jerry_api_value_t err_value = jerry_api_create_void_value ();
|
|
||||||
|
|
||||||
jerry_init (flags);
|
|
||||||
|
|
||||||
js_register_functions ();
|
js_register_functions ();
|
||||||
|
|
||||||
if (!jerry_parse (jerry_src, source_size, &err_obj_p))
|
jerry_value_t parsed_code = jerry_parse (jerry_src, source_size, false);
|
||||||
|
|
||||||
|
if (!jerry_value_has_error_flag (parsed_code))
|
||||||
{
|
{
|
||||||
printf ("Error: jerry_parse failed\r\n");
|
jerry_value_t ret_value = jerry_run (parsed_code);
|
||||||
ret_code = JERRY_COMPLETION_CODE_UNHANDLED_EXCEPTION;
|
|
||||||
jerry_api_release_object (err_obj_p);
|
if (jerry_value_has_error_flag (ret_value))
|
||||||
|
{
|
||||||
|
printf ("Error: ret_value has an error flag!\r\n");
|
||||||
|
return ret_code = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
jerry_release_value (ret_value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((flags & JERRY_FLAG_PARSE_ONLY) == 0)
|
printf ("Error: jerry_parse failed!\r\n");
|
||||||
{
|
ret_code = -1;
|
||||||
ret_code = jerry_run (&err_value);
|
|
||||||
jerry_api_string_t *err_str_p = NULL;
|
|
||||||
|
|
||||||
if (err_str_p != NULL)
|
|
||||||
{
|
|
||||||
jerry_api_release_string (err_str_p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jerry_release_value (parsed_code);
|
||||||
|
|
||||||
return ret_code;
|
return ret_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int js_eval (const char *source_p, const size_t source_size)
|
int js_eval (const char *source_p, const size_t source_size)
|
||||||
{
|
{
|
||||||
jerry_completion_code_t status;
|
int status = 0;
|
||||||
jerry_api_value_t res;
|
|
||||||
|
|
||||||
status = jerry_api_eval ((jerry_api_char_t *) source_p,
|
jerry_value_t ret_val = jerry_eval ((jerry_char_t *) source_p,
|
||||||
source_size,
|
source_size,
|
||||||
false,
|
false);
|
||||||
false,
|
|
||||||
&res);
|
|
||||||
|
|
||||||
jerry_api_release_value (&res);
|
if (jerry_value_has_error_flag (ret_val))
|
||||||
|
{
|
||||||
|
printf ("Error: jerry_eval failed!\r\n");
|
||||||
|
status = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
jerry_release_value (ret_val);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
int js_loop (uint32_t ticknow)
|
int js_loop (uint32_t ticknow)
|
||||||
{
|
{
|
||||||
jerry_api_object_t *global_obj_p;
|
int status = 0;
|
||||||
jerry_api_value_t sysloop_func;
|
jerry_value_t global_obj = jerry_get_global_object ();
|
||||||
bool is_ok;
|
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);
|
||||||
|
|
||||||
global_obj_p = jerry_api_get_global ();
|
if (jerry_value_has_error_flag (sysloop_func))
|
||||||
is_ok = jerry_api_get_object_field_value (global_obj_p,
|
|
||||||
(const jerry_api_char_t*) fn_sys_loop_name,
|
|
||||||
&sysloop_func);
|
|
||||||
if (!is_ok)
|
|
||||||
{
|
{
|
||||||
printf ("Error: '%s' not defined!!!\r\n", fn_sys_loop_name);
|
printf ("Error: '%s' not defined!!!\r\n", fn_sys_loop_name);
|
||||||
jerry_api_release_object (global_obj_p);
|
jerry_release_value (global_obj);
|
||||||
|
jerry_release_value (sysloop_func);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!API_DATA_IS_FUNCTION (&sysloop_func))
|
if (!jerry_value_is_function (sysloop_func))
|
||||||
{
|
{
|
||||||
printf ("Error: '%s' is not a function!!!\r\n", fn_sys_loop_name);
|
printf ("Error: '%s' is not a function!!!\r\n", fn_sys_loop_name);
|
||||||
jerry_api_release_value (&sysloop_func);
|
jerry_release_value (global_obj);
|
||||||
jerry_api_release_object (global_obj_p);
|
jerry_release_value (sysloop_func);
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
jerry_api_value_t* val_args;
|
jerry_value_t val_args[1];
|
||||||
uint16_t val_argv;
|
uint16_t val_argv = 1;
|
||||||
|
|
||||||
val_argv = 1;
|
val_args[0] = jerry_create_number (ticknow);
|
||||||
val_args = (jerry_api_value_t*) malloc (sizeof (jerry_api_value_t) * val_argv);
|
|
||||||
val_args[0].type = JERRY_API_DATA_TYPE_UINT32;
|
|
||||||
val_args[0].u.v_uint32 = ticknow;
|
|
||||||
|
|
||||||
jerry_api_value_t res;
|
jerry_value_t ret_val_sysloop = jerry_call_function (sysloop_func,
|
||||||
is_ok = jerry_api_call_function (sysloop_func.u.v_object,
|
global_obj,
|
||||||
global_obj_p,
|
val_args,
|
||||||
&res,
|
val_argv);
|
||||||
val_args,
|
if (jerry_value_has_error_flag (ret_val_sysloop))
|
||||||
val_argv);
|
{
|
||||||
jerry_api_release_value (&res);
|
status = -3;
|
||||||
free (val_args);
|
}
|
||||||
|
|
||||||
jerry_api_release_value (&sysloop_func);
|
jerry_release_value (global_obj);
|
||||||
jerry_api_release_object (global_obj_p);
|
jerry_release_value (ret_val_sysloop);
|
||||||
|
jerry_release_value (sysloop_func);
|
||||||
|
jerry_release_value (val_args[0]);
|
||||||
|
|
||||||
return 0;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
void js_exit (void)
|
void js_exit (void)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
|
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
|
||||||
|
* Copyright 2016 University of Szeged.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -15,17 +16,16 @@
|
|||||||
|
|
||||||
#include "mbed-drivers/mbed.h"
|
#include "mbed-drivers/mbed.h"
|
||||||
|
|
||||||
#include "jerry-core/jerry.h"
|
#include "jerry-core/jerry-api.h"
|
||||||
#include "jerry_run.h"
|
#include "jerry_run.h"
|
||||||
|
|
||||||
#include "jerry_targetjs.h"
|
#include "jerry_targetjs.h"
|
||||||
|
|
||||||
static Serial pc (USBTX, USBRX); //tx, rx
|
static Serial pc (USBTX, USBRX); //tx, rx
|
||||||
|
|
||||||
static int jerry_init (void)
|
static int jerry_task_init (void)
|
||||||
{
|
{
|
||||||
int retcode;
|
int retcode;
|
||||||
int src;
|
|
||||||
|
|
||||||
DECLARE_JS_CODES;
|
DECLARE_JS_CODES;
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ static int jerry_init (void)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/* run rest of the js files */
|
/* run rest of the js files */
|
||||||
for (src = 1; js_codes[src].source; src++)
|
for (int src = 1; js_codes[src].source; src++)
|
||||||
{
|
{
|
||||||
retcode = js_eval (js_codes[src].source, js_codes[src].length);
|
retcode = js_eval (js_codes[src].source, js_codes[src].length);
|
||||||
if (retcode != 0)
|
if (retcode != 0)
|
||||||
@@ -60,15 +60,13 @@ static void jerry_loop (void)
|
|||||||
|
|
||||||
void app_start (int, char**)
|
void app_start (int, char**)
|
||||||
{
|
{
|
||||||
// set 9600 baud rate for stdout
|
/* set 9600 baud rate for stdout */
|
||||||
pc.baud (9600);
|
pc.baud (9600);
|
||||||
|
|
||||||
printf ("\r\nJerryScript in mbed\r\n");
|
printf ("\r\nJerryScript in mbed\r\n");
|
||||||
printf (" build %s\r\n", jerry_build_date);
|
printf ("Version: \t%d.%d\n\n", JERRY_API_MAJOR_VERSION, JERRY_API_MINOR_VERSION);
|
||||||
printf (" hash %s\r\n", jerry_commit_hash);
|
|
||||||
printf (" branch %s\r\n", jerry_branch_name);
|
|
||||||
|
|
||||||
if (jerry_init () == 0)
|
if (jerry_task_init () == 0)
|
||||||
{
|
{
|
||||||
minar::Scheduler::postCallback(jerry_loop).period(minar::milliseconds(100));
|
minar::Scheduler::postCallback(jerry_loop).period(minar::milliseconds(100));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user