logos icon indicating copy to clipboard operation
logos copied to clipboard

Logos errors out on calling %orig with an inline block with multiple lines.

Open orikad opened this issue 11 years ago • 4 comments

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"

orikad avatar Jan 11 '14 19:01 orikad

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!

theiostream avatar Jan 15 '14 22:01 theiostream

Yes, that works, as I originally mentioned "and putting the block in a variable, works too, obviously".

orikad avatar Jan 15 '14 22:01 orikad

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.

DHowett avatar Jan 15 '14 23:01 DHowett

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.

JesseVelden avatar Jul 31 '16 12:07 JesseVelden