logos
logos copied to clipboard
Logos errors out on calling %orig with an inline block with multiple lines.
When hooking a method which accepts a block as a paramter, Logos dislikes this form of calling the original implementation:
%hook AwesomeClass
- (void)AwesomeMethod:(void (^)(void))awesomeBlock
{
%orig(^{
NSLog(@"Hello");
});
}
%end
However, this works:
%hook AwesomeClass
- (void)AwesomeMethod:(void (^)(void))awesomeBlock
{
%orig(^{ NSLog(@"Hello"); });
}
%end
and putting the block in a variable, works too, obviously.
Logos errors out with this error: "error: missing closing parenthesis"
Attempt to declare the block separately and then pass the block to %orig. I think that should work with Logos as-is and this is quite an interesting issue!
Yes, that works, as I originally mentioned "and putting the block in a variable, works too, obviously".
Unfortunately, this is a known (and difficult to fix properly) issue. Logos is a somewhat degenerate parser - regex-based, non-tokenizing, and without a lexical understanding.
I think this is related: by having a comment with //*
it gives a %hook does not make sense inside a block later in the code.