gen_error_codes.pl 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/usr/bin/perl -w
  2. use strict;
  3. use warnings;
  4. my $header = <<'END';
  5. /*
  6. * Copyright 2016-2018 Andrey Semashev
  7. *
  8. * Distributed under the Boost Software License, Version 1.0.
  9. * See http://www.boost.org/LICENSE_1_0.txt
  10. */
  11. #ifndef BOOST_WINAPI_ERROR_CODES_HPP_INCLUDED_
  12. #define BOOST_WINAPI_ERROR_CODES_HPP_INCLUDED_
  13. #include <boost/winapi/basic_types.hpp>
  14. #ifdef BOOST_HAS_PRAGMA_ONCE
  15. #pragma once
  16. #endif
  17. namespace boost {
  18. namespace winapi {
  19. END
  20. my $footer = <<'END';
  21. } // namespace winapi
  22. } // namespace boost
  23. #endif // BOOST_WINAPI_ERROR_CODES_HPP_INCLUDED_
  24. END
  25. print $header;
  26. while (<>)
  27. {
  28. my $line = $_;
  29. chomp($line);
  30. if ($line =~ /^\s*#\s*define\s+([a-zA-Z_\d]+)\s+(0[xX][[:xdigit:]]+|\d+|[a-zA-Z_\d]+)[lLuU]*\s*(\/\/.*|\/\*.*)?$/)
  31. {
  32. # We define some of the constants in other headers
  33. if ($1 ne "FORCEINLINE" && $1 ne "WAIT_TIMEOUT")
  34. {
  35. my $value = $2;
  36. print "BOOST_CONSTEXPR_OR_CONST DWORD_ ", $1 , "_ = ";
  37. if ($value =~ /0[xX][[:xdigit:]]+|\d+/)
  38. {
  39. print $value;
  40. }
  41. else
  42. {
  43. print $value, "_";
  44. }
  45. print ";\n";
  46. }
  47. }
  48. }
  49. print $footer;