From 13ebd105c44c0a4175232422e9ee36acab641aca Mon Sep 17 00:00:00 2001 From: Ed_ Date: Thu, 30 Jan 2025 14:14:53 -0500 Subject: [PATCH] Fix for convert_cpp_enum_to_c for gen_c_library It wasn't generating correct typedefs for when underlying type was used over the enum name. --- gen_c_library/components/misc.hpp | 15 +++++++++++++-- scripts/helpers/vendor_toolchain.ps1 | 14 ++++++++------ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/gen_c_library/components/misc.hpp b/gen_c_library/components/misc.hpp index 0976652..c4633ae 100644 --- a/gen_c_library/components/misc.hpp +++ b/gen_c_library/components/misc.hpp @@ -7,8 +7,19 @@ void convert_cpp_enum_to_c( CodeEnum to_convert, CodeBody to_append ) { #pragma push_macro("enum_underlying") #undef enum_underlying - StrCached type = to_convert->UnderlyingType ? to_convert->UnderlyingType.to_strbuilder().to_str() : to_convert->Name; - CodeTypedef tdef = parse_typedef(token_fmt("type", type, "name", to_convert->Name, stringize( typedef enum ; ))); + StrCached type; + CodeTypedef tdef; + if (to_convert->UnderlyingType) + { + type = to_convert->UnderlyingType.to_strbuilder().to_str(); + tdef = parse_typedef(token_fmt("type", type, "name", to_convert->Name, stringize( typedef ; ))); + } + else + { + type = to_convert->Name; + tdef = parse_typedef(token_fmt("type", type, "name", to_convert->Name, stringize( typedef enum ; ))); + + } if (to_convert->UnderlyingType) { to_convert->UnderlyingTypeMacro = untyped_str(token_fmt("type", to_convert->UnderlyingType->Name, stringize(enum_underlying()))); diff --git a/scripts/helpers/vendor_toolchain.ps1 b/scripts/helpers/vendor_toolchain.ps1 index 30fa75d..d183b74 100644 --- a/scripts/helpers/vendor_toolchain.ps1 +++ b/scripts/helpers/vendor_toolchain.ps1 @@ -344,15 +344,17 @@ if ( $vendor -match "clang" ) } # Check if output is a static library - # if ( $binary -match '\.lib$' ) - # { - # $lib_args = @() + if ( $binary -match '\.lib$' ) + { + $lib_args = @() # $lib_args += $flag_nologo # $lib_args += $flag_link_win_machine_64 # $lib_args += ( $flag_link_win_path_output + $binary ) - # $lib_args += $object - # return run-archiver $archiver $binary $lib_args - # } + # $lib_args += '--format=windows' + # $lib_args += '-X64' + $lib_args += $object + return run-archiver $archiver $binary $lib_args + } $linker_args += $object return run-linker $linker $binary $linker_args