Skip to content

Commit fc6f73f

Browse files
committed
Speculatively removing jerry_port_console from all non-default targets
Most targets implemented `jerry_port_console` for the sake of the engine only; in those targets the removal was trivial. Where the function was called from the embedder application as well, the calls were replaced with equivalents (e.g., `printf`, `printk`). NOTE: This patch still leaves several targets without a JS `print` implementation. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
1 parent 3c6e11a commit fc6f73f

File tree

8 files changed

+19
-122
lines changed

8 files changed

+19
-122
lines changed

targets/curie_bsp/jerry_app/quark/main.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "zephyr.h"
3737
#include "microkernel/task.h"
3838
#include "os/os.h"
39+
#include "misc/printk.h"
3940

4041
static T_QUEUE queue;
4142

@@ -51,17 +52,17 @@ void jerry_resolve_error (jerry_value_t ret_value)
5152
jerry_char_t *err_str_buf = (jerry_char_t *) balloc (err_str_size, NULL);
5253
jerry_size_t sz = jerry_string_to_char_buffer (err_str_val, err_str_buf, err_str_size);
5354
err_str_buf[sz] = 0;
54-
jerry_port_console ("Script Error: unhandled exception: %s\n", err_str_buf);
55+
printk ("Script Error: unhandled exception: %s\n", err_str_buf);
5556
bfree(err_str_buf);
5657
jerry_release_value (err_str_val);
5758
}
5859
}
5960

6061
void help ()
6162
{
62-
jerry_port_console ("Usage:\n");
63-
jerry_port_console ("js e 'JavaScript Command'\n");
64-
jerry_port_console ("eg. js e print ('Hello World');\n");
63+
printk ("Usage:\n");
64+
printk ("js e 'JavaScript Command'\n");
65+
printk ("eg. js e print ('Hello World');\n");
6566
}
6667

6768
void eval_jerry_script (int argc, char *argv[], struct tcmd_handler_ctx *ctx)
@@ -79,7 +80,7 @@ void eval_jerry_script (int argc, char *argv[], struct tcmd_handler_ctx *ctx)
7980
size_t *str_lens = (size_t *) balloc ((argc - 2) * sizeof(size_t), &err);
8081
if (str_lens == NULL || err != E_OS_OK)
8182
{
82-
jerry_port_console ("%s: allocate memory failed!", __func__);
83+
printk ("%s: allocate memory failed!", __func__);
8384
TCMD_RSP_ERROR (ctx, NULL);
8485
return;
8586
}
@@ -92,7 +93,7 @@ void eval_jerry_script (int argc, char *argv[], struct tcmd_handler_ctx *ctx)
9293
char *buffer = (char *) balloc (str_total_length, &err);
9394
if (buffer == NULL || err != E_OS_OK)
9495
{
95-
jerry_port_console ("%s: allocate memory failed!", __func__);
96+
printk ("%s: allocate memory failed!", __func__);
9697
TCMD_RSP_ERROR (ctx, NULL);
9798
return;
9899
}

targets/curie_bsp/source/curie-bsp-port.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,6 @@
2020
#include <stddef.h>
2121
#include "jerryscript-port.h"
2222

23-
/**
24-
* Provide console message implementation for the engine.
25-
* Curie BSP implementation
26-
*/
27-
void
28-
jerry_port_console (const char *format, /**< format string */
29-
...) /**< parameters */
30-
{
31-
char buf[256];
32-
int length = 0;
33-
va_list args;
34-
va_start (args, format);
35-
length = vsnprintf (buf, 256, format, args);
36-
buf[length] = '\0';
37-
printk ("%s", buf);
38-
va_end (args);
39-
} /* jerry_port_console */
40-
4123
/**
4224
* Provide log message implementation for the engine.
4325
* Curie BSP implementation

targets/esp8266/user/jerry_port.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,6 @@
2020
#include "jerry-core/jerryscript-port.h"
2121
int ets_putc (int);
2222

23-
/**
24-
* Provide console message implementation for the engine.
25-
*/
26-
void
27-
jerry_port_console (const char *format, /**< format string */
28-
...) /**< parameters */
29-
{
30-
va_list args;
31-
va_start (args, format);
32-
ets_vprintf (ets_putc, format, args);
33-
va_end (args);
34-
} /* jerry_port_console */
35-
3623
/**
3724
* Provide log message implementation for the engine.
3825
*/

targets/mbed/source/port/jerry_port.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,6 @@
2222

2323
#include "mbed-hal/us_ticker_api.h"
2424

25-
/**
26-
* Provide console message implementation for the engine.
27-
*/
28-
void
29-
jerry_port_console (const char *format, /**< format string */
30-
...) /**< parameters */
31-
{
32-
va_list args;
33-
va_start (args, format);
34-
vfprintf (stdout, format, args);
35-
va_end (args);
36-
} /* jerry_port_console */
37-
3825
/**
3926
* Provide log message implementation for the engine.
4027
*/
@@ -62,7 +49,7 @@ jerry_port_fatal (jerry_fatal_code_t code) /**< fatal code enum item */
6249

6350
/**
6451
* Implementation of jerry_port_get_time_zone.
65-
*
52+
*
6653
* @return true - if success
6754
*/
6855
bool

targets/mbedos5/source/jerry_port_mbed.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,6 @@
2222

2323
#include "us_ticker_api.h"
2424

25-
#ifndef JSMBED_OVERRIDE_JERRY_PORT_CONSOLE
26-
/**
27-
* Provide console message implementation for the engine.
28-
*/
29-
void
30-
jerry_port_console (const char *format, /**< format string */
31-
...) /**< parameters */
32-
{
33-
va_list args;
34-
va_start (args, format);
35-
vfprintf (stdout, format, args);
36-
va_end (args);
37-
38-
if (strlen (format) == 1 && format[0] == 0x0a) /* line feed (\n) */
39-
{
40-
printf ("\r"); /* add CR for proper display in serial monitors */
41-
}
42-
} /* jerry_port_console */
43-
#endif /* JSMBED_OVERRIDE_JERRY_PORT_CONSOLE */
44-
4525
#ifndef JSMBED_OVERRIDE_JERRY_PORT_LOG
4626
/**
4727
* Provide log message implementation for the engine.

targets/nuttx-stm32f4/jerry_main.c

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,16 @@
4444
static void
4545
print_help (char *name)
4646
{
47-
jerry_port_console ("Usage: %s [OPTION]... [FILE]...\n"
48-
"\n"
49-
"Options:\n"
50-
" --log-level [0-3]\n"
51-
" --mem-stats\n"
52-
" --mem-stats-separate\n"
53-
" --show-opcodes\n"
54-
" --start-debug-server\n"
55-
"\n",
56-
name);
47+
printf ("Usage: %s [OPTION]... [FILE]...\n"
48+
"\n"
49+
"Options:\n"
50+
" --log-level [0-3]\n"
51+
" --mem-stats\n"
52+
" --mem-stats-separate\n"
53+
" --show-opcodes\n"
54+
" --start-debug-server\n"
55+
"\n",
56+
name);
5757
} /* print_help */
5858

5959
/**
@@ -449,7 +449,7 @@ int jerry_main (int argc, char *argv[])
449449

450450
if (files_counter == 0)
451451
{
452-
jerry_port_console ("No input files, running a hello world demo:\n");
452+
printf ("No input files, running a hello world demo:\n");
453453
char *source_p = "var a = 3.5; print('Hello world ' + (a + 1.5) + ' times from JerryScript')";
454454

455455
jerry_run_simple ((jerry_char_t *) source_p, strlen (source_p), flags);
@@ -522,19 +522,6 @@ void jerry_port_fatal (jerry_fatal_code_t code)
522522
exit (1);
523523
} /* jerry_port_fatal */
524524

525-
/**
526-
* Provide console message implementation for the engine.
527-
*/
528-
void
529-
jerry_port_console (const char *format, /**< format string */
530-
...) /**< parameters */
531-
{
532-
va_list args;
533-
va_start (args, format);
534-
vfprintf (stdout, format, args);
535-
va_end (args);
536-
} /* jerry_port_console */
537-
538525
/**
539526
* Provide log message implementation for the engine.
540527
*/

targets/tizenrt-artik05x/apps/jerryscript/jerry_port.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,6 @@ void jerry_port_fatal (jerry_fatal_code_t code)
2929
exit (code);
3030
} /* jerry_port_fatal */
3131

32-
/**
33-
* Provide console message implementation for the engine.
34-
*/
35-
void
36-
jerry_port_console (const char *format, /**< format string */
37-
...) /**< parameters */
38-
{
39-
va_list args;
40-
va_start (args, format);
41-
vprintf (format, args);
42-
va_end (args);
43-
} /* jerry_port_console */
44-
4532
/**
4633
* Provide log message implementation for the engine.
4734
*/
@@ -110,4 +97,3 @@ longjmp (jmp_buf buf, int value)
11097
(void)(value); // suppress unused param warning
11198
__builtin_longjmp (buf, 1);
11299
} /* longjmp */
113-

targets/zephyr/src/jerry-port.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,6 @@
1919

2020
#include "jerryscript-port.h"
2121

22-
/**
23-
* Provide console message implementation for the engine.
24-
*/
25-
void
26-
jerry_port_console (const char *format, /**< format string */
27-
...) /**< parameters */
28-
{
29-
va_list args;
30-
va_start (args, format);
31-
vfprintf (stdout, format, args);
32-
va_end (args);
33-
} /* jerry_port_console */
34-
3522

3623
/**
3724
* Provide log message implementation for the engine.

0 commit comments

Comments
 (0)