iupaizaio_pp   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 113
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 88
dl 0
loc 113
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A PaizaPreprocessor.preprocess() 0 2 1
1
#!/usr/bin/env python
2
#
3
# iupaizaio_pp.py
4
#
5
# Copyright (C) 2015-2018, Takazumi Shirayanagi
6
# This software is released under the new BSD License,
7
# see LICENSE
8
#
9
10
import os
11
import sys
12
sys.path.append(os.path.join(os.path.dirname(__file__), '../fused'))
13
from iutest_pp_strip import IutestPreprocessor
14
15
predefined_macros = {
16
    '__clang__': '1',
17
    '_LIBCPP_VERSION': '1101',
18
    'NULL': '0',
19
    '__linux__': '1',
20
    '__cplusplus': '201402',
21
    '__cpp_rvalue_references': '200610',
22
    '__has_include': None
23
}
24
25
iutest_config_macro = {
26
}
27
28
expands_macros = [
29
    'IUTEST_IPP_INLINE',
30
    'IUTEST_NULLPTR',
31
    'IUTEST_CXX_CONSTEXPR',
32
    'IUTEST_CXX_CONSTEXPR_OR_CONST',
33
    'IUTEST_CXX_DELETED_FUNCTION',
34
    'IUTEST_CXX_DEFAULT_FUNCTION',
35
    'IUTEST_CXX_EXPLICIT_CONVERSION',
36
    'IUTEST_CXX_NOEXCEPT_SPEC',
37
    'IUTEST_CXX_OVERRIDE',
38
    'IUTEST_CXX_FINAL',
39
    'IUTEST_CXX_NOTHROW',
40
    'IUTEST_PRAGMA_GCC_WARN_PUSH',
41
    'IUTEST_PRAGMA_GCC_WARN_DISABLE',
42
    'IUTEST_PRAGMA_GCC_WARN_POP',
43
    'IUTEST_ATTRIBUTE_UNUSED_',
44
    'IUTEST_ATTRIBUTE_DEPRECATED_',
45
    'IUTEST_ATTRIBUTE_PURE_',
46
    'IUTEST_ATTRIBUTE_NORETURN_'
47
]
48
49
#
50
expand_function_macros = [
51
    'IUTEST_PRAGMA_CRT_SECURE_WARN_DISABLE_BEGIN',
52
    'IUTEST_PRAGMA_CRT_SECURE_WARN_DISABLE_END',
53
    'IUTEST_PRAGMA_EXTERN_TEMPLATE_WARN_DISABLE_BEGIN',
54
    'IUTEST_PRAGMA_EXTERN_TEMPLATE_WARN_DISABLE_END',
55
    'IUTEST_PRAGMA_CONSTEXPR_CALLED_AT_RUNTIME_WARN_DISABLE_BEGIN',
56
    'IUTEST_PRAGMA_CONSTEXPR_CALLED_AT_RUNTIME_WARN_DISABLE_END',
57
    'IUTEST_PRAGMA_MSC_WARN_PUSH',
58
    'IUTEST_PRAGMA_MSC_WARN_DISABLE',
59
    'IUTEST_PRAGMA_MSC_WARN_POP',
60
    'IUTEST_WORKAROUND_MSC_STLSTREAM_C4250',
61
    'IUTEST_EXPLICIT_TEMPLATE_TYPE_',
62
    'IUTEST_APPEND_EXPLICIT_TEMPLATE_TYPE_'
63
]
64
65
#
66
clang_has_features = {
67
    'cxx_nullptr': '1',
68
    'cxx_attributes': '1',
69
    'cxx_auto_type': '1',
70
    'cxx_constexpr': '1',
71
    'cxx_decltype': '1',
72
    'cxx_defaulted_functions': '1',
73
    'cxx_deleted_functions': '1',
74
    'cxx_explicit_conversions': '1',
75
    'cxx_generalized_initializers': '1',
76
    'cxx_lambdas': '1',
77
    'cxx_noexcept': '1',
78
    'cxx_override_control': '1',
79
    'cxx_rtti': '1',
80
    'cxx_rvalue_references': '1',
81
    'cxx_static_assert': '1',
82
    'cxx_strong_enums': '1',
83
    'cxx_unicode_literals': '1',
84
    'cxx_variadic_templates': '1',
85
    'c_generic_selections': '0'
86
}
87
88
clang_has_include = {
89
    '<cxxabi.h>': '1',
90
    '<cuchar>': '0',
91
    '<uchar.h>': '0',
92
    '<experimental/any>': '0',
93
    '<ext/cmath>': '0',
94
    '<array>': '1',
95
    '<future>': '1',
96
    '<ratio>': '1',
97
    '<shared_mutex>': '1',
98
    '<scoped_allocator>': '1',
99
    '<typeindex>': '1',
100
    '<type_traits>': '1',
101
    '<tr1/tuple>': '0'
102
}
103
104
class PaizaPreprocessor:
105
    pp = IutestPreprocessor(predefined_macros
106
        , expand_function_macros
107
        , expands_macros
108
        , clang_has_features
109
        , clang_has_include)
110
111
    def preprocess(self, code, add_macros):
112
        return self.pp.preprocess(code, add_macros)
113