Skip to content

Commit cb4b2d6

Browse files
committed
update deps:
* move to official boost cmake * update googletest * update non-std repos * update json
1 parent b7ced2e commit cb4b2d6

24 files changed

+171
-152
lines changed

.gitmodules

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
[submodule "thirdparty/gtest"]
2-
path = thirdparty/gtest
3-
url = https://github.com/google/googletest.git
2+
path = thirdparty/gtest
3+
url = https://github.com/google/googletest.git
44
[submodule "thirdparty/boost"]
5-
path = thirdparty/boost
6-
url = https://github.com/Manu343726/boost-cmake.git
7-
branch = master
5+
path = thirdparty/boost
6+
url = https://github.com/boostorg/boost.git
87
[submodule "thirdparty/nonstd/expected-lite"]
98
path = thirdparty/nonstd/expected-lite
109
url = https://github.com/martinmoene/expected-lite.git

include/jinja2cpp/binding/nlohmann_json.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ struct Reflector<nlohmann::json>
9595
Value result;
9696
switch (val.type())
9797
{
98+
case nlohmann::detail::value_t::binary:
99+
break;
98100
case nlohmann::detail::value_t::null:
99101
break;
100102
case nlohmann::detail::value_t::object:
@@ -127,6 +129,8 @@ struct Reflector<nlohmann::json>
127129
Value result;
128130
switch (val->type())
129131
{
132+
case nlohmann::detail::value_t::binary:
133+
break;
130134
case nlohmann::detail::value_t::null:
131135
break;
132136
case nlohmann::detail::value_t::object:
@@ -159,4 +163,4 @@ struct Reflector<nlohmann::json>
159163
} // namespace detail
160164
} // namespace jinja2
161165

162-
#endif // JINJA2CPP_BINDING_NLOHMANN_JSON_H
166+
#endif // JINJA2CPP_BINDING_NLOHMANN_JSON_H

src/error_info.cpp

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#include "helpers.h"
22

33
#include <fmt/format.h>
4+
#include <fmt/xchar.h>
45
#include <jinja2cpp/error_info.h>
6+
#include <iterator>
57

68
namespace
79
{
@@ -110,146 +112,146 @@ template<typename CharT>
110112
void RenderErrorInfo(std::basic_string<CharT>& result, const ErrorInfoTpl<CharT>& errInfo)
111113
{
112114
using string_t = std::basic_string<CharT>;
113-
fmt::basic_memory_buffer<CharT> out;
115+
auto out = fmt::basic_memory_buffer<CharT>();
114116

115117
auto& loc = errInfo.GetErrorLocation();
116118

117-
fmt::format_to(out, UNIVERSAL_STR("{}:{}:{}: error: ").GetValue<CharT>(), ConvertString<string_t>(loc.fileName), loc.line, loc.col);
119+
fmt::format_to(std::back_inserter(out), UNIVERSAL_STR("{}:{}:{}: error: ").GetValue<CharT>(), ConvertString<string_t>(loc.fileName), loc.line, loc.col);
118120
ErrorCode errCode = errInfo.GetCode();
119121
switch (errCode)
120122
{
121123
case ErrorCode::Unspecified:
122-
format_to(out, UNIVERSAL_STR("Parse error").GetValue<CharT>());
124+
format_to(std::back_inserter(out), UNIVERSAL_STR("Parse error").GetValue<CharT>());
123125
break;
124126
case ErrorCode::UnexpectedException:
125127
{
126128
auto& extraParams = errInfo.GetExtraParams();
127-
format_to(out, UNIVERSAL_STR("Unexpected exception occurred during template processing. Exception: {}").GetValue<CharT>(), extraParams[0]);
129+
format_to(std::back_inserter(out), UNIVERSAL_STR("Unexpected exception occurred during template processing. Exception: {}").GetValue<CharT>(), extraParams[0]);
128130
break;
129131
}
130132
case ErrorCode::MetadataParseError:
131133
{
132134
auto& extraParams = errInfo.GetExtraParams();
133-
format_to(out, UNIVERSAL_STR("Error occurred during template metadata parsing. Error: {}").GetValue<CharT>(), extraParams[0]);
135+
format_to(std::back_inserter(out), UNIVERSAL_STR("Error occurred during template metadata parsing. Error: {}").GetValue<CharT>(), extraParams[0]);
134136
break;
135137
}
136138
case ErrorCode::YetUnsupported:
137-
format_to(out, UNIVERSAL_STR("This feature has not been supported yet").GetValue<CharT>());
139+
format_to(std::back_inserter(out), UNIVERSAL_STR("This feature has not been supported yet").GetValue<CharT>());
138140
break;
139141
case ErrorCode::FileNotFound:
140-
format_to(out, UNIVERSAL_STR("File not found").GetValue<CharT>());
142+
format_to(std::back_inserter(out), UNIVERSAL_STR("File not found").GetValue<CharT>());
141143
break;
142144
case ErrorCode::ExpectedStringLiteral:
143-
format_to(out, UNIVERSAL_STR("String expected").GetValue<CharT>());
145+
format_to(std::back_inserter(out), UNIVERSAL_STR("String expected").GetValue<CharT>());
144146
break;
145147
case ErrorCode::ExpectedIdentifier:
146-
format_to(out, UNIVERSAL_STR("Identifier expected").GetValue<CharT>());
148+
format_to(std::back_inserter(out), UNIVERSAL_STR("Identifier expected").GetValue<CharT>());
147149
break;
148150
case ErrorCode::ExpectedSquareBracket:
149-
format_to(out, UNIVERSAL_STR("']' expected").GetValue<CharT>());
151+
format_to(std::back_inserter(out), UNIVERSAL_STR("']' expected").GetValue<CharT>());
150152
break;
151153
case ErrorCode::ExpectedRoundBracket:
152-
format_to(out, UNIVERSAL_STR("')' expected").GetValue<CharT>());
154+
format_to(std::back_inserter(out), UNIVERSAL_STR("')' expected").GetValue<CharT>());
153155
break;
154156
case ErrorCode::ExpectedCurlyBracket:
155-
format_to(out, UNIVERSAL_STR("'}}' expected").GetValue<CharT>());
157+
format_to(std::back_inserter(out), UNIVERSAL_STR("'}}' expected").GetValue<CharT>());
156158
break;
157159
case ErrorCode::ExpectedToken:
158160
{
159161
auto& extraParams = errInfo.GetExtraParams();
160-
format_to(out, UNIVERSAL_STR("Unexpected token '{}'").GetValue<CharT>(), extraParams[0]);
162+
format_to(std::back_inserter(out), UNIVERSAL_STR("Unexpected token '{}'").GetValue<CharT>(), extraParams[0]);
161163
if (extraParams.size() > 1)
162164
{
163-
format_to(out, UNIVERSAL_STR(". Expected: ").GetValue<CharT>());
165+
format_to(std::back_inserter(out), UNIVERSAL_STR(". Expected: ").GetValue<CharT>());
164166
for (std::size_t i = 1; i < extraParams.size(); ++ i)
165167
{
166168
if (i != 1)
167-
format_to(out, UNIVERSAL_STR(", ").GetValue<CharT>());
168-
format_to(out, UNIVERSAL_STR("\'{}\'").GetValue<CharT>(), extraParams[i]);
169+
format_to(std::back_inserter(out), UNIVERSAL_STR(", ").GetValue<CharT>());
170+
format_to(std::back_inserter(out), UNIVERSAL_STR("\'{}\'").GetValue<CharT>(), extraParams[i]);
169171
}
170172
}
171173
break;
172174
}
173175
case ErrorCode::ExpectedExpression:
174176
{
175177
auto& extraParams = errInfo.GetExtraParams();
176-
format_to(out, UNIVERSAL_STR("Expected expression, got: '{}'").GetValue<CharT>(), extraParams[0]);
178+
format_to(std::back_inserter(out), UNIVERSAL_STR("Expected expression, got: '{}'").GetValue<CharT>(), extraParams[0]);
177179
break;
178180
}
179181
case ErrorCode::ExpectedEndOfStatement:
180182
{
181183
auto& extraParams = errInfo.GetExtraParams();
182-
format_to(out, UNIVERSAL_STR("Expected end of statement, got: '{}'").GetValue<CharT>(), extraParams[0]);
184+
format_to(std::back_inserter(out), UNIVERSAL_STR("Expected end of statement, got: '{}'").GetValue<CharT>(), extraParams[0]);
183185
break;
184186
}
185187
case ErrorCode::ExpectedRawEnd:
186-
format_to(out, UNIVERSAL_STR("Expected end of raw block").GetValue<CharT>());
188+
format_to(std::back_inserter(out), UNIVERSAL_STR("Expected end of raw block").GetValue<CharT>());
187189
break;
188190
case ErrorCode::ExpectedMetaEnd:
189-
format_to(out, UNIVERSAL_STR("Expected end of meta block").GetValue<CharT>());
191+
format_to(std::back_inserter(out), UNIVERSAL_STR("Expected end of meta block").GetValue<CharT>());
190192
break;
191193
case ErrorCode::UnexpectedToken:
192194
{
193195
auto& extraParams = errInfo.GetExtraParams();
194-
format_to(out, UNIVERSAL_STR("Unexpected token: '{}'").GetValue<CharT>(), extraParams[0]);
196+
format_to(std::back_inserter(out), UNIVERSAL_STR("Unexpected token: '{}'").GetValue<CharT>(), extraParams[0]);
195197
break;
196198
}
197199
case ErrorCode::UnexpectedStatement:
198200
{
199201
auto& extraParams = errInfo.GetExtraParams();
200-
format_to(out, UNIVERSAL_STR("Unexpected statement: '{}'").GetValue<CharT>(), extraParams[0]);
202+
format_to(std::back_inserter(out), UNIVERSAL_STR("Unexpected statement: '{}'").GetValue<CharT>(), extraParams[0]);
201203
break;
202204
}
203205
case ErrorCode::UnexpectedCommentBegin:
204-
format_to(out, UNIVERSAL_STR("Unexpected comment begin").GetValue<CharT>());
206+
format_to(std::back_inserter(out), UNIVERSAL_STR("Unexpected comment begin").GetValue<CharT>());
205207
break;
206208
case ErrorCode::UnexpectedCommentEnd:
207-
format_to(out, UNIVERSAL_STR("Unexpected comment end").GetValue<CharT>());
209+
format_to(std::back_inserter(out), UNIVERSAL_STR("Unexpected comment end").GetValue<CharT>());
208210
break;
209211
case ErrorCode::UnexpectedRawBegin:
210-
format_to(out, UNIVERSAL_STR("Unexpected raw block begin").GetValue<CharT>());
212+
format_to(std::back_inserter(out), UNIVERSAL_STR("Unexpected raw block begin").GetValue<CharT>());
211213
break;
212214
case ErrorCode::UnexpectedRawEnd:
213-
format_to(out, UNIVERSAL_STR("Unexpected raw block end").GetValue<CharT>());
215+
format_to(std::back_inserter(out), UNIVERSAL_STR("Unexpected raw block end").GetValue<CharT>());
214216
break;
215217
case ErrorCode::UnexpectedMetaBegin:
216-
format_to(out, UNIVERSAL_STR("Unexpected meta block begin").GetValue<CharT>());
218+
format_to(std::back_inserter(out), UNIVERSAL_STR("Unexpected meta block begin").GetValue<CharT>());
217219
break;
218220
case ErrorCode::UnexpectedMetaEnd:
219-
format_to(out, UNIVERSAL_STR("Unexpected meta block end").GetValue<CharT>());
221+
format_to(std::back_inserter(out), UNIVERSAL_STR("Unexpected meta block end").GetValue<CharT>());
220222
break;
221223
case ErrorCode::UnexpectedExprBegin:
222-
format_to(out, UNIVERSAL_STR("Unexpected expression block begin").GetValue<CharT>());
224+
format_to(std::back_inserter(out), UNIVERSAL_STR("Unexpected expression block begin").GetValue<CharT>());
223225
break;
224226
case ErrorCode::UnexpectedExprEnd:
225-
format_to(out, UNIVERSAL_STR("Unexpected expression block end").GetValue<CharT>());
227+
format_to(std::back_inserter(out), UNIVERSAL_STR("Unexpected expression block end").GetValue<CharT>());
226228
break;
227229
case ErrorCode::UnexpectedStmtBegin:
228-
format_to(out, UNIVERSAL_STR("Unexpected statement block begin").GetValue<CharT>());
230+
format_to(std::back_inserter(out), UNIVERSAL_STR("Unexpected statement block begin").GetValue<CharT>());
229231
break;
230232
case ErrorCode::UnexpectedStmtEnd:
231-
format_to(out, UNIVERSAL_STR("Unexpected statement block end").GetValue<CharT>());
233+
format_to(std::back_inserter(out), UNIVERSAL_STR("Unexpected statement block end").GetValue<CharT>());
232234
break;
233235
case ErrorCode::TemplateNotParsed:
234-
format_to(out, UNIVERSAL_STR("Template not parsed").GetValue<CharT>());
236+
format_to(std::back_inserter(out), UNIVERSAL_STR("Template not parsed").GetValue<CharT>());
235237
break;
236238
case ErrorCode::TemplateNotFound:
237-
format_to(out, UNIVERSAL_STR("Template(s) not found: {}").GetValue<CharT>(), errInfo.GetExtraParams()[0]);
239+
format_to(std::back_inserter(out), UNIVERSAL_STR("Template(s) not found: {}").GetValue<CharT>(), errInfo.GetExtraParams()[0]);
238240
break;
239241
case ErrorCode::InvalidTemplateName:
240-
format_to(out, UNIVERSAL_STR("Invalid template name: {}").GetValue<CharT>(), errInfo.GetExtraParams()[0]);
242+
format_to(std::back_inserter(out), UNIVERSAL_STR("Invalid template name: {}").GetValue<CharT>(), errInfo.GetExtraParams()[0]);
241243
break;
242244
case ErrorCode::InvalidValueType:
243-
format_to(out, UNIVERSAL_STR("Invalid value type").GetValue<CharT>());
245+
format_to(std::back_inserter(out), UNIVERSAL_STR("Invalid value type").GetValue<CharT>());
244246
break;
245247
case ErrorCode::ExtensionDisabled:
246-
format_to(out, UNIVERSAL_STR("Extension disabled").GetValue<CharT>());
248+
format_to(std::back_inserter(out), UNIVERSAL_STR("Extension disabled").GetValue<CharT>());
247249
break;
248250
case ErrorCode::TemplateEnvAbsent:
249-
format_to(out, UNIVERSAL_STR("Template environment doesn't set").GetValue<CharT>());
251+
format_to(std::back_inserter(out), UNIVERSAL_STR("Template environment doesn't set").GetValue<CharT>());
250252
break;
251253
}
252-
format_to(out, UNIVERSAL_STR("\n{}").GetValue<CharT>(), errInfo.GetLocationDescr());
254+
format_to(std::back_inserter(out), UNIVERSAL_STR("\n{}").GetValue<CharT>(), errInfo.GetLocationDescr());
253255
result = to_string(out);
254256
}
255257

src/serialize_filters.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@
66
#include "value_helpers.h"
77
#include "value_visitors.h"
88

9+
#include <fmt/args.h>
10+
911
#include <algorithm>
1012
#include <numeric>
1113
#include <random>
1214
#include <sstream>
1315
#include <string>
16+
#include <variant>
1417

1518
using namespace std::string_literals;
1619

@@ -214,15 +217,15 @@ struct FormatArgumentConverter : visitors::BaseVisitor<FormatArgument>
214217
template<typename T>
215218
result_t make_result(const T& t) const
216219
{
217-
return fmt::internal::make_arg<FormatContext>(m_decorator(t));
220+
return fmt::detail::make_arg<FormatContext>(m_decorator(t));
218221
}
219222

220223
const RenderContext* m_context;
221224
const ResultDecorator& m_decorator;
222225
};
223226

224227
template<typename T>
225-
using NamedArgument = fmt::internal::named_arg<T, char>;
228+
using NamedArgument = fmt::detail::named_arg<char, T>;
226229

227230
using ValueHandle =
228231
nonstd::variant<bool, std::string, int64_t, double, NamedArgument<bool>, NamedArgument<std::string>, NamedArgument<int64_t>, NamedArgument<double>>;
@@ -263,7 +266,7 @@ class NamedArgumentCreator
263266
const auto& name = nonstd::get<std::string>(m_valuesBuffer.back());
264267
m_valuesBuffer.push_back(t);
265268
const auto& value = nonstd::get<T>(m_valuesBuffer.back());
266-
m_valuesBuffer.emplace_back(fmt::arg(name, value));
269+
m_valuesBuffer.emplace_back(fmt::arg(name.c_str(), value));
267270
return nonstd::get<NamedArgument<T>>(m_valuesBuffer.back());
268271
}
269272

src/value_visitors.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <boost/algorithm/string/predicate.hpp>
99
#include <boost/optional.hpp>
1010
#include <fmt/format.h>
11+
#include <fmt/xchar.h>
1112

1213
#include <iostream>
1314
#include <cmath>

test/errors_test.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ TEST_P(ErrorsGenericExtensionsTest, Test_Wide)
251251
EXPECT_EQ(expectedResult, result);
252252
}
253253

254-
INSTANTIATE_TEST_CASE_P(BasicTest, ErrorsGenericTest, ::testing::Values(
254+
INSTANTIATE_TEST_SUITE_P(BasicTest, ErrorsGenericTest, ::testing::Values(
255255
InputOutputPair{"{{}}",
256256
"noname.j2tpl:1:3: error: Unexpected token: '<<End of block>>'\n{{}}\n--^-------"},
257257
InputOutputPair{"{{ ) }}",
@@ -272,7 +272,7 @@ INSTANTIATE_TEST_CASE_P(BasicTest, ErrorsGenericTest, ::testing::Values(
272272
"noname.j2tpl:1:1: error: Unexpected expression block end\n}}\n^-------"}
273273
));
274274

275-
INSTANTIATE_TEST_CASE_P(BasicExpressionsTest, ErrorsGenericTest, ::testing::Values(
275+
INSTANTIATE_TEST_SUITE_P(BasicExpressionsTest, ErrorsGenericTest, ::testing::Values(
276276
InputOutputPair{"{{ * or }}",
277277
"noname.j2tpl:1:4: error: Unexpected token: '*'\n{{ * or }}\n---^-------"},
278278
InputOutputPair{"{{ 1 + }}",
@@ -343,7 +343,7 @@ INSTANTIATE_TEST_CASE_P(BasicExpressionsTest, ErrorsGenericTest, ::testing::Valu
343343
"noname.j2tpl:1:3: error: Unexpected token: '<<End of block>>'\n{{}}\n--^-------"}
344344
));
345345

346-
INSTANTIATE_TEST_CASE_P(StatementsTest_1, ErrorsGenericTest, ::testing::Values(
346+
INSTANTIATE_TEST_SUITE_P(StatementsTest_1, ErrorsGenericTest, ::testing::Values(
347347
InputOutputPair{"{% if %}",
348348
"noname.j2tpl:1:7: error: Expected expression, got: '<<End of block>>'\n{% if %}\n ---^-------"},
349349
InputOutputPair{"{% endif %}",
@@ -419,7 +419,7 @@ INSTANTIATE_TEST_CASE_P(StatementsTest_1, ErrorsGenericTest, ::testing::Values(
419419
"noname.j2tpl:1:38: error: Expected end of statement, got: ','\n{% from 'foo' import bar with context, %}\n ---^-------"}
420420
));
421421

422-
INSTANTIATE_TEST_CASE_P(StatementsTest_2, ErrorsGenericTest, ::testing::Values(
422+
INSTANTIATE_TEST_SUITE_P(StatementsTest_2, ErrorsGenericTest, ::testing::Values(
423423
InputOutputPair{"{% block %}",
424424
"noname.j2tpl:1:10: error: Identifier expected\n{% block %}\n ---^-------"},
425425
InputOutputPair{"{% block 10 %}",
@@ -494,7 +494,7 @@ INSTANTIATE_TEST_CASE_P(StatementsTest_2, ErrorsGenericTest, ::testing::Values(
494494
InputOutputPair{ "{% meta %}", "noname.j2tpl:1:11: error: Expected end of meta block\n{% meta %}\n ---^-------" },
495495
InputOutputPair{ "{% endmeta %}", "noname.j2tpl:1:1: error: Unexpected meta block end\n{% endmeta %}\n^-------" }));
496496

497-
INSTANTIATE_TEST_CASE_P(ExtensionStatementsTest, ErrorsGenericExtensionsTest, ::testing::Values(
497+
INSTANTIATE_TEST_SUITE_P(ExtensionStatementsTest, ErrorsGenericExtensionsTest, ::testing::Values(
498498
InputOutputPair{"{% do %}",
499499
"noname.j2tpl:1:7: error: Unexpected token: '<<End of block>>'\n{% do %}\n ---^-------"},
500500
InputOutputPair{"{% do 1 + %}",

0 commit comments

Comments
 (0)