From 1865466edfe091cae376735359b665479021dca2 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Sat, 17 Dec 2011 11:00:58 -0800 Subject: [PATCH] support for std::endl and cout << ints --- src/library.js | 10 ++++++++++ system/include/libcxx/ostream | 2 ++ tests/runner.py | 4 ++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/library.js b/src/library.js index ba9ef0f8e..1747155f7 100644 --- a/src/library.js +++ b/src/library.js @@ -4320,6 +4320,16 @@ LibraryManager.library = { _fputs(str, _stdout); // XXX stderr etc. }, + _ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEi__deps: ['fputs', '$libcxx'], + _ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEi: function(stream, num) { + _fputs(allocate(intArrayFromString(num.toString()), 'i8', ALLOC_STACK), _stdout); + }, + + _ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEPFRS3_S4_E__deps: ['fputc', '$libcxx'], + _ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEPFRS3_S4_E: function(stream, x) { + _fputc('\n'.charCodeAt(0), _stdout); + }, + // glibc _ZNSt8ios_base4InitC1Ev: function() { diff --git a/system/include/libcxx/ostream b/system/include/libcxx/ostream index dd28e6865..f7cbb8a2d 100644 --- a/system/include/libcxx/ostream +++ b/system/include/libcxx/ostream @@ -1181,6 +1181,7 @@ basic_ostream<_CharT, _Traits>::seekp(off_type __off, ios_base::seekdir __dir) return *this; } +*/ template inline _LIBCPP_INLINE_VISIBILITY basic_ostream<_CharT, _Traits>& @@ -1209,6 +1210,7 @@ flush(basic_ostream<_CharT, _Traits>& __os) return __os; } +/* #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template diff --git a/tests/runner.py b/tests/runner.py index 41064d43f..e7793685b 100644 --- a/tests/runner.py +++ b/tests/runner.py @@ -3482,12 +3482,12 @@ at function.:blag int main() { - std::cout << "hello world"; + std::cout << "hello world" << std::endl << 77 << "." << std::endl; return 0; } ''' - self.do_run(src, 'hello world') + self.do_run(src, 'hello world\n77.\n') def test_stdvec(self): src = '''