@@ -2702,7 +2702,14 @@ def show(self):
2702
2702
for className in list (self .classes .keys ()):
2703
2703
self .classes [className ].show ()
2704
2704
2705
- def __init__ (self , headerFileName , argType = "file" , encoding = None , ** kwargs ):
2705
+ def __init__ (
2706
+ self ,
2707
+ headerFileName ,
2708
+ argType = "file" ,
2709
+ encoding = None ,
2710
+ preprocessed = False ,
2711
+ ** kwargs
2712
+ ):
2706
2713
"""Create the parsed C++ header file parse tree
2707
2714
2708
2715
headerFileName - Name of the file to parse OR actual file contents (depends on argType)
@@ -2802,21 +2809,24 @@ def __init__(self, headerFileName, argType="file", encoding=None, **kwargs):
2802
2809
"[ ]+" , " " , supportedAccessSpecifier [i ]
2803
2810
).strip ()
2804
2811
2805
- # Change multi line #defines and expressions to single lines maintaining line nubmers
2806
- # Based from http://stackoverflow.com/questions/2424458/regular-expression-to-match-cs-multiline-preprocessor-statements
2807
- matches = re .findall (r"(?m)^(?:.*\\\r?\n)+.*$" , headerFileStr )
2808
- is_define = re .compile (r"[ \t\v]*#[Dd][Ee][Ff][Ii][Nn][Ee]" )
2809
- for m in matches :
2810
- # Keep the newlines so that linecount doesnt break
2811
- num_newlines = len ([a for a in m if a == "\n " ])
2812
- if is_define .match (m ):
2813
- new_m = m .replace ("\n " , "<CppHeaderParser_newline_temp_replacement>\\ n" )
2814
- else :
2815
- # Just expression taking up multiple lines, make it take 1 line for easier parsing
2816
- new_m = m .replace ("\\ \n " , " " )
2817
- if num_newlines > 0 :
2818
- new_m += "\n " * (num_newlines )
2819
- headerFileStr = headerFileStr .replace (m , new_m )
2812
+ if not preprocessed :
2813
+ # Change multi line #defines and expressions to single lines maintaining line nubmers
2814
+ # Based from http://stackoverflow.com/questions/2424458/regular-expression-to-match-cs-multiline-preprocessor-statements
2815
+ matches = re .findall (r"(?m)^(?:.*\\\r?\n)+.*$" , headerFileStr )
2816
+ is_define = re .compile (r"[ \t\v]*#[Dd][Ee][Ff][Ii][Nn][Ee]" )
2817
+ for m in matches :
2818
+ # Keep the newlines so that linecount doesnt break
2819
+ num_newlines = len ([a for a in m if a == "\n " ])
2820
+ if is_define .match (m ):
2821
+ new_m = m .replace (
2822
+ "\n " , "<CppHeaderParser_newline_temp_replacement>\\ n"
2823
+ )
2824
+ else :
2825
+ # Just expression taking up multiple lines, make it take 1 line for easier parsing
2826
+ new_m = m .replace ("\\ \n " , " " )
2827
+ if num_newlines > 0 :
2828
+ new_m += "\n " * (num_newlines )
2829
+ headerFileStr = headerFileStr .replace (m , new_m )
2820
2830
2821
2831
# Filter out Extern "C" statements. These are order dependent
2822
2832
matches = re .findall (
0 commit comments