JavaScript:SpiderMonkey:C Coding Style: Difference between revisions

Jump to navigation Jump to search
(Rearrange, clarify wording a few places, note the change to 100-column limit)
Line 36: Line 36:
  JS_SetContext(rt,        /* OK */
  JS_SetContext(rt,        /* OK */
               cx);
               cx);
= Whitespace in declarations =
These rules are inconsistently applied.  Be consistent with the code you're editing rather than adhere too closely to these guidelines!
* In a declaration of a pointer, the <code>*</code> goes with the variable name:
char* s;                  /* bad */
char *s;                  /* OK */
* Even in the return type of a method:
class JSString {
    ...
    JSString* dependentBase() const;  /* bad */
    JSString * dependentBase() const;  /* bad */
    JSString *dependentBase() const;  /* OK */
    ...
};
* But in top-level function declarations/definitions, put a line break immediately before the name being declared:
extern const char *
js_GetStringBytes(JSContext *cx, JSString *str);  /* OK */
* And put a space in <code>*JS_FASTCALL</code>, because that would be crazy.
extern JSString *JS_FASTCALL          /* bad */
js_ConcatStrings(JSContext *cx, JSString *left, JSString *right);
extern JSString * JS_FASTCALL          /* OK */
js_ConcatStrings(JSContext *cx, JSString *left, JSString *right);


= Other whitespace =
= Other whitespace =
638

edits

Navigation menu