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 print capture variables for pblock #242

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

dhcdht
Copy link

@dhcdht dhcdht commented Apr 24, 2018

before:
Imp: 0x10a451d40 Signature: void ^();

after:
Imp: 0x10a451d40 Signature: void ^() Variables : {
<ViewController: 0x7fdd9b204060>
<AppDelegate: 0x60c00002acc0>
};

董宏昌 added 2 commits April 23, 2018 13:36
before:
Imp: 0x10a451d40    Signature: void ^();

after:
Imp: 0x10a451d40    Signature: void ^()   Variables : {
<ViewController: 0x7fdd9b204060>
<AppDelegate: 0x60c00002acc0>
};
Copy link
Contributor

@kastiglione kastiglione left a comment

Choose a reason for hiding this comment

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

Thanks! This is a nice addition. I have some questions.

@@ -111,7 +111,7 @@ def run(self, arguments, options):
struct Block_literal_1 real = *((__bridge struct Block_literal_1 *)$block);
NSMutableDictionary *dict = (id)[NSMutableDictionary dictionary];

[dict setObject:(id)[NSNumber numberWithLong:(long)real.invoke] forKey:@"invoke"];
[dict setValue:(id)[NSNumber numberWithLong:(long)real.invoke] forKey:@"invoke"];
Copy link
Contributor

Choose a reason for hiding this comment

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

why the change to setValue:forKey:?

Copy link
Author

Choose a reason for hiding this comment

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

That can fix #198 . There is another MR that can fix it separately

#241

I guess because function declaration of setValue:forKey doesn't need id , just id

json.update(variables_json)

variablesStrs = []
for i in range(10):
Copy link
Contributor

Choose a reason for hiding this comment

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

why up to 10?

print 'Imp: ' + hex(json['invoke']) + ' Signature: ' + sigStr
print 'Imp: ' + hex(json['invoke']) + ' Signature: ' + sigStr + ' Variables : {\n'+variablesStr+'\n};'

def getBlockVariables(self, block, min_var_count=1, max_var_count=20):
Copy link
Contributor

Choose a reason for hiding this comment

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

can you explain min_var_count and max_var_count? I'm not clear on their purpose.

@dhcdht
Copy link
Author

dhcdht commented May 22, 2018

@kastiglione
hi, I have added some comments for max_var_count.
max_var_count is the number of placeholders for the variables captured by the block.

the related code

#define BLOCK_VARIABLES_COUNT ($variables_count)
struct Block_literal_1 {
    ...
    // imported variables
    Class *variables[BLOCK_VARIABLES_COUNT];
}

@filip-doordash
Copy link

I think this is super useful! Is this something that is still in progress? If not, I'd be happy to take a stab at the implementation myself.

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.

4 participants