C++ coding style (for webkit)

本文详细介绍了WebKit项目的命名规范,包括变量、函数、类等的命名原则,并提供了Objective-C及C++代码中的具体应用实例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 Rename parameter definition according webkit’s renaming style:

1)        Use CamelCase. Capitalize the first letter, including all letters in an acronym, in a class, struct, protocol, or namespace name. Lower-case the first letter, including all letters in an acronym, in a variable or function name.

2)        Use full words, except in the rare case where an abbreviation would be more canonical and easier to understand.

3)        Data members in C++ classes should be private. Static data members should be prefixed by "s_".Other data members should be prefixed by "m_".

4)        Prefix Objective-C instance variables with "_".

5)        Precede boolean values with words like "is" and "did".

6)        Precede setters with the word"set". Use bare words for getters. Setter and getter names should match the names of the variables being set/gotten.

7)        Precede getters that return values through out arguments with the word "get".

8)        Use descriptive verbs in function names.

9)        Leave meaningless variable names out of function declarations. A good rule of thumb is if the parameter type name contains the parameter name (without trailing numbers or pluralization),then the parameter name isn't needed. Usually, there should be a parameter name for bools, strings, and numerical types.

10)    Prefer enums to bools on function parameters if callers are likely to be passing constants, since named constants are easier to read at the call site. An exception to this rule is a setter function, where the name of the function already makes clear what the boolean is.

11)    Objective-C method names should follow the Cocoa naming guidelines — they should read like a phrase and each piece of the selector should start with a lowercase letter and use intercaps.

12)    Enum members should use InterCapswith an initial capital letter.

13)    Prefer const to #define. Prefer inline functions to macros.

14)    #defined constants should use all uppercase names with words separated by underscores.

15)    Macros that expand to function calls or other non-constant computation: these should be named like functions,and should have parentheses at the end, even if they take no arguments (with the exception of some special macros like ASSERT). Note that usually it is preferable to use an inline function in such cases instead of a macro.

16)    #define, #ifdef  "headerguards" should be named exactly the same as the file (including case),replacing the '.' with a '_'.

 

And the Webkit coding stype link : http://www.webkit.org/coding/coding-style.html 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值