Skip to content

Commit 2a435a8

Browse files
committed
Replace usage of jerryx_print_byte with jerryx_print_buffer.
As we now have JERRY_ZSTR_ARG, so we can take advantage of it With this, the jerry_port_print_byte port api won't need any more, this reduced the port api surface JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo [email protected]
1 parent a75d4ec commit 2a435a8

File tree

9 files changed

+18
-64
lines changed

9 files changed

+18
-64
lines changed

docs/05.PORT-API.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,18 +116,6 @@ void jerry_port_context_free (void);
116116
void jerry_port_log (const char *message_p);
117117
```
118118
119-
```c
120-
/**
121-
* Print a single character to standard output.
122-
*
123-
* This port function is never called from jerry-core directly, it is only used by jerry-ext components to print
124-
* information.
125-
*
126-
* @param byte: the byte to print.
127-
*/
128-
void jerry_port_print_byte (jerry_char_t byte);
129-
```
130-
131119
```c
132120
/**
133121
* Print a buffer to standard output

docs/10.EXT-REFERENCE-HANDLER.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -351,22 +351,22 @@ jerryx_handler_gc (const jerry_value_t func_obj_val, const jerry_value_t this_p,
351351
**Summary**
352352

353353
Provide a `print` implementation for scripts. The routine converts all of its
354-
arguments to strings and outputs them char-by-char using
355-
`jerry_port_print_byte`. The NULL character is output as "\u0000",
356-
other characters are output bytewise.
354+
arguments to strings and outputs them by using `jerry_port_print_buffer`.
355+
The NULL character is output as "\u0000", other characters are output bytewise.
357356

358357
*Note*: This implementation does not use standard C `printf` to print its
359358
output. This allows more flexibility but also extends the core JerryScript
360359
engine port API. Applications that want to use `jerryx_handler_print` must
361360
ensure that their port implementation also provides
362-
`jerry_port_print_byte`.
361+
`jerry_port_print_buffer`.
363362

364363
**Prototype**
365364

366365
```c
367366
jerry_value_t
368-
jerryx_handler_print (const jerry_value_t func_obj_val, const jerry_value_t this_p,
369-
const jerry_value_t args_p[], const jerry_length_t args_cnt);
367+
jerryx_handler_print (const jerry_call_info_t *call_info_p,
368+
const jerry_value_t args_p[],
369+
const jerry_length_t args_cnt);
370370
```
371371
372372
- `func_obj_val` - the function object that was called (unused).
@@ -379,7 +379,7 @@ jerryx_handler_print (const jerry_value_t func_obj_val, const jerry_value_t this
379379
**See also**
380380
381381
- [jerryx_register_global](#jerryx_register_global)
382-
- [jerry_port_print_byte](05.PORT-API.md#jerry_port_print_char)
382+
- [jerry_port_print_buffer](05.PORT-API.md#jerry_port_print_buffer)
383383
384384
385385
# Handler registration helper

docs/16.MIGRATION-GUIDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,3 +770,4 @@ In this section the new API functions are listed.
770770
- [`jerry_port_get_current_context`](05.PORT-API.md#jerry_port_get_current_context)
771771
- [`jerry_port_fatal`](05.PORT-API.md#jerry_port_fatal)
772772
- [`jerry_port_sleep`](05.PORT-API.md#jerry_port_sleep)
773+
- [`jerry_port_print_byte`](05.PORT-API.md#jerry_port_print_byte)

jerry-core/include/jerryscript-port.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,6 @@ void jerry_port_context_free (void);
142142
*/
143143
void jerry_port_log (const char *message_p);
144144

145-
/**
146-
* Print a single character to standard output.
147-
*
148-
* This port function is never called from jerry-core directly, it is only used by jerry-ext components to print
149-
* information.
150-
*
151-
* @param byte: the byte to print.
152-
*/
153-
void jerry_port_print_byte (jerry_char_t byte);
154-
155145
/**
156146
* Print a buffer to standard output
157147
*

jerry-ext/include/jerryscript-ext/print.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
JERRY_C_API_BEGIN
2323

2424
jerry_value_t jerryx_print_value (const jerry_value_t value);
25-
void jerryx_print_byte (jerry_char_t ch);
2625
void jerryx_print_buffer (const jerry_char_t *buffer_p, jerry_size_t buffer_size);
2726
void jerryx_print_backtrace (unsigned depth);
2827
void jerryx_print_unhandled_exception (jerry_value_t exception);

jerry-ext/util/handlers.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@
2525
* Provide a 'print' implementation for scripts.
2626
*
2727
* The routine converts all of its arguments to strings and outputs them
28-
* char-by-char using jerry_port_print_byte.
28+
* by using jerry_port_print_buffer.
2929
*
30-
* The NUL character is output as "\u0000", other characters are output
30+
* The NULL character is output as "\u0000", other characters are output
3131
* bytewise.
3232
*
3333
* Note:
3434
* This implementation does not use standard C `printf` to print its
3535
* output. This allows more flexibility but also extends the core
3636
* JerryScript engine port API. Applications that want to use
3737
* `jerryx_handler_print` must ensure that their port implementation also
38-
* provides `jerry_port_print_byte`.
38+
* provides `jerry_port_print_buffer`.
3939
*
4040
* @return undefined - if all arguments could be converted to strings,
4141
* error - otherwise.
@@ -51,7 +51,7 @@ jerryx_handler_print (const jerry_call_info_t *call_info_p, /**< call informatio
5151
{
5252
if (index > 0)
5353
{
54-
jerryx_print_byte (' ');
54+
jerryx_print_buffer (JERRY_ZSTR_ARG (" "));
5555
}
5656

5757
jerry_value_t result = jerryx_print_value (args_p[index]);
@@ -62,7 +62,7 @@ jerryx_handler_print (const jerry_call_info_t *call_info_p, /**< call informatio
6262
}
6363
}
6464

65-
jerryx_print_byte ('\n');
65+
jerryx_print_buffer (JERRY_ZSTR_ARG ("\n"));
6666
return jerry_undefined ();
6767
} /* jerryx_handler_print */
6868

jerry-ext/util/print.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -111,20 +111,6 @@ jerryx_print_value (const jerry_value_t value)
111111
return jerry_undefined ();
112112
} /* jerryx_print */
113113

114-
/**
115-
* Print a character to standard output, also sending it to the debugger, if connected.
116-
*
117-
* @param ch: input character
118-
*/
119-
void
120-
jerryx_print_byte (jerry_char_t byte)
121-
{
122-
jerry_port_print_byte (byte);
123-
#if JERRY_DEBUGGER
124-
jerry_debugger_send_output (&byte, 1);
125-
#endif /* JERRY_DEBUGGER */
126-
} /* jerryx_print_char */
127-
128114
/**
129115
* Print a buffer to standard output, also sending it to the debugger, if connected.
130116
*

jerry-ext/util/repl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jerryx_repl (const jerry_char_t *prompt_p, jerry_size_t prompt_size)
3838

3939
if (line_p == NULL)
4040
{
41-
jerryx_print_byte ('\n');
41+
jerryx_print_buffer (JERRY_ZSTR_ARG ("\n"));
4242
return;
4343
}
4444

@@ -80,7 +80,7 @@ jerryx_repl (const jerry_char_t *prompt_p, jerry_size_t prompt_size)
8080
goto exception;
8181
}
8282

83-
jerryx_print_byte ('\n');
83+
jerryx_print_buffer (JERRY_ZSTR_ARG ("\n"));
8484

8585
jerry_value_free (result);
8686
result = jerry_run_jobs ();

jerry-port/common/jerry-port-io.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,7 @@ jerry_port_log (const char *message_p) /**< message */
2929
} /* jerry_port_log */
3030

3131
/**
32-
* Default implementation of jerry_port_print_byte. Uses 'putchar' to
33-
* print a single character to standard output.
34-
*/
35-
void JERRY_ATTR_WEAK
36-
jerry_port_print_byte (jerry_char_t byte) /**< the character to print */
37-
{
38-
putchar (byte);
39-
} /* jerry_port_print_byte */
40-
41-
/**
42-
* Default implementation of jerry_port_print_buffer. Uses 'jerry_port_print_byte' to
32+
* Default implementation of jerry_port_print_buffer. Uses 'putchar' to
4333
* print characters of the input buffer.
4434
*/
4535
void JERRY_ATTR_WEAK
@@ -48,9 +38,9 @@ jerry_port_print_buffer (const jerry_char_t *buffer_p, /**< string buffer */
4838
{
4939
for (jerry_size_t i = 0; i < buffer_size; i++)
5040
{
51-
jerry_port_print_byte (buffer_p[i]);
41+
putchar (buffer_p[i]);
5242
}
53-
} /* jerry_port_print_byte */
43+
} /* jerry_port_print_buffer */
5444

5545
/**
5646
* Read a line from standard input as a zero-terminated string.

0 commit comments

Comments
 (0)