mirror of
https://github.com/Ed94/gencpp.git
synced 2025-06-14 18:51:47 -07:00
More dependency movement from zpl, incremental design improvements.
Made token_fmt more ergonomic, going to have to use a similar behavior with the upfront body constructors.
This commit is contained in:
@ -13,51 +13,45 @@ foreach ( $arg in $args )
|
||||
}
|
||||
}
|
||||
|
||||
$path_root = git rev-parse --show-toplevel
|
||||
$path_build = Join-Path $path_root build
|
||||
$path_scripts = Join-Path $path_root scripts
|
||||
$path_test = Join-Path $path_root test
|
||||
$path_gen = Join-Path $path_test gen
|
||||
$path_test_build = Join-Path $path_test build
|
||||
$path_gen_build = Join-Path $path_gen build
|
||||
|
||||
$path_root = git rev-parse --show-toplevel
|
||||
$path_build = Join-Path $path_root build
|
||||
$path_scripts = Join-Path $path_root scripts
|
||||
write-host "`n`nBuilding Test`n"
|
||||
|
||||
if ( -not( Test-Path $path_gen_build ) )
|
||||
{
|
||||
# Generate build files for meta-program
|
||||
Push-Location $path_gen
|
||||
$args_meson = @()
|
||||
$args_meson += "setup"
|
||||
$args_meson += $path_gen_build
|
||||
|
||||
# if ( $test -eq $true )
|
||||
# {
|
||||
#region Test Build
|
||||
write-host "`n`nBuilding Test`n"
|
||||
|
||||
$path_test = Join-Path $path_root test
|
||||
$path_gen = Join-Path $path_test gen
|
||||
$path_test_build = Join-Path $path_test build
|
||||
$path_gen_build = Join-Path $path_gen build
|
||||
|
||||
# Generate files using metaprogram.
|
||||
if ( -not( Test-Path $path_gen_build ) )
|
||||
{
|
||||
$args_meson = @()
|
||||
$args_meson += "setup"
|
||||
$args_meson += $path_gen_build
|
||||
|
||||
Push-Location $path_gen
|
||||
& meson $args_meson
|
||||
Pop-Location
|
||||
}
|
||||
& meson $args_meson
|
||||
Pop-Location
|
||||
}
|
||||
|
||||
# Compile meta-program
|
||||
Push-Location $path_root
|
||||
$args_ninja = @()
|
||||
$args_ninja += "-C"
|
||||
$args_ninja += $path_gen_build
|
||||
|
||||
Push-Location $path_root
|
||||
& ninja $args_ninja
|
||||
Pop-Location
|
||||
Pop-Location
|
||||
|
||||
# Test NonParsed
|
||||
if ($true) {
|
||||
Push-location $path_gen
|
||||
# Run meta-program
|
||||
$gencpp = Join-Path $path_gen_build gencpp.exe
|
||||
|
||||
Push-location $path_gen
|
||||
|
||||
Write-Host `nGenerating files...
|
||||
Write-Host `nGenerating files -- Parsed...
|
||||
& $gencpp
|
||||
|
||||
# Format generated files
|
||||
Write-Host `nBeginning format...
|
||||
$formatParams = @(
|
||||
'-i' # In-place
|
||||
@ -72,60 +66,30 @@ $path_scripts = Join-Path $path_root scripts
|
||||
|
||||
clang-format $formatParams $targetFiles
|
||||
Write-Host "`nFormatting complete"
|
||||
Pop-Location
|
||||
}
|
||||
Pop-Location
|
||||
|
||||
# Test Parsed
|
||||
if ($true) {
|
||||
$gencpp = Join-Path $path_gen_build gencpp_parsed.exe
|
||||
# Build the program depending on generated files.
|
||||
if ( -not( Test-Path $path_test_build ) )
|
||||
{
|
||||
Push-Location $path_test
|
||||
$args_meson = @()
|
||||
$args_meson += "setup"
|
||||
$args_meson += $path_test_build
|
||||
|
||||
Push-location $path_gen
|
||||
# & meson $args_meson
|
||||
Pop-Location
|
||||
}
|
||||
|
||||
Write-Host `nGenerating files -- using Parse API...
|
||||
& $gencpp
|
||||
Push-Location $path_root
|
||||
$args_ninja = @()
|
||||
$args_ninja += "-C"
|
||||
$args_ninja += $path_test_build
|
||||
|
||||
Write-Host `nBeginning format...
|
||||
$formatParams = @(
|
||||
'-i' # In-place
|
||||
'-style=file' # Search for a .clang-format file in the parent directory of the source file.
|
||||
'-verbose'
|
||||
)
|
||||
|
||||
$include = @('*.gen.hpp', '*.gen.cpp')
|
||||
$exclude = $null
|
||||
|
||||
$targetFiles = @(Get-ChildItem -Recurse -Path $path_gen -Include $include -Exclude $exclude | Select-Object -ExpandProperty FullName)
|
||||
|
||||
clang-format $formatParams $targetFiles
|
||||
Write-Host "`nFormatting complete"
|
||||
Pop-Location
|
||||
}
|
||||
|
||||
|
||||
# Build the program depending on generated files.
|
||||
# if ( -not( Test-Path $path_test_build ) )k
|
||||
# {
|
||||
# $args_meson = @()
|
||||
# $args_meson += "setup"
|
||||
# $args_meson += $path_test_build
|
||||
|
||||
# Push-Location $path_test
|
||||
# & meson $args_meson
|
||||
# Pop-Location
|
||||
# }
|
||||
|
||||
# $args_ninja = @()
|
||||
# $args_ninja += "-C"
|
||||
# $args_ninja += $path_test_build
|
||||
|
||||
# Push-Location $path_root
|
||||
# ninja $args_ninja
|
||||
# Pop-Location
|
||||
Pop-Location
|
||||
|
||||
# $testcpp = Join-Path $path_test_build testcpp.exe
|
||||
Push-Location $path_test
|
||||
$testcpp = Join-Path $path_test_build testcpp.exe
|
||||
|
||||
# Push-Location $path_test
|
||||
# & $testcpp
|
||||
# Pop-Location
|
||||
# endregion Test Build
|
||||
# }
|
||||
Pop-Location
|
||||
|
98
scripts/gencpp.natvis
Normal file
98
scripts/gencpp.natvis
Normal file
@ -0,0 +1,98 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
|
||||
|
||||
<Type Name="gen::AllocatorInfo">
|
||||
<DisplayString>Data:{Data} Proc:{Proc}</DisplayString>
|
||||
</Type>
|
||||
|
||||
<Type Name="gen::Array<*>">
|
||||
<DisplayString>Num:{((Header*)((char*)Data - sizeof(Header)))->Num}, Capacity:{((Header*)((char*)Data - sizeof(Header)))->Capacity}</DisplayString>
|
||||
<Expand>
|
||||
<Synthetic Name="Header">
|
||||
<DisplayString>{(Header*)((char*)Data - sizeof(Header))}</DisplayString>
|
||||
<Expand>
|
||||
<Item Name="Allocator">((Header*)((char*)Data - sizeof(Header)))->Allocator</Item>
|
||||
<Item Name="Capacity">((Header*)((char*)Data - sizeof(Header)))->Capacity</Item>
|
||||
<Item Name="Num">((Header*)((char*)Data - sizeof(Header)))->Num</Item>
|
||||
</Expand>
|
||||
</Synthetic>
|
||||
<ArrayItems>
|
||||
<Size>((Header*)((char*)Data - sizeof(Header)))->Capacity</Size>
|
||||
<ValuePointer>Data</ValuePointer>
|
||||
</ArrayItems>
|
||||
</Expand>
|
||||
</Type>
|
||||
|
||||
<Type Name="gen::StrC">
|
||||
<DisplayString>Len:{Len} Ptr:{Ptr, [Len]s}</DisplayString>
|
||||
</Type>
|
||||
|
||||
<Type Name="gen::String">
|
||||
<DisplayString Condition="Data == nullptr">null</DisplayString>
|
||||
<DisplayString>{Data,na}</DisplayString>
|
||||
<Expand>
|
||||
<Synthetic Name="Header">
|
||||
<DisplayString>{(Header*)((char*)Data - sizeof(Header))}</DisplayString>
|
||||
<Expand>
|
||||
<Item Name="Allocator">((Header*)((char*)Data - sizeof(Header)))->Allocator</Item>
|
||||
<Item Name="Length">((Header*)((char*)Data - sizeof(Header)))->Length</Item>
|
||||
<Item Name="Capacity">((Header*)((char*)Data - sizeof(Header)))->Capacity</Item>
|
||||
</Expand>
|
||||
</Synthetic>
|
||||
</Expand>
|
||||
</Type>
|
||||
|
||||
<Type Name="gen::String::Header">
|
||||
<DisplayString>Length: {Length}, Capacity: {Capacity}</DisplayString>
|
||||
<Expand>
|
||||
<Item Name="Allocator">Allocator</Item>
|
||||
<Item Name="Length">Length</Item>
|
||||
<Item Name="Capacity">Capacity</Item>
|
||||
</Expand>
|
||||
</Type>
|
||||
|
||||
<Type Name="gen::AST">
|
||||
<DisplayString>{Name} {Type}</DisplayString>
|
||||
<Expand>
|
||||
<Item Name="Type">Type</Item>
|
||||
<Item Name="Name">Name</Item>
|
||||
<Item Name="Parent">Parent</Item>
|
||||
<Item Name="Op" Condition="Op != 43">Op</Item>
|
||||
<Item Name="ModuleFlags">ModuleFlags</Item>
|
||||
<Item Name="ParentAcess" Condition="ParentAccess != gen::AccessSpec::Invalid">ParentAccess</Item>
|
||||
<Item Name="ArrStatic" Condition="DynamicEntries == false">ArrStatic</Item>
|
||||
<Item Name="Index" Condition="DynamicEntries == false">StaticIndex</Item>
|
||||
<Item Name="ArrDyn" Condition="DynamicEntries == true">ArrDyn</Item>
|
||||
<Item Name="Index" Condition="DynamicEntries == true">ArrDyn.num()</Item>
|
||||
</Expand>
|
||||
</Type>
|
||||
|
||||
<Type Name="gen::Code">
|
||||
<DisplayString Condition="ast != nullptr">{ast->Name} {ast->Type}</DisplayString>
|
||||
<Expand>
|
||||
<Item Name="Type">ast->Type</Item>
|
||||
<Item Name="Name">ast->Name</Item>
|
||||
<Item Name="Parent">ast->Parent</Item>
|
||||
<Item Name="Op" Condition="ast->Op != 43">ast->Op</Item>
|
||||
<Item Name="ModuleFlags">ast->ModuleFlags</Item>
|
||||
<Item Name="ParentAcess" Condition="ast->ParentAccess != gen::AccessSpec::Invalid">ast->ParentAccess</Item>
|
||||
<Item Name="ArrStatic" Condition="ast->DynamicEntries == false">ast->ArrStatic</Item>
|
||||
<Item Name="Index" Condition="ast->DynamicEntries == false">ast->StaticIndex</Item>
|
||||
<Item Name="ArrDyn" Condition="ast->DynamicEntries == true">ast->ArrDyn</Item>
|
||||
<Item Name="Index" Condition="ast->DynamicEntries == true">ast->ArrDyn.num()</Item>
|
||||
</Expand>
|
||||
</Type>
|
||||
|
||||
<Type Name="gen::Code">
|
||||
<DisplayString>{ast.Name} {ast.Type}</DisplayString>
|
||||
</Type>
|
||||
|
||||
<Type Name ="gen::Parser::Token">
|
||||
<DisplayString>Length:{Length} Text:{Text, [Length]s} Type:{Type}</DisplayString>
|
||||
</Type>
|
||||
|
||||
<Type Name="gen::Parser::TokArray">
|
||||
<DisplayString>Current[ { Arr[Idx] } ] Idx:{ Idx }</DisplayString>
|
||||
</Type>
|
||||
|
||||
</AutoVisualizer>
|
Reference in New Issue
Block a user