diff options
author | Ignacio Etcheverry <neikeq@users.noreply.github.com> | 2018-12-08 22:08:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-08 22:08:18 +0100 |
commit | c9550b800aed10451273143958dfff461105d45b (patch) | |
tree | 18a32ab01c83814c10612b35d9217cf68c405d74 /modules/mono/csharp_script.cpp | |
parent | 41d1dba35fc851258d5aabad819d09f6a43e324c (diff) | |
parent | b26487a2b46e6a15af2cbbed88755fd33d35e935 (diff) |
Merge pull request #23438 from zorbathut/zorbathut/csharpinstance
Implement CSharpScript::get_script_method_list and related functionality.
Diffstat (limited to 'modules/mono/csharp_script.cpp')
-rw-r--r-- | modules/mono/csharp_script.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 3c818898e6..943d95bfc9 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -2474,6 +2474,18 @@ void CSharpScript::set_source_code(const String &p_code) { #endif } +void CSharpScript::get_script_method_list(List<MethodInfo> *p_list) const { + + if (!script_class) + return; + + // TODO: Filter out things unsuitable for explicit calls, like constructors. + const Vector<GDMonoMethod *> &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 +2494,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; |