diff --git a/Readme.md b/Readme.md index 70d031f..164a361 100644 --- a/Readme.md +++ b/Readme.md @@ -3,7 +3,7 @@ An attempt at simple staged metaprogramming for c/c++. This project is not minimum feature complete yet. -Version 1 will have a most of c and a subset of c++ features available to it. +Version 1 will have c and a subset of c++ features available to it. ## How it works diff --git a/project/gen.cpp b/project/gen.cpp index c771b65..63ede1b 100644 --- a/project/gen.cpp +++ b/project/gen.cpp @@ -1,5 +1,4 @@ #include "Bloat.hpp" -#define gen_time #include "gen.hpp" #ifdef gen_time diff --git a/scripts/build.ci.ps1 b/scripts/build.ci.ps1 index fe404fd..b814462 100644 --- a/scripts/build.ci.ps1 +++ b/scripts/build.ci.ps1 @@ -98,23 +98,29 @@ Pop-Location # Build the program depending on generated files. - # if ( -not( Test-Path $path_test_build ) ) - # { - # $args_meson = @() - # $args_meson += "setup" - # $args_meson += $path_test_build + if ( -not( Test-Path $path_test_build ) ) + { + $args_meson = @() + $args_meson += "setup" + $args_meson += $path_test_build - # Push-Location $path_test - # & meson $args_meson - # Pop-Location - # } + Push-Location $path_test + & meson $args_meson + Pop-Location + } - # $args_ninja = @() - # $args_ninja += "-C" - # $args_ninja += $path_test_build + $args_ninja = @() + $args_ninja += "-C" + $args_ninja += $path_test_build - # Push-Location $path_root - # ninja $args_ninja - # Pop-Location - #endregion Test Build + Push-Location $path_root + ninja $args_ninja + Pop-Location + + $testcpp = Join-Path $path_test_build testcpp.exe + + Push-Location $path_test + & $testcpp + Pop-Location + # endregion Test Build # } diff --git a/test/gen/math.gen.hpp b/test/gen/math.gen.hpp index a74c1a1..4c95f93 100644 --- a/test/gen/math.gen.hpp +++ b/test/gen/math.gen.hpp @@ -1,24 +1,24 @@ inline -u8 square_u8(u8 value) +u8 square(u8 value) { - return value * value + return value * value; } inline -u16 square_u16(u16 value) +u16 square(u16 value) { - return value * value + return value * value; } inline -u32 square_u32(u32 value) +u32 square(u32 value) { - return value * value + return value * value; } inline -u64 square_u64(u64 value) +u64 square(u64 value) { - return value * value + return value * value; } diff --git a/test/math.hpp b/test/math.hpp index 853dcf7..913cdd7 100644 --- a/test/math.hpp +++ b/test/math.hpp @@ -1,6 +1,5 @@ #pragma once -#define gen_time #include "Bloat.hpp" #include "gen.hpp" @@ -23,10 +22,10 @@ { Code integral_type = make_type( type ); - string name = string_sprintf( g_allocator, (char*)sprintf_buf, ZPL_PRINTF_MAXLEN, "square_%s", type ); + string name = string_sprintf( g_allocator, (char*)sprintf_buf, ZPL_PRINTF_MAXLEN, "square", type ); Code specifiers = make_specifiers( 1, Specifier::Inline ); Code params = make_parameters( 1, "value", integral_type ); - Code ret_stmt = make_fmt( "\treturn value * value" ); + Code ret_stmt = make_fmt( "\treturn value * value;" ); Code result = make_function( name, specifiers, @@ -64,11 +63,4 @@ #include "math.gen.hpp" #undef square - #define sym_square( Type_, Value_ ) square_#Type_( Value_ ) - - template - type square( type value ) - [ - sym_square( type, value ); - ] #endif diff --git a/test/meson.build b/test/meson.build index 17e3114..b79b260 100644 --- a/test/meson.build +++ b/test/meson.build @@ -4,14 +4,15 @@ project( 'test', 'c', 'cpp', default_options : ['buildtype=debug'] ) includes = include_directories( [ - '../project' - , '../thirdparty' + './gen', + '../project', + '../thirdparty' ]) # get_sources = files('./get_sources.ps1') # sources = files(run_command('powershell', get_sources, check: true).stdout().strip().split('\n')) -sources = [ 'math.hpp' ] +sources = [ 'test.cpp' ] if get_option('buildtype').startswith('debug') @@ -19,4 +20,4 @@ if get_option('buildtype').startswith('debug') endif -executable( '', sources, include_directories : includes ) +executable( 'testcpp', sources, include_directories : includes ) diff --git a/test/test.cpp b/test/test.cpp index c9a9ff9..4049250 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -25,7 +25,7 @@ int gen_main() int main() { - u32 result = square(5); + u32 result = square( 5U ); zpl_printf("TEST RESULT: %d", result); }