From 6e7dbe052a74dee2f797ba7e54b5e635b75258d4 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Mon, 30 Apr 2018 15:12:57 +0200 Subject: [PATCH 1/2] http2: rename http2_state class to Http2State This commit renames the http2_state class to follow the guidelines in CPP_STYLE_GUIDE.md. --- src/env-inl.h | 4 ++-- src/env.h | 6 +++--- src/node_http2.cc | 2 +- src/node_http2_state.h | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/env-inl.h b/src/env-inl.h index fa241f9706ec65..09593031766b44 100644 --- a/src/env-inl.h +++ b/src/env-inl.h @@ -482,12 +482,12 @@ inline void Environment::set_http_parser_buffer_in_use(bool in_use) { http_parser_buffer_in_use_ = in_use; } -inline http2::http2_state* Environment::http2_state() const { +inline http2::Http2State* Environment::http2_state() const { return http2_state_.get(); } inline void Environment::set_http2_state( - std::unique_ptr buffer) { + std::unique_ptr buffer) { CHECK(!http2_state_); // Should be set only once. http2_state_ = std::move(buffer); } diff --git a/src/env.h b/src/env.h index af4470ad8632fe..2a4e351c9649cc 100644 --- a/src/env.h +++ b/src/env.h @@ -643,8 +643,8 @@ class Environment { inline bool http_parser_buffer_in_use() const; inline void set_http_parser_buffer_in_use(bool in_use); - inline http2::http2_state* http2_state() const; - inline void set_http2_state(std::unique_ptr state); + inline http2::Http2State* http2_state() const; + inline void set_http2_state(std::unique_ptr state); inline AliasedBuffer* fs_stats_field_array(); @@ -829,7 +829,7 @@ class Environment { char* http_parser_buffer_; bool http_parser_buffer_in_use_ = false; - std::unique_ptr http2_state_; + std::unique_ptr http2_state_; AliasedBuffer fs_stats_field_array_; diff --git a/src/node_http2.cc b/src/node_http2.cc index 05d9243ee30ec0..ecd990d9ff602f 100644 --- a/src/node_http2.cc +++ b/src/node_http2.cc @@ -2660,7 +2660,7 @@ void Initialize(Local target, Isolate* isolate = env->isolate(); HandleScope scope(isolate); - std::unique_ptr state(new http2_state(isolate)); + std::unique_ptr state(new Http2State(isolate)); #define SET_STATE_TYPEDARRAY(name, field) \ target->Set(context, \ diff --git a/src/node_http2_state.h b/src/node_http2_state.h index ed88f068a04b16..64a0942f7ffa67 100644 --- a/src/node_http2_state.h +++ b/src/node_http2_state.h @@ -84,9 +84,9 @@ namespace http2 { IDX_SESSION_STATS_COUNT }; -class http2_state { +class Http2State { public: - explicit http2_state(v8::Isolate* isolate) : + explicit Http2State(v8::Isolate* isolate) : root_buffer( isolate, sizeof(http2_state_internal)), From 230cf8a79c13ac2f6dd661ff409697453dfdfdda Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Wed, 2 May 2018 08:59:35 +0200 Subject: [PATCH 2/2] doc: add snake_case section for C-like structs This commit adds a section mentioning that for C-like structs it is alright to use snake_case. Refs: https://github.com/nodejs/node/pull/20423 --- CPP_STYLE_GUIDE.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CPP_STYLE_GUIDE.md b/CPP_STYLE_GUIDE.md index edc5f0f12e212c..41e1f082f87751 100644 --- a/CPP_STYLE_GUIDE.md +++ b/CPP_STYLE_GUIDE.md @@ -12,6 +12,7 @@ * [CamelCase for methods, functions, and classes](#camelcase-for-methods-functions-and-classes) * [snake\_case for local variables and parameters](#snake_case-for-local-variables-and-parameters) * [snake\_case\_ for private class fields](#snake_case_-for-private-class-fields) + * [snake\_case\_ for C-like structs](#snake_case_-for-c-like-structs) * [Space after `template`](#space-after-template) * [Memory Management](#memory-management) * [Memory allocation](#memory-allocation) @@ -147,6 +148,15 @@ class Foo { }; ``` +## snake\_case\_ for C-like structs +For plain C-like structs snake_case can be used. + +```c++ +struct foo_bar { + int name; +} +``` + ## Space after `template` ```c++