chromium/v8/src/utils/ostreams.cc

// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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 there is anything left in the line buffer, print it now, even though it
  // was not terminated by a newline.
  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);
    // Without terminating newline, keep the characters in the buffer for the
    // next invocation.
    if (!newline) break;
    // Otherwise, write out the first line, then continue.
    __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 {

// Locale-independent predicates.
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)) {}

}  // namespace

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) {}

}  // namespace internal
}  // namespace v8

#undef snprintf
#undef LOG_TAG