-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.c
61 lines (50 loc) · 1.45 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**
* File: run_js.c
* Author: AWTK Develop Team
* Brief: entry of javascript awtk
*
* Copyright (c) 2018 - 2018 Guangzhou ZHIYUAN Electronics Co.,Ltd.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* License file for more details.
*
*/
/**
* History:
* ================================================================
* 2018-08-08 Li XianJing <xianjimli@hotmail.com> created
*
*/
#include "awtk.h"
#include "awtk_js.h"
#include "jerry_script_helper.h"
const char* script_file = NULL;
static ret_t on_cmd_line(int argc, char* argv[]) {
script_file = argc == 2 ? argv[1] : "demoui";
return RET_OK;
}
#define BOOT_SCRIPT \
"\
if (this['console'] === undefined) { \
this.console = {};\
this.console.log = function (str) {\
print(str);\
};\
}"
static ret_t application_init() {
awtk_jerryscript_init();
jerry_script_eval_buff(BOOT_SCRIPT, strlen(BOOT_SCRIPT), "console.js", TRUE);
return_value_if_fail(jerry_script_eval_file("awtk", TRUE) == RET_OK, RET_FAIL);
return_value_if_fail(jerry_script_eval_file(script_file, FALSE) == RET_OK, RET_FAIL);
return RET_OK;
}
static ret_t application_exit() {
return RET_OK;
}
#define APP_NAME "AWTK-JS"
#define ON_CMD_LINE on_cmd_line
#define FINAL_EXIT() awtk_jerryscript_deinit()
#include "../../res/assets.inc"
#include "awtk_main.inc"