From 7063c59b97fa4f365f9e5ec1f563235ede4104db Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Wed, 16 Oct 2013 20:34:39 +0400 Subject: [PATCH] cpplint: disallow comma-first in C++ --- src/env-inl.h | 20 ++++++------- src/handle_wrap.cc | 6 ++-- src/node_contextify.cc | 10 +++---- src/node_crypto.h | 64 ++++++++++++++++++++-------------------- src/node_file.cc | 6 ++-- src/node_http_parser.cc | 8 ++--- src/node_stat_watcher.cc | 6 ++-- src/node_zlib.cc | 30 +++++++++---------- src/stream_wrap.cc | 8 ++--- src/stream_wrap.h | 4 +-- src/udp_wrap.cc | 4 +-- tools/cpplint.py | 3 ++ 12 files changed, 86 insertions(+), 83 deletions(-) diff --git a/src/env-inl.h b/src/env-inl.h index 6ab93c4e46f..6fd64940d1c 100644 --- a/src/env-inl.h +++ b/src/env-inl.h @@ -52,14 +52,14 @@ inline void Environment::IsolateData::Put() { } inline Environment::IsolateData::IsolateData(v8::Isolate* isolate) - : event_loop_(uv_default_loop()) - , isolate_(isolate) + : event_loop_(uv_default_loop()), + isolate_(isolate), #define V(PropertyName, StringValue) \ - , PropertyName ## _index_( \ - FIXED_ONE_BYTE_STRING(isolate, StringValue).Eternalize(isolate)) + PropertyName ## _index_( \ + FIXED_ONE_BYTE_STRING(isolate, StringValue).Eternalize(isolate)), PER_ISOLATE_STRING_PROPERTIES(V) #undef V - , ref_count_(0) { + ref_count_(0) { } inline uv_loop_t* Environment::IsolateData::event_loop() const { @@ -155,11 +155,11 @@ inline Environment* Environment::GetCurrentChecked( } inline Environment::Environment(v8::Local context) - : isolate_(context->GetIsolate()) - , isolate_data_(IsolateData::GetOrCreate(context->GetIsolate())) - , using_smalloc_alloc_cb_(false) - , using_domains_(false) - , context_(context->GetIsolate(), context) { + : isolate_(context->GetIsolate()), + isolate_data_(IsolateData::GetOrCreate(context->GetIsolate())), + using_smalloc_alloc_cb_(false), + using_domains_(false), + context_(context->GetIsolate(), context) { // We'll be creating new objects so make sure we've entered the context. v8::Context::Scope context_scope(context); v8::HandleScope handle_scope(isolate()); diff --git a/src/handle_wrap.cc b/src/handle_wrap.cc index 05d4c4dddc7..d1c132435d2 100644 --- a/src/handle_wrap.cc +++ b/src/handle_wrap.cc @@ -89,9 +89,9 @@ void HandleWrap::Close(const FunctionCallbackInfo& args) { HandleWrap::HandleWrap(Environment* env, Handle object, uv_handle_t* handle) - : env_(env) - , flags_(0) - , handle__(handle) { + : env_(env), + flags_(0), + handle__(handle) { handle__->data = this; HandleScope scope(node_isolate); persistent().Reset(node_isolate, object); diff --git a/src/node_contextify.cc b/src/node_contextify.cc index ca281df05c3..f78f49fb36c 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -64,12 +64,12 @@ class ContextifyContext { public: explicit ContextifyContext(Environment* env, Local sandbox) - : env_(env) - , sandbox_(env->isolate(), sandbox) - , context_(env->isolate(), CreateV8Context(env)) - , proxy_global_(env->isolate(), context()->Global()) + : env_(env), + sandbox_(env->isolate(), sandbox), + context_(env->isolate(), CreateV8Context(env)), + proxy_global_(env->isolate(), context()->Global()), // Wait for sandbox_, proxy_global_, and context_ to die - , references_(3) { + references_(3) { sandbox_.MakeWeak(this, WeakCallback); sandbox_.MarkIndependent(); context_.MakeWeak(this, WeakCallback); diff --git a/src/node_crypto.h b/src/node_crypto.h index 772db95f935..01a4db820f6 100644 --- a/src/node_crypto.h +++ b/src/node_crypto.h @@ -94,10 +94,10 @@ class SecureContext : public WeakObject { static void SetTicketKeys(const v8::FunctionCallbackInfo& args); SecureContext(Environment* env, v8::Local wrap) - : WeakObject(env->isolate(), wrap) - , ca_store_(NULL) - , ctx_(NULL) - , env_(env) { + : WeakObject(env->isolate(), wrap), + ca_store_(NULL), + ctx_(NULL), + env_(env) { } void FreeCTXMem() { @@ -134,10 +134,10 @@ class SSLWrap { }; SSLWrap(Environment* env, SecureContext* sc, Kind kind) - : env_(env) - , kind_(kind) - , next_sess_(NULL) - , session_callbacks_(false) { + : env_(env), + kind_(kind), + next_sess_(NULL), + session_callbacks_(false) { ssl_ = SSL_new(sc->ctx_); assert(ssl_ != NULL); } @@ -285,11 +285,11 @@ class Connection : public SSLWrap, public WeakObject { v8::Local wrap, SecureContext* sc, SSLWrap::Kind kind) - : SSLWrap(env, sc, kind) - , WeakObject(env->isolate(), wrap) - , bio_read_(NULL) - , bio_write_(NULL) - , hello_offset_(0) { + : SSLWrap(env, sc, kind), + WeakObject(env->isolate(), wrap), + bio_read_(NULL), + bio_write_(NULL), + hello_offset_(0) { hello_parser_.Start(SSLWrap::OnClientHello, OnClientHelloParseEnd, this); @@ -347,10 +347,10 @@ class CipherBase : public WeakObject { CipherBase(v8::Isolate* isolate, v8::Local wrap, CipherKind kind) - : WeakObject(isolate, wrap) - , cipher_(NULL) - , initialised_(false) - , kind_(kind) { + : WeakObject(isolate, wrap), + cipher_(NULL), + initialised_(false), + kind_(kind) { } ~CipherBase() { @@ -380,9 +380,9 @@ class Hmac : public WeakObject { static void HmacDigest(const v8::FunctionCallbackInfo& args); Hmac(v8::Isolate* isolate, v8::Local wrap) - : WeakObject(isolate, wrap) - , md_(NULL) - , initialised_(false) { + : WeakObject(isolate, wrap), + md_(NULL), + initialised_(false) { } ~Hmac() { @@ -409,9 +409,9 @@ class Hash : public WeakObject { static void HashDigest(const v8::FunctionCallbackInfo& args); Hash(v8::Isolate* isolate, v8::Local wrap) - : WeakObject(isolate, wrap) - , md_(NULL) - , initialised_(false) { + : WeakObject(isolate, wrap), + md_(NULL), + initialised_(false) { } ~Hash() { @@ -443,9 +443,9 @@ class Sign : public WeakObject { static void SignFinal(const v8::FunctionCallbackInfo& args); Sign(v8::Isolate* isolate, v8::Local wrap) - : WeakObject(isolate, wrap) - , md_(NULL) - , initialised_(false) { + : WeakObject(isolate, wrap), + md_(NULL), + initialised_(false) { } ~Sign() { @@ -477,9 +477,9 @@ class Verify : public WeakObject { static void VerifyFinal(const v8::FunctionCallbackInfo& args); Verify(v8::Isolate* isolate, v8::Local wrap) - : WeakObject(isolate, wrap) - , md_(NULL) - , initialised_(false) { + : WeakObject(isolate, wrap), + md_(NULL), + initialised_(false) { } ~Verify() { @@ -515,9 +515,9 @@ class DiffieHellman : public WeakObject { static void SetPrivateKey(const v8::FunctionCallbackInfo& args); DiffieHellman(v8::Isolate* isolate, v8::Local wrap) - : WeakObject(isolate, wrap) - , initialised_(false) - , dh(NULL) { + : WeakObject(isolate, wrap), + initialised_(false), + dh(NULL) { } ~DiffieHellman() { diff --git a/src/node_file.cc b/src/node_file.cc index fa49dd4bcc7..a6905aa3e13 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -67,9 +67,9 @@ using v8::Value; class FSReqWrap: public ReqWrap { public: FSReqWrap(Environment* env, const char* syscall, char* data = NULL) - : ReqWrap(env) - , syscall_(syscall) - , data_(data) { + : ReqWrap(env), + syscall_(syscall), + data_(data) { } void ReleaseEarly() { diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc index 12e9ee2fd38..f7faf0d792f 100644 --- a/src/node_http_parser.cc +++ b/src/node_http_parser.cc @@ -190,10 +190,10 @@ struct StringPtr { class Parser : public WeakObject { public: Parser(Environment* env, Local wrap, enum http_parser_type type) - : WeakObject(env->isolate(), wrap) - , env_(env) - , current_buffer_len_(0) - , current_buffer_data_(NULL) { + : WeakObject(env->isolate(), wrap), + env_(env), + current_buffer_len_(0), + current_buffer_data_(NULL) { Init(type); } diff --git a/src/node_stat_watcher.cc b/src/node_stat_watcher.cc index 892ccac0e8d..45936fe93cb 100644 --- a/src/node_stat_watcher.cc +++ b/src/node_stat_watcher.cc @@ -64,9 +64,9 @@ static void Delete(uv_handle_t* handle) { StatWatcher::StatWatcher(Environment* env, Local wrap) - : WeakObject(env->isolate(), wrap) - , watcher_(new uv_fs_poll_t) - , env_(env) { + : WeakObject(env->isolate(), wrap), + watcher_(new uv_fs_poll_t), + env_(env) { uv_fs_poll_init(env->event_loop(), watcher_); watcher_->data = static_cast(this); } diff --git a/src/node_zlib.cc b/src/node_zlib.cc index 2d411ab29a5..e9de782d0eb 100644 --- a/src/node_zlib.cc +++ b/src/node_zlib.cc @@ -71,21 +71,21 @@ class ZCtx : public WeakObject { public: ZCtx(Environment* env, Local wrap, node_zlib_mode mode) - : WeakObject(env->isolate(), wrap) - , chunk_size_(0) - , dictionary_(NULL) - , dictionary_len_(0) - , env_(env) - , err_(0) - , flush_(0) - , init_done_(false) - , level_(0) - , memLevel_(0) - , mode_(mode) - , strategy_(0) - , windowBits_(0) - , write_in_progress_(false) - , refs_(0) { + : WeakObject(env->isolate(), wrap), + chunk_size_(0), + dictionary_(NULL), + dictionary_len_(0), + env_(env), + err_(0), + flush_(0), + init_done_(false), + level_(0), + memLevel_(0), + mode_(mode), + strategy_(0), + windowBits_(0), + write_in_progress_(false), + refs_(0) { } diff --git a/src/stream_wrap.cc b/src/stream_wrap.cc index 49a2f90f46f..f1949d98296 100644 --- a/src/stream_wrap.cc +++ b/src/stream_wrap.cc @@ -54,10 +54,10 @@ using v8::Value; StreamWrap::StreamWrap(Environment* env, Local object, uv_stream_t* stream) - : HandleWrap(env, object, reinterpret_cast(stream)) - , stream_(stream) - , default_callbacks_(this) - , callbacks_(&default_callbacks_) { + : HandleWrap(env, object, reinterpret_cast(stream)), + stream_(stream), + default_callbacks_(this), + callbacks_(&default_callbacks_) { } diff --git a/src/stream_wrap.h b/src/stream_wrap.h index 26fb5d5ef64..374e7c75cea 100644 --- a/src/stream_wrap.h +++ b/src/stream_wrap.h @@ -38,8 +38,8 @@ typedef class ReqWrap ShutdownWrap; class WriteWrap: public ReqWrap { public: WriteWrap(Environment* env, v8::Local obj, StreamWrap* wrap) - : ReqWrap(env, obj) - , wrap_(wrap) { + : ReqWrap(env, obj), + wrap_(wrap) { } void* operator new(size_t size, char* storage) { return storage; } diff --git a/src/udp_wrap.cc b/src/udp_wrap.cc index fd679ab4d8a..151789d2591 100644 --- a/src/udp_wrap.cc +++ b/src/udp_wrap.cc @@ -60,8 +60,8 @@ class SendWrap : public ReqWrap { SendWrap::SendWrap(Environment* env, Local req_wrap_obj, bool have_callback) - : ReqWrap(env, req_wrap_obj) - , have_callback_(have_callback) { + : ReqWrap(env, req_wrap_obj), + have_callback_(have_callback) { } diff --git a/tools/cpplint.py b/tools/cpplint.py index 3993d0856cd..5dd1b25a259 100644 --- a/tools/cpplint.py +++ b/tools/cpplint.py @@ -2108,6 +2108,9 @@ def CheckStyle(filename, clean_lines, linenum, file_extension, error): 'the base class list in a class definition, the colon should ' 'be on the following line.') + if len(line) > initial_spaces and line[initial_spaces] == ',': + error(filename, linenum, 'whitespace/commafirst', 4, + 'Comma-first style is not allowed') # Check if the line is a header guard. is_header_guard = False