MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / _static_default_init

Method _static_default_init

modules/gdscript/gdscript.cpp:701–726  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

699}
700
701void GDScript::_static_default_init() {
702 for (const KeyValue<StringName, MemberInfo> &E : static_variables_indices) {
703 const GDScriptDataType &type = E.value.data_type;
704 // Only initialize builtin types, which are not expected to be `null`.
705 if (!type.has_type || type.kind != GDScriptDataType::BUILTIN) {
706 continue;
707 }
708 if (type.builtin_type == Variant::ARRAY && type.has_container_element_type(0)) {
709 const GDScriptDataType element_type = type.get_container_element_type(0);
710 Array default_value;
711 default_value.set_typed(element_type.builtin_type, element_type.native_type, element_type.script_type);
712 static_variables.write[E.value.index] = default_value;
713 } else if (type.builtin_type == Variant::DICTIONARY && type.has_container_element_types()) {
714 const GDScriptDataType key_type = type.get_container_element_type_or_variant(0);
715 const GDScriptDataType value_type = type.get_container_element_type_or_variant(1);
716 Dictionary default_value;
717 default_value.set_typed(key_type.builtin_type, key_type.native_type, key_type.script_type, value_type.builtin_type, value_type.native_type, value_type.script_type);
718 static_variables.write[E.value.index] = default_value;
719 } else {
720 Variant default_value;
721 Callable::CallError err;
722 Variant::construct(type.builtin_type, default_value, nullptr, 0, err);
723 static_variables.write[E.value.index] = default_value;
724 }
725 }
726}
727
728#ifdef TOOLS_ENABLED
729

Callers 1

_compile_classMethod · 0.80

Tested by

no test coverage detected