Skip to content

Commit

Permalink
Force ObjC++ for expr-based commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Williams committed Oct 15, 2015
1 parent 598fb71 commit 23b895f
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions commands/FBAccessibilityCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ def forceStartAccessibilityServer():
if not fb.evaluateBooleanExpression('[UIView instancesRespondToSelector:@selector(_accessibilityElementsInContainer:)]'):
#Starting accessibility server is different for simulator and device
if fb.evaluateExpressionValue('(id)[[UIDevice currentDevice] model]').GetObjectDescription().lower().find('simulator') >= 0:
lldb.debugger.HandleCommand('expr (void)[[UIApplication sharedApplication] accessibilityActivate]')
lldb.debugger.HandleCommand('expr -l Objc++ -- (void)[[UIApplication sharedApplication] accessibilityActivate]')
else:
lldb.debugger.HandleCommand('expr (void)[[[UIApplication sharedApplication] _accessibilityBundlePrincipalClass] _accessibilityStartServer]')
lldb.debugger.HandleCommand('expr -l Objc++ -- (void)[[[UIApplication sharedApplication] _accessibilityBundlePrincipalClass] _accessibilityStartServer]')

def accessibilityLabel(view):
#using Apple private API to get real value of accessibility string for element.
Expand Down
4 changes: 2 additions & 2 deletions commands/FBAutoLayoutCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def setBorderOnAmbiguousViewRecursive(view, width, color):
isAmbiguous = fb.evaluateBooleanExpression('(BOOL)[%s hasAmbiguousLayout]' % view)
if isAmbiguous:
layer = viewHelpers.convertToLayer(view)
lldb.debugger.HandleCommand('expr (void)[%s setBorderWidth:(CGFloat)%s]' % (layer, width))
lldb.debugger.HandleCommand('expr (void)[%s setBorderColor:(CGColorRef)[(id)[UIColor %sColor] CGColor]]' % (layer, color))
lldb.debugger.HandleCommand('expr -l Objc++ -- (void)[%s setBorderWidth:(CGFloat)%s]' % (layer, width))
lldb.debugger.HandleCommand('expr -l Objc++ -- (void)[%s setBorderColor:(CGColorRef)[(id)[UIColor %sColor] CGColor]]' % (layer, color))

subviews = fb.evaluateExpression('(id)[%s subviews]' % view)
subviewsCount = int(fb.evaluateExpression('(int)[(id)%s count]' % subviews))
Expand Down
4 changes: 2 additions & 2 deletions commands/FBComponentCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ def options(self):

def run(self, arguments, options):
if options.set:
lldb.debugger.HandleCommand('expr (void)[CKComponentDebugController setDebugMode:YES]')
lldb.debugger.HandleCommand('expr -l Objc++ -- (void)[CKComponentDebugController setDebugMode:YES]')
print 'Debug mode for ComponentKit has been set.'
elif options.unset:
lldb.debugger.HandleCommand('expr (void)[CKComponentDebugController setDebugMode:NO]')
lldb.debugger.HandleCommand('expr -l Objc++ -- (void)[CKComponentDebugController setDebugMode:NO]')
print 'Debug mode for ComponentKit has been unset.'
else:
print 'No option for ComponentKit Debug mode specified.'
Expand Down
6 changes: 3 additions & 3 deletions commands/FBDisplayCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def run(self, args, options):
colorClassName = 'NSColor'

layer = viewHelpers.convertToLayer(args[0])
lldb.debugger.HandleCommand('expr (void)[%s setBorderWidth:(CGFloat)%s]' % (layer, options.width))
lldb.debugger.HandleCommand('expr (void)[%s setBorderColor:(CGColorRef)[(id)[%s %sColor] CGColor]]' % (layer, colorClassName, options.color))
lldb.debugger.HandleCommand('expr -l Objc++ -- (void)[%s setBorderWidth:(CGFloat)%s]' % (layer, options.width))
lldb.debugger.HandleCommand('expr -l Objc++ -- (void)[%s setBorderColor:(CGColorRef)[(id)[%s %sColor] CGColor]]' % (layer, colorClassName, options.color))
lldb.debugger.HandleCommand('caflush')


Expand All @@ -68,7 +68,7 @@ def args(self):

def run(self, args, options):
layer = viewHelpers.convertToLayer(args[0])
lldb.debugger.HandleCommand('expr (void)[%s setBorderWidth:(CGFloat)%s]' % (layer, 0))
lldb.debugger.HandleCommand('expr -l Objc++ -- (void)[%s setBorderWidth:(CGFloat)%s]' % (layer, 0))
lldb.debugger.HandleCommand('caflush')


Expand Down
4 changes: 2 additions & 2 deletions commands/FBInvocationCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ def prettyPrintInvocation(frame, invocation):
for argDescription in argDescriptions:
s = re.sub(r'argument [0-9]+: ', '', argDescription)

lldb.debugger.HandleCommand('expr void *$v')
lldb.debugger.HandleCommand('expr (void)[' + invocation + ' getArgument:&$v atIndex:' + str(index) + ']')
lldb.debugger.HandleCommand('expr -l Objc++ -- void *$v')
lldb.debugger.HandleCommand('expr -l Objc++ -- (void)[' + invocation + ' getArgument:&$v atIndex:' + str(index) + ']')

address = findArgAdressAtIndexFromStackFrame(frame, index)

Expand Down
14 changes: 7 additions & 7 deletions commands/FBVisualizationCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ def _showColor(color):
colorToUse = '[UIColor colorWithCIColor:(CIColor *){}]'.format(color)

imageSize = 58
lldb.debugger.HandleCommand('expr (void)UIGraphicsBeginImageContextWithOptions((CGSize)CGSizeMake({imageSize}, {imageSize}), NO, 0.0)'.format(imageSize=imageSize))
lldb.debugger.HandleCommand('expr (void)[(id){} setFill]'.format(colorToUse))
lldb.debugger.HandleCommand('expr (void)UIRectFill((CGRect)CGRectMake(0.0, 0.0, {imageSize}, {imageSize}))'.format(imageSize=imageSize))
lldb.debugger.HandleCommand('expr -l Objc++ -- (void)UIGraphicsBeginImageContextWithOptions((CGSize)CGSizeMake({imageSize}, {imageSize}), NO, 0.0)'.format(imageSize=imageSize))
lldb.debugger.HandleCommand('expr -l Objc++ -- (void)[(id){} setFill]'.format(colorToUse))
lldb.debugger.HandleCommand('expr -l Objc++ -- (void)UIRectFill((CGRect)CGRectMake(0.0, 0.0, {imageSize}, {imageSize}))'.format(imageSize=imageSize))

frame = lldb.debugger.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame()
result = frame.EvaluateExpression('(UIImage *)UIGraphicsGetImageFromCurrentImageContext()')
Expand All @@ -96,13 +96,13 @@ def _showColor(color):
image = result.GetValue()
_showImage(image)

lldb.debugger.HandleCommand('expr (void)UIGraphicsEndImageContext()')
lldb.debugger.HandleCommand('expr -l Objc++ -- (void)UIGraphicsEndImageContext()')

def _showLayer(layer):
layer = '(' + layer + ')'

lldb.debugger.HandleCommand('expr (void)UIGraphicsBeginImageContextWithOptions(((CGRect)[(id)' + layer + ' bounds]).size, NO, 0.0)')
lldb.debugger.HandleCommand('expr (void)[(id)' + layer + ' renderInContext:(void *)UIGraphicsGetCurrentContext()]')
lldb.debugger.HandleCommand('expr -l Objc++ -- (void)UIGraphicsBeginImageContextWithOptions(((CGRect)[(id)' + layer + ' bounds]).size, NO, 0.0)')
lldb.debugger.HandleCommand('expr -l Objc++ -- (void)[(id)' + layer + ' renderInContext:(void *)UIGraphicsGetCurrentContext()]')

frame = lldb.debugger.GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame()
result = frame.EvaluateExpression('(UIImage *)UIGraphicsGetImageFromCurrentImageContext()')
Expand All @@ -112,7 +112,7 @@ def _showLayer(layer):
image = result.GetValue()
_showImage(image)

lldb.debugger.HandleCommand('expr (void)UIGraphicsEndImageContext()')
lldb.debugger.HandleCommand('expr -l Objc++ -- (void)UIGraphicsEndImageContext()')

def _dataIsImage(data):
data = '(' + data + ')'
Expand Down
16 changes: 8 additions & 8 deletions fblldbviewhelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
import fblldbbase as fb

def flushCoreAnimationTransaction():
lldb.debugger.HandleCommand('expr (void)[CATransaction flush]')
lldb.debugger.HandleCommand('expr -l Objc++ -- (void)[CATransaction flush]')

def setViewHidden(object, hidden):
lldb.debugger.HandleCommand('expr (void)[' + object + ' setHidden:' + str(int(hidden)) + ']')
lldb.debugger.HandleCommand('expr -l Objc++ -- (void)[' + object + ' setHidden:' + str(int(hidden)) + ']')
flushCoreAnimationTransaction()

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

lldb.debugger.HandleCommand('expr (void)[%s setTag:(NSInteger)%s]' % (mask, viewOrLayer))
lldb.debugger.HandleCommand('expr (void)[%s setBackgroundColor:[UIColor %sColor]]' % (mask, color))
lldb.debugger.HandleCommand('expr (void)[%s setAlpha:(CGFloat)%s]' % (mask, alpha))
lldb.debugger.HandleCommand('expr (void)[%s addSubview:%s]' % (window, mask))
lldb.debugger.HandleCommand('expr -l Objc++ -- (void)[%s setTag:(NSInteger)%s]' % (mask, viewOrLayer))
lldb.debugger.HandleCommand('expr -l Objc++ -- (void)[%s setBackgroundColor:[UIColor %sColor]]' % (mask, color))
lldb.debugger.HandleCommand('expr -l Objc++ -- (void)[%s setAlpha:(CGFloat)%s]' % (mask, alpha))
lldb.debugger.HandleCommand('expr -l Objc++ -- (void)[%s addSubview:%s]' % (window, mask))
flushCoreAnimationTransaction()

def unmaskView(viewOrLayer):
window = fb.evaluateExpression('(UIWindow *)[[UIApplication sharedApplication] keyWindow]')
mask = fb.evaluateExpression('(UIView *)[%s viewWithTag:(NSInteger)%s]' % (window, viewOrLayer))
lldb.debugger.HandleCommand('expr (void)[%s removeFromSuperview]' % mask)
lldb.debugger.HandleCommand('expr -l Objc++ -- (void)[%s removeFromSuperview]' % mask)
flushCoreAnimationTransaction()

def convertPoint(x, y, fromViewOrLayer, toViewOrLayer):
Expand Down Expand Up @@ -89,4 +89,4 @@ def upwardsRecursiveDescription(view, maxDepth=0):
return builder

def slowAnimation(speed=1):
lldb.debugger.HandleCommand('expr (void)[[[UIApplication sharedApplication] windows] setValue:@(%s) forKeyPath:@"layer.speed"]' % speed)
lldb.debugger.HandleCommand('expr -l Objc++ -- (void)[[[UIApplication sharedApplication] windows] setValue:@(%s) forKeyPath:@"layer.speed"]' % speed)

0 comments on commit 23b895f

Please sign in to comment.