diff --git a/xls/public/c_api.cc b/xls/public/c_api.cc index da85cbb5b5..3f4802864c 100644 --- a/xls/public/c_api.cc +++ b/xls/public/c_api.cc @@ -233,6 +233,10 @@ bool xls_format_preference_from_string(const char* s, char** error_out, *result_out = xls_format_preference_plain_binary; } else if (got == "plain_hex") { *result_out = xls_format_preference_plain_hex; + } else if (got == "zero_padded_binary") { + *result_out = xls_format_preference_zero_padded_binary; + } else if (got == "zero_padded_hex") { + *result_out = xls_format_preference_zero_padded_hex; } else { absl::Status error = absl::InvalidArgumentError(absl::StrFormat( "Invalid value for conversion to XLS format preference: `%s`", s)); diff --git a/xls/public/c_api_format_preference.h b/xls/public/c_api_format_preference.h index 783766b643..13b9581043 100644 --- a/xls/public/c_api_format_preference.h +++ b/xls/public/c_api_format_preference.h @@ -30,6 +30,8 @@ enum { xls_format_preference_hex, xls_format_preference_plain_binary, xls_format_preference_plain_hex, + xls_format_preference_zero_padded_binary, + xls_format_preference_zero_padded_hex, }; } // extern "C" diff --git a/xls/public/c_api_impl_helpers.cc b/xls/public/c_api_impl_helpers.cc index bb3875cdfe..581ddb70a2 100644 --- a/xls/public/c_api_impl_helpers.cc +++ b/xls/public/c_api_impl_helpers.cc @@ -84,6 +84,12 @@ bool FormatPreferenceFromC(xls_format_preference c_pref, case xls_format_preference_plain_hex: *cpp_pref = xls::FormatPreference::kPlainHex; break; + case xls_format_preference_zero_padded_binary: + *cpp_pref = xls::FormatPreference::kZeroPaddedBinary; + break; + case xls_format_preference_zero_padded_hex: + *cpp_pref = xls::FormatPreference::kZeroPaddedHex; + break; default: *error_out = ToOwnedCString( absl::StrFormat("Invalid format preference value: %d", c_pref));