summaryrefslogtreecommitdiff
path: root/deps/v8/src/ostreams.h
diff options
context:
space:
mode:
authorMichaël Zasso <targos@protonmail.com>2018-09-07 17:07:13 +0200
committerMichaël Zasso <targos@protonmail.com>2018-09-07 20:59:13 +0200
commit586db2414a338e1bf6eaf6e672a3adc7ce309f6a (patch)
tree139fa972aef648481ddee22a3a85b99707d28df5 /deps/v8/src/ostreams.h
parent12ed7c94e5160aa6d38e3d2cb2a73dae0a6f9342 (diff)
downloadnode-new-586db2414a338e1bf6eaf6e672a3adc7ce309f6a.tar.gz
deps: update V8 to 6.9.427.22
PR-URL: https://github.com/nodejs/node/pull/21983 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'deps/v8/src/ostreams.h')
-rw-r--r--deps/v8/src/ostreams.h61
1 files changed, 56 insertions, 5 deletions
diff --git a/deps/v8/src/ostreams.h b/deps/v8/src/ostreams.h
index f2f961e379..c6b64a1cd9 100644
--- a/deps/v8/src/ostreams.h
+++ b/deps/v8/src/ostreams.h
@@ -18,7 +18,6 @@
namespace v8 {
namespace internal {
-
class OFStreamBase : public std::streambuf {
public:
explicit OFStreamBase(FILE* f);
@@ -27,12 +26,11 @@ class OFStreamBase : public std::streambuf {
protected:
FILE* const f_;
- virtual int sync();
- virtual int_type overflow(int_type c);
- virtual std::streamsize xsputn(const char* s, std::streamsize n);
+ int sync() override;
+ int_type overflow(int_type c) override;
+ std::streamsize xsputn(const char* s, std::streamsize n) override;
};
-
// An output stream writing to a file.
class V8_EXPORT_PRIVATE OFStream : public std::ostream {
public:
@@ -43,6 +41,31 @@ class V8_EXPORT_PRIVATE OFStream : public std::ostream {
OFStreamBase buf_;
};
+#if defined(ANDROID) && !defined(V8_ANDROID_LOG_STDOUT)
+class V8_EXPORT_PRIVATE AndroidLogStream : public std::streambuf {
+ public:
+ virtual ~AndroidLogStream();
+
+ protected:
+ std::streamsize xsputn(const char* s, std::streamsize n) override;
+
+ private:
+ std::string line_buffer_;
+};
+
+class StdoutStream : public std::ostream {
+ public:
+ StdoutStream() : std::ostream(&stream_) {}
+
+ private:
+ AndroidLogStream stream_;
+};
+#else
+class StdoutStream : public OFStream {
+ public:
+ StdoutStream() : OFStream(stdout) {}
+};
+#endif
// Wrappers to disambiguate uint16_t and uc16.
struct AsUC16 {
@@ -92,6 +115,23 @@ struct AsHexBytes {
ByteOrder byte_order;
};
+template <typename T>
+struct PrintIteratorRange {
+ T start;
+ T end;
+ PrintIteratorRange(T start, T end) : start(start), end(end) {}
+};
+
+// Print any collection which can be iterated via std::begin and std::end.
+// {Iterator} is the common type of {std::begin} and {std::end} called on a
+// {const T&}. This function is only instantiable if that type exists.
+template <typename T, typename Iterator = typename std::common_type<
+ decltype(std::begin(std::declval<const T&>())),
+ decltype(std::end(std::declval<const T&>()))>::type>
+PrintIteratorRange<Iterator> PrintCollection(const T& collection) {
+ return {std::begin(collection), std::end(collection)};
+}
+
// Writes the given character to the output escaping everything outside of
// printable/space ASCII range. Additionally escapes '\' making escaping
// reversible.
@@ -113,6 +153,17 @@ V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, const AsHex& v);
V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
const AsHexBytes& v);
+template <typename T>
+std::ostream& operator<<(std::ostream& os, const PrintIteratorRange<T>& range) {
+ const char* comma = "";
+ os << "[";
+ for (T it = range.start; it != range.end; ++it, comma = ", ") {
+ os << comma << *it;
+ }
+ os << "]";
+ return os;
+}
+
} // namespace internal
} // namespace v8