@@ -100,6 +100,12 @@ def warning_print(fmt, *args):
100
100
101
101
if debug :
102
102
103
+ class _debug_caller_lineno :
104
+ def __str__ (self ):
105
+ return str (inspect .currentframe ().f_back .f_back .f_back .f_lineno )
106
+
107
+ debug_caller_lineno = _debug_caller_lineno ()
108
+
103
109
def debug_print (fmt , * args ):
104
110
fmt = "[%4d] " + fmt
105
111
args = (inspect .currentframe ().f_back .f_lineno ,) + args
@@ -108,16 +114,18 @@ def debug_print(fmt, *args):
108
114
109
115
else :
110
116
117
+ debug_caller_lineno = None
118
+
111
119
def debug_print (fmt , * args ):
112
120
pass
113
121
114
122
115
123
if debug_trace :
116
124
117
125
def trace_print (* args ):
118
- sys .stdout .write ("[%s] " % (inspect .currentframe ().f_back .f_lineno ))
126
+ sys .stdout .write ("[%s]" % (inspect .currentframe ().f_back .f_lineno ))
119
127
for a in args :
120
- sys .stdout .write ("%s " % a )
128
+ sys .stdout .write (" %s " % a )
121
129
sys .stdout .write ("\n " )
122
130
123
131
@@ -721,7 +729,7 @@ def __init__(self, nameStack, curTemplate, doxygen, location, defaultAccess):
721
729
722
730
if curTemplate :
723
731
self ["template" ] = curTemplate
724
- trace_print ("Setting template to '%s'" % self ["template" ])
732
+ trace_print ("Setting template to" , self ["template" ])
725
733
726
734
methodAccessSpecificList = {}
727
735
propertyAccessSpecificList = {}
@@ -1857,7 +1865,6 @@ def finalize_vars(self):
1857
1865
else :
1858
1866
trace_print ("WARN-this should almost never happen!" )
1859
1867
trace_print (var )
1860
- trace_print ("-" * 80 )
1861
1868
var ["unresolved" ] = True
1862
1869
1863
1870
elif tag in self ._template_typenames :
@@ -1942,23 +1949,23 @@ def finalize_vars(self):
1942
1949
# var['raw_type'] = var['raw_type'][2:]
1943
1950
1944
1951
# Take care of #defines and #pragmas etc
1945
- trace_print ("Processing precomp_macro_buf: %s" % self ._precomp_macro_buf )
1952
+ trace_print ("Processing precomp_macro_buf:" , self ._precomp_macro_buf )
1946
1953
for m , location in self ._precomp_macro_buf :
1947
1954
macro = m .replace ("<CppHeaderParser_newline_temp_replacement>\\ n" , "\n " )
1948
1955
ml = macro .lower ()
1949
1956
try :
1950
1957
if ml .startswith ("#define" ):
1951
- trace_print ("Adding #define %s" % macro )
1958
+ trace_print ("Adding #define" , macro )
1952
1959
define = CppDefine (macro , location )
1953
1960
self .defines .append (define ["value" ])
1954
1961
self .defines_detail .append (define )
1955
1962
elif ml .startswith ("#pragma" ):
1956
- trace_print ("Adding #pragma %s" % macro )
1963
+ trace_print ("Adding #pragma" , macro )
1957
1964
pragma = CppPragma (macro , location )
1958
1965
self .pragmas_detail .append (pragma )
1959
1966
self .pragmas .append (pragma ["value" ])
1960
1967
elif ml .startswith ("#include" ):
1961
- trace_print ("Adding #include %s" % macro )
1968
+ trace_print ("Adding #include" , macro )
1962
1969
include = CppInclude (macro , location )
1963
1970
self .includes .append (include ["value" ])
1964
1971
self .includes_detail .append (include )
@@ -2447,8 +2454,9 @@ def _evaluate_property_stack(self, clearStack=True, addToVar=None):
2447
2454
# Is it really a list of variables?
2448
2455
if leftMostComma != 0 :
2449
2456
trace_print (
2450
- "Multiple variables for namestack in %s. Separating processing"
2451
- % self .nameStack
2457
+ "Multiple variables for namestack in" ,
2458
+ self .nameStack ,
2459
+ ". Separating processing" ,
2452
2460
)
2453
2461
orig_nameStack = self .nameStack [:]
2454
2462
@@ -2572,7 +2580,6 @@ def _evaluate_class_stack(self):
2572
2580
if key in self .classes :
2573
2581
trace_print ("ERROR name collision:" , key )
2574
2582
self .classes [key ].show ()
2575
- trace_print ("-" * 80 )
2576
2583
newClass .show ()
2577
2584
assert key not in self .classes # namespace collision
2578
2585
self .classes [key ] = newClass
@@ -3237,10 +3244,10 @@ def _evaluate_stack(self, token=None):
3237
3244
nameStackCopy = self .nameStack [:]
3238
3245
3239
3246
debug_print (
3240
- "Evaluating stack %s\n BraceDepth: %s (called from %d )" ,
3247
+ "Evaluating stack %s\n BraceDepth: %s (called from %s )" ,
3241
3248
self .nameStack ,
3242
3249
self .braceDepth ,
3243
- inspect . currentframe (). f_back . f_lineno ,
3250
+ debug_caller_lineno ,
3244
3251
)
3245
3252
3246
3253
# Handle special case of overloading operator ()
@@ -3282,7 +3289,7 @@ def _evaluate_stack(self, token=None):
3282
3289
)
3283
3290
):
3284
3291
debug_print ("trace" )
3285
- trace_print ("typedef %s " , self .stack )
3292
+ trace_print ("typedef" , self .stack )
3286
3293
self ._evaluate_typedef ()
3287
3294
return
3288
3295
@@ -3399,7 +3406,7 @@ def _evaluate_stack(self, token=None):
3399
3406
elif self .braceDepth > len (self .nameSpaces ) + 1 :
3400
3407
debug_print ("trace" )
3401
3408
else :
3402
- debug_print ("Discarded statement %s" % ( self .nameStack ,) )
3409
+ debug_print ("Discarded statement %s" , self .nameStack )
3403
3410
3404
3411
try :
3405
3412
self .nameStackHistory [self .braceDepth ] = (nameStackCopy , self .curClass )
@@ -3635,35 +3642,35 @@ def _strip_parent_keys(self):
3635
3642
obj_queue = [self ]
3636
3643
while len (obj_queue ):
3637
3644
obj = obj_queue .pop ()
3638
- trace_print ("pop %s type %s" % ( obj , type (obj ) ))
3645
+ trace_print ("pop" , obj , " type" , type (obj ))
3639
3646
try :
3640
3647
if "parent" in obj .keys ():
3641
3648
del obj ["parent" ]
3642
- trace_print ("Stripped parent from %s" % obj .keys ())
3649
+ trace_print ("Stripped parent from" , obj .keys ())
3643
3650
except :
3644
3651
pass
3645
3652
try :
3646
3653
if "method" in obj .keys ():
3647
3654
del obj ["method" ]
3648
- trace_print ("Stripped method from %s" % obj .keys ())
3655
+ trace_print ("Stripped method from" , obj .keys ())
3649
3656
except :
3650
3657
pass
3651
3658
# Figure out what sub types are one of ours
3652
3659
try :
3653
3660
if not hasattr (obj , "keys" ):
3654
3661
obj = obj .__dict__
3655
3662
for k in obj .keys ():
3656
- trace_print ("-Try key %s" % ( k ) )
3657
- trace_print ("-type %s" % ( type (obj [k ]) ))
3663
+ trace_print ("-Try key" , k )
3664
+ trace_print ("-type" , type (obj [k ]))
3658
3665
if k in ["nameStackHistory" , "parent" , "_public_typedefs" ]:
3659
3666
continue
3660
3667
if type (obj [k ]) == list :
3661
3668
for i in obj [k ]:
3662
- trace_print ("push l %s" % i )
3669
+ trace_print ("push l" , i )
3663
3670
obj_queue .append (i )
3664
3671
elif type (obj [k ]) == dict :
3665
3672
if len (obj ):
3666
- trace_print ("push d %s" % obj [k ])
3673
+ trace_print ("push d" , obj [k ])
3667
3674
obj_queue .append (obj [k ])
3668
3675
elif type (obj [k ]) == type (type (0 )):
3669
3676
if type (obj [k ]) == int :
0 commit comments