Use Refcounted to manage to NativeEntry (bug 5852 part 4, r=ds).
--HG-- extra : rebase_source : 2e08816db6819c9d9957a0e0ade9cd1aa420fd54
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// vim: set sts=8 ts=2 sw=2 tw=99 et:
|
||||
// vim: set sts=8 ts=4 sw=4 tw=99 et:
|
||||
//
|
||||
// Copyright (C) 2013, David Anderson and AlliedModders LLC
|
||||
// All rights reserved.
|
||||
@@ -31,6 +31,7 @@
|
||||
#define _include_amtl_refcounting_h_
|
||||
|
||||
#include <am-utility.h>
|
||||
#include <am-moveable.h>
|
||||
|
||||
namespace ke {
|
||||
|
||||
@@ -189,6 +190,11 @@ class Ref
|
||||
{
|
||||
AddRef();
|
||||
}
|
||||
Ref(Moveable<Ref> other)
|
||||
: thing_(other->thing_)
|
||||
{
|
||||
other->thing_ = NULL;
|
||||
}
|
||||
template <typename S>
|
||||
Ref(const Ref<S> &other)
|
||||
: thing_(*other)
|
||||
@@ -255,6 +261,13 @@ class Ref
|
||||
return *this;
|
||||
}
|
||||
|
||||
Ref &operator =(Moveable<Ref> other) {
|
||||
Release();
|
||||
thing_ = other->thing_;
|
||||
other->thing_ = NULL;
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
void AddRef() {
|
||||
if (thing_)
|
||||
|
||||
Reference in New Issue
Block a user