#endif // defined(USE_GTEST)
-bool isSandcastle() {
- return ((std::getenv("SANDCASTLE")) || \
- (std::getenv("TW_JOB_USER") && std::string(std::getenv("TW_JOB_USER")) == "sandcastle"));
+static inline bool isSandcastle() {
+ return (
+ (std::getenv("SANDCASTLE")) ||
+ (std::getenv("TW_JOB_USER") &&
+ std::string(std::getenv("TW_JOB_USER")) == "sandcastle"));
}
out << "}";
return out;
}
-auto ct = CodeTemplate(R"(
+static const auto ct = CodeTemplate(R"(
int foo($args) {
$bar
int commatest(int a${,stuff})
int notest(int a${,empty,})
)");
-auto ct_expect = R"(
+static const auto ct_expect = R"(
int foo(hi, 8) {
what
ASSERT_EQ(second_key, expected_key);
}
-const auto cf_examples = R"JIT(
+static const auto cf_examples = R"JIT(
def if_test(a, b):
# FIXME: use 0 instead of a.
# c = 0
struct CodeTemplate {
/* implicit */ CodeTemplate(std::string t) : template_text(std::move(t)) {}
- std::string format(const TemplateEnv& env) {
+ std::string format(const TemplateEnv& env) const {
std::stringstream out;
size_t pos = 0;
size_t indent = 0;
private:
using string_list = std::vector<std::string>;
- char charAt(size_t p) {
+ char charAt(size_t p) const {
if (p >= template_text.size())
throw std::logic_error("EOS found in key");
return template_text[p];
size_t pos,
std::ostream& k,
bool& comma_before,
- bool& comma_after) {
+ bool& comma_after) const {
comma_before = false;
comma_after = false;
pos++;
return parseIdent(pos, k);
}
}
- size_t parseIdent(size_t pos, std::ostream& k) {
+ size_t parseIdent(size_t pos, std::ostream& k) const {
while (pos < template_text.size() &&
(isalnum(template_text[pos]) || template_text[pos] == '_')) {
k << template_text[pos];
std::ostream& out,
const string_list& strings,
bool comma_before,
- bool comma_after) {
+ bool comma_after) const {
if (comma_before && strings.size() > 0)
out << ", ";
for (size_t i = 0; i < strings.size(); ++i) {
// leading or trailing newlines when the input string does not have leading
// or trailing newlines. It's the responsibility of the calling function
// to indent correctly in the context.
- void emitIndent(std::ostream& out, size_t indent) {
+ void emitIndent(std::ostream& out, size_t indent) const {
for (size_t i = 0; i < indent; ++i) {
out << " ";
}
void emitStringWithIndents(
std::ostream& out,
size_t indent,
- const std::string& str) {
+ const std::string& str) const {
for (auto c : str) {
out << c;
if (c == '\n') {
void emitLinesIndented(
std::stringstream& out,
size_t indent,
- const string_list& strings) {
+ const string_list& strings) const {
for (size_t i = 0; i < strings.size(); ++i) {
if (i > 0)
emitIndent(out, indent);