summaryrefslogtreecommitdiff
path: root/editor/editor_translation_parser.cpp
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2021-08-22 09:31:44 -0300
committerGitHub <noreply@github.com>2021-08-22 09:31:44 -0300
commita73b5fa1124ab91401f965f0bf6fd48407b79c4e (patch)
treefee311b675144ae3a5fecc58857912ea250b1bb7 /editor/editor_translation_parser.cpp
parent2a5c64f2a188360d09f793c0dbd35e1911b4c073 (diff)
parent3682978aee06cd5cf26ba462a4e44d352e9e0cd1 (diff)
Merge pull request #51970 from reduz/implement-gdvirtuals-everywhere
Replace BIND_VMETHOD by new GDVIRTUAL syntax
Diffstat (limited to 'editor/editor_translation_parser.cpp')
-rw-r--r--editor/editor_translation_parser.cpp23
1 files changed, 7 insertions, 16 deletions
diff --git a/editor/editor_translation_parser.cpp b/editor/editor_translation_parser.cpp
index 27d428e682..df47b2d988 100644
--- a/editor/editor_translation_parser.cpp
+++ b/editor/editor_translation_parser.cpp
@@ -38,15 +38,10 @@
EditorTranslationParser *EditorTranslationParser::singleton = nullptr;
Error EditorTranslationParserPlugin::parse_file(const String &p_path, Vector<String> *r_ids, Vector<Vector<String>> *r_ids_ctx_plural) {
- if (!get_script_instance()) {
- return ERR_UNAVAILABLE;
- }
-
- if (get_script_instance()->has_method("_parse_file")) {
- Array ids;
- Array ids_ctx_plural;
- get_script_instance()->call("_parse_file", p_path, ids, ids_ctx_plural);
+ Array ids;
+ Array ids_ctx_plural;
+ if (GDVIRTUAL_CALL(_parse_file, p_path, ids, ids_ctx_plural)) {
// Add user's extracted translatable messages.
for (int i = 0; i < ids.size(); i++) {
r_ids->append(ids[i]);
@@ -71,12 +66,8 @@ Error EditorTranslationParserPlugin::parse_file(const String &p_path, Vector<Str
}
void EditorTranslationParserPlugin::get_recognized_extensions(List<String> *r_extensions) const {
- if (!get_script_instance()) {
- return;
- }
-
- if (get_script_instance()->has_method("_get_recognized_extensions")) {
- Array extensions = get_script_instance()->call("_get_recognized_extensions");
+ Vector<String> extensions;
+ if (GDVIRTUAL_CALL(_get_recognized_extensions, extensions)) {
for (int i = 0; i < extensions.size(); i++) {
r_extensions->push_back(extensions[i]);
}
@@ -86,8 +77,8 @@ void EditorTranslationParserPlugin::get_recognized_extensions(List<String> *r_ex
}
void EditorTranslationParserPlugin::_bind_methods() {
- BIND_VMETHOD(MethodInfo(Variant::NIL, "_parse_file", PropertyInfo(Variant::STRING, "path"), PropertyInfo(Variant::ARRAY, "msgids"), PropertyInfo(Variant::ARRAY, "msgids_context_plural")));
- BIND_VMETHOD(MethodInfo(Variant::ARRAY, "_get_recognized_extensions"));
+ GDVIRTUAL_BIND(_parse_file, "path", "msgids", "msgids_context_plural");
+ GDVIRTUAL_BIND(_get_recognized_extensions);
}
/////////////////////////