From f13f2d512f0439a29804182cee756dce62add857 Mon Sep 17 00:00:00 2001 From: Ben Rog-Wilhelm Date: Thu, 1 Nov 2018 08:35:16 -0700 Subject: Implement CSharpScript::get_script_method_list and related functionality. --- modules/mono/csharp_script.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'modules/mono/csharp_script.cpp') diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 3c818898e6..ba31f12d37 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -2474,6 +2474,17 @@ void CSharpScript::set_source_code(const String &p_code) { #endif } +void CSharpScript::get_script_method_list(List *p_list) const { + + if (!script_class) + return; + + const Vector &methods = script_class->get_all_methods(); + for (int i = 0; i < methods.size(); ++i) { + p_list->push_back(methods[i]->get_method_info()); + } +} + bool CSharpScript::has_method(const StringName &p_method) const { if (!script_class) @@ -2482,6 +2493,25 @@ bool CSharpScript::has_method(const StringName &p_method) const { return script_class->has_fetched_method_unknown_params(p_method); } +MethodInfo CSharpScript::get_method_info(const StringName &p_method) const { + + if (!script_class) + return MethodInfo(); + + GDMonoClass *top = script_class; + + while (top && top != native) { + GDMonoMethod *params = top->get_fetched_method_unknown_params(p_method); + if (params) { + return params->get_method_info(); + } + + top = top->get_parent_class(); + } + + return MethodInfo(); +} + Error CSharpScript::reload(bool p_keep_state) { bool has_instances; -- cgit v1.2.3 From b26487a2b46e6a15af2cbbed88755fd33d35e935 Mon Sep 17 00:00:00 2001 From: Ben Rog-Wilhelm Date: Sat, 8 Dec 2018 00:54:12 -0800 Subject: Tweaks after feedback --- modules/mono/csharp_script.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'modules/mono/csharp_script.cpp') diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index ba31f12d37..943d95bfc9 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -2479,6 +2479,7 @@ void CSharpScript::get_script_method_list(List *p_list) const { if (!script_class) return; + // TODO: Filter out things unsuitable for explicit calls, like constructors. const Vector &methods = script_class->get_all_methods(); for (int i = 0; i < methods.size(); ++i) { p_list->push_back(methods[i]->get_method_info()); -- cgit v1.2.3