Skip to content

Commit

Permalink
Merge pull request #86 from facebook/componentkit
Browse files Browse the repository at this point in the history
Add pcomponents/dcomponents/rcomponents for debugging in ComponentKit
  • Loading branch information
kastiglione committed Mar 26, 2015
2 parents d447d64 + 3d961fe commit 800e3af
Showing 1 changed file with 81 additions and 0 deletions.
81 changes: 81 additions & 0 deletions commands/FBComponentCommands.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/usr/bin/python

import os

import lldb
import fblldbbase as fb

def lldbinit():
# Tell LLDB to print CKComponentAction as a c-string
lldb.debugger.HandleCommand('type summary add --summary-string "${var%c-string}" CKComponentAction')

def lldbcommands():
return [
FBComponentsDebugCommand(),
FBComponentsPrintCommand(),
FBComponentsReflowCommand(),
]


class FBComponentsDebugCommand(fb.FBCommand):
def name(self):
return 'dcomponents'

def description(self):
return 'Set debugging options for components.'

def options(self):
return [
fb.FBCommandArgument(short='-s', long='--set', arg='set', help='Set debug mode for components', boolean=True),
fb.FBCommandArgument(short='-u', long='--unset', arg='unset', help='Unset debug mode for components', boolean=True),
]

def run(self, arguments, options):
if options.set:
lldb.debugger.HandleCommand('expr (void)[CKComponentDebugController setDebugMode:YES]')
print 'Debug mode for ComponentKit has been set.'
elif options.unset:
lldb.debugger.HandleCommand('expr (void)[CKComponentDebugController setDebugMode:NO]')
print 'Debug mode for ComponentKit has been unset.'
else:
print 'No option for ComponentKit Debug mode specified.'

class FBComponentsPrintCommand(fb.FBCommand):
def name(self):
return 'pcomponents'

def description(self):
return 'Print a recursive description of components found starting from <aView>.'

def options(self):
return [ fb.FBCommandArgument(short='-u', long='--up', arg='upwards', boolean=True, default=False, help='Print only the component hierarchy found on the first superview that has them, carrying the search up to its window.') ]

def args(self):
return [ fb.FBCommandArgument(arg='aView', type='UIView*', help='The view to from which the search for components begins.', default='(id)[[UIApplication sharedApplication] keyWindow]') ]

def run(self, arguments, options):
upwards = 'NO'
if options.upwards:
upwards = 'YES'

lldb.debugger.HandleCommand('po (id)[CKComponentHierarchyDebugHelper componentHierarchyDescriptionForView:(UIView *)' + arguments[0] + ' searchUpwards:' + upwards + ']')

class FBComponentsReflowCommand(fb.FBCommand):
def name(self):
return 'rcomponents'

def description(self):
return 'Synchronously reflow and update root components found starting from <aView>.'

def options(self):
return [ fb.FBCommandArgument(short='-u', long='--up', arg='upwards', boolean=True, default=False, help='Reflow only the root components found on the first superview that has them, carrying the search up to its window.') ]

def args(self):
return [ fb.FBCommandArgument(arg='aView', type='UIView*', help='The view to from which the search for the root components begins.', default='(id)[[UIApplication sharedApplication] keyWindow]') ]

def run(self, arguments, options):
upwards = 'NO'
if options.upwards:
upwards = 'YES'

lldb.debugger.HandleCommand('e (void)[CKComponentDebugController reflowComponentsForView:(UIView *)' + arguments[0] + ' searchUpwards:' + upwards + ']')

0 comments on commit 800e3af

Please sign in to comment.