diff options
Diffstat (limited to 'core/reference.cpp')
| -rw-r--r-- | core/reference.cpp | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/core/reference.cpp b/core/reference.cpp index 5e8244d2c..5285888f7 100644 --- a/core/reference.cpp +++ b/core/reference.cpp @@ -30,7 +30,6 @@ #include "script_language.h" - bool Reference::init_ref() { if (refcount.ref()) { @@ -39,7 +38,7 @@ bool Reference::init_ref() { // at the same time, which is never likely to happen (would be crazy to do) // so don't do it. - if (refcount_init.get()>0) { + if (refcount_init.get() > 0) { refcount_init.unref(); refcount.unref(); // first referencing is already 1, so compensate for the ref above } @@ -49,30 +48,27 @@ bool Reference::init_ref() { return false; } - } - void Reference::_bind_methods() { - ClassDB::bind_method(D_METHOD("init_ref"),&Reference::init_ref); - ClassDB::bind_method(D_METHOD("reference"),&Reference::reference); - ClassDB::bind_method(D_METHOD("unreference"),&Reference::unreference); + ClassDB::bind_method(D_METHOD("init_ref"), &Reference::init_ref); + ClassDB::bind_method(D_METHOD("reference"), &Reference::reference); + ClassDB::bind_method(D_METHOD("unreference"), &Reference::unreference); } int Reference::reference_get_count() const { return refcount.get(); } -void Reference::reference(){ +void Reference::reference() { refcount.ref(); if (get_script_instance()) { get_script_instance()->refcount_incremented(); } - } -bool Reference::unreference(){ +bool Reference::unreference() { bool die = refcount.unref(); @@ -81,7 +77,6 @@ bool Reference::unreference(){ } return die; - } Reference::Reference() { @@ -90,14 +85,12 @@ Reference::Reference() { refcount_init.init(); } - Reference::~Reference() { - } Variant WeakRef::get_ref() const { - if (ref==0) + if (ref == 0) return Variant(); Object *obj = ObjectDB::get_instance(ref); @@ -113,21 +106,21 @@ Variant WeakRef::get_ref() const { } void WeakRef::set_obj(Object *p_object) { - ref=p_object ? p_object->get_instance_ID() : 0; + ref = p_object ? p_object->get_instance_ID() : 0; } -void WeakRef::set_ref(const REF& p_ref) { +void WeakRef::set_ref(const REF &p_ref) { - ref=p_ref.is_valid() ? p_ref->get_instance_ID() : 0; + ref = p_ref.is_valid() ? p_ref->get_instance_ID() : 0; } WeakRef::WeakRef() { - ref=0; + ref = 0; } void WeakRef::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_ref:Object"),&WeakRef::get_ref); + ClassDB::bind_method(D_METHOD("get_ref:Object"), &WeakRef::get_ref); } #if 0 |
