AngelScript: used as '@obj = ref.get();'
| 183 | |
| 184 | // AngelScript: used as '@obj = ref.get();' |
| 185 | void *CScriptWeakRef::Get() const |
| 186 | { |
| 187 | // If we hold a null handle, then just return null |
| 188 | if( m_ref == 0 || m_weakRefFlag == 0 ) |
| 189 | return 0; |
| 190 | |
| 191 | // Lock on the shared bool, so we can be certain it won't be changed to true |
| 192 | // between the inspection of the flag and the increase of the ref count in the |
| 193 | // owning object. |
| 194 | m_weakRefFlag->Lock(); |
| 195 | if( !m_weakRefFlag->Get() ) |
| 196 | { |
| 197 | m_type->GetEngine()->AddRefScriptObject(m_ref, m_type->GetSubType()); |
| 198 | m_weakRefFlag->Unlock(); |
| 199 | return m_ref; |
| 200 | } |
| 201 | m_weakRefFlag->Unlock(); |
| 202 | |
| 203 | return 0; |
| 204 | } |
| 205 | |
| 206 | bool CScriptWeakRef::Equals(void *ref) const |
| 207 | { |
no test coverage detected