Skip to content
Merged
Show file tree
Hide file tree
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
47 changes: 28 additions & 19 deletions PATENTS
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
Additional Grant of Patent Rights
Additional Grant of Patent Rights Version 2

"Software" means the Chisel software distributed by Facebook, Inc.
"Software" means the chisel software distributed by Facebook, Inc.

Facebook hereby grants you a perpetual, worldwide, royalty-free, non-exclusive,
irrevocable (subject to the termination provision below) license under any
rights in any patent claims owned by Facebook, to make, have made, use, sell,
offer to sell, import, and otherwise transfer the Software. For avoidance of
doubt, no license is granted under Facebook’s rights in any patent claims that
are infringed by (i) modifications to the Software made by you or a third party,
or (ii) the Software in combination with any software or other technology
provided by you or a third party.
Facebook, Inc. ("Facebook") hereby grants to each recipient of the Software
("you") a perpetual, worldwide, royalty-free, non-exclusive, irrevocable
(subject to the termination provision below) license under any Necessary
Claims, to make, have made, use, sell, offer to sell, import, and otherwise
transfer the Software. For avoidance of doubt, no license is granted under
Facebook’s rights in any patent claims that are infringed by (i) modifications
to the Software made by you or any third party or (ii) the Software in
combination with any software or other technology.

The license granted hereunder will terminate, automatically and without notice,
for anyone that makes any claim (including by filing any lawsuit, assertion or
other action) alleging (a) direct, indirect, or contributory infringement or
inducement to infringe any patent: (i) by Facebook or any of its subsidiaries or
affiliates, whether or not such claim is related to the Software, (ii) by any
party if such claim arises in whole or in part from any software, product or
service of Facebook or any of its subsidiaries or affiliates, whether or not
such claim is related to the Software, or (iii) by any party relating to the
Software; or (b) that any right in any patent claim of Facebook is invalid or
unenforceable.
if you (or any of your subsidiaries, corporate affiliates or agents) initiate
directly or indirectly, or take a direct financial interest in, any Patent
Assertion: (i) against Facebook or any of its subsidiaries or corporate
affiliates, (ii) against any party if such Patent Assertion arises in whole or
in part from any software, technology, product or service of Facebook or any of
its subsidiaries or corporate affiliates, or (iii) against any party relating
to the Software. Notwithstanding the foregoing, if Facebook or any of its
subsidiaries or corporate affiliates files a lawsuit alleging patent
infringement against you in the first instance, and you respond by filing a
patent infringement counterclaim in that lawsuit against that party that is
unrelated to the Software, the license granted hereunder will not terminate
under section (i) of this paragraph due to such counterclaim.

A "Necessary Claim" is a claim of a patent owned by Facebook that is
necessarily infringed by the Software standing alone.

A "Patent Assertion" is any lawsuit or other action alleging direct, indirect,
or contributory infringement or inducement to infringe any patent, including a
cross-claim or counterclaim.
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 + ']')
27 changes: 27 additions & 0 deletions commands/FBDisplayCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ def lldbcommands():
FBUnmaskViewCommand(),
FBShowViewCommand(),
FBHideViewCommand(),
FBSlowAnimationCommand(),
FBUnslowAnimationCommand()
]


Expand Down Expand Up @@ -145,3 +147,28 @@ def args(self):

def run(self, args, options):
viewHelpers.setViewHidden(args[0], True)


class FBSlowAnimationCommand(fb.FBCommand):
def name(self):
return 'slowanim'

def description(self):
return 'Slows down animations. Works on the iOS Simulator and a device.'

def args(self):
return [ fb.FBCommandArgument(arg='speed', type='float', default=0.1, help='Animation speed (default 0.1).') ]

def run(self, args, option):
viewHelpers.slowAnimation(args[0])


class FBUnslowAnimationCommand(fb.FBCommand):
def name(self):
return 'unslowanim'

def description(self):
return 'Turn off slow animations.'

def run(self, args, option):
viewHelpers.slowAnimation()
99 changes: 99 additions & 0 deletions commands/FBPrintCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ def lldbcommands():
FBPrintInternals(),
FBPrintInstanceVariable(),
FBPrintKeyPath(),
FBPrintApplicationDocumentsPath(),
FBPrintData(),
]

class FBPrintViewHierarchyCommand(fb.FBCommand):
Expand Down Expand Up @@ -299,3 +301,100 @@ def run(self, arguments, options):
object = fb.evaluateObjectExpression(objectToMessage)
printCommand = 'po [{} valueForKeyPath:@"{}"]'.format(object, keypath)
lldb.debugger.HandleCommand(printCommand)


class FBPrintApplicationDocumentsPath(fb.FBCommand):
def name(self):
return 'pdocspath'

def description(self):
return "Print application's 'Documents' directory path."

def options(self):
return [
fb.FBCommandArgument(short='-o', long='--open', arg='open', boolean=True, default=False, help='open in Finder'),
]

def run(self, arguments, options):
# in iOS SDK NSDocumentDirectory == 9 NSUserDomainMask == 1
NSDocumentDirectory = '9'
NSUserDomainMask = '1'
path = fb.evaluateExpressionValue('(NSString*)[NSSearchPathForDirectoriesInDomains(' + NSDocumentDirectory + ', ' + NSUserDomainMask + ', YES) lastObject]')
pathString = '{}'.format(path).split('"')[1]
cmd = 'echo {} | tr -d "\n" | pbcopy'.format(pathString)
os.system(cmd)
print pathString
if options.open:
os.system('open '+ pathString)


class FBPrintData(fb.FBCommand):
def name(self):
return 'pdata'

def description(self):
return 'Print the contents of NSData object as string.\n' \
'Supported encodings:\n' \
'- ascii,\n' \
'- utf8,\n' \
'- utf16, unicode,\n' \
'- utf16l (Little endian),\n' \
'- utf16b (Big endian),\n' \
'- utf32,\n' \
'- utf32l (Little endian),\n' \
'- utf32b (Big endian),\n' \
'- latin1, iso88591 (88591),\n' \
'- latin2, iso88592 (88592),\n' \
'- cp1251 (1251),\n' \
'- cp1252 (1252),\n' \
'- cp1253 (1253),\n' \
'- cp1254 (1254),\n' \
'- cp1250 (1250),' \

def options(self):
return [
fb.FBCommandArgument(arg='encoding', short='-e', long='--encoding', type='string', help='Used encoding (default utf-8).', default='utf-8')
]

def args(self):
return [
fb.FBCommandArgument(arg='data', type='NSData *', help='NSData object.')
]

def run(self, arguments, option):
# Normalize encoding.
encoding_text = option.encoding.lower().replace(' -', '')
enc = 4 # Default encoding UTF-8.
if encoding_text == 'ascii':
enc = 1
elif encoding_text == 'utf8':
enc = 4
elif encoding_text == 'latin1' or encoding_text == '88591' or encoding_text == 'iso88591':
enc = 5
elif encoding_text == 'latin2' or encoding_text == '88592' or encoding_text == 'iso88592':
enc = 9
elif encoding_text == 'unicode' or encoding_text == 'utf16':
enc = 10
elif encoding_text == '1251' or encoding_text == 'cp1251':
enc = 11
elif encoding_text == '1252' or encoding_text == 'cp1252':
enc = 12
elif encoding_text == '1253' or encoding_text == 'cp1253':
enc = 13
elif encoding_text == '1254' or encoding_text == 'cp1254':
enc = 14
elif encoding_text == '1250' or encoding_text == 'cp1250':
enc = 15
elif encoding_text == 'utf16b':
enc = 0x90000100
elif encoding_text == 'utf16l':
enc = 0x94000100
elif encoding_text == 'utf32':
enc = 0x8c000100
elif encoding_text == 'utf32b':
enc = 0x98000100
elif encoding_text == 'utf32l':
enc = 0x9c000100

print_command = 'po (NSString *)[[NSString alloc] initWithData:{} encoding:{}]'.format(arguments[0], enc)
lldb.debugger.HandleCommand(print_command)
3 changes: 3 additions & 0 deletions fblldbviewhelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,6 @@ def upwardsRecursiveDescription(view, maxDepth=0):
currentPrefix += " | "

return builder

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