Title: [97070] trunk/Websites/webkit.org
- Revision
- 97070
- Author
- [email protected]
- Date
- 2011-10-10 11:12:28 -0700 (Mon, 10 Oct 2011)
Log Message
Style guide should mandate use of pass-by-reference for out arguments
https://bugs.webkit.org/show_bug.cgi?id=69766
Reviewed by Darin Adler.
This matches the convention used throughout WebCore.
* coding/coding-style.html:
Modified Paths
Diff
Modified: trunk/Websites/webkit.org/ChangeLog (97069 => 97070)
--- trunk/Websites/webkit.org/ChangeLog 2011-10-10 18:01:09 UTC (rev 97069)
+++ trunk/Websites/webkit.org/ChangeLog 2011-10-10 18:12:28 UTC (rev 97070)
@@ -1,3 +1,14 @@
+2011-10-10 Ryosuke Niwa <[email protected]>
+
+ Style guide should mandate use of pass-by-reference for out arguments
+ https://bugs.webkit.org/show_bug.cgi?id=69766
+
+ Reviewed by Darin Adler.
+
+ This matches the convention used throughout WebCore.
+
+ * coding/coding-style.html:
+
2011-10-06 Amruth Raj <[email protected]>
Add Motorola Mobility to team.html
Modified: trunk/Websites/webkit.org/coding/coding-style.html (97069 => 97070)
--- trunk/Websites/webkit.org/coding/coding-style.html 2011-10-10 18:01:09 UTC (rev 97069)
+++ trunk/Websites/webkit.org/coding/coding-style.html 2011-10-10 18:12:28 UTC (rev 97070)
@@ -575,6 +575,17 @@
</pre>
</li>
+<li>Precede getters that return values through out arguments with the word "get".</li>
+<h4 class="right">Right:</h4>
+<pre class="code">
+void getInlineBoxAndOffset(InlineBox*&, int& caretOffset) const;
+</pre>
+
+<h4 class="wrong">Wrong:</h4>
+<pre class="code">
+void inlineBoxAndOffset(InlineBox*&, int& caretOffset) const;
+</pre>
+
<li>Use descriptive verbs in function names.
<h4 class="right">Right:</h4>
<pre class="code">
@@ -697,7 +708,12 @@
MyOtherClass::MyOtherClass() : MySuperClass() {}
</pre>
+</ol>
+<h3>Pointers and References</h3>
+
+<ol>
+
<li>Pointer types in non-C++ code — Pointer types should be written with a space between the
type and the * (so the * is adjacent to the following identifier if any).
@@ -720,6 +736,32 @@
const KCDashArray &dashes = dashArray();
</pre>
+<li>An out argument of a function should be passed by reference except rare cases where
+it is optional in which case it should be passed by pointer.
+
+<h4 class="right">Right:</h4>
+<pre class="code">
+void MyClass::getSomeValue(OutArgumentType& outArgument) const
+{
+ outArgument = m_value;
+}
+
+void MyClass::doSomething(OutArgumentType* outArgument) const
+{
+ doSomething();
+ if (outArgument)
+ outArgument = m_value;
+}
+</pre>
+
+<h4 class="wrong">Wrong:</h4>
+<pre class="code">
+void MyClass::getSomeValue(OutArgumentType* outArgument) const
+{
+ *outArgument = m_value;
+}
+</pre>
+
</ol>
<h3>#include Statements</h3>
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes