summaryrefslogtreecommitdiff
path: root/modules/gdnative/nativescript
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2020-05-14 13:23:58 +0200
committerRémi Verschelde <rverschelde@gmail.com>2020-05-14 16:54:55 +0200
commit0be6d925dc3c6413bce7a3ccb49631b8e4a6e67a (patch)
treea27e497da7104dd0a64f98a04fa3067668735e91 /modules/gdnative/nativescript
parent710b34b70227becdc652b4ae027fe0ac47409642 (diff)
Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks
Which means that reduz' beloved style which we all became used to will now be changed automatically to remove the first empty line. This makes us lean closer to 1TBS (the one true brace style) instead of hybridating it with some Allman-inspired spacing. There's still the case of braces around single-statement blocks that needs to be addressed (but clang-format can't help with that, but clang-tidy may if we agree about it). Part of #33027.
Diffstat (limited to 'modules/gdnative/nativescript')
-rw-r--r--modules/gdnative/nativescript/api_generator.cpp7
-rw-r--r--modules/gdnative/nativescript/godot_nativescript.cpp6
-rw-r--r--modules/gdnative/nativescript/nativescript.cpp49
-rw-r--r--modules/gdnative/nativescript/nativescript.h3
-rw-r--r--modules/gdnative/nativescript/register_types.cpp1
5 files changed, 0 insertions, 66 deletions
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..ee944ee7cb 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);
@@ -315,7 +310,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()) {
diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp
index ed3ec44bf7..70a651be1e 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
@@ -207,7 +206,6 @@ StringName NativeScript::get_instance_base_type() const {
}
ScriptInstance *NativeScript::instance_create(Object *p_this) {
-
NativeScriptDesc *script_data = get_script_desc();
if (!script_data) {
@@ -336,7 +334,6 @@ void NativeScript::get_script_signal_list(List<MethodInfo> *r_signals) const {
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);
}
@@ -376,7 +373,6 @@ void NativeScript::get_script_method_list(List<MethodInfo> *p_list) const {
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 +404,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 +428,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 +445,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 +458,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 +493,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 +530,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 +548,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 +565,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 +578,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 +613,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 +658,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 +676,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 +694,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 +707,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();
@@ -884,10 +861,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 +911,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 +934,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) {
@@ -1127,7 +1099,6 @@ void NativeScriptInstance::call_multilevel_reversed(const StringName &p_method,
}
NativeScriptInstance::~NativeScriptInstance() {
-
NativeScriptDesc *script_data = GET_SCRIPT_DESC();
if (!script_data)
@@ -1145,16 +1116,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,7 +1152,6 @@ 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)
@@ -1253,13 +1220,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 +1249,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();
@@ -1490,7 +1453,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;
@@ -1553,7 +1515,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 +1525,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,7 +1539,6 @@ void *NativeScriptLanguage::alloc_instance_binding_data(Object *p_object) {
}
void NativeScriptLanguage::free_instance_binding_data(void *p_data) {
-
if (!p_data)
return;
@@ -1600,7 +1559,6 @@ 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)
@@ -1622,7 +1580,6 @@ 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)
@@ -1741,13 +1698,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);
@@ -1835,14 +1790,12 @@ void NativeReloadNode::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_WM_FOCUS_OUT: {
-
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 +1823,12 @@ void NativeReloadNode::_notification(int p_what) {
} break;
case NOTIFICATION_WM_FOCUS_IN: {
-
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()) {
diff --git a/modules/gdnative/nativescript/nativescript.h b/modules/gdnative/nativescript/nativescript.h
index d24b247e59..1aca142889 100644
--- a/modules/gdnative/nativescript/nativescript.h
+++ b/modules/gdnative/nativescript/nativescript.h
@@ -47,7 +47,6 @@
#include <nativescript/godot_nativescript.h>
struct NativeScriptDesc {
-
struct Method {
godot_instance_method method;
MethodInfo info;
@@ -194,7 +193,6 @@ public:
};
class NativeScriptInstance : public ScriptInstance {
-
friend class NativeScript;
Object *owner;
@@ -245,7 +243,6 @@ public:
class NativeReloadNode;
class NativeScriptLanguage : public ScriptLanguage {
-
friend class NativeScript;
friend class NativeScriptInstance;
friend class NativeReloadNode;
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();