<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.mozilla.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ehoogeveen</id>
	<title>MozillaWiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.mozilla.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ehoogeveen"/>
	<link rel="alternate" type="text/html" href="https://wiki.mozilla.org/Special:Contributions/Ehoogeveen"/>
	<updated>2026-09-04T19:14:55Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.10</generator>
	<entry>
		<id>https://wiki.mozilla.org/index.php?title=JavaScript:SpiderMonkey:Coding_Style&amp;diff=1074535</id>
		<title>JavaScript:SpiderMonkey:Coding Style</title>
		<link rel="alternate" type="text/html" href="https://wiki.mozilla.org/index.php?title=JavaScript:SpiderMonkey:Coding_Style&amp;diff=1074535"/>
		<updated>2015-05-13T20:16:39Z</updated>

		<summary type="html">&lt;p&gt;Ehoogeveen: Reflect change from |T *t| to |T* t|. Also remove the edge cases that are obvious with the new style.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Functions =&lt;br /&gt;
&lt;br /&gt;
* Public function names begin with JS_ followed by capitalized &amp;quot;intercaps&amp;quot;, e.g. JS_NewObject.&lt;br /&gt;
* Extern but library-private function names use a js_ prefix and mixed case, e.g. js_SearchScope.&lt;br /&gt;
* Most static function names have unprefixed, mixed-case names: GetChar.&lt;br /&gt;
* But static native methods of JS objects have lowercase, underscore-separated or intercaps names, e.g., str_indexOf.&lt;br /&gt;
* Function return types are on a separate line preceding the function name.&lt;br /&gt;
* Function braces go on the line following the function name.&lt;br /&gt;
 void DoThis()           /* bad */&lt;br /&gt;
 {&lt;br /&gt;
     ...&lt;br /&gt;
 }&lt;br /&gt;
 void&lt;br /&gt;
 DoThis()                /* OK */&lt;br /&gt;
 {&lt;br /&gt;
     ...&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
= Other Symbols =&lt;br /&gt;
&lt;br /&gt;
* Library-private and static data use underscores, not intercaps (but library-private data do use a js_ prefix).&lt;br /&gt;
* Scalar type names are lowercase and js-prefixed: jsdouble.&lt;br /&gt;
* Aggregate type names are JS-prefixed and mixed-case: JSObject.&lt;br /&gt;
* Macros are generally ALL_CAPS and underscored, to call out potential side effects, multiple uses of a formal argument, etc.  Line continuation characters should all line up, in column 79 if that exceeds the width of all the macro text.  Macro parameters should be of the form name_ (instead of something like __name).&lt;br /&gt;
&lt;br /&gt;
= Indentation =&lt;br /&gt;
&lt;br /&gt;
* Use spaces, not tabs.  There should be no tabs in source files.&lt;br /&gt;
* Four spaces of indentation per statement nesting level.&lt;br /&gt;
* &amp;quot;&amp;lt;code&amp;gt;case L:&amp;lt;/code&amp;gt;&amp;quot; labels in &amp;lt;code&amp;gt;switch&amp;lt;/code&amp;gt; statements count as half of a nesting level, so indent two spaces, with the labeled statements indenting two more for a standard four spaces indentation from &amp;lt;code&amp;gt;switch&amp;lt;/code&amp;gt; to a case-controlled statement.&lt;br /&gt;
 switch (discriminant) {&lt;br /&gt;
   case L1:&lt;br /&gt;
     DoSomething();&lt;br /&gt;
   . . .&lt;br /&gt;
 }&lt;br /&gt;
* Function arguments that overflow the first line of the call expression should be aligned to underhang the first argument (to start in overflow lines in the column after the opening parenthesis).&lt;br /&gt;
 JS_SetContext(rt,         /* bad */&lt;br /&gt;
              cx);&lt;br /&gt;
 JS_SetContext(rt,         /* OK */&lt;br /&gt;
               cx);&lt;br /&gt;
&lt;br /&gt;
= Whitespace in declarations =&lt;br /&gt;
&lt;br /&gt;
These rules are inconsistently applied.  Be consistent with the code you&#039;re editing rather than adhere too closely to these guidelines!&lt;br /&gt;
&lt;br /&gt;
* In a declaration of a pointer, the &amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt; goes with the type:&lt;br /&gt;
 char *s;                  /* bad */&lt;br /&gt;
 char* s;                  /* OK */&lt;br /&gt;
* In C++ method declarations with default arguments, use spaces and comments like so:&lt;br /&gt;
 static void&lt;br /&gt;
 Frob(JSContext* cx, uint32_t defaultValue = 0);&lt;br /&gt;
 static void&lt;br /&gt;
 Frob(JSContext* cx, uint32_t defaultValue /* = 0 */)&lt;br /&gt;
 {&lt;br /&gt;
     /* ... */&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
= Other whitespace =&lt;br /&gt;
&lt;br /&gt;
* Code should fit within 99 columns; comments should fit within 80 columns; both figures include indentation. Break down lines that are too long by splitting after a binary operator.&lt;br /&gt;
* Exception: in a &amp;lt;code&amp;gt;switch&amp;lt;/code&amp;gt; statement where each case is a trivially-short statement, it&#039;s ok to put the &amp;lt;code&amp;gt;case&amp;lt;/code&amp;gt;, the statement, and the &amp;lt;code&amp;gt;break;&amp;lt;/code&amp;gt; all on one line.&lt;br /&gt;
* Comment &amp;lt;code&amp;gt;/* FALL THROUGH */&amp;lt;/code&amp;gt; in place of missing &amp;lt;code&amp;gt;break&amp;lt;/code&amp;gt; when intentionally falling through from one case-controlled statement sequence into another, or into the &amp;lt;code&amp;gt;default&amp;lt;/code&amp;gt; statements.&lt;br /&gt;
* Do not use spaces between a function name and its arguments list, or between an array name and the square bracket. Also, do no use spaces after a bracket. Use a space after a comma to separate arguments.&lt;br /&gt;
 JS_SetContext ( rt, cx ); /* bad */&lt;br /&gt;
 JS_SetContext(rt, cx);    /* OK */&lt;br /&gt;
* Use a space between a C keyword and parentheses.&lt;br /&gt;
 if(condition)             /* bad */&lt;br /&gt;
 if (condition)            /* OK */&lt;br /&gt;
* In a conditional, if the consequent (and, if present, the alternate) is a single statement, no braces are used.&lt;br /&gt;
 if (today == &amp;quot;Tuesday&amp;quot;)&lt;br /&gt;
     puts(&amp;quot;I don&#039;t have my wallet on me.&amp;quot;);&lt;br /&gt;
 else&lt;br /&gt;
     puts(&amp;quot;I would gladly pay you on Tuesday for a hamburger today.&amp;quot;);&lt;br /&gt;
However, if &#039;&#039;either&#039;&#039; the consequent or alternate is a block of multiple statements, braces are used on both.&lt;br /&gt;
 if (canSwingFromWeb) {&lt;br /&gt;
     p-&amp;gt;swingFromWeb();&lt;br /&gt;
 } else {&lt;br /&gt;
     JS_ASSERT(p-&amp;gt;isSpiderPig());&lt;br /&gt;
     p-&amp;gt;doWhateverSpiderPigDoes();&lt;br /&gt;
 }&lt;br /&gt;
* Conditions with multi-line tests should put the brace on the new line to provide a visual separation between the condition and the body.&lt;br /&gt;
&lt;br /&gt;
   types::TypeSet* types = frame.extra(lhs).types;&lt;br /&gt;
   if (JSOp(*PC) == JSOP_SETPROP &amp;amp;&amp;amp; id == types::MakeTypeId(cx, id) &amp;amp;&amp;amp;&lt;br /&gt;
       types &amp;amp;&amp;amp; !types-&amp;gt;unknownObject() &amp;amp;&amp;amp;&lt;br /&gt;
       types-&amp;gt;getObjectCount() == 1 &amp;amp;&amp;amp;&lt;br /&gt;
       types-&amp;gt;getTypeObject(0) != NULL &amp;amp;&amp;amp;&lt;br /&gt;
       !types-&amp;gt;getTypeObject(0)-&amp;gt;unknownProperties())&lt;br /&gt;
   {&lt;br /&gt;
       JS_ASSERT(usePropCache);&lt;br /&gt;
       types::TypeObject* object = types-&amp;gt;getTypeObject(0);&lt;br /&gt;
       types::TypeSet* propertyTypes = object-&amp;gt;getProperty(cx, id, false);&lt;br /&gt;
       ...&lt;br /&gt;
   } else {&lt;br /&gt;
       ...&lt;br /&gt;
   }&lt;br /&gt;
However, if there is already a visual separation between the condition and the body, putting the { on a new line isn&#039;t necessary:&lt;br /&gt;
&lt;br /&gt;
   if (forHead-&amp;gt;pn_kid1 &amp;amp;&amp;amp; NewSrcNote2(cx, cg, SRC_DECL,&lt;br /&gt;
                                       (forHead-&amp;gt;pn_kid1-&amp;gt;isOp(JSOP_DEFVAR))&lt;br /&gt;
                                       ? SRC_DECL_VAR&lt;br /&gt;
                                       : SRC_DECL_LET) &amp;lt; 0) {&lt;br /&gt;
       return false;&lt;br /&gt;
   }&lt;br /&gt;
* &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; loop heads go on one line where possible; when not possible, initializer part, update, and termination parts each go on separate lines&lt;br /&gt;
 for (int i = 0;&lt;br /&gt;
      i &amp;lt; 5;&lt;br /&gt;
      i++) {                 /* bad, could all fit on one line */&lt;br /&gt;
     doStuff();&lt;br /&gt;
 }&lt;br /&gt;
 for (int i = 0; i &amp;lt; 5; i++) /* OK */&lt;br /&gt;
     doStuff();&lt;br /&gt;
 for (size_t ind = JSObject::JSSLOT_DATE_COMPONENTS_START;&lt;br /&gt;
      ind &amp;lt; JSObject::DATE_FIXED_RESERVED_SLOTS; ind++) {   /* bad */&lt;br /&gt;
     obj-&amp;gt;setSlot(ind, DoubleValue(utcTime));&lt;br /&gt;
 }&lt;br /&gt;
 for (size_t ind = JSObject::JSSLOT_DATE_COMPONENTS_START;&lt;br /&gt;
      ind &amp;lt; JSObject::DATE_FIXED_RESERVED_SLOTS;&lt;br /&gt;
      ind++) {                                               /* OK */&lt;br /&gt;
     obj-&amp;gt;setSlot(ind, DoubleValue(utcTime));&lt;br /&gt;
 }&lt;br /&gt;
* In comments, use one space, not two, between sentences and after a colon.&lt;br /&gt;
&lt;br /&gt;
= Control Flow =&lt;br /&gt;
&lt;br /&gt;
* Minimize indentation using return, break, and continue where appropriate.  Prefer return (break, continue) statements to cast out abnormal cases, instead of nesting &amp;quot;if/else&amp;quot; statements and indenting the common cases.&lt;br /&gt;
 void&lt;br /&gt;
 MyFunction(int n)&lt;br /&gt;
 {&lt;br /&gt;
     if (n) {              /* bad */&lt;br /&gt;
         ...&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
 void&lt;br /&gt;
 MyFunction(int n)&lt;br /&gt;
 {&lt;br /&gt;
     if (!n)&lt;br /&gt;
         return;           /* OK */&lt;br /&gt;
     ...&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
* If an &amp;quot;if&amp;quot; statement controls a &amp;quot;then&amp;quot; clause ending in a return statement, do not use &amp;quot;else&amp;quot; after return.&lt;br /&gt;
 if (condition) {          /* bad */&lt;br /&gt;
     DoThis();&lt;br /&gt;
     return;&lt;br /&gt;
 } else {&lt;br /&gt;
     DoThat();&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 if (condition) {          /* OK */&lt;br /&gt;
     DoThis();&lt;br /&gt;
     return;&lt;br /&gt;
 }&lt;br /&gt;
 DoThat();&lt;br /&gt;
&lt;br /&gt;
* Avoid similar arbitrary patterns and non-sequiturs:&lt;br /&gt;
 if (condition) {          /* bad */&lt;br /&gt;
     DoThis();&lt;br /&gt;
     DoThat();&lt;br /&gt;
 } else {&lt;br /&gt;
     CleanUp();&lt;br /&gt;
     return;&lt;br /&gt;
 }&lt;br /&gt;
 DoTheOther();&lt;br /&gt;
 if (!condition) {         /* OK */&lt;br /&gt;
     CleanUp();&lt;br /&gt;
     return;&lt;br /&gt;
 }&lt;br /&gt;
 DoThis();&lt;br /&gt;
 DoThat();&lt;br /&gt;
 DoTheOther();&lt;br /&gt;
&lt;br /&gt;
* Avoid using &amp;amp;&amp;amp; or || to mix deciding-whether-to-do-something with error-checking.&lt;br /&gt;
&lt;br /&gt;
 if (obj-&amp;gt;hasProblems() &amp;amp;&amp;amp; !obj-&amp;gt;rectify())     /* bad */&lt;br /&gt;
     return false;&lt;br /&gt;
 &lt;br /&gt;
 if (obj-&amp;gt;hasProblems()) {                      /* OK */&lt;br /&gt;
     if (!obj-&amp;gt;rectify())&lt;br /&gt;
         return false;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
= Comments =&lt;br /&gt;
&lt;br /&gt;
* In C files, always use C style comments.  C++ comments are ok otherwise.&lt;br /&gt;
* Terminate a comment with a period (so try to make comments be complete sentences).&lt;br /&gt;
 /* This is a good comment. */&lt;br /&gt;
 // This is also a good comment.&lt;br /&gt;
* For C-style multiline comments, align with any indentation, and start every line with an asterisk. Asterisks stack in the same column. Precede the multiline comment with one empty line unless the prior line ends in a left brace. The first line of the comment contains only leading space followed by &amp;lt;code&amp;gt;/*&amp;lt;/code&amp;gt;. Multiline comments should also be bracketed.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if (condition) {&lt;br /&gt;
    /*&lt;br /&gt;
     * This is a lengthy C-style&lt;br /&gt;
     * multiline comment.&lt;br /&gt;
     */&lt;br /&gt;
    // This is a length&lt;br /&gt;
    // C++-style comment&lt;br /&gt;
    DoYourStuff();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Entry Points and Callbacks =&lt;br /&gt;
&lt;br /&gt;
* DLL entry points have their return type expanded within a JS_PUBLIC_API() macro call, to get the right Windows secret type qualifiers in the right places for all build variants.&lt;br /&gt;
* Callback functions that might be called from a DLL are similarly macroized with JS_STATIC_DLL_CALLBACK (if the function otherwise would be static to hide its name) or JS_DLL_CALLBACK (this macro takes no type argument; it should be used after the return type and before the function name).&lt;br /&gt;
&lt;br /&gt;
= Data Types and Alignments =&lt;br /&gt;
&lt;br /&gt;
* As with all Mozilla code, SpiderMonkey needs to compile and execute correctly on many platforms, including 64-bits systems.&lt;br /&gt;
* JS and NSPR have common roots in the dawn of time (Netscape 2), and the &amp;lt;code&amp;gt;JS_THREADSAFE&amp;lt;/code&amp;gt; mode of building SpiderMonkey depends on NSPR, so reading the [http://www.mozilla.org/projects/nspr/reference/html/ NSPR documentation] is well worth your while.&lt;br /&gt;
* Not all 64-bit systems use the same integer type model: some are &amp;quot;LP64&amp;quot; (long and pointer are 64 bits, int is 32 bits), while others are &amp;quot;LLP64&amp;quot; (only long long and pointer are 64 bits; long and int are 32 bits).&lt;br /&gt;
* Use size_t for unsigned number of bytes variables, ptrdiff_t for signed pointer subtraction results.  In particular, do not use uintN, which is just shorthand for unsigned int, and so may not be big enough.&lt;br /&gt;
&lt;br /&gt;
= Header files =&lt;br /&gt;
&lt;br /&gt;
== #ifndef wrappers ==&lt;br /&gt;
&lt;br /&gt;
Use this exact form for #ifndef wrappers in header files:&lt;br /&gt;
&lt;br /&gt;
  #ifndef &amp;lt;guard&amp;gt;&lt;br /&gt;
  #define &amp;lt;guard&amp;gt;&lt;br /&gt;
  ...&lt;br /&gt;
  #endif // &amp;lt;guard&amp;gt;&lt;br /&gt;
&lt;br /&gt;
GCC and clang recognize this idiom and avoid re-reading headers that use it.  Don&#039;t put any code before the #ifndef or after the #endif, and don&#039;t put anything else in the #ifndef, otherwise the optimization will be thwarted and the file will be multiply-included.  (Check with the -H option if you want to be sure.)&lt;br /&gt;
&lt;br /&gt;
Include guards should be named by determining the fully-qualified include path,&lt;br /&gt;
then substituting _ for &#039;/&#039; and &#039;.&#039; and &#039;-&#039; in it.  For example, js/src/vm/Stack-inl.h&#039;s guard is vm_Stack_inl_h_, and js/public/Vector.h&#039;s guard is js_Vector_h (because its include path is js/Vector.h).&lt;br /&gt;
&lt;br /&gt;
== #include paths ==&lt;br /&gt;
&lt;br /&gt;
All #include statements should use a fully-qualified (within SpiderMonkey) path, even if it&#039;s not necessary.  For example, this:&lt;br /&gt;
&lt;br /&gt;
  #include &amp;quot;vm/Stack.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
not:&lt;br /&gt;
&lt;br /&gt;
  #include &amp;quot;Stack.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This keeps things consistent and helps with the ordering.&lt;br /&gt;
&lt;br /&gt;
For headers in js/public/, the prefix is &amp;quot;js/&amp;quot;, e.g.:&lt;br /&gt;
&lt;br /&gt;
  #include &amp;quot;js/Vector.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
For headers in mfbt/, the prefix is &amp;quot;mozilla/&amp;quot;, e.g.:&lt;br /&gt;
&lt;br /&gt;
  #include &amp;quot;mozilla/Assertions.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== #include ordering ==&lt;br /&gt;
&lt;br /&gt;
The following order is used for module X:  &lt;br /&gt;
* If X-inl.h exists, it goes first.  (And X-inl.h&#039;s first #include should be X.h.) Otherwise, X.h goes first.  This rule ensures that X.h and X-inl.h both #include all the headers that they need themselves.&lt;br /&gt;
* mozilla/*.h&lt;br /&gt;
* &amp;lt;*.h&amp;gt;&lt;br /&gt;
* js*.h&lt;br /&gt;
* */*.h (this includes the public JSAPI headers in js/public/*.h which should be included using the form js/*.h)&lt;br /&gt;
* js*inlines.h&lt;br /&gt;
* */*-inl.h.&lt;br /&gt;
&lt;br /&gt;
Keep (case-insensitive) lexicographic order with each section.&lt;br /&gt;
&lt;br /&gt;
The presence of conditionally-compiled #include statements complicates thing.  If you have a single #include statement within a #if/#ifdef/#ifndef block, placing the block in the appropriate section is straightforward.  If you have multiple #include statements within a block, use your judgment as to where the best place for it is.&lt;br /&gt;
&lt;br /&gt;
Example for X.cpp:&lt;br /&gt;
&lt;br /&gt;
 #include &amp;quot;X.h&amp;quot;    // put &amp;quot;X-inl.h&amp;quot; instead, if it exists&lt;br /&gt;
 &lt;br /&gt;
 #include &amp;quot;mozilla/HashFunctions.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 #include &amp;lt;string.h&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 #include &amp;quot;jsbar.h&amp;quot;&lt;br /&gt;
 #ifdef BAZ&lt;br /&gt;
 # include &amp;quot;jsbaz.h&amp;quot;&lt;br /&gt;
 #endif&lt;br /&gt;
 #include &amp;quot;jscaz.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 #include &amp;quot;ds/Baz.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;js/Bar.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;vm/Bat.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 #include &amp;quot;jssqueeinlines.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;jswoot-inl.h&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 #include &amp;quot;frontend/Thingamabob-inl.h&amp;quot;&lt;br /&gt;
 #include &amp;quot;vm/VirtualReality-inl.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
= C++ =&lt;br /&gt;
&lt;br /&gt;
== Namespaces ==&lt;br /&gt;
&lt;br /&gt;
* Public functions and types should be in the JS:: namespace, in preference to the old JS/JS_ name prefixes.&lt;br /&gt;
* Library-private and friend functions should be in the js:: namespace, in preference to the old js_ name prefix.&lt;br /&gt;
* Compile-time-evaluated functions (i.e., template meta-functions) should be in &#039;js::tl::&#039;, the &amp;quot;template library&amp;quot; namespace, to avoid collision with their runtime counterparts.&lt;br /&gt;
* In SpiderMonkey .cpp files, it is okay to have &#039;using namespace js;&#039;, but it is not okay to do the same with any other namespace, like JS:: or mozilla::. These can introduce ambiguities that come and go depending on which .cpp files the build system decides to unify.&lt;br /&gt;
* If you do have names in JS:: that should be readily available throughout SpiderMonkey, you may add a &#039;using&#039; declaration to js/src/NamespaceImports.h.&lt;br /&gt;
* Avoid unnamed namespaces unless they are necessary to give a class&#039;s members internal linkage.  Although the C++ standard officially deprecates &#039;static&#039; on  functions, &#039;static&#039; has the following advantages over unnamed namespaces:&lt;br /&gt;
** It is difficult to name functions in unnamed namespaces in gdb.&lt;br /&gt;
** Static says &amp;quot;this is a translation-unit-local helper function&amp;quot; on the function, without having to look around for an enclosing &amp;quot;namespace {&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Enums ==&lt;br /&gt;
&lt;br /&gt;
Older code uses SHOUT_REALLY_LOUD for enum values, newer code uses InterCaps. Enums should be preferred to boolean arguments for ease of understanding at the invocation site.&lt;br /&gt;
&lt;br /&gt;
== Classical OOP ==&lt;br /&gt;
&lt;br /&gt;
* Most structs can become classes, with associated functions becoming methods. This already started for the [https://bugzilla.mozilla.org/show_bug.cgi?id=upvar2 upvar2 bug].&lt;br /&gt;
** Style detailing: mrbkap suggests left brace before class body on its own line in column 1 to match function style and facilitate vim navigation. People do this already when inheriting, since the left brace can get lost in the superclass(es).&lt;br /&gt;
 class JSObject&lt;br /&gt;
 {&lt;br /&gt;
      ...&lt;br /&gt;
 }&lt;br /&gt;
* Member variable names, private or public, are sometimes decorated with a trailing &#039;_&#039;.&lt;br /&gt;
 class Fail&lt;br /&gt;
 {&lt;br /&gt;
     size_t capacity;  // common&lt;br /&gt;
     T* begin_;        // also common, being used more as time goes on&lt;br /&gt;
 }&lt;br /&gt;
Sometimes a canonical argument name may conflict with a member name.  In this case, one can disambiguate with &amp;quot;this-&amp;gt;&amp;quot;, although such explicit qualification should only be added when necessary:&lt;br /&gt;
 class C&lt;br /&gt;
 {&lt;br /&gt;
     size_t count;&lt;br /&gt;
     bool fresh;&lt;br /&gt;
     void change(size_t count) {&lt;br /&gt;
         this-&amp;gt;count = count;&lt;br /&gt;
         this-&amp;gt;fresh = false;  // verbose and unnecessary&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
* Most macros become inline helpers. With LiveConnect gone on mozilla-central, we can make the helpers methods of relevant structs or classes finally, instead of static inline functions.&lt;br /&gt;
* Based on 20+ years of bad experiences, we are going to go slow and resist virtual methods and bases, MI, and the like. Function pointer tables for now, as before -- see [https://bugzilla.mozilla.org/show_bug.cgi?id=408416 JSObjectOps needs a make-over].&lt;br /&gt;
* Templates are good, Mozilla has positive experience and the portability is there for the kind of [http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization RAII] helpers we need.&lt;br /&gt;
* No exceptions, so std is hard to use. There is initial work underway to make STL-like containers that mesh well with the rest of the JS engine (see js::Vector, js::HashMap, js::Pool).&lt;br /&gt;
** There are still improvements to be made to the new hash table: double-hash implementation; improve bit-mixing into multiplicative hash if the cycle costs can be supported (measurement is required and we should understand down to the bits what is going on); a js::HashSet or js::HashMap&amp;lt;T,void&amp;gt; specialization such that set-like use of hashtables do not waste any space on values.&lt;br /&gt;
&lt;br /&gt;
=== Initializer lists ===&lt;br /&gt;
&lt;br /&gt;
Initializer lists can break in one of two ways. The first may be preferable when constructors take few arguments:&lt;br /&gt;
&lt;br /&gt;
 class Ninja : public WeaponWeilder, public Camouflagible,&lt;br /&gt;
               public Assassinatable, public ShapeShiftable&lt;br /&gt;
 {&lt;br /&gt;
     Ninja() : WeaponWeilder(Weapons::SHURIKEN),&lt;br /&gt;
               Camouflagible(Garments::SHINOBI_SHOZOKU),&lt;br /&gt;
               Assassinatable(AssassinationDifficulty::HIGHLY_DIFFICULT),&lt;br /&gt;
               ShapeShiftable(MPCost(512)) {}&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The other permitted style mitigates longer-identifiers-squishing-text-against-the-right-side-of-the-screen-syndrome by using a half-indented colon:&lt;br /&gt;
&lt;br /&gt;
 class Ninja&lt;br /&gt;
   : public WeaponWeilder, public Camouflagible, public Assassinatable,&lt;br /&gt;
     public ShapeShiftable&lt;br /&gt;
 {&lt;br /&gt;
     Ninja()&lt;br /&gt;
       : WeaponWeilder(Weapons::SHURIKEN),&lt;br /&gt;
         Camouflagible(Garments::SHINOBI_SHOZOKU),&lt;br /&gt;
         Assassinatable(AssassinationDifficulty::HIGHLY_DIFFICULT),&lt;br /&gt;
         ShapeShiftable(MPCost(512)) {}&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Inline methods ===&lt;br /&gt;
&lt;br /&gt;
If the method in question fits on one line and is branch free, do a one liner:&lt;br /&gt;
&lt;br /&gt;
 class Eater&lt;br /&gt;
 {&lt;br /&gt;
     void eat(Eaten &amp;amp;other) { other.setConsumed(); }&lt;br /&gt;
 };&lt;br /&gt;
&lt;br /&gt;
If it&#039;s too long, put the type, declarator including formals (unless they overflow), and left brace all on the first line:&lt;br /&gt;
&lt;br /&gt;
 class Eater&lt;br /&gt;
 {&lt;br /&gt;
     Food* obtainFoodFromEatery(Eatery &amp;amp;eatery) {&lt;br /&gt;
         if (!eatery.hasFood())&lt;br /&gt;
             return NULL;&lt;br /&gt;
         return eatery.purchaseFood();&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
&lt;br /&gt;
For out-of-line inlines (when the definitions are too unwieldy to place in the class definition) use the inline keyword as an indicator that there&#039;s an out-of-line inline definition:&lt;br /&gt;
&lt;br /&gt;
 class SpaceGoo&lt;br /&gt;
 {&lt;br /&gt;
     inline BlobbyWrapper* enblob(Entity &amp;amp;other);&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 inline BlobbyWrapper*&lt;br /&gt;
 SpaceGoo::enblob(Entity &amp;amp;other)&lt;br /&gt;
 {&lt;br /&gt;
     /* ... */&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* [https://developer.mozilla.org/en/Mozilla_Coding_Style_Guide Mozilla&#039;s coding style guide].&lt;br /&gt;
* [http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml Google&#039;s C++ coding style guide].&lt;br /&gt;
&lt;br /&gt;
= Exceptions to this coding style =&lt;br /&gt;
&lt;br /&gt;
SpiderMonkey contains some code imported from other projects, e.g. ctypes/libffi/, that is minimally modified.  Such code does not have to follow SpiderMonkey style.&lt;/div&gt;</summary>
		<author><name>Ehoogeveen</name></author>
	</entry>
	<entry>
		<id>https://wiki.mozilla.org/index.php?title=Security/Bug_Approval_Process&amp;diff=724713</id>
		<title>Security/Bug Approval Process</title>
		<link rel="alternate" type="text/html" href="https://wiki.mozilla.org/index.php?title=Security/Bug_Approval_Process&amp;diff=724713"/>
		<updated>2013-10-08T17:54:22Z</updated>

		<summary type="html">&lt;p&gt;Ehoogeveen: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Purpose: don&#039;t 0-day ourselves==&lt;br /&gt;
People watch our check-ins. If the patch is an obvious security fix, the check-in comment says &amp;quot;security fix&amp;quot;, or the testcase shows how to trigger a vulnerability someone may be able to start exploiting our users before we were planning to ship that fix.&lt;br /&gt;
&lt;br /&gt;
==Principle: assume the worst==&lt;br /&gt;
* If there&#039;s no rating we assume it could be critical&lt;br /&gt;
* If we don&#039;t know the regression range we assume it needs porting to all supported branches&lt;br /&gt;
&lt;br /&gt;
==Process==&lt;br /&gt;
For security bugs with no sec- severity rating assume the worst and follow the rules for sec-critical. If you have experience fixing security bugs you could also take a crack at rating it yourself following the [[Security_Severity_Ratings]]&lt;br /&gt;
&lt;br /&gt;
Core-security bug fixes should just be landed by a developer without any&lt;br /&gt;
explicit approval if:&lt;br /&gt;
&lt;br /&gt;
# The bug has a sec-low, sec-moderate, sec-other, or sec-want rating.&amp;lt;br&amp;gt;&#039;&#039;&#039;OR&#039;&#039;&#039;&lt;br /&gt;
# The bug is a recent regression on mozilla-central (this means that the specific regressing check-in has been identified on mozilla-central)&lt;br /&gt;
&lt;br /&gt;
This means that the developer can mark the status flags for ESR, Beta, and Aurora as &amp;quot;unaffected.&amp;quot; It also means that we haven&#039;t shipped anywhere public in an official release yet.&lt;br /&gt;
&lt;br /&gt;
If it meets the above criteria, check that patch in.&lt;br /&gt;
&lt;br /&gt;
Otherwise, if the bug has a patch *and* is sec-high or sec-critical, the developer should set the sec-approval flag to &#039;?&#039; on the patch when it is ready to be checked into mozilla-central (or elsewhere if it is branch only).&lt;br /&gt;
&lt;br /&gt;
If you have a patch and the bug is a hidden core-security bug with no rating then either:&lt;br /&gt;
# request sec-approval (to be safe) and wait for a rating, &amp;lt;br&amp;gt;&#039;&#039;&#039;OR&#039;&#039;&#039;&lt;br /&gt;
# rate it following the [[Security_Severity_Ratings]] and then proceed according to whether the bug is low/moderate or high/critical as above.&lt;br /&gt;
&lt;br /&gt;
If developers are unsure about a bug and it has a patch ready, just mark the sec-approval flag to &#039;?&#039; and move on. Don&#039;t overthink it!&lt;br /&gt;
&lt;br /&gt;
An automatic nomination comment will be added to bugzilla when sec-approval is set to &#039;?&#039;. The questions in this need to be filled out as best as possible when sec-approval is requested for the patch.&lt;br /&gt;
&lt;br /&gt;
It is as follows (courtesy of Dan Veditz):&lt;br /&gt;
&lt;br /&gt;
: [Security approval request comment]&lt;br /&gt;
: How easily can the security issue be deduced from the patch?&lt;br /&gt;
: &lt;br /&gt;
: Do comments in the patch, the check-in comment, or tests included in the patch paint a bulls-eye on the security problem?&lt;br /&gt;
: &lt;br /&gt;
: Which older supported branches are affected by this flaw?&lt;br /&gt;
: &lt;br /&gt;
: If not all supported branches, which bug introduced the flaw?&lt;br /&gt;
: &lt;br /&gt;
: Do you have backports for the affected branches? If not, how different, hard to create, and risky will they be?&lt;br /&gt;
: &lt;br /&gt;
: How likely is this patch to cause regressions; how much testing does it need?&lt;br /&gt;
&lt;br /&gt;
This is similar to the ESR approval nomination form and is meant to help us evaluate the risks around approving the patch for checkin.&lt;br /&gt;
&lt;br /&gt;
When the bug is approved for landing, the sec-approval flag will be set to &#039;+&#039; with a comment from the approver to land the patch. At that point, land it.&lt;br /&gt;
&lt;br /&gt;
This will allow us to control when we can land security bugs without exposing them too early and to make sure they get landed on the various branches.&lt;br /&gt;
&lt;br /&gt;
The security assurance team and release management will have their own process for approving bugs:&lt;br /&gt;
&lt;br /&gt;
# The Security assurance team goes through sec-approval ? bugs daily and approves low risk fixes for central (if early in cycle). Developers can also ping the Security Assurance Team (specifically Al Billings &amp;amp; Dan Veditz) in #security on IRC when important.&lt;br /&gt;
# Security team marks tracking flags to ? for all affected versions when approved for central. (This allows release management to decide whether to uplift to branches just like always.)&lt;br /&gt;
# Weekly security/release management triage meeting goes through sec-approval + and ? bugs where beta and ESR is affected, ? bugs with higher risk (sec-high and sec-critical), or ? bugs near end of cycle.&lt;/div&gt;</summary>
		<author><name>Ehoogeveen</name></author>
	</entry>
</feed>