mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 08:32:43 +00:00 
			
		
		
		
	Add clang-format file
Also run it across the whole tree to get everything using the One True Style. We don't yet run this in an automated fashion as it's a little slow, but there is a snippet to do so in makeall.sh.
This commit is contained in:
		
							parent
							
								
									c11351ac50
								
							
						
					
					
						commit
						0dc9af5f7e
					
				
					 286 changed files with 3244 additions and 2424 deletions
				
			
		
							
								
								
									
										13
									
								
								.clang-format
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								.clang-format
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,13 @@ | ||||||
|  | --- | ||||||
|  | Language: Cpp | ||||||
|  | BasedOnStyle: WebKit | ||||||
|  | SpaceAfterTemplateKeyword: false | ||||||
|  | AlignEscapedNewlines: true | ||||||
|  | AlignTrailingComments: true | ||||||
|  | BreakBeforeInheritanceComma: true | ||||||
|  | BreakConstructorInitializers: BeforeComma | ||||||
|  | IndentPPDirectives: AfterHash | ||||||
|  | BreakBeforeBraces: Custom | ||||||
|  | BraceWrapping: | ||||||
|  |     AfterFunction: true | ||||||
|  |     AfterEnum: true | ||||||
|  | @ -3,9 +3,9 @@ | ||||||
| #include <AK/ByteBuffer.h> | #include <AK/ByteBuffer.h> | ||||||
| #include <AK/RetainPtr.h> | #include <AK/RetainPtr.h> | ||||||
| #include <AK/StringImpl.h> | #include <AK/StringImpl.h> | ||||||
|  | #include <AK/StringView.h> | ||||||
| #include <AK/Traits.h> | #include <AK/Traits.h> | ||||||
| #include <AK/Vector.h> | #include <AK/Vector.h> | ||||||
| #include <AK/StringView.h> |  | ||||||
| #include <AK/kstdio.h> | #include <AK/kstdio.h> | ||||||
| 
 | 
 | ||||||
| namespace AK { | namespace AK { | ||||||
|  | @ -96,7 +96,11 @@ public: | ||||||
|     bool is_empty() const { return length() == 0; } |     bool is_empty() const { return length() == 0; } | ||||||
|     ssize_t length() const { return m_impl ? m_impl->length() : 0; } |     ssize_t length() const { return m_impl ? m_impl->length() : 0; } | ||||||
|     const char* characters() const { return m_impl ? m_impl->characters() : nullptr; } |     const char* characters() const { return m_impl ? m_impl->characters() : nullptr; } | ||||||
|     char operator[](ssize_t i) const { ASSERT(m_impl); return (*m_impl)[i]; } |     char operator[](ssize_t i) const | ||||||
|  |     { | ||||||
|  |         ASSERT(m_impl); | ||||||
|  |         return (*m_impl)[i]; | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     bool ends_with(const String&) const; |     bool ends_with(const String&) const; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -17,4 +17,3 @@ inline void not_implemented() { ASSERT(false); } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| using AK::not_implemented; | using AK::not_implemented; | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -1,9 +1,9 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
|  | #include "Assertions.h" | ||||||
| #include "StdLibExtras.h" | #include "StdLibExtras.h" | ||||||
| #include "Types.h" | #include "Types.h" | ||||||
| #include "kmalloc.h" | #include "kmalloc.h" | ||||||
| #include "Assertions.h" |  | ||||||
| 
 | 
 | ||||||
| namespace AK { | namespace AK { | ||||||
| 
 | 
 | ||||||
|  | @ -77,4 +77,3 @@ private: | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| using AK::Bitmap; | using AK::Bitmap; | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -1,9 +1,9 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include "Types.h" |  | ||||||
| #include "StdLibExtras.h" | #include "StdLibExtras.h" | ||||||
| #include <AK/Retainable.h> | #include "Types.h" | ||||||
| #include <AK/RetainPtr.h> | #include <AK/RetainPtr.h> | ||||||
|  | #include <AK/Retainable.h> | ||||||
| #include <AK/kmalloc.h> | #include <AK/kmalloc.h> | ||||||
| 
 | 
 | ||||||
| namespace AK { | namespace AK { | ||||||
|  | @ -28,8 +28,16 @@ public: | ||||||
|         m_data = nullptr; |         m_data = nullptr; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     byte& operator[](int i) { ASSERT(i < m_size); return m_data[i]; } |     byte& operator[](int i) | ||||||
|     const byte& operator[](int i) const { ASSERT(i < m_size); return m_data[i]; } |     { | ||||||
|  |         ASSERT(i < m_size); | ||||||
|  |         return m_data[i]; | ||||||
|  |     } | ||||||
|  |     const byte& operator[](int i) const | ||||||
|  |     { | ||||||
|  |         ASSERT(i < m_size); | ||||||
|  |         return m_data[i]; | ||||||
|  |     } | ||||||
|     bool is_empty() const { return !m_size; } |     bool is_empty() const { return !m_size; } | ||||||
|     int size() const { return m_size; } |     int size() const { return m_size; } | ||||||
| 
 | 
 | ||||||
|  | @ -52,7 +60,12 @@ public: | ||||||
|     void grow(int size); |     void grow(int size); | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     enum ConstructionMode { Uninitialized, Copy, Wrap, Adopt }; |     enum ConstructionMode { | ||||||
|  |         Uninitialized, | ||||||
|  |         Copy, | ||||||
|  |         Wrap, | ||||||
|  |         Adopt | ||||||
|  |     }; | ||||||
|     explicit ByteBufferImpl(int);                       // For ConstructionMode=Uninitialized
 |     explicit ByteBufferImpl(int);                       // For ConstructionMode=Uninitialized
 | ||||||
|     ByteBufferImpl(const void*, int, ConstructionMode); // For ConstructionMode=Copy
 |     ByteBufferImpl(const void*, int, ConstructionMode); // For ConstructionMode=Copy
 | ||||||
|     ByteBufferImpl(void*, int, ConstructionMode);       // For ConstructionMode=Wrap/Adopt
 |     ByteBufferImpl(void*, int, ConstructionMode);       // For ConstructionMode=Wrap/Adopt
 | ||||||
|  | @ -101,8 +114,16 @@ public: | ||||||
|     bool operator!() const { return is_null(); } |     bool operator!() const { return is_null(); } | ||||||
|     bool is_null() const { return m_impl == nullptr; } |     bool is_null() const { return m_impl == nullptr; } | ||||||
| 
 | 
 | ||||||
|     byte& operator[](ssize_t i) { ASSERT(m_impl); return (*m_impl)[i]; } |     byte& operator[](ssize_t i) | ||||||
|     byte operator[](ssize_t i) const { ASSERT(m_impl); return (*m_impl)[i]; } |     { | ||||||
|  |         ASSERT(m_impl); | ||||||
|  |         return (*m_impl)[i]; | ||||||
|  |     } | ||||||
|  |     byte operator[](ssize_t i) const | ||||||
|  |     { | ||||||
|  |         ASSERT(m_impl); | ||||||
|  |         return (*m_impl)[i]; | ||||||
|  |     } | ||||||
|     bool is_empty() const { return !m_impl || m_impl->is_empty(); } |     bool is_empty() const { return !m_impl || m_impl->is_empty(); } | ||||||
|     ssize_t size() const { return m_impl ? m_impl->size() : 0; } |     ssize_t size() const { return m_impl ? m_impl->size() : 0; } | ||||||
| 
 | 
 | ||||||
|  | @ -241,4 +262,3 @@ inline Retained<ByteBufferImpl> ByteBufferImpl::adopt(void* data, int size) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| using AK::ByteBuffer; | using AK::ByteBuffer; | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -60,9 +60,14 @@ public: | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         const T& operator*() const { return m_queue.m_elements[m_index]; } |         const T& operator*() const { return m_queue.m_elements[m_index]; } | ||||||
|  | 
 | ||||||
|     private: |     private: | ||||||
|         friend class CircularQueue; |         friend class CircularQueue; | ||||||
|         ConstIterator(const CircularQueue& queue, const int index) : m_queue(queue), m_index(index) { } |         ConstIterator(const CircularQueue& queue, const int index) | ||||||
|  |             : m_queue(queue) | ||||||
|  |             , m_index(index) | ||||||
|  |         { | ||||||
|  |         } | ||||||
|         const CircularQueue& m_queue; |         const CircularQueue& m_queue; | ||||||
|         int m_index { 0 }; |         int m_index { 0 }; | ||||||
|     }; |     }; | ||||||
|  | @ -82,4 +87,3 @@ private: | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| using AK::CircularQueue; | using AK::CircularQueue; | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -9,8 +9,14 @@ template<typename T> | ||||||
| class DoublyLinkedList { | class DoublyLinkedList { | ||||||
| private: | private: | ||||||
|     struct Node { |     struct Node { | ||||||
|         explicit Node(const T& v) : value(v) { } |         explicit Node(const T& v) | ||||||
|         explicit Node(T&& v) : value(move(v)) { } |             : value(v) | ||||||
|  |         { | ||||||
|  |         } | ||||||
|  |         explicit Node(T&& v) | ||||||
|  |             : value(move(v)) | ||||||
|  |         { | ||||||
|  |         } | ||||||
|         T value; |         T value; | ||||||
|         Node* next { nullptr }; |         Node* next { nullptr }; | ||||||
|         Node* prev { nullptr }; |         Node* prev { nullptr }; | ||||||
|  | @ -33,15 +39,30 @@ public: | ||||||
|         m_tail = nullptr; |         m_tail = nullptr; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     T& first() { ASSERT(head()); return head()->value; } |     T& first() | ||||||
|     const T& first() const { ASSERT(head()); return head()->value; } |     { | ||||||
|     T& last() { ASSERT(head()); return tail()->value; } |         ASSERT(head()); | ||||||
|     const T& last() const { ASSERT(head()); return tail()->value; } |         return head()->value; | ||||||
|  |     } | ||||||
|  |     const T& first() const | ||||||
|  |     { | ||||||
|  |         ASSERT(head()); | ||||||
|  |         return head()->value; | ||||||
|  |     } | ||||||
|  |     T& last() | ||||||
|  |     { | ||||||
|  |         ASSERT(head()); | ||||||
|  |         return tail()->value; | ||||||
|  |     } | ||||||
|  |     const T& last() const | ||||||
|  |     { | ||||||
|  |         ASSERT(head()); | ||||||
|  |         return tail()->value; | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     void append(T&& value) |     void append(T&& value) | ||||||
|     { |     { | ||||||
|         append_node(new Node(move(value))); |         append_node(new Node(move(value))); | ||||||
| 
 |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     void append(const T& value) |     void append(const T& value) | ||||||
|  | @ -62,14 +83,22 @@ public: | ||||||
|     public: |     public: | ||||||
|         bool operator!=(const Iterator& other) const { return m_node != other.m_node; } |         bool operator!=(const Iterator& other) const { return m_node != other.m_node; } | ||||||
|         bool operator==(const Iterator& other) const { return m_node == other.m_node; } |         bool operator==(const Iterator& other) const { return m_node == other.m_node; } | ||||||
|         Iterator& operator++() { m_node = m_node->next; return *this; } |         Iterator& operator++() | ||||||
|  |         { | ||||||
|  |             m_node = m_node->next; | ||||||
|  |             return *this; | ||||||
|  |         } | ||||||
|         T& operator*() { return m_node->value; } |         T& operator*() { return m_node->value; } | ||||||
|         T* operator->() { return &m_node->value; } |         T* operator->() { return &m_node->value; } | ||||||
|         bool is_end() const { return !m_node; } |         bool is_end() const { return !m_node; } | ||||||
|         static Iterator universal_end() { return Iterator(nullptr); } |         static Iterator universal_end() { return Iterator(nullptr); } | ||||||
|  | 
 | ||||||
|     private: |     private: | ||||||
|         friend class DoublyLinkedList; |         friend class DoublyLinkedList; | ||||||
|         explicit Iterator(DoublyLinkedList::Node* node) : m_node(node) { } |         explicit Iterator(DoublyLinkedList::Node* node) | ||||||
|  |             : m_node(node) | ||||||
|  |         { | ||||||
|  |         } | ||||||
|         DoublyLinkedList::Node* m_node; |         DoublyLinkedList::Node* m_node; | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|  | @ -80,14 +109,22 @@ public: | ||||||
|     public: |     public: | ||||||
|         bool operator!=(const ConstIterator& other) const { return m_node != other.m_node; } |         bool operator!=(const ConstIterator& other) const { return m_node != other.m_node; } | ||||||
|         bool operator==(const ConstIterator& other) const { return m_node == other.m_node; } |         bool operator==(const ConstIterator& other) const { return m_node == other.m_node; } | ||||||
|         ConstIterator& operator++() { m_node = m_node->next; return *this; } |         ConstIterator& operator++() | ||||||
|  |         { | ||||||
|  |             m_node = m_node->next; | ||||||
|  |             return *this; | ||||||
|  |         } | ||||||
|         const T& operator*() const { return m_node->value; } |         const T& operator*() const { return m_node->value; } | ||||||
|         const T* operator->() const { return &m_node->value; } |         const T* operator->() const { return &m_node->value; } | ||||||
|         bool is_end() const { return !m_node; } |         bool is_end() const { return !m_node; } | ||||||
|         static ConstIterator universal_end() { return ConstIterator(nullptr); } |         static ConstIterator universal_end() { return ConstIterator(nullptr); } | ||||||
|  | 
 | ||||||
|     private: |     private: | ||||||
|         friend class DoublyLinkedList; |         friend class DoublyLinkedList; | ||||||
|         explicit ConstIterator(const DoublyLinkedList::Node* node) : m_node(node) { } |         explicit ConstIterator(const DoublyLinkedList::Node* node) | ||||||
|  |             : m_node(node) | ||||||
|  |         { | ||||||
|  |         } | ||||||
|         const DoublyLinkedList::Node* m_node; |         const DoublyLinkedList::Node* m_node; | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|  | @ -163,4 +200,3 @@ private: | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| using AK::DoublyLinkedList; | using AK::DoublyLinkedList; | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -1,7 +1,7 @@ | ||||||
| #include "FileSystemPath.h" | #include "FileSystemPath.h" | ||||||
|  | #include "StringBuilder.h" | ||||||
| #include "Vector.h" | #include "Vector.h" | ||||||
| #include "kstdio.h" | #include "kstdio.h" | ||||||
| #include "StringBuilder.h" |  | ||||||
| 
 | 
 | ||||||
| namespace AK { | namespace AK { | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -31,7 +31,8 @@ | ||||||
| 
 | 
 | ||||||
| namespace AK { | namespace AK { | ||||||
| 
 | 
 | ||||||
| template<typename> class Function; | template<typename> | ||||||
|  | class Function; | ||||||
| 
 | 
 | ||||||
| template<typename Out, typename... In> | template<typename Out, typename... In> | ||||||
| class Function<Out(In...)> { | class Function<Out(In...)> { | ||||||
|  | @ -109,4 +110,3 @@ private: | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| using AK::Function; | using AK::Function; | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -17,4 +17,3 @@ inline unsigned pair_int_hash(dword key1, dword key2) | ||||||
| { | { | ||||||
|     return int_hash((int_hash(key1) * 209) ^ (int_hash(key2 * 413))); |     return int_hash((int_hash(key1) * 209) ^ (int_hash(key2 * 413))); | ||||||
| } | } | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -148,4 +148,3 @@ auto HashMap<K, V>::find(const K& key) const -> ConstIteratorType | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| using AK::HashMap; | using AK::HashMap; | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -2,15 +2,16 @@ | ||||||
| 
 | 
 | ||||||
| #include "Assertions.h" | #include "Assertions.h" | ||||||
| #include "DoublyLinkedList.h" | #include "DoublyLinkedList.h" | ||||||
| #include "Traits.h" |  | ||||||
| #include "StdLibExtras.h" | #include "StdLibExtras.h" | ||||||
|  | #include "Traits.h" | ||||||
| #include "kstdio.h" | #include "kstdio.h" | ||||||
| 
 | 
 | ||||||
| //#define HASHTABLE_DEBUG
 | //#define HASHTABLE_DEBUG
 | ||||||
| 
 | 
 | ||||||
| namespace AK { | namespace AK { | ||||||
| 
 | 
 | ||||||
| template<typename T, typename = Traits<T>> class HashTable; | template<typename T, typename = Traits<T>> | ||||||
|  | class HashTable; | ||||||
| 
 | 
 | ||||||
| template<typename T, typename TraitsForT> | template<typename T, typename TraitsForT> | ||||||
| class HashTable { | class HashTable { | ||||||
|  | @ -112,6 +113,7 @@ public: | ||||||
|                     return; |                     return; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  | 
 | ||||||
|     private: |     private: | ||||||
|         friend class HashTable; |         friend class HashTable; | ||||||
|         explicit Iterator(HashTable& table, bool is_end, typename DoublyLinkedList<T>::Iterator bucket_iterator = DoublyLinkedList<T>::Iterator::universal_end(), int bucket_index = 0) |         explicit Iterator(HashTable& table, bool is_end, typename DoublyLinkedList<T>::Iterator bucket_iterator = DoublyLinkedList<T>::Iterator::universal_end(), int bucket_index = 0) | ||||||
|  | @ -190,6 +192,7 @@ public: | ||||||
|                     return; |                     return; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  | 
 | ||||||
|     private: |     private: | ||||||
|         friend class HashTable; |         friend class HashTable; | ||||||
|         ConstIterator(const HashTable& table, bool is_end, typename DoublyLinkedList<T>::ConstIterator bucket_iterator = DoublyLinkedList<T>::ConstIterator::universal_end(), int bucket_index = 0) |         ConstIterator(const HashTable& table, bool is_end, typename DoublyLinkedList<T>::ConstIterator bucket_iterator = DoublyLinkedList<T>::ConstIterator::universal_end(), int bucket_index = 0) | ||||||
|  | @ -285,7 +288,6 @@ void HashTable<T, TraitsForT>::set(const T& value) | ||||||
|     m_size++; |     m_size++; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| template<typename T, typename TraitsForT> | template<typename T, typename TraitsForT> | ||||||
| void HashTable<T, TraitsForT>::rehash(int new_capacity) | void HashTable<T, TraitsForT>::rehash(int new_capacity) | ||||||
| { | { | ||||||
|  | @ -429,4 +431,3 @@ void HashTable<T, TraitsForT>::dump() const | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| using AK::HashTable; | using AK::HashTable; | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -5,7 +5,8 @@ | ||||||
| 
 | 
 | ||||||
| namespace AK { | namespace AK { | ||||||
| 
 | 
 | ||||||
| template<typename T> class InlineLinkedListNode { | template<typename T> | ||||||
|  | class InlineLinkedListNode { | ||||||
| public: | public: | ||||||
|     InlineLinkedListNode(); |     InlineLinkedListNode(); | ||||||
| 
 | 
 | ||||||
|  | @ -16,33 +17,39 @@ public: | ||||||
|     T* next() const; |     T* next() const; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| template<typename T> inline InlineLinkedListNode<T>::InlineLinkedListNode() | template<typename T> | ||||||
|  | inline InlineLinkedListNode<T>::InlineLinkedListNode() | ||||||
| { | { | ||||||
|     set_prev(0); |     set_prev(0); | ||||||
|     set_next(0); |     set_next(0); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| template<typename T> inline void InlineLinkedListNode<T>::set_prev(T* prev) | template<typename T> | ||||||
|  | inline void InlineLinkedListNode<T>::set_prev(T* prev) | ||||||
| { | { | ||||||
|     static_cast<T*>(this)->m_prev = prev; |     static_cast<T*>(this)->m_prev = prev; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| template<typename T> inline void InlineLinkedListNode<T>::set_next(T* next) | template<typename T> | ||||||
|  | inline void InlineLinkedListNode<T>::set_next(T* next) | ||||||
| { | { | ||||||
|     static_cast<T*>(this)->m_next = next; |     static_cast<T*>(this)->m_next = next; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| template<typename T> inline T* InlineLinkedListNode<T>::prev() const | template<typename T> | ||||||
|  | inline T* InlineLinkedListNode<T>::prev() const | ||||||
| { | { | ||||||
|     return static_cast<const T*>(this)->m_prev; |     return static_cast<const T*>(this)->m_prev; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| template<typename T> inline T* InlineLinkedListNode<T>::next() const | template<typename T> | ||||||
|  | inline T* InlineLinkedListNode<T>::next() const | ||||||
| { | { | ||||||
|     return static_cast<const T*>(this)->m_next; |     return static_cast<const T*>(this)->m_next; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| template<typename T> class InlineLinkedList { | template<typename T> | ||||||
|  | class InlineLinkedList { | ||||||
| public: | public: | ||||||
|     InlineLinkedList() {} |     InlineLinkedList() {} | ||||||
| 
 | 
 | ||||||
|  | @ -75,7 +82,8 @@ private: | ||||||
|     T* m_tail { nullptr }; |     T* m_tail { nullptr }; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| template<typename T> inline size_t InlineLinkedList<T>::size_slow() const | template<typename T> | ||||||
|  | inline size_t InlineLinkedList<T>::size_slow() const | ||||||
| { | { | ||||||
|     size_t size = 0; |     size_t size = 0; | ||||||
|     for (T* node = m_head; node; node = node->next()) |     for (T* node = m_head; node; node = node->next()) | ||||||
|  | @ -83,13 +91,15 @@ template<typename T> inline size_t InlineLinkedList<T>::size_slow() const | ||||||
|     return size; |     return size; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| template<typename T> inline void InlineLinkedList<T>::clear() | template<typename T> | ||||||
|  | inline void InlineLinkedList<T>::clear() | ||||||
| { | { | ||||||
|     m_head = 0; |     m_head = 0; | ||||||
|     m_tail = 0; |     m_tail = 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| template<typename T> inline void InlineLinkedList<T>::prepend(T* node) | template<typename T> | ||||||
|  | inline void InlineLinkedList<T>::prepend(T* node) | ||||||
| { | { | ||||||
|     if (!m_head) { |     if (!m_head) { | ||||||
|         ASSERT(!m_tail); |         ASSERT(!m_tail); | ||||||
|  | @ -107,7 +117,8 @@ template<typename T> inline void InlineLinkedList<T>::prepend(T* node) | ||||||
|     m_head = node; |     m_head = node; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| template<typename T> inline void InlineLinkedList<T>::append(T* node) | template<typename T> | ||||||
|  | inline void InlineLinkedList<T>::append(T* node) | ||||||
| { | { | ||||||
|     if (!m_tail) { |     if (!m_tail) { | ||||||
|         ASSERT(!m_head); |         ASSERT(!m_head); | ||||||
|  | @ -125,7 +136,8 @@ template<typename T> inline void InlineLinkedList<T>::append(T* node) | ||||||
|     m_tail = node; |     m_tail = node; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| template<typename T> inline void InlineLinkedList<T>::remove(T* node) | template<typename T> | ||||||
|  | inline void InlineLinkedList<T>::remove(T* node) | ||||||
| { | { | ||||||
|     if (node->prev()) { |     if (node->prev()) { | ||||||
|         ASSERT(node != m_head); |         ASSERT(node != m_head); | ||||||
|  | @ -144,7 +156,8 @@ template<typename T> inline void InlineLinkedList<T>::remove(T* node) | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| template<typename T> inline T* InlineLinkedList<T>::remove_head() | template<typename T> | ||||||
|  | inline T* InlineLinkedList<T>::remove_head() | ||||||
| { | { | ||||||
|     T* node = head(); |     T* node = head(); | ||||||
|     if (node) |     if (node) | ||||||
|  | @ -152,7 +165,8 @@ template<typename T> inline T* InlineLinkedList<T>::remove_head() | ||||||
|     return node; |     return node; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| template<typename T> inline T* InlineLinkedList<T>::remove_tail() | template<typename T> | ||||||
|  | inline T* InlineLinkedList<T>::remove_tail() | ||||||
| { | { | ||||||
|     T* node = tail(); |     T* node = tail(); | ||||||
|     if (node) |     if (node) | ||||||
|  | @ -160,7 +174,8 @@ template<typename T> inline T* InlineLinkedList<T>::remove_tail() | ||||||
|     return node; |     return node; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| template<typename T> inline void InlineLinkedList<T>::append(InlineLinkedList<T>& other) | template<typename T> | ||||||
|  | inline void InlineLinkedList<T>::append(InlineLinkedList<T>& other) | ||||||
| { | { | ||||||
|     if (!other.head()) |     if (!other.head()) | ||||||
|         return; |         return; | ||||||
|  |  | ||||||
|  | @ -1,9 +1,9 @@ | ||||||
| #include <AK/MappedFile.h> | #include <AK/MappedFile.h> | ||||||
|  | #include <fcntl.h> | ||||||
|  | #include <stdio.h> | ||||||
| #include <sys/mman.h> | #include <sys/mman.h> | ||||||
| #include <sys/stat.h> | #include <sys/stat.h> | ||||||
| #include <fcntl.h> |  | ||||||
| #include <unistd.h> | #include <unistd.h> | ||||||
| #include <stdio.h> |  | ||||||
| 
 | 
 | ||||||
| //#define DEBUG_MAPPED_FILE
 | //#define DEBUG_MAPPED_FILE
 | ||||||
| 
 | 
 | ||||||
|  | @ -74,4 +74,3 @@ MappedFile& MappedFile::operator=(MappedFile&& other) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -30,4 +30,3 @@ private: | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| using AK::MappedFile; | using AK::MappedFile; | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -18,7 +18,8 @@ template<typename T> | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| template<typename T> | template<typename T> | ||||||
| class [[gnu::packed]] NetworkOrdered { | class [[gnu::packed]] NetworkOrdered | ||||||
|  | { | ||||||
| public: | public: | ||||||
|     NetworkOrdered() |     NetworkOrdered() | ||||||
|         : m_network_value(0) |         : m_network_value(0) | ||||||
|  |  | ||||||
							
								
								
									
										24
									
								
								AK/OwnPtr.h
									
										
									
									
									
								
							
							
						
						
									
										24
									
								
								AK/OwnPtr.h
									
										
									
									
									
								
							|  | @ -1,8 +1,8 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include "StdLibExtras.h" | #include "StdLibExtras.h" | ||||||
| #include "Types.h" |  | ||||||
| #include "Traits.h" | #include "Traits.h" | ||||||
|  | #include "Types.h" | ||||||
| 
 | 
 | ||||||
| namespace AK { | namespace AK { | ||||||
| 
 | 
 | ||||||
|  | @ -10,9 +10,19 @@ template<typename T> | ||||||
| class OwnPtr { | class OwnPtr { | ||||||
| public: | public: | ||||||
|     OwnPtr() {} |     OwnPtr() {} | ||||||
|     explicit OwnPtr(T* ptr) : m_ptr(ptr) { } |     explicit OwnPtr(T* ptr) | ||||||
|     OwnPtr(OwnPtr&& other) : m_ptr(other.leak_ptr()) { } |         : m_ptr(ptr) | ||||||
|     template<typename U> OwnPtr(OwnPtr<U>&& other) : m_ptr(static_cast<T*>(other.leak_ptr())) { } |     { | ||||||
|  |     } | ||||||
|  |     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(std::nullptr_t) {}; | ||||||
|     ~OwnPtr() |     ~OwnPtr() | ||||||
|     { |     { | ||||||
|  | @ -91,7 +101,8 @@ private: | ||||||
|     T* m_ptr = nullptr; |     T* m_ptr = nullptr; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| template<class T, class... Args> inline OwnPtr<T> | template<class T, class... Args> | ||||||
|  | inline OwnPtr<T> | ||||||
| make(Args&&... args) | make(Args&&... args) | ||||||
| { | { | ||||||
|     return OwnPtr<T>(new T(AK::forward<Args>(args)...)); |     return OwnPtr<T>(new T(AK::forward<Args>(args)...)); | ||||||
|  | @ -105,6 +116,5 @@ struct Traits<OwnPtr<T>> { | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| using AK::OwnPtr; |  | ||||||
| using AK::make; | using AK::make; | ||||||
| 
 | using AK::OwnPtr; | ||||||
|  |  | ||||||
|  | @ -1,27 +1,69 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <AK/Types.h> |  | ||||||
| #include <AK/Retained.h> | #include <AK/Retained.h> | ||||||
|  | #include <AK/Types.h> | ||||||
| 
 | 
 | ||||||
| namespace AK { | namespace AK { | ||||||
| 
 | 
 | ||||||
| template<typename T> | template<typename T> | ||||||
| class RetainPtr { | class RetainPtr { | ||||||
| public: | public: | ||||||
|     enum AdoptTag { Adopt }; |     enum AdoptTag { | ||||||
|  |         Adopt | ||||||
|  |     }; | ||||||
| 
 | 
 | ||||||
|     RetainPtr() {} |     RetainPtr() {} | ||||||
|     RetainPtr(const T* ptr) : m_ptr(const_cast<T*>(ptr)) { retain_if_not_null(m_ptr); } |     RetainPtr(const T* ptr) | ||||||
|     RetainPtr(T* ptr) : m_ptr(ptr) { retain_if_not_null(m_ptr); } |         : m_ptr(const_cast<T*>(ptr)) | ||||||
|     RetainPtr(T& object) : m_ptr(&object) { m_ptr->retain(); } |     { | ||||||
|     RetainPtr(const T& object) : m_ptr(const_cast<T*>(&object)) { m_ptr->retain(); } |         retain_if_not_null(m_ptr); | ||||||
|     RetainPtr(AdoptTag, T& object) : m_ptr(&object) { } |     } | ||||||
|     RetainPtr(RetainPtr& other) : m_ptr(other.copy_ref().leak_ref()) { } |     RetainPtr(T* ptr) | ||||||
|     RetainPtr(RetainPtr&& other) : m_ptr(other.leak_ref()) { } |         : m_ptr(ptr) | ||||||
|     template<typename U> RetainPtr(Retained<U>&& other) : m_ptr(static_cast<T*>(&other.leak_ref())) { } |     { | ||||||
|     template<typename U> RetainPtr(RetainPtr<U>&& other) : m_ptr(static_cast<T*>(other.leak_ref())) { } |         retain_if_not_null(m_ptr); | ||||||
|     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(T& object) | ||||||
|  |         : m_ptr(&object) | ||||||
|  |     { | ||||||
|  |         m_ptr->retain(); | ||||||
|  |     } | ||||||
|  |     RetainPtr(const T& object) | ||||||
|  |         : m_ptr(const_cast<T*>(&object)) | ||||||
|  |     { | ||||||
|  |         m_ptr->retain(); | ||||||
|  |     } | ||||||
|  |     RetainPtr(AdoptTag, T& object) | ||||||
|  |         : m_ptr(&object) | ||||||
|  |     { | ||||||
|  |     } | ||||||
|  |     RetainPtr(RetainPtr& other) | ||||||
|  |         : m_ptr(other.copy_ref().leak_ref()) | ||||||
|  |     { | ||||||
|  |     } | ||||||
|  |     RetainPtr(RetainPtr&& other) | ||||||
|  |         : m_ptr(other.leak_ref()) | ||||||
|  |     { | ||||||
|  |     } | ||||||
|  |     template<typename U> | ||||||
|  |     RetainPtr(Retained<U>&& other) | ||||||
|  |         : m_ptr(static_cast<T*>(&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() |     ~RetainPtr() | ||||||
|     { |     { | ||||||
|         clear(); |         clear(); | ||||||
|  | @ -143,4 +185,3 @@ private: | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| using AK::RetainPtr; | using AK::RetainPtr; | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -76,4 +76,3 @@ public: | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| using AK::Retainable; | using AK::Retainable; | ||||||
| 
 |  | ||||||
|  |  | ||||||
							
								
								
									
										137
									
								
								AK/Retained.h
									
										
									
									
									
								
							
							
						
						
									
										137
									
								
								AK/Retained.h
									
										
									
									
									
								
							|  | @ -34,17 +34,61 @@ inline void release_if_not_null(T* ptr) | ||||||
| template<typename T> | template<typename T> | ||||||
| class CONSUMABLE(unconsumed) Retained { | class CONSUMABLE(unconsumed) Retained { | ||||||
| public: | public: | ||||||
|     enum AdoptTag { Adopt }; |     enum AdoptTag { | ||||||
|  |         Adopt | ||||||
|  |     }; | ||||||
| 
 | 
 | ||||||
|     RETURN_TYPESTATE(unconsumed) Retained(const T& object) : m_ptr(const_cast<T*>(&object)) { m_ptr->retain(); } |     RETURN_TYPESTATE(unconsumed) | ||||||
|     RETURN_TYPESTATE(unconsumed) Retained(T& object) : m_ptr(&object) { m_ptr->retain(); } |     Retained(const T& object) | ||||||
|     template<typename U> RETURN_TYPESTATE(unconsumed) Retained(U& object) : m_ptr(&static_cast<T&>(object)) { m_ptr->retain(); } |         : m_ptr(const_cast<T*>(&object)) | ||||||
|     RETURN_TYPESTATE(unconsumed) Retained(AdoptTag, T& object) : m_ptr(&object) { } |     { | ||||||
|     RETURN_TYPESTATE(unconsumed) Retained(Retained& other) : m_ptr(&other.copy_ref().leak_ref()) { } |         m_ptr->retain(); | ||||||
|     RETURN_TYPESTATE(unconsumed) Retained(Retained&& other) : m_ptr(&other.leak_ref()) { } |     } | ||||||
|     template<typename U> RETURN_TYPESTATE(unconsumed) Retained(Retained<U>&& other) : m_ptr(static_cast<T*>(&other.leak_ref())) { } |     RETURN_TYPESTATE(unconsumed) | ||||||
|     RETURN_TYPESTATE(unconsumed) Retained(const Retained& other) : m_ptr(&const_cast<Retained&>(other).copy_ref().leak_ref()) { } |     Retained(T& object) | ||||||
|     template<typename U> RETURN_TYPESTATE(unconsumed) Retained(const Retained<U>& other) : m_ptr(&const_cast<Retained<U>&>(other).copy_ref().leak_ref()) { } |         : m_ptr(&object) | ||||||
|  |     { | ||||||
|  |         m_ptr->retain(); | ||||||
|  |     } | ||||||
|  |     template<typename U> | ||||||
|  |     RETURN_TYPESTATE(unconsumed) | ||||||
|  |     Retained(U& object) | ||||||
|  |         : m_ptr(&static_cast<T&>(object)) | ||||||
|  |     { | ||||||
|  |         m_ptr->retain(); | ||||||
|  |     } | ||||||
|  |     RETURN_TYPESTATE(unconsumed) | ||||||
|  |     Retained(AdoptTag, T& object) | ||||||
|  |         : m_ptr(&object) | ||||||
|  |     { | ||||||
|  |     } | ||||||
|  |     RETURN_TYPESTATE(unconsumed) | ||||||
|  |     Retained(Retained& other) | ||||||
|  |         : m_ptr(&other.copy_ref().leak_ref()) | ||||||
|  |     { | ||||||
|  |     } | ||||||
|  |     RETURN_TYPESTATE(unconsumed) | ||||||
|  |     Retained(Retained&& other) | ||||||
|  |         : m_ptr(&other.leak_ref()) | ||||||
|  |     { | ||||||
|  |     } | ||||||
|  |     template<typename U> | ||||||
|  |     RETURN_TYPESTATE(unconsumed) | ||||||
|  |     Retained(Retained<U>&& other) | ||||||
|  |         : m_ptr(static_cast<T*>(&other.leak_ref())) | ||||||
|  |     { | ||||||
|  |     } | ||||||
|  |     RETURN_TYPESTATE(unconsumed) | ||||||
|  |     Retained(const Retained& other) | ||||||
|  |         : m_ptr(&const_cast<Retained&>(other).copy_ref().leak_ref()) | ||||||
|  |     { | ||||||
|  |     } | ||||||
|  |     template<typename U> | ||||||
|  |     RETURN_TYPESTATE(unconsumed) | ||||||
|  |     Retained(const Retained<U>& other) | ||||||
|  |         : m_ptr(&const_cast<Retained<U>&>(other).copy_ref().leak_ref()) | ||||||
|  |     { | ||||||
|  |     } | ||||||
|     ~Retained() |     ~Retained() | ||||||
|     { |     { | ||||||
|         release_if_not_null(m_ptr); |         release_if_not_null(m_ptr); | ||||||
|  | @ -57,7 +101,8 @@ public: | ||||||
| #endif | #endif | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     CALLABLE_WHEN(unconsumed) Retained& operator=(Retained&& other) |     CALLABLE_WHEN(unconsumed) | ||||||
|  |     Retained& operator=(Retained&& other) | ||||||
|     { |     { | ||||||
|         if (this != &other) { |         if (this != &other) { | ||||||
|             release_if_not_null(m_ptr); |             release_if_not_null(m_ptr); | ||||||
|  | @ -67,7 +112,8 @@ public: | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     template<typename U> |     template<typename U> | ||||||
|     CALLABLE_WHEN(unconsumed) Retained& operator=(Retained<U>&& other) |     CALLABLE_WHEN(unconsumed) | ||||||
|  |     Retained& operator=(Retained<U>&& other) | ||||||
|     { |     { | ||||||
|         if (this != static_cast<void*>(&other)) { |         if (this != static_cast<void*>(&other)) { | ||||||
|             release_if_not_null(m_ptr); |             release_if_not_null(m_ptr); | ||||||
|  | @ -76,7 +122,8 @@ public: | ||||||
|         return *this; |         return *this; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     CALLABLE_WHEN(unconsumed) Retained& operator=(T& object) |     CALLABLE_WHEN(unconsumed) | ||||||
|  |     Retained& operator=(T& object) | ||||||
|     { |     { | ||||||
|         if (m_ptr != &object) |         if (m_ptr != &object) | ||||||
|             release_if_not_null(m_ptr); |             release_if_not_null(m_ptr); | ||||||
|  | @ -85,12 +132,14 @@ public: | ||||||
|         return *this; |         return *this; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     CALLABLE_WHEN(unconsumed) Retained copy_ref() const |     CALLABLE_WHEN(unconsumed) | ||||||
|  |     Retained copy_ref() const | ||||||
|     { |     { | ||||||
|         return Retained(*m_ptr); |         return Retained(*m_ptr); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     CALLABLE_WHEN(unconsumed) SET_TYPESTATE(consumed) |     CALLABLE_WHEN(unconsumed) | ||||||
|  |     SET_TYPESTATE(consumed) | ||||||
|     T& leak_ref() |     T& leak_ref() | ||||||
|     { |     { | ||||||
|         ASSERT(m_ptr); |         ASSERT(m_ptr); | ||||||
|  | @ -99,17 +148,57 @@ public: | ||||||
|         return *leakedPtr; |         return *leakedPtr; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     CALLABLE_WHEN(unconsumed) T* ptr() { ASSERT(m_ptr); return m_ptr; } |     CALLABLE_WHEN(unconsumed) | ||||||
|     CALLABLE_WHEN(unconsumed) const T* ptr() const { ASSERT(m_ptr); return m_ptr; } |     T* ptr() | ||||||
|  |     { | ||||||
|  |         ASSERT(m_ptr); | ||||||
|  |         return m_ptr; | ||||||
|  |     } | ||||||
|  |     CALLABLE_WHEN(unconsumed) | ||||||
|  |     const T* ptr() const | ||||||
|  |     { | ||||||
|  |         ASSERT(m_ptr); | ||||||
|  |         return m_ptr; | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     CALLABLE_WHEN(unconsumed) T* operator->() { ASSERT(m_ptr); return m_ptr; } |     CALLABLE_WHEN(unconsumed) | ||||||
|     CALLABLE_WHEN(unconsumed) const T* operator->() const { ASSERT(m_ptr); return m_ptr; } |     T* operator->() | ||||||
|  |     { | ||||||
|  |         ASSERT(m_ptr); | ||||||
|  |         return m_ptr; | ||||||
|  |     } | ||||||
|  |     CALLABLE_WHEN(unconsumed) | ||||||
|  |     const T* operator->() const | ||||||
|  |     { | ||||||
|  |         ASSERT(m_ptr); | ||||||
|  |         return m_ptr; | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     CALLABLE_WHEN(unconsumed) T& operator*() { ASSERT(m_ptr); return *m_ptr; } |     CALLABLE_WHEN(unconsumed) | ||||||
|     CALLABLE_WHEN(unconsumed) const T& operator*() const { ASSERT(m_ptr); return *m_ptr; } |     T& operator*() | ||||||
|  |     { | ||||||
|  |         ASSERT(m_ptr); | ||||||
|  |         return *m_ptr; | ||||||
|  |     } | ||||||
|  |     CALLABLE_WHEN(unconsumed) | ||||||
|  |     const T& operator*() const | ||||||
|  |     { | ||||||
|  |         ASSERT(m_ptr); | ||||||
|  |         return *m_ptr; | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     CALLABLE_WHEN(unconsumed) operator T*() { ASSERT(m_ptr); return m_ptr; } |     CALLABLE_WHEN(unconsumed) | ||||||
|     CALLABLE_WHEN(unconsumed) operator const T*() const { ASSERT(m_ptr); return m_ptr; } |     operator T*() | ||||||
|  |     { | ||||||
|  |         ASSERT(m_ptr); | ||||||
|  |         return m_ptr; | ||||||
|  |     } | ||||||
|  |     CALLABLE_WHEN(unconsumed) | ||||||
|  |     operator const T*() const | ||||||
|  |     { | ||||||
|  |         ASSERT(m_ptr); | ||||||
|  |         return m_ptr; | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     Retained() {} |     Retained() {} | ||||||
|  | @ -125,5 +214,5 @@ inline Retained<T> adopt(T& object) | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| using AK::Retained; |  | ||||||
| using AK::adopt; | using AK::adopt; | ||||||
|  | using AK::Retained; | ||||||
|  |  | ||||||
|  | @ -8,7 +8,10 @@ template<typename T> | ||||||
| class SinglyLinkedList { | class SinglyLinkedList { | ||||||
| private: | private: | ||||||
|     struct Node { |     struct Node { | ||||||
|         explicit Node(T&& v) : value(v) { } |         explicit Node(T&& v) | ||||||
|  |             : value(v) | ||||||
|  |         { | ||||||
|  |         } | ||||||
|         T value; |         T value; | ||||||
|         Node* next { nullptr }; |         Node* next { nullptr }; | ||||||
|     }; |     }; | ||||||
|  | @ -38,10 +41,26 @@ public: | ||||||
|         m_tail = nullptr; |         m_tail = nullptr; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     T& first() { ASSERT(head()); return head()->value; } |     T& first() | ||||||
|     const T& first() const { ASSERT(head()); return head()->value; } |     { | ||||||
|     T& last() { ASSERT(head()); return tail()->value; } |         ASSERT(head()); | ||||||
|     const T& last() const { ASSERT(head()); return tail()->value; } |         return head()->value; | ||||||
|  |     } | ||||||
|  |     const T& first() const | ||||||
|  |     { | ||||||
|  |         ASSERT(head()); | ||||||
|  |         return head()->value; | ||||||
|  |     } | ||||||
|  |     T& last() | ||||||
|  |     { | ||||||
|  |         ASSERT(head()); | ||||||
|  |         return tail()->value; | ||||||
|  |     } | ||||||
|  |     const T& last() const | ||||||
|  |     { | ||||||
|  |         ASSERT(head()); | ||||||
|  |         return tail()->value; | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     T take_first() |     T take_first() | ||||||
|     { |     { | ||||||
|  | @ -79,13 +98,21 @@ public: | ||||||
|     class Iterator { |     class Iterator { | ||||||
|     public: |     public: | ||||||
|         bool operator!=(const Iterator& other) { return m_node != other.m_node; } |         bool operator!=(const Iterator& other) { return m_node != other.m_node; } | ||||||
|         Iterator& operator++() { m_node = m_node->next; return *this; } |         Iterator& operator++() | ||||||
|  |         { | ||||||
|  |             m_node = m_node->next; | ||||||
|  |             return *this; | ||||||
|  |         } | ||||||
|         T& operator*() { return m_node->value; } |         T& operator*() { return m_node->value; } | ||||||
|         bool is_end() const { return !m_node; } |         bool is_end() const { return !m_node; } | ||||||
|         static Iterator universal_end() { return Iterator(nullptr); } |         static Iterator universal_end() { return Iterator(nullptr); } | ||||||
|  | 
 | ||||||
|     private: |     private: | ||||||
|         friend class SinglyLinkedList; |         friend class SinglyLinkedList; | ||||||
|         explicit Iterator(SinglyLinkedList::Node* node) : m_node(node) { } |         explicit Iterator(SinglyLinkedList::Node* node) | ||||||
|  |             : m_node(node) | ||||||
|  |         { | ||||||
|  |         } | ||||||
|         SinglyLinkedList::Node* m_node; |         SinglyLinkedList::Node* m_node; | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|  | @ -95,13 +122,21 @@ public: | ||||||
|     class ConstIterator { |     class ConstIterator { | ||||||
|     public: |     public: | ||||||
|         bool operator!=(const ConstIterator& other) { return m_node != other.m_node; } |         bool operator!=(const ConstIterator& other) { return m_node != other.m_node; } | ||||||
|         ConstIterator& operator++() { m_node = m_node->next; return *this; } |         ConstIterator& operator++() | ||||||
|  |         { | ||||||
|  |             m_node = m_node->next; | ||||||
|  |             return *this; | ||||||
|  |         } | ||||||
|         const T& operator*() const { return m_node->value; } |         const T& operator*() const { return m_node->value; } | ||||||
|         bool is_end() const { return !m_node; } |         bool is_end() const { return !m_node; } | ||||||
|         static ConstIterator universal_end() { return ConstIterator(nullptr); } |         static ConstIterator universal_end() { return ConstIterator(nullptr); } | ||||||
|  | 
 | ||||||
|     private: |     private: | ||||||
|         friend class SinglyLinkedList; |         friend class SinglyLinkedList; | ||||||
|         explicit ConstIterator(const SinglyLinkedList::Node* node) : m_node(node) { } |         explicit ConstIterator(const SinglyLinkedList::Node* node) | ||||||
|  |             : m_node(node) | ||||||
|  |         { | ||||||
|  |         } | ||||||
|         const SinglyLinkedList::Node* m_node; |         const SinglyLinkedList::Node* m_node; | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|  | @ -142,4 +177,3 @@ private: | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| using AK::SinglyLinkedList; | using AK::SinglyLinkedList; | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -1,5 +1,5 @@ | ||||||
| #include <AK/StdLibExtras.h> |  | ||||||
| #include <AK/Assertions.h> | #include <AK/Assertions.h> | ||||||
|  | #include <AK/StdLibExtras.h> | ||||||
| #include <AK/Types.h> | #include <AK/Types.h> | ||||||
| #include <AK/kstdio.h> | #include <AK/kstdio.h> | ||||||
| 
 | 
 | ||||||
|  | @ -20,8 +20,7 @@ void* mmx_memcpy(void* dest, const void* src, size_t len) | ||||||
|             "rep movsb\n" |             "rep movsb\n" | ||||||
|             : "=S"(src_ptr), "=D"(dest_ptr), "=c"(prologue) |             : "=S"(src_ptr), "=D"(dest_ptr), "=c"(prologue) | ||||||
|             : "0"(src_ptr), "1"(dest_ptr), "2"(prologue) |             : "0"(src_ptr), "1"(dest_ptr), "2"(prologue) | ||||||
|             : "memory" |             : "memory"); | ||||||
|         ); |  | ||||||
|     } |     } | ||||||
|     for (dword i = len / 64; i; --i) { |     for (dword i = len / 64; i; --i) { | ||||||
|         asm volatile( |         asm volatile( | ||||||
|  | @ -40,12 +39,14 @@ void* mmx_memcpy(void* dest, const void* src, size_t len) | ||||||
|             "movq %%mm4, 32(%1)\n" |             "movq %%mm4, 32(%1)\n" | ||||||
|             "movq %%mm5, 40(%1)\n" |             "movq %%mm5, 40(%1)\n" | ||||||
|             "movq %%mm6, 48(%1)\n" |             "movq %%mm6, 48(%1)\n" | ||||||
|                     "movq %%mm7, 56(%1)\n" |             "movq %%mm7, 56(%1)\n" ::"r"(src_ptr), | ||||||
|                     :: "r" (src_ptr), "r" (dest_ptr) : "memory"); |             "r"(dest_ptr) | ||||||
|  |             : "memory"); | ||||||
|         src_ptr += 64; |         src_ptr += 64; | ||||||
|         dest_ptr += 64; |         dest_ptr += 64; | ||||||
|     } |     } | ||||||
|     asm volatile("emms":::"memory"); |     asm volatile("emms" :: | ||||||
|  |                      : "memory"); | ||||||
|     // Whatever remains we'll have to memcpy.
 |     // Whatever remains we'll have to memcpy.
 | ||||||
|     len %= 64; |     len %= 64; | ||||||
|     if (len) |     if (len) | ||||||
|  | @ -62,7 +63,9 @@ static inline uint32_t divq(uint64_t n, uint32_t d) | ||||||
|     uint32_t n0 = n; |     uint32_t n0 = n; | ||||||
|     uint32_t q; |     uint32_t q; | ||||||
|     uint32_t r; |     uint32_t r; | ||||||
|     asm volatile("divl %4" : "=d"(r), "=a"(q) : "0"(n1), "1"(n0), "rm"(d)); |     asm volatile("divl %4" | ||||||
|  |                  : "=d"(r), "=a"(q) | ||||||
|  |                  : "0"(n1), "1"(n0), "rm"(d)); | ||||||
|     return q; |     return q; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -149,5 +152,4 @@ uint64_t __udivmoddi4(uint64_t n, uint64_t d, uint64_t* r) | ||||||
|     return q; |     return q; | ||||||
| } | } | ||||||
| #endif | #endif | ||||||
| 
 |  | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -27,8 +27,7 @@ extern "C" void* mmx_memcpy(void* to, const void* from, size_t); | ||||||
|         "rep movsl\n" |         "rep movsl\n" | ||||||
|         : "=S"(src), "=D"(dest), "=c"(count) |         : "=S"(src), "=D"(dest), "=c"(count) | ||||||
|         : "S"(src), "D"(dest), "c"(count) |         : "S"(src), "D"(dest), "c"(count) | ||||||
|         : "memory" |         : "memory"); | ||||||
|     ); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| [[gnu::always_inline]] inline void fast_dword_fill(dword* dest, dword value, size_t count) | [[gnu::always_inline]] inline void fast_dword_fill(dword* dest, dword value, size_t count) | ||||||
|  | @ -37,8 +36,7 @@ extern "C" void* mmx_memcpy(void* to, const void* from, size_t); | ||||||
|         "rep stosl\n" |         "rep stosl\n" | ||||||
|         : "=D"(dest), "=c"(count) |         : "=D"(dest), "=c"(count) | ||||||
|         : "D"(dest), "c"(count), "a"(value) |         : "D"(dest), "c"(count), "a"(value) | ||||||
|         : "memory" |         : "memory"); | ||||||
|     ); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| inline constexpr dword round_up_to_power_of_two(dword value, dword power_of_two) | inline constexpr dword round_up_to_power_of_two(dword value, dword power_of_two) | ||||||
|  | @ -60,7 +58,6 @@ inline T max(const T& a, const T& b) | ||||||
|     return a < b ? b : a; |     return a < b ? b : a; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| template<typename T, typename U> | template<typename T, typename U> | ||||||
| static inline T ceil_div(T a, U b) | static inline T ceil_div(T a, U b) | ||||||
| { | { | ||||||
|  | @ -112,21 +109,32 @@ void swap(T& a, U& b) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| template<bool B, class T = void> | template<bool B, class T = void> | ||||||
| struct EnableIf | struct EnableIf { | ||||||
| { |  | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| template<class T> | template<class T> | ||||||
| struct EnableIf<true, T> | struct EnableIf<true, T> { | ||||||
| { |  | ||||||
|     typedef T Type; |     typedef T Type; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| template<class T> struct RemoveConst { typedef T Type; }; | template<class T> | ||||||
| template<class T> struct RemoveConst<const T> { typedef T Type; }; | struct RemoveConst { | ||||||
| template<class T> struct RemoveVolatile { typedef T Type; }; |     typedef T Type; | ||||||
| template<class T> struct RemoveVolatile<const T> { typedef T Type; }; | }; | ||||||
| template<class T> struct RemoveCV { | template<class T> | ||||||
|  | struct RemoveConst<const T> { | ||||||
|  |     typedef T Type; | ||||||
|  | }; | ||||||
|  | template<class T> | ||||||
|  | struct RemoveVolatile { | ||||||
|  |     typedef T Type; | ||||||
|  | }; | ||||||
|  | template<class T> | ||||||
|  | struct RemoveVolatile<const T> { | ||||||
|  |     typedef T Type; | ||||||
|  | }; | ||||||
|  | template<class T> | ||||||
|  | struct RemoveCV { | ||||||
|     typedef typename RemoveVolatile<typename RemoveConst<T>::Type>::Type Type; |     typedef typename RemoveVolatile<typename RemoveConst<T>::Type>::Type Type; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | @ -143,69 +151,145 @@ typedef IntegralConstant<bool, false> FalseType; | ||||||
| typedef IntegralConstant<bool, true> TrueType; | typedef IntegralConstant<bool, true> TrueType; | ||||||
| 
 | 
 | ||||||
| template<class T> | template<class T> | ||||||
| struct __IsPointerHelper : FalseType { }; | struct __IsPointerHelper : FalseType { | ||||||
|  | }; | ||||||
| 
 | 
 | ||||||
| template<class T> | template<class T> | ||||||
| struct __IsPointerHelper<T*> : TrueType { }; | struct __IsPointerHelper<T*> : TrueType { | ||||||
|  | }; | ||||||
| 
 | 
 | ||||||
| template<class T> | template<class T> | ||||||
| struct IsPointer : __IsPointerHelper<typename RemoveCV<T>::Type> { }; | struct IsPointer : __IsPointerHelper<typename RemoveCV<T>::Type> { | ||||||
|  | }; | ||||||
| 
 | 
 | ||||||
| template<class> struct IsFunction : FalseType { }; | template<class> | ||||||
|  | struct IsFunction : FalseType { | ||||||
|  | }; | ||||||
| 
 | 
 | ||||||
| template<class Ret, class... Args> struct IsFunction<Ret(Args...)> : TrueType { }; | template<class Ret, class... Args> | ||||||
| template<class Ret, class... Args> struct IsFunction<Ret(Args...,...)> : TrueType { }; | struct IsFunction<Ret(Args...)> : TrueType { | ||||||
| template<class Ret, class... Args> struct IsFunction<Ret(Args...) const> : TrueType { }; | }; | ||||||
| template<class Ret, class... Args> struct IsFunction<Ret(Args...,...) const> : TrueType { }; | template<class Ret, class... Args> | ||||||
| template<class Ret, class... Args> struct IsFunction<Ret(Args...) volatile> : TrueType { }; | struct IsFunction<Ret(Args..., ...)> : TrueType { | ||||||
| template<class Ret, class... Args> struct IsFunction<Ret(Args...,...) volatile> : TrueType { }; | }; | ||||||
| template<class Ret, class... Args> struct IsFunction<Ret(Args...) const volatile> : TrueType { }; | template<class Ret, class... Args> | ||||||
| template<class Ret, class... Args> struct IsFunction<Ret(Args...,...) const volatile> : TrueType { }; | struct IsFunction<Ret(Args...) const> : TrueType { | ||||||
|  | }; | ||||||
|  | template<class Ret, class... Args> | ||||||
|  | struct IsFunction<Ret(Args..., ...) const> : TrueType { | ||||||
|  | }; | ||||||
|  | template<class Ret, class... Args> | ||||||
|  | struct IsFunction<Ret(Args...) volatile> : TrueType { | ||||||
|  | }; | ||||||
|  | template<class Ret, class... Args> | ||||||
|  | struct IsFunction<Ret(Args..., ...) volatile> : TrueType { | ||||||
|  | }; | ||||||
|  | template<class Ret, class... Args> | ||||||
|  | struct IsFunction<Ret(Args...) const volatile> : TrueType { | ||||||
|  | }; | ||||||
|  | template<class Ret, class... Args> | ||||||
|  | struct IsFunction<Ret(Args..., ...) const volatile> : TrueType { | ||||||
|  | }; | ||||||
| 
 | 
 | ||||||
| template<class Ret, class... Args> struct IsFunction<Ret(Args...) &> : TrueType { }; | template<class Ret, class... Args> | ||||||
| template<class Ret, class... Args> struct IsFunction<Ret(Args...,...) &> : TrueType { }; | struct IsFunction<Ret(Args...)&> : TrueType { | ||||||
| template<class Ret, class... Args> struct IsFunction<Ret(Args...) const &> : TrueType { }; | }; | ||||||
| template<class Ret, class... Args> struct IsFunction<Ret(Args...,...) const &> : TrueType { }; | template<class Ret, class... Args> | ||||||
| template<class Ret, class... Args> struct IsFunction<Ret(Args...) volatile &> : TrueType { }; | struct IsFunction<Ret(Args..., ...)&> : TrueType { | ||||||
| template<class Ret, class... Args> struct IsFunction<Ret(Args...,...) volatile &> : TrueType { }; | }; | ||||||
| template<class Ret, class... Args> struct IsFunction<Ret(Args...) const volatile &> : TrueType { }; | template<class Ret, class... Args> | ||||||
| template<class Ret, class... Args> struct IsFunction<Ret(Args...,...) const volatile &> : TrueType { }; | struct IsFunction<Ret(Args...) const&> : TrueType { | ||||||
|  | }; | ||||||
|  | template<class Ret, class... Args> | ||||||
|  | struct IsFunction<Ret(Args..., ...) const&> : TrueType { | ||||||
|  | }; | ||||||
|  | template<class Ret, class... Args> | ||||||
|  | struct IsFunction<Ret(Args...) volatile&> : TrueType { | ||||||
|  | }; | ||||||
|  | template<class Ret, class... Args> | ||||||
|  | struct IsFunction<Ret(Args..., ...) volatile&> : TrueType { | ||||||
|  | }; | ||||||
|  | template<class Ret, class... Args> | ||||||
|  | struct IsFunction<Ret(Args...) const volatile&> : TrueType { | ||||||
|  | }; | ||||||
|  | template<class Ret, class... Args> | ||||||
|  | struct IsFunction<Ret(Args..., ...) const volatile&> : TrueType { | ||||||
|  | }; | ||||||
| 
 | 
 | ||||||
| template<class Ret, class... Args> struct IsFunction<Ret(Args...) &&> : TrueType { }; | template<class Ret, class... Args> | ||||||
| template<class Ret, class... Args> struct IsFunction<Ret(Args...,...) &&> : TrueType { }; | struct IsFunction<Ret(Args...) &&> : TrueType { | ||||||
| template<class Ret, class... Args> struct IsFunction<Ret(Args...) const &&> : TrueType { }; | }; | ||||||
| template<class Ret, class... Args> struct IsFunction<Ret(Args...,...) const &&> : TrueType { }; | template<class Ret, class... Args> | ||||||
| template<class Ret, class... Args> struct IsFunction<Ret(Args...) volatile &&> : TrueType { }; | struct IsFunction<Ret(Args..., ...) &&> : TrueType { | ||||||
| template<class Ret, class... Args> struct IsFunction<Ret(Args...,...) volatile &&> : TrueType { }; | }; | ||||||
| template<class Ret, class... Args> struct IsFunction<Ret(Args...) const volatile &&> : TrueType { }; | template<class Ret, class... Args> | ||||||
| template<class Ret, class... Args> struct IsFunction<Ret(Args...,...) const volatile &&> : TrueType { }; | struct IsFunction<Ret(Args...) const&&> : TrueType { | ||||||
|  | }; | ||||||
|  | template<class Ret, class... Args> | ||||||
|  | struct IsFunction<Ret(Args..., ...) const&&> : TrueType { | ||||||
|  | }; | ||||||
|  | template<class Ret, class... Args> | ||||||
|  | struct IsFunction<Ret(Args...) volatile&&> : TrueType { | ||||||
|  | }; | ||||||
|  | template<class Ret, class... Args> | ||||||
|  | struct IsFunction<Ret(Args..., ...) volatile&&> : TrueType { | ||||||
|  | }; | ||||||
|  | template<class Ret, class... Args> | ||||||
|  | struct IsFunction<Ret(Args...) const volatile&&> : TrueType { | ||||||
|  | }; | ||||||
|  | template<class Ret, class... Args> | ||||||
|  | struct IsFunction<Ret(Args..., ...) const volatile&&> : TrueType { | ||||||
|  | }; | ||||||
| 
 | 
 | ||||||
| template<class T> struct IsRvalueReference : FalseType { }; | template<class T> | ||||||
| template<class T> struct IsRvalueReference<T&&> : TrueType { }; | struct IsRvalueReference : FalseType { | ||||||
|  | }; | ||||||
|  | template<class T> | ||||||
|  | struct IsRvalueReference<T&&> : TrueType { | ||||||
|  | }; | ||||||
| 
 | 
 | ||||||
| template<class T> struct RemovePointer { typedef T Type; }; | template<class T> | ||||||
| template<class T> struct RemovePointer<T*> { typedef T Type; }; | struct RemovePointer { | ||||||
| template<class T> struct RemovePointer<T* const> { typedef T Type; }; |     typedef T Type; | ||||||
| template<class T> struct RemovePointer<T* volatile> { typedef T Type; }; | }; | ||||||
| template<class T> struct RemovePointer<T* const volatile> { typedef T Type; }; | template<class T> | ||||||
|  | struct RemovePointer<T*> { | ||||||
|  |     typedef T Type; | ||||||
|  | }; | ||||||
|  | template<class T> | ||||||
|  | struct RemovePointer<T* const> { | ||||||
|  |     typedef T Type; | ||||||
|  | }; | ||||||
|  | template<class T> | ||||||
|  | struct RemovePointer<T* volatile> { | ||||||
|  |     typedef T Type; | ||||||
|  | }; | ||||||
|  | template<class T> | ||||||
|  | struct RemovePointer<T* const volatile> { | ||||||
|  |     typedef T Type; | ||||||
|  | }; | ||||||
| 
 | 
 | ||||||
| template<typename T, typename U> | template<typename T, typename U> | ||||||
| struct IsSame { | struct IsSame { | ||||||
|     enum { value = 0 }; |     enum { | ||||||
|  |         value = 0 | ||||||
|  |     }; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| template<typename T> | template<typename T> | ||||||
| struct IsSame<T, T> { | struct IsSame<T, T> { | ||||||
|     enum { value = 1 }; |     enum { | ||||||
|  |         value = 1 | ||||||
|  |     }; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| using AK::min; |  | ||||||
| using AK::max; |  | ||||||
| using AK::move; |  | ||||||
| using AK::forward; |  | ||||||
| using AK::exchange; |  | ||||||
| using AK::swap; |  | ||||||
| using AK::ceil_div; | using AK::ceil_div; | ||||||
|  | using AK::exchange; | ||||||
|  | using AK::forward; | ||||||
| using AK::IsSame; | using AK::IsSame; | ||||||
|  | using AK::max; | ||||||
|  | using AK::min; | ||||||
|  | using AK::move; | ||||||
|  | using AK::swap; | ||||||
|  |  | ||||||
|  | @ -1,7 +1,7 @@ | ||||||
| #include "StringBuilder.h" | #include "StringBuilder.h" | ||||||
| #include <LibC/stdarg.h> |  | ||||||
| #include "printf.cpp" | #include "printf.cpp" | ||||||
| #include <AK/StdLibExtras.h> | #include <AK/StdLibExtras.h> | ||||||
|  | #include <LibC/stdarg.h> | ||||||
| 
 | 
 | ||||||
| namespace AK { | namespace AK { | ||||||
| 
 | 
 | ||||||
|  | @ -45,7 +45,8 @@ void StringBuilder::appendvf(const char* fmt, va_list ap) | ||||||
| { | { | ||||||
|     printf_internal([this](char*&, char ch) { |     printf_internal([this](char*&, char ch) { | ||||||
|         append(ch); |         append(ch); | ||||||
|     }, nullptr, fmt, ap); |     }, | ||||||
|  |         nullptr, fmt, ap); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void StringBuilder::appendf(const char* fmt, ...) | void StringBuilder::appendf(const char* fmt, ...) | ||||||
|  | @ -71,4 +72,3 @@ String StringBuilder::to_string() | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -30,4 +30,3 @@ private: | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| using AK::StringBuilder; | using AK::StringBuilder; | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -1,7 +1,7 @@ | ||||||
| #include "StringImpl.h" | #include "StringImpl.h" | ||||||
|  | #include "HashTable.h" | ||||||
| #include "StdLibExtras.h" | #include "StdLibExtras.h" | ||||||
| #include "kmalloc.h" | #include "kmalloc.h" | ||||||
| #include "HashTable.h" |  | ||||||
| 
 | 
 | ||||||
| //#define DEBUG_STRINGIMPL
 | //#define DEBUG_STRINGIMPL
 | ||||||
| 
 | 
 | ||||||
|  | @ -26,7 +26,8 @@ static StringImpl* s_the_empty_stringimpl = nullptr; | ||||||
| StringImpl& StringImpl::the_empty_stringimpl() | StringImpl& StringImpl::the_empty_stringimpl() | ||||||
| { | { | ||||||
|     if (!s_the_empty_stringimpl) |     if (!s_the_empty_stringimpl) | ||||||
|         s_the_empty_stringimpl = new StringImpl(ConstructTheEmptyStringImpl);; |         s_the_empty_stringimpl = new StringImpl(ConstructTheEmptyStringImpl); | ||||||
|  |     ; | ||||||
|     return *s_the_empty_stringimpl; |     return *s_the_empty_stringimpl; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -168,4 +169,3 @@ void StringImpl::compute_hash() const | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -1,12 +1,15 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include "Retainable.h" |  | ||||||
| #include "RetainPtr.h" | #include "RetainPtr.h" | ||||||
|  | #include "Retainable.h" | ||||||
| #include "Types.h" | #include "Types.h" | ||||||
| 
 | 
 | ||||||
| namespace AK { | namespace AK { | ||||||
| 
 | 
 | ||||||
| enum ShouldChomp { NoChomp, Chomp }; | enum ShouldChomp { | ||||||
|  |     NoChomp, | ||||||
|  |     Chomp | ||||||
|  | }; | ||||||
| 
 | 
 | ||||||
| class StringImpl : public Retainable<StringImpl> { | class StringImpl : public Retainable<StringImpl> { | ||||||
| public: | public: | ||||||
|  | @ -22,7 +25,11 @@ public: | ||||||
| 
 | 
 | ||||||
|     ssize_t length() const { return m_length; } |     ssize_t length() const { return m_length; } | ||||||
|     const char* characters() const { return m_characters; } |     const char* characters() const { return m_characters; } | ||||||
|     char operator[](ssize_t i) const { ASSERT(i >= 0 && i < m_length); return m_characters[i]; } |     char operator[](ssize_t i) const | ||||||
|  |     { | ||||||
|  |         ASSERT(i >= 0 && i < m_length); | ||||||
|  |         return m_characters[i]; | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     unsigned hash() const |     unsigned hash() const | ||||||
|     { |     { | ||||||
|  | @ -32,10 +39,17 @@ public: | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     enum ConstructTheEmptyStringImplTag { ConstructTheEmptyStringImpl }; |     enum ConstructTheEmptyStringImplTag { | ||||||
|     explicit StringImpl(ConstructTheEmptyStringImplTag) : m_characters("") { } |         ConstructTheEmptyStringImpl | ||||||
|  |     }; | ||||||
|  |     explicit StringImpl(ConstructTheEmptyStringImplTag) | ||||||
|  |         : m_characters("") | ||||||
|  |     { | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     enum ConstructWithInlineBufferTag { ConstructWithInlineBuffer }; |     enum ConstructWithInlineBufferTag { | ||||||
|  |         ConstructWithInlineBuffer | ||||||
|  |     }; | ||||||
|     StringImpl(ConstructWithInlineBufferTag, ssize_t length); |     StringImpl(ConstructWithInlineBufferTag, ssize_t length); | ||||||
| 
 | 
 | ||||||
|     void compute_hash() const; |     void compute_hash() const; | ||||||
|  | @ -63,6 +77,6 @@ inline dword string_hash(const char* characters, int length) | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| using AK::StringImpl; |  | ||||||
| using AK::Chomp; | using AK::Chomp; | ||||||
| using AK::string_hash; | using AK::string_hash; | ||||||
|  | using AK::StringImpl; | ||||||
|  |  | ||||||
|  | @ -1,5 +1,5 @@ | ||||||
| #include <AK/StringView.h> |  | ||||||
| #include <AK/AKString.h> | #include <AK/AKString.h> | ||||||
|  | #include <AK/StringView.h> | ||||||
| 
 | 
 | ||||||
| namespace AK { | namespace AK { | ||||||
| 
 | 
 | ||||||
|  | @ -50,5 +50,4 @@ unsigned StringView::to_uint(bool& ok) const | ||||||
|     return value; |     return value; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -9,8 +9,16 @@ class String; | ||||||
| class StringView { | class StringView { | ||||||
| public: | public: | ||||||
|     StringView() {} |     StringView() {} | ||||||
|     StringView(const char* characters, int length) : m_characters(characters), m_length(length) { } |     StringView(const char* characters, int length) | ||||||
|     StringView(const unsigned char* characters, int length) : m_characters((const char*)characters), m_length(length) { } |         : m_characters(characters) | ||||||
|  |         , m_length(length) | ||||||
|  |     { | ||||||
|  |     } | ||||||
|  |     StringView(const unsigned char* characters, int length) | ||||||
|  |         : m_characters((const char*)characters) | ||||||
|  |         , m_length(length) | ||||||
|  |     { | ||||||
|  |     } | ||||||
|     StringView(const char* cstring) |     StringView(const char* cstring) | ||||||
|         : m_characters(cstring) |         : m_characters(cstring) | ||||||
|     { |     { | ||||||
|  |  | ||||||
|  | @ -5,7 +5,12 @@ namespace AK { | ||||||
| template<typename T> | template<typename T> | ||||||
| class TemporaryChange { | class TemporaryChange { | ||||||
| public: | public: | ||||||
|     TemporaryChange(T& variable, T value) : m_variable(variable), m_old_value(variable) { m_variable = value; } |     TemporaryChange(T& variable, T value) | ||||||
|  |         : m_variable(variable) | ||||||
|  |         , m_old_value(variable) | ||||||
|  |     { | ||||||
|  |         m_variable = value; | ||||||
|  |     } | ||||||
|     ~TemporaryChange() { m_variable = m_old_value; } |     ~TemporaryChange() { m_variable = m_old_value; } | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|  |  | ||||||
|  | @ -1,13 +1,12 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include "kstdio.h" |  | ||||||
| #include "HashFunctions.h" | #include "HashFunctions.h" | ||||||
|  | #include "kstdio.h" | ||||||
| 
 | 
 | ||||||
| namespace AK { | namespace AK { | ||||||
| 
 | 
 | ||||||
| template<typename T> | template<typename T> | ||||||
| struct Traits  | struct Traits { | ||||||
| { |  | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| template<> | template<> | ||||||
|  | @ -38,4 +37,3 @@ struct Traits<T*> { | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -48,9 +48,11 @@ constexpr unsigned KB = 1024; | ||||||
| constexpr unsigned MB = KB * KB; | constexpr unsigned MB = KB * KB; | ||||||
| constexpr unsigned GB = KB * KB * KB; | constexpr unsigned GB = KB * KB * KB; | ||||||
| 
 | 
 | ||||||
| enum class IterationDecision { Continue, Abort }; | enum class IterationDecision { | ||||||
|  |     Continue, | ||||||
|  |     Abort | ||||||
|  | }; | ||||||
| 
 | 
 | ||||||
| namespace std { | namespace std { | ||||||
| typedef decltype(nullptr) nullptr_t; | typedef decltype(nullptr) nullptr_t; | ||||||
| } | } | ||||||
| 
 |  | ||||||
|  |  | ||||||
							
								
								
									
										62
									
								
								AK/Vector.h
									
										
									
									
									
								
							
							
						
						
									
										62
									
								
								AK/Vector.h
									
										
									
									
									
								
							|  | @ -112,8 +112,16 @@ public: | ||||||
|         return m_outline_buffer; |         return m_outline_buffer; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     const T& at(int i) const { ASSERT(i >= 0 && i < m_size); return data()[i]; } |     const T& at(int i) const | ||||||
|     T& at(int i) { ASSERT(i >= 0 && i < m_size); return data()[i]; } |     { | ||||||
|  |         ASSERT(i >= 0 && i < m_size); | ||||||
|  |         return data()[i]; | ||||||
|  |     } | ||||||
|  |     T& at(int i) | ||||||
|  |     { | ||||||
|  |         ASSERT(i >= 0 && i < m_size); | ||||||
|  |         return data()[i]; | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     const T& operator[](int i) const { return at(i); } |     const T& operator[](int i) const { return at(i); } | ||||||
|     T& operator[](int i) { return at(i); } |     T& operator[](int i) { return at(i); } | ||||||
|  | @ -314,8 +322,16 @@ public: | ||||||
|         bool operator<(const Iterator& other) { return m_index < other.m_index; } |         bool operator<(const Iterator& other) { return m_index < other.m_index; } | ||||||
|         bool operator>(const Iterator& other) { return m_index > other.m_index; } |         bool operator>(const Iterator& other) { return m_index > other.m_index; } | ||||||
|         bool operator>=(const Iterator& other) { return m_index >= other.m_index; } |         bool operator>=(const Iterator& other) { return m_index >= other.m_index; } | ||||||
|         Iterator& operator++() { ++m_index; return *this; } |         Iterator& operator++() | ||||||
|         Iterator& operator--() { --m_index; return *this; } |         { | ||||||
|  |             ++m_index; | ||||||
|  |             return *this; | ||||||
|  |         } | ||||||
|  |         Iterator& operator--() | ||||||
|  |         { | ||||||
|  |             --m_index; | ||||||
|  |             return *this; | ||||||
|  |         } | ||||||
|         Iterator operator-(int value) { return { m_vector, m_index - value }; } |         Iterator operator-(int value) { return { m_vector, m_index - value }; } | ||||||
|         Iterator operator+(int value) { return { m_vector, m_index + value }; } |         Iterator operator+(int value) { return { m_vector, m_index + value }; } | ||||||
|         Iterator& operator=(const Iterator& other) |         Iterator& operator=(const Iterator& other) | ||||||
|  | @ -325,9 +341,14 @@ public: | ||||||
|         } |         } | ||||||
|         T& operator*() { return m_vector[m_index]; } |         T& operator*() { return m_vector[m_index]; } | ||||||
|         int operator-(const Iterator& other) { return m_index - other.m_index; } |         int operator-(const Iterator& other) { return m_index - other.m_index; } | ||||||
|  | 
 | ||||||
|     private: |     private: | ||||||
|         friend class Vector; |         friend class Vector; | ||||||
|         Iterator(Vector& vector, int index) : m_vector(vector), m_index(index) { } |         Iterator(Vector& vector, int index) | ||||||
|  |             : m_vector(vector) | ||||||
|  |             , m_index(index) | ||||||
|  |         { | ||||||
|  |         } | ||||||
|         Vector& m_vector; |         Vector& m_vector; | ||||||
|         int m_index { 0 }; |         int m_index { 0 }; | ||||||
|     }; |     }; | ||||||
|  | @ -342,8 +363,16 @@ public: | ||||||
|         bool operator<(const ConstIterator& other) { return m_index < other.m_index; } |         bool operator<(const ConstIterator& other) { return m_index < other.m_index; } | ||||||
|         bool operator>(const ConstIterator& other) { return m_index > other.m_index; } |         bool operator>(const ConstIterator& other) { return m_index > other.m_index; } | ||||||
|         bool operator>=(const ConstIterator& other) { return m_index >= other.m_index; } |         bool operator>=(const ConstIterator& other) { return m_index >= other.m_index; } | ||||||
|         ConstIterator& operator++() { ++m_index; return *this; } |         ConstIterator& operator++() | ||||||
|         ConstIterator& operator--() { --m_index; return *this; } |         { | ||||||
|  |             ++m_index; | ||||||
|  |             return *this; | ||||||
|  |         } | ||||||
|  |         ConstIterator& operator--() | ||||||
|  |         { | ||||||
|  |             --m_index; | ||||||
|  |             return *this; | ||||||
|  |         } | ||||||
|         ConstIterator operator-(int value) { return { m_vector, m_index - value }; } |         ConstIterator operator-(int value) { return { m_vector, m_index - value }; } | ||||||
|         ConstIterator operator+(int value) { return { m_vector, m_index + value }; } |         ConstIterator operator+(int value) { return { m_vector, m_index + value }; } | ||||||
|         ConstIterator& operator=(const ConstIterator& other) |         ConstIterator& operator=(const ConstIterator& other) | ||||||
|  | @ -353,9 +382,14 @@ public: | ||||||
|         } |         } | ||||||
|         const T& operator*() const { return m_vector[m_index]; } |         const T& operator*() const { return m_vector[m_index]; } | ||||||
|         int operator-(const ConstIterator& other) { return m_index - other.m_index; } |         int operator-(const ConstIterator& other) { return m_index - other.m_index; } | ||||||
|  | 
 | ||||||
|     private: |     private: | ||||||
|         friend class Vector; |         friend class Vector; | ||||||
|         ConstIterator(const Vector& vector, const int index) : m_vector(vector), m_index(index) { } |         ConstIterator(const Vector& vector, const int index) | ||||||
|  |             : m_vector(vector) | ||||||
|  |             , m_index(index) | ||||||
|  |         { | ||||||
|  |         } | ||||||
|         const Vector& m_vector; |         const Vector& m_vector; | ||||||
|         int m_index { 0 }; |         int m_index { 0 }; | ||||||
|     }; |     }; | ||||||
|  | @ -377,8 +411,16 @@ private: | ||||||
|     T* slot(int i) { return &data()[i]; } |     T* slot(int i) { return &data()[i]; } | ||||||
|     const T* slot(int i) const { return &data()[i]; } |     const T* slot(int i) const { return &data()[i]; } | ||||||
| 
 | 
 | ||||||
|     T* inline_buffer() { static_assert(inline_capacity > 0); return reinterpret_cast<T*>(m_inline_buffer_storage); } |     T* inline_buffer() | ||||||
|     const T* inline_buffer() const { static_assert(inline_capacity > 0); return reinterpret_cast<const T*>(m_inline_buffer_storage); } |     { | ||||||
|  |         static_assert(inline_capacity > 0); | ||||||
|  |         return reinterpret_cast<T*>(m_inline_buffer_storage); | ||||||
|  |     } | ||||||
|  |     const T* inline_buffer() const | ||||||
|  |     { | ||||||
|  |         static_assert(inline_capacity > 0); | ||||||
|  |         return reinterpret_cast<const T*>(m_inline_buffer_storage); | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     int m_size { 0 }; |     int m_size { 0 }; | ||||||
|     int m_capacity { 0 }; |     int m_capacity { 0 }; | ||||||
|  |  | ||||||
							
								
								
									
										10
									
								
								AK/WeakPtr.h
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								AK/WeakPtr.h
									
										
									
									
									
								
							|  | @ -4,11 +4,13 @@ | ||||||
| 
 | 
 | ||||||
| namespace AK { | namespace AK { | ||||||
| 
 | 
 | ||||||
| template<typename T> class OwnPtr; | template<typename T> | ||||||
|  | class OwnPtr; | ||||||
| 
 | 
 | ||||||
| template<typename T> | template<typename T> | ||||||
| class WeakPtr { | class WeakPtr { | ||||||
|     friend class Weakable<T>; |     friend class Weakable<T>; | ||||||
|  | 
 | ||||||
| public: | public: | ||||||
|     WeakPtr() {} |     WeakPtr() {} | ||||||
|     WeakPtr(std::nullptr_t) {} |     WeakPtr(std::nullptr_t) {} | ||||||
|  | @ -48,7 +50,10 @@ public: | ||||||
|     bool operator==(const OwnPtr<T>& other) const { return ptr() == other.ptr(); } |     bool operator==(const OwnPtr<T>& other) const { return ptr() == other.ptr(); } | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     WeakPtr(RetainPtr<WeakLink<T>>&& link) : m_link(move(link)) { } |     WeakPtr(RetainPtr<WeakLink<T>>&& link) | ||||||
|  |         : m_link(move(link)) | ||||||
|  |     { | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     RetainPtr<WeakLink<T>> m_link; |     RetainPtr<WeakLink<T>> m_link; | ||||||
| }; | }; | ||||||
|  | @ -64,4 +69,3 @@ inline WeakPtr<T> Weakable<T>::make_weak_ptr() | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| using AK::WeakPtr; | using AK::WeakPtr; | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -1,23 +1,29 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include "Assertions.h" | #include "Assertions.h" | ||||||
| #include "Retainable.h" |  | ||||||
| #include "RetainPtr.h" | #include "RetainPtr.h" | ||||||
|  | #include "Retainable.h" | ||||||
| 
 | 
 | ||||||
| namespace AK { | namespace AK { | ||||||
| 
 | 
 | ||||||
| template<typename T> class Weakable; | template<typename T> | ||||||
| template<typename T> class WeakPtr; | class Weakable; | ||||||
|  | template<typename T> | ||||||
|  | class WeakPtr; | ||||||
| 
 | 
 | ||||||
| template<typename T> | template<typename T> | ||||||
| class WeakLink : public Retainable<WeakLink<T>> { | class WeakLink : public Retainable<WeakLink<T>> { | ||||||
|     friend class Weakable<T>; |     friend class Weakable<T>; | ||||||
|  | 
 | ||||||
| public: | public: | ||||||
|     T* ptr() { return static_cast<T*>(m_ptr); } |     T* ptr() { return static_cast<T*>(m_ptr); } | ||||||
|     const T* ptr() const { return static_cast<const T*>(m_ptr); } |     const T* ptr() const { return static_cast<const T*>(m_ptr); } | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     explicit WeakLink(T& weakable) : m_ptr(&weakable) { } |     explicit WeakLink(T& weakable) | ||||||
|  |         : m_ptr(&weakable) | ||||||
|  |     { | ||||||
|  |     } | ||||||
|     T* m_ptr; |     T* m_ptr; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | @ -25,6 +31,7 @@ template<typename T> | ||||||
| class Weakable { | class Weakable { | ||||||
| private: | private: | ||||||
|     class Link; |     class Link; | ||||||
|  | 
 | ||||||
| public: | public: | ||||||
|     WeakPtr<T> make_weak_ptr(); |     WeakPtr<T> make_weak_ptr(); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -4,6 +4,7 @@ | ||||||
| #    define AK_MAKE_ETERNAL                                               \ | #    define AK_MAKE_ETERNAL                                               \ | ||||||
|     public:                                                               \ |     public:                                                               \ | ||||||
|         void* operator new(size_t size) { return kmalloc_eternal(size); } \ |         void* operator new(size_t size) { return kmalloc_eternal(size); } \ | ||||||
|  |                                                                           \ | ||||||
|     private: |     private: | ||||||
| #else | #else | ||||||
| #    define AK_MAKE_ETERNAL | #    define AK_MAKE_ETERNAL | ||||||
|  |  | ||||||
|  | @ -169,7 +169,6 @@ template<typename PutChFunc> | ||||||
|     return fieldWidth; |     return fieldWidth; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| template<typename PutChFunc> | template<typename PutChFunc> | ||||||
| [[gnu::always_inline]] inline int print_signed_number(PutChFunc putch, char*& bufptr, int number, bool leftPad, bool zeroPad, dword fieldWidth) | [[gnu::always_inline]] inline int print_signed_number(PutChFunc putch, char*& bufptr, int number, bool leftPad, bool zeroPad, dword fieldWidth) | ||||||
| { | { | ||||||
|  | @ -223,14 +222,11 @@ one_more: | ||||||
|                 if (*(p + 1)) |                 if (*(p + 1)) | ||||||
|                     goto one_more; |                     goto one_more; | ||||||
|             } |             } | ||||||
|             switch( *p ) |             switch (*p) { | ||||||
|             { |             case 's': { | ||||||
|                 case 's': |  | ||||||
|                     { |  | ||||||
|                 const char* sp = va_arg(ap, const char*); |                 const char* sp = va_arg(ap, const char*); | ||||||
|                 ret += print_string(putch, bufptr, sp ? sp : "(null)", leftPad, fieldWidth); |                 ret += print_string(putch, bufptr, sp ? sp : "(null)", leftPad, fieldWidth); | ||||||
|                     } |             } break; | ||||||
|                     break; |  | ||||||
| 
 | 
 | ||||||
|             case 'd': |             case 'd': | ||||||
|                 ret += print_signed_number(putch, bufptr, va_arg(ap, int), leftPad, zeroPad, fieldWidth); |                 ret += print_signed_number(putch, bufptr, va_arg(ap, int), leftPad, zeroPad, fieldWidth); | ||||||
|  | @ -297,13 +293,10 @@ one_more: | ||||||
|                 ret += print_hex(putch, bufptr, va_arg(ap, dword), 8); |                 ret += print_hex(putch, bufptr, va_arg(ap, dword), 8); | ||||||
|                 break; |                 break; | ||||||
|             } |             } | ||||||
|         } |         } else { | ||||||
|         else { |  | ||||||
|             putch(bufptr, *p); |             putch(bufptr, *p); | ||||||
|             ++ret; |             ++ret; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     return ret; |     return ret; | ||||||
| } | } | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -1,10 +1,10 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <AK/Vector.h> | #include <AK/Vector.h> | ||||||
| #include <LibGUI/GTableView.h> | #include <LibGUI/GDirectoryModel.h> | ||||||
| #include <LibGUI/GItemView.h> | #include <LibGUI/GItemView.h> | ||||||
| #include <LibGUI/GStackWidget.h> | #include <LibGUI/GStackWidget.h> | ||||||
| #include <LibGUI/GDirectoryModel.h> | #include <LibGUI/GTableView.h> | ||||||
| #include <sys/stat.h> | #include <sys/stat.h> | ||||||
| 
 | 
 | ||||||
| class DirectoryView final : public GStackWidget { | class DirectoryView final : public GStackWidget { | ||||||
|  | @ -26,7 +26,12 @@ public: | ||||||
|     Function<void(String)> on_status_message; |     Function<void(String)> on_status_message; | ||||||
|     Function<void(int done, int total)> on_thumbnail_progress; |     Function<void(int done, int total)> on_thumbnail_progress; | ||||||
| 
 | 
 | ||||||
|     enum ViewMode { Invalid, List, Icon }; |     enum ViewMode | ||||||
|  |     { | ||||||
|  |         Invalid, | ||||||
|  |         List, | ||||||
|  |         Icon | ||||||
|  |     }; | ||||||
|     void set_view_mode(ViewMode); |     void set_view_mode(ViewMode); | ||||||
|     ViewMode view_mode() const { return m_view_mode; } |     ViewMode view_mode() const { return m_view_mode; } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,7 +1,7 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <LibGUI/GWidget.h> |  | ||||||
| #include <AK/Function.h> | #include <AK/Function.h> | ||||||
|  | #include <LibGUI/GWidget.h> | ||||||
| 
 | 
 | ||||||
| class GlyphEditorWidget; | class GlyphEditorWidget; | ||||||
| class GlyphMapWidget; | class GlyphMapWidget; | ||||||
|  |  | ||||||
|  | @ -1,5 +1,5 @@ | ||||||
| #include <LibGUI/GFrame.h> |  | ||||||
| #include <AK/Function.h> | #include <AK/Function.h> | ||||||
|  | #include <LibGUI/GFrame.h> | ||||||
| 
 | 
 | ||||||
| class GlyphEditorWidget final : public GFrame { | class GlyphEditorWidget final : public GFrame { | ||||||
| public: | public: | ||||||
|  |  | ||||||
|  | @ -1,7 +1,7 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <LibGUI/GFrame.h> |  | ||||||
| #include <AK/Function.h> | #include <AK/Function.h> | ||||||
|  | #include <LibGUI/GFrame.h> | ||||||
| 
 | 
 | ||||||
| class GlyphMapWidget final : public GFrame { | class GlyphMapWidget final : public GFrame { | ||||||
| public: | public: | ||||||
|  |  | ||||||
|  | @ -1,9 +1,9 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <LibGUI/GWindow.h> |  | ||||||
| #include <LibGUI/GWidget.h> |  | ||||||
| #include "IRCClient.h" | #include "IRCClient.h" | ||||||
| #include "IRCWindow.h" | #include "IRCWindow.h" | ||||||
|  | #include <LibGUI/GWidget.h> | ||||||
|  | #include <LibGUI/GWindow.h> | ||||||
| 
 | 
 | ||||||
| class GAction; | class GAction; | ||||||
| class GStackWidget; | class GStackWidget; | ||||||
|  |  | ||||||
|  | @ -1,11 +1,11 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
|  | #include "IRCLogBuffer.h" | ||||||
| #include <AK/AKString.h> | #include <AK/AKString.h> | ||||||
| #include <AK/CircularQueue.h> | #include <AK/CircularQueue.h> | ||||||
| #include <AK/Vector.h> |  | ||||||
| #include <AK/Retainable.h> |  | ||||||
| #include <AK/RetainPtr.h> | #include <AK/RetainPtr.h> | ||||||
| #include "IRCLogBuffer.h" | #include <AK/Retainable.h> | ||||||
|  | #include <AK/Vector.h> | ||||||
| 
 | 
 | ||||||
| class IRCClient; | class IRCClient; | ||||||
| class IRCChannelMemberListModel; | class IRCChannelMemberListModel; | ||||||
|  |  | ||||||
|  | @ -1,13 +1,16 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <LibGUI/GModel.h> |  | ||||||
| #include <AK/Function.h> | #include <AK/Function.h> | ||||||
|  | #include <LibGUI/GModel.h> | ||||||
| 
 | 
 | ||||||
| class IRCChannel; | class IRCChannel; | ||||||
| 
 | 
 | ||||||
| class IRCChannelMemberListModel final : public GModel { | class IRCChannelMemberListModel final : public GModel { | ||||||
| public: | public: | ||||||
|     enum Column { Name }; |     enum Column | ||||||
|  |     { | ||||||
|  |         Name | ||||||
|  |     }; | ||||||
|     static Retained<IRCChannelMemberListModel> create(IRCChannel& channel) { return adopt(*new IRCChannelMemberListModel(channel)); } |     static Retained<IRCChannelMemberListModel> create(IRCChannel& channel) { return adopt(*new IRCChannelMemberListModel(channel)); } | ||||||
|     virtual ~IRCChannelMemberListModel() override; |     virtual ~IRCChannelMemberListModel() override; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,13 +1,13 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <AK/AKString.h> |  | ||||||
| #include <AK/HashMap.h> |  | ||||||
| #include <AK/CircularQueue.h> |  | ||||||
| #include <AK/Function.h> |  | ||||||
| #include <LibCore/CTCPSocket.h> |  | ||||||
| #include <LibCore/CConfigFile.h> |  | ||||||
| #include "IRCLogBuffer.h" | #include "IRCLogBuffer.h" | ||||||
| #include "IRCWindow.h" | #include "IRCWindow.h" | ||||||
|  | #include <AK/AKString.h> | ||||||
|  | #include <AK/CircularQueue.h> | ||||||
|  | #include <AK/Function.h> | ||||||
|  | #include <AK/HashMap.h> | ||||||
|  | #include <LibCore/CConfigFile.h> | ||||||
|  | #include <LibCore/CTCPSocket.h> | ||||||
| 
 | 
 | ||||||
| class IRCChannel; | class IRCChannel; | ||||||
| class IRCQuery; | class IRCQuery; | ||||||
|  | @ -17,6 +17,7 @@ class CNotifier; | ||||||
| class IRCClient final : public CObject { | class IRCClient final : public CObject { | ||||||
|     friend class IRCChannel; |     friend class IRCChannel; | ||||||
|     friend class IRCQuery; |     friend class IRCQuery; | ||||||
|  | 
 | ||||||
| public: | public: | ||||||
|     IRCClient(); |     IRCClient(); | ||||||
|     virtual ~IRCClient() override; |     virtual ~IRCClient() override; | ||||||
|  |  | ||||||
|  | @ -2,8 +2,8 @@ | ||||||
| 
 | 
 | ||||||
| #include <AK/AKString.h> | #include <AK/AKString.h> | ||||||
| #include <AK/CircularQueue.h> | #include <AK/CircularQueue.h> | ||||||
| #include <AK/Retainable.h> |  | ||||||
| #include <AK/RetainPtr.h> | #include <AK/RetainPtr.h> | ||||||
|  | #include <AK/Retainable.h> | ||||||
| #include <SharedGraphics/Color.h> | #include <SharedGraphics/Color.h> | ||||||
| 
 | 
 | ||||||
| class IRCLogBufferModel; | class IRCLogBufferModel; | ||||||
|  |  | ||||||
|  | @ -6,7 +6,8 @@ class IRCLogBuffer; | ||||||
| 
 | 
 | ||||||
| class IRCLogBufferModel final : public GModel { | class IRCLogBufferModel final : public GModel { | ||||||
| public: | public: | ||||||
|     enum Column { |     enum Column | ||||||
|  |     { | ||||||
|         Timestamp = 0, |         Timestamp = 0, | ||||||
|         Name, |         Name, | ||||||
|         Text, |         Text, | ||||||
|  |  | ||||||
|  | @ -1,11 +1,11 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
|  | #include "IRCLogBuffer.h" | ||||||
| #include <AK/AKString.h> | #include <AK/AKString.h> | ||||||
| #include <AK/CircularQueue.h> | #include <AK/CircularQueue.h> | ||||||
| #include <AK/Vector.h> |  | ||||||
| #include <AK/Retainable.h> |  | ||||||
| #include <AK/RetainPtr.h> | #include <AK/RetainPtr.h> | ||||||
| #include "IRCLogBuffer.h" | #include <AK/Retainable.h> | ||||||
|  | #include <AK/Vector.h> | ||||||
| 
 | 
 | ||||||
| class IRCClient; | class IRCClient; | ||||||
| class IRCWindow; | class IRCWindow; | ||||||
|  |  | ||||||
|  | @ -11,7 +11,8 @@ class GTextEditor; | ||||||
| 
 | 
 | ||||||
| class IRCWindow : public GWidget { | class IRCWindow : public GWidget { | ||||||
| public: | public: | ||||||
|     enum Type { |     enum Type | ||||||
|  |     { | ||||||
|         Server, |         Server, | ||||||
|         Channel, |         Channel, | ||||||
|         Query, |         Query, | ||||||
|  |  | ||||||
|  | @ -1,14 +1,15 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <LibGUI/GModel.h> |  | ||||||
| #include <AK/Function.h> | #include <AK/Function.h> | ||||||
|  | #include <LibGUI/GModel.h> | ||||||
| 
 | 
 | ||||||
| class IRCClient; | class IRCClient; | ||||||
| class IRCWindow; | class IRCWindow; | ||||||
| 
 | 
 | ||||||
| class IRCWindowListModel final : public GModel { | class IRCWindowListModel final : public GModel { | ||||||
| public: | public: | ||||||
|     enum Column { |     enum Column | ||||||
|  |     { | ||||||
|         Name, |         Name, | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,5 +1,5 @@ | ||||||
| #include <LibGUI/GFrame.h> |  | ||||||
| #include <AK/CircularQueue.h> | #include <AK/CircularQueue.h> | ||||||
|  | #include <LibGUI/GFrame.h> | ||||||
| 
 | 
 | ||||||
| class GraphWidget final : public GFrame { | class GraphWidget final : public GFrame { | ||||||
| public: | public: | ||||||
|  |  | ||||||
|  | @ -1,7 +1,7 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <LibGUI/GWidget.h> |  | ||||||
| #include <LibCore/CFile.h> | #include <LibCore/CFile.h> | ||||||
|  | #include <LibGUI/GWidget.h> | ||||||
| 
 | 
 | ||||||
| class GLabel; | class GLabel; | ||||||
| class GraphWidget; | class GraphWidget; | ||||||
|  |  | ||||||
|  | @ -3,15 +3,16 @@ | ||||||
| #include <AK/AKString.h> | #include <AK/AKString.h> | ||||||
| #include <AK/HashMap.h> | #include <AK/HashMap.h> | ||||||
| #include <AK/Vector.h> | #include <AK/Vector.h> | ||||||
| #include <LibGUI/GModel.h> |  | ||||||
| #include <LibCore/CFile.h> | #include <LibCore/CFile.h> | ||||||
|  | #include <LibGUI/GModel.h> | ||||||
| #include <unistd.h> | #include <unistd.h> | ||||||
| 
 | 
 | ||||||
| class GraphWidget; | class GraphWidget; | ||||||
| 
 | 
 | ||||||
| class ProcessModel final : public GModel { | class ProcessModel final : public GModel { | ||||||
| public: | public: | ||||||
|     enum Column { |     enum Column | ||||||
|  |     { | ||||||
|         Icon = 0, |         Icon = 0, | ||||||
|         Name, |         Name, | ||||||
|         CPU, |         CPU, | ||||||
|  |  | ||||||
|  | @ -1,7 +1,7 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <LibGUI/GTableView.h> |  | ||||||
| #include <AK/Function.h> | #include <AK/Function.h> | ||||||
|  | #include <LibGUI/GTableView.h> | ||||||
| #include <unistd.h> | #include <unistd.h> | ||||||
| 
 | 
 | ||||||
| class GraphWidget; | class GraphWidget; | ||||||
|  | @ -19,4 +19,3 @@ public: | ||||||
| private: | private: | ||||||
|     virtual void model_notification(const GModelNotification&) override; |     virtual void model_notification(const GModelNotification&) override; | ||||||
| }; | }; | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -1,7 +1,7 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <LibGUI/GButton.h> |  | ||||||
| #include "WindowIdentifier.h" | #include "WindowIdentifier.h" | ||||||
|  | #include <LibGUI/GButton.h> | ||||||
| 
 | 
 | ||||||
| class TaskbarButton final : public GButton { | class TaskbarButton final : public GButton { | ||||||
| public: | public: | ||||||
|  |  | ||||||
|  | @ -1,6 +1,6 @@ | ||||||
| #include <LibGUI/GWindow.h> |  | ||||||
| #include <LibGUI/GWidget.h> |  | ||||||
| #include "WindowList.h" | #include "WindowList.h" | ||||||
|  | #include <LibGUI/GWidget.h> | ||||||
|  | #include <LibGUI/GWindow.h> | ||||||
| 
 | 
 | ||||||
| class TaskbarWindow final : public GWindow { | class TaskbarWindow final : public GWindow { | ||||||
| public: | public: | ||||||
|  |  | ||||||
|  | @ -18,6 +18,7 @@ public: | ||||||
|     { |     { | ||||||
|         return m_client_id == other.m_client_id && m_window_id == other.m_window_id; |         return m_client_id == other.m_client_id && m_window_id == other.m_window_id; | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
| private: | private: | ||||||
|     int m_client_id { -1 }; |     int m_client_id { -1 }; | ||||||
|     int m_window_id { -1 }; |     int m_window_id { -1 }; | ||||||
|  |  | ||||||
|  | @ -1,10 +1,10 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
|  | #include "WindowIdentifier.h" | ||||||
| #include <AK/AKString.h> | #include <AK/AKString.h> | ||||||
| #include <AK/HashMap.h> | #include <AK/HashMap.h> | ||||||
| #include <SharedGraphics/Rect.h> |  | ||||||
| #include <LibGUI/GButton.h> | #include <LibGUI/GButton.h> | ||||||
| #include "WindowIdentifier.h" | #include <SharedGraphics/Rect.h> | ||||||
| 
 | 
 | ||||||
| class Window { | class Window { | ||||||
| public: | public: | ||||||
|  | @ -64,7 +64,8 @@ class WindowList { | ||||||
| public: | public: | ||||||
|     static WindowList& the(); |     static WindowList& the(); | ||||||
| 
 | 
 | ||||||
|     template<typename Callback> void for_each_window(Callback callback) |     template<typename Callback> | ||||||
|  |     void for_each_window(Callback callback) | ||||||
|     { |     { | ||||||
|         for (auto& it : m_windows) |         for (auto& it : m_windows) | ||||||
|             callback(*it.value); |             callback(*it.value); | ||||||
|  |  | ||||||
|  | @ -3,12 +3,12 @@ | ||||||
| #include <AK/AKString.h> | #include <AK/AKString.h> | ||||||
| #include <AK/Types.h> | #include <AK/Types.h> | ||||||
| #include <AK/Vector.h> | #include <AK/Vector.h> | ||||||
| #include <SharedGraphics/GraphicsBitmap.h> | #include <LibCore/CConfigFile.h> | ||||||
| #include <SharedGraphics/Rect.h> |  | ||||||
| #include <LibGUI/GFrame.h> |  | ||||||
| #include <LibCore/CNotifier.h> | #include <LibCore/CNotifier.h> | ||||||
| #include <LibCore/CTimer.h> | #include <LibCore/CTimer.h> | ||||||
| #include <LibCore/CConfigFile.h> | #include <LibGUI/GFrame.h> | ||||||
|  | #include <SharedGraphics/GraphicsBitmap.h> | ||||||
|  | #include <SharedGraphics/Rect.h> | ||||||
| 
 | 
 | ||||||
| class Font; | class Font; | ||||||
| 
 | 
 | ||||||
|  | @ -45,7 +45,6 @@ private: | ||||||
|     void invalidate_cursor(); |     void invalidate_cursor(); | ||||||
|     void set_window_title(const String&); |     void set_window_title(const String&); | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|     void inject_string(const String&); |     void inject_string(const String&); | ||||||
|     void unimplemented_escape(); |     void unimplemented_escape(); | ||||||
|     void unimplemented_xterm_escape(); |     void unimplemented_xterm_escape(); | ||||||
|  | @ -107,7 +106,11 @@ private: | ||||||
|         bool dirty { false }; |         bool dirty { false }; | ||||||
|         word length { 0 }; |         word length { 0 }; | ||||||
|     }; |     }; | ||||||
|     Line& line(size_t index) { ASSERT(index < m_rows); return *m_lines[index]; } |     Line& line(size_t index) | ||||||
|  |     { | ||||||
|  |         ASSERT(index < m_rows); | ||||||
|  |         return *m_lines[index]; | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     Line** m_lines { nullptr }; |     Line** m_lines { nullptr }; | ||||||
| 
 | 
 | ||||||
|  | @ -125,7 +128,8 @@ private: | ||||||
|     void execute_escape_sequence(byte final); |     void execute_escape_sequence(byte final); | ||||||
|     void execute_xterm_command(); |     void execute_xterm_command(); | ||||||
| 
 | 
 | ||||||
|     enum EscapeState { |     enum EscapeState | ||||||
|  |     { | ||||||
|         Normal, |         Normal, | ||||||
|         ExpectBracket, |         ExpectBracket, | ||||||
|         ExpectParameter, |         ExpectParameter, | ||||||
|  |  | ||||||
|  | @ -1,11 +1,12 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <LibGUI/GWidget.h> |  | ||||||
| #include <AK/Vector.h> |  | ||||||
| #include "VBWidget.h" | #include "VBWidget.h" | ||||||
|  | #include <AK/Vector.h> | ||||||
|  | #include <LibGUI/GWidget.h> | ||||||
| 
 | 
 | ||||||
| class VBForm : public GWidget { | class VBForm : public GWidget { | ||||||
|     friend class VBWidget; |     friend class VBWidget; | ||||||
|  | 
 | ||||||
| public: | public: | ||||||
|     explicit VBForm(const String& name, GWidget* parent = nullptr); |     explicit VBForm(const String& name, GWidget* parent = nullptr); | ||||||
|     virtual ~VBForm() override; |     virtual ~VBForm() override; | ||||||
|  | @ -43,7 +44,8 @@ private: | ||||||
|     void add_to_selection(VBWidget&); |     void add_to_selection(VBWidget&); | ||||||
|     void remove_from_selection(VBWidget&); |     void remove_from_selection(VBWidget&); | ||||||
|     void delete_selected_widgets(); |     void delete_selected_widgets(); | ||||||
|     template<typename Callback> void for_each_selected_widget(Callback); |     template<typename Callback> | ||||||
|  |     void for_each_selected_widget(Callback); | ||||||
| 
 | 
 | ||||||
|     VBWidget* single_selected_widget(); |     VBWidget* single_selected_widget(); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -9,6 +9,7 @@ class VBWidget; | ||||||
| 
 | 
 | ||||||
| class VBProperty { | class VBProperty { | ||||||
|     friend class VBWidget; |     friend class VBWidget; | ||||||
|  | 
 | ||||||
| public: | public: | ||||||
|     VBProperty(VBWidget&, const String& name, const GVariant& value); |     VBProperty(VBWidget&, const String& name, const GVariant& value); | ||||||
|     VBProperty(VBWidget&, const String& name, Function<GVariant(const GWidget&)>&& getter, Function<void(GWidget&, const GVariant&)>&& setter); |     VBProperty(VBWidget&, const String& name, Function<GVariant(const GWidget&)>&& getter, Function<void(GWidget&, const GVariant&)>&& setter); | ||||||
|  |  | ||||||
|  | @ -1,12 +1,12 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <SharedGraphics/Rect.h> | #include "VBWidgetType.h" | ||||||
|  | #include <AK/Function.h> | ||||||
|  | #include <AK/HashMap.h> | ||||||
| #include <AK/Retainable.h> | #include <AK/Retainable.h> | ||||||
| #include <AK/Retained.h> | #include <AK/Retained.h> | ||||||
| #include <AK/Weakable.h> | #include <AK/Weakable.h> | ||||||
| #include <AK/HashMap.h> | #include <SharedGraphics/Rect.h> | ||||||
| #include <AK/Function.h> |  | ||||||
| #include "VBWidgetType.h" |  | ||||||
| 
 | 
 | ||||||
| class GPainter; | class GPainter; | ||||||
| class GVariant; | class GVariant; | ||||||
|  | @ -15,7 +15,18 @@ class VBForm; | ||||||
| class VBProperty; | class VBProperty; | ||||||
| class VBWidgetPropertyModel; | class VBWidgetPropertyModel; | ||||||
| 
 | 
 | ||||||
| enum class Direction { None, Left, UpLeft, Up, UpRight, Right, DownRight, Down, DownLeft }; | enum class Direction | ||||||
|  | { | ||||||
|  |     None, | ||||||
|  |     Left, | ||||||
|  |     UpLeft, | ||||||
|  |     Up, | ||||||
|  |     UpRight, | ||||||
|  |     Right, | ||||||
|  |     DownRight, | ||||||
|  |     Down, | ||||||
|  |     DownLeft | ||||||
|  | }; | ||||||
| template<typename Callback> | template<typename Callback> | ||||||
| inline void for_each_direction(Callback callback) | inline void for_each_direction(Callback callback) | ||||||
| { | { | ||||||
|  | @ -29,8 +40,10 @@ inline void for_each_direction(Callback callback) | ||||||
|     callback(Direction::DownLeft); |     callback(Direction::DownLeft); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| class VBWidget : public Retainable<VBWidget>, public Weakable<VBWidget> { | class VBWidget : public Retainable<VBWidget> | ||||||
|  |     , public Weakable<VBWidget> { | ||||||
|     friend class VBWidgetPropertyModel; |     friend class VBWidgetPropertyModel; | ||||||
|  | 
 | ||||||
| public: | public: | ||||||
|     static Retained<VBWidget> create(VBWidgetType type, VBForm& form) { return adopt(*new VBWidget(type, form)); } |     static Retained<VBWidget> create(VBWidgetType type, VBForm& form) { return adopt(*new VBWidget(type, form)); } | ||||||
|     ~VBWidget(); |     ~VBWidget(); | ||||||
|  |  | ||||||
|  | @ -7,7 +7,8 @@ class VBProperty; | ||||||
| 
 | 
 | ||||||
| class VBWidgetPropertyModel : public GModel { | class VBWidgetPropertyModel : public GModel { | ||||||
| public: | public: | ||||||
|     enum Column { |     enum Column | ||||||
|  |     { | ||||||
|         Name = 0, |         Name = 0, | ||||||
|         Value, |         Value, | ||||||
|         __Count |         __Count | ||||||
|  |  | ||||||
|  | @ -1,9 +1,9 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include "VBWidgetType.h" | #include "VBWidgetType.h" | ||||||
|  | #include <AK/AKString.h> | ||||||
| #include <AK/HashMap.h> | #include <AK/HashMap.h> | ||||||
| #include <AK/OwnPtr.h> | #include <AK/OwnPtr.h> | ||||||
| #include <AK/AKString.h> |  | ||||||
| 
 | 
 | ||||||
| class GWidget; | class GWidget; | ||||||
| class VBProperty; | class VBProperty; | ||||||
|  | @ -11,7 +11,8 @@ class VBWidget; | ||||||
| 
 | 
 | ||||||
| class VBWidgetRegistry { | class VBWidgetRegistry { | ||||||
| public: | public: | ||||||
|     template<typename Callback> static void for_each_widget_type(Callback callback) |     template<typename Callback> | ||||||
|  |     static void for_each_widget_type(Callback callback) | ||||||
|     { |     { | ||||||
|         for (unsigned i = 1; i < (unsigned)VBWidgetType::__Count; ++i) |         for (unsigned i = 1; i < (unsigned)VBWidgetType::__Count; ++i) | ||||||
|             callback((VBWidgetType)i); |             callback((VBWidgetType)i); | ||||||
|  |  | ||||||
|  | @ -1,6 +1,7 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| enum class VBWidgetType { | enum class VBWidgetType | ||||||
|  | { | ||||||
|     None = 0, |     None = 0, | ||||||
|     GWidget, |     GWidget, | ||||||
|     GButton, |     GButton, | ||||||
|  |  | ||||||
|  | @ -1,8 +1,8 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <LibGUI/GFrame.h> |  | ||||||
| #include <LibCore/CTimer.h> |  | ||||||
| #include <AK/Noncopyable.h> | #include <AK/Noncopyable.h> | ||||||
|  | #include <LibCore/CTimer.h> | ||||||
|  | #include <LibGUI/GFrame.h> | ||||||
| 
 | 
 | ||||||
| class Field; | class Field; | ||||||
| class GButton; | class GButton; | ||||||
|  | @ -27,12 +27,14 @@ public: | ||||||
|     SquareButton* button { nullptr }; |     SquareButton* button { nullptr }; | ||||||
|     SquareLabel* label { nullptr }; |     SquareLabel* label { nullptr }; | ||||||
| 
 | 
 | ||||||
|     template<typename Callback> void for_each_neighbor(Callback); |     template<typename Callback> | ||||||
|  |     void for_each_neighbor(Callback); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| class Field final : public GFrame { | class Field final : public GFrame { | ||||||
|     friend class Square; |     friend class Square; | ||||||
|     friend class SquareLabel; |     friend class SquareLabel; | ||||||
|  | 
 | ||||||
| public: | public: | ||||||
|     Field(GLabel& flag_label, GLabel& time_label, GButton& face_button, GWidget* parent); |     Field(GLabel& flag_label, GLabel& time_label, GButton& face_button, GWidget* parent); | ||||||
|     virtual ~Field() override; |     virtual ~Field() override; | ||||||
|  | @ -66,9 +68,15 @@ private: | ||||||
| 
 | 
 | ||||||
|     void flood_fill(Square&); |     void flood_fill(Square&); | ||||||
| 
 | 
 | ||||||
|     template<typename Callback> void for_each_square(Callback); |     template<typename Callback> | ||||||
|  |     void for_each_square(Callback); | ||||||
| 
 | 
 | ||||||
|     enum class Face { Default, Good, Bad }; |     enum class Face | ||||||
|  |     { | ||||||
|  |         Default, | ||||||
|  |         Good, | ||||||
|  |         Bad | ||||||
|  |     }; | ||||||
|     void set_face(Face); |     void set_face(Face); | ||||||
| 
 | 
 | ||||||
|     int m_rows { 9 }; |     int m_rows { 9 }; | ||||||
|  |  | ||||||
|  | @ -1,7 +1,7 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <LibGUI/GWidget.h> |  | ||||||
| #include <AK/CircularQueue.h> | #include <AK/CircularQueue.h> | ||||||
|  | #include <LibGUI/GWidget.h> | ||||||
| 
 | 
 | ||||||
| class SnakeGame : public GWidget { | class SnakeGame : public GWidget { | ||||||
| public: | public: | ||||||
|  |  | ||||||
|  | @ -1,7 +1,7 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <Kernel/kstdio.h> |  | ||||||
| #include <Kernel/i386.h> | #include <Kernel/i386.h> | ||||||
|  | #include <Kernel/kstdio.h> | ||||||
| 
 | 
 | ||||||
| #ifdef DEBUG | #ifdef DEBUG | ||||||
| [[noreturn]] void __assertion_failed(const char* msg, const char* file, unsigned line, const char* func); | [[noreturn]] void __assertion_failed(const char* msg, const char* file, unsigned line, const char* func); | ||||||
|  | @ -11,7 +11,14 @@ | ||||||
| #    define ASSERT(expr) | #    define ASSERT(expr) | ||||||
| #    define ASSERT_NOT_REACHED() CRASH() | #    define ASSERT_NOT_REACHED() CRASH() | ||||||
| #endif | #endif | ||||||
| #define CRASH() do { asm volatile("ud2"); } while(0) | #define CRASH()              \ | ||||||
| #define RELEASE_ASSERT(x) do { if (!(x)) CRASH(); } while(0) |     do {                     \ | ||||||
|  |         asm volatile("ud2"); \ | ||||||
|  |     } while (0) | ||||||
|  | #define RELEASE_ASSERT(x) \ | ||||||
|  |     do {                  \ | ||||||
|  |         if (!(x))         \ | ||||||
|  |             CRASH();      \ | ||||||
|  |     } while (0) | ||||||
| #define ASSERT_INTERRUPTS_DISABLED() ASSERT(!(cpu_flags() & 0x200)) | #define ASSERT_INTERRUPTS_DISABLED() ASSERT(!(cpu_flags() & 0x200)) | ||||||
| #define ASSERT_INTERRUPTS_ENABLED() ASSERT(cpu_flags() & 0x200) | #define ASSERT_INTERRUPTS_ENABLED() ASSERT(cpu_flags() & 0x200) | ||||||
|  |  | ||||||
|  | @ -35,4 +35,3 @@ private: | ||||||
|     ConsoleImplementation* m_implementation { nullptr }; |     ConsoleImplementation* m_implementation { nullptr }; | ||||||
|     CircularQueue<char, 16384> m_logbuffer; |     CircularQueue<char, 16384> m_logbuffer; | ||||||
| }; | }; | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -1,10 +1,10 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <AK/Types.h> |  | ||||||
| #include <AK/AKString.h> | #include <AK/AKString.h> | ||||||
| #include <SharedGraphics/Size.h> | #include <AK/Types.h> | ||||||
| #include <Kernel/PhysicalAddress.h> |  | ||||||
| #include <Kernel/Devices/BlockDevice.h> | #include <Kernel/Devices/BlockDevice.h> | ||||||
|  | #include <Kernel/PhysicalAddress.h> | ||||||
|  | #include <SharedGraphics/Size.h> | ||||||
| 
 | 
 | ||||||
| class BXVGADevice final : public BlockDevice { | class BXVGADevice final : public BlockDevice { | ||||||
|     AK_MAKE_ETERNAL |     AK_MAKE_ETERNAL | ||||||
|  |  | ||||||
|  | @ -10,7 +10,10 @@ public: | ||||||
|     virtual bool is_seekable() const override { return true; } |     virtual bool is_seekable() const override { return true; } | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
|     BlockDevice(unsigned major, unsigned minor) : Device(major, minor) { } |     BlockDevice(unsigned major, unsigned minor) | ||||||
|  |         : Device(major, minor) | ||||||
|  |     { | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     virtual bool is_block_device() const final { return true; } |     virtual bool is_block_device() const final { return true; } | ||||||
|  |  | ||||||
|  | @ -7,7 +7,10 @@ public: | ||||||
|     virtual ~CharacterDevice() override; |     virtual ~CharacterDevice() override; | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
|     CharacterDevice(unsigned major, unsigned minor) : Device(major, minor) { } |     CharacterDevice(unsigned major, unsigned minor) | ||||||
|  |         : Device(major, minor) | ||||||
|  |     { | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     virtual bool is_character_device() const final { return true; } |     virtual bool is_character_device() const final { return true; } | ||||||
|  |  | ||||||
|  | @ -23,4 +23,3 @@ public: | ||||||
| protected: | protected: | ||||||
|     DiskDevice(); |     DiskDevice(); | ||||||
| }; | }; | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -1,9 +1,9 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <Kernel/Devices/DiskDevice.h> |  | ||||||
| #include <AK/RetainPtr.h> |  | ||||||
| #include <AK/AKString.h> | #include <AK/AKString.h> | ||||||
|  | #include <AK/RetainPtr.h> | ||||||
| #include <AK/Types.h> | #include <AK/Types.h> | ||||||
|  | #include <Kernel/Devices/DiskDevice.h> | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| 
 | 
 | ||||||
| class FileBackedDiskDevice final : public DiskDevice { | class FileBackedDiskDevice final : public DiskDevice { | ||||||
|  | @ -30,4 +30,3 @@ private: | ||||||
|     DiskOffset m_file_length { 0 }; |     DiskOffset m_file_length { 0 }; | ||||||
|     unsigned m_block_size { 0 }; |     unsigned m_block_size { 0 }; | ||||||
| }; | }; | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -16,4 +16,3 @@ private: | ||||||
|     virtual bool can_write(FileDescriptor&) const override { return true; } |     virtual bool can_write(FileDescriptor&) const override { return true; } | ||||||
|     virtual const char* class_name() const override { return "FullDevice"; } |     virtual const char* class_name() const override { return "FullDevice"; } | ||||||
| }; | }; | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -1,9 +1,9 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <Kernel/Lock.h> |  | ||||||
| #include <AK/RetainPtr.h> | #include <AK/RetainPtr.h> | ||||||
| #include <Kernel/Devices/DiskDevice.h> | #include <Kernel/Devices/DiskDevice.h> | ||||||
| #include <Kernel/IRQHandler.h> | #include <Kernel/IRQHandler.h> | ||||||
|  | #include <Kernel/Lock.h> | ||||||
| #include <Kernel/PCI.h> | #include <Kernel/PCI.h> | ||||||
| #include <Kernel/PhysicalAddress.h> | #include <Kernel/PhysicalAddress.h> | ||||||
| #include <Kernel/VM/PhysicalPage.h> | #include <Kernel/VM/PhysicalPage.h> | ||||||
|  | @ -14,7 +14,8 @@ struct PhysicalRegionDescriptor { | ||||||
|     word end_of_table { 0 }; |     word end_of_table { 0 }; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| class IDEDiskDevice final : public IRQHandler, public DiskDevice { | class IDEDiskDevice final : public IRQHandler | ||||||
|  |     , public DiskDevice { | ||||||
|     AK_MAKE_ETERNAL |     AK_MAKE_ETERNAL | ||||||
| public: | public: | ||||||
|     static Retained<IDEDiskDevice> create(); |     static Retained<IDEDiskDevice> create(); | ||||||
|  | @ -58,4 +59,3 @@ private: | ||||||
|     word m_bus_master_base { 0 }; |     word m_bus_master_base { 0 }; | ||||||
|     Lockable<bool> m_dma_enabled; |     Lockable<bool> m_dma_enabled; | ||||||
| }; | }; | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -1,15 +1,16 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <AK/Types.h> |  | ||||||
| #include <AK/DoublyLinkedList.h> |  | ||||||
| #include <AK/CircularQueue.h> |  | ||||||
| #include <Kernel/Devices/CharacterDevice.h> |  | ||||||
| #include "IRQHandler.h" | #include "IRQHandler.h" | ||||||
| #include "KeyCode.h" | #include "KeyCode.h" | ||||||
|  | #include <AK/CircularQueue.h> | ||||||
|  | #include <AK/DoublyLinkedList.h> | ||||||
|  | #include <AK/Types.h> | ||||||
|  | #include <Kernel/Devices/CharacterDevice.h> | ||||||
| 
 | 
 | ||||||
| class KeyboardClient; | class KeyboardClient; | ||||||
| 
 | 
 | ||||||
| class KeyboardDevice final : public IRQHandler, public CharacterDevice { | class KeyboardDevice final : public IRQHandler | ||||||
|  |     , public CharacterDevice { | ||||||
|     AK_MAKE_ETERNAL |     AK_MAKE_ETERNAL | ||||||
| public: | public: | ||||||
|     using Event = KeyEvent; |     using Event = KeyEvent; | ||||||
|  |  | ||||||
|  | @ -18,4 +18,3 @@ private: | ||||||
|     virtual bool can_read(FileDescriptor&) const override; |     virtual bool can_read(FileDescriptor&) const override; | ||||||
|     virtual const char* class_name() const override { return "NullDevice"; } |     virtual const char* class_name() const override { return "NullDevice"; } | ||||||
| }; | }; | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -1,11 +1,12 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <Kernel/Devices/CharacterDevice.h> |  | ||||||
| #include <Kernel/MousePacket.h> |  | ||||||
| #include <Kernel/IRQHandler.h> |  | ||||||
| #include <AK/CircularQueue.h> | #include <AK/CircularQueue.h> | ||||||
|  | #include <Kernel/Devices/CharacterDevice.h> | ||||||
|  | #include <Kernel/IRQHandler.h> | ||||||
|  | #include <Kernel/MousePacket.h> | ||||||
| 
 | 
 | ||||||
| class PS2MouseDevice final : public IRQHandler, public CharacterDevice { | class PS2MouseDevice final : public IRQHandler | ||||||
|  |     , public CharacterDevice { | ||||||
| public: | public: | ||||||
|     PS2MouseDevice(); |     PS2MouseDevice(); | ||||||
|     virtual ~PS2MouseDevice() override; |     virtual ~PS2MouseDevice() override; | ||||||
|  |  | ||||||
|  | @ -18,4 +18,3 @@ private: | ||||||
|     virtual bool can_write(FileDescriptor&) const override { return true; } |     virtual bool can_write(FileDescriptor&) const override { return true; } | ||||||
|     virtual const char* class_name() const override { return "RandomDevice"; } |     virtual const char* class_name() const override { return "RandomDevice"; } | ||||||
| }; | }; | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -16,4 +16,3 @@ private: | ||||||
|     virtual bool can_write(FileDescriptor&) const override { return true; } |     virtual bool can_write(FileDescriptor&) const override { return true; } | ||||||
|     virtual const char* class_name() const override { return "ZeroDevice"; } |     virtual const char* class_name() const override { return "ZeroDevice"; } | ||||||
| }; | }; | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -26,4 +26,3 @@ private: | ||||||
| 
 | 
 | ||||||
|     HashTable<SlavePTY*> m_slave_ptys; |     HashTable<SlavePTY*> m_slave_ptys; | ||||||
| }; | }; | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -1,9 +1,9 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <Kernel/UnixTypes.h> | #include <Kernel/FileSystem/DiskBackedFileSystem.h> | ||||||
| #include <Kernel/FileSystem/Inode.h> | #include <Kernel/FileSystem/Inode.h> | ||||||
| #include <Kernel/FileSystem/ext2_fs.h> | #include <Kernel/FileSystem/ext2_fs.h> | ||||||
| #include <Kernel/FileSystem/DiskBackedFileSystem.h> | #include <Kernel/UnixTypes.h> | ||||||
| 
 | 
 | ||||||
| struct ext2_group_desc; | struct ext2_group_desc; | ||||||
| struct ext2_inode; | struct ext2_inode; | ||||||
|  | @ -13,6 +13,7 @@ class Ext2FS; | ||||||
| 
 | 
 | ||||||
| class Ext2FSInode final : public Inode { | class Ext2FSInode final : public Inode { | ||||||
|     friend class Ext2FS; |     friend class Ext2FS; | ||||||
|  | 
 | ||||||
| public: | public: | ||||||
|     virtual ~Ext2FSInode() override; |     virtual ~Ext2FSInode() override; | ||||||
| 
 | 
 | ||||||
|  | @ -59,6 +60,7 @@ private: | ||||||
| 
 | 
 | ||||||
| class Ext2FS final : public DiskBackedFS { | class Ext2FS final : public DiskBackedFS { | ||||||
|     friend class Ext2FSInode; |     friend class Ext2FSInode; | ||||||
|  | 
 | ||||||
| public: | public: | ||||||
|     static Retained<Ext2FS> create(Retained<DiskDevice>&&); |     static Retained<Ext2FS> create(Retained<DiskDevice>&&); | ||||||
|     virtual ~Ext2FS() override; |     virtual ~Ext2FS() override; | ||||||
|  |  | ||||||
|  | @ -1,15 +1,18 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <Kernel/DoubleBuffer.h> | #include <Kernel/DoubleBuffer.h> | ||||||
| #include <Kernel/UnixTypes.h> |  | ||||||
| #include <Kernel/File.h> | #include <Kernel/File.h> | ||||||
|  | #include <Kernel/UnixTypes.h> | ||||||
| 
 | 
 | ||||||
| class FileDescriptor; | class FileDescriptor; | ||||||
| 
 | 
 | ||||||
| class FIFO final : public File { | class FIFO final : public File { | ||||||
| public: | public: | ||||||
|     enum class Direction : byte { |     enum class Direction : byte | ||||||
|         Neither, Reader, Writer |     { | ||||||
|  |         Neither, | ||||||
|  |         Reader, | ||||||
|  |         Writer | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     static RetainPtr<FIFO> from_fifo_id(dword); |     static RetainPtr<FIFO> from_fifo_id(dword); | ||||||
|  |  | ||||||
|  | @ -1,14 +1,14 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <Kernel/FileSystem/VirtualFileSystem.h> | #include <AK/Badge.h> | ||||||
| #include <Kernel/FileSystem/InodeMetadata.h> |  | ||||||
| #include <Kernel/FileSystem/Inode.h> |  | ||||||
| #include <Kernel/FileSystem/FIFO.h> |  | ||||||
| #include <Kernel/LinearAddress.h> |  | ||||||
| #include <AK/ByteBuffer.h> | #include <AK/ByteBuffer.h> | ||||||
| #include <AK/CircularQueue.h> | #include <AK/CircularQueue.h> | ||||||
| #include <AK/Retainable.h> | #include <AK/Retainable.h> | ||||||
| #include <AK/Badge.h> | #include <Kernel/FileSystem/FIFO.h> | ||||||
|  | #include <Kernel/FileSystem/Inode.h> | ||||||
|  | #include <Kernel/FileSystem/InodeMetadata.h> | ||||||
|  | #include <Kernel/FileSystem/VirtualFileSystem.h> | ||||||
|  | #include <Kernel/LinearAddress.h> | ||||||
| #include <Kernel/Net/Socket.h> | #include <Kernel/Net/Socket.h> | ||||||
| 
 | 
 | ||||||
| class File; | class File; | ||||||
|  | @ -119,4 +119,3 @@ private: | ||||||
|     SocketRole m_socket_role { SocketRole::None }; |     SocketRole m_socket_role { SocketRole::None }; | ||||||
|     FIFO::Direction m_fifo_direction { FIFO::Direction::Neither }; |     FIFO::Direction m_fifo_direction { FIFO::Direction::Neither }; | ||||||
| }; | }; | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -1,20 +1,20 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <Kernel/Devices/DiskDevice.h> |  | ||||||
| #include "InodeIdentifier.h" | #include "InodeIdentifier.h" | ||||||
| #include "InodeMetadata.h" | #include "InodeMetadata.h" | ||||||
| #include "UnixTypes.h" | #include "UnixTypes.h" | ||||||
|  | #include <AK/AKString.h> | ||||||
| #include <AK/ByteBuffer.h> | #include <AK/ByteBuffer.h> | ||||||
|  | #include <AK/Function.h> | ||||||
| #include <AK/HashMap.h> | #include <AK/HashMap.h> | ||||||
| #include <AK/OwnPtr.h> | #include <AK/OwnPtr.h> | ||||||
| #include <AK/Retainable.h> |  | ||||||
| #include <AK/RetainPtr.h> | #include <AK/RetainPtr.h> | ||||||
| #include <AK/AKString.h> | #include <AK/Retainable.h> | ||||||
| #include <AK/Function.h> |  | ||||||
| #include <AK/kstdio.h> |  | ||||||
| #include <Kernel/Lock.h> |  | ||||||
| #include <AK/WeakPtr.h> | #include <AK/WeakPtr.h> | ||||||
|  | #include <AK/kstdio.h> | ||||||
|  | #include <Kernel/Devices/DiskDevice.h> | ||||||
| #include <Kernel/KResult.h> | #include <Kernel/KResult.h> | ||||||
|  | #include <Kernel/Lock.h> | ||||||
| 
 | 
 | ||||||
| static const dword mepoch = 476763780; | static const dword mepoch = 476763780; | ||||||
| 
 | 
 | ||||||
|  | @ -25,6 +25,7 @@ class VMObject; | ||||||
| 
 | 
 | ||||||
| class FS : public Retainable<FS> { | class FS : public Retainable<FS> { | ||||||
|     friend class Inode; |     friend class Inode; | ||||||
|  | 
 | ||||||
| public: | public: | ||||||
|     virtual ~FS(); |     virtual ~FS(); | ||||||
| 
 | 
 | ||||||
|  | @ -93,4 +94,3 @@ struct Traits<InodeIdentifier> { | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -1,12 +1,12 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <AK/Retainable.h> |  | ||||||
| #include <AK/AKString.h> | #include <AK/AKString.h> | ||||||
| #include <AK/Function.h> | #include <AK/Function.h> | ||||||
|  | #include <AK/Retainable.h> | ||||||
| #include <AK/WeakPtr.h> | #include <AK/WeakPtr.h> | ||||||
|  | #include <Kernel/FileSystem/FileSystem.h> | ||||||
| #include <Kernel/FileSystem/InodeIdentifier.h> | #include <Kernel/FileSystem/InodeIdentifier.h> | ||||||
| #include <Kernel/FileSystem/InodeMetadata.h> | #include <Kernel/FileSystem/InodeMetadata.h> | ||||||
| #include <Kernel/FileSystem/FileSystem.h> |  | ||||||
| #include <Kernel/KResult.h> | #include <Kernel/KResult.h> | ||||||
| #include <Kernel/Lock.h> | #include <Kernel/Lock.h> | ||||||
| 
 | 
 | ||||||
|  | @ -17,6 +17,7 @@ class VMObject; | ||||||
| class Inode : public Retainable<Inode> { | class Inode : public Retainable<Inode> { | ||||||
|     friend class VFS; |     friend class VFS; | ||||||
|     friend class FS; |     friend class FS; | ||||||
|  | 
 | ||||||
| public: | public: | ||||||
|     virtual ~Inode(); |     virtual ~Inode(); | ||||||
| 
 | 
 | ||||||
|  | @ -89,4 +90,3 @@ private: | ||||||
|     RetainPtr<LocalSocket> m_socket; |     RetainPtr<LocalSocket> m_socket; | ||||||
|     bool m_metadata_dirty { false }; |     bool m_metadata_dirty { false }; | ||||||
| }; | }; | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -39,4 +39,3 @@ private: | ||||||
|     dword m_fsid { 0 }; |     dword m_fsid { 0 }; | ||||||
|     dword m_index { 0 }; |     dword m_index { 0 }; | ||||||
| }; | }; | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -84,5 +84,3 @@ struct InodeMetadata { | ||||||
|     unsigned major_device { 0 }; |     unsigned major_device { 0 }; | ||||||
|     unsigned minor_device { 0 }; |     unsigned minor_device { 0 }; | ||||||
| }; | }; | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -1,9 +1,9 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <Kernel/Lock.h> |  | ||||||
| #include <AK/Types.h> | #include <AK/Types.h> | ||||||
| #include <Kernel/FileSystem/FileSystem.h> | #include <Kernel/FileSystem/FileSystem.h> | ||||||
| #include <Kernel/FileSystem/Inode.h> | #include <Kernel/FileSystem/Inode.h> | ||||||
|  | #include <Kernel/Lock.h> | ||||||
| 
 | 
 | ||||||
| class Process; | class Process; | ||||||
| 
 | 
 | ||||||
|  | @ -11,6 +11,7 @@ class ProcFSInode; | ||||||
| 
 | 
 | ||||||
| class ProcFS final : public FS { | class ProcFS final : public FS { | ||||||
|     friend class ProcFSInode; |     friend class ProcFSInode; | ||||||
|  | 
 | ||||||
| public: | public: | ||||||
|     [[gnu::pure]] static ProcFS& the(); |     [[gnu::pure]] static ProcFS& the(); | ||||||
| 
 | 
 | ||||||
|  | @ -69,6 +70,7 @@ struct ProcFSInodeCustomData { | ||||||
| 
 | 
 | ||||||
| class ProcFSInode final : public Inode { | class ProcFSInode final : public Inode { | ||||||
|     friend class ProcFS; |     friend class ProcFS; | ||||||
|  | 
 | ||||||
| public: | public: | ||||||
|     virtual ~ProcFSInode() override; |     virtual ~ProcFSInode() override; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,9 +1,9 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
|  | #include <AK/HashMap.h> | ||||||
| #include <Kernel/FileSystem/FileSystem.h> | #include <Kernel/FileSystem/FileSystem.h> | ||||||
| #include <Kernel/FileSystem/Inode.h> | #include <Kernel/FileSystem/Inode.h> | ||||||
| #include <Kernel/UnixTypes.h> | #include <Kernel/UnixTypes.h> | ||||||
| #include <AK/HashMap.h> |  | ||||||
| 
 | 
 | ||||||
| class SynthFSInode; | class SynthFSInode; | ||||||
| 
 | 
 | ||||||
|  | @ -47,6 +47,7 @@ struct SynthFSInodeCustomData { | ||||||
| class SynthFSInode final : public Inode { | class SynthFSInode final : public Inode { | ||||||
|     friend class SynthFS; |     friend class SynthFS; | ||||||
|     friend class DevPtsFS; |     friend class DevPtsFS; | ||||||
|  | 
 | ||||||
| public: | public: | ||||||
|     virtual ~SynthFSInode() override; |     virtual ~SynthFSInode() override; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,14 +1,14 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
|  | #include "FileSystem.h" | ||||||
|  | #include "InodeIdentifier.h" | ||||||
|  | #include "InodeMetadata.h" | ||||||
|  | #include <AK/AKString.h> | ||||||
|  | #include <AK/Function.h> | ||||||
| #include <AK/HashMap.h> | #include <AK/HashMap.h> | ||||||
| #include <AK/OwnPtr.h> | #include <AK/OwnPtr.h> | ||||||
| #include <AK/RetainPtr.h> | #include <AK/RetainPtr.h> | ||||||
| #include <AK/AKString.h> |  | ||||||
| #include <AK/Vector.h> | #include <AK/Vector.h> | ||||||
| #include <AK/Function.h> |  | ||||||
| #include "InodeIdentifier.h" |  | ||||||
| #include "InodeMetadata.h" |  | ||||||
| #include "FileSystem.h" |  | ||||||
| #include <Kernel/KResult.h> | #include <Kernel/KResult.h> | ||||||
| 
 | 
 | ||||||
| #define O_RDONLY 0 | #define O_RDONLY 0 | ||||||
|  | @ -116,4 +116,3 @@ private: | ||||||
|     Vector<OwnPtr<Mount>> m_mounts; |     Vector<OwnPtr<Mount>> m_mounts; | ||||||
|     HashMap<dword, Device*> m_devices; |     HashMap<dword, Device*> m_devices; | ||||||
| }; | }; | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -89,10 +89,8 @@ | ||||||
| #else | #else | ||||||
| #    define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size) | #    define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size) | ||||||
| #    define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10) | #    define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10) | ||||||
| #define EXT2_INODE_SIZE(s)	(((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \ | #    define EXT2_INODE_SIZE(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? EXT2_GOOD_OLD_INODE_SIZE : (s)->s_inode_size) | ||||||
| 				 EXT2_GOOD_OLD_INODE_SIZE : (s)->s_inode_size) | #    define EXT2_FIRST_INO(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? EXT2_GOOD_OLD_FIRST_INO : (s)->s_first_ino) | ||||||
| #define EXT2_FIRST_INO(s)	(((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \ |  | ||||||
| 				 EXT2_GOOD_OLD_FIRST_INO : (s)->s_first_ino) |  | ||||||
| #endif | #endif | ||||||
| #define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof(__u32)) | #define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof(__u32)) | ||||||
| 
 | 
 | ||||||
|  | @ -135,8 +133,7 @@ struct ext2_acl_entry	/* Access Control List Entry */ | ||||||
| /*
 | /*
 | ||||||
|  * Structure of a blocks group descriptor |  * Structure of a blocks group descriptor | ||||||
|  */ |  */ | ||||||
| struct ext2_group_desc | struct ext2_group_desc { | ||||||
| { |  | ||||||
|     __u32 bg_block_bitmap;      /* Blocks bitmap block */ |     __u32 bg_block_bitmap;      /* Blocks bitmap block */ | ||||||
|     __u32 bg_inode_bitmap;      /* Inodes bitmap block */ |     __u32 bg_inode_bitmap;      /* Inodes bitmap block */ | ||||||
|     __u32 bg_inode_table;       /* Inodes table block */ |     __u32 bg_inode_table;       /* Inodes table block */ | ||||||
|  | @ -149,8 +146,7 @@ struct ext2_group_desc | ||||||
|     __u16 bg_checksum;      /* crc16(s_uuid+grouo_num+group_desc)*/ |     __u16 bg_checksum;      /* crc16(s_uuid+grouo_num+group_desc)*/ | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| struct ext4_group_desc | struct ext4_group_desc { | ||||||
| { |  | ||||||
|     __u32 bg_block_bitmap;      /* Blocks bitmap block */ |     __u32 bg_block_bitmap;      /* Blocks bitmap block */ | ||||||
|     __u32 bg_inode_bitmap;      /* Inodes bitmap block */ |     __u32 bg_inode_bitmap;      /* Inodes bitmap block */ | ||||||
|     __u32 bg_inode_table;       /* Inodes table block */ |     __u32 bg_inode_table;       /* Inodes table block */ | ||||||
|  | @ -214,7 +210,6 @@ struct ext2_dx_countlimit { | ||||||
|     __u16 count; |     __u16 count; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| /*
 | /*
 | ||||||
|  * Macro-instructions used to manage group descriptors |  * Macro-instructions used to manage group descriptors | ||||||
|  */ |  */ | ||||||
|  | @ -222,8 +217,7 @@ struct ext2_dx_countlimit { | ||||||
| #define EXT2_MIN_DESC_SIZE_64BIT 64 | #define EXT2_MIN_DESC_SIZE_64BIT 64 | ||||||
| #define EXT2_MAX_DESC_SIZE EXT2_MIN_BLOCK_SIZE | #define EXT2_MAX_DESC_SIZE EXT2_MIN_BLOCK_SIZE | ||||||
| #define EXT2_DESC_SIZE(s) \ | #define EXT2_DESC_SIZE(s) \ | ||||||
|        ((EXT2_SB(s)->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT) ? \ |     ((EXT2_SB(s)->s_feature_incompat & EXT4_FEATURE_INCOMPAT_64BIT) ? (s)->s_desc_size : EXT2_MIN_DESC_SIZE) | ||||||
| 	(s)->s_desc_size : EXT2_MIN_DESC_SIZE) |  | ||||||
| 
 | 
 | ||||||
| #define EXT2_BLOCKS_PER_GROUP(s) (EXT2_SB(s)->s_blocks_per_group) | #define EXT2_BLOCKS_PER_GROUP(s) (EXT2_SB(s)->s_blocks_per_group) | ||||||
| #define EXT2_INODES_PER_GROUP(s) (EXT2_SB(s)->s_inodes_per_group) | #define EXT2_INODES_PER_GROUP(s) (EXT2_SB(s)->s_inodes_per_group) | ||||||
|  | @ -476,8 +470,7 @@ struct ext2_inode_large { | ||||||
| 
 | 
 | ||||||
| #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt | #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt | ||||||
| #define set_opt(o, opt) o |= EXT2_MOUNT_##opt | #define set_opt(o, opt) o |= EXT2_MOUNT_##opt | ||||||
| #define test_opt(sb, opt)		(EXT2_SB(sb)->s_mount_opt & \ | #define test_opt(sb, opt) (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_##opt) | ||||||
| 					 EXT2_MOUNT_##opt) |  | ||||||
| /*
 | /*
 | ||||||
|  * Maximal mount counts between two filesystem checks |  * Maximal mount counts between two filesystem checks | ||||||
|  */ |  */ | ||||||
|  | @ -644,13 +637,9 @@ struct ext2_super_block { | ||||||
| #define EXT4_FEATURE_INCOMPAT_MMP 0x0100 | #define EXT4_FEATURE_INCOMPAT_MMP 0x0100 | ||||||
| #define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200 | #define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200 | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| #define EXT2_FEATURE_COMPAT_SUPP 0 | #define EXT2_FEATURE_COMPAT_SUPP 0 | ||||||
| #define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE) | #define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE) | ||||||
| #define EXT2_FEATURE_RO_COMPAT_SUPP	(EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \ | #define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER | EXT2_FEATURE_RO_COMPAT_LARGE_FILE | EXT4_FEATURE_RO_COMPAT_DIR_NLINK | EXT2_FEATURE_RO_COMPAT_BTREE_DIR) | ||||||
| 					 EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \ |  | ||||||
| 					 EXT4_FEATURE_RO_COMPAT_DIR_NLINK| \ |  | ||||||
| 					 EXT2_FEATURE_RO_COMPAT_BTREE_DIR) |  | ||||||
| 
 | 
 | ||||||
| /*
 | /*
 | ||||||
|  * Default values for user and/or group using reserved blocks |  * Default values for user and/or group using reserved blocks | ||||||
|  | @ -719,8 +708,7 @@ struct ext2_dir_entry_2 { | ||||||
|  */ |  */ | ||||||
| #define EXT2_DIR_PAD 4 | #define EXT2_DIR_PAD 4 | ||||||
| #define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1) | #define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1) | ||||||
| #define EXT2_DIR_REC_LEN(name_len)	(((name_len) + 8 + EXT2_DIR_ROUND) & \ | #define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & ~EXT2_DIR_ROUND) | ||||||
| 					 ~EXT2_DIR_ROUND) |  | ||||||
| 
 | 
 | ||||||
| /*
 | /*
 | ||||||
|  * This structure will be used for multiple mount protection. It will be |  * This structure will be used for multiple mount protection. It will be | ||||||
|  |  | ||||||
|  | @ -3,8 +3,7 @@ | ||||||
|  * everything we need.  (cross fingers)  Other header files may have  |  * everything we need.  (cross fingers)  Other header files may have  | ||||||
|  * also defined the types that we need. |  * also defined the types that we need. | ||||||
|  */ |  */ | ||||||
| #if (!defined(_LINUX_TYPES_H) && !defined(_BLKID_TYPES_H) && \ | #if (!defined(_LINUX_TYPES_H) && !defined(_BLKID_TYPES_H) && !defined(_EXT2_TYPES_H)) | ||||||
| 	!defined(_EXT2_TYPES_H)) |  | ||||||
| #    define _EXT2_TYPES_H | #    define _EXT2_TYPES_H | ||||||
| 
 | 
 | ||||||
| #    define __S8_TYPEDEF __signed__ char | #    define __S8_TYPEDEF __signed__ char | ||||||
|  | @ -51,12 +50,12 @@ typedef	int		__s16; | ||||||
| #            if (2 == 2) | #            if (2 == 2) | ||||||
| typedef short __s16; | typedef short __s16; | ||||||
| #            else | #            else | ||||||
|   ?==error: undefined 16 bit type |         ? == error | ||||||
|  |         : undefined 16 bit type | ||||||
| #            endif /* SIZEOF_SHORT == 2 */ | #            endif /* SIZEOF_SHORT == 2 */ | ||||||
| #        endif     /* SIZEOF_INT == 2 */ | #        endif     /* SIZEOF_INT == 2 */ | ||||||
| #    endif         /* __S16_TYPEDEF */ | #    endif         /* __S16_TYPEDEF */ | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| #    ifdef __U32_TYPEDEF | #    ifdef __U32_TYPEDEF | ||||||
| typedef __U32_TYPEDEF __u32; | typedef __U32_TYPEDEF __u32; | ||||||
| #    else | #    else | ||||||
|  | @ -69,7 +68,8 @@ typedef	unsigned long	__u32; | ||||||
| #                if (2 == 4) | #                if (2 == 4) | ||||||
|         typedef unsigned short __u32; |         typedef unsigned short __u32; | ||||||
| #                else | #                else | ||||||
|  ?== error: undefined 32 bit type |             ? == error | ||||||
|  |             : undefined 32 bit type | ||||||
| #                endif /* SIZEOF_SHORT == 4 */ | #                endif /* SIZEOF_SHORT == 4 */ | ||||||
| #            endif     /* SIZEOF_LONG == 4 */ | #            endif     /* SIZEOF_LONG == 4 */ | ||||||
| #        endif         /* SIZEOF_INT == 4 */ | #        endif         /* SIZEOF_INT == 4 */ | ||||||
|  | @ -87,7 +87,8 @@ typedef	long		__s32; | ||||||
| #                if (2 == 4) | #                if (2 == 4) | ||||||
| typedef short __s32; | typedef short __s32; | ||||||
| #                else | #                else | ||||||
|  ?== error: undefined 32 bit type |                 ? == error | ||||||
|  |                 : undefined 32 bit type | ||||||
| #                endif /* SIZEOF_SHORT == 4 */ | #                endif /* SIZEOF_SHORT == 4 */ | ||||||
| #            endif     /* SIZEOF_LONG == 4 */ | #            endif     /* SIZEOF_LONG == 4 */ | ||||||
| #        endif         /* SIZEOF_INT == 4 */ | #        endif         /* SIZEOF_INT == 4 */ | ||||||
|  |  | ||||||
							
								
								
									
										21
									
								
								Kernel/IO.h
									
										
									
									
									
								
							
							
						
						
									
										21
									
								
								Kernel/IO.h
									
										
									
									
									
								
							|  | @ -7,27 +7,36 @@ namespace IO { | ||||||
| inline byte in8(word port) | inline byte in8(word port) | ||||||
| { | { | ||||||
|     byte value; |     byte value; | ||||||
|     asm volatile("inb %1, %0":"=a"(value):"Nd"(port)); |     asm volatile("inb %1, %0" | ||||||
|  |                  : "=a"(value) | ||||||
|  |                  : "Nd"(port)); | ||||||
|     return value; |     return value; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| inline word in16(word port) | inline word in16(word port) | ||||||
| { | { | ||||||
|     word value; |     word value; | ||||||
|     asm volatile("inw %1, %0":"=a"(value):"Nd"(port)); |     asm volatile("inw %1, %0" | ||||||
|  |                  : "=a"(value) | ||||||
|  |                  : "Nd"(port)); | ||||||
|     return value; |     return value; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| inline dword in32(word port) | inline dword in32(word port) | ||||||
| { | { | ||||||
|     dword value; |     dword value; | ||||||
|     asm volatile("inl %1, %0":"=a"(value):"Nd"(port)); |     asm volatile("inl %1, %0" | ||||||
|  |                  : "=a"(value) | ||||||
|  |                  : "Nd"(port)); | ||||||
|     return value; |     return value; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| inline void repeated_in16(word port, byte* buffer, int buffer_size) | inline void repeated_in16(word port, byte* buffer, int buffer_size) | ||||||
| { | { | ||||||
|     asm volatile("rep insw" : "+D"(buffer), "+c"(buffer_size) : "d"(port) : "memory"); |     asm volatile("rep insw" | ||||||
|  |                  : "+D"(buffer), "+c"(buffer_size) | ||||||
|  |                  : "d"(port) | ||||||
|  |                  : "memory"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| inline void out8(word port, byte value) | inline void out8(word port, byte value) | ||||||
|  | @ -47,7 +56,9 @@ inline void out32(word port, dword value) | ||||||
| 
 | 
 | ||||||
| inline void repeated_out16(word port, const byte* data, int data_size) | inline void repeated_out16(word port, const byte* data, int data_size) | ||||||
| { | { | ||||||
|     asm volatile("rep outsw" : "+S"(data), "+c"(data_size) : "d"(port)); |     asm volatile("rep outsw" | ||||||
|  |                  : "+S"(data), "+c"(data_size) | ||||||
|  |                  : "d"(port)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -18,4 +18,3 @@ protected: | ||||||
| private: | private: | ||||||
|     byte m_irq_number { 0 }; |     byte m_irq_number { 0 }; | ||||||
| }; | }; | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -3,19 +3,30 @@ | ||||||
| #include <AK/Assertions.h> | #include <AK/Assertions.h> | ||||||
| #include <LibC/errno_numbers.h> | #include <LibC/errno_numbers.h> | ||||||
| 
 | 
 | ||||||
| enum KSuccessTag { KSuccess }; | enum KSuccessTag | ||||||
|  | { | ||||||
|  |     KSuccess | ||||||
|  | }; | ||||||
| 
 | 
 | ||||||
| class KResult { | class KResult { | ||||||
| public: | public: | ||||||
|     explicit KResult(int negative_e) : m_error(negative_e) { ASSERT(negative_e <= 0); } |     explicit KResult(int negative_e) | ||||||
|     KResult(KSuccessTag) : m_error(0) { } |         : m_error(negative_e) | ||||||
|  |     { | ||||||
|  |         ASSERT(negative_e <= 0); | ||||||
|  |     } | ||||||
|  |     KResult(KSuccessTag) | ||||||
|  |         : m_error(0) | ||||||
|  |     { | ||||||
|  |     } | ||||||
|     operator int() const { return m_error; } |     operator int() const { return m_error; } | ||||||
| 
 | 
 | ||||||
|     bool is_success() const { return m_error == ESUCCESS; } |     bool is_success() const { return m_error == ESUCCESS; } | ||||||
|     bool is_error() const { return !is_success(); } |     bool is_error() const { return !is_success(); } | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     template<typename T> friend class KResultOr; |     template<typename T> | ||||||
|  |     friend class KResultOr; | ||||||
|     KResult() {} |     KResult() {} | ||||||
| 
 | 
 | ||||||
|     int m_error { 0 }; |     int m_error { 0 }; | ||||||
|  | @ -27,7 +38,8 @@ public: | ||||||
|     KResultOr(KResult error) |     KResultOr(KResult error) | ||||||
|         : m_error(error) |         : m_error(error) | ||||||
|         , m_is_error(true) |         , m_is_error(true) | ||||||
|     { } |     { | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     KResultOr(T&& value) |     KResultOr(T&& value) | ||||||
|     { |     { | ||||||
|  | @ -54,9 +66,21 @@ public: | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     bool is_error() const { return m_is_error; } |     bool is_error() const { return m_is_error; } | ||||||
|     KResult error() const { ASSERT(m_is_error); return m_error; } |     KResult error() const | ||||||
|     T& value() { ASSERT(!m_is_error); return *reinterpret_cast<T*>(&m_storage); } |     { | ||||||
|     const T& value() const { ASSERT(!m_is_error); return *reinterpret_cast<T*>(&m_storage); } |         ASSERT(m_is_error); | ||||||
|  |         return m_error; | ||||||
|  |     } | ||||||
|  |     T& value() | ||||||
|  |     { | ||||||
|  |         ASSERT(!m_is_error); | ||||||
|  |         return *reinterpret_cast<T*>(&m_storage); | ||||||
|  |     } | ||||||
|  |     const T& value() const | ||||||
|  |     { | ||||||
|  |         ASSERT(!m_is_error); | ||||||
|  |         return *reinterpret_cast<T*>(&m_storage); | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     T release_value() |     T release_value() | ||||||
|     { |     { | ||||||
|  | @ -71,4 +95,3 @@ private: | ||||||
|     KResult m_error; |     KResult m_error; | ||||||
|     bool m_is_error { false }; |     bool m_is_error { false }; | ||||||
| }; | }; | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -2,7 +2,8 @@ | ||||||
| 
 | 
 | ||||||
| #include <AK/Types.h> | #include <AK/Types.h> | ||||||
| 
 | 
 | ||||||
| enum KeyCode : byte { | enum KeyCode : byte | ||||||
|  | { | ||||||
|     Key_Invalid = 0, |     Key_Invalid = 0, | ||||||
|     Key_Escape, |     Key_Escape, | ||||||
|     Key_Tab, |     Key_Tab, | ||||||
|  | @ -113,7 +114,8 @@ enum KeyCode : byte { | ||||||
|     Key_Shift = Key_LeftShift, |     Key_Shift = Key_LeftShift, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| enum KeyModifier { | enum KeyModifier | ||||||
|  | { | ||||||
|     Mod_None = 0x00, |     Mod_None = 0x00, | ||||||
|     Mod_Alt = 0x01, |     Mod_Alt = 0x01, | ||||||
|     Mod_Ctrl = 0x02, |     Mod_Ctrl = 0x02, | ||||||
|  |  | ||||||
|  | @ -5,7 +5,10 @@ | ||||||
| class LinearAddress { | class LinearAddress { | ||||||
| public: | public: | ||||||
|     LinearAddress() {} |     LinearAddress() {} | ||||||
|     explicit LinearAddress(dword address) : m_address(address) { } |     explicit LinearAddress(dword address) | ||||||
|  |         : m_address(address) | ||||||
|  |     { | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     bool is_null() const { return m_address == 0; } |     bool is_null() const { return m_address == 0; } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -2,9 +2,9 @@ | ||||||
| 
 | 
 | ||||||
| #include <AK/Assertions.h> | #include <AK/Assertions.h> | ||||||
| #include <AK/Types.h> | #include <AK/Types.h> | ||||||
| #include <Kernel/i386.h> |  | ||||||
| #include <Kernel/Scheduler.h> |  | ||||||
| #include <Kernel/KSyms.h> | #include <Kernel/KSyms.h> | ||||||
|  | #include <Kernel/Scheduler.h> | ||||||
|  | #include <Kernel/i386.h> | ||||||
| 
 | 
 | ||||||
| class Thread; | class Thread; | ||||||
| extern Thread* current; | extern Thread* current; | ||||||
|  | @ -22,7 +22,10 @@ static inline dword CAS(volatile dword* mem, dword newval, dword oldval) | ||||||
| 
 | 
 | ||||||
| class Lock { | class Lock { | ||||||
| public: | public: | ||||||
|     Lock(const char* name = nullptr) : m_name(name) { } |     Lock(const char* name = nullptr) | ||||||
|  |         : m_name(name) | ||||||
|  |     { | ||||||
|  |     } | ||||||
|     ~Lock() {} |     ~Lock() {} | ||||||
| 
 | 
 | ||||||
|     void lock(); |     void lock(); | ||||||
|  | @ -40,7 +43,11 @@ private: | ||||||
| 
 | 
 | ||||||
| class Locker { | class Locker { | ||||||
| public: | public: | ||||||
|     [[gnu::always_inline]] inline explicit Locker(Lock& l) : m_lock(l) { lock(); } |     [[gnu::always_inline]] inline explicit Locker(Lock& l) | ||||||
|  |         : m_lock(l) | ||||||
|  |     { | ||||||
|  |         lock(); | ||||||
|  |     } | ||||||
|     [[gnu::always_inline]] inline ~Locker() { unlock(); } |     [[gnu::always_inline]] inline ~Locker() { unlock(); } | ||||||
|     [[gnu::always_inline]] inline void unlock() { m_lock.unlock(); } |     [[gnu::always_inline]] inline void unlock() { m_lock.unlock(); } | ||||||
|     [[gnu::always_inline]] inline void lock() { m_lock.lock(); } |     [[gnu::always_inline]] inline void lock() { m_lock.lock(); } | ||||||
|  | @ -124,7 +131,10 @@ template<typename T> | ||||||
| class Lockable { | class Lockable { | ||||||
| public: | public: | ||||||
|     Lockable() {} |     Lockable() {} | ||||||
|     Lockable(T&& resource) : m_resource(move(resource)) { } |     Lockable(T&& resource) | ||||||
|  |         : m_resource(move(resource)) | ||||||
|  |     { | ||||||
|  |     } | ||||||
|     Lock& lock() { return m_lock; } |     Lock& lock() { return m_lock; } | ||||||
|     T& resource() { return m_resource; } |     T& resource() { return m_resource; } | ||||||
| 
 | 
 | ||||||
|  | @ -138,4 +148,3 @@ private: | ||||||
|     T m_resource; |     T m_resource; | ||||||
|     Lock m_lock; |     Lock m_lock; | ||||||
| }; | }; | ||||||
| 
 |  | ||||||
|  |  | ||||||
Some files were not shown because too many files have changed in this diff Show more
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Robin Burchell
						Robin Burchell