Move log message output(fprintf, puthcar) to target code

Related issue #752

JerryScript-DCO-1.0-Signed-off-by: SaeHie Park saehie.park@samsung.com
This commit is contained in:
SaeHie Park
2015-11-30 18:42:10 +09:00
parent 9cb711ad80
commit 8fbde244e9
12 changed files with 155 additions and 7 deletions
+47
View File
@@ -0,0 +1,47 @@
/* Copyright 2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef JERRY_PORT_H
#define JERRY_PORT_H
#include <stdio.h>
#ifdef __cplusplus
# define EXTERN_C "C"
#else /* !__cplusplus */
# define EXTERN_C
#endif /* !__cplusplus */
/** \addtogroup jerry Jerry engine port
* @{
*/
/**
* Target port functions for console output
*/
extern EXTERN_C
int jerry_port_logmsg (FILE* stream, const char* format, ...);
extern EXTERN_C
int jerry_port_errormsg (const char* format, ...);
extern EXTERN_C
int jerry_port_putchar (int c);
/**
* @}
*/
#endif /* !JERRY_API_H */
+1
View File
@@ -20,6 +20,7 @@
#include <stdint.h>
#include "jerry-api.h"
#include "jerry-port.h"
/** \addtogroup jerry Jerry engine interface
* @{
+2 -2
View File
@@ -99,7 +99,7 @@ extern void __noreturn jerry_unimplemented (const char *, const char *, const ch
{ \
if (lvl <= jerry_debug_level && jerry_log_file) \
{ \
fprintf (jerry_log_file, __VA_ARGS__); \
jerry_port_logmsg (jerry_log_file, __VA_ARGS__); \
} \
} \
while (0)
@@ -120,7 +120,7 @@ extern void __noreturn jerry_unimplemented (const char *, const char *, const ch
#define JERRY_DDDLOG(...) JERRY_DLOG (__VA_ARGS__)
#endif /* !JERRY_ENABLE_LOG */
#define JERRY_ERROR_MSG(...) fprintf (stderr, __VA_ARGS__)
#define JERRY_ERROR_MSG(...) jerry_port_errormsg (__VA_ARGS__)
#define JERRY_WARNING_MSG(...) JERRY_ERROR_MSG (__VA_ARGS__)
/**
+2 -2
View File
@@ -1005,11 +1005,11 @@ lit_put_ecma_char (ecma_char_t ecma_char) /**< code unit */
{
if (ecma_char <= LIT_UTF8_1_BYTE_CODE_POINT_MAX)
{
putchar (ecma_char);
jerry_port_putchar (ecma_char);
}
else
{
FIXME ("Support unicode characters printing.");
putchar ('_');
jerry_port_putchar ('_');
}
} /* lit_put_ecma_char */
+1 -1
View File
@@ -27,7 +27,7 @@
lexer_dump_line (line); \
printf ("\n"); \
for (size_t i = 0; i < column; i++) { \
putchar (' '); \
jerry_port_putchar (' '); \
} \
printf ("^\n"); \
printf ("%s: Ln %lu, Col %lu: ", TYPE, (unsigned long) (line + 1), (unsigned long) (column + 1)); \
+2 -2
View File
@@ -123,7 +123,7 @@ pp_printf (const char *format, vm_instr_t instr, lit_cpointer_t lit_ids[], vm_in
{
if (*format != '%')
{
putchar (*format);
jerry_port_putchar (*format);
format++;
continue;
}
@@ -144,7 +144,7 @@ pp_printf (const char *format, vm_instr_t instr, lit_cpointer_t lit_ids[], vm_in
}
default:
{
putchar ('%');
jerry_port_putchar ('%');
continue;
}
}