Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add two commands pclassmethod and pinstancemethod #113

Merged
merged 30 commits into from
Jan 1, 2016

Conversation

longv2go
Copy link
Contributor

This command show the class`s methods in a pretty way.

Options:
--address/-a ; Print the implementation address of the method
--instance/-i ; Print the instance methods
--class/-c ; Print the class methods

You can get the runtime address of the method use option '-a' then do something more with that address,
such as run lldb command "dis -a " to disassemble the method.

Examples:

(lldb) pme -a self
Class Methods:
No instance methods were found.

Instance Methods:
- (void)outAction:(id)arg0  0x000ee680
- (void)innerAction:(id)arg0  0x000ee6f0
- (void)inges:(id)arg0  0x000ee760
- (void)underGes:(id)arg0  0x000ee7d0
......

@kastiglione
Copy link
Contributor

Thanks for the pull request!

Why not one command (say pmethods) and let the person pass either a class or an instance?

(lldb) pmethods self
- (void)setSignInButton:(id)arg0 
- (id)signInFailureText
- (void)setSignInFailureText:(id)arg0 
- (void).cxx_destruct
......
(lldb) pmethods [self class]
+ (id)test:(id)arg0

@longv2go
Copy link
Contributor Author

@kastiglione Now It supply only one command 'pmethods', it take two options, if '-a' set, it would print all class methods and instance mehtods, if '-c' set, it would only print class methods, default it only print intance methods.

@kastiglione
Copy link
Contributor

👍 I will take a look tomorrow (it's the end of the night for me now)

One question: What happens if you call pmethods XYSomeClass?

@longv2go
Copy link
Contributor Author

@kastiglione The pmethods can take an Instance of some Class or a Class object as its argument, and It
would print the same thing. I know the argument is an Instance or just a Class object. It use the options '-a' '-c' to determine print the class methods or instance methods.

(lldb) pme self
- (id)signInService
- (id)usernameTextField
- (bool)isValidUsername:(id)arg0 
......

(lldb) pme [self class]
- (id)signInService
- (id)usernameTextField
- (bool)isValidUsername:(id)arg0 
......

(lldb) pme -a self
+ (id)test:(id)arg0 
- (id)signInService
- (id)usernameTextField
- (bool)isValidUsername:(id)arg0 
- (bool)isValidPassword:(id)arg0 
- (id)signInSignal
......

@kastiglione
Copy link
Contributor

thanks, will try this out today or tomorrow!

@PaulTaykalo
Copy link

Is there any way to know, what prevents this PR to be merged in ?:)

return 'pmethods'

def description(self):
return 'Print the class instance methods.'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Print the class and instance methods of a class."

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@longv2go Do you plan to update this description?

@kastiglione
Copy link
Contributor

@PaulTaykalo I dropped the ball on following up on the review, apologies.


def options(self):
return [
fb.FBCommandArgument(short='-a', long='--all', arg='all', help='If display all methos include class and instance methods', default=False, boolean=True),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find the combination of '-a' and '-c' to be a bit counter-intuitive. What about '-i/--instance' for instance and '-c/--class' for class and if neither is specified then it defaults to both. This ensures that there aren't any combinations that don't make sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just add a new '-a' option to show the implementation address of the method

@longv2go
Copy link
Contributor Author

Hi, @fbdeveloper @kastiglione @PaulTaykalo , I change the implementation of pmethods, the CLI not changed. The last version has some issues, it run slowly when the class has many methods and it`s implementation is not so clearly. So I wrote a new method 'evaluate' in fblldbbase.py, it can evaluate a batch of Objective-C expressions and automatic transform the Objective-C object to Python object. I rewrote pmethods base on 'evaluate'. The lines of code go to down, run faster, and more clearly now. Please review this. :)

@arigrant
Copy link
Contributor

Ah sorry, that was me, accidentally logged into an old fb dev account for a repo I was looking into.

@jamesgpearce
Copy link

hahaha

def __init__(self, json):
self.name = json['name']
self.type_encoding = json['type_encoding']
self.peremeters_type = json['parameters_type']

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parameters_type

@longv2go
Copy link
Contributor Author

Thanks for reviewing! Sorry for my poor english!

@kastiglione
Copy link
Contributor

@arigrant I'll be traveling for the next few days. Would you mind merging this when ready?

Thanks @longv2go!

@@ -32,6 +32,10 @@ def class_getSuperclass(klass):
value = fb.evaluateExpression(command)
return value

def class_isMetaClass(klass):
command = '(BOOL)class_isMetaClass((Class){})'.format(klass)
return fb.evaluateBooleanExpression(command)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@longv2go You don't need the (BOOL) cast when calling evaluateBooleanExpression.

@kastiglione
Copy link
Contributor

Thanks @longv2go!

kastiglione added a commit that referenced this pull request Jan 1, 2016
add two commands pclassmethod and  pinstancemethod
@kastiglione kastiglione merged commit 867b4e2 into facebook:master Jan 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants