diff options
Diffstat (limited to 'core/variant_parser.cpp')
-rw-r--r-- | core/variant_parser.cpp | 241 |
1 files changed, 0 insertions, 241 deletions
diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp index 234156d39f..798a830dd0 100644 --- a/core/variant_parser.cpp +++ b/core/variant_parser.cpp @@ -504,39 +504,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream, return OK; } else if (token.type == TK_IDENTIFIER) { - /* - VECTOR2, // 5 - RECT2, - VECTOR3, - MATRIX32, - PLANE, - QUAT, // 10 - _AABB, //sorry naming convention fail :( not like it's used often - MATRIX3, - TRANSFORM, - // misc types - COLOR, - IMAGE, // 15 - NODE_PATH, - _RID, - OBJECT, - INPUT_EVENT, - DICTIONARY, // 20 - ARRAY, - - // arrays - RAW_ARRAY, - INT_ARRAY, - REAL_ARRAY, - STRING_ARRAY, // 25 - VECTOR2_ARRAY, - VECTOR3_ARRAY, - COLOR_ARRAY, - - VARIANT_MAX - -*/ String id = token.value; if (id == "true") value = true; @@ -681,126 +649,6 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream, value = Color(args[0], args[1], args[2], args[3]); return OK; - } else if (id == "Image") { - - //:| - - get_token(p_stream, token, line, r_err_str); - if (token.type != TK_PARENTHESIS_OPEN) { - r_err_str = "Expected '('"; - return ERR_PARSE_ERROR; - } - - get_token(p_stream, token, line, r_err_str); - if (token.type == TK_PARENTHESIS_CLOSE) { - value = Image(); // just an Image() - return OK; - } else if (token.type != TK_NUMBER) { - r_err_str = "Expected number (width)"; - return ERR_PARSE_ERROR; - } - - get_token(p_stream, token, line, r_err_str); - - int width = token.value; - if (token.type != TK_COMMA) { - r_err_str = "Expected ','"; - return ERR_PARSE_ERROR; - } - - get_token(p_stream, token, line, r_err_str); - if (token.type != TK_NUMBER) { - r_err_str = "Expected number (height)"; - return ERR_PARSE_ERROR; - } - - int height = token.value; - - get_token(p_stream, token, line, r_err_str); - if (token.type != TK_COMMA) { - r_err_str = "Expected ','"; - return ERR_PARSE_ERROR; - } - - get_token(p_stream, token, line, r_err_str); - - bool has_mipmaps = false; - - if (token.type == TK_NUMBER) { - has_mipmaps = bool(token.value); - } else if (token.type == TK_IDENTIFIER && String(token.value) == "true") { - has_mipmaps = true; - } else if (token.type == TK_IDENTIFIER && String(token.value) == "false") { - has_mipmaps = false; - } else { - r_err_str = "Expected number/true/false (mipmaps)"; - return ERR_PARSE_ERROR; - } - - int mipmaps = token.value; - - get_token(p_stream, token, line, r_err_str); - if (token.type != TK_COMMA) { - r_err_str = "Expected ','"; - return ERR_PARSE_ERROR; - } - - get_token(p_stream, token, line, r_err_str); - if (token.type != TK_IDENTIFIER) { - r_err_str = "Expected identifier (format)"; - return ERR_PARSE_ERROR; - } - - String sformat = token.value; - - Image::Format format = Image::FORMAT_MAX; - - for (int i = 0; i < Image::FORMAT_MAX; i++) { - if (Image::get_format_name(Image::Format(i)) == sformat) { - format = Image::Format(i); - } - } - - if (format == Image::FORMAT_MAX) { - r_err_str = "Unknown image format: " + String(sformat); - return ERR_PARSE_ERROR; - } - - int len = Image::get_image_data_size(width, height, format, mipmaps); - - PoolVector<uint8_t> buffer; - buffer.resize(len); - - if (buffer.size() != len) { - r_err_str = "Couldn't allocate image buffer of size: " + itos(len); - } - - { - PoolVector<uint8_t>::Write w = buffer.write(); - - for (int i = 0; i < len; i++) { - get_token(p_stream, token, line, r_err_str); - if (token.type != TK_COMMA) { - r_err_str = "Expected ','"; - return ERR_PARSE_ERROR; - } - - get_token(p_stream, token, line, r_err_str); - if (token.type != TK_NUMBER) { - r_err_str = "Expected number"; - return ERR_PARSE_ERROR; - } - - w[i] = int(token.value); - } - } - - Image img(width, height, mipmaps, format, buffer); - - value = img; - - return OK; - } else if (id == "NodePath") { get_token(p_stream, token, line, r_err_str); @@ -1357,68 +1205,12 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream, value = ie; return OK; - } else if (id == "img") { // compatibility with project.godot - - Token token; // FIXME: no need for this declaration? the first argument in line 509 is a Token& token. - get_token(p_stream, token, line, r_err_str); - if (token.type != TK_PARENTHESIS_OPEN) { - r_err_str = "Expected '(' in old-style project.godot construct"; - return ERR_PARSE_ERROR; - } - - while (true) { - CharType c = p_stream->get_char(); - if (p_stream->is_eof()) { - r_err_str = "Unexpected EOF in old style project.godot img()"; - return ERR_PARSE_ERROR; - } - if (c == ')') - break; - } - - value = Image(); - - return OK; } else { r_err_str = "Unexpected identifier: '" + id + "'."; return ERR_PARSE_ERROR; } - /* - VECTOR2, // 5 - RECT2, - VECTOR3, - MATRIX32, - PLANE, - QUAT, // 10 - _AABB, //sorry naming convention fail :( not like it's used often - MATRIX3, - TRANSFORM, - - // misc types - COLOR, - IMAGE, // 15 - NODE_PATH, - _RID, - OBJECT, - INPUT_EVENT, - DICTIONARY, // 20 - ARRAY, - - // arrays - RAW_ARRAY, - INT_ARRAY, - REAL_ARRAY, - STRING_ARRAY, // 25 - VECTOR2_ARRAY, - VECTOR3_ARRAY, - COLOR_ARRAY, - - VARIANT_MAX - - */ - return OK; } else if (token.type == TK_NUMBER) { @@ -1886,39 +1678,6 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str p_store_string_func(p_store_string_ud, "Color( " + rtosfix(c.r) + ", " + rtosfix(c.g) + ", " + rtosfix(c.b) + ", " + rtosfix(c.a) + " )"); } break; - case Variant::IMAGE: { - - Image img = p_variant; - - if (img.empty()) { - p_store_string_func(p_store_string_ud, "Image()"); - break; - } - - String imgstr = "Image( "; - imgstr += itos(img.get_width()); - imgstr += ", " + itos(img.get_height()); - imgstr += ", " + String(img.has_mipmaps() ? "true" : "false"); - imgstr += ", " + Image::get_format_name(img.get_format()); - - String s; - - PoolVector<uint8_t> data = img.get_data(); - int len = data.size(); - PoolVector<uint8_t>::Read r = data.read(); - const uint8_t *ptr = r.ptr(); - for (int i = 0; i < len; i++) { - - if (i > 0) - s += ", "; - s += itos(ptr[i]); - } - - imgstr += ", "; - p_store_string_func(p_store_string_ud, imgstr); - p_store_string_func(p_store_string_ud, s); - p_store_string_func(p_store_string_ud, " )"); - } break; case Variant::NODE_PATH: { String str = p_variant; |