From 48759438b747c24b536cd099d65ab0c9ea720a38 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 17 Aug 2023 09:53:01 -0400 Subject: DRTVWR-588: Remove Boost Phoenix, Bind and Assign from some tests. llsdserialize_test used Boost.Foreach, Boost.Function and Boost.Bind. llleap_test used Boost.Assign. Both used Boost.Phoenix. Replace Boost.Foreach with range 'for'. Replace Boost.Function with std::function. Replace Boost.Assign with initializer lists. Replace Boost.Bind and Boost.Phoenix with lambdas. --- indra/llcommon/tests/llsdserialize_test.cpp | 39 ++++++++++------------------- 1 file changed, 13 insertions(+), 26 deletions(-) (limited to 'indra/llcommon/tests/llsdserialize_test.cpp') diff --git a/indra/llcommon/tests/llsdserialize_test.cpp b/indra/llcommon/tests/llsdserialize_test.cpp index 5dbcf4c9b8..f46682e2d7 100644 --- a/indra/llcommon/tests/llsdserialize_test.cpp +++ b/indra/llcommon/tests/llsdserialize_test.cpp @@ -44,18 +44,10 @@ typedef U32 uint32_t; #include "llstring.h" #endif -#include "boost/range.hpp" -#include "boost/foreach.hpp" -#include "boost/function.hpp" -#include "boost/bind.hpp" -#include "boost/phoenix/bind/bind_function.hpp" -#include "boost/phoenix/core/argument.hpp" -using namespace boost::phoenix; - -#include "../llsd.h" -#include "../llsdserialize.h" +#include "llsd.h" +#include "llsdserialize.h" #include "llsdutil.h" -#include "../llformat.h" +#include "llformat.h" #include "../test/lltut.h" #include "../test/namedtempfile.h" @@ -1697,13 +1689,6 @@ namespace tut struct TestPythonCompatible { TestPythonCompatible(): - // Note the peculiar insertion of __FILE__ into this string. Since - // this script is being written into a platform-dependent temp - // directory, we can't locate indra/lib/python relative to - // Python's __file__. Use __FILE__ instead, navigating relative - // to this C++ source file. Use Python raw-string syntax so - // Windows pathname backslashes won't mislead Python's string - // scanner. import_llsd("import os.path\n" "import sys\n" "from llbase import llsd\n") @@ -1801,7 +1786,7 @@ namespace tut // helper for test<3> static void writeLLSDArray(std::ostream& out, const LLSD& array) { - BOOST_FOREACH(LLSD item, llsd::inArray(array)) + for (LLSD item: llsd::inArray(array)) { LLSDSerialize::toNotation(item, out); // It's important to separate with newlines because Python's llsd @@ -1841,21 +1826,22 @@ namespace tut // Create an llsdXXXXXX file containing 'data' serialized to // notation. NamedTempFile file("llsd", - // NamedTempFile's boost::function constructor + // NamedTempFile's std::function constructor // takes a callable. To this callable it passes the // std::ostream with which it's writing the // NamedTempFile. - boost::bind(writeLLSDArray, _1, cdata)); + [cdata](std::ostream& out){ writeLLSDArray(out, cdata); }); python("read C++ notation", - placeholders::arg1 << + [this, pydata, &file](std::ostream& out) { + out << import_llsd << "def parse_each(iterable):\n" " for item in iterable:\n" " yield llsd.parse(item)\n" << pydata << // Don't forget raw-string syntax for Windows pathnames. - "verify(parse_each(open(r'" << file.getName() << "', 'rb')))\n"); + "verify(parse_each(open(r'" << file.getName() << "', 'rb')))\n"; }); } template<> template<> @@ -1869,7 +1855,8 @@ namespace tut NamedTempFile file("llsd", ""); python("write Python notation", - placeholders::arg1 << + [this, &file](std::ostream& out) { + out << import_llsd << "DATA = [\n" " 17,\n" @@ -1881,9 +1868,9 @@ namespace tut "]\n" // Don't forget raw-string syntax for Windows pathnames. // N.B. Using 'print' implicitly adds newlines. - "with open(r'" << file.getName() << "', 'w') as f:\n" + "with open(r'" << file.getName() << "', 'wb') as f:\n" " for item in DATA:\n" - " print(llsd.format_notation(item).decode(), file=f)\n"); + " print(llsd.format_notation(item), file=f)\n"; }); std::ifstream inf(file.getName().c_str()); LLSD item; -- cgit v1.2.3 From 931a2fd63de2de417adbe3e02d55af7a459bca36 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 17 Aug 2023 11:23:02 -0400 Subject: DRTVWR-588: print(file=) to binary file still requires str argument. Use f.writelines((bytes, b'\n')) instead. --- indra/llcommon/tests/llsdserialize_test.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'indra/llcommon/tests/llsdserialize_test.cpp') diff --git a/indra/llcommon/tests/llsdserialize_test.cpp b/indra/llcommon/tests/llsdserialize_test.cpp index f46682e2d7..efd7dc9852 100644 --- a/indra/llcommon/tests/llsdserialize_test.cpp +++ b/indra/llcommon/tests/llsdserialize_test.cpp @@ -1867,10 +1867,9 @@ namespace tut "lines.''',\n" "]\n" // Don't forget raw-string syntax for Windows pathnames. - // N.B. Using 'print' implicitly adds newlines. "with open(r'" << file.getName() << "', 'wb') as f:\n" " for item in DATA:\n" - " print(llsd.format_notation(item), file=f)\n"; }); + " f.writelines((llsd.format_notation(item), b'\n'))\n"; }); std::ifstream inf(file.getName().c_str()); LLSD item; -- cgit v1.2.3 From b5fe9c476943807aa7526f67dd648b5ad250824b Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 17 Aug 2023 11:45:34 -0400 Subject: DRTVWR-588: To write b'\n' in Python source, use "b'\\n'" --- indra/llcommon/tests/llsdserialize_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/tests/llsdserialize_test.cpp') diff --git a/indra/llcommon/tests/llsdserialize_test.cpp b/indra/llcommon/tests/llsdserialize_test.cpp index efd7dc9852..bb469f0686 100644 --- a/indra/llcommon/tests/llsdserialize_test.cpp +++ b/indra/llcommon/tests/llsdserialize_test.cpp @@ -1869,7 +1869,7 @@ namespace tut // Don't forget raw-string syntax for Windows pathnames. "with open(r'" << file.getName() << "', 'wb') as f:\n" " for item in DATA:\n" - " f.writelines((llsd.format_notation(item), b'\n'))\n"; }); + " f.writelines((llsd.format_notation(item), b'\\n'))\n"; }); std::ifstream inf(file.getName().c_str()); LLSD item; -- cgit v1.2.3 From 5ed44adec58ba2ecb8dd073122bd8882fed30638 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Tue, 12 Sep 2023 09:29:26 -0400 Subject: DRTVWR-588: Fix a couple merge glitches in llsdserialize_test.cpp. --- indra/llcommon/tests/llsdserialize_test.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/llcommon/tests/llsdserialize_test.cpp') diff --git a/indra/llcommon/tests/llsdserialize_test.cpp b/indra/llcommon/tests/llsdserialize_test.cpp index c87deb8ffe..341b0d5609 100644 --- a/indra/llcommon/tests/llsdserialize_test.cpp +++ b/indra/llcommon/tests/llsdserialize_test.cpp @@ -1948,7 +1948,7 @@ namespace tut { writeLLSDArray(serialize, out, cdata); }); python("read C++ " + desc, - [this, pydata, &file](std::ostream& out) { + [pydata, &file](std::ostream& out) { out << import_llsd << "from functools import partial\n" @@ -2062,7 +2062,7 @@ namespace tut NamedTempFile file("llsd", ""); python("Python " + pyformatter, - [this, &file](std::ostream& out) { + [pyformatter, &file](std::ostream& out) { out << import_llsd << "import struct\n" @@ -2081,7 +2081,7 @@ namespace tut " for item in DATA:\n" " serialized = llsd." << pyformatter << "(item)\n" " f.write(lenformat.pack(len(serialized)))\n" - " f.write(serialized)\n"); + " f.write(serialized)\n";}); std::ifstream inf(file.getName().c_str()); LLSD item; -- cgit v1.2.3