开发者

Uncrustify spacing issue with macro inside method call

I am attempting to use Uncrustify on a project of mine, but I am running开发者_运维知识库 into some issues with spacing changes that it makes when a macro is used as the receiver of an Objective-C message. For example, given the following macro and method call, I would expect the spacing to remain exactly as is.

#define NilOrNotNSNull(val) ({id __val = (val); (__val == [NSNull null]) ? nil : __val;})

title_ = [NilOrNotNSNull([dict objectForKey:@"post_title"]) copy];

However, this is the result.

#define NilOrNotNSNull(val) ({id __val = (val); (__val == [NSNull null]) ? nil : __val;})

title_ = [NilOrNotNSNull ([dict objectForKey:@"post_title"])copy];

It appears as if Uncrustify does not recognize that the text in parentheses is an argument for the macro, but then I'm not really sure what the heck it thinks it is. This seems like an Uncrustify bug to me, but it could be an issue with my config, so I figured I'd ask here as well as filing an issue on GitHub. Here is the config I'm using: https://gist.github.com/812314

If anyone could offer some insight, I'd appreciate it.


I don't get your exact output when I run using your config. What version are you using? My version output is as follows:

macbook-adamd:~ adamd$ uncrustify --version
uncrustify 0.56

The output that I get using your config has a backslash that wraps your macro's close parent to a newline:

#define NilOrNotNSNull(val) ({ id __val = (val); (__val == [NSNull null]) ? nil : __val; } \
                         )

title_ = [NilOrNotNSNull ([dict objectForKey:@"post_title"])copy];

That said, I was able to eliminate the space between NilOrNotNSNull and the open paren by adding set func_call_user NilOrNotNSNull to the top of the config file. See the documentation for the sp_func_call_user_paren for more information. It seems you have the option set up to remove the space, just no definitions for it to match.

Here is my output with the set func_call_user NilOrNotNSNull :

#define NilOrNotNSNull(val) ({ id __val = (val); (__val == [NSNull null]) ? nil : __val; } \
                             )

title_ = [NilOrNotNSNull([dict objectForKey:@"post_title"]) copy];

I forked your gist and updated it: https://gist.github.com/815042

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜