Exemplo n.º 1
0
    def __init__(self):
        Task.__init__(self)

        # There are 5 header groups:
        # 0. Related headers
        # 1. C system headers (includes standard library headers)
        # 2. C++ system headers (includes standard library headers)
        # 3. Other library headers
        # 4. Project headers
        #
        # See comments below for how headers are classified.

        # Header type 0: Related headers
        # Base name of include matches base name of current file

        # Header type 1: C standard library headers
        self.c_std = [
            "assert.h", "complex.h", "ctype.h", "errno.h", "fenv.h", "float.h",
            "inttypes.h", "iso646.h", "limits.h", "locale.h", "math.h",
            "setjmp.h", "signal.h", "stdalign.h", "stdarg.h", "stdatomic.h",
            "stdbool.h", "stddef.h", "stdint.h", "stdio.h", "stdlib.h",
            "stdnoreturn.h", "string.h", "tgmath.h", "threads.h", "time.h",
            "uchar.h", "wchar.h", "wctype.h"
        ]

        # Header type 1: C system headers
        self.c_sys_regex = regex.compile("<[a-z][A-Za-z0-9/_-]*\.h>")

        # Header type 2: C++ standard library headers
        self.cpp_std = [
            "cstdlib", "csignal", "csetjmp", "cstdarg", "typeinfo", "typeindex",
            "type_traits", "bitset", "functional", "utility", "ctime", "chrono",
            "cstddef", "initializer_list", "tuple", "new", "memory",
            "scoped_allocator", "climits", "cfloat", "cstdint", "cinttypes",
            "limits", "exception", "stdexcept", "cassert", "system_error",
            "cerrno", "cctype", "cwctype", "cstring", "cwchar", "cuchar",
            "string", "array", "vector", "deque", "list", "forward_list", "set",
            "map", "unordered_set", "unordered_map", "stack", "queue",
            "algorithm", "iterator", "cmath", "complex", "valarray", "random",
            "numeric", "ratio", "cfenv", "iosfwd", "ios", "istream", "ostream",
            "iostream", "fstream", "sstream", "strstream", "iomanip",
            "streambuf", "cstdio", "locale", "clocale", "codecvt", "regex",
            "atomic", "thread", "mutex", "shared_mutex", "future",
            "condition_variable", "ciso646", "ccomplex", "ctgmath", "cstdalign",
            "cstdbool", "any", "filesystem", "optional", "string_view",
            "variant"
        ]

        # Header type 3: Other library headers
        # They use angle brackets (open_bracket group is angle bracket)
        #
        # Header type 4: Project headers
        # They use double quotes (all other headers)
        self.header_regex = regex.compile("(?P<comment>//\s*)?"
                                          "\#include\s*"
                                          "(?P<header>"
                                          "(?P<open_bracket><|\")"
                                          "(?P<name>[^>\"]*)"
                                          "(?P<close_bracket>>|\"))"
                                          "(?P<postfix>.*)$")
Exemplo n.º 2
0
    def __init__(self, current_year):
        """Constructor for LicenseUpdate task.

        Keyword arguments:
        current_year -- year string
        """
        Task.__init__(self)

        self.__current_year = current_year
Exemplo n.º 3
0
    def __init__(self, clang_version):
        """Constructor for ClangFormat task.

        Keyword arguments:
        clang_version -- version number of clang-format appended to executable
                         name
        """
        Task.__init__(self)

        if clang_version == "":
            self.exec_name = "clang-format"
        else:
            self.exec_name = "clang-format-" + clang_version
Exemplo n.º 4
0
    def __init__(self):
        Task.__init__(self)

        self.headers = []

        # assert is a macro, so it's ommitted to avoid prefixing with std::
        self.headers.append(Header("assert"))

        self.headers.append(
            Header(
                "ctype", {
                    "isalum", "isalpha", "isblank", "iscntrl", "isdigit",
                    "isgraph", "islower", "isprint", "ispunct", "isspace",
                    "isupper", "isxdigit", "tolower", "toupper"
                }))
        self.headers.append(Header("errno"))
        self.headers.append(Header("float"))
        self.headers.append(Header("limits"))
        self.headers.append(
            Header(
                "math", {
                    "cos", "acos", "cosh", "acosh", "sin", "asin", "asinh",
                    "tan", "atan", "atan2", "atanh", "exp", "frexp", "ldexp",
                    "log", "log10", "ilogb", "log1p", "log2", "logb", "modf",
                    "exp2", "expm1", "scalbl", "scalbln", "pow", "sqrt", "cbrt",
                    "hypot", "erf", "erfc", "tgamma", "lgamma", "ceil", "floor",
                    "fmod", "trunc", "round", "lround", "llround", "rint",
                    "lrint", "llrint", "nearbyint", "remainder", "remquo",
                    "copysign", "nan", "nextafter", "nexttoward", "fdim",
                    "fmax", "fmin", "fma", "fpclassify", "abs", "fabs",
                    "signbit", "isfinite", "isinf", "isnan", "isnormal",
                    "isgreater", "isgreaterequal", "isless", "islessequal",
                    "islessgreater", "isunordered"
                }))
        self.headers.append(
            Header("setjmp", {"longjmp", "setjmp"}, ["jmp_buf"]))
        self.headers.append(
            Header("signal", {"signal", "raise"}, ["sig_atomic_t"], False))
        self.headers.append(Header("stdarg", {"va_list"}))
        self.headers.append(
            Header("stddef", type_regexes=["(ptrdiff|max_align|nullptr)_t"]))

        # size_t isn't actually defined in stdint, but it fits best here for
        # removing the std:: prefix
        self.headers.append(
            Header(
                "stdint",
                type_regexes=[
                    "((u?int((_fast|_least)?(8|16|32|64)|max|ptr)|size)_t)"
                ],
                add_prefix=False))

        self.headers.append(
            Header(
                "stdio", {
                    "remove", "rename", "rewind", "tmpfile", "tmpnam", "fclose",
                    "fflush", "fopen", "freopen", "fgetc", "fgets", "fputc",
                    "fputs", "fread", "fwrite", "fgetpos", "fseek", "fsetpos",
                    "ftell", "feof", "ferror", "setbuf", "setvbuf", "fprintf",
                    "snprintf", "sprintf", "vfprintf", "vprintf", "vsnprintf",
                    "vsprintf", "printf", "fscanf", "sscanf", "vfscanf",
                    "vscanf", "vsscanf", "scanf", "getchar", "gets", "putc",
                    "putchar", "puts", "getc", "ungetc", "clearerr", "perror"
                }, ["FILE", "fpos_t"]))
        self.headers.append(
            Header(
                "stdlib", {
                    "atof", "atoi", "atol", "atoll", "strtof", "strtol",
                    "strtod", "strtold", "strtoll", "strtoul", "strtoull",
                    "rand", "srand", "free", "calloc", "malloc", "realloc",
                    "abort", "at_quick_exit", "quick_exit", "atexit", "exit",
                    "getenv", "system", "_Exit", "bsearch", "qsort", "llabs",
                    "labs", "abs", "lldiv", "ldiv", "div", "mblen", "btowc",
                    "wctomb", "wcstombs", "mbstowcs"
                }, ["(l|ll)?div_t"]))
        self.headers.append(
            Header(
                "string", {
                    "memcpy", "memcmp", "memchr", "memmove", "memset", "strcpy",
                    "strncpy", "strcat", "strncat", "strcmp", "strncmp",
                    "strcoll", "strchr", "strrchr", "strstr", "strxfrm",
                    "strcspn", "strrspn", "strpbrk", "strtok", "strerror",
                    "strlen"
                }))
        self.headers.append(
            Header(
                "time", {
                    "clock", "asctime", "ctime", "difftime", "gmtime",
                    "localtime", "mktime", "strftime", "time"
                }, ["(clock|time)_t"]))