Skip to content

Commit 99e9e17

Browse files
committed
Rename context to emitter.
1 parent b68e51e commit 99e9e17

11 files changed

Lines changed: 99 additions & 99 deletions

File tree

src/client/autotools.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ ac_processor::ac_processor(const path &p)
269269
conditions = parse_conditions(file);
270270
}
271271

272-
void print_checks2(primitives::CppContext &ctx, const ChecksSet &checks, const String &name);
272+
void print_checks2(primitives::CppEmitter &ctx, const ChecksSet &checks, const String &name);
273273

274274
void ac_processor::output()
275275
{
@@ -279,7 +279,7 @@ void ac_processor::output()
279279

280280
void ac_processor::output2()
281281
{
282-
primitives::CppContext ctx;
282+
primitives::CppEmitter ctx;
283283
print_checks2(ctx, checks.checks, "x");
284284
std::cout << ctx.getText();
285285
}

src/client/fix_imports.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include "fix_imports.h"
1818

1919
#include <config.h>
20-
#include <context.h>
20+
#include <emitter.h>
2121
#include <project_path.h>
2222

2323
#include <printers/cmake.h>
@@ -31,7 +31,7 @@
3131

3232
String fix_imports(const Strings &lines_old, const String &old_target, const String &new_target)
3333
{
34-
CMakeContext ctx;
34+
CMakeEmitter ctx;
3535
ctx.addLine("if (NOT TARGET " + new_target + ")");
3636
ctx.increaseIndent();
3737
for (auto &line1 : lines_old)
@@ -124,7 +124,7 @@ void fix_imports(const String &target, const path &aliases_file, const path &old
124124
auto fix = [&aliases_s](const auto &lines, const auto &dep)
125125
{
126126
const auto &tgt = dep.target_name_hash;
127-
CMakeContext ctx;
127+
CMakeEmitter ctx;
128128

129129
StringSet aliases;
130130
{
@@ -146,7 +146,7 @@ void fix_imports(const String &target, const path &aliases_file, const path &old
146146
return ctx.getText();
147147
};
148148

149-
CMakeContext ctx;
149+
CMakeEmitter ctx;
150150
file_header(ctx, dep);
151151
if (exe)
152152
{

src/common/checks.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ String Checks::save() const
518518
return dump_yaml_config(root);
519519
}
520520

521-
void invert(CMakeContext &ctx, const CheckPtr &c)
521+
void invert(CMakeEmitter &ctx, const CheckPtr &c)
522522
{
523523
ctx.addLine();
524524
ctx.addLine("if (" + c->getVariable() + ")");
@@ -528,7 +528,7 @@ void invert(CMakeContext &ctx, const CheckPtr &c)
528528
ctx.addLine("endif()");
529529
}
530530

531-
void Checks::write_checks(CMakeContext &ctx, const StringSet &prefixes) const
531+
void Checks::write_checks(CMakeEmitter &ctx, const StringSet &prefixes) const
532532
{
533533
for (auto &c : checks)
534534
{
@@ -652,7 +652,7 @@ void Checks::write_checks(CMakeContext &ctx, const StringSet &prefixes) const
652652
}
653653
}
654654

655-
void Checks::write_parallel_checks_for_workers(CMakeContext &ctx) const
655+
void Checks::write_parallel_checks_for_workers(CMakeEmitter &ctx) const
656656
{
657657
for (auto &c : checks)
658658
{
@@ -761,7 +761,7 @@ void Checks::read_parallel_checks_for_workers(const path &dir)
761761
}
762762
}
763763

764-
void Checks::write_definitions(CMakeContext &ctx, const Package &d, const StringSet &prefixes) const
764+
void Checks::write_definitions(CMakeEmitter &ctx, const Package &d, const StringSet &prefixes) const
765765
{
766766
const auto m = [&d]
767767
{
@@ -900,7 +900,7 @@ void Checks::print_values() const
900900
//LOG_INFO(logger, v->printStatus());
901901
}
902902

903-
void Checks::print_values(CMakeContext &ctx) const
903+
void Checks::print_values(CMakeEmitter &ctx) const
904904
{
905905
std::map<String, CheckPtr> checks_to_print;
906906
for (auto &c : checks)
@@ -998,7 +998,7 @@ String CheckParameters::getHash() const
998998
return h;
999999
}
10001000

1001-
void CheckParameters::writeHeadersBefore(CMakeContext &ctx) const
1001+
void CheckParameters::writeHeadersBefore(CMakeEmitter &ctx) const
10021002
{
10031003
if (!headers.empty())
10041004
{
@@ -1010,13 +1010,13 @@ void CheckParameters::writeHeadersBefore(CMakeContext &ctx) const
10101010
}
10111011
}
10121012

1013-
void CheckParameters::writeHeadersAfter(CMakeContext &ctx) const
1013+
void CheckParameters::writeHeadersAfter(CMakeEmitter &ctx) const
10141014
{
10151015
if (!headers.empty())
10161016
ctx.addLine("set(CMAKE_EXTRA_INCLUDE_FILES ${_oh})");
10171017
}
10181018

1019-
void CheckParameters::writeBefore(CMakeContext &ctx) const
1019+
void CheckParameters::writeBefore(CMakeEmitter &ctx) const
10201020
{
10211021
if (!definitions.empty())
10221022
{
@@ -1052,7 +1052,7 @@ void CheckParameters::writeBefore(CMakeContext &ctx) const
10521052
}
10531053
}
10541054

1055-
void CheckParameters::writeAfter(CMakeContext &ctx) const
1055+
void CheckParameters::writeAfter(CMakeEmitter &ctx) const
10561056
{
10571057
if (!definitions.empty())
10581058
ctx.addLine("set(CMAKE_REQUIRED_DEFINITIONS ${_od})");

src/common/checks.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616

1717
#pragma once
1818

19-
#include "context.h"
19+
#include "emitter.h"
2020
#include "cppan_string.h"
2121
#include "filesystem.h"
2222
#include "yaml.h"
2323

24-
class CMakeContext;
24+
class CMakeEmitter;
2525
struct Package;
2626

2727
struct CheckParameters
@@ -36,10 +36,10 @@ struct CheckParameters
3636
// it is possible only in sequential mode
3737
bool all_includes = false;
3838

39-
void writeHeadersBefore(CMakeContext &ctx) const;
40-
void writeHeadersAfter(CMakeContext &ctx) const;
41-
void writeBefore(CMakeContext &ctx) const;
42-
void writeAfter(CMakeContext &ctx) const;
39+
void writeHeadersBefore(CMakeEmitter &ctx) const;
40+
void writeHeadersAfter(CMakeEmitter &ctx) const;
41+
void writeBefore(CMakeEmitter &ctx) const;
42+
void writeAfter(CMakeEmitter &ctx) const;
4343
void load(const yaml &n);
4444
void save(yaml &n) const;
4545
bool empty() const;
@@ -97,7 +97,7 @@ class Check
9797
Value getValue() const { return value; }
9898
String getMessage() const { return message; }
9999

100-
virtual void writeCheck(CMakeContext &/*ctx*/) const {}
100+
virtual void writeCheck(CMakeEmitter &/*ctx*/) const {}
101101
virtual void save(yaml &/*root*/) const {}
102102

103103
void setValue(const Value &v) { value = v; }
@@ -186,16 +186,16 @@ struct Checks
186186
void save(yaml &root) const;
187187
String save() const;
188188

189-
void write_checks(CMakeContext &ctx, const StringSet &prefixes = StringSet()) const;
190-
void write_definitions(CMakeContext &ctx, const Package &d, const StringSet &prefixes = StringSet()) const;
189+
void write_checks(CMakeEmitter &ctx, const StringSet &prefixes = StringSet()) const;
190+
void write_definitions(CMakeEmitter &ctx, const Package &d, const StringSet &prefixes = StringSet()) const;
191191

192-
void write_parallel_checks_for_workers(CMakeContext &ctx) const;
192+
void write_parallel_checks_for_workers(CMakeEmitter &ctx) const;
193193
void read_parallel_checks_for_workers(const path &dir);
194194

195195
void remove_known_vars(const std::set<String> &known_vars);
196196
std::vector<Checks> scatter(int N) const;
197197
void print_values() const;
198-
void print_values(CMakeContext &ctx) const;
198+
void print_values(CMakeEmitter &ctx) const;
199199

200200
Checks &operator+=(const Checks &rhs);
201201

src/common/checks_detail.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@
1919
#include "printers/printer.h"
2020

2121
#include <boost/algorithm/string.hpp>
22-
#include <primitives/context.h>
22+
#include <primitives/emitter.h>
2323

2424
#include <memory>
2525

2626
extern const std::map<int, Check::Information> check_information;
2727

2828
class CheckParametersScopedWriter
2929
{
30-
CMakeContext &ctx;
30+
CMakeEmitter &ctx;
3131
const CheckParameters &p;
3232
bool with_headers;
3333
public:
34-
CheckParametersScopedWriter(CMakeContext &ctx, const CheckParameters &p, bool with_headers = false)
34+
CheckParametersScopedWriter(CMakeEmitter &ctx, const CheckParameters &p, bool with_headers = false)
3535
: ctx(ctx), p(p), with_headers(with_headers)
3636
{
3737
if (with_headers)
@@ -72,7 +72,7 @@ class CheckFunction : public Check
7272
root[information.cppan_key].push_back(y);
7373
}
7474

75-
void writeCheck(CMakeContext &ctx) const override
75+
void writeCheck(CMakeEmitter &ctx) const override
7676
{
7777
CheckParametersScopedWriter p(ctx, parameters);
7878
ctx.addLine(information.function + "(" + getData() + " " + getVariable() + ")");
@@ -136,7 +136,7 @@ class CheckType : public Check
136136

137137
virtual ~CheckType() {}
138138

139-
void writeCheck(CMakeContext &ctx) const override
139+
void writeCheck(CMakeEmitter &ctx) const override
140140
{
141141
CheckParametersScopedWriter p(ctx, parameters, true);
142142
ctx.addLine(information.function + "(\"" + getData() + "\" " + getVariable() + ")");
@@ -164,7 +164,7 @@ class CheckStructMember : public Check
164164

165165
virtual ~CheckStructMember() {}
166166

167-
void writeCheck(CMakeContext &ctx) const override
167+
void writeCheck(CMakeEmitter &ctx) const override
168168
{
169169
CheckParametersScopedWriter p(ctx, parameters);
170170
ctx.addLine(information.function + "(\"" + struct_ + "\" \"" + getData() + "\" \"");
@@ -274,7 +274,7 @@ class CheckSymbol : public Check
274274

275275
virtual ~CheckSymbol() {}
276276

277-
void writeCheck(CMakeContext &ctx) const override
277+
void writeCheck(CMakeEmitter &ctx) const override
278278
{
279279
CheckParametersScopedWriter p(ctx, parameters);
280280
ctx.addLine(information.function + "(\"" + getData() + "\" \"");
@@ -323,7 +323,7 @@ class CheckDecl : public Check
323323
root[information.cppan_key].push_back(n);
324324
}
325325

326-
void writeCheck(CMakeContext &ctx) const override
326+
void writeCheck(CMakeEmitter &ctx) const override
327327
{
328328
static const Strings headers = {
329329
"HAVE_SYS_TYPES_H",

src/common/project.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -389,13 +389,13 @@ void Patch::patchSources(const Project &prj, const Files &files) const
389389
continue;
390390

391391
auto r = primitives::patch::patch(t, f);
392-
if (!r)
392+
if (!r.first)
393393
{
394-
LOG_ERROR(logger, "cannot apply patch to: " << s);
394+
LOG_ERROR(logger, "cannot apply patch to: " << s << ": " << r.second);
395395
continue;
396396
}
397397

398-
write_file(fn, *r);
398+
write_file(fn, r.second);
399399
write_file(fn_patch, t); // save orig
400400
}
401401

@@ -1513,7 +1513,7 @@ void saveOptionsMap(yaml &node, const OptionsMap &m)
15131513

15141514
String Project::print_cpp()
15151515
{
1516-
primitives::CppContext ctx;
1516+
primitives::CppEmitter ctx;
15171517

15181518
String name = pkg.ppath.back();
15191519

@@ -1809,11 +1809,11 @@ String Project::print_cpp()
18091809
return ctx.getText();
18101810
}
18111811

1812-
void print_checks2(primitives::CppContext &ctx, const ChecksSet &checks, const String &name);
1812+
void print_checks2(primitives::CppEmitter &ctx, const ChecksSet &checks, const String &name);
18131813

18141814
String Project::print_cpp2()
18151815
{
1816-
primitives::CppContext ctx;
1816+
primitives::CppEmitter ctx;
18171817

18181818
String name = pkg.ppath.back();
18191819

@@ -2042,7 +2042,7 @@ String Project::print_cpp2()
20422042
return ctx.getText();
20432043
}
20442044

2045-
void print_checks2(primitives::CppContext &ctx, const ChecksSet &checks, const String &name)
2045+
void print_checks2(primitives::CppEmitter &ctx, const ChecksSet &checks, const String &name)
20462046
{
20472047
if (checks.size() > 2)
20482048
{

0 commit comments

Comments
 (0)