Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add "Singleton pattern" section to the WebKit coding style
https://bugs.webkit.org/show_bug.cgi?id=141040

Reviewed by Ryosuke Niwa.

Add "Singleton pattern" section to the WebKit coding style to document
what was discussed on webkit-dev:
https://lists.webkit.org/pipermail/webkit-dev/2015-January/027199.html

* coding/coding-style.html:

Canonical link: https://commits.webkit.org/159079@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@179401 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
cdumez committed Jan 30, 2015
1 parent 211aa28 commit 68bce1e
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Websites/webkit.org/ChangeLog
@@ -1,3 +1,16 @@
2015-01-30 Chris Dumez <cdumez@apple.com>

Add "Singleton pattern" section to the WebKit coding style
https://bugs.webkit.org/show_bug.cgi?id=141040

Reviewed by Ryosuke Niwa.

Add "Singleton pattern" section to the WebKit coding style to document
what was discussed on webkit-dev:
https://lists.webkit.org/pipermail/webkit-dev/2015-January/027199.html

* coding/coding-style.html:

2015-01-27 Daniel Bates <dabates@apple.com>

Update Xcode requirement and add instructions to build, run, and debug WebKit for iOS Simulator
Expand Down
32 changes: 32 additions & 0 deletions Websites/webkit.org/coding/coding-style.html
Expand Up @@ -1119,6 +1119,38 @@ <h4 class="wrong">Wrong:</h4>
</li>
</ol>

<h3 id="singleton">Singleton pattern</h3>

<ol>
<li id="singleton-static-member">
Use a static member function named "singleton()" to access the instance of the singleton.
<h4 class="right">Right:</h4>
<pre class="code">
class MySingleton {
public:
static MySingleton& singleton();
...
</pre>

<h4 class="wrong">Wrong:</h4>
<pre class="code">
class MySingleton {
public:
static MySingleton& shared();
...
</pre>

<h4 class="wrong">Wrong:</h4>
<pre class="code">
class MySingleton {
...
};

MySingleton& mySingleton(); // free function.
</pre>
</li>
</ol>

<h3 id="comments">Comments</h3>
<ol>
<li id="comments-eol">Use only <i>one</i> space before end of line comments and in between sentences in comments.
Expand Down

0 comments on commit 68bce1e

Please sign in to comment.