@@ -20,6 +20,9 @@ def NamespaceDefinitionsFolder():
20
20
def ClassSpecifiersFolder ():
21
21
return os .path .join (ToplevelFolder (), "class.pre" )
22
22
23
+ def NonMemberFunctionDeclarationsFolder ():
24
+ return os .path .join (ToplevelFolder (), "functions" , "non-member" )
25
+
23
26
24
27
def GenerateEnumDeclarations ():
25
28
#https://eel.is/c++draft/enum
@@ -69,6 +72,41 @@ def GenerateClassSpecifiers():
69
72
return generator
70
73
71
74
75
+ def GenerateNonMemberFunctions ():
76
+ special_cases = """
77
+ int const f\(\);|
78
+ int volatile f\(\);|
79
+ int const volatile f\(\);|
80
+ int\* f\(\);|
81
+ int& f\(\);|
82
+ int&& f\(\);|
83
+ void f\(bool const b\);|
84
+ void f\(bool volatile b\);|
85
+ void f\(bool const volatile b\);|
86
+ void f\(bool& b\);|
87
+ void f\(bool&& b\);|
88
+ int f\(bool b\.\.\.\);|
89
+ void f\(\) noexcept;|
90
+ void f\(\) noexcept\(false\);|
91
+ extern "C" int f\(bool b\);|
92
+ namespace CppScope \{ extern "C" int f\(bool b\); \}|
93
+ extern "C" \{ extern "C\+\+" int f\(bool b\); \}|
94
+ int f\(bool b\) = delete;|
95
+ int f\(bool b\) try \{ return b \? 1 : 2; \} catch\(\.\.\.\) \{ throw; \}|
96
+ int f\(bool b\) noexcept\(false\) try \{ return b \? 1 : 2; \} catch\(\.\.\.\) \{ throw; \}|
97
+ auto f\(bool b\) -> int;|
98
+ auto f\(bool b\) -> auto \{ return b; \}|
99
+ class C;\n int C::\* f\(int C::\* p\);|
100
+ class C;\n using MemFnPtr = char\(C::\*\)\(int\) const&;\n const MemFnPtr& f\(MemFnPtr a, MemFnPtr& b, MemFnPtr&& c, const MemFnPtr& d\);
101
+ """
102
+ all_fundamental_types_except_void = "decltype\(nullptr\)|bool|char|signed char|unsigned char|char8_t|char16_t|char32_t|wchar_t|short|int|long|long long|unsigned short|unsigned int|unsigned long|unsigned long long|float|double|long double"
103
+ all_fundamental_types = f"{ all_fundamental_types_except_void } |void"
104
+ function_returning_fundamental_types = f"({ all_fundamental_types } ) f\(\);"
105
+ function_taking_one_fundamental_type = f"void f\(({ all_fundamental_types_except_void } ) arg\);"
106
+ regex = f"({ function_returning_fundamental_types } |{ function_taking_one_fundamental_type } |{ special_cases } )"
107
+ generator = exrex .generate (regex )
108
+ return generator
109
+
72
110
def GenerateIndexedCppFiles (parentDirectory , fileContents ):
73
111
os .makedirs (parentDirectory , exist_ok = True )
74
112
for index , aDeclaration in enumerate (fileContents ):
@@ -84,3 +122,4 @@ def GenerateIndexedCppFiles(parentDirectory, fileContents):
84
122
GenerateIndexedCppFiles (EmptyDeclarationFolder (), [";" ])
85
123
GenerateIndexedCppFiles (NamespaceDefinitionsFolder (), GenerateNamespaceDefinitions ())
86
124
GenerateIndexedCppFiles (ClassSpecifiersFolder (), GenerateClassSpecifiers ())
125
+ GenerateIndexedCppFiles (NonMemberFunctionDeclarationsFolder (), GenerateNonMemberFunctions ())
0 commit comments