Skip to content

Commit dddc46e

Browse files
committed
Fix jerry-port routines
1 parent c56492e commit dddc46e

2 files changed

Lines changed: 38 additions & 14 deletions

File tree

src/include/Jerryscript/Except.h

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

1313
#include "Types.h"
1414
#include <csetjmp>
15-
#include <jerryscript-port.h>
15+
#include <jerry-core/include/jerryscript-port.h>
1616

1717
namespace Jerryscript
1818
{

src/jerry-port.cpp

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,18 @@ void jerry_port_watchdog_set_period(uint32_t milliseconds)
3030
/**
3131
* Provide log message implementation for the engine.
3232
*/
33-
void jerry_port_log(jerry_log_level_t level, /**< log level */
34-
const char* format, /**< format string */
35-
...) /**< parameters */
33+
void jerry_port_log(const char* msg)
3634
{
37-
(void)level; /* ignore log level */
38-
39-
va_list args;
40-
va_start(args, format);
41-
m_vprintf(format, args);
42-
va_end(args);
35+
m_puts(msg);
4336
}
4437

4538
/**
46-
* Default implementation of jerry_port_get_current_time.
39+
* Default implementation of jerry_port_current_time.
4740
*/
48-
double jerry_port_get_current_time()
41+
double jerry_port_current_time()
4942
{
5043
return RTC.getRtcNanoseconds() / 1e9;
51-
} /* jerry_port_get_current_time */
44+
}
5245

5346
/**
5447
* Default implementation of jerry_port_get_local_time_zone_adjustment. Uses the 'tm_gmtoff' field
@@ -61,9 +54,24 @@ double jerry_port_get_current_time()
6154
double jerry_port_get_local_time_zone_adjustment(double unix_ms, /**< ms since unix epoch */
6255
bool is_utc) /**< is the time above in UTC? */
6356
{
57+
// TODO
6458
return 0.0;
6559
}
6660

61+
/**
62+
* Get the current system time in UTC.
63+
*
64+
* This port function is called by jerry-core when JERRY_BUILTIN_DATE is enabled.
65+
* It can also be used in the implementing application to initialize the random number generator.
66+
*
67+
* @return milliseconds since Unix epoch
68+
*/
69+
int32_t jerry_port_local_tza(double unix_ms)
70+
{
71+
// TODO
72+
return 0;
73+
}
74+
6775
/**
6876
* Default implementation of jerry_port_fatal.
6977
*/
@@ -88,12 +96,28 @@ jerry_value_t jerry_port_module_resolve(const jerry_value_t specifier, /**< modu
8896
return jerry_error(JERRY_ERROR_REFERENCE, {});
8997
}
9098

99+
size_t jerry_port_context_alloc(size_t context_size)
100+
{
101+
return context_size;
102+
}
103+
104+
void jerry_port_context_free(void)
105+
{
106+
}
107+
91108
/**
92109
* Get the current context.
93110
*
94111
* @return the pointer to the current context
95112
*/
96-
jerry_context_t* jerry_port_get_current_context(void)
113+
jerry_context_t* jerry_port_context_get(void)
97114
{
98115
return Jerryscript::Context::getCurrent();
99116
}
117+
118+
/**
119+
* Init the program
120+
*/
121+
void jerry_port_init(void)
122+
{
123+
}

0 commit comments

Comments
 (0)