Skip to content

Commit

Permalink
Big, possibly complete sweep of naming changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
awesomekling committed Jan 31, 2019
1 parent 27fa09a commit ffab689
Show file tree
Hide file tree
Showing 93 changed files with 830 additions and 885 deletions.
6 changes: 3 additions & 3 deletions AK/AKString.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class String {

String() { }
String(const String& other)
: m_impl(const_cast<String&>(other).m_impl.copyRef())
: m_impl(const_cast<String&>(other).m_impl.copy_ref())
{
}

Expand Down Expand Up @@ -44,7 +44,7 @@ class String {
{
}

unsigned toUInt(bool& ok) const;
unsigned to_uint(bool& ok) const;

String to_lowercase() const
{
Expand Down Expand Up @@ -89,7 +89,7 @@ class String {
String& operator=(const String& other)
{
if (this != &other)
m_impl = const_cast<String&>(other).m_impl.copyRef();
m_impl = const_cast<String&>(other).m_impl.copy_ref();
return *this;
}

Expand Down
4 changes: 2 additions & 2 deletions AK/Assertions.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

namespace AK {

inline void notImplemented() { ASSERT(false); }
inline void not_implemented() { ASSERT(false); }

}

using AK::notImplemented;
using AK::not_implemented;

2 changes: 1 addition & 1 deletion AK/Bitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Bitmap {
, m_owned(true)
{
ASSERT(m_size != 0);
size_t size_to_allocate = ceilDiv(size, 8u);
size_t size_to_allocate = ceil_div(size, 8u);
m_data = reinterpret_cast<byte*>(kmalloc(size_to_allocate));
memset(m_data, default_value ? 0xff : 0x00, size_to_allocate);
}
Expand Down
4 changes: 2 additions & 2 deletions AK/ByteBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ByteBuffer {
ByteBuffer() { }
ByteBuffer(std::nullptr_t) { }
ByteBuffer(const ByteBuffer& other)
: m_impl(other.m_impl.copyRef())
: m_impl(other.m_impl.copy_ref())
{
}
ByteBuffer(ByteBuffer&& other)
Expand All @@ -26,7 +26,7 @@ class ByteBuffer {
}
ByteBuffer& operator=(const ByteBuffer& other)
{
m_impl = other.m_impl.copyRef();
m_impl = other.m_impl.copy_ref();
return *this;
}

Expand Down
2 changes: 1 addition & 1 deletion AK/DoublyLinkedList.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class DoublyLinkedList {
append_node(new Node(value));
}

bool containsSlow(const T& value) const
bool contains_slow(const T& value) const
{
for (auto* node = m_head; node; node = node->next) {
if (node->value == value)
Expand Down
2 changes: 1 addition & 1 deletion AK/FileSystemPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ bool FileSystemPath::canonicalize(bool resolve_symbolic_links)
builder.append('/');
builder.append(cpart);
}
m_string = builder.build();
m_string = builder.to_string();
return true;
}

Expand Down
18 changes: 9 additions & 9 deletions AK/Function.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,41 +41,41 @@ class Function<Out(In...)> {

template<typename CallableType, class = typename EnableIf<!(IsPointer<CallableType>::value && IsFunction<typename RemovePointer<CallableType>::Type>::value) && IsRvalueReference<CallableType&&>::value>::Type>
Function(CallableType&& callable)
: m_callableWrapper(make<CallableWrapper<CallableType>>(move(callable)))
: m_callable_wrapper(make<CallableWrapper<CallableType>>(move(callable)))
{
}

template<typename FunctionType, class = typename EnableIf<IsPointer<FunctionType>::value && IsFunction<typename RemovePointer<FunctionType>::Type>::value>::Type>
Function(FunctionType f)
: m_callableWrapper(make<CallableWrapper<FunctionType>>(move(f)))
: m_callable_wrapper(make<CallableWrapper<FunctionType>>(move(f)))
{
}

Out operator()(In... in) const
{
ASSERT(m_callableWrapper);
return m_callableWrapper->call(forward<In>(in)...);
ASSERT(m_callable_wrapper);
return m_callable_wrapper->call(forward<In>(in)...);
}

explicit operator bool() const { return !!m_callableWrapper; }
explicit operator bool() const { return !!m_callable_wrapper; }

template<typename CallableType, class = typename EnableIf<!(IsPointer<CallableType>::value && IsFunction<typename RemovePointer<CallableType>::Type>::value) && IsRvalueReference<CallableType&&>::value>::Type>
Function& operator=(CallableType&& callable)
{
m_callableWrapper = make<CallableWrapper<CallableType>>(move(callable));
m_callable_wrapper = make<CallableWrapper<CallableType>>(move(callable));
return *this;
}

template<typename FunctionType, class = typename EnableIf<IsPointer<FunctionType>::value && IsFunction<typename RemovePointer<FunctionType>::Type>::value>::Type>
Function& operator=(FunctionType f)
{
m_callableWrapper = make<CallableWrapper<FunctionType>>(move(f));
m_callable_wrapper = make<CallableWrapper<FunctionType>>(move(f));
return *this;
}

Function& operator=(std::nullptr_t)
{
m_callableWrapper = nullptr;
m_callable_wrapper = nullptr;
return *this;
}

Expand Down Expand Up @@ -103,7 +103,7 @@ class Function<Out(In...)> {
CallableType m_callable;
};

OwnPtr<CallableWrapperBase> m_callableWrapper;
OwnPtr<CallableWrapperBase> m_callable_wrapper;
};

}
Expand Down
6 changes: 3 additions & 3 deletions AK/HashFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "Types.h"

inline unsigned intHash(dword key)
inline unsigned int_hash(dword key)
{
key += ~(key << 15);
key ^= (key >> 10);
Expand All @@ -13,8 +13,8 @@ inline unsigned intHash(dword key)
return key;
}

inline unsigned pairIntHash(dword key1, dword key2)
inline unsigned pair_int_hash(dword key1, dword key2)
{
return intHash((intHash(key1) * 209) ^ (intHash(key2 * 413)));
return int_hash((int_hash(key1) * 209) ^ (int_hash(key2 * 413)));
}

2 changes: 1 addition & 1 deletion AK/HashMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class HashMap {
void set(const K&, const V&);
void set(const K&, V&&);
void remove(const K&);
void removeOneRandomly() { m_table.remove(m_table.begin()); }
void remove_one_randomly() { m_table.remove(m_table.begin()); }

typedef HashTable<Entry, EntryTraits> HashTableType;
typedef typename HashTableType::Iterator IteratorType;
Expand Down
22 changes: 11 additions & 11 deletions AK/MappedFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,40 @@

namespace AK {

MappedFile::MappedFile(String&& fileName)
: m_fileName(std::move(fileName))
MappedFile::MappedFile(String&& file_name)
: m_file_name(std::move(file_name))
{
m_fileLength = 1024;
m_fd = open(m_fileName.characters(), O_RDONLY);
m_file_length = 1024;
m_fd = open(m_file_name.characters(), O_RDONLY);

if (m_fd != -1) {
struct stat st;
fstat(m_fd, &st);
m_fileLength = st.st_size;
m_map = mmap(nullptr, m_fileLength, PROT_READ, MAP_SHARED, m_fd, 0);
m_file_length = st.st_size;
m_map = mmap(nullptr, m_file_length, PROT_READ, MAP_SHARED, m_fd, 0);

if (m_map == MAP_FAILED)
perror("");
}

printf("MappedFile{%s} := { m_fd=%d, m_fileLength=%zu, m_map=%p }\n", m_fileName.characters(), m_fd, m_fileLength, m_map);
printf("MappedFile{%s} := { m_fd=%d, m_file_length=%zu, m_map=%p }\n", m_file_name.characters(), m_fd, m_file_length, m_map);
}

MappedFile::~MappedFile()
{
if (m_map != (void*)-1) {
ASSERT(m_fd != -1);
munmap(m_map, m_fileLength);
munmap(m_map, m_file_length);
}
}

MappedFile::MappedFile(MappedFile&& other)
: m_fileName(std::move(other.m_fileName))
, m_fileLength(other.m_fileLength)
: m_file_name(std::move(other.m_file_name))
, m_file_length(other.m_file_length)
, m_fd(other.m_fd)
, m_map(other.m_map)
{
other.m_fileLength = 0;
other.m_file_length = 0;
other.m_fd = -1;
other.m_map = (void*)-1;
}
Expand Down
10 changes: 5 additions & 5 deletions AK/MappedFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ namespace AK {
class MappedFile {
public:
MappedFile() { }
explicit MappedFile(String&& fileName);
explicit MappedFile(String&& file_name);
MappedFile(MappedFile&&);
~MappedFile();

bool isValid() const { return m_map != (void*)-1; }
bool is_valid() const { return m_map != (void*)-1; }

void* pointer() { return m_map; }
const void* pointer() const { return m_map; }
size_t fileLength() const { return m_fileLength; }
size_t file_length() const { return m_file_length; }

private:
String m_fileName;
size_t m_fileLength { 0 };
String m_file_name;
size_t m_file_length { 0 };
int m_fd { -1 };
void* m_map { (void*)-1 };
};
Expand Down
10 changes: 5 additions & 5 deletions AK/OwnPtr.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class OwnPtr {
public:
OwnPtr() { }
explicit OwnPtr(T* ptr) : m_ptr(ptr) { }
OwnPtr(OwnPtr&& other) : m_ptr(other.leakPtr()) { }
template<typename U> OwnPtr(OwnPtr<U>&& other) : m_ptr(static_cast<T*>(other.leakPtr())) { }
OwnPtr(OwnPtr&& other) : m_ptr(other.leak_ptr()) { }
template<typename U> OwnPtr(OwnPtr<U>&& other) : m_ptr(static_cast<T*>(other.leak_ptr())) { }
OwnPtr(std::nullptr_t) { };
~OwnPtr()
{
Expand All @@ -29,7 +29,7 @@ class OwnPtr {
{
if (this != &other) {
delete m_ptr;
m_ptr = other.leakPtr();
m_ptr = other.leak_ptr();
}
return *this;
}
Expand All @@ -39,7 +39,7 @@ class OwnPtr {
{
if (this != static_cast<void*>(&other)) {
delete m_ptr;
m_ptr = other.leakPtr();
m_ptr = other.leak_ptr();
}
return *this;
}
Expand Down Expand Up @@ -69,7 +69,7 @@ class OwnPtr {
typedef T* OwnPtr::*UnspecifiedBoolType;
operator UnspecifiedBoolType() const { return m_ptr ? &OwnPtr::m_ptr : nullptr; }

T* leakPtr()
T* leak_ptr()
{
T* leakedPtr = m_ptr;
m_ptr = nullptr;
Expand Down
40 changes: 20 additions & 20 deletions AK/RetainPtr.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
namespace AK {

template<typename T>
inline void retainIfNotNull(T* ptr)
inline void retain_if_not_null(T* ptr)
{
if (ptr)
ptr->retain();
}

template<typename T>
inline void releaseIfNotNull(T* ptr)
inline void release_if_not_null(T* ptr)
{
if (ptr)
ptr->release();
Expand All @@ -25,15 +25,15 @@ class RetainPtr {
enum AdoptTag { Adopt };

RetainPtr() { }
RetainPtr(const T* ptr) : m_ptr(const_cast<T*>(ptr)) { retainIfNotNull(m_ptr); }
RetainPtr(T* ptr) : m_ptr(ptr) { retainIfNotNull(m_ptr); }
RetainPtr(const T* ptr) : m_ptr(const_cast<T*>(ptr)) { retain_if_not_null(m_ptr); }
RetainPtr(T* ptr) : m_ptr(ptr) { retain_if_not_null(m_ptr); }
RetainPtr(T& object) : m_ptr(&object) { m_ptr->retain(); }
RetainPtr(AdoptTag, T& object) : m_ptr(&object) { }
RetainPtr(RetainPtr& other) : m_ptr(other.copyRef().leakRef()) { }
RetainPtr(RetainPtr&& other) : m_ptr(other.leakRef()) { }
template<typename U> RetainPtr(RetainPtr<U>&& other) : m_ptr(static_cast<T*>(other.leakRef())) { }
RetainPtr(const RetainPtr& other) : m_ptr(const_cast<RetainPtr&>(other).copyRef().leakRef()) { }
template<typename U> RetainPtr(const RetainPtr<U>& other) : m_ptr(const_cast<RetainPtr<U>&>(other).copyRef().leakRef()) { }
RetainPtr(RetainPtr& other) : m_ptr(other.copy_ref().leak_ref()) { }
RetainPtr(RetainPtr&& other) : m_ptr(other.leak_ref()) { }
template<typename U> RetainPtr(RetainPtr<U>&& other) : m_ptr(static_cast<T*>(other.leak_ref())) { }
RetainPtr(const RetainPtr& other) : m_ptr(const_cast<RetainPtr&>(other).copy_ref().leak_ref()) { }
template<typename U> RetainPtr(const RetainPtr<U>& other) : m_ptr(const_cast<RetainPtr<U>&>(other).copy_ref().leak_ref()) { }
~RetainPtr()
{
clear();
Expand All @@ -49,8 +49,8 @@ class RetainPtr {
RetainPtr& operator=(RetainPtr&& other)
{
if (this != &other) {
releaseIfNotNull(m_ptr);
m_ptr = other.leakRef();
release_if_not_null(m_ptr);
m_ptr = other.leak_ref();
}
return *this;
}
Expand All @@ -59,27 +59,27 @@ class RetainPtr {
RetainPtr& operator=(RetainPtr<U>&& other)
{
if (this != static_cast<void*>(&other)) {
releaseIfNotNull(m_ptr);
m_ptr = other.leakRef();
release_if_not_null(m_ptr);
m_ptr = other.leak_ref();
}
return *this;
}

RetainPtr& operator=(T* ptr)
{
if (m_ptr != ptr)
releaseIfNotNull(m_ptr);
release_if_not_null(m_ptr);
m_ptr = ptr;
retainIfNotNull(m_ptr);
retain_if_not_null(m_ptr);
return *this;
}

RetainPtr& operator=(T& object)
{
if (m_ptr != &object)
releaseIfNotNull(m_ptr);
release_if_not_null(m_ptr);
m_ptr = &object;
retainIfNotNull(m_ptr);
retain_if_not_null(m_ptr);
return *this;
}

Expand All @@ -89,14 +89,14 @@ class RetainPtr {
return *this;
}

RetainPtr copyRef() const
RetainPtr copy_ref() const
{
return RetainPtr(m_ptr);
}

void clear()
{
releaseIfNotNull(m_ptr);
release_if_not_null(m_ptr);
m_ptr = nullptr;
}

Expand All @@ -105,7 +105,7 @@ class RetainPtr {
typedef T* RetainPtr::*UnspecifiedBoolType;
operator UnspecifiedBoolType() const { return m_ptr ? &RetainPtr::m_ptr : nullptr; }

T* leakRef()
T* leak_ref()
{
T* leakedPtr = m_ptr;
m_ptr = nullptr;
Expand Down
Loading

0 comments on commit ffab689

Please sign in to comment.