CMake: MSVC: Add natvis file for blender's native types

This currently contains some types I personally needed
more types can be added if people desire them.

Due to the .natvis being added to creator, Visual Studio
will automatically pick up on these types and show the
improved visualizers while debugging.

vscode can also use this file, but you'll have to check
its documentation on how to set that up.

Pull Request: https://projects.blender.org/blender/blender/pulls/118576
This commit is contained in:
Ray Molenkamp 2024-02-27 01:02:42 +01:00 committed by Ray molenkamp
parent 7c0a22cdaf
commit cfb60c98be
2 changed files with 63 additions and 0 deletions

@ -152,6 +152,11 @@ set(SRC
creator_intern.h
)
if(CMAKE_GENERATOR MATCHES "^Visual Studio.+")
# This helps visual studio find the debugger visualizers
list(APPEND SRC ${CMAKE_SOURCE_DIR}/tools/utils_ide/natvis/Blender.natvis)
endif()
# MSVC 2010 gives linking errors with the manifest.
if(WIN32 AND NOT UNIX)
add_definitions(

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="blender::StringRef">
<DisplayString>{data_,[size_]s} (size={size_})</DisplayString>
</Type>
<Type Name="blender::Vector&lt;*&gt;">
<DisplayString>{{size={end_ - begin_}}}</DisplayString>
<Expand>
<Item Name="[size]" ExcludeView="simple"> end_ - begin_</Item>
<Item Name="[capacity]" ExcludeView="simple">capacity_end_ - begin_</Item>
<ArrayItems>
<Size>end_ - begin_</Size>
<ValuePointer>begin_</ValuePointer>
</ArrayItems>
</Expand>
</Type>
<Type Name="blender::Span&lt;*&gt;">
<DisplayString>{{size={size_ }}}</DisplayString>
<Expand>
<Item Name="[size]" ExcludeView="simple"> size_</Item>
<ArrayItems>
<Size>size_</Size>
<ValuePointer>data_</ValuePointer>
</ArrayItems>
</Expand>
</Type>
<Type Name="blender::VecBase&lt;*,3&gt;">
<DisplayString>{{x={x}, y={y}, z={z}}}</DisplayString>
</Type>
<Type Name="blender::Array&lt;*&gt;">
<DisplayString>{{size={size_ }}}</DisplayString>
<Expand>
<Item Name="[size]" ExcludeView="simple"> size_</Item>
<ArrayItems>
<Size>size_</Size>
<ValuePointer>data_</ValuePointer>
</ArrayItems>
</Expand>
</Type>
<Type Name="blender::Map&lt;*&gt;">
<DisplayString>Size={occupied_and_removed_slots_ - removed_slots_}</DisplayString>
<Expand>
<CustomListItems>
<Variable Name="slot" InitialValue="slots_.data_"/>
<Variable Name="i" InitialValue="0"/>
<Loop>
<Item Condition="slot-&gt;state_ == 1" Name="{slot-&gt;key_buffer_}">slot-&gt;value_buffer_</Item>
<Exec>++slot</Exec>
<Exec>++i</Exec>
<Break Condition="i &gt; slots_.size_"/>
</Loop>
</CustomListItems>
</Expand>
</Type>
<Type Name="blender::TypedBuffer&lt;*,*&gt;">
<DisplayString>{*($T1*)buffer_.buffer_.buffer_}</DisplayString>
</Type>
</AutoVisualizer>