MCPcopy Create free account
hub / github.com/GDRETools/gdsdecomp / parse_value

Method parse_value

compat/variant_writer_compat.cpp:218–706  ·  view source on GitHub ↗

Primarily for parsing V3 input event objects stored in project.godot The only other Objects that get stored inline in text resources that we know of are Position3D objects, and those are unchanged from Godot 2.x

Source from the content-addressed store, hash-verified

216// The only other Objects that get stored inline in text resources that we know of are Position3D objects,
217// and those are unchanged from Godot 2.x
218Error VariantParserCompat::parse_value(VariantParser::Token &token, Variant &r_value, VariantParser::Stream *p_stream, int &line, String &r_err_str, VariantParser::ResourceParser *p_res_parser) {
219 // Since Arrays and Dictionaries can have Objects inside of them...
220 if (token.type == TK_CURLY_BRACKET_OPEN) {
221 Dictionary d;
222 Error err = _parse_dictionary(d, p_stream, line, r_err_str, p_res_parser);
223 if (err) {
224 return err;
225 }
226 r_value = d;
227 return OK;
228 } else if (token.type == TK_BRACKET_OPEN) {
229 Array a;
230 Error err = _parse_array(a, p_stream, line, r_err_str, p_res_parser);
231 if (err) {
232 return err;
233 }
234 r_value = a;
235 return OK;
236 } else if (token.type == TK_IDENTIFIER) {
237 String id = token.value;
238 if (id == "Object") {
239 get_token(p_stream, token, line, r_err_str);
240 if (token.type != TK_PARENTHESIS_OPEN) {
241 r_err_str = "Expected '('";
242 return ERR_PARSE_ERROR;
243 }
244
245 get_token(p_stream, token, line, r_err_str);
246
247 if (token.type != TK_IDENTIFIER) {
248 r_err_str = "Expected identifier with type of object";
249 return ERR_PARSE_ERROR;
250 }
251
252 String type = token.value;
253 // TODO: Need to make ParserCompat take in a ver_major so we can make use of the converters; as it stands, this rarely ever is needed
254 // hacks for v3 input_event
255 bool v3_input_key_hacks = InputEventConverterCompat::handles_type_static(type, 3);
256 Object *obj = ClassDB::instantiate(type);
257
258 if (!obj) {
259 r_err_str = "Can't instantiate Object() of type: " + type;
260 return ERR_PARSE_ERROR;
261 }
262
263 Ref<RefCounted> ref = Ref<RefCounted>(Object::cast_to<RefCounted>(obj));
264
265 get_token(p_stream, token, line, r_err_str);
266 if (token.type != TK_COMMA) {
267 r_err_str = "Expected ',' after object type";
268 return ERR_PARSE_ERROR;
269 }
270
271 bool at_key = true;
272 String key;
273 Token token2;
274 bool need_comma = false;
275

Callers

nothing calls this directly

Calls 7

setMethod · 0.80
assignMethod · 0.80
is_validMethod · 0.45
getMethod · 0.45
get_typeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected