diff options
Diffstat (limited to 'AK')
-rw-r--r-- | AK/AKString.h | 6 | ||||
-rw-r--r-- | AK/Assertions.h | 4 | ||||
-rw-r--r-- | AK/Bitmap.h | 2 | ||||
-rw-r--r-- | AK/ByteBuffer.h | 4 | ||||
-rw-r--r-- | AK/DoublyLinkedList.h | 2 | ||||
-rw-r--r-- | AK/FileSystemPath.cpp | 2 | ||||
-rw-r--r-- | AK/Function.h | 18 | ||||
-rw-r--r-- | AK/HashFunctions.h | 6 | ||||
-rw-r--r-- | AK/HashMap.h | 2 | ||||
-rw-r--r-- | AK/MappedFile.cpp | 22 | ||||
-rw-r--r-- | AK/MappedFile.h | 10 | ||||
-rw-r--r-- | AK/OwnPtr.h | 10 | ||||
-rw-r--r-- | AK/RetainPtr.h | 40 | ||||
-rw-r--r-- | AK/SimpleMalloc.cpp | 70 | ||||
-rw-r--r-- | AK/SimpleMalloc.h | 2 | ||||
-rw-r--r-- | AK/SinglyLinkedList.h | 2 | ||||
-rw-r--r-- | AK/StdLibExtras.h | 4 | ||||
-rw-r--r-- | AK/String.cpp | 8 | ||||
-rw-r--r-- | AK/StringBuilder.cpp | 4 | ||||
-rw-r--r-- | AK/StringBuilder.h | 2 | ||||
-rw-r--r-- | AK/StringImpl.cpp | 46 | ||||
-rw-r--r-- | AK/TemporaryFile.cpp | 6 | ||||
-rw-r--r-- | AK/TemporaryFile.h | 6 | ||||
-rw-r--r-- | AK/Traits.h | 6 | ||||
-rw-r--r-- | AK/Vector.h | 8 | ||||
-rw-r--r-- | AK/WeakPtr.h | 10 | ||||
-rw-r--r-- | AK/Weakable.h | 2 | ||||
-rw-r--r-- | AK/kmalloc.cpp | 2 | ||||
-rw-r--r-- | AK/printf.cpp | 28 | ||||
-rw-r--r-- | AK/test.cpp | 36 |
30 files changed, 185 insertions, 185 deletions
diff --git a/AK/AKString.h b/AK/AKString.h index 654ba91468..29438e2369 100644 --- a/AK/AKString.h +++ b/AK/AKString.h @@ -15,7 +15,7 @@ public: String() { } String(const String& other) - : m_impl(const_cast<String&>(other).m_impl.copyRef()) + : m_impl(const_cast<String&>(other).m_impl.copy_ref()) { } @@ -44,7 +44,7 @@ public: { } - unsigned toUInt(bool& ok) const; + unsigned to_uint(bool& ok) const; String to_lowercase() const { @@ -89,7 +89,7 @@ public: 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; } diff --git a/AK/Assertions.h b/AK/Assertions.h index 4439c5dbc5..fcc1f692a7 100644 --- a/AK/Assertions.h +++ b/AK/Assertions.h @@ -8,9 +8,9 @@ namespace AK { -inline void notImplemented() { ASSERT(false); } +inline void not_implemented() { ASSERT(false); } } -using AK::notImplemented; +using AK::not_implemented; diff --git a/AK/Bitmap.h b/AK/Bitmap.h index cd89ff2996..270b25bf2b 100644 --- a/AK/Bitmap.h +++ b/AK/Bitmap.h @@ -51,7 +51,7 @@ private: , 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); } diff --git a/AK/ByteBuffer.h b/AK/ByteBuffer.h index 9f776c45a8..33267f347a 100644 --- a/AK/ByteBuffer.h +++ b/AK/ByteBuffer.h @@ -11,7 +11,7 @@ public: 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) @@ -26,7 +26,7 @@ public: } ByteBuffer& operator=(const ByteBuffer& other) { - m_impl = other.m_impl.copyRef(); + m_impl = other.m_impl.copy_ref(); return *this; } diff --git a/AK/DoublyLinkedList.h b/AK/DoublyLinkedList.h index e011d680a4..3bd8899a3b 100644 --- a/AK/DoublyLinkedList.h +++ b/AK/DoublyLinkedList.h @@ -48,7 +48,7 @@ public: 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) diff --git a/AK/FileSystemPath.cpp b/AK/FileSystemPath.cpp index defdd1a9d6..2a3a556d27 100644 --- a/AK/FileSystemPath.cpp +++ b/AK/FileSystemPath.cpp @@ -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; } diff --git a/AK/Function.h b/AK/Function.h index d1aab89d45..b2d10aa0fe 100644 --- a/AK/Function.h +++ b/AK/Function.h @@ -41,41 +41,41 @@ public: 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; } @@ -103,7 +103,7 @@ private: CallableType m_callable; }; - OwnPtr<CallableWrapperBase> m_callableWrapper; + OwnPtr<CallableWrapperBase> m_callable_wrapper; }; } diff --git a/AK/HashFunctions.h b/AK/HashFunctions.h index 6f9829c0cb..21bfaff94e 100644 --- a/AK/HashFunctions.h +++ b/AK/HashFunctions.h @@ -2,7 +2,7 @@ #include "Types.h" -inline unsigned intHash(dword key) +inline unsigned int_hash(dword key) { key += ~(key << 15); key ^= (key >> 10); @@ -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))); } diff --git a/AK/HashMap.h b/AK/HashMap.h index 7d8a78f72f..1630aaebbb 100644 --- a/AK/HashMap.h +++ b/AK/HashMap.h @@ -54,7 +54,7 @@ public: 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; diff --git a/AK/MappedFile.cpp b/AK/MappedFile.cpp index 6a8ad3515b..3cf7570bc1 100644 --- a/AK/MappedFile.cpp +++ b/AK/MappedFile.cpp @@ -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; } diff --git a/AK/MappedFile.h b/AK/MappedFile.h index 4fbc1872dd..5eee9ed939 100644 --- a/AK/MappedFile.h +++ b/AK/MappedFile.h @@ -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 }; }; diff --git a/AK/OwnPtr.h b/AK/OwnPtr.h index 63b6a4bfb4..1988b7169e 100644 --- a/AK/OwnPtr.h +++ b/AK/OwnPtr.h @@ -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() { @@ -29,7 +29,7 @@ public: { if (this != &other) { delete m_ptr; - m_ptr = other.leakPtr(); + m_ptr = other.leak_ptr(); } return *this; } @@ -39,7 +39,7 @@ public: { if (this != static_cast<void*>(&other)) { delete m_ptr; - m_ptr = other.leakPtr(); + m_ptr = other.leak_ptr(); } return *this; } @@ -69,7 +69,7 @@ public: 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; diff --git a/AK/RetainPtr.h b/AK/RetainPtr.h index 582cf358d7..b98278ccee 100644 --- a/AK/RetainPtr.h +++ b/AK/RetainPtr.h @@ -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(); @@ -25,15 +25,15 @@ public: 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(); @@ -49,8 +49,8 @@ public: 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; } @@ -59,8 +59,8 @@ public: 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; } @@ -68,18 +68,18 @@ public: 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; } @@ -89,14 +89,14 @@ public: 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; } @@ -105,7 +105,7 @@ public: 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; diff --git a/AK/SimpleMalloc.cpp b/AK/SimpleMalloc.cpp index e92d7295d0..295e841922 100644 --- a/AK/SimpleMalloc.cpp +++ b/AK/SimpleMalloc.cpp @@ -50,28 +50,28 @@ public: void initialize(byte* base) { m_base = base; - m_free = capacityInAllocations(); + m_free = capacity_in_allocations(); dump(); } - static constexpr dword capacityInAllocations() + static constexpr dword capacity_in_allocations() { return 1048576 / chunkSize; } - static constexpr dword capacityInBytes() + static constexpr dword capacity_in_bytes() { - return capacityInAllocations() * chunkSize; + return capacity_in_allocations() * chunkSize; } byte* allocate() { auto bitmap = this->bitmap(); - for (dword i = 0; i < capacityInAllocations(); ++i) { + for (dword i = 0; i < capacity_in_allocations(); ++i) { if (!bitmap.get(i)) { bitmap.set(i, true); --m_free; - return pointerToChunk(i); + return pointer_to_chunk(i); } } return nullptr; @@ -84,57 +84,57 @@ public: void free(byte* ptr) { - ASSERT(isInAllocator(ptr)); + ASSERT(is_in_allocator(ptr)); auto bitmap = this->bitmap(); - auto chunkIndex = chunkIndexFromPointer(ptr); - ASSERT(bitmap.get(chunkIndex)); - bitmap.set(chunkIndex, false); + auto chunk_index = chunk_index_from_pointer(ptr); + ASSERT(bitmap.get(chunk_index)); + bitmap.set(chunk_index, false); ++m_free; } - bool isInAllocator(byte* ptr) + bool is_in_allocator(byte* ptr) { - return ptr >= pointerToChunk(0) && ptr <= addressAfterThisAllocator(); + return ptr >= pointer_to_chunk(0) && ptr <= address_after_this_allocator(); } - dword chunkIndexFromPointer(byte* ptr) + dword chunk_index_from_pointer(byte* ptr) { - return (ptr - pointerToChunk(0)) / chunkSize; + return (ptr - pointer_to_chunk(0)) / chunkSize; } - byte* pointerToChunk(dword index) + byte* pointer_to_chunk(dword index) { - return m_base + sizeOfAllocationBitmapInBytes() + (index * chunkSize); + return m_base + size_of_allocation_bitmap_in_bytes() + (index * chunkSize); } AllocationBitmap bitmap() { - return AllocationBitmap::wrap(m_base, capacityInAllocations()); + return AllocationBitmap::wrap(m_base, capacity_in_allocations()); } - static constexpr dword sizeOfAllocationBitmapInBytes() + static constexpr dword size_of_allocation_bitmap_in_bytes() { - return capacityInAllocations() / 8; + return capacity_in_allocations() / 8; } - byte* addressAfterThisAllocator() const + byte* address_after_this_allocator() const { - return m_base + sizeOfAllocationBitmapInBytes() + capacityInBytes(); + return m_base + size_of_allocation_bitmap_in_bytes() + capacity_in_bytes(); } - dword numberOfFreeChunks() const + dword number_of_free_chunks() const { return m_free; } private: byte* m_base { nullptr }; - dword m_free { capacityInAllocations() }; + dword m_free { capacity_in_allocations() }; }; struct Allocator { void initialize(); - void initializeIfNeeded(); + void initialize_if_needed(); void dump(); ChunkAllocator<8> alloc8; @@ -148,7 +148,7 @@ struct Allocator { static Allocator allocator; -void Allocator::initializeIfNeeded() +void Allocator::initialize_if_needed() { if (initialized) return; @@ -161,9 +161,9 @@ void Allocator::initialize() space = (byte*)mmap((void*)0x20000000, 32 * MB, PROT_WRITE | PROT_READ | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); ASSERT(space != MAP_FAILED); alloc8.initialize(space + 0x10000); - alloc16.initialize(alloc8.addressAfterThisAllocator()); - alloc4096.initialize(alloc16.addressAfterThisAllocator()); - alloc16384.initialize(alloc4096.addressAfterThisAllocator()); + alloc16.initialize(alloc8.address_after_this_allocator()); + alloc4096.initialize(alloc16.address_after_this_allocator()); + alloc16384.initialize(alloc4096.address_after_this_allocator()); } void Allocator::dump() @@ -188,7 +188,7 @@ byte* allocate(dword size) { if (!size) return nullptr; - allocator.initializeIfNeeded(); + allocator.initialize_if_needed(); if (size <= 8) { if (auto* ptr = allocator.alloc8.allocate()) return ptr; @@ -210,7 +210,7 @@ byte* allocate(dword size) return nullptr; } -byte* allocateZeroed(dword size) +byte* allocate_zeroed(dword size) { auto* ptr = allocate(size); if (!ptr) @@ -232,20 +232,20 @@ void free(byte* ptr) { if (!ptr) return; - allocator.initializeIfNeeded(); - if (allocator.alloc8.isInAllocator(ptr)) { + allocator.initialize_if_needed(); + if (allocator.alloc8.is_in_allocator(ptr)) { allocator.alloc8.free(ptr); return; } - if (allocator.alloc16.isInAllocator(ptr)) { + if (allocator.alloc16.is_in_allocator(ptr)) { allocator.alloc16.free(ptr); return; } - if (allocator.alloc4096.isInAllocator(ptr)) { + if (allocator.alloc4096.is_in_allocator(ptr)) { allocator.alloc4096.free(ptr); return; } - if (allocator.alloc16384.isInAllocator(ptr)) { + if (allocator.alloc16384.is_in_allocator(ptr)) { allocator.alloc16384.free(ptr); return; } diff --git a/AK/SimpleMalloc.h b/AK/SimpleMalloc.h index 3b4457cdff..84b214533b 100644 --- a/AK/SimpleMalloc.h +++ b/AK/SimpleMalloc.h @@ -7,7 +7,7 @@ namespace SimpleMalloc { void initialize(); void dump(); byte* allocate(dword); -byte* allocateZeroed(dword); +byte* allocate_zeroed(dword); void free(byte*); byte* reallocate(byte*, dword); diff --git a/AK/SinglyLinkedList.h b/AK/SinglyLinkedList.h index b22cab0ac5..e7bd1cfd3b 100644 --- a/AK/SinglyLinkedList.h +++ b/AK/SinglyLinkedList.h @@ -47,7 +47,7 @@ public: m_tail = node; } - 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) diff --git a/AK/StdLibExtras.h b/AK/StdLibExtras.h index 8c13ee0e12..7d68c5d002 100644 --- a/AK/StdLibExtras.h +++ b/AK/StdLibExtras.h @@ -45,7 +45,7 @@ inline T max(const T& a, const T& b) template<typename T, typename U> -static inline T ceilDiv(T a, U b) +static inline T ceil_div(T a, U b) { static_assert(sizeof(T) == sizeof(U)); T result = a / b; @@ -173,5 +173,5 @@ using AK::move; using AK::forward; using AK::exchange; using AK::swap; -using AK::ceilDiv; +using AK::ceil_div; diff --git a/AK/String.cpp b/AK/String.cpp index 638296f7d4..421bcb89a9 100644 --- a/AK/String.cpp +++ b/AK/String.cpp @@ -42,10 +42,10 @@ String String::substring(size_t start, size_t length) const ASSERT(start + length <= m_impl->length()); // FIXME: This needs some input bounds checking. char* buffer; - auto newImpl = StringImpl::create_uninitialized(length, buffer); + auto new_impl = StringImpl::create_uninitialized(length, buffer); memcpy(buffer, characters() + start, length); buffer[length] = '\0'; - return newImpl; + return new_impl; } Vector<String> String::split(const char separator) const @@ -79,7 +79,7 @@ ByteBuffer String::to_byte_buffer() const return ByteBuffer::copy(reinterpret_cast<const byte*>(characters()), length()); } -unsigned String::toUInt(bool& ok) const +unsigned String::to_uint(bool& ok) const { unsigned value = 0; for (size_t i = 0; i < length(); ++i) { @@ -101,7 +101,7 @@ String String::format(const char* fmt, ...) va_start(ap, fmt); builder.appendvf(fmt, ap); va_end(ap); - return builder.build(); + return builder.to_string(); } } diff --git a/AK/StringBuilder.cpp b/AK/StringBuilder.cpp index 790ea55440..5ef572d019 100644 --- a/AK/StringBuilder.cpp +++ b/AK/StringBuilder.cpp @@ -43,7 +43,7 @@ void StringBuilder::append(char ch) void StringBuilder::appendvf(const char* fmt, va_list ap) { - printfInternal([this] (char*&, char ch) { + printf_internal([this] (char*&, char ch) { append(ch); }, nullptr, fmt, ap); } @@ -62,7 +62,7 @@ ByteBuffer StringBuilder::to_byte_buffer() return move(m_buffer); } -String StringBuilder::build() +String StringBuilder::to_string() { auto string = String((const char*)m_buffer.pointer(), m_length); m_buffer.clear(); diff --git a/AK/StringBuilder.h b/AK/StringBuilder.h index a01f5504c4..9aa83c6357 100644 --- a/AK/StringBuilder.h +++ b/AK/StringBuilder.h @@ -17,7 +17,7 @@ public: void appendf(const char*, ...); void appendvf(const char*, va_list); - String build(); + String to_string(); ByteBuffer to_byte_buffer(); private: diff --git a/AK/StringImpl.cpp b/AK/StringImpl.cpp index 7b00550114..3bf43dd1cd 100644 --- a/AK/StringImpl.cpp +++ b/AK/StringImpl.cpp @@ -55,7 +55,7 @@ StringImpl::~StringImpl() #endif } -static inline size_t allocationSizeForStringImpl(size_t length) +static inline size_t allocation_size_for_stringimpl(size_t length) { return sizeof(StringImpl) + (sizeof(char) * length) + sizeof(char); } @@ -63,14 +63,14 @@ static inline size_t allocationSizeForStringImpl(size_t length) RetainPtr<StringImpl> StringImpl::create_uninitialized(size_t length, char*& buffer) { ASSERT(length); - void* slot = kmalloc(allocationSizeForStringImpl(length)); + void* slot = kmalloc(allocation_size_for_stringimpl(length)); if (!slot) return nullptr; - auto newStringImpl = adopt(*new (slot) StringImpl(ConstructWithInlineBuffer, length)); - buffer = const_cast<char*>(newStringImpl->m_characters); + auto new_stringimpl = adopt(*new (slot) StringImpl(ConstructWithInlineBuffer, length)); + buffer = const_cast<char*>(new_stringimpl->m_characters); buffer[length] = '\0'; - return newStringImpl; + return new_stringimpl; } RetainPtr<StringImpl> StringImpl::create(const char* cstring, size_t length, ShouldChomp shouldChomp) @@ -82,17 +82,17 @@ RetainPtr<StringImpl> StringImpl::create(const char* cstring, size_t length, Sho return the_empty_stringimpl(); char* buffer; - auto newStringImpl = create_uninitialized(length, buffer); - if (!newStringImpl) + auto new_stringimpl = create_uninitialized(length, buffer); + if (!new_stringimpl) return nullptr; memcpy(buffer, cstring, length * sizeof(char)); if (shouldChomp && buffer[length - 1] == '\n') { buffer[length - 1] = '\0'; - --newStringImpl->m_length; + --new_stringimpl->m_length; } - return newStringImpl; + return new_stringimpl; } RetainPtr<StringImpl> StringImpl::create(const char* cstring, ShouldChomp shouldChomp) @@ -103,26 +103,26 @@ RetainPtr<StringImpl> StringImpl::create(const char* cstring, ShouldChomp should return create(cstring, strlen(cstring), shouldChomp); } -static inline bool isASCIILowercase(char c) +static inline bool is_ascii_lowercase(char c) { return c >= 'a' && c <= 'z'; } -static inline bool isASCIIUppercase(char c) +static inline bool is_ascii_uppercase(char c) { return c >= 'A' && c <= 'Z'; } -static inline char toASCIILowercase(char c) +static inline char to_ascii_lowercase(char c) { - if (isASCIIUppercase(c)) + if (is_ascii_uppercase(c)) return c | 0x20; return c; } -static inline char toASCIIUppercase(char c) +static inline char to_ascii_uppercase(char c) { - if (isASCIILowercase(c)) + if (is_ascii_lowercase(c)) return c & ~0x20; return c; } @@ -133,18 +133,18 @@ RetainPtr<StringImpl> StringImpl::to_lowercase() const return const_cast<StringImpl*>(this); for (size_t i = 0; i < m_length; ++i) { - if (!isASCIILowercase(m_characters[i])) - goto slowPath; + if (!is_ascii_lowercase(m_characters[i])) + goto slow_path; } return const_cast<StringImpl*>(this); -slowPath: +slow_path: char* buffer; auto lowercased = create_uninitialized(m_length, buffer); if (!lowercased) return nullptr; for (size_t i = 0; i < m_length; ++i) - buffer[i] = toASCIILowercase(m_characters[i]); + buffer[i] = to_ascii_lowercase(m_characters[i]); return lowercased; } @@ -155,18 +155,18 @@ RetainPtr<StringImpl> StringImpl::to_uppercase() const return const_cast<StringImpl*>(this); for (size_t i = 0; i < m_length; ++i) { - if (!isASCIIUppercase(m_characters[i])) - goto slowPath; + if (!is_ascii_uppercase(m_characters[i])) + goto slow_path; } return const_cast<StringImpl*>(this); -slowPath: +slow_path: char* buffer; auto uppercased = create_uninitialized(m_length, buffer); if (!uppercased) return nullptr; for (size_t i = 0; i < m_length; ++i) - buffer[i] = toASCIIUppercase(m_characters[i]); + buffer[i] = to_ascii_uppercase(m_characters[i]); return uppercased; } diff --git a/AK/TemporaryFile.cpp b/AK/TemporaryFile.cpp index 9d16ee54ea..3ed991c01f 100644 --- a/AK/TemporaryFile.cpp +++ b/AK/TemporaryFile.cpp @@ -11,14 +11,14 @@ TemporaryFile::TemporaryFile() int fd = mkstemp(nameBuffer); if (fd != -1) { m_stream = fdopen(fd, "w+"); - m_fileName = nameBuffer; + m_file_name = nameBuffer; } } TemporaryFile::~TemporaryFile() { - if (isValid()) { - unlink(m_fileName.characters()); + if (is_valid()) { + unlink(m_file_name.characters()); fclose(m_stream); } } diff --git a/AK/TemporaryFile.h b/AK/TemporaryFile.h index 4596a214d0..624eeb4c9b 100644 --- a/AK/TemporaryFile.h +++ b/AK/TemporaryFile.h @@ -10,14 +10,14 @@ public: TemporaryFile(); ~TemporaryFile(); - bool isValid() const { return m_stream; } + bool is_valid() const { return m_stream; } FILE* stream() { return m_stream; } - String fileName() const { return m_fileName; } + String file_name() const { return m_file_name; } void sync(); private: FILE* m_stream { nullptr }; - String m_fileName; + String m_file_name; }; } diff --git a/AK/Traits.h b/AK/Traits.h index 734212187a..de6a8671aa 100644 --- a/AK/Traits.h +++ b/AK/Traits.h @@ -12,13 +12,13 @@ struct Traits template<> struct Traits<int> { - static unsigned hash(int i) { return intHash(i); } + static unsigned hash(int i) { return int_hash(i); } static void dump(int i) { kprintf("%d", i); } }; template<> struct Traits<unsigned> { - static unsigned hash(unsigned u) { return intHash(u); } + static unsigned hash(unsigned u) { return int_hash(u); } static void dump(unsigned u) { kprintf("%u", u); } }; @@ -26,7 +26,7 @@ template<typename T> struct Traits<T*> { static unsigned hash(const T* p) { - return intHash((dword)p); + return int_hash((dword)p); } static void dump(const T* p) { kprintf("%p", p); } }; diff --git a/AK/Vector.h b/AK/Vector.h index 6d9c7c1ff8..eea3116662 100644 --- a/AK/Vector.h +++ b/AK/Vector.h @@ -219,16 +219,16 @@ public: if (capacity() >= neededCapacity) return; size_t new_capacity = padded_capacity(neededCapacity); - auto newImpl = VectorImpl<T, Allocator>::create(new_capacity); + auto new_impl = VectorImpl<T, Allocator>::create(new_capacity); if (m_impl) { - newImpl->m_size = m_impl->m_size; + new_impl->m_size = m_impl->m_size; for (size_t i = 0; i < size(); ++i) { - new (newImpl->slot(i)) T(move(m_impl->at(i))); + new (new_impl->slot(i)) T(move(m_impl->at(i))); m_impl->at(i).~T(); } Allocator::deallocate(m_impl); } - m_impl = newImpl; + m_impl = new_impl; } void resize(size_t new_size) diff --git a/AK/WeakPtr.h b/AK/WeakPtr.h index a89c2bc8bf..775c2dfee1 100644 --- a/AK/WeakPtr.h +++ b/AK/WeakPtr.h @@ -13,14 +13,14 @@ public: template<typename U> WeakPtr(WeakPtr<U>&& other) - : m_link(reinterpret_cast<WeakLink<T>*>(other.leakLink())) + : m_link(reinterpret_cast<WeakLink<T>*>(other.leak_link())) { } template<typename U> WeakPtr& operator=(WeakPtr<U>&& other) { - m_link = reinterpret_cast<WeakLink<T>*>(other.leakLink()); + m_link = reinterpret_cast<WeakLink<T>*>(other.leak_link()); return *this; } @@ -38,7 +38,7 @@ public: bool is_null() const { return !m_link || !m_link->ptr(); } void clear() { m_link = nullptr; } - WeakLink<T>* leakLink() { return m_link.leakRef(); } + WeakLink<T>* leak_link() { return m_link.leak_ref(); } private: WeakPtr(RetainPtr<WeakLink<T>>&& link) : m_link(move(link)) { } @@ -47,11 +47,11 @@ private: }; template<typename T> -inline WeakPtr<T> Weakable<T>::makeWeakPtr() +inline WeakPtr<T> Weakable<T>::make_weak_ptr() { if (!m_link) m_link = adopt(*new WeakLink<T>(static_cast<T&>(*this))); - return WeakPtr<T>(m_link.copyRef()); + return WeakPtr<T>(m_link.copy_ref()); } } diff --git a/AK/Weakable.h b/AK/Weakable.h index 8f47b6ac2f..c9590c2be1 100644 --- a/AK/Weakable.h +++ b/AK/Weakable.h @@ -26,7 +26,7 @@ class Weakable { private: class Link; public: - WeakPtr<T> makeWeakPtr(); + WeakPtr<T> make_weak_ptr(); protected: Weakable() { } diff --git a/AK/kmalloc.cpp b/AK/kmalloc.cpp index c3926b6df0..e510a9314e 100644 --- a/AK/kmalloc.cpp +++ b/AK/kmalloc.cpp @@ -84,7 +84,7 @@ void* kcalloc(size_t nmemb, size_t size) { if (!nmemb || !size) return nullptr; - return SimpleMalloc::allocateZeroed(nmemb * size); + return SimpleMalloc::allocate_zeroed(nmemb * size); } void* kmalloc(size_t size) diff --git a/AK/printf.cpp b/AK/printf.cpp index 63a028cefc..b40ee07ca7 100644 --- a/AK/printf.cpp +++ b/AK/printf.cpp @@ -13,7 +13,7 @@ ALWAYS_INLINE size_t strlen(const char* str) static constexpr const char* h = "0123456789abcdef"; template<typename PutChFunc> -ALWAYS_INLINE int printHex(PutChFunc putch, char*& bufptr, dword number, byte fields) +ALWAYS_INLINE int print_hex(PutChFunc putch, char*& bufptr, dword number, byte fields) { int ret = 0; byte shr_count = fields * 4; @@ -26,7 +26,7 @@ ALWAYS_INLINE int printHex(PutChFunc putch, char*& bufptr, dword number, byte fi } template<typename PutChFunc> -ALWAYS_INLINE int printNumber(PutChFunc putch, char*& bufptr, dword number, bool leftPad, bool zeroPad, dword fieldWidth) +ALWAYS_INLINE int print_number(PutChFunc putch, char*& bufptr, dword number, bool leftPad, bool zeroPad, dword fieldWidth) { dword divisor = 1000000000; char ch; @@ -108,7 +108,7 @@ ALWAYS_INLINE int print_octal_number(PutChFunc putch, char*& bufptr, dword numbe } template<typename PutChFunc> -ALWAYS_INLINE int printString(PutChFunc putch, char*& bufptr, const char* str, bool leftPad, dword fieldWidth) +ALWAYS_INLINE int print_string(PutChFunc putch, char*& bufptr, const char* str, bool leftPad, dword fieldWidth) { size_t len = strlen(str); if (!fieldWidth || fieldWidth < len) @@ -129,17 +129,17 @@ ALWAYS_INLINE int printString(PutChFunc putch, char*& bufptr, const char* str, b template<typename PutChFunc> -ALWAYS_INLINE int printSignedNumber(PutChFunc putch, char*& bufptr, int number, bool leftPad, bool zeroPad, dword fieldWidth) +ALWAYS_INLINE int print_signed_number(PutChFunc putch, char*& bufptr, int number, bool leftPad, bool zeroPad, dword fieldWidth) { if (number < 0) { putch(bufptr, '-'); - return printNumber(putch, bufptr, 0 - number, leftPad, zeroPad, fieldWidth) + 1; + return print_number(putch, bufptr, 0 - number, leftPad, zeroPad, fieldWidth) + 1; } - return printNumber(putch, bufptr, number, leftPad, zeroPad, fieldWidth); + return print_number(putch, bufptr, number, leftPad, zeroPad, fieldWidth); } template<typename PutChFunc> -ALWAYS_INLINE int printfInternal(PutChFunc putch, char* buffer, const char*& fmt, char*& ap) +ALWAYS_INLINE int printf_internal(PutChFunc putch, char* buffer, const char*& fmt, char*& ap) { const char *p; @@ -174,16 +174,16 @@ one_more: case 's': { const char* sp = va_arg(ap, const char*); - ret += printString(putch, bufptr, sp ? sp : "(null)", leftPad, fieldWidth); + ret += print_string(putch, bufptr, sp ? sp : "(null)", leftPad, fieldWidth); } break; case 'd': - ret += printSignedNumber(putch, bufptr, va_arg(ap, int), leftPad, zeroPad, fieldWidth); + ret += print_signed_number(putch, bufptr, va_arg(ap, int), leftPad, zeroPad, fieldWidth); break; case 'u': - ret += printNumber(putch, bufptr, va_arg(ap, dword), leftPad, zeroPad, fieldWidth); + ret += print_number(putch, bufptr, va_arg(ap, dword), leftPad, zeroPad, fieldWidth); break; case 'o': @@ -191,15 +191,15 @@ one_more: break; case 'x': - ret += printHex(putch, bufptr, va_arg(ap, dword), 8); + ret += print_hex(putch, bufptr, va_arg(ap, dword), 8); break; case 'w': - ret += printHex(putch, bufptr, va_arg(ap, int), 4); + ret += print_hex(putch, bufptr, va_arg(ap, int), 4); break; case 'b': - ret += printHex(putch, bufptr, va_arg(ap, int), 2); + ret += print_hex(putch, bufptr, va_arg(ap, int), 2); break; case 'c': @@ -211,7 +211,7 @@ one_more: putch(bufptr, '0'); putch(bufptr, 'x'); ret += 2; - ret += printHex(putch, bufptr, va_arg(ap, dword), 8); + ret += print_hex(putch, bufptr, va_arg(ap, dword), 8); break; } } diff --git a/AK/test.cpp b/AK/test.cpp index 34ba3244be..761d817147 100644 --- a/AK/test.cpp +++ b/AK/test.cpp @@ -13,7 +13,7 @@ #include "FileSystemPath.h" #include "Lock.h" -static void testWeakPtr(); +static void test_weak_ptr(); void log_locked() { } void log_unlocked() { } @@ -223,7 +223,7 @@ int main(int c, char** v) } { - auto printInts = [] (const Vector<int>& v) { + auto print_ints = [] (const Vector<int>& v) { printf("Vector {\n size: %zu\n capacity: %zu\n elements: ", v.size(), v.capacity()); for (auto i : v) printf("%d ", i); @@ -235,23 +235,23 @@ int main(int c, char** v) v.append(1); v.append(2); v.append(3); - printInts(v); + print_ints(v); v.remove(1); - printInts(v); + print_ints(v); v.remove(0); - printInts(v); + print_ints(v); v.remove(0); - printInts(v); + print_ints(v); v.remove(0); - printInts(v); + print_ints(v); } { - auto printInts = [] (const HashTable<int>& h) { + auto print_ints = [] (const HashTable<int>& h) { printf("HashTable {\n size: %u\n capacity: %u\n elements: ", h.size(), h.capacity()); for (auto i : h) printf("%d ", i); @@ -268,17 +268,17 @@ int main(int c, char** v) h.dump(); - printInts(h); + print_ints(h); h.remove(30); - printInts(h); + print_ints(h); h.set(30); h.remove(30); - printInts(h); + print_ints(h); } - testWeakPtr(); + test_weak_ptr(); return 0; } @@ -289,16 +289,16 @@ public: ~TestWeakable() { } }; -void testWeakPtr() +void test_weak_ptr() { auto* weakable = new TestWeakable; - auto weakPtr = weakable->makeWeakPtr(); - ASSERT(weakPtr); - ASSERT(weakPtr.ptr() == weakable); + auto weak_ptr = weakable->make_weak_ptr(); + ASSERT(weak_ptr); + ASSERT(weak_ptr.ptr() == weakable); delete weakable; - ASSERT(!weakPtr); - ASSERT(weakPtr.ptr() == nullptr); + ASSERT(!weak_ptr); + ASSERT(weak_ptr.ptr() == nullptr); } |