Improve the jerry port api documents. (#4977)
Notable changes: - Remove the comments in port impl, that's easily getting to in-consistence - Sync the jerryscript-port.h and 05.PORT-API.md - Fixes the invalid comment in port codes JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com
This commit is contained in:
@@ -30,35 +30,20 @@
|
||||
|
||||
static const char ESP_JS_TAG[] = "JS";
|
||||
|
||||
/**
|
||||
* Provide log message implementation for the engine.
|
||||
*/
|
||||
void
|
||||
jerry_port_log (const char *message_p) /**< message */
|
||||
jerry_port_log (const char *message_p)
|
||||
{
|
||||
ESP_LOGI (ESP_JS_TAG, "%s", message_p);
|
||||
} /* jerry_port_log */
|
||||
|
||||
/**
|
||||
* Implementation of jerry_port_fatal.
|
||||
* Calls 'abort' if exit code is non-zero, 'exit' otherwise.
|
||||
*/
|
||||
void
|
||||
jerry_port_fatal (jerry_fatal_code_t code) /**< cause of error */
|
||||
jerry_port_fatal (jerry_fatal_code_t code)
|
||||
{
|
||||
ESP_LOGE (ESP_JS_TAG, "Fatal error: %d", code);
|
||||
vTaskSuspend (NULL);
|
||||
abort ();
|
||||
} /* jerry_port_fatal */
|
||||
|
||||
/**
|
||||
* Default implementation of jerry_port_local_tza. Uses the 'tm_gmtoff' field
|
||||
* of 'struct tm' (a GNU extension) filled by 'localtime_r' if available on the
|
||||
* system, does nothing otherwise.
|
||||
*
|
||||
* @return offset between UTC and local time at the given unix timestamp, if
|
||||
* available. Otherwise, returns 0, assuming UTC time.
|
||||
*/
|
||||
int32_t
|
||||
jerry_port_local_tza (double unix_ms)
|
||||
{
|
||||
@@ -71,13 +56,6 @@ jerry_port_local_tza (double unix_ms)
|
||||
return -atoi (buf) * 3600 * 1000 / 100;
|
||||
} /* jerry_port_local_tza */
|
||||
|
||||
/**
|
||||
* Implementation of jerry_port_get_current_time.
|
||||
* Uses 'gettimeofday' if available on the system, does nothing otherwise.
|
||||
*
|
||||
* @return milliseconds since Unix epoch if 'gettimeofday' is available
|
||||
* 0 - otherwise.
|
||||
*/
|
||||
double
|
||||
jerry_port_current_time (void)
|
||||
{
|
||||
|
||||
@@ -20,20 +20,14 @@
|
||||
|
||||
#include "mbed.h"
|
||||
|
||||
/**
|
||||
* Aborts the program.
|
||||
*/
|
||||
void
|
||||
jerry_port_fatal (jerry_fatal_code_t code)
|
||||
{
|
||||
exit ((int) code);
|
||||
} /* jerry_port_fatal */
|
||||
|
||||
/**
|
||||
* Provide log message implementation for the engine.
|
||||
*/
|
||||
void
|
||||
jerry_port_log (const char *message_p) /**< message */
|
||||
jerry_port_log (const char *message_p)
|
||||
{
|
||||
while (*message_p != '\0')
|
||||
{
|
||||
@@ -47,11 +41,6 @@ jerry_port_log (const char *message_p) /**< message */
|
||||
}
|
||||
} /* jerry_port_log */
|
||||
|
||||
/**
|
||||
* Dummy function to get the time zone adjustment.
|
||||
*
|
||||
* @return 0
|
||||
*/
|
||||
int32_t
|
||||
jerry_port_local_tza (double unix_ms)
|
||||
{
|
||||
@@ -60,11 +49,6 @@ jerry_port_local_tza (double unix_ms)
|
||||
return 0;
|
||||
} /* jerry_port_local_tza */
|
||||
|
||||
/**
|
||||
* Implementation of jerry_port_current_time.
|
||||
*
|
||||
* @return current timer's counter value in milliseconds
|
||||
*/
|
||||
double
|
||||
jerry_port_current_time (void)
|
||||
{
|
||||
|
||||
@@ -19,23 +19,12 @@
|
||||
|
||||
#include "jerryscript-port.h"
|
||||
|
||||
/**
|
||||
* Default implementation of jerry_port_log. Prints log messages to stderr.
|
||||
*/
|
||||
void
|
||||
jerry_port_log (const char *message_p) /**< message */
|
||||
jerry_port_log (const char *message_p)
|
||||
{
|
||||
(void) message_p;
|
||||
} /* jerry_port_log */
|
||||
|
||||
/**
|
||||
* Read a line from standard input as a zero-terminated string.
|
||||
*
|
||||
* @param out_size_p: length of the string
|
||||
*
|
||||
* @return pointer to the buffer storing the string,
|
||||
* or NULL if end of input
|
||||
*/
|
||||
jerry_char_t *
|
||||
jerry_port_line_read (jerry_size_t *out_size_p)
|
||||
{
|
||||
@@ -43,20 +32,12 @@ jerry_port_line_read (jerry_size_t *out_size_p)
|
||||
return NULL;
|
||||
} /* jerry_port_line_read */
|
||||
|
||||
/**
|
||||
* Aborts the program.
|
||||
*/
|
||||
void
|
||||
jerry_port_fatal (jerry_fatal_code_t code)
|
||||
{
|
||||
exit ((int) code);
|
||||
} /* jerry_port_fatal */
|
||||
|
||||
/**
|
||||
* Dummy function to get the time zone adjustment.
|
||||
*
|
||||
* @return 0
|
||||
*/
|
||||
int32_t
|
||||
jerry_port_local_tza (double unix_ms)
|
||||
{
|
||||
@@ -66,11 +47,6 @@ jerry_port_local_tza (double unix_ms)
|
||||
return 0;
|
||||
} /* jerry_port_local_tza */
|
||||
|
||||
/**
|
||||
* Dummy function to get the current time.
|
||||
*
|
||||
* @return 0
|
||||
*/
|
||||
double
|
||||
jerry_port_current_time (void)
|
||||
{
|
||||
|
||||
@@ -18,11 +18,6 @@
|
||||
|
||||
#include "jerryscript-port.h"
|
||||
|
||||
/**
|
||||
* Dummy function to get the time zone adjustment.
|
||||
*
|
||||
* @return 0
|
||||
*/
|
||||
int32_t
|
||||
jerry_port_local_tza (double unix_ms)
|
||||
{
|
||||
@@ -32,11 +27,6 @@ jerry_port_local_tza (double unix_ms)
|
||||
return 0;
|
||||
} /* jerry_port_local_tza */
|
||||
|
||||
/**
|
||||
* Dummy function to get the current time.
|
||||
*
|
||||
* @return 0
|
||||
*/
|
||||
double
|
||||
jerry_port_current_time (void)
|
||||
{
|
||||
|
||||
@@ -22,20 +22,12 @@
|
||||
|
||||
#include "getline-zephyr.h"
|
||||
|
||||
/**
|
||||
* Aborts the program.
|
||||
*/
|
||||
void
|
||||
jerry_port_fatal (jerry_fatal_code_t code)
|
||||
{
|
||||
exit ((int) code);
|
||||
} /* jerry_port_fatal */
|
||||
|
||||
/**
|
||||
* Dummy function to get the time zone adjustment.
|
||||
*
|
||||
* @return 0
|
||||
*/
|
||||
int32_t
|
||||
jerry_port_local_tza (double unix_ms)
|
||||
{
|
||||
@@ -45,11 +37,6 @@ jerry_port_local_tza (double unix_ms)
|
||||
return 0;
|
||||
} /* jerry_port_local_tza */
|
||||
|
||||
/**
|
||||
* Dummy function to get the current time.
|
||||
*
|
||||
* @return 0
|
||||
*/
|
||||
double
|
||||
jerry_port_current_time (void)
|
||||
{
|
||||
@@ -57,18 +44,12 @@ jerry_port_current_time (void)
|
||||
return (double) ms;
|
||||
} /* jerry_port_current_time */
|
||||
|
||||
/**
|
||||
* Provide implementation of jerry_port_sleep.
|
||||
*/
|
||||
void
|
||||
jerry_port_sleep (uint32_t sleep_time) /**< milliseconds to sleep */
|
||||
jerry_port_sleep (uint32_t sleep_time)
|
||||
{
|
||||
k_usleep ((useconds_t) sleep_time * 1000);
|
||||
} /* jerry_port_sleep */
|
||||
|
||||
/**
|
||||
* Read line from stdin
|
||||
*/
|
||||
jerry_char_t *
|
||||
jerry_port_line_read (jerry_size_t *out_size_p)
|
||||
{
|
||||
@@ -78,9 +59,6 @@ jerry_port_line_read (jerry_size_t *out_size_p)
|
||||
return (jerry_char_t *) line_p;
|
||||
} /* jerry_port_line_read */
|
||||
|
||||
/**
|
||||
* Free line, no-op.
|
||||
*/
|
||||
void
|
||||
jerry_port_line_free (jerry_char_t *line_p)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user