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

Method weakref

core/variant/variant_utility.cpp:868–896  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

866// Utility
867
868Variant VariantUtilityFunctions::weakref(Callable::CallError &r_error, const Variant &obj) {
869 if (obj.get_type() == Variant::OBJECT) {
870 r_error.error = Callable::CallError::CALL_OK;
871 if (obj.is_ref_counted()) {
872 Ref<WeakRef> wref = memnew(WeakRef);
873 Ref<RefCounted> r = obj;
874 if (r.is_valid()) {
875 wref->set_ref(r);
876 }
877 return wref;
878 } else {
879 Ref<WeakRef> wref = memnew(WeakRef);
880 Object *o = obj.get_validated_object();
881 if (o) {
882 wref->set_obj(o);
883 }
884 return wref;
885 }
886 } else if (obj.get_type() == Variant::NIL) {
887 r_error.error = Callable::CallError::CALL_OK;
888 Ref<WeakRef> wref = memnew(WeakRef);
889 return wref;
890 } else {
891 r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
892 r_error.argument = 0;
893 r_error.expected = Variant::OBJECT;
894 return Variant();
895 }
896}
897
898int64_t VariantUtilityFunctions::_typeof(const Variant &obj) {
899 return obj.get_type();

Callers

nothing calls this directly

Calls 7

set_refMethod · 0.80
get_validated_objectMethod · 0.80
set_objMethod · 0.80
VariantClass · 0.70
get_typeMethod · 0.45
is_ref_countedMethod · 0.45
is_validMethod · 0.45

Tested by

no test coverage detected