You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
Style: Enforce braces around if blocks and loops
Using clang-tidy's `readability-braces-around-statements`. https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
This commit is contained in:
@@ -150,8 +150,9 @@ Error VariantParser::get_token(Stream *p_stream, Token &r_token, int &line, Stri
|
||||
r_token.type = TK_EOF;
|
||||
return OK;
|
||||
}
|
||||
if (ch == '\n')
|
||||
if (ch == '\n') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -278,8 +279,9 @@ Error VariantParser::get_token(Stream *p_stream, Token &r_token, int &line, Stri
|
||||
str += res;
|
||||
|
||||
} else {
|
||||
if (ch == '\n')
|
||||
if (ch == '\n') {
|
||||
line++;
|
||||
}
|
||||
str += ch;
|
||||
}
|
||||
}
|
||||
@@ -362,8 +364,9 @@ Error VariantParser::get_token(Stream *p_stream, Token &r_token, int &line, Stri
|
||||
} break;
|
||||
}
|
||||
|
||||
if (reading == READING_DONE)
|
||||
if (reading == READING_DONE) {
|
||||
break;
|
||||
}
|
||||
num += c;
|
||||
c = p_stream->get_char();
|
||||
}
|
||||
@@ -372,10 +375,11 @@ Error VariantParser::get_token(Stream *p_stream, Token &r_token, int &line, Stri
|
||||
|
||||
r_token.type = TK_NUMBER;
|
||||
|
||||
if (is_float)
|
||||
if (is_float) {
|
||||
r_token.value = num.as_double();
|
||||
else
|
||||
} else {
|
||||
r_token.value = num.as_int();
|
||||
}
|
||||
return OK;
|
||||
|
||||
} else if ((cchar >= 'A' && cchar <= 'Z') || (cchar >= 'a' && cchar <= 'z') || cchar == '_') {
|
||||
@@ -484,35 +488,38 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
||||
if (token.type == TK_CURLY_BRACKET_OPEN) {
|
||||
Dictionary d;
|
||||
Error err = _parse_dictionary(d, p_stream, line, r_err_str, p_res_parser);
|
||||
if (err)
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
value = d;
|
||||
return OK;
|
||||
} else if (token.type == TK_BRACKET_OPEN) {
|
||||
Array a;
|
||||
Error err = _parse_array(a, p_stream, line, r_err_str, p_res_parser);
|
||||
if (err)
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
value = a;
|
||||
return OK;
|
||||
|
||||
} else if (token.type == TK_IDENTIFIER) {
|
||||
String id = token.value;
|
||||
if (id == "true")
|
||||
if (id == "true") {
|
||||
value = true;
|
||||
else if (id == "false")
|
||||
} else if (id == "false") {
|
||||
value = false;
|
||||
else if (id == "null" || id == "nil")
|
||||
} else if (id == "null" || id == "nil") {
|
||||
value = Variant();
|
||||
else if (id == "inf")
|
||||
} else if (id == "inf") {
|
||||
value = Math_INF;
|
||||
else if (id == "nan")
|
||||
} else if (id == "nan") {
|
||||
value = Math_NAN;
|
||||
else if (id == "Vector2") {
|
||||
} else if (id == "Vector2") {
|
||||
Vector<float> args;
|
||||
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
|
||||
if (err)
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
if (args.size() != 2) {
|
||||
r_err_str = "Expected 2 arguments for constructor";
|
||||
@@ -523,8 +530,9 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
||||
} else if (id == "Vector2i") {
|
||||
Vector<int32_t> args;
|
||||
Error err = _parse_construct<int32_t>(p_stream, args, line, r_err_str);
|
||||
if (err)
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
if (args.size() != 2) {
|
||||
r_err_str = "Expected 2 arguments for constructor";
|
||||
@@ -535,8 +543,9 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
||||
} else if (id == "Rect2") {
|
||||
Vector<float> args;
|
||||
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
|
||||
if (err)
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
if (args.size() != 4) {
|
||||
r_err_str = "Expected 4 arguments for constructor";
|
||||
@@ -547,8 +556,9 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
||||
} else if (id == "Rect2i") {
|
||||
Vector<int32_t> args;
|
||||
Error err = _parse_construct<int32_t>(p_stream, args, line, r_err_str);
|
||||
if (err)
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
if (args.size() != 4) {
|
||||
r_err_str = "Expected 4 arguments for constructor";
|
||||
@@ -559,8 +569,9 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
||||
} else if (id == "Vector3") {
|
||||
Vector<float> args;
|
||||
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
|
||||
if (err)
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
if (args.size() != 3) {
|
||||
r_err_str = "Expected 3 arguments for constructor";
|
||||
@@ -571,8 +582,9 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
||||
} else if (id == "Vector3i") {
|
||||
Vector<int32_t> args;
|
||||
Error err = _parse_construct<int32_t>(p_stream, args, line, r_err_str);
|
||||
if (err)
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
if (args.size() != 3) {
|
||||
r_err_str = "Expected 3 arguments for constructor";
|
||||
@@ -584,8 +596,9 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
||||
|
||||
Vector<float> args;
|
||||
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
|
||||
if (err)
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
if (args.size() != 6) {
|
||||
r_err_str = "Expected 6 arguments for constructor";
|
||||
@@ -599,8 +612,9 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
||||
} else if (id == "Plane") {
|
||||
Vector<float> args;
|
||||
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
|
||||
if (err)
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
if (args.size() != 4) {
|
||||
r_err_str = "Expected 4 arguments for constructor";
|
||||
@@ -611,8 +625,9 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
||||
} else if (id == "Quat") {
|
||||
Vector<float> args;
|
||||
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
|
||||
if (err)
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
if (args.size() != 4) {
|
||||
r_err_str = "Expected 4 arguments for constructor";
|
||||
@@ -624,8 +639,9 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
||||
} else if (id == "AABB" || id == "Rect3") {
|
||||
Vector<float> args;
|
||||
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
|
||||
if (err)
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
if (args.size() != 6) {
|
||||
r_err_str = "Expected 6 arguments for constructor";
|
||||
@@ -638,8 +654,9 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
||||
|
||||
Vector<float> args;
|
||||
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
|
||||
if (err)
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
if (args.size() != 9) {
|
||||
r_err_str = "Expected 9 arguments for constructor";
|
||||
@@ -650,8 +667,9 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
||||
} else if (id == "Transform") {
|
||||
Vector<float> args;
|
||||
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
|
||||
if (err)
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
if (args.size() != 12) {
|
||||
r_err_str = "Expected 12 arguments for constructor";
|
||||
@@ -663,8 +681,9 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
||||
} else if (id == "Color") {
|
||||
Vector<float> args;
|
||||
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
|
||||
if (err)
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
if (args.size() != 4) {
|
||||
r_err_str = "Expected 4 arguments for constructor";
|
||||
@@ -758,8 +777,9 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
||||
|
||||
if (at_key) {
|
||||
Error err = get_token(p_stream, token2, line, r_err_str);
|
||||
if (err != OK)
|
||||
if (err != OK) {
|
||||
return err;
|
||||
}
|
||||
|
||||
if (token2.type == TK_PARENTHESIS_CLOSE) {
|
||||
Reference *reference = Object::cast_to<Reference>(obj);
|
||||
@@ -790,8 +810,9 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
||||
|
||||
err = get_token(p_stream, token2, line, r_err_str);
|
||||
|
||||
if (err != OK)
|
||||
if (err != OK) {
|
||||
return err;
|
||||
}
|
||||
if (token2.type != TK_COLON) {
|
||||
r_err_str = "Expected ':'";
|
||||
return ERR_PARSE_ERROR;
|
||||
@@ -799,13 +820,15 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
||||
at_key = false;
|
||||
} else {
|
||||
Error err = get_token(p_stream, token2, line, r_err_str);
|
||||
if (err != OK)
|
||||
if (err != OK) {
|
||||
return err;
|
||||
}
|
||||
|
||||
Variant v;
|
||||
err = parse_value(token2, v, p_stream, line, r_err_str, p_res_parser);
|
||||
if (err)
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
obj->set(key, v);
|
||||
need_comma = true;
|
||||
at_key = true;
|
||||
@@ -822,8 +845,9 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
||||
if (p_res_parser && id == "Resource" && p_res_parser->func) {
|
||||
RES res;
|
||||
Error err = p_res_parser->func(p_res_parser->userdata, p_stream, res, line, r_err_str);
|
||||
if (err)
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
value = res;
|
||||
|
||||
@@ -831,8 +855,9 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
||||
} else if (p_res_parser && id == "ExtResource" && p_res_parser->ext_func) {
|
||||
RES res;
|
||||
Error err = p_res_parser->ext_func(p_res_parser->userdata, p_stream, res, line, r_err_str);
|
||||
if (err)
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
value = res;
|
||||
|
||||
@@ -840,8 +865,9 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
||||
} else if (p_res_parser && id == "SubResource" && p_res_parser->sub_func) {
|
||||
RES res;
|
||||
Error err = p_res_parser->sub_func(p_res_parser->userdata, p_stream, res, line, r_err_str);
|
||||
if (err)
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
value = res;
|
||||
|
||||
@@ -874,8 +900,9 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
||||
} else if (id == "PackedByteArray" || id == "PoolByteArray" || id == "ByteArray") {
|
||||
Vector<uint8_t> args;
|
||||
Error err = _parse_construct<uint8_t>(p_stream, args, line, r_err_str);
|
||||
if (err)
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
Vector<uint8_t> arr;
|
||||
{
|
||||
@@ -894,8 +921,9 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
||||
} else if (id == "PackedInt32Array" || id == "PackedIntArray" || id == "PoolIntArray" || id == "IntArray") {
|
||||
Vector<int32_t> args;
|
||||
Error err = _parse_construct<int32_t>(p_stream, args, line, r_err_str);
|
||||
if (err)
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
Vector<int32_t> arr;
|
||||
{
|
||||
@@ -914,8 +942,9 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
||||
} else if (id == "PackedInt64Array") {
|
||||
Vector<int64_t> args;
|
||||
Error err = _parse_construct<int64_t>(p_stream, args, line, r_err_str);
|
||||
if (err)
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
Vector<int64_t> arr;
|
||||
{
|
||||
@@ -934,8 +963,9 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
||||
} else if (id == "PackedFloat32Array" || id == "PackedRealArray" || id == "PoolRealArray" || id == "FloatArray") {
|
||||
Vector<float> args;
|
||||
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
|
||||
if (err)
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
Vector<float> arr;
|
||||
{
|
||||
@@ -953,8 +983,9 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
||||
} else if (id == "PackedFloat64Array") {
|
||||
Vector<double> args;
|
||||
Error err = _parse_construct<double>(p_stream, args, line, r_err_str);
|
||||
if (err)
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
Vector<double> arr;
|
||||
{
|
||||
@@ -1021,8 +1052,9 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
||||
} else if (id == "PackedVector2Array" || id == "PoolVector2Array" || id == "Vector2Array") {
|
||||
Vector<float> args;
|
||||
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
|
||||
if (err)
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
Vector<Vector2> arr;
|
||||
{
|
||||
@@ -1041,8 +1073,9 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
||||
} else if (id == "PackedVector3Array" || id == "PoolVector3Array" || id == "Vector3Array") {
|
||||
Vector<float> args;
|
||||
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
|
||||
if (err)
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
Vector<Vector3> arr;
|
||||
{
|
||||
@@ -1061,8 +1094,9 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
||||
} else if (id == "PackedColorArray" || id == "PoolColorArray" || id == "ColorArray") {
|
||||
Vector<float> args;
|
||||
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
|
||||
if (err)
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
Vector<Color> arr;
|
||||
{
|
||||
@@ -1113,8 +1147,9 @@ Error VariantParser::_parse_array(Array &array, Stream *p_stream, int &line, Str
|
||||
}
|
||||
|
||||
Error err = get_token(p_stream, token, line, r_err_str);
|
||||
if (err != OK)
|
||||
if (err != OK) {
|
||||
return err;
|
||||
}
|
||||
|
||||
if (token.type == TK_BRACKET_CLOSE) {
|
||||
return OK;
|
||||
@@ -1132,8 +1167,9 @@ Error VariantParser::_parse_array(Array &array, Stream *p_stream, int &line, Str
|
||||
|
||||
Variant v;
|
||||
err = parse_value(token, v, p_stream, line, r_err_str, p_res_parser);
|
||||
if (err)
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
array.push_back(v);
|
||||
need_comma = true;
|
||||
@@ -1154,8 +1190,9 @@ Error VariantParser::_parse_dictionary(Dictionary &object, Stream *p_stream, int
|
||||
|
||||
if (at_key) {
|
||||
Error err = get_token(p_stream, token, line, r_err_str);
|
||||
if (err != OK)
|
||||
if (err != OK) {
|
||||
return err;
|
||||
}
|
||||
|
||||
if (token.type == TK_CURLY_BRACKET_CLOSE) {
|
||||
return OK;
|
||||
@@ -1173,13 +1210,15 @@ Error VariantParser::_parse_dictionary(Dictionary &object, Stream *p_stream, int
|
||||
|
||||
err = parse_value(token, key, p_stream, line, r_err_str, p_res_parser);
|
||||
|
||||
if (err)
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
err = get_token(p_stream, token, line, r_err_str);
|
||||
|
||||
if (err != OK)
|
||||
if (err != OK) {
|
||||
return err;
|
||||
}
|
||||
if (token.type != TK_COLON) {
|
||||
r_err_str = "Expected ':'";
|
||||
return ERR_PARSE_ERROR;
|
||||
@@ -1187,13 +1226,15 @@ Error VariantParser::_parse_dictionary(Dictionary &object, Stream *p_stream, int
|
||||
at_key = false;
|
||||
} else {
|
||||
Error err = get_token(p_stream, token, line, r_err_str);
|
||||
if (err != OK)
|
||||
if (err != OK) {
|
||||
return err;
|
||||
}
|
||||
|
||||
Variant v;
|
||||
err = parse_value(token, v, p_stream, line, r_err_str, p_res_parser);
|
||||
if (err)
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
object[key] = v;
|
||||
need_comma = true;
|
||||
at_key = true;
|
||||
@@ -1219,8 +1260,9 @@ Error VariantParser::_parse_tag(Token &token, Stream *p_stream, int &line, Strin
|
||||
r_err_str = "Unexpected EOF while parsing simple tag";
|
||||
return ERR_PARSE_ERROR;
|
||||
}
|
||||
if (c == ']')
|
||||
if (c == ']') {
|
||||
break;
|
||||
}
|
||||
r_tag.name += String::chr(c);
|
||||
}
|
||||
|
||||
@@ -1246,8 +1288,9 @@ Error VariantParser::_parse_tag(Token &token, Stream *p_stream, int &line, Strin
|
||||
}
|
||||
|
||||
get_token(p_stream, token, line, r_err_str);
|
||||
if (token.type == TK_BRACKET_CLOSE)
|
||||
if (token.type == TK_BRACKET_CLOSE) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (parsing_tag && token.type == TK_PERIOD) {
|
||||
r_tag.name += "."; //support tags such as [someprop.Android] for specific platforms
|
||||
@@ -1279,8 +1322,9 @@ Error VariantParser::_parse_tag(Token &token, Stream *p_stream, int &line, Strin
|
||||
get_token(p_stream, token, line, r_err_str);
|
||||
Variant value;
|
||||
Error err = parse_value(token, value, p_stream, line, r_err_str, p_res_parser);
|
||||
if (err)
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
r_tag.fields[id] = value;
|
||||
}
|
||||
@@ -1319,8 +1363,9 @@ Error VariantParser::parse_tag_assign_eof(Stream *p_stream, int &line, String &r
|
||||
c = p_stream->get_char();
|
||||
}
|
||||
|
||||
if (p_stream->is_eof())
|
||||
if (p_stream->is_eof()) {
|
||||
return ERR_FILE_EOF;
|
||||
}
|
||||
|
||||
if (c == ';') { //comment
|
||||
while (true) {
|
||||
@@ -1328,8 +1373,9 @@ Error VariantParser::parse_tag_assign_eof(Stream *p_stream, int &line, String &r
|
||||
if (p_stream->is_eof()) {
|
||||
return ERR_FILE_EOF;
|
||||
}
|
||||
if (ch == '\n')
|
||||
if (ch == '\n') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -1348,8 +1394,9 @@ Error VariantParser::parse_tag_assign_eof(Stream *p_stream, int &line, String &r
|
||||
p_stream->saved = '"';
|
||||
Token tk;
|
||||
Error err = get_token(p_stream, tk, line, r_err_str);
|
||||
if (err)
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
if (tk.type != TK_STRING) {
|
||||
r_err_str = "Error reading quoted string";
|
||||
return ERR_INVALID_DATA;
|
||||
@@ -1375,8 +1422,9 @@ Error VariantParser::parse_tag_assign_eof(Stream *p_stream, int &line, String &r
|
||||
Error VariantParser::parse(Stream *p_stream, Variant &r_ret, String &r_err_str, int &r_err_line, ResourceParser *p_res_parser) {
|
||||
Token token;
|
||||
Error err = get_token(p_stream, token, r_err_line, r_err_str);
|
||||
if (err)
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
if (token.type == TK_EOF) {
|
||||
return ERR_FILE_EOF;
|
||||
@@ -1390,10 +1438,11 @@ Error VariantParser::parse(Stream *p_stream, Variant &r_ret, String &r_err_str,
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static String rtosfix(double p_value) {
|
||||
if (p_value == 0.0)
|
||||
if (p_value == 0.0) {
|
||||
return "0"; //avoid negative zero (-0) being written, which may annoy git, svn, etc. for changes when they don't exist.
|
||||
else
|
||||
} else {
|
||||
return rtoss(p_value);
|
||||
}
|
||||
}
|
||||
|
||||
Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_string_func, void *p_store_string_ud, EncodeResourceFunc p_encode_res_func, void *p_encode_res_ud) {
|
||||
@@ -1410,8 +1459,9 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
|
||||
case Variant::FLOAT: {
|
||||
String s = rtosfix(p_variant.operator real_t());
|
||||
if (s != "inf" && s != "nan") {
|
||||
if (s.find(".") == -1 && s.find("e") == -1)
|
||||
if (s.find(".") == -1 && s.find("e") == -1) {
|
||||
s += ".0";
|
||||
}
|
||||
}
|
||||
p_store_string_func(p_store_string_ud, s);
|
||||
} break;
|
||||
@@ -1467,8 +1517,9 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
|
||||
Transform2D m3 = p_variant;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 2; j++) {
|
||||
if (i != 0 || j != 0)
|
||||
if (i != 0 || j != 0) {
|
||||
s += ", ";
|
||||
}
|
||||
s += rtosfix(m3.elements[i][j]);
|
||||
}
|
||||
}
|
||||
@@ -1481,8 +1532,9 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
|
||||
Basis m3 = p_variant;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
if (i != 0 || j != 0)
|
||||
if (i != 0 || j != 0) {
|
||||
s += ", ";
|
||||
}
|
||||
s += rtosfix(m3.elements[i][j]);
|
||||
}
|
||||
}
|
||||
@@ -1496,8 +1548,9 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
|
||||
Basis &m3 = t.basis;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
if (i != 0 || j != 0)
|
||||
if (i != 0 || j != 0) {
|
||||
s += ", ";
|
||||
}
|
||||
s += rtosfix(m3.elements[i][j]);
|
||||
}
|
||||
}
|
||||
@@ -1602,8 +1655,9 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
|
||||
write(E->get(), p_store_string_func, p_store_string_ud, p_encode_res_func, p_encode_res_ud);
|
||||
p_store_string_func(p_store_string_ud, ": ");
|
||||
write(dict[E->get()], p_store_string_func, p_store_string_ud, p_encode_res_func, p_encode_res_ud);
|
||||
if (E->next())
|
||||
if (E->next()) {
|
||||
p_store_string_func(p_store_string_ud, ",\n");
|
||||
}
|
||||
}
|
||||
|
||||
p_store_string_func(p_store_string_ud, "\n}");
|
||||
@@ -1614,8 +1668,9 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
|
||||
Array array = p_variant;
|
||||
int len = array.size();
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (i > 0)
|
||||
if (i > 0) {
|
||||
p_store_string_func(p_store_string_ud, ", ");
|
||||
}
|
||||
write(array[i], p_store_string_func, p_store_string_ud, p_encode_res_func, p_encode_res_ud);
|
||||
}
|
||||
p_store_string_func(p_store_string_ud, " ]");
|
||||
@@ -1630,8 +1685,9 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
|
||||
const uint8_t *ptr = data.ptr();
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (i > 0)
|
||||
if (i > 0) {
|
||||
p_store_string_func(p_store_string_ud, ", ");
|
||||
}
|
||||
|
||||
p_store_string_func(p_store_string_ud, itos(ptr[i]));
|
||||
}
|
||||
@@ -1646,8 +1702,9 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
|
||||
const int32_t *ptr = data.ptr();
|
||||
|
||||
for (int32_t i = 0; i < len; i++) {
|
||||
if (i > 0)
|
||||
if (i > 0) {
|
||||
p_store_string_func(p_store_string_ud, ", ");
|
||||
}
|
||||
|
||||
p_store_string_func(p_store_string_ud, itos(ptr[i]));
|
||||
}
|
||||
@@ -1662,8 +1719,9 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
|
||||
const int64_t *ptr = data.ptr();
|
||||
|
||||
for (int64_t i = 0; i < len; i++) {
|
||||
if (i > 0)
|
||||
if (i > 0) {
|
||||
p_store_string_func(p_store_string_ud, ", ");
|
||||
}
|
||||
|
||||
p_store_string_func(p_store_string_ud, itos(ptr[i]));
|
||||
}
|
||||
@@ -1678,8 +1736,9 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
|
||||
const float *ptr = data.ptr();
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (i > 0)
|
||||
if (i > 0) {
|
||||
p_store_string_func(p_store_string_ud, ", ");
|
||||
}
|
||||
p_store_string_func(p_store_string_ud, rtosfix(ptr[i]));
|
||||
}
|
||||
|
||||
@@ -1693,8 +1752,9 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
|
||||
const double *ptr = data.ptr();
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (i > 0)
|
||||
if (i > 0) {
|
||||
p_store_string_func(p_store_string_ud, ", ");
|
||||
}
|
||||
p_store_string_func(p_store_string_ud, rtosfix(ptr[i]));
|
||||
}
|
||||
|
||||
@@ -1711,8 +1771,9 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
|
||||
//write_string("\n");
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (i > 0)
|
||||
if (i > 0) {
|
||||
p_store_string_func(p_store_string_ud, ", ");
|
||||
}
|
||||
String str = ptr[i];
|
||||
p_store_string_func(p_store_string_ud, "\"" + str.c_escape() + "\"");
|
||||
}
|
||||
@@ -1727,8 +1788,9 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
|
||||
const Vector2 *ptr = data.ptr();
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (i > 0)
|
||||
if (i > 0) {
|
||||
p_store_string_func(p_store_string_ud, ", ");
|
||||
}
|
||||
p_store_string_func(p_store_string_ud, rtosfix(ptr[i].x) + ", " + rtosfix(ptr[i].y));
|
||||
}
|
||||
|
||||
@@ -1742,8 +1804,9 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
|
||||
const Vector3 *ptr = data.ptr();
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (i > 0)
|
||||
if (i > 0) {
|
||||
p_store_string_func(p_store_string_ud, ", ");
|
||||
}
|
||||
p_store_string_func(p_store_string_ud, rtosfix(ptr[i].x) + ", " + rtosfix(ptr[i].y) + ", " + rtosfix(ptr[i].z));
|
||||
}
|
||||
|
||||
@@ -1758,8 +1821,9 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
|
||||
const Color *ptr = data.ptr();
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (i > 0)
|
||||
if (i > 0) {
|
||||
p_store_string_func(p_store_string_ud, ", ");
|
||||
}
|
||||
|
||||
p_store_string_func(p_store_string_ud, rtosfix(ptr[i].r) + ", " + rtosfix(ptr[i].g) + ", " + rtosfix(ptr[i].b) + ", " + rtosfix(ptr[i].a));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user