summaryrefslogtreecommitdiff
path: root/core/class_db.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/class_db.h')
-rw-r--r--core/class_db.h39
1 files changed, 32 insertions, 7 deletions
diff --git a/core/class_db.h b/core/class_db.h
index 092469beb7..398eca9132 100644
--- a/core/class_db.h
+++ b/core/class_db.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,13 +35,15 @@
#include "core/object.h"
#include "core/print_string.h"
-/** To bind more then 6 parameters include this:
+/** To bind more then 6 parameters include this:
* #include "core/method_bind_ext.gen.inc"
*/
-#define DEFVAL(m_defval) (m_defval)
+// Makes callable_mp readily available in all classes connecting signals.
+// Needs to come after method_bind and object have been included.
+#include "core/callable_method_pointer.h"
-//#define SIMPLE_METHODDEF
+#define DEFVAL(m_defval) (m_defval)
#ifdef DEBUG_METHODS_ENABLED
@@ -114,6 +116,7 @@ public:
APIType api;
ClassInfo *inherits_ptr;
+ void *class_ptr;
HashMap<StringName, MethodBind *> method_map;
HashMap<StringName, int> constant_map;
HashMap<StringName, List<StringName> > enum_map;
@@ -177,6 +180,7 @@ public:
ERR_FAIL_COND(!t);
t->creation_func = &creator<T>;
t->exposed = true;
+ t->class_ptr = T::get_class_ptr_static();
T::register_custom_data_to_otdb();
}
@@ -188,6 +192,7 @@ public:
ClassInfo *t = classes.getptr(T::get_class_static());
ERR_FAIL_COND(!t);
t->exposed = true;
+ t->class_ptr = T::get_class_ptr_static();
//nothing
}
@@ -206,6 +211,7 @@ public:
ERR_FAIL_COND(!t);
t->creation_func = &_create_ptr_func<T>;
t->exposed = true;
+ t->class_ptr = T::get_class_ptr_static();
T::register_custom_data_to_otdb();
}
@@ -214,6 +220,7 @@ public:
static void get_direct_inheriters_from_class(const StringName &p_class, List<StringName> *p_classes);
static StringName get_parent_class_nocheck(const StringName &p_class);
static StringName get_parent_class(const StringName &p_class);
+ static StringName get_compatibility_remapped_class(const StringName &p_class);
static bool class_exists(const StringName &p_class);
static bool is_parent_class(const StringName &p_class, const StringName &p_inherits);
static bool can_instance(const StringName &p_class);
@@ -284,12 +291,30 @@ public:
return bind_methodfi(METHOD_FLAGS_DEFAULT, bind, p_method_name, ptr, 6);
}
+ template <class N, class M>
+ static MethodBind *bind_method(N p_method_name, M p_method, const Variant &p_def1, const Variant &p_def2, const Variant &p_def3, const Variant &p_def4, const Variant &p_def5, const Variant &p_def6, const Variant &p_def7) {
+
+ MethodBind *bind = create_method_bind(p_method);
+ const Variant *ptr[7] = { &p_def1, &p_def2, &p_def3, &p_def4, &p_def5, &p_def6, &p_def7 };
+
+ return bind_methodfi(METHOD_FLAGS_DEFAULT, bind, p_method_name, ptr, 7);
+ }
+
+ template <class N, class M>
+ static MethodBind *bind_method(N p_method_name, M p_method, const Variant &p_def1, const Variant &p_def2, const Variant &p_def3, const Variant &p_def4, const Variant &p_def5, const Variant &p_def6, const Variant &p_def7, const Variant &p_def8) {
+
+ MethodBind *bind = create_method_bind(p_method);
+ const Variant *ptr[8] = { &p_def1, &p_def2, &p_def3, &p_def4, &p_def5, &p_def6, &p_def7, &p_def8 };
+
+ return bind_methodfi(METHOD_FLAGS_DEFAULT, bind, p_method_name, ptr, 8);
+ }
+
template <class M>
- static MethodBind *bind_vararg_method(uint32_t p_flags, StringName p_name, M p_method, const MethodInfo &p_info = MethodInfo(), const Vector<Variant> &p_default_args = Vector<Variant>()) {
+ static MethodBind *bind_vararg_method(uint32_t p_flags, StringName p_name, M p_method, const MethodInfo &p_info = MethodInfo(), const Vector<Variant> &p_default_args = Vector<Variant>(), bool p_return_nil_is_variant = true) {
GLOBAL_LOCK_FUNCTION;
- MethodBind *bind = create_vararg_method_bind(p_method, p_info);
+ MethodBind *bind = create_vararg_method_bind(p_method, p_info, p_return_nil_is_variant);
ERR_FAIL_COND_V(!bind, NULL);
bind->set_name(p_name);