FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Combine old and new evaluate functions · extended-debug/chisel@582dfb4 · GitHub

Commit 582dfb4

Browse files
Dave Lee
committed
Combine old and new evaluate functions
`evaluateObjCExpression` and `evaluateExpressionValue` were almost identical, so this change renames `evaluateObjCExpression` to `evaluateExpressionValue` and deletes the previous implementation of `evaluateExpressionValue`.
1 parent 9083abc commit 582dfb4

10 files changed

Lines changed: 40 additions & 53 deletions

‎commands/FBAccessibilityCommands.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ def forceStartAccessibilityServer():
9595
if not fb.evaluateBooleanExpression('[UIView instancesRespondToSelector:@selector(_accessibilityElementsInContainer:)]'):
9696
#Starting accessibility server is different for simulator and device
9797
if isRunningInSimulator():
98-
fb.evaluateObjCExpression('(void)[[UIApplication sharedApplication] accessibilityActivate]')
98+
fb.evaluateExpressionValue('(void)[[UIApplication sharedApplication] accessibilityActivate]')
9999
else:
100-
fb.evaluateObjCExpression('(void)[[[UIApplication sharedApplication] _accessibilityBundlePrincipalClass] _accessibilityStartServer]')
100+
fb.evaluateExpressionValue('(void)[[[UIApplication sharedApplication] _accessibilityBundlePrincipalClass] _accessibilityStartServer]')
101101

102102
def accessibilityLabel(view):
103103
#using Apple private API to get real value of accessibility string for element.

‎commands/FBAutoLayoutCommands.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def args(self):
3131

3232
def run(self, arguments, options):
3333
view = fb.evaluateInputExpression(arguments[0])
34-
print fb.evaluateObjCExpression('(id)[{} _autolayoutTrace]'.format(view)).GetObjectDescription()
34+
print fb.evaluateExpressionValue('(id)[{} _autolayoutTrace]'.format(view)).GetObjectDescription()
3535

3636

3737
def setBorderOnAmbiguousViewRecursive(view, width, color):
@@ -41,8 +41,8 @@ def setBorderOnAmbiguousViewRecursive(view, width, color):
4141
isAmbiguous = fb.evaluateBooleanExpression('(BOOL)[%s hasAmbiguousLayout]' % view)
4242
if isAmbiguous:
4343
layer = viewHelpers.convertToLayer(view)
44-
fb.evaluateObjCExpression('(void)[%s setBorderWidth:(CGFloat)%s]' % (layer, width))
45-
fb.evaluateObjCExpression('(void)[%s setBorderColor:(CGColorRef)[(id)[UIColor %sColor] CGColor]]' % (layer, color))
44+
fb.evaluateExpressionValue('(void)[%s setBorderWidth:(CGFloat)%s]' % (layer, width))
45+
fb.evaluateExpressionValue('(void)[%s setBorderColor:(CGColorRef)[(id)[UIColor %sColor] CGColor]]' % (layer, color))
4646

4747
subviews = fb.evaluateExpression('(id)[%s subviews]' % view)
4848
subviewsCount = int(fb.evaluateExpression('(int)[(id)%s count]' % subviews))

‎commands/FBComponentCommands.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ def options(self):
3232

3333
def run(self, arguments, options):
3434
if options.set:
35-
fb.evaluateObjCExpression('(void)[CKComponentDebugController setDebugMode:YES]')
35+
fb.evaluateExpressionValue('(void)[CKComponentDebugController setDebugMode:YES]')
3636
print 'Debug mode for ComponentKit has been set.'
3737
elif options.unset:
38-
fb.evaluateObjCExpression('(void)[CKComponentDebugController setDebugMode:NO]')
38+
fb.evaluateExpressionValue('(void)[CKComponentDebugController setDebugMode:NO]')
3939
print 'Debug mode for ComponentKit has been unset.'
4040
else:
4141
print 'No option for ComponentKit Debug mode specified.'
@@ -61,7 +61,7 @@ def run(self, arguments, options):
6161
showViews = 'YES' if options.showViews == 'YES' else 'NO'
6262

6363
view = fb.evaluateInputExpression(arguments[0])
64-
print fb.evaluateObjCExpression('(id)[CKComponentHierarchyDebugHelper componentHierarchyDescriptionForView:(UIView *)' + view + ' searchUpwards:' + upwards + ' showViews:' + showViews + ']').GetObjectDescription()
64+
print fb.evaluateExpressionValue('(id)[CKComponentHierarchyDebugHelper componentHierarchyDescriptionForView:(UIView *)' + view + ' searchUpwards:' + upwards + ' showViews:' + showViews + ']').GetObjectDescription()
6565

6666
class FBComponentsReflowCommand(fb.FBCommand):
6767
def name(self):

‎commands/FBDisplayCommands.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ def options(self):
6363

6464
def run(self, args, options):
6565
def setBorder(layer, width, color, colorClass):
66-
fb.evaluateObjCExpression('(void)[%s setBorderWidth:(CGFloat)%s]' % (layer, width))
67-
fb.evaluateObjCExpression('(void)[%s setBorderColor:(CGColorRef)[(id)[%s %sColor] CGColor]]' % (layer, colorClass, color))
66+
fb.evaluateExpressionValue('(void)[%s setBorderWidth:(CGFloat)%s]' % (layer, width))
67+
fb.evaluateExpressionValue('(void)[%s setBorderColor:(CGColorRef)[(id)[%s %sColor] CGColor]]' % (layer, colorClass, color))
6868

6969
obj = fb.evaluateInputExpression(args[0])
7070
depth = int(options.depth)
@@ -114,7 +114,7 @@ def args(self):
114114

115115
def run(self, args, options):
116116
def setUnborder(layer):
117-
fb.evaluateObjCExpression('(void)[%s setBorderWidth:(CGFloat)%s]' % (layer, 0))
117+
fb.evaluateExpressionValue('(void)[%s setBorderWidth:(CGFloat)%s]' % (layer, 0))
118118

119119
obj = args[0]
120120
depth = int(options.depth)

‎commands/FBFindCommands.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,6 @@ def run(self, arguments, options):
122122
@staticmethod
123123
def taplog_callback(frame, bp_loc, internal_dict):
124124
parameterExpr = objc.functionPreambleExpressionForObjectParameterAtIndex(0)
125-
print fb.evaluateObjCExpression('(UIView *)[[[%s allTouches] anyObject] view]' % (parameterExpr)).GetObjectDescription()
125+
print fb.evaluateExpressionValue('(UIView *)[[[%s allTouches] anyObject] view]' % (parameterExpr)).GetObjectDescription()
126126
# We don't want to proceed event (click on button for example), so we just skip it
127127
lldb.debugger.HandleCommand('thread return')

‎commands/FBFlickerCommands.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def inputCallback(self, input):
111111
if isMac:
112112
recursionName = '_subtreeDescription'
113113

114-
print fb.evaluateObjCExpression('(NSString *)[(id){} {}]'.format(oldView, recursionName)).GetObjectDescription()
114+
print fb.evaluateExpressionValue('(NSString *)[(id){} {}]'.format(oldView, recursionName)).GetObjectDescription()
115115
else:
116116
print '\nI really have no idea what you meant by \'' + input + '\'... =\\\n'
117117

@@ -121,7 +121,7 @@ def setCurrentView(self, view, oldView=None):
121121
if oldView:
122122
viewHelpers.unmaskView(oldView)
123123
viewHelpers.maskView(self.currentView, 'red', '0.4')
124-
print fb.evaluateObjCExpression('(id)' + view).GetObjectDescription()
124+
print fb.evaluateExpressionValue('(id)' + view).GetObjectDescription()
125125

126126
def superviewOfView(view):
127127
superview = fb.evaluateObjectExpression('[' + view + ' superview]')

‎commands/FBPrintCommands.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def description(self):
9494
return 'Print layer tree from the perspective of the render server.'
9595

9696
def run(self, arguments, options):
97-
print fb.evaluateObjCExpression('(id)[NSString stringWithCString:(char *)CARenderServerGetInfo(0, 2, 0)]').GetObjectDescription()
97+
print fb.evaluateExpressionValue('(id)[NSString stringWithCString:(char *)CARenderServerGetInfo(0, 2, 0)]').GetObjectDescription()
9898

9999

100100
class FBPrintViewControllerHierarchyCommand(fb.FBCommand):
@@ -112,7 +112,7 @@ def run(self, arguments, options):
112112

113113
if arguments[0] == '__keyWindow_rootVC_dynamic__':
114114
if fb.evaluateBooleanExpression('[UIViewController respondsToSelector:@selector(_printHierarchy)]'):
115-
print fb.evaluateObjCExpression('(id)[UIViewController _printHierarchy]').GetObjectDescription()
115+
print fb.evaluateExpressionValue('(id)[UIViewController _printHierarchy]').GetObjectDescription()
116116
return
117117

118118
arguments[0] = '(id)[(id)[[UIApplication sharedApplication] keyWindow] rootViewController]'
@@ -289,7 +289,7 @@ def run(self, arguments, options):
289289
ivarTypeCommand = '((char *)ivar_getTypeEncoding((void*)object_getInstanceVariable((id){}, \"{}\", 0)))[0]'.format(object, ivarName)
290290
ivarTypeEncodingFirstChar = fb.evaluateExpression(ivarTypeCommand)
291291

292-
result = fb.evaluateObjCExpression('(({} *)({}))->{}'.format(printCommand, objectClass, object, ivarName))
292+
result = fb.evaluateExpressionValue('(({} *)({}))->{}'.format(printCommand, objectClass, object, ivarName))
293293
return result.GetObjectDescription() if '@' in ivarTypeEncodingFirstChar else result.GetValue()
294294

295295
class FBPrintKeyPath(fb.FBCommand):
@@ -312,7 +312,7 @@ def run(self, arguments, options):
312312
objectToMessage, keypath = command.split('.', 1)
313313
object = fb.evaluateObjectExpression(objectToMessage)
314314
printCommand = '(id)[{} valueForKeyPath:@"{}"]'.format(object, keypath)
315-
print fb.evaluateObjCExpression(printCommand).GetObjectDescription()
315+
print fb.evaluateExpressionValue(printCommand).GetObjectDescription()
316316

317317

318318
class FBPrintApplicationDocumentsPath(fb.FBCommand):
@@ -409,7 +409,7 @@ def run(self, arguments, option):
409409
enc = 0x9c000100
410410

411411
print_command = '(id)[[NSString alloc] initWithData:{} encoding:{}]'.format(arguments[0], enc)
412-
print fb.evaluateObjCExpression(print_command).GetObjectDescription()
412+
print fb.evaluateExpressionValue(print_command).GetObjectDescription()
413413

414414
class FBPrintTargetActions(fb.FBCommand):
415415

‎commands/FBVisualizationCommands.py‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ def _showColor(color):
8383
colorToUse = '[UIColor colorWithCIColor:(CIColor *){}]'.format(color)
8484

8585
imageSize = 58
86-
fb.evaluateObjCExpression('(void)UIGraphicsBeginImageContextWithOptions((CGSize)CGSizeMake({imageSize}, {imageSize}), NO, 0.0)'.format(imageSize=imageSize))
87-
fb.evaluateObjCExpression('(void)[(id){} setFill]'.format(colorToUse))
88-
fb.evaluateObjCExpression('(void)UIRectFill((CGRect)CGRectMake(0.0, 0.0, {imageSize}, {imageSize}))'.format(imageSize=imageSize))
86+
fb.evaluateExpressionValue('(void)UIGraphicsBeginImageContextWithOptions((CGSize)CGSizeMake({imageSize}, {imageSize}), NO, 0.0)'.format(imageSize=imageSize))
87+
fb.evaluateExpressionValue('(void)[(id){} setFill]'.format(colorToUse))
88+
fb.evaluateExpressionValue('(void)UIRectFill((CGRect)CGRectMake(0.0, 0.0, {imageSize}, {imageSize}))'.format(imageSize=imageSize))
8989

9090
frame = lldb.debugger.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame()
9191
result = frame.EvaluateExpression('(UIImage *)UIGraphicsGetImageFromCurrentImageContext()')
@@ -96,7 +96,7 @@ def _showColor(color):
9696
image = result.GetValue()
9797
_showImage(image)
9898

99-
fb.evaluateObjCExpression('(void)UIGraphicsEndImageContext()')
99+
fb.evaluateExpressionValue('(void)UIGraphicsEndImageContext()')
100100

101101
def _showLayer(layer):
102102
layer = '(' + layer + ')'
@@ -108,8 +108,8 @@ def _showLayer(layer):
108108
print 'Nothing to see here - the size of this element is {} x {}.'.format(width, height)
109109
return
110110

111-
fb.evaluateObjCExpression('(void)UIGraphicsBeginImageContextWithOptions(' + size + ', NO, 0.0)')
112-
fb.evaluateObjCExpression('(void)[(id)' + layer + ' renderInContext:(void *)UIGraphicsGetCurrentContext()]')
111+
fb.evaluateExpressionValue('(void)UIGraphicsBeginImageContextWithOptions(' + size + ', NO, 0.0)')
112+
fb.evaluateExpressionValue('(void)[(id)' + layer + ' renderInContext:(void *)UIGraphicsGetCurrentContext()]')
113113

114114
frame = lldb.debugger.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame()
115115
result = frame.EvaluateExpression('(UIImage *)UIGraphicsGetImageFromCurrentImageContext()')
@@ -119,7 +119,7 @@ def _showLayer(layer):
119119
image = result.GetValue()
120120
_showImage(image)
121121

122-
fb.evaluateObjCExpression('(void)UIGraphicsEndImageContext()')
122+
fb.evaluateExpressionValue('(void)UIGraphicsEndImageContext()')
123123

124124
def _dataIsImage(data):
125125
data = '(' + data + ')'
@@ -163,7 +163,7 @@ def _visualize(target):
163163
if _dataIsImage(target):
164164
_showImage('(id)[UIImage imageWithData:' + target + ']')
165165
elif _dataIsString(target):
166-
print fb.evaluateObjCExpression('(id)[[NSString alloc] initWithData:' + target + ' encoding:4]').GetObjectDescription()
166+
print fb.evaluateExpressionValue('(id)[[NSString alloc] initWithData:' + target + ' encoding:4]').GetObjectDescription()
167167
else:
168168
print 'Data isn\'t an image and isn\'t a string.'
169169
else:

‎fblldbbase.py‎

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,12 @@ def description(self):
3636
def run(self, arguments, option):
3737
pass
3838

39-
def evaluateObjCExpression(expression, printErrors=True):
39+
# evaluates expression in Objective-C++ context, so it will work even for
40+
# Swift projects
41+
def evaluateExpressionValue(expression, printErrors=True):
4042
frame = lldb.debugger.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame()
4143
options = lldb.SBExpressionOptions()
42-
options.SetLanguage(lldb.eLanguageTypeObjC)
44+
options.SetLanguage(lldb.eLanguageTypeObjC_plus_plus)
4345
value = frame.EvaluateExpression(expression, options)
4446
error = value.GetError()
4547

@@ -56,7 +58,7 @@ def evaluateObjCExpression(expression, printErrors=True):
5658
def evaluateInputExpression(expression, printErrors=True):
5759
# HACK
5860
if expression.startswith('(id)'):
59-
return evaluateObjCExpression(expression, printErrors).GetValue()
61+
return evaluateExpressionValue(expression, printErrors).GetValue()
6062

6163
frame = lldb.debugger.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame()
6264
value = frame.EvaluateExpression(expression)
@@ -67,21 +69,6 @@ def evaluateInputExpression(expression, printErrors=True):
6769

6870
return value.GetValue()
6971

70-
def evaluateExpressionValueWithLanguage(expression, language, printErrors):
71-
# lldb.frame is supposed to contain the right frame, but it doesnt :/ so do the dance
72-
frame = lldb.debugger.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame()
73-
expr_options = lldb.SBExpressionOptions()
74-
expr_options.SetLanguage(language) # requires lldb r210874 (2014-06-13) / Xcode 6
75-
value = frame.EvaluateExpression(expression, expr_options)
76-
if printErrors and value.GetError() is not None and str(value.GetError()) != 'success':
77-
print value.GetError()
78-
return value
79-
80-
# evaluates expression in Objective-C++ context, so it will work even for
81-
# Swift projects
82-
def evaluateExpressionValue(expression, printErrors=True):
83-
return evaluateExpressionValueWithLanguage(expression, lldb.eLanguageTypeObjC_plus_plus, printErrors)
84-
8572
def evaluateIntegerExpression(expression, printErrors=True):
8673
output = evaluateExpression('(int)(' + expression + ')', printErrors).replace('\'', '')
8774
if output.startswith('\\x'): # Booleans may display as \x01 (Hex)

‎fblldbviewhelpers.py‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
import fblldbobjcruntimehelpers as runtimeHelpers
1414

1515
def flushCoreAnimationTransaction():
16-
fb.evaluateObjCExpression('(void)[CATransaction flush]')
16+
fb.evaluateExpressionValue('(void)[CATransaction flush]')
1717

1818
def setViewHidden(object, hidden):
19-
fb.evaluateObjCExpression('(void)[{} setHidden:{}]'.format(object, int(hidden)))
19+
fb.evaluateExpressionValue('(void)[{} setHidden:{}]'.format(object, int(hidden)))
2020
flushCoreAnimationTransaction()
2121

2222
def maskView(viewOrLayer, color, alpha):
@@ -31,16 +31,16 @@ def maskView(viewOrLayer, color, alpha):
3131
size.GetChildMemberWithName('height').GetValue())
3232
mask = fb.evaluateExpression('(id)[[UIView alloc] initWithFrame:%s]' % rectExpr)
3333

34-
fb.evaluateObjCExpression('(void)[%s setTag:(NSInteger)%s]' % (mask, viewOrLayer))
35-
fb.evaluateObjCExpression('(void)[%s setBackgroundColor:[UIColor %sColor]]' % (mask, color))
36-
fb.evaluateObjCExpression('(void)[%s setAlpha:(CGFloat)%s]' % (mask, alpha))
37-
fb.evaluateObjCExpression('(void)[%s addSubview:%s]' % (window, mask))
34+
fb.evaluateExpressionValue('(void)[%s setTag:(NSInteger)%s]' % (mask, viewOrLayer))
35+
fb.evaluateExpressionValue('(void)[%s setBackgroundColor:[UIColor %sColor]]' % (mask, color))
36+
fb.evaluateExpressionValue('(void)[%s setAlpha:(CGFloat)%s]' % (mask, alpha))
37+
fb.evaluateExpressionValue('(void)[%s addSubview:%s]' % (window, mask))
3838
flushCoreAnimationTransaction()
3939

4040
def unmaskView(viewOrLayer):
4141
window = fb.evaluateExpression('(UIWindow *)[[UIApplication sharedApplication] keyWindow]')
4242
mask = fb.evaluateExpression('(UIView *)[%s viewWithTag:(NSInteger)%s]' % (window, viewOrLayer))
43-
fb.evaluateObjCExpression('(void)[%s removeFromSuperview]' % mask)
43+
fb.evaluateExpressionValue('(void)[%s removeFromSuperview]' % mask)
4444
flushCoreAnimationTransaction()
4545

4646
def convertPoint(x, y, fromViewOrLayer, toViewOrLayer):
@@ -113,4 +113,4 @@ def upwardsRecursiveDescription(view, maxDepth=0):
113113
return builder
114114

115115
def slowAnimation(speed=1):
116-
fb.evaluateObjCExpression('(void)[[[UIApplication sharedApplication] windows] setValue:@(%s) forKeyPath:@"layer.speed"]' % speed)
116+
fb.evaluateExpressionValue('(void)[[[UIApplication sharedApplication] windows] setValue:@(%s) forKeyPath:@"layer.speed"]' % speed)

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL