You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-08 12:40:44 +00:00
Change get_class_static to return StringName.
Use that static `get_class_static` for `_get_class_namev` to avoid duplication.
This commit is contained in:
@@ -1345,7 +1345,7 @@ static Error _encode_container_type(const ContainerType &p_type, uint8_t *&buf,
|
|||||||
_encode_string(EncodedObjectAsID::get_class_static(), buf, r_len);
|
_encode_string(EncodedObjectAsID::get_class_static(), buf, r_len);
|
||||||
}
|
}
|
||||||
} else if (p_type.class_name != StringName()) {
|
} else if (p_type.class_name != StringName()) {
|
||||||
_encode_string(p_full_objects ? p_type.class_name.operator String() : EncodedObjectAsID::get_class_static(), buf, r_len);
|
_encode_string(p_full_objects ? p_type.class_name : EncodedObjectAsID::get_class_static(), buf, r_len);
|
||||||
} else {
|
} else {
|
||||||
// No need to check `p_full_objects` since `class_name` should be non-empty for `builtin_type == Variant::OBJECT`.
|
// No need to check `p_full_objects` since `class_name` should be non-empty for `builtin_type == Variant::OBJECT`.
|
||||||
if (buf) {
|
if (buf) {
|
||||||
|
|||||||
@@ -419,14 +419,14 @@ private:
|
|||||||
public: \
|
public: \
|
||||||
static constexpr bool _class_is_enabled = !bool(GD_IS_DEFINED(ClassDB_Disable_##m_class)) && m_inherits::_class_is_enabled; \
|
static constexpr bool _class_is_enabled = !bool(GD_IS_DEFINED(ClassDB_Disable_##m_class)) && m_inherits::_class_is_enabled; \
|
||||||
virtual const StringName *_get_class_namev() const override { \
|
virtual const StringName *_get_class_namev() const override { \
|
||||||
|
return &get_class_static(); \
|
||||||
|
} \
|
||||||
|
static const StringName &get_class_static() { \
|
||||||
static StringName _class_name_static; \
|
static StringName _class_name_static; \
|
||||||
if (unlikely(!_class_name_static)) { \
|
if (unlikely(!_class_name_static)) { \
|
||||||
StringName::assign_static_unique_class_name(&_class_name_static, #m_class); \
|
StringName::assign_static_unique_class_name(&_class_name_static, #m_class); \
|
||||||
} \
|
} \
|
||||||
return &_class_name_static; \
|
return _class_name_static; \
|
||||||
} \
|
|
||||||
static _FORCE_INLINE_ String get_class_static() { \
|
|
||||||
return String(#m_class); \
|
|
||||||
} \
|
} \
|
||||||
virtual bool is_class(const String &p_class) const override { \
|
virtual bool is_class(const String &p_class) const override { \
|
||||||
if (_get_extension() && _get_extension()->is_class(p_class)) { \
|
if (_get_extension() && _get_extension()->is_class(p_class)) { \
|
||||||
@@ -739,11 +739,7 @@ protected:
|
|||||||
Variant _call_deferred_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
|
Variant _call_deferred_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
|
||||||
|
|
||||||
virtual const StringName *_get_class_namev() const {
|
virtual const StringName *_get_class_namev() const {
|
||||||
static StringName _class_name_static;
|
return &get_class_static();
|
||||||
if (unlikely(!_class_name_static)) {
|
|
||||||
StringName::assign_static_unique_class_name(&_class_name_static, "Object");
|
|
||||||
}
|
|
||||||
return &_class_name_static;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TypedArray<StringName> _get_meta_list_bind() const;
|
TypedArray<StringName> _get_meta_list_bind() const;
|
||||||
@@ -811,7 +807,13 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* TYPE API */
|
/* TYPE API */
|
||||||
static String get_class_static() { return "Object"; }
|
static const StringName &get_class_static() {
|
||||||
|
static StringName _class_name_static;
|
||||||
|
if (unlikely(!_class_name_static)) {
|
||||||
|
StringName::assign_static_unique_class_name(&_class_name_static, "Object");
|
||||||
|
}
|
||||||
|
return _class_name_static;
|
||||||
|
}
|
||||||
|
|
||||||
_FORCE_INLINE_ String get_class() const { return get_class_name(); }
|
_FORCE_INLINE_ String get_class() const { return get_class_name(); }
|
||||||
|
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ void GDScriptDocGen::_doctype_from_gdtype(const GDType &p_gdtype, String &r_type
|
|||||||
return;
|
return;
|
||||||
case GDType::SCRIPT:
|
case GDType::SCRIPT:
|
||||||
if (p_gdtype.is_meta_type) {
|
if (p_gdtype.is_meta_type) {
|
||||||
r_type = p_gdtype.script_type.is_valid() ? p_gdtype.script_type->get_class() : Script::get_class_static();
|
r_type = p_gdtype.script_type.is_valid() ? p_gdtype.script_type->get_class_name() : Script::get_class_static();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (p_gdtype.script_type.is_valid()) {
|
if (p_gdtype.script_type.is_valid()) {
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ GDScriptDataType GDScriptCompiler::_gdtype_from_datatype(const GDScriptParser::D
|
|||||||
if (p_handle_metatype && p_datatype.is_meta_type) {
|
if (p_handle_metatype && p_datatype.is_meta_type) {
|
||||||
result.kind = GDScriptDataType::NATIVE;
|
result.kind = GDScriptDataType::NATIVE;
|
||||||
result.builtin_type = Variant::OBJECT;
|
result.builtin_type = Variant::OBJECT;
|
||||||
result.native_type = p_datatype.script_type.is_valid() ? p_datatype.script_type->get_class() : Script::get_class_static();
|
result.native_type = p_datatype.script_type.is_valid() ? p_datatype.script_type->get_class_name() : Script::get_class_static();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4357,7 +4357,7 @@ static StringName _find_narrowest_native_or_global_class(const GDScriptParser::D
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (p_type.is_meta_type) {
|
if (p_type.is_meta_type) {
|
||||||
return script.is_valid() ? script->get_class() : Script::get_class_static();
|
return script.is_valid() ? script->get_class_name() : Script::get_class_static();
|
||||||
}
|
}
|
||||||
if (script.is_null()) {
|
if (script.is_null()) {
|
||||||
return p_type.native_type;
|
return p_type.native_type;
|
||||||
@@ -5257,7 +5257,7 @@ PropertyInfo GDScriptParser::DataType::to_property_info(const String &p_name) co
|
|||||||
case SCRIPT:
|
case SCRIPT:
|
||||||
result.type = Variant::OBJECT;
|
result.type = Variant::OBJECT;
|
||||||
if (is_meta_type) {
|
if (is_meta_type) {
|
||||||
result.class_name = script_type.is_valid() ? script_type->get_class() : Script::get_class_static();
|
result.class_name = script_type.is_valid() ? script_type->get_class_name() : Script::get_class_static();
|
||||||
} else if (script_type.is_valid() && script_type->get_global_name() != StringName()) {
|
} else if (script_type.is_valid() && script_type->get_global_name() != StringName()) {
|
||||||
result.class_name = script_type->get_global_name();
|
result.class_name = script_type->get_global_name();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user