gen_test_error_codes_abi.pl 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/usr/bin/perl -w
  2. use strict;
  3. use warnings;
  4. my $header = <<'END';
  5. /*
  6. * Copyright Andrey Semashev 2018.
  7. * Distributed under the Boost Software License, Version 1.0.
  8. * (See accompanying file LICENSE_1_0.txt or copy at
  9. * http://www.boost.org/LICENSE_1_0.txt)
  10. */
  11. /*!
  12. * \file error_codes_abi.cpp
  13. * \author Andrey Semashev
  14. * \date 09.03.2018
  15. *
  16. * \brief This file contains ABI test for error_codes.hpp
  17. */
  18. #include <boost/winapi/error_codes.hpp>
  19. #include <windows.h>
  20. #include <winerror.h>
  21. #include <boost/predef/platform/windows_uwp.h>
  22. #include "abi_test_tools.hpp"
  23. int main()
  24. {
  25. END
  26. my $footer = <<'END';
  27. return boost::report_errors();
  28. }
  29. END
  30. print $header;
  31. while (<>)
  32. {
  33. my $line = $_;
  34. chomp($line);
  35. if ($line =~ /^\s*BOOST_CONSTEXPR_OR_CONST\s+DWORD_\s+([a-zA-Z_\d]+)_\s+.*$/)
  36. {
  37. print "#if ";
  38. # Some constants have different values in different Windows SDKs
  39. if ($1 eq "ERROR_IPSEC_IKE_NEG_STATUS_END")
  40. {
  41. print "BOOST_PLAT_WINDOWS_SDK_VERSION >= BOOST_WINAPI_WINDOWS_SDK_6_0 && ";
  42. }
  43. print "defined(", $1 , ")\n";
  44. print " BOOST_WINAPI_TEST_CONSTANT(", $1 , ");\n";
  45. print "#endif\n";
  46. }
  47. }
  48. print $footer;