Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyuu17 committed Jun 6, 2024
0 parents commit ec91f8e
Show file tree
Hide file tree
Showing 41 changed files with 3,003 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 4
tab_width = 4

[{*.cpp,*.hpp}]
cpp_indent_braces = false
cpp_indent_multi_line_relative_to = innermost_parenthesis
cpp_indent_within_parentheses = indent
cpp_indent_preserve_within_parentheses = true
cpp_indent_case_labels = true
cpp_indent_case_contents = true
cpp_indent_case_contents_when_block = false
cpp_indent_lambda_braces_when_parameter = true
cpp_indent_goto_labels = one_left
cpp_indent_preprocessor = leftmost_column
cpp_indent_access_specifiers = false
cpp_indent_namespace_contents = true
cpp_indent_preserve_comments = true
cpp_new_line_before_open_brace_namespace = ignore
cpp_new_line_before_open_brace_type = ignore
cpp_new_line_before_open_brace_function = ignore
cpp_new_line_before_open_brace_block = ignore
cpp_new_line_before_open_brace_lambda = ignore
cpp_space_within_parentheses = remove
cpp_space_before_parentheses = remove
cpp_space_within_empty_parentheses = remove
cpp_space_between_empty_square_brackets = remove
cpp_space_within_square_brackets = remove
cpp_space_in_lambda_square_brackets = remove
cpp_space_before_comma = remove
cpp_space_after_comma = insert
cpp_space_remove_around_member_operators = false
cpp_space_before_and_after_binary_operators = insert
cpp_space_around_assignment_operators = insert
cpp_space_pointer_reference_alignment = right
cpp_space_around_ternary_operator = insert
cpp_wrap_preserve_blocks = one_line
96 changes: 96 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Main

on:
push:
paths-ignore:
- '.gitignore'
- '*.md'

jobs:
lint:
name: 🧹 Lint / 📜 C++
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run clang-format style check
uses: jidicula/[email protected]
with:
clang-format-version: '15'
exclude-regex: 'extern'

build:
strategy:
fail-fast: false
matrix:
build_type: ['Debug', 'Release']
config:
- { name: '🍏 macOS Clang', os: macos-latest }
- { name: '🐧 Linux GCC', os: ubuntu-latest }
- { name: '🪟 Windows MSVC', os: windows-latest }

name: 🛠 Build / ${{ matrix.config.name }} (${{ matrix.build_type }})
runs-on: ${{ matrix.config.os }}

steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Install Dependencies (macOS)
if: matrix.config.os == 'macos-latest'
run: brew install ccache ninja

- name: Install Dependencies (Linux)
if: matrix.config.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y ccache ninja-build
- name: Install Dependencies (Windows)
if: matrix.config.os == 'windows-latest'
run: |
choco upgrade ccache ninja
- name: Setup MSVC (Windows)
if: matrix.config.os == 'windows-latest'
uses: ilammy/msvc-dev-cmd@v1

- name: ccache
uses: hendrikmuhs/[email protected]
with:
max-size: '10G'
key: ${{ matrix.config.os }}-${{ matrix.build_type }}

- name: Configure
run: >
mkdir GDExtension-build
cmake
-B GDExtension-build
-G "Ninja"
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
--install-prefix ${{ github.workspace }}/install-${{ matrix.build_type }}
.
- name: Build
run: cmake --build GDExtension-build

- name: Install
run: cmake --install GDExtension-build

- name: Upload artifact (Debug)
if: matrix.build_type == 'Debug'
uses: actions/upload-artifact@v3
with:
name: ${{ github.event.repository.name }}-Debug
path: |
${{ github.workspace }}/install-${{ matrix.build_type }}/*
- name: Upload artifact (Release)
if: matrix.build_type == 'Release'
uses: actions/upload-artifact@v3
with:
name: ${{ github.event.repository.name }}-Release
path: |
${{ github.workspace }}/install-${{ matrix.build_type }}/*
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CMakeLists.txt.user
.vscode/settings.json
.vs/

build/
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "extern/godot-cpp"]
path = extern/godot-cpp
url = https://github.com/godotengine/godot-cpp.git
[submodule "extern/gsl"]
path = extern/gsl
url = https://github.com/microsoft/GSL.git
6 changes: 6 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"recommendations": [
"ms-vscode.cpptools-extension-pack",
"ms-vscode.cmake-tools"
]
}
210 changes: 210 additions & 0 deletions .vscode/godot.natvis
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="Vector&lt;*&gt;">
<Expand>
<Item Name="[size]">_cowdata._ptr ? (((const unsigned int *)(_cowdata._ptr))[-1]) : 0</Item>
<ArrayItems>
<Size>_cowdata._ptr ? (((const unsigned int *)(_cowdata._ptr))[-1]) : 0</Size>
<ValuePointer>_cowdata._ptr</ValuePointer>
</ArrayItems>
</Expand>
</Type>

<Type Name="LocalVector&lt;*&gt;">
<Expand>
<Item Name="[size]">count</Item>
<ArrayItems>
<Size>count</Size>
<ValuePointer>data</ValuePointer>
</ArrayItems>
</Expand>
</Type>

<Type Name="List&lt;*&gt;">
<Expand>
<Item Name="[size]">_data ? (_data->size_cache) : 0</Item>
<LinkedListItems>
<Size>_data ? (_data->size_cache) : 0</Size>
<HeadPointer>_data->first</HeadPointer>
<NextPointer>next_ptr</NextPointer>
<ValueNode>value</ValueNode>
</LinkedListItems>
</Expand>
</Type>

<Type Name="HashMap&lt;*,*&gt;">
<Expand>
<Item Name="[size]">num_elements</Item>
<LinkedListItems>
<Size>num_elements</Size>
<HeadPointer>head_element</HeadPointer>
<NextPointer>next</NextPointer>
<ValueNode>data</ValueNode>
</LinkedListItems>
</Expand>
</Type>

<Type Name="VMap&lt;*,*&gt;">
<Expand>
<Item Condition="_cowdata._ptr" Name="[size]">*(reinterpret_cast&lt;int*&gt;(_cowdata._ptr) - 1)</Item>
<ArrayItems Condition="_cowdata._ptr">
<Size>*(reinterpret_cast&lt;int*&gt;(_cowdata._ptr) - 1)</Size>
<ValuePointer>reinterpret_cast&lt;VMap&lt;$T1,$T2&gt;::Pair*&gt;(_cowdata._ptr)</ValuePointer>
</ArrayItems>
</Expand>
</Type>

<Type Name="VMap&lt;Callable,*&gt;::Pair">
<DisplayString Condition="dynamic_cast&lt;CallableCustomMethodPointerBase*&gt;(key.custom)">{dynamic_cast&lt;CallableCustomMethodPointerBase*&gt;(key.custom)->text}</DisplayString>
</Type>

<!-- requires PR 64364
<Type Name="GDScriptThreadContext">
<DisplayString Condition="_is_main == true">main thread {_debug_thread_id}</DisplayString>
</Type>
-->

<Type Name="Variant">
<DisplayString Condition="type == Variant::NIL">nil</DisplayString>
<DisplayString Condition="type == Variant::BOOL">{_data._bool}</DisplayString>
<DisplayString Condition="type == Variant::INT">{_data._int}</DisplayString>
<DisplayString Condition="type == Variant::FLOAT">{_data._float}</DisplayString>
<DisplayString Condition="type == Variant::TRANSFORM2D">{_data._transform2d}</DisplayString>
<DisplayString Condition="type == Variant::AABB">{_data._aabb}</DisplayString>
<DisplayString Condition="type == Variant::BASIS">{_data._basis}</DisplayString>
<DisplayString Condition="type == Variant::TRANSFORM3D">{_data._transform3d}</DisplayString>
<DisplayString Condition="type == Variant::PROJECTION">{_data._projection}</DisplayString>
<DisplayString Condition="type == Variant::STRING">{*(String *)_data._mem}</DisplayString>
<DisplayString Condition="type == Variant::VECTOR2">{*(Vector2 *)_data._mem}</DisplayString>
<DisplayString Condition="type == Variant::RECT2">{*(Rect2 *)_data._mem}</DisplayString>
<DisplayString Condition="type == Variant::VECTOR3">{*(Vector3 *)_data._mem}</DisplayString>
<DisplayString Condition="type == Variant::VECTOR4">{*(Vector4 *)_data._mem}</DisplayString>
<DisplayString Condition="type == Variant::PLANE">{*(Plane *)_data._mem}</DisplayString>
<DisplayString Condition="type == Variant::QUATERNION">{*(Quaternion *)_data._mem}</DisplayString>
<DisplayString Condition="type == Variant::COLOR">{*(Color *)_data._mem}</DisplayString>
<DisplayString Condition="type == Variant::NODE_PATH">{*(NodePath *)_data._mem}</DisplayString>
<DisplayString Condition="type == Variant::RID">{*(::RID *)_data._mem}</DisplayString>
<DisplayString Condition="type == Variant::OBJECT">{*(Object *)_data._mem}</DisplayString>
<DisplayString Condition="type == Variant::DICTIONARY">{*(Dictionary *)_data._mem}</DisplayString>
<DisplayString Condition="type == Variant::ARRAY">{*(Array *)_data._mem}</DisplayString>
<DisplayString Condition="type == Variant::PACKED_BYTE_ARRAY">{reinterpret_cast&lt;const Variant::PackedArrayRef&lt;unsigned char&gt;*&gt;(_data.packed_array)->array}</DisplayString>
<DisplayString Condition="type == Variant::PACKED_INT32_ARRAY">{reinterpret_cast&lt;const Variant::PackedArrayRef&lt;int&gt;*&gt;(_data.packed_array)->array}</DisplayString>
<!-- broken, will show incorrect data
<DisplayString Condition="type == Variant::PACKED_INT64_ARRAY">{*(PackedInt64Array *)_data._mem}</DisplayString>
-->
<DisplayString Condition="type == Variant::PACKED_FLOAT32_ARRAY">{reinterpret_cast&lt;const Variant::PackedArrayRef&lt;float&gt;*&gt;(_data.packed_array)->array}</DisplayString>
<DisplayString Condition="type == Variant::PACKED_FLOAT64_ARRAY">{reinterpret_cast&lt;const Variant::PackedArrayRef&lt;double&gt;*&gt;(_data.packed_array)->array}</DisplayString>
<DisplayString Condition="type == Variant::PACKED_STRING_ARRAY">{reinterpret_cast&lt;const Variant::PackedArrayRef&lt;String&gt;*&gt;(_data.packed_array)->array}</DisplayString>
<DisplayString Condition="type == Variant::PACKED_VECTOR2_ARRAY">{reinterpret_cast&lt;const Variant::PackedArrayRef&lt;Vector2&gt;*&gt;(_data.packed_array)->array}</DisplayString>
<DisplayString Condition="type == Variant::PACKED_VECTOR3_ARRAY">{reinterpret_cast&lt;const Variant::PackedArrayRef&lt;Vector3&gt;*&gt;(_data.packed_array)->array}</DisplayString>
<DisplayString Condition="type == Variant::PACKED_COLOR_ARRAY">{reinterpret_cast&lt;const Variant::PackedArrayRef&lt;Color&gt;*&gt;(_data.packed_array)->array}</DisplayString>

<StringView Condition="type == Variant::STRING &amp;&amp; ((String *)(_data._mem))->_cowdata._ptr">((String *)(_data._mem))->_cowdata._ptr,s32</StringView>

<Expand>
<Item Name="[value]" Condition="type == Variant::BOOL">_data._bool</Item>
<Item Name="[value]" Condition="type == Variant::INT">_data._int</Item>
<Item Name="[value]" Condition="type == Variant::FLOAT">_data._float</Item>
<Item Name="[value]" Condition="type == Variant::TRANSFORM2D">_data._transform2d</Item>
<Item Name="[value]" Condition="type == Variant::AABB">_data._aabb</Item>
<Item Name="[value]" Condition="type == Variant::BASIS">_data._basis</Item>
<Item Name="[value]" Condition="type == Variant::TRANSFORM3D">_data._transform3d</Item>
<Item Name="[value]" Condition="type == Variant::STRING">*(String *)_data._mem</Item>
<Item Name="[value]" Condition="type == Variant::VECTOR2">*(Vector2 *)_data._mem</Item>
<Item Name="[value]" Condition="type == Variant::RECT2">*(Rect2 *)_data._mem</Item>
<Item Name="[value]" Condition="type == Variant::VECTOR3">*(Vector3 *)_data._mem</Item>
<Item Name="[value]" Condition="type == Variant::PLANE">*(Plane *)_data._mem</Item>
<Item Name="[value]" Condition="type == Variant::QUATERNION">*(Quaternion *)_data._mem</Item>
<Item Name="[value]" Condition="type == Variant::COLOR">*(Color *)_data._mem</Item>
<Item Name="[value]" Condition="type == Variant::NODE_PATH">*(NodePath *)_data._mem</Item>
<Item Name="[value]" Condition="type == Variant::RID">*(::RID *)_data._mem</Item>
<Item Name="[value]" Condition="type == Variant::OBJECT">*(Object *)_data._mem</Item>
<Item Name="[value]" Condition="type == Variant::DICTIONARY">*(Dictionary *)_data._mem</Item>
<Item Name="[value]" Condition="type == Variant::ARRAY">*(Array *)_data._mem</Item>
<Item Name="[value]" Condition="type == Variant::PACKED_BYTE_ARRAY">reinterpret_cast&lt;const Variant::PackedArrayRef&lt;unsigned char&gt;*&gt;(_data.packed_array)->array</Item>
<Item Name="[value]" Condition="type == Variant::PACKED_INT32_ARRAY">*(PackedInt32Array *)_data._mem</Item>
<Item Name="[value]" Condition="type == Variant::PACKED_INT64_ARRAY">*(PackedInt64Array *)_data._mem</Item>
<Item Name="[value]" Condition="type == Variant::PACKED_FLOAT32_ARRAY">*(PackedFloat32Array *)_data._mem</Item>
<Item Name="[value]" Condition="type == Variant::PACKED_FLOAT64_ARRAY">*(PackedFloat64Array *)_data._mem</Item>
<Item Name="[value]" Condition="type == Variant::PACKED_STRING_ARRAY">*(PackedStringArray *)_data._mem</Item>
<Item Name="[value]" Condition="type == Variant::PACKED_VECTOR2_ARRAY">*(PackedVector2Array *)_data._mem</Item>
<Item Name="[value]" Condition="type == Variant::PACKED_VECTOR3_ARRAY">*(PackedVector3Array *)_data._mem</Item>
<Item Name="[value]" Condition="type == Variant::PACKED_COLOR_ARRAY">*(PackedColorArray *)_data._mem</Item>
</Expand>
</Type>

<Type Name="String">
<DisplayString Condition="_cowdata._ptr == 0">[empty]</DisplayString>
<DisplayString Condition="_cowdata._ptr != 0">{_cowdata._ptr,s32}</DisplayString>
<StringView Condition="_cowdata._ptr != 0">_cowdata._ptr,s32</StringView>
</Type>

<Type Name="godot::String">
<DisplayString>{*reinterpret_cast&lt;void**&gt;(opaque),s32}</DisplayString>
<Expand>
<Item Name="opaque_ptr">*reinterpret_cast&lt;void**&gt;(opaque)</Item>
<Item Name="string">*reinterpret_cast&lt;void**&gt;(opaque),s32</Item>
</Expand>
</Type>

<Type Name="StringName">
<DisplayString Condition="_data &amp;&amp; _data->cname">{_data->cname}</DisplayString>
<DisplayString Condition="_data &amp;&amp; !_data->cname">{_data->name,s32}</DisplayString>
<DisplayString Condition="!_data">[empty]</DisplayString>
<StringView Condition="_data &amp;&amp; _data->cname">_data->cname</StringView>
<StringView Condition="_data &amp;&amp; !_data->cname">_data->name,s32</StringView>
</Type>

<!-- can't cast the opaque to ::StringName because Natvis does not support global namespace specifier? -->
<Type Name="godot::StringName">
<DisplayString Condition="(*reinterpret_cast&lt;const char***&gt;(opaque))[1]">{(*reinterpret_cast&lt;const char***&gt;(opaque))[1],s8}</DisplayString>
<DisplayString Condition="!(*reinterpret_cast&lt;const char***&gt;(opaque))[1]">{(*reinterpret_cast&lt;const char***&gt;(opaque))[2],s32}</DisplayString>
<Expand>
<Item Name="opaque_ptr">*reinterpret_cast&lt;void**&gt;(opaque)</Item>
<Item Name="&amp;cname">(*reinterpret_cast&lt;const char***&gt;(opaque))+1</Item>
<Item Name="cname">(*reinterpret_cast&lt;const char***&gt;(opaque))[1],s8</Item>
</Expand>
</Type>

<Type Name="Object::SignalData">
<DisplayString Condition="user.name._cowdata._ptr">"{user.name}" {slot_map}</DisplayString>
<DisplayString Condition="!user.name._cowdata._ptr">"{slot_map}</DisplayString>
</Type>

<Type Name="Vector2">
<DisplayString>{{{x},{y}}}</DisplayString>
<Expand>
<Item Name="x">x</Item>
<Item Name="y">y</Item>
</Expand>
</Type>

<Type Name="Vector3">
<DisplayString>{{{x},{y},{z}}}</DisplayString>
<Expand>
<Item Name="x">x</Item>
<Item Name="y">y</Item>
<Item Name="z">z</Item>
</Expand>
</Type>

<Type Name="Quaternion">
<DisplayString>Quaternion {{{x},{y},{z},{w}}}</DisplayString>
<Expand>
<Item Name="x">x</Item>
<Item Name="y">y</Item>
<Item Name="z">z</Item>
<Item Name="w">w</Item>
</Expand>
</Type>

<Type Name="Color">
<DisplayString>Color {{{r},{g},{b},{a}}}</DisplayString>
<Expand>
<Item Name="red">r</Item>
<Item Name="green">g</Item>
<Item Name="blue">b</Item>
<Item Name="alpha">a</Item>
</Expand>
</Type>
</AutoVisualizer>
Loading

0 comments on commit ec91f8e

Please sign in to comment.