summaryrefslogtreecommitdiffstats
path: root/core/class_db.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/class_db.cpp')
-rw-r--r--core/class_db.cpp107
1 files changed, 95 insertions, 12 deletions
diff --git a/core/class_db.cpp b/core/class_db.cpp
index 0503f7c6fc..1cb287a143 100644
--- a/core/class_db.cpp
+++ b/core/class_db.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -46,11 +46,6 @@
#ifdef DEBUG_METHODS_ENABLED
-ParamDef::ParamDef(const Variant &p_variant)
- : used(true),
- val(p_variant) {
-}
-
MethodDefinition D_METHOD(const char *p_name) {
MethodDefinition md;
@@ -538,11 +533,10 @@ void ClassDB::get_method_list(StringName p_class, List<MethodInfo> *p_methods, b
minfo.arguments.push_back(method->get_argument_info(i));
}
- if (method->get_argument_type(-1) != Variant::NIL) {
- minfo.return_val = method->get_argument_info(-1);
- }
-
+ minfo.return_val = method->get_return_info();
minfo.flags = method->get_hint_flags();
+ minfo.default_arguments = method->get_default_arguments();
+
p_methods->push_back(minfo);
}
@@ -583,7 +577,7 @@ MethodBind *ClassDB::get_method(StringName p_class, StringName p_name) {
return NULL;
}
-void ClassDB::bind_integer_constant(const StringName &p_class, const StringName &p_name, int p_constant) {
+void ClassDB::bind_integer_constant(const StringName &p_class, const StringName &p_enum, const StringName &p_name, int p_constant) {
OBJTYPE_WLOCK;
@@ -600,6 +594,24 @@ void ClassDB::bind_integer_constant(const StringName &p_class, const StringName
type->constant_map[p_name] = p_constant;
#ifdef DEBUG_METHODS_ENABLED
+
+ String enum_name = p_enum;
+ if (enum_name != String()) {
+ if (enum_name.find(".") != -1) {
+ enum_name = enum_name.get_slicec('.', 1);
+ }
+
+ List<StringName> *constants_list = type->enum_map.getptr(enum_name);
+
+ if (constants_list) {
+ constants_list->push_back(p_name);
+ } else {
+ List<StringName> new_list;
+ new_list.push_back(p_name);
+ type->enum_map[enum_name] = new_list;
+ }
+ }
+
type->constant_order.push_back(p_name);
#endif
}
@@ -655,6 +667,77 @@ int ClassDB::get_integer_constant(const StringName &p_class, const StringName &p
return 0;
}
+#ifdef DEBUG_METHODS_ENABLED
+StringName ClassDB::get_integer_constant_enum(const StringName &p_class, const StringName &p_name, bool p_no_inheritance) {
+
+ OBJTYPE_RLOCK;
+
+ ClassInfo *type = classes.getptr(p_class);
+
+ while (type) {
+
+ const StringName *k = NULL;
+ while ((k = type->enum_map.next(k))) {
+
+ List<StringName> &constants_list = type->enum_map.get(*k);
+ const List<StringName>::Element *found = constants_list.find(p_name);
+ if (found)
+ return *k;
+ }
+
+ if (p_no_inheritance)
+ break;
+
+ type = type->inherits_ptr;
+ }
+
+ return StringName();
+}
+
+void ClassDB::get_enum_list(const StringName &p_class, List<StringName> *p_enums, bool p_no_inheritance) {
+
+ OBJTYPE_RLOCK;
+
+ ClassInfo *type = classes.getptr(p_class);
+
+ while (type) {
+
+ const StringName *k = NULL;
+ while ((k = type->enum_map.next(k))) {
+ p_enums->push_back(*k);
+ }
+
+ if (p_no_inheritance)
+ break;
+
+ type = type->inherits_ptr;
+ }
+}
+
+void ClassDB::get_enum_constants(const StringName &p_class, const StringName &p_enum, List<StringName> *p_constants, bool p_no_inheritance) {
+
+ OBJTYPE_RLOCK;
+
+ ClassInfo *type = classes.getptr(p_class);
+
+ while (type) {
+
+ const List<StringName> *constants = type->enum_map.getptr(p_enum);
+
+ if (constants) {
+ for (const List<StringName>::Element *E = constants->front(); E; E = E->next()) {
+ p_constants->push_back(E->get());
+ }
+ }
+
+ if (p_no_inheritance)
+ break;
+
+ type = type->inherits_ptr;
+ }
+}
+#endif
+
void ClassDB::add_signal(StringName p_class, const MethodInfo &p_signal) {
OBJTYPE_WLOCK;
@@ -777,7 +860,7 @@ void ClassDB::add_property(StringName p_class, const PropertyInfo &p_pinfo, cons
MethodBind *mb_get = NULL;
if (p_getter) {
- MethodBind *mb_get = get_method(p_class, p_getter);
+ mb_get = get_method(p_class, p_getter);
#ifdef DEBUG_METHODS_ENABLED
if (!mb_get) {