1425bb815Sopenharmony_ci/*
2425bb815Sopenharmony_ci * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
3425bb815Sopenharmony_ci * Description: Definition of header file for generating bytecode.
4425bb815Sopenharmony_ci * Create: 2020/09/07
5425bb815Sopenharmony_ci */
6425bb815Sopenharmony_ci
7425bb815Sopenharmony_ci#ifndef GENERATE_BYTECODE_H
8425bb815Sopenharmony_ci#define GENERATE_BYTECODE_H
9425bb815Sopenharmony_ci
10425bb815Sopenharmony_ci#ifdef __cplusplus
11425bb815Sopenharmony_ciextern "C"
12425bb815Sopenharmony_ci{
13425bb815Sopenharmony_ci#endif /* __cplusplus */
14425bb815Sopenharmony_ci
15425bb815Sopenharmony_ci#ifdef JERRY_FOR_IAR_CONFIG
16425bb815Sopenharmony_ci
17425bb815Sopenharmony_ci#include "jerryscript.h"
18425bb815Sopenharmony_ci#include "jerry-snapshot.h"
19425bb815Sopenharmony_ci
20425bb815Sopenharmony_citypedef enum {
21425bb815Sopenharmony_ci  EXCE_ACE_JERRY_EXEC_OK = 0, // program function OK
22425bb815Sopenharmony_ci  EXCE_ACE_JERRY_NULL_PATH, // null path for generateing snapshot
23425bb815Sopenharmony_ci  EXCE_ACE_JERRY_MALLOC_ERROR, // error when malloc
24425bb815Sopenharmony_ci  EXCE_ACE_JERRY_INPUT_PATH_ERROR, // passed input path is NULL OR open failed
25425bb815Sopenharmony_ci  EXCE_ACE_JERRY_INPUT_PATH_NOT_DIR, // passed input path is not a directory
26425bb815Sopenharmony_ci  EXCE_ACE_JERRY_OPEN_DIR_FAILED, // open directory failed
27425bb815Sopenharmony_ci  EXCE_ACE_JERRY_GENERATE_SNAPSHOT_FAILED, // jerry_generate_snapshot failed
28425bb815Sopenharmony_ci  EXCE_ACE_JERRY_OPEN_FILE_FAILED, // open file failed
29425bb815Sopenharmony_ci  EXCE_ACE_JERRY_WRITE_SNAPSHOT_FILE_FAILED, // write into snapshot file failed
30425bb815Sopenharmony_ci  EXCE_ACE_JERRY_READ_FILE_FAILED, // read .js file or snapshot file process failed
31425bb815Sopenharmony_ci  EXCE_ACE_JERRY_FILE_TOO_LARGE, // bytes of js or snapshot file out of psRAM buffer size for them
32425bb815Sopenharmony_ci  EXCE_ACE_JERRY_SPLICE_PATH_ERROR, // error when splice path
33425bb815Sopenharmony_ci  EXCE_ACE_JERRY_SPLICE_OUTPUT_PATH_ERROR, // error when splice output file abs name
34425bb815Sopenharmony_ci  EXCE_ACE_JERRY_SPRINTFS_VERSION_ERROR, // error when sprintf_s for jerry_version
35425bb815Sopenharmony_ci  EXCE_ACE_JERRY_GET_FILE_STAT_ERROR, // error when getting file stat
36425bb815Sopenharmony_ci  EXCE_ACE_JERRY_LINKLIST_ERROR, // error when malloc for list node
37425bb815Sopenharmony_ci  EXCE_ACE_JERRY_UNLINKFILE_ERROR, // error when unlink bytecode file
38425bb815Sopenharmony_ci  EXCE_ACE_JERRY_SNAPSHOT_VERSION_ERROR, // snapshot file version wrong
39425bb815Sopenharmony_ci} EXECRES;
40425bb815Sopenharmony_ci
41425bb815Sopenharmony_citypedef struct
42425bb815Sopenharmony_ci{
43425bb815Sopenharmony_ci  jerry_context_t *context_p;
44425bb815Sopenharmony_ci} ContextRecord;
45425bb815Sopenharmony_ci
46425bb815Sopenharmony_cichar* get_jerry_version_no();
47425bb815Sopenharmony_ciEXECRES walk_directory(char* filefolder);
48425bb815Sopenharmony_ciEXECRES walk_del_bytecode(char* filefolder);
49425bb815Sopenharmony_ci
50425bb815Sopenharmony_civoid bms_task_context_init (void);
51425bb815Sopenharmony_civoid js_task_context_init (void);
52425bb815Sopenharmony_civoid jerry_port_default_remove_current_context_record ();
53425bb815Sopenharmony_ci
54425bb815Sopenharmony_civoid jerry_external_context_init(uint32_t heap_size, jerry_context_alloc_t alloc, void *cb_data_p);
55425bb815Sopenharmony_ci
56425bb815Sopenharmony_civoid RefreshAllServiceTimeStamp(void);
57425bb815Sopenharmony_ci#endif  // JERRY_FOR_IAR_CONFIG
58425bb815Sopenharmony_ci
59425bb815Sopenharmony_ci#ifdef __cplusplus
60425bb815Sopenharmony_ci}
61425bb815Sopenharmony_ci#endif /* __cplusplus */
62425bb815Sopenharmony_ci#endif  // GENERATE_BYTECODE_H
63