Skip to content

Commit

Permalink
Run reformatter
Browse files Browse the repository at this point in the history
  • Loading branch information
sparkprime committed Oct 29, 2017
1 parent 381d7dd commit 79577a6
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 49 deletions.
4 changes: 2 additions & 2 deletions cmd/jsonnet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -741,8 +741,8 @@ int main(int argc, const char **argv)

// Write output JSON.
if (config.evalMulti) {
if (!write_multi_output_files(vm, output, config.evalMultiOutputDir,
config.outputFile)) {
if (!write_multi_output_files(
vm, output, config.evalMultiOutputDir, config.outputFile)) {
jsonnet_destroy(vm);
return EXIT_FAILURE;
}
Expand Down
4 changes: 2 additions & 2 deletions core/desugarer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -647,13 +647,13 @@ class Desugarer {
// TODO(dcunnin): Abstract this into a template function if it becomes more common.
AST *file = ast->file;
desugar(file, obj_level);
ast->file = dynamic_cast<LiteralString*>(file);
ast->file = dynamic_cast<LiteralString *>(file);

} else if (auto *ast = dynamic_cast<Importstr *>(ast_)) {
// TODO(dcunnin): Abstract this into a template function if it becomes more common.
AST *file = ast->file;
desugar(file, obj_level);
ast->file = dynamic_cast<LiteralString*>(file);
ast->file = dynamic_cast<LiteralString *>(file);

} else if (auto *ast = dynamic_cast<InSuper *>(ast_)) {
desugar(ast->element, obj_level);
Expand Down
4 changes: 3 additions & 1 deletion core/json.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ struct JsonnetJsonValue {
JsonnetJsonValue(JsonnetJsonValue&&) = default;

JsonnetJsonValue(Kind kind, std::string string, double number)
: kind(kind), string(string), number(number) {}
: kind(kind), string(string), number(number)
{
}

Kind kind;
std::string string;
Expand Down
4 changes: 1 addition & 3 deletions core/lexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ static void lex_ws(const char *&c, unsigned &new_lines, unsigned &indent, const
line_start = c + 1;
break;

case ' ':
indent += 1;
break;
case ' ': indent += 1; break;

// This only works for \t at the beginning of lines, but we strip it everywhere else
// anyway. The only case where this will cause a problem is spaces followed by \t
Expand Down
3 changes: 1 addition & 2 deletions core/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -688,8 +688,7 @@ class Parser {

case Token::TRUE: return alloc->make<LiteralBoolean>(span(tok), tok.fodder, true);

case Token::NULL_LIT:
return alloc->make<LiteralNull>(span(tok), tok.fodder);
case Token::NULL_LIT: return alloc->make<LiteralNull>(span(tok), tok.fodder);

// Variables
case Token::DOLLAR: return alloc->make<Dollar>(span(tok), tok.fodder);
Expand Down
1 change: 0 additions & 1 deletion core/string_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ limitations under the License.
/** Unparse the string. */
UString jsonnet_string_unparse(const UString &str, bool single);


// Note that the following two functions do not handle the quoting of ' and "
// inside verbatim strings because that quoting is reversible. Thus, that
// quoting is done at lexing time and undone again at pretty-printing time.
Expand Down
17 changes: 5 additions & 12 deletions core/vm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2086,23 +2086,15 @@ class Interpreter {

case Value::BOOLEAN:
args2.emplace_back(
JsonnetJsonValue::BOOL,
"",
arg.v.b ? 1.0 : 0.0);
JsonnetJsonValue::BOOL, "", arg.v.b ? 1.0 : 0.0);
break;

case Value::NUMBER:
args2.emplace_back(
JsonnetJsonValue::NUMBER,
"",
arg.v.d);
args2.emplace_back(JsonnetJsonValue::NUMBER, "", arg.v.d);
break;

case Value::NULL_TYPE:
args2.emplace_back(
JsonnetJsonValue::NULL_KIND,
"",
0);
args2.emplace_back(JsonnetJsonValue::NULL_KIND, "", 0);
break;

default:
Expand Down Expand Up @@ -2256,7 +2248,8 @@ class Interpreter {
long sz = array->elements.size();
if (index < 0 || index >= sz) {
std::stringstream ss;
ss << "Array bounds error: " << index << " not within [0, " << sz << ")";
ss << "Array bounds error: " << index << " not within [0, " << sz
<< ")";
throw makeError(ast.location, ss.str());
}
if (scratch.v.d != index) {
Expand Down
53 changes: 27 additions & 26 deletions stdlib/to_c_array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,36 @@
#include <iostream>
#include <iterator>

int main(int argc, char *argv[]) {
if (argc < 3) {
std::cerr << "usage: to_c_array <infile> <outfile>\n";
return 1;
}
int main(int argc, char *argv[])
{
if (argc < 3) {
std::cerr << "usage: to_c_array <infile> <outfile>\n";
return 1;
}

std::ifstream in_file(argv[1]);
if (!in_file.is_open()) {
std::cerr << "Can't open input file.";
return 1;
}
std::ifstream in_file(argv[1]);
if (!in_file.is_open()) {
std::cerr << "Can't open input file.";
return 1;
}

std::ofstream out_file(argv[2]);
if (!out_file.is_open()) {
std::cerr << "Can't open output file.";
return 1;
}
std::ofstream out_file(argv[2]);
if (!out_file.is_open()) {
std::cerr << "Can't open output file.";
return 1;
}

char c;
bool first_character = true;
while (in_file.get(c)) {
if (first_character) {
first_character = false;
} else {
out_file << ",";
char c;
bool first_character = true;
while (in_file.get(c)) {
if (first_character) {
first_character = false;
} else {
out_file << ",";
}
// Write byte value of c to stdout.
out_file << (int)c;
}
// Write byte value of c to stdout.
out_file << (int)c;
}

return 0;
return 0;
}

0 comments on commit 79577a6

Please sign in to comment.