Skip to content

Commit

Permalink
Removed my added compatibility methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
nlupugla committed Sep 18, 2024
1 parent b295f0c commit 820ba4a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 103 deletions.
62 changes: 0 additions & 62 deletions core/core_bind.compat.inc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
/**************************************************************************/

#ifndef DISABLE_DEPRECATED
#include "core_bind.h"

namespace core_bind {

Expand All @@ -53,67 +52,6 @@ void OS::_bind_compatibility_methods() {
ClassDB::bind_compatibility_method(D_METHOD("execute_with_pipe", "path", "arguments"), &OS::_execute_with_pipe_bind_compat_94434);
}

// ClassDB

namespace special {

Dictionary ClassDB::class_get_signal_compat_82198(const StringName &p_class, const StringName &p_signal) const {
MethodInfo signal;
if (::ClassDB::get_signal(p_class, p_signal, &signal)) {
return signal.operator Dictionary();
} else {
return Dictionary();
}
}

TypedArray<Dictionary> ClassDB::class_get_signal_list_compat_82198(const StringName &p_class, bool p_no_inheritance) const {
List<MethodInfo> signals;
::ClassDB::get_signal_list(p_class, &signals, p_no_inheritance);
TypedArray<Dictionary> ret;

for (const MethodInfo &E : signals) {
ret.push_back(E.operator Dictionary());
}

return ret;
}

TypedArray<Dictionary> ClassDB::class_get_property_list_compat_82198(const StringName &p_class, bool p_no_inheritance) const {
List<PropertyInfo> plist;
::ClassDB::get_property_list(p_class, &plist, p_no_inheritance);
TypedArray<Dictionary> ret;
for (const PropertyInfo &E : plist) {
ret.push_back(E.operator Dictionary());
}

return ret;
}

TypedArray<Dictionary> ClassDB::class_get_method_list_compat_82198(const StringName &p_class, bool p_no_inheritance) const {
List<MethodInfo> methods;
::ClassDB::get_method_list(p_class, &methods, p_no_inheritance);
TypedArray<Dictionary> ret;

for (const MethodInfo &E : methods) {
#ifdef DEBUG_METHODS_ENABLED
ret.push_back(E.operator Dictionary());
#else
Dictionary dict;
dict["name"] = E.name;
ret.push_back(dict);
#endif
}

return ret;
}

void ClassDB::_bind_compatibility_methods() {
::ClassDB::bind_compatibility_method(D_METHOD("class_get_signal", "class", "signal"), &ClassDB::class_get_signal_compat_82198);
::ClassDB::bind_compatibility_method(D_METHOD("class_get_signal_list", "class", "no_inheritance"), &ClassDB::class_get_signal_list_compat_82198, DEFVAL(false));
::ClassDB::bind_compatibility_method(D_METHOD("class_get_property_list", "class", "no_inheritance"), &ClassDB::class_get_property_list_compat_82198, DEFVAL(false));
::ClassDB::bind_compatibility_method(D_METHOD("class_get_method_list", "class", "no_inheritance"), &ClassDB::class_get_method_list_compat_82198, DEFVAL(false));
}
} // namespace special
} // namespace core_bind

#endif // DISABLE_DEPRECATED
8 changes: 0 additions & 8 deletions core/core_bind.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,6 @@ class ClassDB : public Object {

protected:
static void _bind_methods();
static void _bind_compatibility_methods();

public:
PackedStringArray get_class_list() const;
Expand Down Expand Up @@ -496,13 +495,6 @@ class ClassDB : public Object {
TypedArray<Dictionary> class_get_struct_list(const StringName &p_class, bool p_no_inheritance = false) const;
TypedArray<Dictionary> class_get_struct_members(const StringName &p_class, const StringName &p_struct) const;

#ifndef DISABLE_DEPRECATED
Dictionary class_get_signal_compat_82198(const StringName &p_class, const StringName &p_signal) const;
TypedArray<Dictionary> class_get_signal_list_compat_82198(const StringName &p_class, bool p_no_inheritance = false) const;
TypedArray<Dictionary> class_get_property_list_compat_82198(const StringName &p_class, bool p_no_inheritance = false) const;
TypedArray<Dictionary> class_get_method_list_compat_82198(const StringName &p_class, bool p_no_inheritance = false) const;
#endif

#ifdef TOOLS_ENABLED
virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;
#endif
Expand Down
10 changes: 0 additions & 10 deletions core/object/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,12 +417,6 @@ class Object {
TypedArray<Struct<MethodInfo>> _get_signal_list_as_structs() const;
TypedArray<Struct<Connection>> _get_signal_connection_list_as_structs(const StringName &p_signal) const;
TypedArray<Struct<Connection>> _get_incoming_connections_as_structs() const;
#ifndef DISABLE_DEPRECATED
void _add_user_signal_compat_82198(const String &p_name, const Array &p_args = Array());
TypedArray<Dictionary> _get_signal_list_compat_82198() const;
TypedArray<Dictionary> _get_signal_connection_list_compat_82198(const StringName &p_signal) const;
TypedArray<Dictionary> _get_incoming_connections_compat_82198() const;
#endif
void _set_bind(const StringName &p_set, const Variant &p_value);
Variant _get_bind(const StringName &p_name) const;
void _set_indexed_bind(const NodePath &p_name, const Variant &p_value);
Expand Down Expand Up @@ -530,10 +524,6 @@ class Object {
TypedArray<Struct<PropertyInfo>> _get_property_list_as_structs_bind() const;
TypedArray<Dictionary> _get_method_list_bind() const;
TypedArray<Struct<MethodInfo>> _get_method_list_as_structs_bind() const;
#ifndef DISABLE_DEPRECATED
TypedArray<Dictionary> _get_property_list_bind_compat_82198() const;
TypedArray<Dictionary> _get_method_list_bind_compat_82198() const;
#endif

void _clear_internal_resource_paths(const Variant &p_var);

Expand Down
5 changes: 3 additions & 2 deletions core/variant/container_type_validate.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ struct ContainerTypeValidate {
Ref<Script> script;

bool is_array_of_structs = false;
const StructInfo *struct_info; // TODO: if is_array_of_structs == true, then require struct_info != nullptr, but not sure the best way to enforce this.
const StructInfo *struct_info = nullptr; // TODO: if is_array_of_structs == true, then require struct_info != nullptr, but not sure the best way to enforce this.
const char *where = "container";

ContainerTypeValidate(const Variant::Type p_type = Variant::NIL, const StringName &p_class_name = StringName(), const Ref<Script> &p_script = Ref<Script>(), const char *p_where = "container") {
ContainerTypeValidate(){};
ContainerTypeValidate(const Variant::Type p_type, const StringName &p_class_name, const Ref<Script> &p_script, const char *p_where = "container") {
type = p_type;
class_name = p_class_name;
script = p_script;
Expand Down
42 changes: 21 additions & 21 deletions core/variant/dictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,48 +86,48 @@ Variant Dictionary::get_value_at_index(int p_index) const {
// WARNING: This operator does not validate the value type. For scripting/extensions this is
// done in `variant_setget.cpp`. Consider using `set()` if the data might be invalid.
Variant &Dictionary::operator[](const Variant &p_key) {
Variant key = p_key;
if (unlikely(!_p->typed_key.validate(key, "use `operator[]`"))) {
ValidatedVariant validated_key = _p->typed_key.validate(p_key, "use `operator[]`");
if (unlikely(!validated_key.valid)) {
if (unlikely(!_p->typed_fallback)) {
_p->typed_fallback = memnew(Variant);
}
VariantInternal::initialize(_p->typed_fallback, _p->typed_value.type);
return *_p->typed_fallback;
} else if (unlikely(_p->read_only)) {
if (likely(_p->variant_map.has(key))) {
*_p->read_only = _p->variant_map[key];
if (likely(_p->variant_map.has(validated_key.value))) {
*_p->read_only = _p->variant_map[validated_key.value];
} else {
VariantInternal::initialize(_p->read_only, _p->typed_value.type);
}
return *_p->read_only;
} else {
if (unlikely(!_p->variant_map.has(key))) {
VariantInternal::initialize(&_p->variant_map[key], _p->typed_value.type);
if (unlikely(!_p->variant_map.has(validated_key.value))) {
VariantInternal::initialize(&_p->variant_map[validated_key.value], _p->typed_value.type);
}
return _p->variant_map[key];
return _p->variant_map[validated_key.value];
}
}

const Variant &Dictionary::operator[](const Variant &p_key) const {
Variant key = p_key;
if (unlikely(!_p->typed_key.validate(key, "use `operator[]`"))) {
ValidatedVariant validated_key = _p->typed_key.validate(p_key, "use `operator[]`");
if (unlikely(!validated_key.valid)) {
if (unlikely(!_p->typed_fallback)) {
_p->typed_fallback = memnew(Variant);
}
VariantInternal::initialize(_p->typed_fallback, _p->typed_value.type);
return *_p->typed_fallback;
} else {
// Will not insert key, so no initialization is necessary.
return _p->variant_map[key];
return _p->variant_map[validated_key.value];
}
}

const Variant *Dictionary::getptr(const Variant &p_key) const {
Variant key = p_key;
if (unlikely(!_p->typed_key.validate(key, "getptr"))) {
ValidatedVariant validated_key = _p->typed_key.validate(p_key, "getptr");
if (unlikely(!validated_key.valid)) {
return nullptr;
}
HashMap<Variant, Variant, VariantHasher, StringLikeVariantComparator>::ConstIterator E(_p->variant_map.find(key));
HashMap<Variant, Variant, VariantHasher, StringLikeVariantComparator>::ConstIterator E(_p->variant_map.find(validated_key.value));
if (!E) {
return nullptr;
}
Expand All @@ -136,11 +136,11 @@ const Variant *Dictionary::getptr(const Variant &p_key) const {

// WARNING: This method does not validate the value type.
Variant *Dictionary::getptr(const Variant &p_key) {
Variant key = p_key;
if (unlikely(!_p->typed_key.validate(key, "getptr"))) {
ValidatedVariant validated_key = _p->typed_key.validate(p_key, "getptr");
if (unlikely(!validated_key.valid)) {
return nullptr;
}
HashMap<Variant, Variant, VariantHasher, StringLikeVariantComparator>::Iterator E(_p->variant_map.find(key));
HashMap<Variant, Variant, VariantHasher, StringLikeVariantComparator>::Iterator E(_p->variant_map.find(validated_key.value));
if (!E) {
return nullptr;
}
Expand Down Expand Up @@ -191,11 +191,11 @@ Variant Dictionary::get_or_add(const Variant &p_key, const Variant &p_default) {

bool Dictionary::set(const Variant &p_key, const Variant &p_value) {
ERR_FAIL_COND_V_MSG(_p->read_only, false, "Dictionary is in read-only state.");
Variant key = p_key;
ERR_FAIL_COND_V(!_p->typed_key.validate(key, "set"), false);
Variant value = p_value;
ERR_FAIL_COND_V(!_p->typed_value.validate(value, "set"), false);
_p->variant_map[key] = value;
ValidatedVariant validated_key = _p->typed_key.validate(p_key, "set");
ERR_FAIL_COND_V(!validated_key.valid, false);
ValidatedVariant validated_value = _p->typed_value.validate(p_value, "set");
ERR_FAIL_COND_V(!validated_value.valid, false);
_p->variant_map[validated_key.value] = validated_value.value;
return true;
}

Expand Down

0 comments on commit 820ba4a

Please sign in to comment.