You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-24 15:26:15 +00:00
Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks
This commit is contained in:
136
core/object.cpp
136
core/object.cpp
@@ -43,7 +43,6 @@
|
||||
#ifdef DEBUG_ENABLED
|
||||
|
||||
struct _ObjectDebugLock {
|
||||
|
||||
Object *obj;
|
||||
|
||||
_ObjectDebugLock(Object *p_obj) {
|
||||
@@ -64,7 +63,6 @@ struct _ObjectDebugLock {
|
||||
#endif
|
||||
|
||||
PropertyInfo::operator Dictionary() const {
|
||||
|
||||
Dictionary d;
|
||||
d["name"] = name;
|
||||
d["class_name"] = class_name;
|
||||
@@ -76,7 +74,6 @@ PropertyInfo::operator Dictionary() const {
|
||||
}
|
||||
|
||||
PropertyInfo PropertyInfo::from_dict(const Dictionary &p_dict) {
|
||||
|
||||
PropertyInfo pi;
|
||||
|
||||
if (p_dict.has("type"))
|
||||
@@ -102,10 +99,8 @@ PropertyInfo PropertyInfo::from_dict(const Dictionary &p_dict) {
|
||||
}
|
||||
|
||||
Array convert_property_list(const List<PropertyInfo> *p_list) {
|
||||
|
||||
Array va;
|
||||
for (const List<PropertyInfo>::Element *E = p_list->front(); E; E = E->next()) {
|
||||
|
||||
va.push_back(Dictionary(E->get()));
|
||||
}
|
||||
|
||||
@@ -113,7 +108,6 @@ Array convert_property_list(const List<PropertyInfo> *p_list) {
|
||||
}
|
||||
|
||||
MethodInfo::operator Dictionary() const {
|
||||
|
||||
Dictionary d;
|
||||
d["name"] = name;
|
||||
d["args"] = convert_property_list(&arguments);
|
||||
@@ -134,7 +128,6 @@ MethodInfo::MethodInfo() :
|
||||
}
|
||||
|
||||
MethodInfo MethodInfo::from_dict(const Dictionary &p_dict) {
|
||||
|
||||
MethodInfo mi;
|
||||
|
||||
if (p_dict.has("name"))
|
||||
@@ -334,7 +327,6 @@ MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name, const Pr
|
||||
}
|
||||
|
||||
Object::Connection::operator Variant() const {
|
||||
|
||||
Dictionary d;
|
||||
d["source"] = source;
|
||||
d["signal"] = signal;
|
||||
@@ -346,16 +338,11 @@ Object::Connection::operator Variant() const {
|
||||
}
|
||||
|
||||
bool Object::Connection::operator<(const Connection &p_conn) const {
|
||||
|
||||
if (source == p_conn.source) {
|
||||
|
||||
if (signal == p_conn.signal) {
|
||||
|
||||
if (target == p_conn.target) {
|
||||
|
||||
return method < p_conn.method;
|
||||
} else {
|
||||
|
||||
return target < p_conn.target;
|
||||
}
|
||||
} else
|
||||
@@ -365,7 +352,6 @@ bool Object::Connection::operator<(const Connection &p_conn) const {
|
||||
}
|
||||
}
|
||||
Object::Connection::Connection(const Variant &p_variant) {
|
||||
|
||||
Dictionary d = p_variant;
|
||||
if (d.has("source"))
|
||||
source = d["source"];
|
||||
@@ -382,7 +368,6 @@ Object::Connection::Connection(const Variant &p_variant) {
|
||||
}
|
||||
|
||||
bool Object::_predelete() {
|
||||
|
||||
_predelete_ok = 1;
|
||||
notification(NOTIFICATION_PREDELETE, true);
|
||||
if (_predelete_ok) {
|
||||
@@ -403,14 +388,12 @@ void Object::_get_valid_parents_static(List<String> *p_parents) {
|
||||
}
|
||||
|
||||
void Object::set(const StringName &p_name, const Variant &p_value, bool *r_valid) {
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
|
||||
_edited = true;
|
||||
#endif
|
||||
|
||||
if (script_instance) {
|
||||
|
||||
if (script_instance->set(p_name, p_value)) {
|
||||
if (r_valid)
|
||||
*r_valid = true;
|
||||
@@ -478,11 +461,9 @@ void Object::set(const StringName &p_name, const Variant &p_value, bool *r_valid
|
||||
}
|
||||
|
||||
Variant Object::get(const StringName &p_name, bool *r_valid) const {
|
||||
|
||||
Variant ret;
|
||||
|
||||
if (script_instance) {
|
||||
|
||||
if (script_instance->get(p_name, ret)) {
|
||||
if (r_valid)
|
||||
*r_valid = true;
|
||||
@@ -585,7 +566,6 @@ void Object::set_indexed(const Vector<StringName> &p_names, const Variant &p_val
|
||||
value_stack.push_back(p_value); // p_names[p_names.size() - 1]
|
||||
|
||||
for (int i = p_names.size() - 1; i > 0; i--) {
|
||||
|
||||
value_stack.back()->prev()->get().set_named(p_names[i], value_stack.back()->get(), r_valid);
|
||||
value_stack.pop_back();
|
||||
|
||||
@@ -623,7 +603,6 @@ Variant Object::get_indexed(const Vector<StringName> &p_names, bool *r_valid) co
|
||||
}
|
||||
|
||||
void Object::get_property_list(List<PropertyInfo> *p_list, bool p_reversed) const {
|
||||
|
||||
if (script_instance && p_reversed) {
|
||||
p_list->push_back(PropertyInfo(Variant::NIL, "Script Variables", PROPERTY_HINT_NONE, String(), PROPERTY_USAGE_CATEGORY));
|
||||
script_instance->get_property_list(p_list);
|
||||
@@ -647,7 +626,6 @@ void Object::_validate_property(PropertyInfo &property) const {
|
||||
}
|
||||
|
||||
void Object::get_method_list(List<MethodInfo> *p_list) const {
|
||||
|
||||
ClassDB::get_method_list(get_class_name(), p_list);
|
||||
if (script_instance) {
|
||||
script_instance->get_method_list(p_list);
|
||||
@@ -655,7 +633,6 @@ void Object::get_method_list(List<MethodInfo> *p_list) const {
|
||||
}
|
||||
|
||||
Variant Object::_call_bind(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
|
||||
|
||||
if (p_argcount < 1) {
|
||||
r_error.error = Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
r_error.argument = 0;
|
||||
@@ -675,7 +652,6 @@ Variant Object::_call_bind(const Variant **p_args, int p_argcount, Variant::Call
|
||||
}
|
||||
|
||||
Variant Object::_call_deferred_bind(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
|
||||
|
||||
if (p_argcount < 1) {
|
||||
r_error.error = Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
r_error.argument = 0;
|
||||
@@ -700,24 +676,19 @@ Variant Object::_call_deferred_bind(const Variant **p_args, int p_argcount, Vari
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
static void _test_call_error(const StringName &p_func, const Variant::CallError &error) {
|
||||
|
||||
switch (error.error) {
|
||||
|
||||
case Variant::CallError::CALL_OK:
|
||||
case Variant::CallError::CALL_ERROR_INVALID_METHOD:
|
||||
break;
|
||||
case Variant::CallError::CALL_ERROR_INVALID_ARGUMENT: {
|
||||
|
||||
ERR_FAIL_MSG("Error calling function: " + String(p_func) + " - Invalid type for argument " + itos(error.argument) + ", expected " + Variant::get_type_name(error.expected) + ".");
|
||||
break;
|
||||
}
|
||||
case Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS: {
|
||||
|
||||
ERR_FAIL_MSG("Error calling function: " + String(p_func) + " - Too many arguments, expected " + itos(error.argument) + ".");
|
||||
break;
|
||||
}
|
||||
case Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS: {
|
||||
|
||||
ERR_FAIL_MSG("Error calling function: " + String(p_func) + " - Too few arguments, expected " + itos(error.argument) + ".");
|
||||
break;
|
||||
}
|
||||
@@ -732,7 +703,6 @@ static void _test_call_error(const StringName &p_func, const Variant::CallError
|
||||
#endif
|
||||
|
||||
void Object::call_multilevel(const StringName &p_method, const Variant **p_args, int p_argcount) {
|
||||
|
||||
if (p_method == CoreStringNames::get_singleton()->_free) {
|
||||
#ifdef DEBUG_ENABLED
|
||||
ERR_FAIL_COND_MSG(Object::cast_to<Reference>(this), "Can't 'free' a reference.");
|
||||
@@ -758,21 +728,18 @@ void Object::call_multilevel(const StringName &p_method, const Variant **p_args,
|
||||
MethodBind *method = ClassDB::get_method(get_class_name(), p_method);
|
||||
|
||||
if (method) {
|
||||
|
||||
method->call(this, p_args, p_argcount, error);
|
||||
_test_call_error(p_method, error);
|
||||
}
|
||||
}
|
||||
|
||||
void Object::call_multilevel_reversed(const StringName &p_method, const Variant **p_args, int p_argcount) {
|
||||
|
||||
MethodBind *method = ClassDB::get_method(get_class_name(), p_method);
|
||||
|
||||
Variant::CallError error;
|
||||
OBJ_DEBUG_LOCK
|
||||
|
||||
if (method) {
|
||||
|
||||
method->call(this, p_args, p_argcount, error);
|
||||
_test_call_error(p_method, error);
|
||||
}
|
||||
@@ -786,7 +753,6 @@ void Object::call_multilevel_reversed(const StringName &p_method, const Variant
|
||||
}
|
||||
|
||||
bool Object::has_method(const StringName &p_method) const {
|
||||
|
||||
if (p_method == CoreStringNames::get_singleton()->_free) {
|
||||
return true;
|
||||
}
|
||||
@@ -801,13 +767,11 @@ bool Object::has_method(const StringName &p_method) const {
|
||||
}
|
||||
|
||||
Variant Object::getvar(const Variant &p_key, bool *r_valid) const {
|
||||
|
||||
if (r_valid)
|
||||
*r_valid = false;
|
||||
return Variant();
|
||||
}
|
||||
void Object::setvar(const Variant &p_key, const Variant &p_value, bool *r_valid) {
|
||||
|
||||
if (r_valid)
|
||||
*r_valid = false;
|
||||
}
|
||||
@@ -831,7 +795,6 @@ Variant Object::callv(const StringName &p_method, const Array &p_args) {
|
||||
}
|
||||
|
||||
Variant Object::call(const StringName &p_name, VARIANT_ARG_DECLARE) {
|
||||
|
||||
VARIANT_ARGPTRS;
|
||||
|
||||
int argc = 0;
|
||||
@@ -848,7 +811,6 @@ Variant Object::call(const StringName &p_name, VARIANT_ARG_DECLARE) {
|
||||
}
|
||||
|
||||
void Object::call_multilevel(const StringName &p_name, VARIANT_ARG_DECLARE) {
|
||||
|
||||
VARIANT_ARGPTRS;
|
||||
|
||||
int argc = 0;
|
||||
@@ -863,7 +825,6 @@ void Object::call_multilevel(const StringName &p_name, VARIANT_ARG_DECLARE) {
|
||||
}
|
||||
|
||||
Variant Object::call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
|
||||
|
||||
r_error.error = Variant::CallError::CALL_OK;
|
||||
|
||||
if (p_method == CoreStringNames::get_singleton()->_free) {
|
||||
@@ -899,7 +860,6 @@ Variant Object::call(const StringName &p_method, const Variant **p_args, int p_a
|
||||
ret = script_instance->call(p_method, p_args, p_argcount, r_error);
|
||||
//force jumptable
|
||||
switch (r_error.error) {
|
||||
|
||||
case Variant::CallError::CALL_OK:
|
||||
return ret;
|
||||
case Variant::CallError::CALL_ERROR_INVALID_METHOD:
|
||||
@@ -916,7 +876,6 @@ Variant Object::call(const StringName &p_method, const Variant **p_args, int p_a
|
||||
MethodBind *method = ClassDB::get_method(get_class_name(), p_method);
|
||||
|
||||
if (method) {
|
||||
|
||||
ret = method->call(this, p_args, p_argcount, r_error);
|
||||
} else {
|
||||
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
||||
@@ -926,7 +885,6 @@ Variant Object::call(const StringName &p_method, const Variant **p_args, int p_a
|
||||
}
|
||||
|
||||
void Object::notification(int p_notification, bool p_reversed) {
|
||||
|
||||
_notificationv(p_notification, p_reversed);
|
||||
|
||||
if (script_instance) {
|
||||
@@ -948,28 +906,23 @@ void Object::_changed_callback(Object *p_changed, const char *p_prop) {
|
||||
}
|
||||
|
||||
void Object::add_change_receptor(Object *p_receptor) {
|
||||
|
||||
change_receptors.insert(p_receptor);
|
||||
}
|
||||
|
||||
void Object::remove_change_receptor(Object *p_receptor) {
|
||||
|
||||
change_receptors.erase(p_receptor);
|
||||
}
|
||||
|
||||
void Object::property_list_changed_notify() {
|
||||
|
||||
_change_notify();
|
||||
}
|
||||
|
||||
void Object::cancel_delete() {
|
||||
|
||||
_predelete_ok = true;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
ObjectRC *Object::_use_rc() {
|
||||
|
||||
// The RC object is lazily created the first time it's requested;
|
||||
// that way, there's no need to allocate and release it at all if this Object
|
||||
// is not being referred by any Variant at all.
|
||||
@@ -999,7 +952,6 @@ ObjectRC *Object::_use_rc() {
|
||||
#endif
|
||||
|
||||
void Object::set_script_and_instance(const RefPtr &p_script, ScriptInstance *p_instance) {
|
||||
|
||||
//this function is not meant to be used in any of these ways
|
||||
ERR_FAIL_COND(p_script.is_null());
|
||||
ERR_FAIL_COND(!p_instance);
|
||||
@@ -1010,7 +962,6 @@ void Object::set_script_and_instance(const RefPtr &p_script, ScriptInstance *p_i
|
||||
}
|
||||
|
||||
void Object::set_script(const RefPtr &p_script) {
|
||||
|
||||
if (script == p_script)
|
||||
return;
|
||||
|
||||
@@ -1037,7 +988,6 @@ void Object::set_script(const RefPtr &p_script) {
|
||||
}
|
||||
|
||||
void Object::set_script_instance(ScriptInstance *p_instance) {
|
||||
|
||||
if (script_instance == p_instance)
|
||||
return;
|
||||
|
||||
@@ -1053,17 +1003,14 @@ void Object::set_script_instance(ScriptInstance *p_instance) {
|
||||
}
|
||||
|
||||
RefPtr Object::get_script() const {
|
||||
|
||||
return script;
|
||||
}
|
||||
|
||||
bool Object::has_meta(const String &p_name) const {
|
||||
|
||||
return metadata.has(p_name);
|
||||
}
|
||||
|
||||
void Object::set_meta(const String &p_name, const Variant &p_value) {
|
||||
|
||||
if (p_value.get_type() == Variant::NIL) {
|
||||
metadata.erase(p_name);
|
||||
return;
|
||||
@@ -1073,7 +1020,6 @@ void Object::set_meta(const String &p_name, const Variant &p_value) {
|
||||
}
|
||||
|
||||
Variant Object::get_meta(const String &p_name) const {
|
||||
|
||||
ERR_FAIL_COND_V(!metadata.has(p_name), Variant());
|
||||
return metadata[p_name];
|
||||
}
|
||||
@@ -1083,20 +1029,17 @@ void Object::remove_meta(const String &p_name) {
|
||||
}
|
||||
|
||||
Array Object::_get_property_list_bind() const {
|
||||
|
||||
List<PropertyInfo> lpi;
|
||||
get_property_list(&lpi);
|
||||
return convert_property_list(&lpi);
|
||||
}
|
||||
|
||||
Array Object::_get_method_list_bind() const {
|
||||
|
||||
List<MethodInfo> ml;
|
||||
get_method_list(&ml);
|
||||
Array ret;
|
||||
|
||||
for (List<MethodInfo>::Element *E = ml.front(); E; E = E->next()) {
|
||||
|
||||
Dictionary d = E->get();
|
||||
//va.push_back(d);
|
||||
ret.push_back(d);
|
||||
@@ -1106,30 +1049,25 @@ Array Object::_get_method_list_bind() const {
|
||||
}
|
||||
|
||||
PoolVector<String> Object::_get_meta_list_bind() const {
|
||||
|
||||
PoolVector<String> _metaret;
|
||||
|
||||
List<Variant> keys;
|
||||
metadata.get_key_list(&keys);
|
||||
for (List<Variant>::Element *E = keys.front(); E; E = E->next()) {
|
||||
|
||||
_metaret.push_back(E->get());
|
||||
}
|
||||
|
||||
return _metaret;
|
||||
}
|
||||
void Object::get_meta_list(List<String> *p_list) const {
|
||||
|
||||
List<Variant> keys;
|
||||
metadata.get_key_list(&keys);
|
||||
for (List<Variant>::Element *E = keys.front(); E; E = E->next()) {
|
||||
|
||||
p_list->push_back(E->get());
|
||||
}
|
||||
}
|
||||
|
||||
void Object::add_user_signal(const MethodInfo &p_signal) {
|
||||
|
||||
ERR_FAIL_COND_MSG(p_signal.name == "", "Signal name cannot be empty.");
|
||||
ERR_FAIL_COND_MSG(ClassDB::has_signal(get_class_name(), p_signal.name), "User signal's name conflicts with a built-in signal of '" + get_class_name() + "'.");
|
||||
ERR_FAIL_COND_MSG(signal_map.has(p_signal.name), "Trying to add already existing signal '" + p_signal.name + "'.");
|
||||
@@ -1139,21 +1077,18 @@ void Object::add_user_signal(const MethodInfo &p_signal) {
|
||||
}
|
||||
|
||||
bool Object::_has_user_signal(const StringName &p_name) const {
|
||||
|
||||
if (!signal_map.has(p_name))
|
||||
return false;
|
||||
return signal_map[p_name].user.name.length() > 0;
|
||||
}
|
||||
|
||||
struct _ObjectSignalDisconnectData {
|
||||
|
||||
StringName signal;
|
||||
Object *target;
|
||||
StringName method;
|
||||
};
|
||||
|
||||
Variant Object::_emit_signal(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
|
||||
|
||||
r_error.error = Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||
|
||||
ERR_FAIL_COND_V(p_argcount < 1, Variant());
|
||||
@@ -1181,7 +1116,6 @@ Variant Object::_emit_signal(const Variant **p_args, int p_argcount, Variant::Ca
|
||||
}
|
||||
|
||||
Error Object::emit_signal(const StringName &p_name, const Variant **p_args, int p_argcount) {
|
||||
|
||||
if (_block_signals)
|
||||
return ERR_CANT_ACQUIRE_RESOURCE; //no emit, signals blocked
|
||||
|
||||
@@ -1212,7 +1146,6 @@ Error Object::emit_signal(const StringName &p_name, const Variant **p_args, int
|
||||
Error err = OK;
|
||||
|
||||
for (int i = 0; i < ssize; i++) {
|
||||
|
||||
const Connection &c = slot_map.getv(i).conn;
|
||||
|
||||
Object *target = ObjectDB::get_instance(slot_map.getk(i)._id);
|
||||
@@ -1269,7 +1202,6 @@ Error Object::emit_signal(const StringName &p_name, const Variant **p_args, int
|
||||
}
|
||||
#endif
|
||||
if (disconnect) {
|
||||
|
||||
_ObjectSignalDisconnectData dd;
|
||||
dd.signal = p_name;
|
||||
dd.target = target;
|
||||
@@ -1279,7 +1211,6 @@ Error Object::emit_signal(const StringName &p_name, const Variant **p_args, int
|
||||
}
|
||||
|
||||
while (!disconnect_data.empty()) {
|
||||
|
||||
const _ObjectSignalDisconnectData &dd = disconnect_data.front()->get();
|
||||
disconnect(dd.signal, dd.target, dd.method);
|
||||
disconnect_data.pop_front();
|
||||
@@ -1289,13 +1220,11 @@ Error Object::emit_signal(const StringName &p_name, const Variant **p_args, int
|
||||
}
|
||||
|
||||
Error Object::emit_signal(const StringName &p_name, VARIANT_ARG_DECLARE) {
|
||||
|
||||
VARIANT_ARGPTRS;
|
||||
|
||||
int argc = 0;
|
||||
|
||||
for (int i = 0; i < VARIANT_ARG_MAX; i++) {
|
||||
|
||||
if (argptr[i]->get_type() == Variant::NIL)
|
||||
break;
|
||||
argc++;
|
||||
@@ -1305,7 +1234,6 @@ Error Object::emit_signal(const StringName &p_name, VARIANT_ARG_DECLARE) {
|
||||
}
|
||||
|
||||
void Object::_add_user_signal(const String &p_name, const Array &p_args) {
|
||||
|
||||
// this version of add_user_signal is meant to be used from scripts or external apis
|
||||
// without access to ADD_SIGNAL in bind_methods
|
||||
// added events are per instance, as opposed to the other ones, which are global
|
||||
@@ -1314,7 +1242,6 @@ void Object::_add_user_signal(const String &p_name, const Array &p_args) {
|
||||
mi.name = p_name;
|
||||
|
||||
for (int i = 0; i < p_args.size(); i++) {
|
||||
|
||||
Dictionary d = p_args[i];
|
||||
PropertyInfo param;
|
||||
|
||||
@@ -1330,13 +1257,11 @@ void Object::_add_user_signal(const String &p_name, const Array &p_args) {
|
||||
}
|
||||
|
||||
Array Object::_get_signal_list() const {
|
||||
|
||||
List<MethodInfo> signal_list;
|
||||
get_signal_list(&signal_list);
|
||||
|
||||
Array ret;
|
||||
for (List<MethodInfo>::Element *E = signal_list.front(); E; E = E->next()) {
|
||||
|
||||
ret.push_back(Dictionary(E->get()));
|
||||
}
|
||||
|
||||
@@ -1344,14 +1269,12 @@ Array Object::_get_signal_list() const {
|
||||
}
|
||||
|
||||
Array Object::_get_signal_connection_list(const String &p_signal) const {
|
||||
|
||||
List<Connection> conns;
|
||||
get_all_signal_connections(&conns);
|
||||
|
||||
Array ret;
|
||||
|
||||
for (List<Connection>::Element *E = conns.front(); E; E = E->next()) {
|
||||
|
||||
Connection &c = E->get();
|
||||
if (c.signal == p_signal) {
|
||||
Dictionary rc;
|
||||
@@ -1369,7 +1292,6 @@ Array Object::_get_signal_connection_list(const String &p_signal) const {
|
||||
}
|
||||
|
||||
Array Object::_get_incoming_connections() const {
|
||||
|
||||
Array ret;
|
||||
int connections_amount = connections.size();
|
||||
for (int idx_conn = 0; idx_conn < connections_amount; idx_conn++) {
|
||||
@@ -1403,7 +1325,6 @@ bool Object::has_signal(const StringName &p_name) const {
|
||||
}
|
||||
|
||||
void Object::get_signal_list(List<MethodInfo> *p_signals) const {
|
||||
|
||||
if (!script.is_null()) {
|
||||
Ref<Script> scr = script;
|
||||
if (scr.is_valid()) {
|
||||
@@ -1416,7 +1337,6 @@ void Object::get_signal_list(List<MethodInfo> *p_signals) const {
|
||||
const StringName *S = NULL;
|
||||
|
||||
while ((S = signal_map.next(S))) {
|
||||
|
||||
if (signal_map[*S].user.name != "") {
|
||||
//user signal
|
||||
p_signals->push_back(signal_map[*S].user);
|
||||
@@ -1425,22 +1345,18 @@ void Object::get_signal_list(List<MethodInfo> *p_signals) const {
|
||||
}
|
||||
|
||||
void Object::get_all_signal_connections(List<Connection> *p_connections) const {
|
||||
|
||||
const StringName *S = NULL;
|
||||
|
||||
while ((S = signal_map.next(S))) {
|
||||
|
||||
const Signal *s = &signal_map[*S];
|
||||
|
||||
for (int i = 0; i < s->slot_map.size(); i++) {
|
||||
|
||||
p_connections->push_back(s->slot_map.getv(i).conn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Object::get_signal_connection_list(const StringName &p_signal, List<Connection> *p_connections) const {
|
||||
|
||||
const Signal *s = signal_map.getptr(p_signal);
|
||||
if (!s)
|
||||
return; //nothing
|
||||
@@ -1450,12 +1366,10 @@ void Object::get_signal_connection_list(const StringName &p_signal, List<Connect
|
||||
}
|
||||
|
||||
int Object::get_persistent_signal_connection_count() const {
|
||||
|
||||
int count = 0;
|
||||
const StringName *S = NULL;
|
||||
|
||||
while ((S = signal_map.next(S))) {
|
||||
|
||||
const Signal *s = &signal_map[*S];
|
||||
|
||||
for (int i = 0; i < s->slot_map.size(); i++) {
|
||||
@@ -1469,14 +1383,12 @@ int Object::get_persistent_signal_connection_count() const {
|
||||
}
|
||||
|
||||
void Object::get_signals_connected_to_this(List<Connection> *p_connections) const {
|
||||
|
||||
for (const List<Connection>::Element *E = connections.front(); E; E = E->next()) {
|
||||
p_connections->push_back(E->get());
|
||||
}
|
||||
}
|
||||
|
||||
Error Object::connect(const StringName &p_signal, Object *p_to_object, const StringName &p_to_method, const Vector<Variant> &p_binds, uint32_t p_flags) {
|
||||
|
||||
ERR_FAIL_NULL_V(p_to_object, ERR_INVALID_PARAMETER);
|
||||
|
||||
Signal *s = signal_map.getptr(p_signal);
|
||||
@@ -1484,7 +1396,6 @@ Error Object::connect(const StringName &p_signal, Object *p_to_object, const Str
|
||||
bool signal_is_valid = ClassDB::has_signal(get_class_name(), p_signal);
|
||||
//check in script
|
||||
if (!signal_is_valid && !script.is_null()) {
|
||||
|
||||
if (Ref<Script>(script)->has_script_signal(p_signal)) {
|
||||
signal_is_valid = true;
|
||||
}
|
||||
@@ -1535,7 +1446,6 @@ Error Object::connect(const StringName &p_signal, Object *p_to_object, const Str
|
||||
}
|
||||
|
||||
bool Object::is_connected(const StringName &p_signal, Object *p_to_object, const StringName &p_to_method) const {
|
||||
|
||||
ERR_FAIL_NULL_V(p_to_object, false);
|
||||
const Signal *s = signal_map.getptr(p_signal);
|
||||
if (!s) {
|
||||
@@ -1557,11 +1467,9 @@ bool Object::is_connected(const StringName &p_signal, Object *p_to_object, const
|
||||
}
|
||||
|
||||
void Object::disconnect(const StringName &p_signal, Object *p_to_object, const StringName &p_to_method) {
|
||||
|
||||
_disconnect(p_signal, p_to_object, p_to_method);
|
||||
}
|
||||
void Object::_disconnect(const StringName &p_signal, Object *p_to_object, const StringName &p_to_method, bool p_force) {
|
||||
|
||||
ERR_FAIL_NULL(p_to_object);
|
||||
Signal *s = signal_map.getptr(p_signal);
|
||||
if (!s) {
|
||||
@@ -1595,27 +1503,22 @@ void Object::_disconnect(const StringName &p_signal, Object *p_to_object, const
|
||||
}
|
||||
|
||||
void Object::_set_bind(const String &p_set, const Variant &p_value) {
|
||||
|
||||
set(p_set, p_value);
|
||||
}
|
||||
|
||||
Variant Object::_get_bind(const String &p_name) const {
|
||||
|
||||
return get(p_name);
|
||||
}
|
||||
|
||||
void Object::_set_indexed_bind(const NodePath &p_name, const Variant &p_value) {
|
||||
|
||||
set_indexed(p_name.get_as_property_path().get_subnames(), p_value);
|
||||
}
|
||||
|
||||
Variant Object::_get_indexed_bind(const NodePath &p_name) const {
|
||||
|
||||
return get_indexed(p_name.get_as_property_path().get_subnames());
|
||||
}
|
||||
|
||||
void Object::initialize_class() {
|
||||
|
||||
static bool initialized = false;
|
||||
if (initialized)
|
||||
return;
|
||||
@@ -1625,7 +1528,6 @@ void Object::initialize_class() {
|
||||
}
|
||||
|
||||
StringName Object::tr(const StringName &p_message) const {
|
||||
|
||||
if (!_can_translate || !TranslationServer::get_singleton())
|
||||
return p_message;
|
||||
|
||||
@@ -1633,11 +1535,8 @@ StringName Object::tr(const StringName &p_message) const {
|
||||
}
|
||||
|
||||
void Object::_clear_internal_resource_paths(const Variant &p_var) {
|
||||
|
||||
switch (p_var.get_type()) {
|
||||
|
||||
case Variant::OBJECT: {
|
||||
|
||||
RES r = p_var;
|
||||
if (!r.is_valid())
|
||||
return;
|
||||
@@ -1653,7 +1552,6 @@ void Object::_clear_internal_resource_paths(const Variant &p_var) {
|
||||
r->clear_internal_resource_paths();
|
||||
} break;
|
||||
case Variant::ARRAY: {
|
||||
|
||||
Array a = p_var;
|
||||
for (int i = 0; i < a.size(); i++) {
|
||||
_clear_internal_resource_paths(a[i]);
|
||||
@@ -1661,13 +1559,11 @@ void Object::_clear_internal_resource_paths(const Variant &p_var) {
|
||||
|
||||
} break;
|
||||
case Variant::DICTIONARY: {
|
||||
|
||||
Dictionary d = p_var;
|
||||
List<Variant> keys;
|
||||
d.get_key_list(&keys);
|
||||
|
||||
for (List<Variant>::Element *E = keys.front(); E; E = E->next()) {
|
||||
|
||||
_clear_internal_resource_paths(E->get());
|
||||
_clear_internal_resource_paths(d[E->get()]);
|
||||
}
|
||||
@@ -1679,7 +1575,6 @@ void Object::_clear_internal_resource_paths(const Variant &p_var) {
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
void Object::editor_set_section_unfold(const String &p_section, bool p_unfolded) {
|
||||
|
||||
set_edited(true);
|
||||
if (p_unfolded)
|
||||
editor_section_folding.insert(p_section);
|
||||
@@ -1688,26 +1583,22 @@ void Object::editor_set_section_unfold(const String &p_section, bool p_unfolded)
|
||||
}
|
||||
|
||||
bool Object::editor_is_section_unfolded(const String &p_section) {
|
||||
|
||||
return editor_section_folding.has(p_section);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void Object::clear_internal_resource_paths() {
|
||||
|
||||
List<PropertyInfo> pinfo;
|
||||
|
||||
get_property_list(&pinfo);
|
||||
|
||||
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
|
||||
|
||||
_clear_internal_resource_paths(get(E->get().name));
|
||||
}
|
||||
}
|
||||
|
||||
void Object::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_class"), &Object::get_class);
|
||||
ClassDB::bind_method(D_METHOD("is_class", "class"), &Object::is_class);
|
||||
ClassDB::bind_method(D_METHOD("set", "property", "value"), &Object::_set_bind);
|
||||
@@ -1812,7 +1703,6 @@ void Object::_bind_methods() {
|
||||
}
|
||||
|
||||
void Object::call_deferred(const StringName &p_method, VARIANT_ARG_DECLARE) {
|
||||
|
||||
MessageQueue::get_singleton()->push_call(this, p_method, VARIANT_ARG_PASS);
|
||||
}
|
||||
|
||||
@@ -1821,22 +1711,18 @@ void Object::set_deferred(const StringName &p_property, const Variant &p_value)
|
||||
}
|
||||
|
||||
void Object::set_block_signals(bool p_block) {
|
||||
|
||||
_block_signals = p_block;
|
||||
}
|
||||
|
||||
bool Object::is_blocking_signals() const {
|
||||
|
||||
return _block_signals;
|
||||
}
|
||||
|
||||
void Object::get_translatable_strings(List<String> *p_strings) const {
|
||||
|
||||
List<PropertyInfo> plist;
|
||||
get_property_list(&plist);
|
||||
|
||||
for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {
|
||||
|
||||
if (!(E->get().usage & PROPERTY_USAGE_INTERNATIONALIZED))
|
||||
continue;
|
||||
|
||||
@@ -1850,7 +1736,6 @@ void Object::get_translatable_strings(List<String> *p_strings) const {
|
||||
}
|
||||
|
||||
Variant::Type Object::get_static_property_type(const StringName &p_property, bool *r_valid) const {
|
||||
|
||||
bool valid;
|
||||
Variant::Type t = ClassDB::get_property_type(get_class_name(), p_property, &valid);
|
||||
if (valid) {
|
||||
@@ -1869,7 +1754,6 @@ Variant::Type Object::get_static_property_type(const StringName &p_property, boo
|
||||
}
|
||||
|
||||
Variant::Type Object::get_static_property_type_indexed(const Vector<StringName> &p_path, bool *r_valid) const {
|
||||
|
||||
if (p_path.size() == 0) {
|
||||
if (r_valid)
|
||||
*r_valid = false;
|
||||
@@ -1918,18 +1802,15 @@ bool Object::is_queued_for_deletion() const {
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
void Object::set_edited(bool p_edited) {
|
||||
|
||||
_edited = p_edited;
|
||||
_edited_version++;
|
||||
}
|
||||
|
||||
bool Object::is_edited() const {
|
||||
|
||||
return _edited;
|
||||
}
|
||||
|
||||
uint32_t Object::get_edited_version() const {
|
||||
|
||||
return _edited_version;
|
||||
}
|
||||
#endif
|
||||
@@ -1956,7 +1837,6 @@ void *Object::get_script_instance_binding(int p_script_language_index) {
|
||||
}
|
||||
|
||||
bool Object::has_script_instance_binding(int p_script_language_index) {
|
||||
|
||||
return _script_instance_bindings[p_script_language_index] != NULL;
|
||||
}
|
||||
|
||||
@@ -1968,7 +1848,6 @@ void Object::set_script_instance_binding(int p_script_language_index, void *p_da
|
||||
}
|
||||
|
||||
Object::Object() {
|
||||
|
||||
_class_ptr = NULL;
|
||||
_block_signals = false;
|
||||
_predelete_ok = 0;
|
||||
@@ -1994,7 +1873,6 @@ Object::Object() {
|
||||
}
|
||||
|
||||
Object::~Object() {
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
ObjectRC *rc = _rc.load(std::memory_order_acquire);
|
||||
if (rc) {
|
||||
@@ -2016,7 +1894,6 @@ Object::~Object() {
|
||||
}
|
||||
|
||||
while ((S = signal_map.next(NULL))) {
|
||||
|
||||
Signal *s = &signal_map[*S];
|
||||
|
||||
//brute force disconnect for performance
|
||||
@@ -2024,7 +1901,6 @@ Object::~Object() {
|
||||
const VMap<Signal::Target, Signal::Slot>::Pair *slot_list = s->slot_map.get_array();
|
||||
|
||||
for (int i = 0; i < slot_count; i++) {
|
||||
|
||||
slot_list[i].value.conn.target->connections.erase(slot_list[i].value.cE);
|
||||
}
|
||||
|
||||
@@ -2033,7 +1909,6 @@ Object::~Object() {
|
||||
|
||||
//signals from nodes that connect to this node
|
||||
while (connections.size()) {
|
||||
|
||||
Connection c = connections.front()->get();
|
||||
c.source->_disconnect(c.signal, c.target, c.method, true);
|
||||
}
|
||||
@@ -2052,12 +1927,10 @@ Object::~Object() {
|
||||
}
|
||||
|
||||
bool predelete_handler(Object *p_object) {
|
||||
|
||||
return p_object->_predelete();
|
||||
}
|
||||
|
||||
void postinitialize_handler(Object *p_object) {
|
||||
|
||||
p_object->_postinitialize();
|
||||
}
|
||||
|
||||
@@ -2065,7 +1938,6 @@ HashMap<ObjectID, Object *> ObjectDB::instances;
|
||||
ObjectID ObjectDB::instance_counter = 1;
|
||||
HashMap<Object *, ObjectID, ObjectDB::ObjectPtrHash> ObjectDB::instance_checks;
|
||||
ObjectID ObjectDB::add_instance(Object *p_object) {
|
||||
|
||||
ERR_FAIL_COND_V(p_object->get_instance_id() != 0, 0);
|
||||
|
||||
rw_lock.write_lock();
|
||||
@@ -2079,7 +1951,6 @@ ObjectID ObjectDB::add_instance(Object *p_object) {
|
||||
}
|
||||
|
||||
void ObjectDB::remove_instance(Object *p_object) {
|
||||
|
||||
rw_lock.write_lock();
|
||||
|
||||
instances.erase(p_object->get_instance_id());
|
||||
@@ -2088,7 +1959,6 @@ void ObjectDB::remove_instance(Object *p_object) {
|
||||
rw_lock.write_unlock();
|
||||
}
|
||||
Object *ObjectDB::get_instance(ObjectID p_instance_id) {
|
||||
|
||||
rw_lock.read_lock();
|
||||
Object **obj = instances.getptr(p_instance_id);
|
||||
rw_lock.read_unlock();
|
||||
@@ -2099,12 +1969,10 @@ Object *ObjectDB::get_instance(ObjectID p_instance_id) {
|
||||
}
|
||||
|
||||
void ObjectDB::debug_objects(DebugFunc p_func) {
|
||||
|
||||
rw_lock.read_lock();
|
||||
|
||||
const ObjectID *K = NULL;
|
||||
while ((K = instances.next(K))) {
|
||||
|
||||
p_func(instances[*K]);
|
||||
}
|
||||
|
||||
@@ -2115,7 +1983,6 @@ void Object::get_argument_options(const StringName &p_function, int p_idx, List<
|
||||
}
|
||||
|
||||
int ObjectDB::get_object_count() {
|
||||
|
||||
rw_lock.read_lock();
|
||||
int count = instances.size();
|
||||
rw_lock.read_unlock();
|
||||
@@ -2126,10 +1993,8 @@ int ObjectDB::get_object_count() {
|
||||
RWLock ObjectDB::rw_lock;
|
||||
|
||||
void ObjectDB::cleanup() {
|
||||
|
||||
rw_lock.write_lock();
|
||||
if (instances.size()) {
|
||||
|
||||
WARN_PRINT("ObjectDB instances leaked at exit (run with --verbose for details).");
|
||||
if (OS::get_singleton()->is_stdout_verbose()) {
|
||||
// Ensure calling the native classes because if a leaked instance has a script
|
||||
@@ -2141,7 +2006,6 @@ void ObjectDB::cleanup() {
|
||||
|
||||
const ObjectID *K = NULL;
|
||||
while ((K = instances.next(K))) {
|
||||
|
||||
String extra_info;
|
||||
if (instances[*K]->is_class("Node"))
|
||||
extra_info = " - Node name: " + String(node_get_name->call(instances[*K], NULL, 0, call_error));
|
||||
|
||||
Reference in New Issue
Block a user