Skip to content

Commit 9ce63df

Browse files
author
Julian LALU
committed
Update natvis
1 parent 836f5cd commit 9ce63df

File tree

2 files changed

+45
-42
lines changed

2 files changed

+45
-42
lines changed

core.natvis

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
33
<!-- hud::memory_allocation<T> -->
44
<Type Name="hud::memory_allocation&lt;*&gt;">
5-
<DisplayString>{{Size = { end_ptr - begin_ptr }}}</DisplayString>
5+
<DisplayString>Ptr = {begin_ptr_}</DisplayString>
66
<Expand>
7-
<Item Name="Size">end_ptr - begin_ptr</Item>
7+
<Item Name="size">end_ptr_ - begin_ptr_</Item>
88
<ArrayItems>
9-
<Size> end_ptr - begin_ptr </Size>
10-
<ValuePointer> begin_ptr </ValuePointer>
9+
<Size> end_ptr_ - begin_ptr_ </Size>
10+
<ValuePointer> begin_ptr_ </ValuePointer>
1111
</ArrayItems>
1212
</Expand>
1313
</Type>
14+
1415
<!-- hud::optional<T> -->
1516
<Type Name="hud::optional&lt;*&gt;">
1617
<DisplayString Condition="some == true">Value: {some_value}</DisplayString>
@@ -46,15 +47,17 @@
4647
<Item Name="second">($T2*)this</Item>
4748
</Expand>
4849
</Type>
50+
4951
<!-- hud::vector<T> -->
50-
<!-- <Type Name="hud::vector&lt;*&gt;">
51-
<DisplayString>{{Size = { end_ptr - begin_ptr }}}</DisplayString>
52-
<Expand>
53-
<Item Name="Size">end_ptr - begin_ptr</Item>
54-
<ArrayItems>
55-
<Size> end_ptr - begin_ptr </Size>
56-
<ValuePointer> begin_ptr </ValuePointer>
57-
</ArrayItems>
58-
</Expand>
59-
</Type> -->
52+
<Type Name="hud::vector&lt;*&gt;">
53+
<DisplayString Condition ="compressed_allocator_.type_2_.end_ptr_ - compressed_allocator_.type_2_.begin_ptr_ == 0"> Size = {compressed_allocator_.type_2_.end_ptr_ - compressed_allocator_.type_2_.begin_ptr_}</DisplayString>
54+
<DisplayString Condition ="compressed_allocator_.type_2_.end_ptr_ - compressed_allocator_.type_2_.begin_ptr_ > 0"> Size = {compressed_allocator_.type_2_.end_ptr_ - compressed_allocator_.type_2_.begin_ptr_}, Ptr = {compressed_allocator_.type_2_.begin_ptr_} </DisplayString>
55+
<Expand>
56+
<Item Condition="compressed_allocator_.type_2_.end_ptr_ - compressed_allocator_.type_2_.begin_ptr_ > 0" Name="Size">compressed_allocator_.type_2_.end_ptr_ - compressed_allocator_.type_2_.begin_ptr_</Item>
57+
<ArrayItems>
58+
<Size>compressed_allocator_.type_2_.end_ptr_ - compressed_allocator_.type_2_.begin_ptr_</Size>
59+
<ValuePointer>compressed_allocator_.type_2_.begin_ptr_</ValuePointer>
60+
</ArrayItems>
61+
</Expand>
62+
</Type>
6063
</AutoVisualizer>

interface/core/allocators/memory_allocation.h

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ namespace hud
3939
* @param end The pointer one past the last element of the contiguous sequence
4040
*/
4141
HD_FORCEINLINE constexpr memory_allocation(type_t *begin, type_t *end) noexcept
42-
: begin_ptr(begin)
43-
, end_ptr(end)
42+
: begin_ptr_(begin)
43+
, end_ptr_(end)
4444
{
4545
}
4646

@@ -50,8 +50,8 @@ namespace hud
5050
* @param count The count of elements in the sequence
5151
*/
5252
HD_FORCEINLINE constexpr memory_allocation(type_t *first, const usize count) noexcept
53-
: begin_ptr(first)
54-
, end_ptr(first + count)
53+
: begin_ptr_(first)
54+
, end_ptr_(first + count)
5555
{
5656
}
5757

@@ -62,8 +62,8 @@ namespace hud
6262
*/
6363
template<typename u_type_t>
6464
HD_FORCEINLINE constexpr memory_allocation(u_type_t *first, const usize count) noexcept
65-
: begin_ptr(first)
66-
, end_ptr(first + count)
65+
: begin_ptr_(first)
66+
, end_ptr_(first + count)
6767
{
6868
}
6969

@@ -72,11 +72,11 @@ namespace hud
7272
* @param other The `memory_allocation` to be moved
7373
*/
7474
HD_FORCEINLINE constexpr memory_allocation(memory_allocation &&other) noexcept
75-
: begin_ptr(other.begin_ptr)
76-
, end_ptr(other.end_ptr)
75+
: begin_ptr_(other.begin_ptr_)
76+
, end_ptr_(other.end_ptr_)
7777
{
78-
other.begin_ptr = nullptr;
79-
other.end_ptr = nullptr;
78+
other.begin_ptr_ = nullptr;
79+
other.end_ptr_ = nullptr;
8080
}
8181

8282
/**
@@ -88,10 +88,10 @@ namespace hud
8888
{
8989
if (this != &other) [[likely]]
9090
{
91-
begin_ptr = other.begin_ptr;
92-
other.begin_ptr = nullptr;
93-
end_ptr = other.end_ptr;
94-
other.end_ptr = nullptr;
91+
begin_ptr_ = other.begin_ptr_;
92+
other.begin_ptr_ = nullptr;
93+
end_ptr_ = other.end_ptr_;
94+
other.end_ptr_ = nullptr;
9595
}
9696
return *this;
9797
}
@@ -102,8 +102,8 @@ namespace hud
102102
*/
103103
HD_FORCEINLINE constexpr void leak() noexcept
104104
{
105-
begin_ptr = nullptr;
106-
end_ptr = nullptr;
105+
begin_ptr_ = nullptr;
106+
end_ptr_ = nullptr;
107107
}
108108

109109
/**
@@ -120,19 +120,19 @@ namespace hud
120120
/** Checks if the `memory_allocation` is empty. */
121121
[[nodiscard]] HD_FORCEINLINE constexpr bool is_empty() const noexcept
122122
{
123-
return begin_ptr == end_ptr;
123+
return begin_ptr_ == end_ptr_;
124124
}
125125

126126
/** Retrieves a pointer to the beginning of the sequence. */
127127
[[nodiscard]] HD_FORCEINLINE constexpr type_t *data() const noexcept
128128
{
129-
return begin_ptr;
129+
return begin_ptr_;
130130
}
131131

132132
/** Retrieves a pointer to the end of the sequence. */
133133
[[nodiscard]] HD_FORCEINLINE constexpr type_t *data_end() const noexcept
134134
{
135-
return end_ptr;
135+
return end_ptr_;
136136
}
137137

138138
/**
@@ -143,14 +143,14 @@ namespace hud
143143
*/
144144
[[nodiscard]] constexpr type_t *data_at(const usize index) const noexcept
145145
{
146-
check(begin_ptr + index <= end_ptr);
146+
check(begin_ptr_ + index <= end_ptr_);
147147
return data() + index;
148148
}
149149

150150
/** Retrieves the count of elements in the `memory_allocation`. */
151151
[[nodiscard]] HD_FORCEINLINE constexpr usize count() const noexcept
152152
{
153-
return static_cast<usize>(end_ptr - begin_ptr);
153+
return static_cast<usize>(end_ptr_ - begin_ptr_);
154154
}
155155

156156
/** Retrieves the count of bytes in the `memory_allocation`. */
@@ -162,7 +162,7 @@ namespace hud
162162
/** Checks whether `index` is in a valid range. */
163163
[[nodiscard]] HD_FORCEINLINE constexpr bool is_valid_index(const usize index) const noexcept
164164
{
165-
return begin_ptr + index < end_ptr;
165+
return begin_ptr_ + index < end_ptr_;
166166
}
167167

168168
/**
@@ -176,7 +176,7 @@ namespace hud
176176
[[nodiscard]] memory_allocation<u_type_t> HD_FORCEINLINE reinterpret_cast_to() const noexcept
177177
{
178178
static_assert(alignof(u_type_t) == alignof(type_t), "Alignement requirement mismatch");
179-
return memory_allocation<u_type_t> {reinterpret_cast<u_type_t *>(begin_ptr), reinterpret_cast<u_type_t *>(end_ptr)};
179+
return memory_allocation<u_type_t> {reinterpret_cast<u_type_t *>(begin_ptr_), reinterpret_cast<u_type_t *>(end_ptr_)};
180180
}
181181

182182
/**
@@ -195,19 +195,19 @@ namespace hud
195195
/** Convert the allocation to a slice. */
196196
[[nodiscard]] HD_FORCEINLINE constexpr slice<type_t> to_slice() const noexcept
197197
{
198-
return slice(begin_ptr, count());
198+
return slice(begin_ptr_, count());
199199
}
200200

201201
/** Retrieves an iterator_type to the beginning of the slice. */
202202
[[nodiscard]] HD_FORCEINLINE constexpr iterator_type begin() const noexcept
203203
{
204-
return iterator_type(begin_ptr);
204+
return iterator_type(begin_ptr_);
205205
}
206206

207207
/** Retrieves an iterator_type to the end of the slice. */
208208
[[nodiscard]] HD_FORCEINLINE constexpr iterator_type end() const noexcept
209209
{
210-
return iterator_type(end_ptr);
210+
return iterator_type(end_ptr_);
211211
}
212212

213213
private:
@@ -216,9 +216,9 @@ namespace hud
216216

217217
private:
218218
/** Pointer to the first element */
219-
pointer_type HD_RESTRICT begin_ptr = nullptr;
219+
pointer_type HD_RESTRICT begin_ptr_ = nullptr;
220220
/** Number of element */
221-
pointer_type HD_RESTRICT end_ptr = nullptr;
221+
pointer_type HD_RESTRICT end_ptr_ = nullptr;
222222
};
223223

224224
} // namespace hud

0 commit comments

Comments
 (0)