@@ -139,12 +139,14 @@ def run(self, arguments, options):
139
139
command = string .Template (tmpString ).substitute (block = block )
140
140
json = fb .evaluate (command )
141
141
142
- variables_json = self .getBlockVariables (block )
142
+ # We assume that the maximum number of variables captured by the block is 10
143
+ max_var_count = 10
144
+ variables_json = self .getBlockVariables (block , max_var_count )
143
145
if variables_json is not None :
144
146
json .update (variables_json )
145
147
146
148
variablesStrs = []
147
- for i in range (10 ):
149
+ for i in range (max_var_count ):
148
150
varKey = 'variables[' + str (i )+ ']'
149
151
if varKey in json :
150
152
variablesStrs .append (json [varKey ])
@@ -162,9 +164,12 @@ def run(self, arguments, options):
162
164
163
165
print 'Imp: ' + hex (json ['invoke' ]) + ' Signature: ' + sigStr + ' Variables : {\n ' + variablesStr + '\n };'
164
166
165
- def getBlockVariables (self , block , min_var_count = 1 , max_var_count = 20 ):
167
+ def getBlockVariables (self , block , max_var_count ):
166
168
'''
167
169
no __Block_byref_xxx
170
+ We must check the block's captured variables one by one here.
171
+ no reason, but it works.
172
+ We assume that the maximum number of variables captured by the block is max_var_count
168
173
'''
169
174
170
175
# http://clang.llvm.org/docs/Block-ABI-Apple.html
@@ -236,7 +241,7 @@ def getBlockVariables(self, block, min_var_count=1, max_var_count=20):
236
241
RETURN(dict);
237
242
"""
238
243
last_json = None
239
- for i in range (min_var_count , max_var_count ):
244
+ for i in range (1 , max_var_count ):
240
245
command = string .Template (tmpString ).substitute (block = block , variables_count = i )
241
246
json = fb .evaluate (command , printErrors = False )
242
247
if json is not None :
0 commit comments