summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2021-08-23 22:30:43 -0300
committerGitHub <noreply@github.com>2021-08-23 22:30:43 -0300
commit13bd020a23008cd4e51be21865c620e12e3b3ded (patch)
tree0de866fe3b53b3d6a51bf1e52a808c628802ff7e /core
parent770a1d00a3b14c4abd1cd57c9621de93b24478aa (diff)
parent65ca132a80760be9f4c0fe1a175445e867bb7ac8 (diff)
Merge pull request #52045 from reduz/expose-rid-creation-utilities
Expose RID creation utilities.
Diffstat (limited to 'core')
-rw-r--r--core/templates/rid_owner.h10
-rw-r--r--core/variant/variant_utility.cpp12
2 files changed, 18 insertions, 4 deletions
diff --git a/core/templates/rid_owner.h b/core/templates/rid_owner.h
index 8d139551ef..e947d2211c 100644
--- a/core/templates/rid_owner.h
+++ b/core/templates/rid_owner.h
@@ -53,14 +53,16 @@ protected:
return rid;
}
- static uint64_t _gen_id() {
- return base_id.increment();
- }
-
static RID _gen_rid() {
return _make_from_id(_gen_id());
}
+ friend struct VariantUtilityFunctions;
+
+ static uint64_t _gen_id() {
+ return base_id.increment();
+ }
+
public:
virtual ~RID_AllocBase() {}
};
diff --git a/core/variant/variant_utility.cpp b/core/variant/variant_utility.cpp
index 6c57d1de10..f5cb2d40d6 100644
--- a/core/variant/variant_utility.cpp
+++ b/core/variant/variant_utility.cpp
@@ -35,6 +35,8 @@
#include "core/object/ref_counted.h"
#include "core/os/os.h"
#include "core/templates/oa_hash_map.h"
+#include "core/templates/rid.h"
+#include "core/templates/rid_owner.h"
#include "core/variant/binder_common.h"
#include "core/variant/variant_parser.h"
@@ -728,6 +730,13 @@ struct VariantUtilityFunctions {
}
return p_instance.get_validated_object() != nullptr;
}
+
+ static inline uint64_t rid_allocate_id() {
+ return RID_AllocBase::_gen_id();
+ }
+ static inline RID rid_from_int64(uint64_t p_base) {
+ return RID::from_uint64(p_base);
+ }
};
#ifdef DEBUG_METHODS_ENABLED
@@ -1265,6 +1274,9 @@ void Variant::_register_variant_utility_functions() {
FUNCBINDR(instance_from_id, sarray("instance_id"), Variant::UTILITY_FUNC_TYPE_GENERAL);
FUNCBINDR(is_instance_id_valid, sarray("id"), Variant::UTILITY_FUNC_TYPE_GENERAL);
FUNCBINDR(is_instance_valid, sarray("instance"), Variant::UTILITY_FUNC_TYPE_GENERAL);
+
+ FUNCBINDR(rid_allocate_id, Vector<String>(), Variant::UTILITY_FUNC_TYPE_GENERAL);
+ FUNCBINDR(rid_from_int64, sarray("base"), Variant::UTILITY_FUNC_TYPE_GENERAL);
}
void Variant::_unregister_variant_utility_functions() {