Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 + ']')