Skip to content

Commit 6c3a6e7

Browse files
akosthekissyichoi
authored andcommitted
Rename jerry-port.h to jerryscript-port.h (#1762)
All public headers should follow the pattern `jerryscript[-*].h`. The `jerry-api.h` to `jerryscript.h` renaming has already happened a while ago, now it's time for the port API header to follow. This patch * renames the public header file, * updates all includes to use the new file name (in `jerry-main`, in all the targets, and in the docs), and * keeps `jerry-port.h` as a deprecated forwarding header to leave some time for external users to follow up with this change. As a related change, the header of the default port implementation is also changed to `jerryscript-port-default.h`. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss [email protected]
1 parent 63b6fd1 commit 6c3a6e7

File tree

23 files changed

+194
-171
lines changed

23 files changed

+194
-171
lines changed

docs/03.API-EXAMPLE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ The following example function will output a JavaScript value:
177177
#include <string.h>
178178
179179
#include "jerryscript.h"
180-
#include "jerry-port.h"
180+
#include "jerryscript-port.h"
181181
182182
static void
183183
print_value (const jerry_value_t value)
@@ -247,7 +247,7 @@ Shell operation can be described with the following loop:
247247
#include <string.h>
248248

249249
#include "jerryscript.h"
250-
#include "jerry-port.h"
250+
#include "jerryscript-port.h"
251251

252252
static void print_value (const jerry_value_t);
253253

docs/05.PORT-API.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ This section describes a basic port implementation which was created for Unix ba
116116

117117
```c
118118
#include <stdlib.h>
119-
#include "jerry-port.h"
119+
#include "jerryscript-port.h"
120120

121121
/**
122122
* Default implementation of jerry_port_fatal.
@@ -131,7 +131,7 @@ void jerry_port_fatal (jerry_fatal_code_t code)
131131
132132
```c
133133
#include <stdarg.h>
134-
#include "jerry-port.h"
134+
#include "jerryscript-port.h"
135135
136136
/**
137137
* Provide console message implementation for the engine.
@@ -168,7 +168,7 @@ jerry_port_log (jerry_log_level_t level, /**< log level */
168168

169169
```c
170170
#include <sys/time.h>
171-
#include "jerry-port.h"
171+
#include "jerryscript-port.h"
172172

173173
/**
174174
* Default implementation of jerry_port_get_time_zone.

jerry-core/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,4 +270,4 @@ foreach(EXT_LIB ${EXTERNAL_LINK_LIBS})
270270
endforeach()
271271

272272
install(TARGETS ${JERRY_CORE_NAME} DESTINATION lib)
273-
install(FILES jerry-api.h jerryscript.h jerry-port.h DESTINATION include)
273+
install(FILES jerryscript.h jerryscript-port.h jerry-api.h jerry-port.h DESTINATION include)

jerry-core/debugger/jerry-debugger-ws.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
#include "jcontext.h"
2424
#include "jerry-debugger.h"
25-
#include "jerry-port.h"
25+
#include "jerryscript-port.h"
2626

2727
/**
2828
* Debugger socket communication port.

jerry-core/debugger/jerry-debugger.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "ecma-objects.h"
2222
#include "jcontext.h"
2323
#include "jerry-debugger.h"
24-
#include "jerry-port.h"
24+
#include "jerryscript-port.h"
2525

2626
/**
2727
* Type cast the debugger send buffer into a specific type.

jerry-core/ecma/operations/ecma-jobqueue.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "ecma-jobqueue.h"
2020
#include "ecma-objects.h"
2121
#include "ecma-promise-object.h"
22-
#include "jerry-port.h"
22+
#include "jerryscript-port.h"
2323

2424
#ifndef CONFIG_DISABLE_ES2015_PROMISE_BUILTIN
2525

jerry-core/jerry-port.h

Lines changed: 2 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -16,145 +16,8 @@
1616
#ifndef JERRY_PORT_H
1717
#define JERRY_PORT_H
1818

19-
#include <stdbool.h>
20-
#include <stdint.h>
21-
#include <stdio.h>
19+
#pragma message ("using jerry-port.h directly is deprecated, please use jerryscript-port.h")
2220

23-
#ifdef __cplusplus
24-
extern "C"
25-
{
26-
#endif /* __cplusplus */
21+
#include "jerryscript-port.h"
2722

28-
/** \addtogroup jerry_port Jerry engine port
29-
* @{
30-
*/
31-
32-
/*
33-
* Termination Port API
34-
*
35-
* Note:
36-
* It is questionable whether a library should be able to terminate an
37-
* application. However, as of now, we only have the concept of completion
38-
* code around jerry_parse and jerry_run. Most of the other API functions
39-
* have no way of signaling an error. So, we keep the termination approach
40-
* with this port function.
41-
*/
42-
43-
/**
44-
* Error codes
45-
*/
46-
typedef enum
47-
{
48-
ERR_OUT_OF_MEMORY = 10,
49-
ERR_SYSCALL = 11,
50-
ERR_REF_COUNT_LIMIT = 12,
51-
ERR_FAILED_INTERNAL_ASSERTION = 120
52-
} jerry_fatal_code_t;
53-
54-
/**
55-
* Signal the port that jerry experienced a fatal failure from which it cannot
56-
* recover.
57-
*
58-
* @param code gives the cause of the error.
59-
*
60-
* Note:
61-
* Jerry expects the function not to return.
62-
*
63-
* Example: a libc-based port may implement this with exit() or abort(), or both.
64-
*/
65-
void jerry_port_fatal (jerry_fatal_code_t code);
66-
67-
/*
68-
* I/O Port API
69-
*/
70-
71-
/**
72-
* Print a string to the console. The function should implement a printf-like
73-
* interface, where the first argument specifies a format string on how to
74-
* stringify the rest of the parameter list.
75-
*
76-
* This function is only called with strings coming from the executed ECMAScript
77-
* wanting to print something as the result of its normal operation.
78-
*
79-
* It should be the port that decides what a "console" is.
80-
*
81-
* Example: a libc-based port may implement this with vprintf().
82-
*/
83-
void jerry_port_console (const char *format, ...) __attribute__ ((format (printf, 1, 2)));
84-
85-
/**
86-
* Jerry log levels. The levels are in severity order
87-
* where the most serious levels come first.
88-
*/
89-
typedef enum
90-
{
91-
JERRY_LOG_LEVEL_ERROR, /**< the engine will terminate after the message is printed */
92-
JERRY_LOG_LEVEL_WARNING, /**< a request is aborted, but the engine continues its operation */
93-
JERRY_LOG_LEVEL_DEBUG, /**< debug messages from the engine, low volume */
94-
JERRY_LOG_LEVEL_TRACE /**< detailed info about engine internals, potentially high volume */
95-
} jerry_log_level_t;
96-
97-
/**
98-
* Display or log a debug/error message. The function should implement a printf-like
99-
* interface, where the first argument specifies the log level
100-
* and the second argument specifies a format string on how to stringify the rest
101-
* of the parameter list.
102-
*
103-
* This function is only called with messages coming from the jerry engine as
104-
* the result of some abnormal operation or describing its internal operations
105-
* (e.g., data structure dumps or tracing info).
106-
*
107-
* It should be the port that decides whether error and debug messages are logged to
108-
* the console, or saved to a database or to a file.
109-
*
110-
* Example: a libc-based port may implement this with vfprintf(stderr) or
111-
* vfprintf(logfile), or both, depending on log level.
112-
*/
113-
void jerry_port_log (jerry_log_level_t level, const char *format, ...) __attribute__ ((format (printf, 2, 3)));
114-
115-
/*
116-
* Date Port API
117-
*/
118-
119-
/**
120-
* Jerry time zone structure
121-
*/
122-
typedef struct
123-
{
124-
int offset; /**< minutes from west */
125-
int daylight_saving_time; /**< daylight saving time (1 - DST applies, 0 - not on DST) */
126-
} jerry_time_zone_t;
127-
128-
/**
129-
* Get timezone and daylight saving data
130-
*
131-
* @return true - if success
132-
* false - otherwise
133-
*/
134-
bool jerry_port_get_time_zone (jerry_time_zone_t *tz_p);
135-
136-
/**
137-
* Get system time
138-
*
139-
* @return milliseconds since Unix epoch
140-
*/
141-
double jerry_port_get_current_time (void);
142-
143-
#ifndef CONFIG_DISABLE_ES2015_PROMISE_BUILTIN
144-
145-
#define JERRY_PORT_ENABLE_JOBQUEUE
146-
147-
typedef uint32_t (*jerry_job_handler_t) (void *);
148-
149-
void jerry_port_jobqueue_enqueue (jerry_job_handler_t handler, void *job_p);
150-
151-
#endif /* !CONFIG_DISABLE_ES2015_PROMISE_BUILTIN */
152-
153-
/**
154-
* @}
155-
*/
156-
157-
#ifdef __cplusplus
158-
}
159-
#endif /* __cplusplus */
16023
#endif /* !JERRY_PORT_H */

jerry-core/jerryscript-port.h

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
/* Copyright JS Foundation and other contributors, http://js.foundation
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
#ifndef JERRYSCRIPT_PORT_H
17+
#define JERRYSCRIPT_PORT_H
18+
19+
#include <stdbool.h>
20+
#include <stdint.h>
21+
#include <stdio.h>
22+
23+
#ifdef __cplusplus
24+
extern "C"
25+
{
26+
#endif /* __cplusplus */
27+
28+
/** \addtogroup jerry_port Jerry engine port
29+
* @{
30+
*/
31+
32+
/*
33+
* Termination Port API
34+
*
35+
* Note:
36+
* It is questionable whether a library should be able to terminate an
37+
* application. However, as of now, we only have the concept of completion
38+
* code around jerry_parse and jerry_run. Most of the other API functions
39+
* have no way of signaling an error. So, we keep the termination approach
40+
* with this port function.
41+
*/
42+
43+
/**
44+
* Error codes
45+
*/
46+
typedef enum
47+
{
48+
ERR_OUT_OF_MEMORY = 10,
49+
ERR_SYSCALL = 11,
50+
ERR_REF_COUNT_LIMIT = 12,
51+
ERR_FAILED_INTERNAL_ASSERTION = 120
52+
} jerry_fatal_code_t;
53+
54+
/**
55+
* Signal the port that jerry experienced a fatal failure from which it cannot
56+
* recover.
57+
*
58+
* @param code gives the cause of the error.
59+
*
60+
* Note:
61+
* Jerry expects the function not to return.
62+
*
63+
* Example: a libc-based port may implement this with exit() or abort(), or both.
64+
*/
65+
void jerry_port_fatal (jerry_fatal_code_t code);
66+
67+
/*
68+
* I/O Port API
69+
*/
70+
71+
/**
72+
* Print a string to the console. The function should implement a printf-like
73+
* interface, where the first argument specifies a format string on how to
74+
* stringify the rest of the parameter list.
75+
*
76+
* This function is only called with strings coming from the executed ECMAScript
77+
* wanting to print something as the result of its normal operation.
78+
*
79+
* It should be the port that decides what a "console" is.
80+
*
81+
* Example: a libc-based port may implement this with vprintf().
82+
*/
83+
void jerry_port_console (const char *format, ...) __attribute__ ((format (printf, 1, 2)));
84+
85+
/**
86+
* Jerry log levels. The levels are in severity order
87+
* where the most serious levels come first.
88+
*/
89+
typedef enum
90+
{
91+
JERRY_LOG_LEVEL_ERROR, /**< the engine will terminate after the message is printed */
92+
JERRY_LOG_LEVEL_WARNING, /**< a request is aborted, but the engine continues its operation */
93+
JERRY_LOG_LEVEL_DEBUG, /**< debug messages from the engine, low volume */
94+
JERRY_LOG_LEVEL_TRACE /**< detailed info about engine internals, potentially high volume */
95+
} jerry_log_level_t;
96+
97+
/**
98+
* Display or log a debug/error message. The function should implement a printf-like
99+
* interface, where the first argument specifies the log level
100+
* and the second argument specifies a format string on how to stringify the rest
101+
* of the parameter list.
102+
*
103+
* This function is only called with messages coming from the jerry engine as
104+
* the result of some abnormal operation or describing its internal operations
105+
* (e.g., data structure dumps or tracing info).
106+
*
107+
* It should be the port that decides whether error and debug messages are logged to
108+
* the console, or saved to a database or to a file.
109+
*
110+
* Example: a libc-based port may implement this with vfprintf(stderr) or
111+
* vfprintf(logfile), or both, depending on log level.
112+
*/
113+
void jerry_port_log (jerry_log_level_t level, const char *format, ...) __attribute__ ((format (printf, 2, 3)));
114+
115+
/*
116+
* Date Port API
117+
*/
118+
119+
/**
120+
* Jerry time zone structure
121+
*/
122+
typedef struct
123+
{
124+
int offset; /**< minutes from west */
125+
int daylight_saving_time; /**< daylight saving time (1 - DST applies, 0 - not on DST) */
126+
} jerry_time_zone_t;
127+
128+
/**
129+
* Get timezone and daylight saving data
130+
*
131+
* @return true - if success
132+
* false - otherwise
133+
*/
134+
bool jerry_port_get_time_zone (jerry_time_zone_t *tz_p);
135+
136+
/**
137+
* Get system time
138+
*
139+
* @return milliseconds since Unix epoch
140+
*/
141+
double jerry_port_get_current_time (void);
142+
143+
#ifndef CONFIG_DISABLE_ES2015_PROMISE_BUILTIN
144+
145+
#define JERRY_PORT_ENABLE_JOBQUEUE
146+
147+
typedef uint32_t (*jerry_job_handler_t) (void *);
148+
149+
void jerry_port_jobqueue_enqueue (jerry_job_handler_t handler, void *job_p);
150+
151+
#endif /* !CONFIG_DISABLE_ES2015_PROMISE_BUILTIN */
152+
153+
/**
154+
* @}
155+
*/
156+
157+
#ifdef __cplusplus
158+
}
159+
#endif /* __cplusplus */
160+
#endif /* !JERRYSCRIPT_PORT_H */

jerry-core/jrt/jrt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <string.h>
2121

2222
#include "jerryscript.h"
23-
#include "jerry-port.h"
23+
#include "jerryscript-port.h"
2424
#include "jrt-types.h"
2525

2626
/*

0 commit comments

Comments
 (0)