#include "src/utils/ostreams.h"
#include <cinttypes>
#include "src/base/lazy-instance.h"
#include "src/objects/string.h"
#if V8_OS_WIN
#include <windows.h>
#if _MSC_VER < 1900
#define snprintf …
#endif
#endif
#if defined(ANDROID) && !defined(V8_ANDROID_LOG_STDOUT)
#define LOG_TAG …
#include <android/log.h>
#endif
namespace v8 {
namespace internal {
DbgStreamBuf::DbgStreamBuf() { … }
DbgStreamBuf::~DbgStreamBuf() { … }
int DbgStreamBuf::overflow(int c) { … }
int DbgStreamBuf::sync() { … }
DbgStdoutStream::DbgStdoutStream() : … { … }
OFStreamBase::OFStreamBase(FILE* f) : … { … }
int OFStreamBase::sync() { … }
OFStreamBase::int_type OFStreamBase::overflow(int_type c) { … }
std::streamsize OFStreamBase::xsputn(const char* s, std::streamsize n) { … }
OFStream::OFStream(FILE* f) : … { … }
#if defined(ANDROID) && !defined(V8_ANDROID_LOG_STDOUT)
AndroidLogStream::~AndroidLogStream() {
if (!line_buffer_.empty()) {
__android_log_write(ANDROID_LOG_INFO, LOG_TAG, line_buffer_.c_str());
}
}
std::streamsize AndroidLogStream::xsputn(const char* s, std::streamsize n) {
const char* const e = s + n;
while (s < e) {
const char* newline = reinterpret_cast<const char*>(memchr(s, '\n', e - s));
size_t line_chars = (newline ? newline : e) - s;
line_buffer_.append(s, line_chars);
if (!newline) break;
__android_log_write(ANDROID_LOG_INFO, LOG_TAG, line_buffer_.c_str());
line_buffer_.clear();
s = newline + 1;
}
return n;
}
#endif
DEFINE_LAZY_LEAKY_OBJECT_GETTER(…)
namespace {
bool IsPrint(uint16_t c) { … }
bool IsSpace(uint16_t c) { … }
bool IsOK(uint16_t c) { … }
std::ostream& PrintUC16(std::ostream& os, uint16_t c, bool (*pred)(uint16_t)) { … }
std::ostream& PrintUC16ForJSON(std::ostream& os, uint16_t c,
bool (*pred)(uint16_t)) { … }
std::ostream& PrintUC32(std::ostream& os, int32_t c, bool (*pred)(uint16_t)) { … }
}
std::ostream& operator<<(std::ostream& os, const AsReversiblyEscapedUC16& c) { … }
std::ostream& operator<<(std::ostream& os, const AsEscapedUC16ForJSON& c) { … }
std::ostream& operator<<(std::ostream& os, const AsUC16& c) { … }
std::ostream& operator<<(std::ostream& os, const AsUC32& c) { … }
std::ostream& operator<<(std::ostream& os, const AsHex& hex) { … }
std::ostream& operator<<(std::ostream& os, const AsHexBytes& hex) { … }
}
}
#undef snprintf
#undef LOG_TAG