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:
@@ -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 */
|
||||||
@@ -20,6 +20,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "jerry-api.h"
|
#include "jerry-api.h"
|
||||||
|
#include "jerry-port.h"
|
||||||
|
|
||||||
/** \addtogroup jerry Jerry engine interface
|
/** \addtogroup jerry Jerry engine interface
|
||||||
* @{
|
* @{
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ extern void __noreturn jerry_unimplemented (const char *, const char *, const ch
|
|||||||
{ \
|
{ \
|
||||||
if (lvl <= jerry_debug_level && jerry_log_file) \
|
if (lvl <= jerry_debug_level && jerry_log_file) \
|
||||||
{ \
|
{ \
|
||||||
fprintf (jerry_log_file, __VA_ARGS__); \
|
jerry_port_logmsg (jerry_log_file, __VA_ARGS__); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
while (0)
|
while (0)
|
||||||
@@ -120,7 +120,7 @@ extern void __noreturn jerry_unimplemented (const char *, const char *, const ch
|
|||||||
#define JERRY_DDDLOG(...) JERRY_DLOG (__VA_ARGS__)
|
#define JERRY_DDDLOG(...) JERRY_DLOG (__VA_ARGS__)
|
||||||
#endif /* !JERRY_ENABLE_LOG */
|
#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__)
|
#define JERRY_WARNING_MSG(...) JERRY_ERROR_MSG (__VA_ARGS__)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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)
|
if (ecma_char <= LIT_UTF8_1_BYTE_CODE_POINT_MAX)
|
||||||
{
|
{
|
||||||
putchar (ecma_char);
|
jerry_port_putchar (ecma_char);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FIXME ("Support unicode characters printing.");
|
FIXME ("Support unicode characters printing.");
|
||||||
putchar ('_');
|
jerry_port_putchar ('_');
|
||||||
}
|
}
|
||||||
} /* lit_put_ecma_char */
|
} /* lit_put_ecma_char */
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
lexer_dump_line (line); \
|
lexer_dump_line (line); \
|
||||||
printf ("\n"); \
|
printf ("\n"); \
|
||||||
for (size_t i = 0; i < column; i++) { \
|
for (size_t i = 0; i < column; i++) { \
|
||||||
putchar (' '); \
|
jerry_port_putchar (' '); \
|
||||||
} \
|
} \
|
||||||
printf ("^\n"); \
|
printf ("^\n"); \
|
||||||
printf ("%s: Ln %lu, Col %lu: ", TYPE, (unsigned long) (line + 1), (unsigned long) (column + 1)); \
|
printf ("%s: Ln %lu, Col %lu: ", TYPE, (unsigned long) (line + 1), (unsigned long) (column + 1)); \
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ pp_printf (const char *format, vm_instr_t instr, lit_cpointer_t lit_ids[], vm_in
|
|||||||
{
|
{
|
||||||
if (*format != '%')
|
if (*format != '%')
|
||||||
{
|
{
|
||||||
putchar (*format);
|
jerry_port_putchar (*format);
|
||||||
format++;
|
format++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -144,7 +144,7 @@ pp_printf (const char *format, vm_instr_t instr, lit_cpointer_t lit_ids[], vm_in
|
|||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
putchar ('%');
|
jerry_port_putchar ('%');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "jerry.h"
|
#include "jerry.h"
|
||||||
#include "jrt/jrt.h"
|
#include "jrt/jrt.h"
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maximum command line arguments number
|
* Maximum command line arguments number
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "jerry.h"
|
#include "jerry.h"
|
||||||
#include "jrt/jrt.h"
|
#include "jrt/jrt.h"
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maximum command line arguments number
|
* Maximum command line arguments number
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "jerry.h"
|
#include "jerry.h"
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standalone Jerry exit codes
|
* Standalone Jerry exit codes
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
/* Copyright 2014-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 MAIN_H
|
||||||
|
#define MAIN_H
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provide log message to filestream implementation for the engine.
|
||||||
|
*/
|
||||||
|
int jerry_port_logmsg (FILE* stream, const char* format, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
int count;
|
||||||
|
va_start (args, format);
|
||||||
|
count = vfprintf (stream, format, args);
|
||||||
|
va_end (args);
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provide error message to console implementation for the engine.
|
||||||
|
*/
|
||||||
|
int jerry_port_errormsg (const char* format, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
int count;
|
||||||
|
va_start (args, format);
|
||||||
|
count = vfprintf (stderr, format, args);
|
||||||
|
va_end (args);
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provide output character to console implementation for the engine.
|
||||||
|
*/
|
||||||
|
int jerry_port_putchar (int c)
|
||||||
|
{
|
||||||
|
return putchar (c);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* !MAIN_H */
|
||||||
@@ -737,3 +737,38 @@ main (void)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provide log message to filestream implementation for the engine.
|
||||||
|
*/
|
||||||
|
int jerry_port_logmsg (FILE* stream, const char* format, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
int count;
|
||||||
|
va_start (args, format);
|
||||||
|
count = vfprintf (stream, format, args);
|
||||||
|
va_end (args);
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provide error message to console implementation for the engine.
|
||||||
|
*/
|
||||||
|
int jerry_port_errormsg (const char* format, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
int count;
|
||||||
|
va_start (args, format);
|
||||||
|
count = vfprintf (stderr, format, args);
|
||||||
|
va_end (args);
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provide output character to console implementation for the engine.
|
||||||
|
*/
|
||||||
|
int jerry_port_putchar (int c)
|
||||||
|
{
|
||||||
|
return putchar (c);
|
||||||
|
}
|
||||||
|
|||||||
@@ -147,3 +147,11 @@ main (int __attr_unused___ argc,
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} /* main */
|
} /* main */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provide output character to console implementation for the engine.
|
||||||
|
*/
|
||||||
|
int jerry_port_putchar (int c)
|
||||||
|
{
|
||||||
|
return putchar (c);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user