summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2015-02-19 13:58:25 +0000
committerMaxime Coste <frrrwww@gmail.com>2015-02-19 13:58:25 +0000
commit8df77121d7afb38e7a5584d0f89f5d7237ebaac1 (patch)
tree81a6eb072d07953ac8d47b60ded015ab49757e14 /src
parent6c65c5e080d381bb713172976847baad5650e24b (diff)
Rename safe_ptr and ref_ptr to SafePtr and RefPtr
Diffstat (limited to 'src')
-rw-r--r--src/alias_registry.hh2
-rw-r--r--src/buffer.hh10
-rw-r--r--src/buffer_manager.hh2
-rw-r--r--src/context.hh8
-rw-r--r--src/main.cc2
-rw-r--r--src/ref_ptr.hh20
-rw-r--r--src/safe_ptr.hh24
-rw-r--r--src/selection.hh2
-rw-r--r--src/shared_string.hh10
-rw-r--r--src/window.hh2
-rw-r--r--src/word_db.hh4
11 files changed, 43 insertions, 43 deletions
diff --git a/src/alias_registry.hh b/src/alias_registry.hh
index f29ee9e6..4f1a472b 100644
--- a/src/alias_registry.hh
+++ b/src/alias_registry.hh
@@ -22,7 +22,7 @@ private:
friend class Scope;
AliasRegistry() {}
- safe_ptr<AliasRegistry> m_parent;
+ SafePtr<AliasRegistry> m_parent;
UnorderedMap<String, String, MemoryDomain::Aliases> m_aliases;
};
diff --git a/src/buffer.hh b/src/buffer.hh
index c3a5dcb2..4c4a6ac5 100644
--- a/src/buffer.hh
+++ b/src/buffer.hh
@@ -55,11 +55,11 @@ public:
const ByteCoord& coord() const { return m_coord; }
private:
- safe_ptr<const Buffer> m_buffer;
+ SafePtr<const Buffer> m_buffer;
ByteCoord m_coord;
};
-using BufferLines = Vector<ref_ptr<StringStorage>, MemoryDomain::BufferContent>;
+using BufferLines = Vector<RefPtr<StringStorage>, MemoryDomain::BufferContent>;
// A Buffer is a in-memory representation of a file
//
@@ -126,7 +126,7 @@ public:
StringView operator[](LineCount line) const
{ return m_lines[line]; }
- ref_ptr<StringStorage> line_storage(LineCount line) const
+ RefPtr<StringStorage> line_storage(LineCount line) const
{ return m_lines.get_storage(line); }
// returns an iterator at given coordinates. clamp line_and_column
@@ -174,11 +174,11 @@ private:
struct LineList : BufferLines
{
[[gnu::always_inline]]
- ref_ptr<StringStorage>& get_storage(LineCount line)
+ RefPtr<StringStorage>& get_storage(LineCount line)
{ return BufferLines::operator[]((int)line); }
[[gnu::always_inline]]
- const ref_ptr<StringStorage>& get_storage(LineCount line) const
+ const RefPtr<StringStorage>& get_storage(LineCount line) const
{ return BufferLines::operator[]((int)line); }
[[gnu::always_inline]]
diff --git a/src/buffer_manager.hh b/src/buffer_manager.hh
index 8a046ff3..8dab6df7 100644
--- a/src/buffer_manager.hh
+++ b/src/buffer_manager.hh
@@ -13,7 +13,7 @@ class Buffer;
class BufferManager : public Singleton<BufferManager>
{
public:
- using BufferList = Vector<safe_ptr<Buffer>>;
+ using BufferList = Vector<SafePtr<Buffer>>;
using iterator = BufferList::const_iterator;
~BufferManager();
diff --git a/src/context.hh b/src/context.hh
index bd89be27..83323994 100644
--- a/src/context.hh
+++ b/src/context.hh
@@ -138,9 +138,9 @@ private:
Flags m_flags;
- safe_ptr<InputHandler> m_input_handler;
- safe_ptr<Window> m_window;
- safe_ptr<Client> m_client;
+ SafePtr<InputHandler> m_input_handler;
+ SafePtr<Window> m_window;
+ SafePtr<Client> m_client;
friend class Client;
Optional<SelectionList> m_selections;
@@ -170,7 +170,7 @@ struct ScopedEdition
Context& context() const { return m_context; }
private:
Context& m_context;
- safe_ptr<Buffer> m_buffer;
+ SafePtr<Buffer> m_buffer;
};
}
diff --git a/src/main.cc b/src/main.cc
index 0d7172be..7f83f802 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -60,7 +60,7 @@ void register_env_vars()
"buflist",
[](StringView name, const Context& context)
{ return join(transformed(BufferManager::instance(),
- [](const safe_ptr<Buffer>& b)
+ [](const SafePtr<Buffer>& b)
{ return b->display_name(); }), ':'); }
}, {
"timestamp",
diff --git a/src/ref_ptr.hh b/src/ref_ptr.hh
index 7bd2ed83..09ec1f48 100644
--- a/src/ref_ptr.hh
+++ b/src/ref_ptr.hh
@@ -5,22 +5,22 @@ namespace Kakoune
{
template<typename T>
-struct ref_ptr
+struct RefPtr
{
- ref_ptr() = default;
- ref_ptr(T* ptr) : m_ptr(ptr) { acquire(); }
- ~ref_ptr() { release(); }
- ref_ptr(const ref_ptr& other) : m_ptr(other.m_ptr) { acquire(); }
- ref_ptr(ref_ptr&& other) : m_ptr(other.m_ptr) { other.m_ptr = nullptr; }
+ RefPtr() = default;
+ RefPtr(T* ptr) : m_ptr(ptr) { acquire(); }
+ ~RefPtr() { release(); }
+ RefPtr(const RefPtr& other) : m_ptr(other.m_ptr) { acquire(); }
+ RefPtr(RefPtr&& other) : m_ptr(other.m_ptr) { other.m_ptr = nullptr; }
- ref_ptr& operator=(const ref_ptr& other)
+ RefPtr& operator=(const RefPtr& other)
{
release();
m_ptr = other.m_ptr;
acquire();
return *this;
}
- ref_ptr& operator=(ref_ptr&& other)
+ RefPtr& operator=(RefPtr&& other)
{
release();
m_ptr = other.m_ptr;
@@ -35,11 +35,11 @@ struct ref_ptr
explicit operator bool() { return m_ptr; }
- friend bool operator==(const ref_ptr& lhs, const ref_ptr& rhs)
+ friend bool operator==(const RefPtr& lhs, const RefPtr& rhs)
{
return lhs.m_ptr == rhs.m_ptr;
}
- friend bool operator!=(const ref_ptr& lhs, const ref_ptr& rhs)
+ friend bool operator!=(const RefPtr& lhs, const RefPtr& rhs)
{
return lhs.m_ptr != rhs.m_ptr;
}
diff --git a/src/safe_ptr.hh b/src/safe_ptr.hh
index 2f9e4ca5..6366bd13 100644
--- a/src/safe_ptr.hh
+++ b/src/safe_ptr.hh
@@ -13,22 +13,22 @@
namespace Kakoune
{
-// *** safe_ptr: objects that assert nobody references them when they die ***
+// *** SafePtr: objects that assert nobody references them when they die ***
template<typename T>
-class safe_ptr
+class SafePtr
{
public:
- safe_ptr() : m_ptr(nullptr) {}
- explicit safe_ptr(T* ptr) : m_ptr(ptr)
+ SafePtr() : m_ptr(nullptr) {}
+ explicit SafePtr(T* ptr) : m_ptr(ptr)
{
#ifdef KAK_DEBUG
if (m_ptr)
m_ptr->inc_safe_count(this);
#endif
}
- safe_ptr(const safe_ptr& other) : safe_ptr(other.m_ptr) {}
- safe_ptr(safe_ptr&& other) noexcept : m_ptr(other.m_ptr)
+ SafePtr(const SafePtr& other) : SafePtr(other.m_ptr) {}
+ SafePtr(SafePtr&& other) noexcept : m_ptr(other.m_ptr)
{
other.m_ptr = nullptr;
#ifdef KAK_DEBUG
@@ -36,7 +36,7 @@ public:
m_ptr->safe_ptr_moved(&other, this);
#endif
}
- ~safe_ptr()
+ ~SafePtr()
{
#ifdef KAK_DEBUG
if (m_ptr)
@@ -44,7 +44,7 @@ public:
#endif
}
- safe_ptr& operator=(const safe_ptr& other)
+ SafePtr& operator=(const SafePtr& other)
{
#ifdef KAK_DEBUG
if (m_ptr != other.m_ptr)
@@ -59,7 +59,7 @@ public:
return *this;
}
- safe_ptr& operator=(safe_ptr&& other) noexcept
+ SafePtr& operator=(SafePtr&& other) noexcept
{
#ifdef KAK_DEBUG
if (m_ptr)
@@ -74,11 +74,11 @@ public:
void reset(T* ptr = nullptr)
{
- *this = safe_ptr(ptr);
+ *this = SafePtr(ptr);
}
- bool operator== (const safe_ptr& other) const { return m_ptr == other.m_ptr; }
- bool operator!= (const safe_ptr& other) const { return m_ptr != other.m_ptr; }
+ bool operator== (const SafePtr& other) const { return m_ptr == other.m_ptr; }
+ bool operator!= (const SafePtr& other) const { return m_ptr != other.m_ptr; }
bool operator== (T* ptr) const { return m_ptr == ptr; }
bool operator!= (T* ptr) const { return m_ptr != ptr; }
diff --git a/src/selection.hh b/src/selection.hh
index cc435aed..1a5834a9 100644
--- a/src/selection.hh
+++ b/src/selection.hh
@@ -136,7 +136,7 @@ private:
size_t m_main = 0;
Vector<Selection> m_selections;
- safe_ptr<Buffer> m_buffer;
+ SafePtr<Buffer> m_buffer;
size_t m_timestamp;
};
diff --git a/src/shared_string.hh b/src/shared_string.hh
index f9adf737..a73f8dd2 100644
--- a/src/shared_string.hh
+++ b/src/shared_string.hh
@@ -44,7 +44,7 @@ struct StringStorage : UseMemoryDomain<MemoryDomain::SharedString>
friend void dec_ref_count(StringStorage* s) { if (--s->refcount == 0) StringStorage::destroy(s); }
};
-inline ref_ptr<StringStorage> operator"" _ss(const char* ptr, size_t len)
+inline RefPtr<StringStorage> operator"" _ss(const char* ptr, size_t len)
{
return StringStorage::create({ptr, (int)len});
}
@@ -75,15 +75,15 @@ public:
return SharedString{StringView::substr(from, length), m_storage};
}
- explicit SharedString(ref_ptr<StringStorage> storage)
+ explicit SharedString(RefPtr<StringStorage> storage)
: StringView{storage->strview()}, m_storage(std::move(storage)) {}
private:
- SharedString(StringView str, ref_ptr<StringStorage> storage)
+ SharedString(StringView str, RefPtr<StringStorage> storage)
: StringView{str}, m_storage(std::move(storage)) {}
friend class StringRegistry;
- ref_ptr<StringStorage> m_storage;
+ RefPtr<StringStorage> m_storage;
};
inline size_t hash_value(const SharedString& str)
@@ -99,7 +99,7 @@ public:
void purge_unused();
private:
- UnorderedMap<StringView, ref_ptr<StringStorage>, MemoryDomain::SharedString> m_strings;
+ UnorderedMap<StringView, RefPtr<StringStorage>, MemoryDomain::SharedString> m_strings;
};
inline SharedString intern(StringView str)
diff --git a/src/window.hh b/src/window.hh
index aaeb34a6..ad04396d 100644
--- a/src/window.hh
+++ b/src/window.hh
@@ -52,7 +52,7 @@ private:
void run_hook_in_own_context(const String& hook_name, StringView param);
- safe_ptr<Buffer> m_buffer;
+ SafePtr<Buffer> m_buffer;
CharCoord m_position;
CharCoord m_dimensions;
diff --git a/src/word_db.hh b/src/word_db.hh
index 81955068..d560b560 100644
--- a/src/word_db.hh
+++ b/src/word_db.hh
@@ -50,9 +50,9 @@ private:
int refcount;
};
using WordToInfo = UnorderedMap<SharedString, WordInfo, MemoryDomain::WordDB>;
- using Lines = Vector<ref_ptr<StringStorage>, MemoryDomain::WordDB>;
+ using Lines = Vector<RefPtr<StringStorage>, MemoryDomain::WordDB>;
- safe_ptr<const Buffer> m_buffer;
+ SafePtr<const Buffer> m_buffer;
size_t m_timestamp;
WordToInfo m_words;
Lines m_lines;