File: gen_error_codes.pl

package info (click to toggle)
boost1.83 1.83.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 545,632 kB
  • sloc: cpp: 3,857,086; xml: 125,552; ansic: 34,414; python: 25,887; asm: 5,276; sh: 4,799; ada: 1,681; makefile: 1,629; perl: 1,212; pascal: 1,139; sql: 810; yacc: 478; ruby: 102; lisp: 24; csh: 6
file content (62 lines) | stat: -rwxr-xr-x 1,236 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/perl -w

use strict;
use warnings;

my $header = <<'END';
/*
 * Copyright 2016-2018 Andrey Semashev
 *
 * Distributed under the Boost Software License, Version 1.0.
 * See http://www.boost.org/LICENSE_1_0.txt
 */

#ifndef BOOST_WINAPI_ERROR_CODES_HPP_INCLUDED_
#define BOOST_WINAPI_ERROR_CODES_HPP_INCLUDED_

#include <boost/winapi/basic_types.hpp>

#ifdef BOOST_HAS_PRAGMA_ONCE
#pragma once
#endif

namespace boost {
namespace winapi {

END

my $footer = <<'END';

} // namespace winapi
} // namespace boost

#endif // BOOST_WINAPI_ERROR_CODES_HPP_INCLUDED_
END

print $header;

while (<>)
{
    my $line = $_;
    chomp($line);
    if ($line =~ /^\s*#\s*define\s+([a-zA-Z_\d]+)\s+(0[xX][[:xdigit:]]+|\d+|[a-zA-Z_\d]+)[lLuU]*\s*(\/\/.*|\/\*.*)?$/)
    {
        # We define some of the constants in other headers
        if ($1 ne "FORCEINLINE" && $1 ne "WAIT_TIMEOUT")
        {
            my $value = $2;
            print "BOOST_CONSTEXPR_OR_CONST DWORD_ ", $1 , "_ = ";
            if ($value =~ /0[xX][[:xdigit:]]+|\d+/)
            {
                print $value;
            }
            else
            {
                print $value, "_";
            }
            print ";\n";
        }
    }
}

print $footer;