summaryrefslogtreecommitdiff
path: root/core/callable.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/callable.cpp')
-rw-r--r--core/callable.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/core/callable.cpp b/core/callable.cpp
index b7bdc715f8..c368565687 100644
--- a/core/callable.cpp
+++ b/core/callable.cpp
@@ -30,6 +30,7 @@
#include "callable.h"
+#include "callable_bind.h"
#include "core/script_language.h"
#include "message_queue.h"
#include "object.h"
@@ -53,6 +54,18 @@ void Callable::call(const Variant **p_arguments, int p_argcount, Variant &r_retu
}
}
+Callable Callable::bind(const Variant **p_arguments, int p_argcount) const {
+ Vector<Variant> args;
+ args.resize(p_argcount);
+ for (int i = 0; i < p_argcount; i++) {
+ args.write[i] = *p_arguments[i];
+ }
+ return Callable(memnew(CallableCustomBind(*this, args)));
+}
+Callable Callable::unbind(int p_argcount) const {
+ return Callable(memnew(CallableCustomUnbind(*this, p_argcount)));
+}
+
Object *Callable::get_object() const {
if (is_null()) {
return nullptr;
@@ -85,6 +98,18 @@ CallableCustom *Callable::get_custom() const {
return custom;
}
+const Callable *Callable::get_base_comparator() const {
+ const Callable *comparator = nullptr;
+ if (is_custom()) {
+ comparator = custom->get_base_comparator();
+ }
+ if (comparator) {
+ return comparator;
+ } else {
+ return this;
+ }
+}
+
uint32_t Callable::hash() const {
if (is_custom()) {
return custom->hash();
@@ -258,6 +283,10 @@ Callable::~Callable() {
}
}
+const Callable *CallableCustom::get_base_comparator() const {
+ return nullptr;
+}
+
CallableCustom::CallableCustom() {
ref_count.init();
}