MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / init

Function init

utils/dasFormatter/formatter.cpp:29–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27
28
29 void init(TextWriter *ss, string content, FormatOptions options, ProgramPtr program) {
30 string line;
31 content.push_back('\n'); // easiest way to flush the last line
32 for (const auto c: content) {
33 if (c != '\n') {
34 line.push_back(c);
35 } else {
36 state.content_.emplace_back(das::move(line));
37 line.clear();
38 }
39 }
40 state.ss = ss;
41 state.enabled = true;
42 state.last = Pos{1, 0};
43 state.program = program;
44 state.options = das::move(options);
45 if ((state.content_.empty() || state.content_.front().substr(0, strlen("options gen2")) != "options gen2") &&
46 state.options.contains(FormatOpt::V2Syntax)) {
47 *state.ss << "options gen2";
48 if (state.options.contains(FormatOpt::SemicolonEOL)) {
49 *state.ss << ";";
50 }
51 *state.ss << "\n";
52 }
53 }
54
55 void destroy() {
56 if (!state.content_.empty()) {

Callers 1

transform_syntaxFunction · 0.70

Calls 4

push_backMethod · 0.45
clearMethod · 0.45
emptyMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected