summaryrefslogtreecommitdiff
path: root/modules/gdnative
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gdnative')
-rw-r--r--modules/gdnative/gdnative.cpp23
-rw-r--r--modules/gdnative/gdnative/color.cpp2
-rw-r--r--modules/gdnative/gdnative/gdnative.cpp8
-rw-r--r--modules/gdnative/gdnative/plane.cpp1
-rw-r--r--modules/gdnative/gdnative/quat.cpp1
-rw-r--r--modules/gdnative/gdnative/rect2.cpp1
-rw-r--r--modules/gdnative/gdnative/string.cpp1
-rw-r--r--modules/gdnative/gdnative/vector2.cpp1
-rw-r--r--modules/gdnative/gdnative/vector3.cpp1
-rw-r--r--modules/gdnative/gdnative_library_editor_plugin.cpp39
-rw-r--r--modules/gdnative/gdnative_library_editor_plugin.h2
-rw-r--r--modules/gdnative/gdnative_library_singleton_editor.cpp18
-rw-r--r--modules/gdnative/include/net/godot_net.h1
-rw-r--r--modules/gdnative/include/videodecoder/godot_videodecoder.h2
-rw-r--r--modules/gdnative/nativescript/api_generator.cpp7
-rw-r--r--modules/gdnative/nativescript/godot_nativescript.cpp12
-rw-r--r--modules/gdnative/nativescript/nativescript.cpp203
-rw-r--r--modules/gdnative/nativescript/nativescript.h27
-rw-r--r--modules/gdnative/nativescript/register_types.cpp1
-rw-r--r--modules/gdnative/net/multiplayer_peer_gdnative.cpp1
-rw-r--r--modules/gdnative/net/packet_peer_gdnative.cpp1
-rw-r--r--modules/gdnative/net/stream_peer_gdnative.h1
-rw-r--r--modules/gdnative/pluginscript/pluginscript_loader.cpp11
-rw-r--r--modules/gdnative/pluginscript/pluginscript_loader.h2
-rw-r--r--modules/gdnative/pluginscript/pluginscript_script.cpp43
-rw-r--r--modules/gdnative/pluginscript/pluginscript_script.h11
-rw-r--r--modules/gdnative/register_types.cpp10
-rw-r--r--modules/gdnative/videodecoder/register_types.cpp2
-rw-r--r--modules/gdnative/videodecoder/video_stream_gdnative.cpp43
-rw-r--r--modules/gdnative/videodecoder/video_stream_gdnative.h47
-rw-r--r--modules/gdnative/xr/xr_interface_gdnative.cpp8
31 files changed, 227 insertions, 304 deletions
diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp
index a131e3a78f..3d747ba41e 100644
--- a/modules/gdnative/gdnative.cpp
+++ b/modules/gdnative/gdnative.cpp
@@ -63,7 +63,6 @@ GDNativeLibrary::~GDNativeLibrary() {
}
bool GDNativeLibrary::_set(const StringName &p_name, const Variant &p_property) {
-
String name = p_name;
if (name.begins_with("entry/")) {
@@ -115,8 +114,9 @@ void GDNativeLibrary::_get_property_list(List<PropertyInfo> *p_list) const {
// set entries
List<String> entry_key_list;
- if (config_file->has_section("entry"))
+ if (config_file->has_section("entry")) {
config_file->get_section_keys("entry", &entry_key_list);
+ }
for (List<String>::Element *E = entry_key_list.front(); E; E = E->next()) {
String key = E->get();
@@ -132,8 +132,9 @@ void GDNativeLibrary::_get_property_list(List<PropertyInfo> *p_list) const {
// set dependencies
List<String> dependency_key_list;
- if (config_file->has_section("dependencies"))
+ if (config_file->has_section("dependencies")) {
config_file->get_section_keys("dependencies", &dependency_key_list);
+ }
for (List<String>::Element *E = dependency_key_list.front(); E; E = E->next()) {
String key = E->get();
@@ -148,7 +149,6 @@ void GDNativeLibrary::_get_property_list(List<PropertyInfo> *p_list) const {
}
void GDNativeLibrary::set_config_file(Ref<ConfigFile> p_config_file) {
-
set_singleton(p_config_file->get_value("general", "singleton", default_singleton));
set_load_once(p_config_file->get_value("general", "load_once", default_load_once));
set_symbol_prefix(p_config_file->get_value("general", "symbol_prefix", default_symbol_prefix));
@@ -156,11 +156,11 @@ void GDNativeLibrary::set_config_file(Ref<ConfigFile> p_config_file) {
String entry_lib_path;
{
-
List<String> entry_keys;
- if (p_config_file->has_section("entry"))
+ if (p_config_file->has_section("entry")) {
p_config_file->get_section_keys("entry", &entry_keys);
+ }
for (List<String>::Element *E = entry_keys.front(); E; E = E->next()) {
String key = E->get();
@@ -188,11 +188,11 @@ void GDNativeLibrary::set_config_file(Ref<ConfigFile> p_config_file) {
Vector<String> dependency_paths;
{
-
List<String> dependency_keys;
- if (p_config_file->has_section("dependencies"))
+ if (p_config_file->has_section("dependencies")) {
p_config_file->get_section_keys("dependencies", &dependency_keys);
+ }
for (List<String>::Element *E = dependency_keys.front(); E; E = E->next()) {
String key = E->get();
@@ -383,7 +383,6 @@ bool GDNative::initialize() {
}
bool GDNative::terminate() {
-
if (!initialized) {
ERR_PRINT("No valid library handle, can't terminate GDNative object");
return false;
@@ -452,7 +451,6 @@ Vector<StringName> GDNativeCallRegistry::get_native_call_types() {
}
Variant GDNative::call_native(StringName p_native_call_type, StringName p_procedure_name, Array p_arguments) {
-
Map<StringName, native_call_cb>::Element *E = GDNativeCallRegistry::singleton->native_calls.find(p_native_call_type);
if (!E) {
ERR_PRINT((String("No handler for native call type \"" + p_native_call_type) + "\" found").utf8().get_data());
@@ -478,7 +476,6 @@ Variant GDNative::call_native(StringName p_native_call_type, StringName p_proced
}
Error GDNative::get_symbol(StringName p_procedure_name, void *&r_handle, bool p_optional) const {
-
if (!initialized) {
ERR_PRINT("No valid library handle, can't get symbol from GDNative object");
return ERR_CANT_OPEN;
@@ -520,13 +517,13 @@ bool GDNativeLibraryResourceLoader::handles_type(const String &p_type) const {
String GDNativeLibraryResourceLoader::get_resource_type(const String &p_path) const {
String el = p_path.get_extension().to_lower();
- if (el == "gdnlib")
+ if (el == "gdnlib") {
return "GDNativeLibrary";
+ }
return "";
}
Error GDNativeLibraryResourceSaver::save(const String &p_path, const RES &p_resource, uint32_t p_flags) {
-
Ref<GDNativeLibrary> lib = p_resource;
if (lib.is_null()) {
diff --git a/modules/gdnative/gdnative/color.cpp b/modules/gdnative/gdnative/color.cpp
index 68c83e05a6..d79170771a 100644
--- a/modules/gdnative/gdnative/color.cpp
+++ b/modules/gdnative/gdnative/color.cpp
@@ -38,13 +38,11 @@ extern "C" {
#endif
void GDAPI godot_color_new_rgba(godot_color *r_dest, const godot_real p_r, const godot_real p_g, const godot_real p_b, const godot_real p_a) {
-
Color *dest = (Color *)r_dest;
*dest = Color(p_r, p_g, p_b, p_a);
}
void GDAPI godot_color_new_rgb(godot_color *r_dest, const godot_real p_r, const godot_real p_g, const godot_real p_b) {
-
Color *dest = (Color *)r_dest;
*dest = Color(p_r, p_g, p_b);
}
diff --git a/modules/gdnative/gdnative/gdnative.cpp b/modules/gdnative/gdnative/gdnative.cpp
index 1216d1d9d3..6b2b5b80a4 100644
--- a/modules/gdnative/gdnative/gdnative.cpp
+++ b/modules/gdnative/gdnative/gdnative.cpp
@@ -56,14 +56,12 @@ godot_object GDAPI *godot_global_get_singleton(char *p_name) {
// MethodBind API
godot_method_bind GDAPI *godot_method_bind_get_method(const char *p_classname, const char *p_methodname) {
-
MethodBind *mb = ClassDB::get_method(StringName(p_classname), StringName(p_methodname));
// MethodBind *mb = ClassDB::get_method("Node", "get_name");
return (godot_method_bind *)mb;
}
void GDAPI godot_method_bind_ptrcall(godot_method_bind *p_method_bind, godot_object *p_instance, const void **p_args, void *p_ret) {
-
MethodBind *mb = (MethodBind *)p_method_bind;
Object *o = (Object *)p_instance;
mb->ptrcall(o, p_args, p_ret);
@@ -93,8 +91,9 @@ godot_variant GDAPI godot_method_bind_call(godot_method_bind *p_method_bind, god
godot_class_constructor GDAPI godot_get_class_constructor(const char *p_classname) {
ClassDB::ClassInfo *class_info = ClassDB::classes.getptr(StringName(p_classname));
- if (class_info)
+ if (class_info) {
return (godot_class_constructor)class_info->creation_func;
+ }
return nullptr;
}
@@ -177,8 +176,9 @@ void *godot_get_class_tag(const godot_string_name *p_class) {
}
godot_object *godot_object_cast_to(const godot_object *p_object, void *p_class_tag) {
- if (!p_object)
+ if (!p_object) {
return nullptr;
+ }
Object *o = (Object *)p_object;
return o->is_class_ptr(p_class_tag) ? (godot_object *)o : nullptr;
diff --git a/modules/gdnative/gdnative/plane.cpp b/modules/gdnative/gdnative/plane.cpp
index 17221fe081..923308dc34 100644
--- a/modules/gdnative/gdnative/plane.cpp
+++ b/modules/gdnative/gdnative/plane.cpp
@@ -38,7 +38,6 @@ extern "C" {
#endif
void GDAPI godot_plane_new_with_reals(godot_plane *r_dest, const godot_real p_a, const godot_real p_b, const godot_real p_c, const godot_real p_d) {
-
Plane *dest = (Plane *)r_dest;
*dest = Plane(p_a, p_b, p_c, p_d);
}
diff --git a/modules/gdnative/gdnative/quat.cpp b/modules/gdnative/gdnative/quat.cpp
index be30b89e5f..15c04f7191 100644
--- a/modules/gdnative/gdnative/quat.cpp
+++ b/modules/gdnative/gdnative/quat.cpp
@@ -38,7 +38,6 @@ extern "C" {
#endif
void GDAPI godot_quat_new(godot_quat *r_dest, const godot_real p_x, const godot_real p_y, const godot_real p_z, const godot_real p_w) {
-
Quat *dest = (Quat *)r_dest;
*dest = Quat(p_x, p_y, p_z, p_w);
}
diff --git a/modules/gdnative/gdnative/rect2.cpp b/modules/gdnative/gdnative/rect2.cpp
index 906b4f0932..a2f735172f 100644
--- a/modules/gdnative/gdnative/rect2.cpp
+++ b/modules/gdnative/gdnative/rect2.cpp
@@ -45,7 +45,6 @@ void GDAPI godot_rect2_new_with_position_and_size(godot_rect2 *r_dest, const god
}
void GDAPI godot_rect2_new(godot_rect2 *r_dest, const godot_real p_x, const godot_real p_y, const godot_real p_width, const godot_real p_height) {
-
Rect2 *dest = (Rect2 *)r_dest;
*dest = Rect2(p_x, p_y, p_width, p_height);
}
diff --git a/modules/gdnative/gdnative/string.cpp b/modules/gdnative/gdnative/string.cpp
index 4cb55900b0..a22af89edc 100644
--- a/modules/gdnative/gdnative/string.cpp
+++ b/modules/gdnative/gdnative/string.cpp
@@ -137,6 +137,7 @@ signed char GDAPI godot_string_nocasecmp_to(const godot_string *p_self, const go
return self->nocasecmp_to(*str);
}
+
signed char GDAPI godot_string_naturalnocasecmp_to(const godot_string *p_self, const godot_string *p_str) {
const String *self = (const String *)p_self;
const String *str = (const String *)p_str;
diff --git a/modules/gdnative/gdnative/vector2.cpp b/modules/gdnative/gdnative/vector2.cpp
index dc273e7951..b6c3569f42 100644
--- a/modules/gdnative/gdnative/vector2.cpp
+++ b/modules/gdnative/gdnative/vector2.cpp
@@ -38,7 +38,6 @@ extern "C" {
#endif
void GDAPI godot_vector2_new(godot_vector2 *r_dest, const godot_real p_x, const godot_real p_y) {
-
Vector2 *dest = (Vector2 *)r_dest;
*dest = Vector2(p_x, p_y);
}
diff --git a/modules/gdnative/gdnative/vector3.cpp b/modules/gdnative/gdnative/vector3.cpp
index bb27ad5a00..3e272ae9df 100644
--- a/modules/gdnative/gdnative/vector3.cpp
+++ b/modules/gdnative/gdnative/vector3.cpp
@@ -38,7 +38,6 @@ extern "C" {
#endif
void GDAPI godot_vector3_new(godot_vector3 *r_dest, const godot_real p_x, const godot_real p_y, const godot_real p_z) {
-
Vector3 *dest = (Vector3 *)r_dest;
*dest = Vector3(p_x, p_y, p_z);
}
diff --git a/modules/gdnative/gdnative_library_editor_plugin.cpp b/modules/gdnative/gdnative_library_editor_plugin.cpp
index 10ddd79d3a..2a9836329e 100644
--- a/modules/gdnative/gdnative_library_editor_plugin.cpp
+++ b/modules/gdnative/gdnative_library_editor_plugin.cpp
@@ -40,7 +40,6 @@ void GDNativeLibraryEditor::edit(Ref<GDNativeLibrary> p_library) {
for (Map<String, NativePlatformConfig>::Element *E = platforms.front(); E; E = E->next()) {
for (List<String>::Element *it = E->value().entries.front(); it; it = it->next()) {
-
String target = E->key() + "." + it->get();
TargetConfig ecfg;
ecfg.library = config->get_value("entry", target, "");
@@ -56,14 +55,12 @@ void GDNativeLibraryEditor::_bind_methods() {
}
void GDNativeLibraryEditor::_update_tree() {
-
tree->clear();
TreeItem *root = tree->create_item();
PopupMenu *filter_list = filter->get_popup();
String text = "";
for (int i = 0; i < filter_list->get_item_count(); i++) {
-
if (!filter_list->is_item_checked(i)) {
continue;
}
@@ -84,7 +81,6 @@ void GDNativeLibraryEditor::_update_tree() {
platform->set_expand_right(0, true);
for (List<String>::Element *it = E->value().entries.front(); it; it = it->next()) {
-
String target = E->key() + "." + it->get();
TreeItem *bit = tree->create_item(platform);
@@ -125,17 +121,16 @@ void GDNativeLibraryEditor::_update_tree() {
}
void GDNativeLibraryEditor::_on_item_button(Object *item, int column, int id) {
-
String target = Object::cast_to<TreeItem>(item)->get_metadata(0);
String platform = target.substr(0, target.find("."));
String entry = target.substr(platform.length() + 1, target.length());
String section = (id == BUTTON_SELECT_DEPENDENCES || id == BUTTON_CLEAR_DEPENDENCES) ? "dependencies" : "entry";
if (id == BUTTON_SELECT_LIBRARY || id == BUTTON_SELECT_DEPENDENCES) {
-
EditorFileDialog::FileMode mode = EditorFileDialog::FILE_MODE_OPEN_FILE;
- if (id == BUTTON_SELECT_DEPENDENCES)
+ if (id == BUTTON_SELECT_DEPENDENCES) {
mode = EditorFileDialog::FILE_MODE_OPEN_FILES;
+ }
file_dialog->set_meta("target", target);
file_dialog->set_meta("section", section);
@@ -156,24 +151,20 @@ void GDNativeLibraryEditor::_on_item_button(Object *item, int column, int id) {
}
void GDNativeLibraryEditor::_on_library_selected(const String &file) {
-
_set_target_value(file_dialog->get_meta("section"), file_dialog->get_meta("target"), file);
}
void GDNativeLibraryEditor::_on_dependencies_selected(const PackedStringArray &files) {
-
_set_target_value(file_dialog->get_meta("section"), file_dialog->get_meta("target"), files);
}
void GDNativeLibraryEditor::_on_filter_selected(int index) {
-
PopupMenu *filter_list = filter->get_popup();
filter_list->set_item_checked(index, !filter_list->is_item_checked(index));
_update_tree();
}
void GDNativeLibraryEditor::_on_item_collapsed(Object *p_item) {
-
TreeItem *item = Object::cast_to<TreeItem>(p_item);
String name = item->get_text(0);
@@ -185,7 +176,6 @@ void GDNativeLibraryEditor::_on_item_collapsed(Object *p_item) {
}
void GDNativeLibraryEditor::_on_item_activated() {
-
TreeItem *item = tree->get_selected();
if (item && tree->get_selected_column() == 0 && item->get_metadata(0).get_type() == Variant::NIL) {
new_architecture_dialog->set_meta("platform", item->get_metadata(1));
@@ -194,7 +184,6 @@ void GDNativeLibraryEditor::_on_item_activated() {
}
void GDNativeLibraryEditor::_on_create_new_entry() {
-
String platform = new_architecture_dialog->get_meta("platform");
String entry = new_architecture_input->get_text().strip_edges();
if (!entry.empty()) {
@@ -204,19 +193,18 @@ void GDNativeLibraryEditor::_on_create_new_entry() {
}
void GDNativeLibraryEditor::_set_target_value(const String &section, const String &target, Variant file) {
- if (section == "entry")
+ if (section == "entry") {
entry_configs[target].library = file;
- else if (section == "dependencies")
+ } else if (section == "dependencies") {
entry_configs[target].dependencies = file;
+ }
_translate_to_config_file();
_update_tree();
}
void GDNativeLibraryEditor::_erase_entry(const String &platform, const String &entry) {
-
if (platforms.has(platform)) {
if (List<String>::Element *E = platforms[platform].entries.find(entry)) {
-
String target = platform + "." + entry;
platforms[platform].entries.erase(E);
@@ -243,19 +231,17 @@ void GDNativeLibraryEditor::_move_entry(const String &platform, const String &en
}
void GDNativeLibraryEditor::_translate_to_config_file() {
-
if (!library.is_null()) {
-
Ref<ConfigFile> config = library->get_config_file();
config->erase_section("entry");
config->erase_section("dependencies");
for (Map<String, NativePlatformConfig>::Element *E = platforms.front(); E; E = E->next()) {
for (List<String>::Element *it = E->value().entries.front(); it; it = it->next()) {
-
String target = E->key() + "." + it->get();
- if (entry_configs[target].library.empty() && entry_configs[target].dependencies.empty())
+ if (entry_configs[target].library.empty() && entry_configs[target].dependencies.empty()) {
continue;
+ }
config->set_value("entry", target, entry_configs[target].library);
config->set_value("dependencies", target, entry_configs[target].dependencies);
@@ -267,7 +253,6 @@ void GDNativeLibraryEditor::_translate_to_config_file() {
}
GDNativeLibraryEditor::GDNativeLibraryEditor() {
-
{ // Define platforms
NativePlatformConfig platform_windows;
platform_windows.name = "Windows";
@@ -388,32 +373,30 @@ GDNativeLibraryEditor::GDNativeLibraryEditor() {
}
void GDNativeLibraryEditorPlugin::edit(Object *p_node) {
-
Ref<GDNativeLibrary> new_library = Object::cast_to<GDNativeLibrary>(p_node);
- if (new_library.is_valid())
+ if (new_library.is_valid()) {
library_editor->edit(new_library);
+ }
}
bool GDNativeLibraryEditorPlugin::handles(Object *p_node) const {
-
return p_node->is_class("GDNativeLibrary");
}
void GDNativeLibraryEditorPlugin::make_visible(bool p_visible) {
-
if (p_visible) {
button->show();
EditorNode::get_singleton()->make_bottom_panel_item_visible(library_editor);
} else {
- if (library_editor->is_visible_in_tree())
+ if (library_editor->is_visible_in_tree()) {
EditorNode::get_singleton()->hide_bottom_panel();
+ }
button->hide();
}
}
GDNativeLibraryEditorPlugin::GDNativeLibraryEditorPlugin(EditorNode *p_node) {
-
library_editor = memnew(GDNativeLibraryEditor);
library_editor->set_custom_minimum_size(Size2(0, 250 * EDSCALE));
button = p_node->add_bottom_panel_item(TTR("GDNativeLibrary"), library_editor);
diff --git a/modules/gdnative/gdnative_library_editor_plugin.h b/modules/gdnative/gdnative_library_editor_plugin.h
index b1274d08b3..5fdb860ca3 100644
--- a/modules/gdnative/gdnative_library_editor_plugin.h
+++ b/modules/gdnative/gdnative_library_editor_plugin.h
@@ -36,7 +36,6 @@
#include "gdnative.h"
class GDNativeLibraryEditor : public Control {
-
GDCLASS(GDNativeLibraryEditor, Control);
struct NativePlatformConfig {
@@ -94,7 +93,6 @@ public:
};
class GDNativeLibraryEditorPlugin : public EditorPlugin {
-
GDCLASS(GDNativeLibraryEditorPlugin, EditorPlugin);
GDNativeLibraryEditor *library_editor;
diff --git a/modules/gdnative/gdnative_library_singleton_editor.cpp b/modules/gdnative/gdnative_library_singleton_editor.cpp
index 378339ecea..409b6cbffe 100644
--- a/modules/gdnative/gdnative_library_singleton_editor.cpp
+++ b/modules/gdnative/gdnative_library_singleton_editor.cpp
@@ -35,7 +35,6 @@
#include "editor/editor_node.h"
Set<String> GDNativeLibrarySingletonEditor::_find_singletons_recursive(EditorFileSystemDirectory *p_dir) {
-
Set<String> file_paths;
// check children
@@ -67,7 +66,6 @@ Set<String> GDNativeLibrarySingletonEditor::_find_singletons_recursive(EditorFil
}
void GDNativeLibrarySingletonEditor::_discover_singletons() {
-
EditorFileSystemDirectory *dir = EditorFileSystem::get_singleton()->get_filesystem();
Set<String> file_paths = _find_singletons_recursive(dir);
@@ -97,7 +95,6 @@ void GDNativeLibrarySingletonEditor::_discover_singletons() {
}
if (changed) {
-
ProjectSettings::get_singleton()->set("gdnative/singletons", files);
_update_libraries(); // So singleton options (i.e. disabled) updates too
ProjectSettings::get_singleton()->save();
@@ -105,7 +102,6 @@ void GDNativeLibrarySingletonEditor::_discover_singletons() {
}
void GDNativeLibrarySingletonEditor::_update_libraries() {
-
updating = true;
libraries->clear();
libraries->create_item(); // root item
@@ -139,19 +135,22 @@ void GDNativeLibrarySingletonEditor::_update_libraries() {
}
// The singletons list changed, we must update the settings
- if (updated_disabled.size() != singletons_disabled.size())
+ if (updated_disabled.size() != singletons_disabled.size()) {
ProjectSettings::get_singleton()->set("gdnative/singletons_disabled", updated_disabled);
+ }
updating = false;
}
void GDNativeLibrarySingletonEditor::_item_edited() {
- if (updating)
+ if (updating) {
return;
+ }
TreeItem *item = libraries->get_edited();
- if (!item)
+ if (!item) {
return;
+ }
bool enabled = item->get_range(1);
String path = item->get_metadata(0);
@@ -169,8 +168,9 @@ void GDNativeLibrarySingletonEditor::_item_edited() {
if (enabled) {
disabled_paths.erase(path);
} else {
- if (disabled_paths.find(path) == -1)
+ if (disabled_paths.find(path) == -1) {
disabled_paths.push_back(path);
+ }
}
undo_redo->create_action(enabled ? TTR("Enabled GDNative Singleton") : TTR("Disabled GDNative Singleton"));
@@ -182,7 +182,6 @@ void GDNativeLibrarySingletonEditor::_item_edited() {
}
void GDNativeLibrarySingletonEditor::_notification(int p_what) {
-
if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
if (is_visible_in_tree()) {
_update_libraries();
@@ -191,7 +190,6 @@ void GDNativeLibrarySingletonEditor::_notification(int p_what) {
}
void GDNativeLibrarySingletonEditor::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("_update_libraries"), &GDNativeLibrarySingletonEditor::_update_libraries);
}
diff --git a/modules/gdnative/include/net/godot_net.h b/modules/gdnative/include/net/godot_net.h
index d245f3b965..42804112f2 100644
--- a/modules/gdnative/include/net/godot_net.h
+++ b/modules/gdnative/include/net/godot_net.h
@@ -45,7 +45,6 @@ extern "C" {
#define GODOT_NET_API_MINOR 1
typedef struct {
-
godot_gdnative_api_version version; /* version of our API */
godot_object *data; /* User reference */
diff --git a/modules/gdnative/include/videodecoder/godot_videodecoder.h b/modules/gdnative/include/videodecoder/godot_videodecoder.h
index 3e91a2e9ac..16c92abd22 100644
--- a/modules/gdnative/include/videodecoder/godot_videodecoder.h
+++ b/modules/gdnative/include/videodecoder/godot_videodecoder.h
@@ -46,7 +46,7 @@ typedef struct
void *next;
void *(*constructor)(godot_object *);
void (*destructor)(void *);
- const char *(*get_plugin_name)(void);
+ const char *(*get_plugin_name)();
const char **(*get_supported_extensions)(int *count);
godot_bool (*open_file)(void *, void *); // data struct, and a FileAccess pointer
godot_real (*get_length)(const void *);
diff --git a/modules/gdnative/nativescript/api_generator.cpp b/modules/gdnative/nativescript/api_generator.cpp
index 3c0cfd0484..62f2ec5024 100644
--- a/modules/gdnative/nativescript/api_generator.cpp
+++ b/modules/gdnative/nativescript/api_generator.cpp
@@ -41,7 +41,6 @@
// helper stuff
static Error save_file(const String &p_path, const List<String> &p_content) {
-
FileAccessRef file = FileAccess::open(p_path, FileAccess::WRITE);
ERR_FAIL_COND_V(!file, ERR_FILE_CANT_WRITE);
@@ -146,7 +145,6 @@ static String get_type_name(const PropertyInfo &info) {
struct MethodInfoComparator {
StringName::AlphCompare compare;
bool operator()(const MethodInfo &p_a, const MethodInfo &p_b) const {
-
return compare(p_a.name, p_b.name);
}
};
@@ -154,7 +152,6 @@ struct MethodInfoComparator {
struct PropertyInfoComparator {
StringName::AlphCompare compare;
bool operator()(const PropertyInfo &p_a, const PropertyInfo &p_b) const {
-
return compare(p_a.name, p_b.name);
}
};
@@ -162,7 +159,6 @@ struct PropertyInfoComparator {
struct ConstantAPIComparator {
NoCaseComparator compare;
bool operator()(const ConstantAPI &p_a, const ConstantAPI &p_b) const {
-
return compare(p_a.constant_name, p_b.constant_name);
}
};
@@ -171,7 +167,6 @@ struct ConstantAPIComparator {
* Reads the entire Godot API to a list
*/
List<ClassAPI> generate_c_api_classes() {
-
List<ClassAPI> api;
List<StringName> classes;
@@ -410,7 +405,6 @@ List<ClassAPI> generate_c_api_classes() {
* Generates the JSON source from the API in p_api
*/
static List<String> generate_c_api_json(const List<ClassAPI> &p_api) {
-
// I'm sorry for the \t mess
List<String> source;
@@ -520,7 +514,6 @@ static List<String> generate_c_api_json(const List<ClassAPI> &p_api) {
* p_path
*/
Error generate_c_api(const String &p_path) {
-
#ifndef TOOLS_ENABLED
return ERR_BUG;
#else
diff --git a/modules/gdnative/nativescript/godot_nativescript.cpp b/modules/gdnative/nativescript/godot_nativescript.cpp
index 0502458b4f..1bdac0dcb2 100644
--- a/modules/gdnative/nativescript/godot_nativescript.cpp
+++ b/modules/gdnative/nativescript/godot_nativescript.cpp
@@ -52,7 +52,6 @@ extern "C" void _native_script_hook() {
// Script API
void GDAPI godot_nativescript_register_class(void *p_gdnative_handle, const char *p_name, const char *p_base, godot_instance_create_func p_create_func, godot_instance_destroy_func p_destroy_func) {
-
String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc> *classes = &NSL->library_classes[*s];
@@ -85,7 +84,6 @@ void GDAPI godot_nativescript_register_class(void *p_gdnative_handle, const char
}
void GDAPI godot_nativescript_register_tool_class(void *p_gdnative_handle, const char *p_name, const char *p_base, godot_instance_create_func p_create_func, godot_instance_destroy_func p_destroy_func) {
-
String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc> *classes = &NSL->library_classes[*s];
@@ -119,7 +117,6 @@ void GDAPI godot_nativescript_register_tool_class(void *p_gdnative_handle, const
}
void GDAPI godot_nativescript_register_method(void *p_gdnative_handle, const char *p_name, const char *p_function_name, godot_method_attributes p_attr, godot_instance_method p_method) {
-
String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
@@ -139,7 +136,6 @@ void GDAPI godot_nativescript_register_method(void *p_gdnative_handle, const cha
}
void GDAPI godot_nativescript_register_property(void *p_gdnative_handle, const char *p_name, const char *p_path, godot_property_attributes *p_attr, godot_property_set_func p_set_func, godot_property_get_func p_get_func) {
-
String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
@@ -164,7 +160,6 @@ void GDAPI godot_nativescript_register_property(void *p_gdnative_handle, const c
}
void GDAPI godot_nativescript_register_signal(void *p_gdnative_handle, const char *p_name, const godot_signal *p_signal) {
-
String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
@@ -209,8 +204,9 @@ void GDAPI godot_nativescript_register_signal(void *p_gdnative_handle, const cha
void GDAPI *godot_nativescript_get_userdata(godot_object *p_instance) {
Object *instance = (Object *)p_instance;
- if (!instance)
+ if (!instance) {
return nullptr;
+ }
if (instance->get_script_instance() && instance->get_script_instance()->get_language() == NativeScriptLanguage::get_singleton()) {
return ((NativeScriptInstance *)instance->get_script_instance())->userdata;
}
@@ -315,7 +311,6 @@ void GDAPI godot_nativescript_set_type_tag(void *p_gdnative_handle, const char *
}
const void GDAPI *godot_nativescript_get_type_tag(const godot_object *p_object) {
-
const Object *o = (Object *)p_object;
if (!o->get_script_instance()) {
@@ -326,8 +321,9 @@ const void GDAPI *godot_nativescript_get_type_tag(const godot_object *p_object)
return nullptr;
}
- if (script->get_script_desc())
+ if (script->get_script_desc()) {
return script->get_script_desc()->type_tag;
+ }
}
return nullptr;
diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp
index ed3ec44bf7..f3dfd0b68e 100644
--- a/modules/gdnative/nativescript/nativescript.cpp
+++ b/modules/gdnative/nativescript/nativescript.cpp
@@ -169,7 +169,6 @@ String NativeScript::get_script_class_icon_path() const {
}
bool NativeScript::can_instance() const {
-
NativeScriptDesc *script_data = get_script_desc();
#ifdef TOOLS_ENABLED
@@ -185,8 +184,9 @@ bool NativeScript::can_instance() const {
Ref<Script> NativeScript::get_base_script() const {
NativeScriptDesc *script_data = get_script_desc();
- if (!script_data)
+ if (!script_data) {
return Ref<Script>();
+ }
NativeScript *script = (NativeScript *)NSL->create_script();
Ref<NativeScript> ns = Ref<NativeScript>(script);
@@ -200,14 +200,14 @@ Ref<Script> NativeScript::get_base_script() const {
StringName NativeScript::get_instance_base_type() const {
NativeScriptDesc *script_data = get_script_desc();
- if (!script_data)
+ if (!script_data) {
return "";
+ }
return script_data->base_native_type;
}
ScriptInstance *NativeScript::instance_create(Object *p_this) {
-
NativeScriptDesc *script_data = get_script_desc();
if (!script_data) {
@@ -274,8 +274,9 @@ bool NativeScript::has_method(const StringName &p_method) const {
NativeScriptDesc *script_data = get_script_desc();
while (script_data) {
- if (script_data->methods.has(p_method))
+ if (script_data->methods.has(p_method)) {
return true;
+ }
script_data = script_data->base_data;
}
@@ -285,14 +286,16 @@ bool NativeScript::has_method(const StringName &p_method) const {
MethodInfo NativeScript::get_method_info(const StringName &p_method) const {
NativeScriptDesc *script_data = get_script_desc();
- if (!script_data)
+ if (!script_data) {
return MethodInfo();
+ }
while (script_data) {
Map<StringName, NativeScriptDesc::Method>::Element *M = script_data->methods.find(p_method);
- if (M)
+ if (M) {
return M->get().info;
+ }
script_data = script_data->base_data;
}
@@ -306,8 +309,9 @@ bool NativeScript::is_valid() const {
bool NativeScript::is_tool() const {
NativeScriptDesc *script_data = get_script_desc();
- if (script_data)
+ if (script_data) {
return script_data->is_tool;
+ }
return false;
}
@@ -320,8 +324,9 @@ bool NativeScript::has_script_signal(const StringName &p_signal) const {
NativeScriptDesc *script_data = get_script_desc();
while (script_data) {
- if (script_data->signals_.has(p_signal))
+ if (script_data->signals_.has(p_signal)) {
return true;
+ }
script_data = script_data->base_data;
}
return false;
@@ -330,13 +335,13 @@ bool NativeScript::has_script_signal(const StringName &p_signal) const {
void NativeScript::get_script_signal_list(List<MethodInfo> *r_signals) const {
NativeScriptDesc *script_data = get_script_desc();
- if (!script_data)
+ if (!script_data) {
return;
+ }
Set<MethodInfo> signals_;
while (script_data) {
-
for (Map<StringName, NativeScriptDesc::Signal>::Element *S = script_data->signals_.front(); S; S = S->next()) {
signals_.insert(S->get().signal);
}
@@ -357,8 +362,9 @@ bool NativeScript::get_property_default_value(const StringName &p_property, Vari
P = script_data->properties.find(p_property);
script_data = script_data->base_data;
}
- if (!P)
+ if (!P) {
return false;
+ }
r_value = P.get().default_value;
return true;
@@ -370,13 +376,13 @@ void NativeScript::update_exports() {
void NativeScript::get_script_method_list(List<MethodInfo> *p_list) const {
NativeScriptDesc *script_data = get_script_desc();
- if (!script_data)
+ if (!script_data) {
return;
+ }
Set<MethodInfo> methods;
while (script_data) {
-
for (Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.front(); E; E = E->next()) {
methods.insert(E->get().info);
}
@@ -408,13 +414,11 @@ void NativeScript::get_script_property_list(List<PropertyInfo> *p_list) const {
}
Vector<ScriptNetData> NativeScript::get_rpc_methods() const {
-
Vector<ScriptNetData> v;
NativeScriptDesc *script_data = get_script_desc();
while (script_data) {
-
for (Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.front(); E; E = E->next()) {
if (E->get().rpc_mode != GODOT_METHOD_RPC_MODE_DISABLED) {
ScriptNetData nd;
@@ -434,7 +438,6 @@ uint16_t NativeScript::get_rpc_method_id(const StringName &p_method) const {
NativeScriptDesc *script_data = get_script_desc();
while (script_data) {
-
Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.find(p_method);
if (E) {
return E->get().rpc_method_id;
@@ -452,7 +455,6 @@ StringName NativeScript::get_rpc_method(uint16_t p_id) const {
NativeScriptDesc *script_data = get_script_desc();
while (script_data) {
-
for (Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.front(); E; E = E->next()) {
if (E->get().rpc_method_id == p_id) {
return E->key();
@@ -466,13 +468,11 @@ StringName NativeScript::get_rpc_method(uint16_t p_id) const {
}
MultiplayerAPI::RPCMode NativeScript::get_rpc_mode_by_id(uint16_t p_id) const {
-
ERR_FAIL_COND_V(p_id == UINT16_MAX, MultiplayerAPI::RPC_MODE_DISABLED);
NativeScriptDesc *script_data = get_script_desc();
while (script_data) {
-
for (Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.front(); E; E = E->next()) {
if (E->get().rpc_method_id == p_id) {
switch (E->get().rpc_mode) {
@@ -503,11 +503,9 @@ MultiplayerAPI::RPCMode NativeScript::get_rpc_mode_by_id(uint16_t p_id) const {
}
MultiplayerAPI::RPCMode NativeScript::get_rpc_mode(const StringName &p_method) const {
-
NativeScriptDesc *script_data = get_script_desc();
while (script_data) {
-
Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.find(p_method);
if (E) {
switch (E->get().rpc_mode) {
@@ -542,7 +540,6 @@ Vector<ScriptNetData> NativeScript::get_rset_properties() const {
NativeScriptDesc *script_data = get_script_desc();
while (script_data) {
-
for (OrderedHashMap<StringName, NativeScriptDesc::Property>::Element E = script_data->properties.front(); E; E = E.next()) {
if (E.get().rset_mode != GODOT_METHOD_RPC_MODE_DISABLED) {
ScriptNetData nd;
@@ -561,7 +558,6 @@ uint16_t NativeScript::get_rset_property_id(const StringName &p_variable) const
NativeScriptDesc *script_data = get_script_desc();
while (script_data) {
-
OrderedHashMap<StringName, NativeScriptDesc::Property>::Element E = script_data->properties.find(p_variable);
if (E) {
return E.get().rset_property_id;
@@ -579,7 +575,6 @@ StringName NativeScript::get_rset_property(uint16_t p_id) const {
NativeScriptDesc *script_data = get_script_desc();
while (script_data) {
-
for (OrderedHashMap<StringName, NativeScriptDesc::Property>::Element E = script_data->properties.front(); E; E = E.next()) {
if (E.get().rset_property_id == p_id) {
return E.key();
@@ -593,13 +588,11 @@ StringName NativeScript::get_rset_property(uint16_t p_id) const {
}
MultiplayerAPI::RPCMode NativeScript::get_rset_mode_by_id(uint16_t p_id) const {
-
ERR_FAIL_COND_V(p_id == UINT16_MAX, MultiplayerAPI::RPC_MODE_DISABLED);
NativeScriptDesc *script_data = get_script_desc();
while (script_data) {
-
for (OrderedHashMap<StringName, NativeScriptDesc::Property>::Element E = script_data->properties.front(); E; E = E.next()) {
if (E.get().rset_property_id == p_id) {
switch (E.get().rset_mode) {
@@ -630,11 +623,9 @@ MultiplayerAPI::RPCMode NativeScript::get_rset_mode_by_id(uint16_t p_id) const {
}
MultiplayerAPI::RPCMode NativeScript::get_rset_mode(const StringName &p_variable) const {
-
NativeScriptDesc *script_data = get_script_desc();
while (script_data) {
-
OrderedHashMap<StringName, NativeScriptDesc::Property>::Element E = script_data->properties.find(p_variable);
if (E) {
switch (E.get().rset_mode) {
@@ -677,7 +668,6 @@ String NativeScript::get_method_documentation(const StringName &p_method) const
ERR_FAIL_COND_V_MSG(!script_data, "", "Attempt to get method documentation on invalid NativeScript.");
while (script_data) {
-
Map<StringName, NativeScriptDesc::Method>::Element *method = script_data->methods.find(p_method);
if (method) {
@@ -696,7 +686,6 @@ String NativeScript::get_signal_documentation(const StringName &p_signal_name) c
ERR_FAIL_COND_V_MSG(!script_data, "", "Attempt to get signal documentation on invalid NativeScript.");
while (script_data) {
-
Map<StringName, NativeScriptDesc::Signal>::Element *signal = script_data->signals_.find(p_signal_name);
if (signal) {
@@ -715,7 +704,6 @@ String NativeScript::get_property_documentation(const StringName &p_path) const
ERR_FAIL_COND_V_MSG(!script_data, "", "Attempt to get property documentation on invalid NativeScript.");
while (script_data) {
-
OrderedHashMap<StringName, NativeScriptDesc::Property>::Element property = script_data->properties.find(p_path);
if (property) {
@@ -729,7 +717,6 @@ String NativeScript::get_property_documentation(const StringName &p_path) const
}
Variant NativeScript::_new(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
-
if (lib_path.empty() || class_name.empty() || library.is_null()) {
r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL;
return Variant();
@@ -840,6 +827,7 @@ bool NativeScriptInstance::set(const StringName &p_name, const Variant &p_value)
}
return false;
}
+
bool NativeScriptInstance::get(const StringName &p_name, Variant &r_ret) const {
NativeScriptDesc *script_data = GET_SCRIPT_DESC();
@@ -884,10 +872,8 @@ void NativeScriptInstance::get_property_list(List<PropertyInfo> *p_properties) c
NativeScriptDesc *script_data = GET_SCRIPT_DESC();
while (script_data) {
-
Map<StringName, NativeScriptDesc::Method>::Element *E = script_data->methods.find("_get_property_list");
if (E) {
-
godot_variant result;
result = E->get().method.method((godot_object *)owner,
E->get().method.method_data,
@@ -936,11 +922,9 @@ void NativeScriptInstance::get_property_list(List<PropertyInfo> *p_properties) c
}
Variant::Type NativeScriptInstance::get_property_type(const StringName &p_name, bool *r_is_valid) const {
-
NativeScriptDesc *script_data = GET_SCRIPT_DESC();
while (script_data) {
-
OrderedHashMap<StringName, NativeScriptDesc::Property>::Element P = script_data->properties.find(p_name);
if (P) {
*r_is_valid = true;
@@ -961,7 +945,6 @@ bool NativeScriptInstance::has_method(const StringName &p_method) const {
}
Variant NativeScriptInstance::call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
-
NativeScriptDesc *script_data = GET_SCRIPT_DESC();
while (script_data) {
@@ -1017,17 +1000,20 @@ String NativeScriptInstance::to_string(bool *r_valid) {
Variant ret = call(CoreStringNames::get_singleton()->_to_string, nullptr, 0, ce);
if (ce.error == Callable::CallError::CALL_OK) {
if (ret.get_type() != Variant::STRING) {
- if (r_valid)
+ if (r_valid) {
*r_valid = false;
+ }
ERR_FAIL_V_MSG(String(), "Wrong type for " + CoreStringNames::get_singleton()->_to_string + ", must be a String.");
}
- if (r_valid)
+ if (r_valid) {
*r_valid = true;
+ }
return ret.operator String();
}
}
- if (r_valid)
+ if (r_valid) {
*r_valid = false;
+ }
return String();
}
@@ -1127,11 +1113,11 @@ void NativeScriptInstance::call_multilevel_reversed(const StringName &p_method,
}
NativeScriptInstance::~NativeScriptInstance() {
-
NativeScriptDesc *script_data = GET_SCRIPT_DESC();
- if (!script_data)
+ if (!script_data) {
return;
+ }
script_data->destroy_func.destroy_func((godot_object *)owner, script_data->destroy_func.method_data, userdata);
@@ -1145,16 +1131,13 @@ NativeScriptInstance::~NativeScriptInstance() {
NativeScriptLanguage *NativeScriptLanguage::singleton;
void NativeScriptLanguage::_unload_stuff(bool p_reload) {
-
Map<String, Ref<GDNative>> erase_and_unload;
for (Map<String, Map<StringName, NativeScriptDesc>>::Element *L = library_classes.front(); L; L = L->next()) {
-
String lib_path = L->key();
Map<StringName, NativeScriptDesc> classes = L->get();
if (p_reload) {
-
Map<String, Ref<GDNative>>::Element *E = library_gdnatives.find(lib_path);
Ref<GDNative> gdn;
@@ -1184,28 +1167,32 @@ void NativeScriptLanguage::_unload_stuff(bool p_reload) {
}
for (Map<StringName, NativeScriptDesc>::Element *C = classes.front(); C; C = C->next()) {
-
// free property stuff first
for (OrderedHashMap<StringName, NativeScriptDesc::Property>::Element P = C->get().properties.front(); P; P = P.next()) {
- if (P.get().getter.free_func)
+ if (P.get().getter.free_func) {
P.get().getter.free_func(P.get().getter.method_data);
+ }
- if (P.get().setter.free_func)
+ if (P.get().setter.free_func) {
P.get().setter.free_func(P.get().setter.method_data);
+ }
}
// free method stuff
for (Map<StringName, NativeScriptDesc::Method>::Element *M = C->get().methods.front(); M; M = M->next()) {
- if (M->get().method.free_func)
+ if (M->get().method.free_func) {
M->get().method.free_func(M->get().method.method_data);
+ }
}
// free constructor/destructor
- if (C->get().create_func.free_func)
+ if (C->get().create_func.free_func) {
C->get().create_func.free_func(C->get().create_func.method_data);
+ }
- if (C->get().destroy_func.free_func)
+ if (C->get().destroy_func.free_func) {
C->get().destroy_func.free_func(C->get().destroy_func.method_data);
+ }
}
erase_and_unload.insert(lib_path, gdn);
@@ -1253,13 +1240,10 @@ NativeScriptLanguage::NativeScriptLanguage() {
}
NativeScriptLanguage::~NativeScriptLanguage() {
-
for (Map<String, Ref<GDNative>>::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) {
-
Ref<GDNative> lib = L->get();
// only shut down valid libs, duh!
if (lib.is_valid()) {
-
// If it's a singleton-library then the gdnative module
// manages the destruction at engine shutdown, not NativeScript.
if (!lib->get_library()->is_singleton()) {
@@ -1285,7 +1269,6 @@ void _add_reload_node() {
}
void NativeScriptLanguage::init() {
-
#if defined(TOOLS_ENABLED) && defined(DEBUG_METHODS_ENABLED)
List<String> args = OS::get_singleton()->get_cmdline_args();
@@ -1304,22 +1287,29 @@ void NativeScriptLanguage::init() {
EditorNode::add_init_callback(&_add_reload_node);
#endif
}
+
String NativeScriptLanguage::get_type() const {
return "NativeScript";
}
+
String NativeScriptLanguage::get_extension() const {
return "gdns";
}
+
Error NativeScriptLanguage::execute_file(const String &p_path) {
return OK; // Qué?
}
+
void NativeScriptLanguage::finish() {
_unload_stuff();
}
+
void NativeScriptLanguage::get_reserved_words(List<String> *p_words) const {
}
+
void NativeScriptLanguage::get_comment_delimiters(List<String> *p_delimiters) const {
}
+
void NativeScriptLanguage::get_string_delimiters(List<String> *p_delimiters) const {
}
@@ -1328,6 +1318,7 @@ Ref<Script> NativeScriptLanguage::get_template(const String &p_class_name, const
s->set_class_name(p_class_name);
return Ref<NativeScript>(s);
}
+
bool NativeScriptLanguage::validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path, List<String> *r_functions, List<ScriptLanguage::Warning> *r_warnings, Set<int> *r_safe_lines) const {
return true;
}
@@ -1336,20 +1327,26 @@ Script *NativeScriptLanguage::create_script() const {
NativeScript *script = memnew(NativeScript);
return script;
}
+
bool NativeScriptLanguage::has_named_classes() const {
return true;
}
+
bool NativeScriptLanguage::supports_builtin_mode() const {
return true;
}
+
int NativeScriptLanguage::find_function(const String &p_function, const String &p_code) const {
return -1;
}
+
String NativeScriptLanguage::make_function(const String &p_class, const String &p_name, const PackedStringArray &p_args) const {
return "";
}
+
void NativeScriptLanguage::auto_indent_code(String &p_code, int p_from_line, int p_to_line) const {
}
+
void NativeScriptLanguage::add_global_constant(const StringName &p_variable, const Variant &p_value) {
}
@@ -1357,27 +1354,36 @@ void NativeScriptLanguage::add_global_constant(const StringName &p_variable, con
String NativeScriptLanguage::debug_get_error() const {
return "";
}
+
int NativeScriptLanguage::debug_get_stack_level_count() const {
return -1;
}
+
int NativeScriptLanguage::debug_get_stack_level_line(int p_level) const {
return -1;
}
+
String NativeScriptLanguage::debug_get_stack_level_function(int p_level) const {
return "";
}
+
String NativeScriptLanguage::debug_get_stack_level_source(int p_level) const {
return "";
}
+
void NativeScriptLanguage::debug_get_stack_level_locals(int p_level, List<String> *p_locals, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {
}
+
void NativeScriptLanguage::debug_get_stack_level_members(int p_level, List<String> *p_members, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {
}
+
void NativeScriptLanguage::debug_get_globals(List<String> *p_locals, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {
}
+
String NativeScriptLanguage::debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems, int p_max_depth) {
return "";
}
+
// Debugging stuff end.
void NativeScriptLanguage::reload_all_scripts() {
@@ -1385,6 +1391,7 @@ void NativeScriptLanguage::reload_all_scripts() {
void NativeScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload) {
}
+
void NativeScriptLanguage::get_recognized_extensions(List<String> *p_extensions) const {
p_extensions->push_back("gdns");
}
@@ -1419,8 +1426,9 @@ int NativeScriptLanguage::profiling_get_accumulated_data(ProfilingInfo *p_info_a
int current = 0;
for (Map<StringName, ProfileData>::Element *d = profile_data.front(); d; d = d->next()) {
- if (current >= p_info_max)
+ if (current >= p_info_max) {
break;
+ }
p_info_arr[current].call_count = d->get().call_count;
p_info_arr[current].self_time = d->get().self_time;
@@ -1442,8 +1450,9 @@ int NativeScriptLanguage::profiling_get_frame_data(ProfilingInfo *p_info_arr, in
int current = 0;
for (Map<StringName, ProfileData>::Element *d = profile_data.front(); d; d = d->next()) {
- if (current >= p_info_max)
+ if (current >= p_info_max) {
break;
+ }
if (d->get().last_frame_call_count) {
p_info_arr[current].call_count = d->get().last_frame_call_count;
@@ -1490,7 +1499,6 @@ void NativeScriptLanguage::profiling_add_data(StringName p_signature, uint64_t p
}
int NativeScriptLanguage::register_binding_functions(godot_instance_binding_functions p_binding_functions) {
-
// find index
int idx = -1;
@@ -1521,14 +1529,16 @@ void NativeScriptLanguage::unregister_binding_functions(int p_idx) {
for (Set<Vector<void *> *>::Element *E = binding_instances.front(); E; E = E->next()) {
Vector<void *> &binding_data = *E->get();
- if (p_idx < binding_data.size() && binding_data[p_idx] && binding_functions[p_idx].second.free_instance_binding_data)
+ if (p_idx < binding_data.size() && binding_data[p_idx] && binding_functions[p_idx].second.free_instance_binding_data) {
binding_functions[p_idx].second.free_instance_binding_data(binding_functions[p_idx].second.data, binding_data[p_idx]);
+ }
}
binding_functions.write[p_idx].first = false;
- if (binding_functions[p_idx].second.free_func)
+ if (binding_functions[p_idx].second.free_func) {
binding_functions[p_idx].second.free_func(binding_functions[p_idx].second.data);
+ }
}
void *NativeScriptLanguage::get_instance_binding_data(int p_idx, Object *p_object) {
@@ -1538,8 +1548,9 @@ void *NativeScriptLanguage::get_instance_binding_data(int p_idx, Object *p_objec
Vector<void *> *binding_data = (Vector<void *> *)p_object->get_script_instance_binding(lang_idx);
- if (!binding_data)
+ if (!binding_data) {
return nullptr; // should never happen.
+ }
if (binding_data->size() <= p_idx) {
// okay, add new elements here.
@@ -1553,7 +1564,6 @@ void *NativeScriptLanguage::get_instance_binding_data(int p_idx, Object *p_objec
}
if (!(*binding_data)[p_idx]) {
-
const void *global_type_tag = get_global_type_tag(p_idx, p_object->get_class_name());
// no binding data yet, soooooo alloc new one \o/
@@ -1564,7 +1574,6 @@ void *NativeScriptLanguage::get_instance_binding_data(int p_idx, Object *p_objec
}
void *NativeScriptLanguage::alloc_instance_binding_data(Object *p_object) {
-
Vector<void *> *binding_data = new Vector<void *>;
binding_data->resize(binding_functions.size());
@@ -1579,15 +1588,16 @@ void *NativeScriptLanguage::alloc_instance_binding_data(Object *p_object) {
}
void NativeScriptLanguage::free_instance_binding_data(void *p_data) {
-
- if (!p_data)
+ if (!p_data) {
return;
+ }
Vector<void *> &binding_data = *(Vector<void *> *)p_data;
for (int i = 0; i < binding_data.size(); i++) {
- if (!binding_data[i])
+ if (!binding_data[i]) {
continue;
+ }
if (binding_functions[i].first && binding_functions[i].second.free_instance_binding_data) {
binding_functions[i].second.free_instance_binding_data(binding_functions[i].second.data, binding_data[i]);
@@ -1600,20 +1610,22 @@ void NativeScriptLanguage::free_instance_binding_data(void *p_data) {
}
void NativeScriptLanguage::refcount_incremented_instance_binding(Object *p_object) {
-
void *data = p_object->get_script_instance_binding(lang_idx);
- if (!data)
+ if (!data) {
return;
+ }
Vector<void *> &binding_data = *(Vector<void *> *)data;
for (int i = 0; i < binding_data.size(); i++) {
- if (!binding_data[i])
+ if (!binding_data[i]) {
continue;
+ }
- if (!binding_functions[i].first)
+ if (!binding_functions[i].first) {
continue;
+ }
if (binding_functions[i].second.refcount_incremented_instance_binding) {
binding_functions[i].second.refcount_incremented_instance_binding(binding_data[i], p_object);
@@ -1622,22 +1634,24 @@ void NativeScriptLanguage::refcount_incremented_instance_binding(Object *p_objec
}
bool NativeScriptLanguage::refcount_decremented_instance_binding(Object *p_object) {
-
void *data = p_object->get_script_instance_binding(lang_idx);
- if (!data)
+ if (!data) {
return true;
+ }
Vector<void *> &binding_data = *(Vector<void *> *)data;
bool can_die = true;
for (int i = 0; i < binding_data.size(); i++) {
- if (!binding_data[i])
+ if (!binding_data[i]) {
continue;
+ }
- if (!binding_functions[i].first)
+ if (!binding_functions[i].first) {
continue;
+ }
if (binding_functions[i].second.refcount_decremented_instance_binding) {
can_die = can_die && binding_functions[i].second.refcount_decremented_instance_binding(binding_data[i], p_object);
@@ -1658,13 +1672,15 @@ void NativeScriptLanguage::set_global_type_tag(int p_idx, StringName p_class_nam
}
const void *NativeScriptLanguage::get_global_type_tag(int p_idx, StringName p_class_name) const {
- if (!global_type_tags.has(p_idx))
+ if (!global_type_tags.has(p_idx)) {
return nullptr;
+ }
const HashMap<StringName, const void *> &tags = global_type_tags[p_idx];
- if (!tags.has(p_class_name))
+ if (!tags.has(p_class_name)) {
return nullptr;
+ }
const void *tag = tags.get(p_class_name);
@@ -1700,8 +1716,9 @@ void NativeScriptLanguage::init_library(const Ref<GDNativeLibrary> &lib) {
library_classes.insert(lib_path, Map<StringName, NativeScriptDesc>());
- if (!library_script_users.has(lib_path))
+ if (!library_script_users.has(lib_path)) {
library_script_users.insert(lib_path, Set<NativeScript *>());
+ }
void *proc_ptr;
@@ -1741,13 +1758,11 @@ void NativeScriptLanguage::unregister_script(NativeScript *script) {
void NativeScriptLanguage::call_libraries_cb(const StringName &name) {
// library_gdnatives is modified only from the main thread, so it's safe not to use mutex here
for (Map<String, Ref<GDNative>>::Element *L = library_gdnatives.front(); L; L = L->next()) {
-
if (L->get().is_null()) {
continue;
}
if (L->get()->is_initialized()) {
-
void *proc_ptr;
Error err = L->get()->get_symbol(L->get()->get_library()->get_symbol_prefix() + name, proc_ptr);
@@ -1812,16 +1827,20 @@ String NativeScriptLanguage::get_global_class_name(const String &p_path, String
if (!p_path.empty()) {
Ref<NativeScript> script = ResourceLoader::load(p_path, "NativeScript");
if (script.is_valid()) {
- if (r_base_type)
+ if (r_base_type) {
*r_base_type = script->get_instance_base_type();
- if (r_icon_path)
+ }
+ if (r_icon_path) {
*r_icon_path = script->get_script_class_icon_path();
+ }
return script->get_script_class_name();
}
- if (r_base_type)
+ if (r_base_type) {
*r_base_type = String();
- if (r_icon_path)
+ }
+ if (r_icon_path) {
*r_icon_path = String();
+ }
}
return String();
}
@@ -1835,14 +1854,13 @@ void NativeReloadNode::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_WM_FOCUS_OUT: {
-
- if (unloaded)
+ if (unloaded) {
break;
+ }
MutexLock lock(NSL->mutex);
NSL->_unload_stuff(true);
for (Map<String, Ref<GDNative>>::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) {
-
Ref<GDNative> gdn = L->get();
if (gdn.is_null()) {
@@ -1870,14 +1888,13 @@ void NativeReloadNode::_notification(int p_what) {
} break;
case NOTIFICATION_WM_FOCUS_IN: {
-
- if (!unloaded)
+ if (!unloaded) {
break;
+ }
MutexLock lock(NSL->mutex);
Set<StringName> libs_to_remove;
for (Map<String, Ref<GDNative>>::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) {
-
Ref<GDNative> gdn = L->get();
if (gdn.is_null()) {
@@ -1915,8 +1932,9 @@ void NativeReloadNode::_notification(int p_what) {
for (Set<NativeScript *>::Element *S = U->get().front(); S; S = S->next()) {
NativeScript *script = S->get();
- if (script->placeholders.size() == 0)
+ if (script->placeholders.size() == 0) {
continue;
+ }
for (Set<PlaceHolderScriptInstance *>::Element *P = script->placeholders.front(); P; P = P->next()) {
script->_update_placeholder(P->get());
@@ -1952,8 +1970,9 @@ bool ResourceFormatLoaderNativeScript::handles_type(const String &p_type) const
String ResourceFormatLoaderNativeScript::get_resource_type(const String &p_path) const {
String el = p_path.get_extension().to_lower();
- if (el == "gdns")
+ if (el == "gdns") {
return "NativeScript";
+ }
return "";
}
diff --git a/modules/gdnative/nativescript/nativescript.h b/modules/gdnative/nativescript/nativescript.h
index 7e7598e06c..1aca142889 100644
--- a/modules/gdnative/nativescript/nativescript.h
+++ b/modules/gdnative/nativescript/nativescript.h
@@ -43,10 +43,10 @@
#include "scene/main/node.h"
#include "modules/gdnative/gdnative.h"
+
#include <nativescript/godot_nativescript.h>
struct NativeScriptDesc {
-
struct Method {
godot_instance_method method;
MethodInfo info;
@@ -54,6 +54,7 @@ struct NativeScriptDesc {
uint16_t rpc_method_id;
String documentation;
};
+
struct Property {
godot_property_set_func setter;
godot_property_get_func getter;
@@ -69,9 +70,9 @@ struct NativeScriptDesc {
String documentation;
};
- uint16_t rpc_count;
+ uint16_t rpc_count = 0;
Map<StringName, Method> methods;
- uint16_t rset_count;
+ uint16_t rset_count = 0;
OrderedHashMap<StringName, Property> properties;
Map<StringName, Signal> signals_; // QtCreator doesn't like the name signals
StringName base;
@@ -82,20 +83,11 @@ struct NativeScriptDesc {
String documentation;
- const void *type_tag;
+ const void *type_tag = nullptr;
bool is_tool;
- inline NativeScriptDesc() :
- rpc_count(0),
- methods(),
- rset_count(0),
- properties(),
- signals_(),
- base(),
- base_native_type(),
- documentation(),
- type_tag(nullptr) {
+ inline NativeScriptDesc() {
zeromem(&create_func, sizeof(godot_instance_create_func));
zeromem(&destroy_func, sizeof(godot_instance_destroy_func));
}
@@ -201,7 +193,6 @@ public:
};
class NativeScriptInstance : public ScriptInstance {
-
friend class NativeScript;
Object *owner;
@@ -252,7 +243,6 @@ public:
class NativeReloadNode;
class NativeScriptLanguage : public ScriptLanguage {
-
friend class NativeScript;
friend class NativeScriptInstance;
friend class NativeReloadNode;
@@ -396,14 +386,13 @@ inline NativeScriptDesc *NativeScript::get_script_desc() const {
class NativeReloadNode : public Node {
GDCLASS(NativeReloadNode, Node);
- bool unloaded;
+ bool unloaded = false;
public:
static void _bind_methods();
void _notification(int p_what);
- NativeReloadNode() :
- unloaded(false) {}
+ NativeReloadNode() {}
};
class ResourceFormatLoaderNativeScript : public ResourceFormatLoader {
diff --git a/modules/gdnative/nativescript/register_types.cpp b/modules/gdnative/nativescript/register_types.cpp
index b5e8174e43..ac8c7ab2fd 100644
--- a/modules/gdnative/nativescript/register_types.cpp
+++ b/modules/gdnative/nativescript/register_types.cpp
@@ -58,7 +58,6 @@ void register_nativescript_types() {
}
void unregister_nativescript_types() {
-
ResourceLoader::remove_resource_format_loader(resource_loader_gdns);
resource_loader_gdns.unref();
diff --git a/modules/gdnative/net/multiplayer_peer_gdnative.cpp b/modules/gdnative/net/multiplayer_peer_gdnative.cpp
index a95697ea65..997eec6425 100644
--- a/modules/gdnative/net/multiplayer_peer_gdnative.cpp
+++ b/modules/gdnative/net/multiplayer_peer_gdnative.cpp
@@ -120,7 +120,6 @@ void MultiplayerPeerGDNative::_bind_methods() {
extern "C" {
void GDAPI godot_net_bind_multiplayer_peer(godot_object *p_obj, const godot_net_multiplayer_peer *p_impl) {
-
((MultiplayerPeerGDNative *)p_obj)->set_native_multiplayer_peer(p_impl);
}
}
diff --git a/modules/gdnative/net/packet_peer_gdnative.cpp b/modules/gdnative/net/packet_peer_gdnative.cpp
index 28135df3b6..6bb21cb48d 100644
--- a/modules/gdnative/net/packet_peer_gdnative.cpp
+++ b/modules/gdnative/net/packet_peer_gdnative.cpp
@@ -67,7 +67,6 @@ int PacketPeerGDNative::get_available_packet_count() const {
extern "C" {
void GDAPI godot_net_bind_packet_peer(godot_object *p_obj, const godot_net_packet_peer *p_impl) {
-
((PacketPeerGDNative *)p_obj)->set_native_packet_peer(p_impl);
}
}
diff --git a/modules/gdnative/net/stream_peer_gdnative.h b/modules/gdnative/net/stream_peer_gdnative.h
index f3711e0f0f..0b2f995aa7 100644
--- a/modules/gdnative/net/stream_peer_gdnative.h
+++ b/modules/gdnative/net/stream_peer_gdnative.h
@@ -36,7 +36,6 @@
#include "modules/gdnative/include/net/godot_net.h"
class StreamPeerGDNative : public StreamPeer {
-
GDCLASS(StreamPeerGDNative, StreamPeer);
protected:
diff --git a/modules/gdnative/pluginscript/pluginscript_loader.cpp b/modules/gdnative/pluginscript/pluginscript_loader.cpp
index 64582cc517..4feee4f4a5 100644
--- a/modules/gdnative/pluginscript/pluginscript_loader.cpp
+++ b/modules/gdnative/pluginscript/pluginscript_loader.cpp
@@ -40,8 +40,9 @@ ResourceFormatLoaderPluginScript::ResourceFormatLoaderPluginScript(PluginScriptL
}
RES ResourceFormatLoaderPluginScript::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, bool p_no_cache) {
- if (r_error)
+ if (r_error) {
*r_error = ERR_FILE_CANT_OPEN;
+ }
PluginScript *script = memnew(PluginScript);
script->init(_language);
@@ -55,8 +56,9 @@ RES ResourceFormatLoaderPluginScript::load(const String &p_path, const String &p
script->reload();
- if (r_error)
+ if (r_error) {
*r_error = OK;
+ }
return scriptres;
}
@@ -71,8 +73,9 @@ bool ResourceFormatLoaderPluginScript::handles_type(const String &p_type) const
String ResourceFormatLoaderPluginScript::get_resource_type(const String &p_path) const {
String el = p_path.get_extension().to_lower();
- if (el == _language->get_extension())
+ if (el == _language->get_extension()) {
return _language->get_type();
+ }
return "";
}
@@ -101,13 +104,11 @@ Error ResourceFormatSaverPluginScript::save(const String &p_path, const RES &p_r
}
void ResourceFormatSaverPluginScript::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const {
-
if (Object::cast_to<PluginScript>(*p_resource)) {
p_extensions->push_back(_language->get_extension());
}
}
bool ResourceFormatSaverPluginScript::recognize(const RES &p_resource) const {
-
return Object::cast_to<PluginScript>(*p_resource) != nullptr;
}
diff --git a/modules/gdnative/pluginscript/pluginscript_loader.h b/modules/gdnative/pluginscript/pluginscript_loader.h
index e47754490a..35fc79c2ca 100644
--- a/modules/gdnative/pluginscript/pluginscript_loader.h
+++ b/modules/gdnative/pluginscript/pluginscript_loader.h
@@ -39,7 +39,6 @@
class PluginScriptLanguage;
class ResourceFormatLoaderPluginScript : public ResourceFormatLoader {
-
PluginScriptLanguage *_language;
public:
@@ -51,7 +50,6 @@ public:
};
class ResourceFormatSaverPluginScript : public ResourceFormatSaver {
-
PluginScriptLanguage *_language;
public:
diff --git a/modules/gdnative/pluginscript/pluginscript_script.cpp b/modules/gdnative/pluginscript/pluginscript_script.cpp
index 6b303c8716..87c6288806 100644
--- a/modules/gdnative/pluginscript/pluginscript_script.cpp
+++ b/modules/gdnative/pluginscript/pluginscript_script.cpp
@@ -56,7 +56,6 @@ void PluginScript::_bind_methods() {
}
PluginScriptInstance *PluginScript::_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, Callable::CallError &r_error) {
-
r_error.error = Callable::CallError::CALL_OK;
// Create instance
@@ -84,7 +83,6 @@ PluginScriptInstance *PluginScript::_create_instance(const Variant **p_args, int
}
Variant PluginScript::_new(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
-
r_error.error = Callable::CallError::CALL_OK;
if (!_valid) {
@@ -156,10 +154,12 @@ Ref<Script> PluginScript::get_base_script() const {
}
StringName PluginScript::get_instance_base_type() const {
- if (_native_parent)
+ if (_native_parent) {
return _native_parent;
- if (_ref_base_parent.is_valid())
+ }
+ if (_ref_base_parent.is_valid()) {
return _ref_base_parent->get_instance_base_type();
+ }
return StringName();
}
@@ -167,7 +167,6 @@ void PluginScript::update_exports() {
#ifdef TOOLS_ENABLED
ASSERT_SCRIPT_VALID();
if (placeholders.size()) {
-
//update placeholders if any
Map<StringName, Variant> propdefvalues;
List<PropertyInfo> propinfos;
@@ -229,8 +228,9 @@ String PluginScript::get_source_code() const {
}
void PluginScript::set_source_code(const String &p_code) {
- if (_source == p_code)
+ if (_source == p_code) {
return;
+ }
_source = p_code;
}
@@ -244,11 +244,13 @@ Error PluginScript::reload(bool p_keep_state) {
_valid = false;
String basedir = _path;
- if (basedir == "")
+ if (basedir == "") {
basedir = get_path();
+ }
- if (basedir != "")
+ if (basedir != "") {
basedir = basedir.get_base_dir();
+ }
if (_data) {
_desc->finish(_data);
@@ -281,7 +283,6 @@ Error PluginScript::reload(bool p_keep_state) {
// ClassDB name (i.e. `Node2D`) or a resource path (i.e. `res://foo/bar.gd`)
StringName *base_name = (StringName *)&manifest.base;
if (*base_name) {
-
if (ClassDB::class_exists(*base_name)) {
_native_parent = *base_name;
} else {
@@ -434,7 +435,6 @@ ScriptLanguage *PluginScript::get_language() const {
}
Error PluginScript::load_source_code(const String &p_path) {
-
Vector<uint8_t> sourcef;
Error err;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
@@ -476,11 +476,11 @@ void PluginScript::get_script_signal_list(List<MethodInfo> *r_signals) const {
int PluginScript::get_member_line(const StringName &p_member) const {
#ifdef TOOLS_ENABLED
- if (_member_lines.has(p_member))
+ if (_member_lines.has(p_member)) {
return _member_lines[p_member];
- else
+ }
#endif
- return -1;
+ return -1;
}
Vector<ScriptNetData> PluginScript::get_rpc_methods() const {
@@ -499,15 +499,17 @@ uint16_t PluginScript::get_rpc_method_id(const StringName &p_method) const {
StringName PluginScript::get_rpc_method(const uint16_t p_rpc_method_id) const {
ASSERT_SCRIPT_VALID_V(StringName());
- if (p_rpc_method_id >= _rpc_methods.size())
+ if (p_rpc_method_id >= _rpc_methods.size()) {
return StringName();
+ }
return _rpc_methods[p_rpc_method_id].name;
}
MultiplayerAPI::RPCMode PluginScript::get_rpc_mode_by_id(const uint16_t p_rpc_method_id) const {
ASSERT_SCRIPT_VALID_V(MultiplayerAPI::RPC_MODE_DISABLED);
- if (p_rpc_method_id >= _rpc_methods.size())
+ if (p_rpc_method_id >= _rpc_methods.size()) {
return MultiplayerAPI::RPC_MODE_DISABLED;
+ }
return _rpc_methods[p_rpc_method_id].mode;
}
@@ -532,15 +534,17 @@ uint16_t PluginScript::get_rset_property_id(const StringName &p_property) const
StringName PluginScript::get_rset_property(const uint16_t p_rset_property_id) const {
ASSERT_SCRIPT_VALID_V(StringName());
- if (p_rset_property_id >= _rpc_variables.size())
+ if (p_rset_property_id >= _rpc_variables.size()) {
return StringName();
+ }
return _rpc_variables[p_rset_property_id].name;
}
MultiplayerAPI::RPCMode PluginScript::get_rset_mode_by_id(const uint16_t p_rset_property_id) const {
ASSERT_SCRIPT_VALID_V(MultiplayerAPI::RPC_MODE_DISABLED);
- if (p_rset_property_id >= _rpc_variables.size())
+ if (p_rset_property_id >= _rpc_variables.size()) {
return MultiplayerAPI::RPC_MODE_DISABLED;
+ }
return _rpc_variables[p_rset_property_id].mode;
}
@@ -550,11 +554,6 @@ MultiplayerAPI::RPCMode PluginScript::get_rset_mode(const StringName &p_variable
}
PluginScript::PluginScript() :
- _data(nullptr),
- _desc(nullptr),
- _language(nullptr),
- _tool(false),
- _valid(false),
_script_list(this) {
}
diff --git a/modules/gdnative/pluginscript/pluginscript_script.h b/modules/gdnative/pluginscript/pluginscript_script.h
index 70b9ca980b..659289ef9b 100644
--- a/modules/gdnative/pluginscript/pluginscript_script.h
+++ b/modules/gdnative/pluginscript/pluginscript_script.h
@@ -38,18 +38,17 @@
#include <pluginscript/godot_pluginscript.h>
class PluginScript : public Script {
-
GDCLASS(PluginScript, Script);
friend class PluginScriptInstance;
friend class PluginScriptLanguage;
private:
- godot_pluginscript_script_data *_data;
- const godot_pluginscript_script_desc *_desc;
- PluginScriptLanguage *_language;
- bool _tool;
- bool _valid;
+ godot_pluginscript_script_data *_data = nullptr;
+ const godot_pluginscript_script_desc *_desc = nullptr;
+ PluginScriptLanguage *_language = nullptr;
+ bool _tool = false;
+ bool _valid = false;
Ref<Script> _ref_base_parent;
StringName _native_parent;
diff --git a/modules/gdnative/register_types.cpp b/modules/gdnative/register_types.cpp
index 67a286ee2e..136af5bd1e 100644
--- a/modules/gdnative/register_types.cpp
+++ b/modules/gdnative/register_types.cpp
@@ -53,7 +53,6 @@
#include "gdnative_library_singleton_editor.h"
class GDNativeExportPlugin : public EditorExportPlugin {
-
protected:
virtual void _export_file(const String &p_path, const String &p_type, const Set<String> &p_features);
};
@@ -77,7 +76,6 @@ void GDNativeExportPlugin::_export_file(const String &p_path, const String &p_ty
Ref<ConfigFile> config = lib->get_config_file();
{
-
List<String> entry_keys;
config->get_section_keys("entry", &entry_keys);
@@ -189,7 +187,6 @@ void GDNativeExportPlugin::_export_file(const String &p_path, const String &p_ty
}
static void editor_init_callback() {
-
GDNativeLibrarySingletonEditor *library_editor = memnew(GDNativeLibrarySingletonEditor);
library_editor->set_name(TTR("GDNative"));
ProjectSettingsEditor::get_singleton()->get_tabs()->add_child(library_editor);
@@ -205,7 +202,6 @@ static void editor_init_callback() {
#endif
static godot_variant cb_standard_varcall(void *p_procedure_handle, godot_array *p_args) {
-
godot_gdnative_procedure_fn proc;
proc = (godot_gdnative_procedure_fn)p_procedure_handle;
@@ -220,7 +216,6 @@ Ref<GDNativeLibraryResourceLoader> resource_loader_gdnlib;
Ref<GDNativeLibraryResourceSaver> resource_saver_gdnlib;
void register_gdnative_types() {
-
#ifdef TOOLS_ENABLED
EditorNode::add_init_callback(editor_init_callback);
@@ -259,8 +254,9 @@ void register_gdnative_types() {
for (int i = 0; i < singletons.size(); i++) {
String path = singletons[i];
- if (excluded.has(path))
+ if (excluded.has(path)) {
continue;
+ }
Ref<GDNativeLibrary> lib = ResourceLoader::load(path);
Ref<GDNative> singleton;
@@ -287,9 +283,7 @@ void register_gdnative_types() {
}
void unregister_gdnative_types() {
-
for (int i = 0; i < singleton_gdnatives.size(); i++) {
-
if (singleton_gdnatives[i].is_null()) {
continue;
}
diff --git a/modules/gdnative/videodecoder/register_types.cpp b/modules/gdnative/videodecoder/register_types.cpp
index c53e8f2c78..4181d8813f 100644
--- a/modules/gdnative/videodecoder/register_types.cpp
+++ b/modules/gdnative/videodecoder/register_types.cpp
@@ -36,7 +36,6 @@
static Ref<ResourceFormatLoaderVideoStreamGDNative> resource_loader_vsgdnative;
void register_videodecoder_types() {
-
resource_loader_vsgdnative.instance();
ResourceLoader::add_resource_format_loader(resource_loader_vsgdnative, true);
@@ -44,7 +43,6 @@ void register_videodecoder_types() {
}
void unregister_videodecoder_types() {
-
ResourceLoader::remove_resource_format_loader(resource_loader_vsgdnative);
resource_loader_vsgdnative.unref();
}
diff --git a/modules/gdnative/videodecoder/video_stream_gdnative.cpp b/modules/gdnative/videodecoder/video_stream_gdnative.cpp
index f7d87595af..9d9c5b6473 100644
--- a/modules/gdnative/videodecoder/video_stream_gdnative.cpp
+++ b/modules/gdnative/videodecoder/video_stream_gdnative.cpp
@@ -105,7 +105,6 @@ int64_t GDAPI godot_videodecoder_file_seek(void *ptr, int64_t pos, int whence) {
}
void GDAPI godot_videodecoder_register_decoder(const godot_videodecoder_interface_gdnative *p_interface) {
-
decoder_server.register_decoder_interface(p_interface);
}
}
@@ -202,32 +201,19 @@ void VideoStreamPlaybackGDNative::update_texture() {
// ctor and dtor
VideoStreamPlaybackGDNative::VideoStreamPlaybackGDNative() :
- texture(Ref<ImageTexture>(memnew(ImageTexture))),
- playing(false),
- paused(false),
- mix_udata(nullptr),
- mix_callback(nullptr),
- num_channels(-1),
- time(0),
- seek_backward(false),
- mix_rate(0),
- delay_compensation(0),
- pcm(nullptr),
- pcm_write_idx(0),
- samples_decoded(0),
- file(nullptr),
- interface(nullptr),
- data_struct(nullptr) {}
+ texture(Ref<ImageTexture>(memnew(ImageTexture))) {}
VideoStreamPlaybackGDNative::~VideoStreamPlaybackGDNative() {
cleanup();
}
void VideoStreamPlaybackGDNative::cleanup() {
- if (data_struct)
+ if (data_struct) {
interface->destructor(data_struct);
- if (pcm)
+ }
+ if (pcm) {
memfree(pcm);
+ }
pcm = nullptr;
time = 0;
num_channels = -1;
@@ -255,7 +241,6 @@ bool VideoStreamPlaybackGDNative::is_paused() const {
}
void VideoStreamPlaybackGDNative::play() {
-
stop();
playing = true;
@@ -274,8 +259,9 @@ void VideoStreamPlaybackGDNative::stop() {
void VideoStreamPlaybackGDNative::seek(float p_time) {
ERR_FAIL_COND(interface == nullptr);
interface->seek(data_struct, p_time);
- if (p_time < time)
+ if (p_time < time) {
seek_backward = true;
+ }
time = p_time;
// reset audio buffers
memset(pcm, 0, num_channels * AUX_BUFFER_SIZE * sizeof(float));
@@ -297,7 +283,6 @@ float VideoStreamPlaybackGDNative::get_length() const {
}
float VideoStreamPlaybackGDNative::get_playback_position() const {
-
ERR_FAIL_COND_V(interface == nullptr, 0);
return interface->get_playback_position(data_struct);
}
@@ -317,7 +302,6 @@ void VideoStreamPlaybackGDNative::set_audio_track(int p_idx) {
}
void VideoStreamPlaybackGDNative::set_mix_callback(AudioMixCallback p_callback, void *p_userdata) {
-
mix_udata = p_userdata;
mix_callback = p_callback;
}
@@ -339,27 +323,26 @@ int VideoStreamPlaybackGDNative::get_mix_rate() const {
Ref<VideoStreamPlayback> VideoStreamGDNative::instance_playback() {
Ref<VideoStreamPlaybackGDNative> pb = memnew(VideoStreamPlaybackGDNative);
VideoDecoderGDNative *decoder = decoder_server.get_decoder(file.get_extension().to_lower());
- if (decoder == nullptr)
+ if (decoder == nullptr) {
return nullptr;
+ }
pb->set_interface(decoder->interface);
pb->set_audio_track(audio_track);
- if (pb->open_file(file))
+ if (pb->open_file(file)) {
return pb;
+ }
return nullptr;
}
void VideoStreamGDNative::set_file(const String &p_file) {
-
file = p_file;
}
String VideoStreamGDNative::get_file() {
-
return file;
}
void VideoStreamGDNative::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_file", "file"), &VideoStreamGDNative::set_file);
ClassDB::bind_method(D_METHOD("get_file"), &VideoStreamGDNative::get_file);
@@ -367,7 +350,6 @@ void VideoStreamGDNative::_bind_methods() {
}
void VideoStreamGDNative::set_audio_track(int p_track) {
-
audio_track = p_track;
}
@@ -405,7 +387,8 @@ bool ResourceFormatLoaderVideoStreamGDNative::handles_type(const String &p_type)
String ResourceFormatLoaderVideoStreamGDNative::get_resource_type(const String &p_path) const {
String el = p_path.get_extension().to_lower();
- if (VideoDecoderServer::get_instance()->get_extensions().has(el))
+ if (VideoDecoderServer::get_instance()->get_extensions().has(el)) {
return "VideoStreamGDNative";
+ }
return "";
}
diff --git a/modules/gdnative/videodecoder/video_stream_gdnative.h b/modules/gdnative/videodecoder/video_stream_gdnative.h
index 092e10a0f5..53017a6a97 100644
--- a/modules/gdnative/videodecoder/video_stream_gdnative.h
+++ b/modules/gdnative/videodecoder/video_stream_gdnative.h
@@ -37,13 +37,11 @@
#include "scene/resources/video_stream.h"
struct VideoDecoderGDNative {
- const godot_videodecoder_interface_gdnative *interface;
- String plugin_name;
+ const godot_videodecoder_interface_gdnative *interface = nullptr;
+ String plugin_name = "none";
Vector<String> supported_extensions;
- VideoDecoderGDNative() :
- interface(nullptr),
- plugin_name("none") {}
+ VideoDecoderGDNative() {}
VideoDecoderGDNative(const godot_videodecoder_interface_gdnative *p_interface) :
interface(p_interface),
@@ -88,8 +86,9 @@ public:
}
VideoDecoderGDNative *get_decoder(const String &extension) {
- if (extensions.size() == 0 || !extensions.has(extension))
+ if (extensions.size() == 0 || !extensions.has(extension)) {
return nullptr;
+ }
return decoders[extensions[extension]];
}
@@ -107,27 +106,26 @@ public:
};
class VideoStreamPlaybackGDNative : public VideoStreamPlayback {
-
GDCLASS(VideoStreamPlaybackGDNative, VideoStreamPlayback);
Ref<ImageTexture> texture;
- bool playing;
- bool paused;
+ bool playing = false;
+ bool paused = false;
Vector2 texture_size;
- void *mix_udata;
- AudioMixCallback mix_callback;
+ void *mix_udata = nullptr;
+ AudioMixCallback mix_callback = nullptr;
- int num_channels;
- float time;
- bool seek_backward;
- int mix_rate;
- double delay_compensation;
+ int num_channels = -1;
+ float time = 0;
+ bool seek_backward = false;
+ int mix_rate = 0;
+ double delay_compensation = 0;
- float *pcm;
- int pcm_write_idx;
- int samples_decoded;
+ float *pcm = nullptr;
+ int pcm_write_idx = 0;
+ int samples_decoded = 0;
void cleanup();
void update_texture();
@@ -135,10 +133,10 @@ class VideoStreamPlaybackGDNative : public VideoStreamPlayback {
protected:
String file_name;
- FileAccess *file;
+ FileAccess *file = nullptr;
- const godot_videodecoder_interface_gdnative *interface;
- void *data_struct;
+ const godot_videodecoder_interface_gdnative *interface = nullptr;
+ void *data_struct = nullptr;
public:
VideoStreamPlaybackGDNative();
@@ -177,11 +175,10 @@ public:
};
class VideoStreamGDNative : public VideoStream {
-
GDCLASS(VideoStreamGDNative, VideoStream);
String file;
- int audio_track;
+ int audio_track = 0;
protected:
static void
@@ -194,7 +191,7 @@ public:
virtual void set_audio_track(int p_track);
virtual Ref<VideoStreamPlayback> instance_playback();
- VideoStreamGDNative() { audio_track = 0; }
+ VideoStreamGDNative() {}
};
class ResourceFormatLoaderVideoStreamGDNative : public ResourceFormatLoader {
diff --git a/modules/gdnative/xr/xr_interface_gdnative.cpp b/modules/gdnative/xr/xr_interface_gdnative.cpp
index d65089a123..d03fc33935 100644
--- a/modules/gdnative/xr/xr_interface_gdnative.cpp
+++ b/modules/gdnative/xr/xr_interface_gdnative.cpp
@@ -80,7 +80,6 @@ void XRInterfaceGDNative::set_interface(const godot_xr_interface_gdnative *p_int
}
StringName XRInterfaceGDNative::get_name() const {
-
ERR_FAIL_COND_V(interface == nullptr, StringName());
godot_string result = interface->get_name(data);
@@ -103,21 +102,18 @@ int XRInterfaceGDNative::get_capabilities() const {
}
bool XRInterfaceGDNative::get_anchor_detection_is_enabled() const {
-
ERR_FAIL_COND_V(interface == nullptr, false);
return interface->get_anchor_detection_is_enabled(data);
}
void XRInterfaceGDNative::set_anchor_detection_is_enabled(bool p_enable) {
-
ERR_FAIL_COND(interface == nullptr);
interface->set_anchor_detection_is_enabled(data, p_enable);
}
int XRInterfaceGDNative::get_camera_feed_id() {
-
ERR_FAIL_COND_V(interface == nullptr, 0);
return (unsigned int)interface->get_camera_feed_id(data);
@@ -134,7 +130,6 @@ bool XRInterfaceGDNative::is_stereo() {
}
bool XRInterfaceGDNative::is_initialized() const {
-
ERR_FAIL_COND_V(interface == nullptr, false);
return interface->is_initialized(data);
@@ -170,7 +165,6 @@ void XRInterfaceGDNative::uninitialize() {
}
Size2 XRInterfaceGDNative::get_render_targetsize() {
-
ERR_FAIL_COND_V(interface == nullptr, Size2());
godot_vector2 result = interface->get_render_targetsize(data);
@@ -202,14 +196,12 @@ CameraMatrix XRInterfaceGDNative::get_projection_for_eye(XRInterface::Eyes p_eye
}
unsigned int XRInterfaceGDNative::get_external_texture_for_eye(XRInterface::Eyes p_eye) {
-
ERR_FAIL_COND_V(interface == nullptr, 0);
return (unsigned int)interface->get_external_texture_for_eye(data, (godot_int)p_eye);
}
void XRInterfaceGDNative::commit_for_eye(XRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect) {
-
ERR_FAIL_COND(interface == nullptr);
interface->commit_for_eye(data, (godot_int)p_eye, (godot_rid *)&p_render_target, (godot_rect2 *)&p_screen_rect);