Skip to content

Commit

Permalink
src: fix whitespace/indent cpplint warnings
Browse files Browse the repository at this point in the history
PR-URL: #7462
Reviewed-By: Trevor Norris <[email protected]>
  • Loading branch information
bnoordhuis authored and Fishrock123 committed Jul 5, 2016
1 parent f72259a commit 3fa643b
Show file tree
Hide file tree
Showing 4 changed files with 249 additions and 248 deletions.
152 changes: 76 additions & 76 deletions src/node_internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,82 +231,82 @@ void ClearFatalExceptionHandlers(Environment* env);
enum NodeInstanceType { MAIN, WORKER, REMOTE_DEBUG_SERVER };

class NodeInstanceData {
public:
NodeInstanceData(NodeInstanceType node_instance_type,
uv_loop_t* event_loop,
int argc,
const char** argv,
int exec_argc,
const char** exec_argv,
bool use_debug_agent_flag)
: node_instance_type_(node_instance_type),
exit_code_(1),
event_loop_(event_loop),
argc_(argc),
argv_(argv),
exec_argc_(exec_argc),
exec_argv_(exec_argv),
use_debug_agent_flag_(use_debug_agent_flag) {
CHECK_NE(event_loop_, nullptr);
}

uv_loop_t* event_loop() const {
return event_loop_;
}

int exit_code() {
CHECK(is_main());
return exit_code_;
}

void set_exit_code(int exit_code) {
CHECK(is_main());
exit_code_ = exit_code;
}

bool is_main() {
return node_instance_type_ == MAIN;
}

bool is_worker() {
return node_instance_type_ == WORKER;
}

bool is_remote_debug_server() {
return node_instance_type_ == REMOTE_DEBUG_SERVER;
}

int argc() {
return argc_;
}

const char** argv() {
return argv_;
}

int exec_argc() {
return exec_argc_;
}

const char** exec_argv() {
return exec_argv_;
}

bool use_debug_agent() {
return is_main() && use_debug_agent_flag_;
}

private:
const NodeInstanceType node_instance_type_;
int exit_code_;
uv_loop_t* const event_loop_;
const int argc_;
const char** argv_;
const int exec_argc_;
const char** exec_argv_;
const bool use_debug_agent_flag_;

DISALLOW_COPY_AND_ASSIGN(NodeInstanceData);
public:
NodeInstanceData(NodeInstanceType node_instance_type,
uv_loop_t* event_loop,
int argc,
const char** argv,
int exec_argc,
const char** exec_argv,
bool use_debug_agent_flag)
: node_instance_type_(node_instance_type),
exit_code_(1),
event_loop_(event_loop),
argc_(argc),
argv_(argv),
exec_argc_(exec_argc),
exec_argv_(exec_argv),
use_debug_agent_flag_(use_debug_agent_flag) {
CHECK_NE(event_loop_, nullptr);
}

uv_loop_t* event_loop() const {
return event_loop_;
}

int exit_code() {
CHECK(is_main());
return exit_code_;
}

void set_exit_code(int exit_code) {
CHECK(is_main());
exit_code_ = exit_code;
}

bool is_main() {
return node_instance_type_ == MAIN;
}

bool is_worker() {
return node_instance_type_ == WORKER;
}

bool is_remote_debug_server() {
return node_instance_type_ == REMOTE_DEBUG_SERVER;
}

int argc() {
return argc_;
}

const char** argv() {
return argv_;
}

int exec_argc() {
return exec_argc_;
}

const char** exec_argv() {
return exec_argv_;
}

bool use_debug_agent() {
return is_main() && use_debug_agent_flag_;
}

private:
const NodeInstanceType node_instance_type_;
int exit_code_;
uv_loop_t* const event_loop_;
const int argc_;
const char** argv_;
const int exec_argc_;
const char** exec_argv_;
const bool use_debug_agent_flag_;

DISALLOW_COPY_AND_ASSIGN(NodeInstanceData);
};

namespace Buffer {
Expand Down
71 changes: 36 additions & 35 deletions src/node_watchdog.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,56 +39,57 @@ class Watchdog {
};

class SigintWatchdog {
public:
explicit SigintWatchdog(v8::Isolate* isolate);
~SigintWatchdog();
public:
explicit SigintWatchdog(v8::Isolate* isolate);
~SigintWatchdog();

void Dispose();
void Dispose();

v8::Isolate* isolate() { return isolate_; }
bool HasReceivedSignal() { return received_signal_; }
void HandleSigint();
private:
void Destroy();
v8::Isolate* isolate() { return isolate_; }
bool HasReceivedSignal() { return received_signal_; }
void HandleSigint();

private:
void Destroy();

v8::Isolate* isolate_;
bool received_signal_;
bool destroyed_;
v8::Isolate* isolate_;
bool received_signal_;
bool destroyed_;
};

class SigintWatchdogHelper {
public:
static SigintWatchdogHelper* GetInstance() { return &instance; }
void Register(SigintWatchdog* watchdog);
void Unregister(SigintWatchdog* watchdog);
public:
static SigintWatchdogHelper* GetInstance() { return &instance; }
void Register(SigintWatchdog* watchdog);
void Unregister(SigintWatchdog* watchdog);

int Start();
bool Stop();
int Start();
bool Stop();

private:
SigintWatchdogHelper();
~SigintWatchdogHelper();
private:
SigintWatchdogHelper();
~SigintWatchdogHelper();

static bool InformWatchdogsAboutSignal();
static SigintWatchdogHelper instance;
static bool InformWatchdogsAboutSignal();
static SigintWatchdogHelper instance;

int start_stop_count_;
int start_stop_count_;

uv_mutex_t mutex_;
uv_mutex_t list_mutex_;
std::vector<SigintWatchdog*> watchdogs_;
bool has_pending_signal_;
uv_mutex_t mutex_;
uv_mutex_t list_mutex_;
std::vector<SigintWatchdog*> watchdogs_;
bool has_pending_signal_;

#ifdef __POSIX__
pthread_t thread_;
uv_sem_t sem_;
bool has_running_thread_;
bool stopping_;
pthread_t thread_;
uv_sem_t sem_;
bool has_running_thread_;
bool stopping_;

static void* RunSigintWatchdog(void* arg);
static void HandleSignal(int signum);
static void* RunSigintWatchdog(void* arg);
static void HandleSignal(int signum);
#else
static BOOL WINAPI WinCtrlCHandlerRoutine(DWORD dwCtrlType);
static BOOL WINAPI WinCtrlCHandlerRoutine(DWORD dwCtrlType);
#endif
};

Expand Down
112 changes: 56 additions & 56 deletions src/string_bytes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,78 +27,78 @@ using v8::Value;

template <typename ResourceType, typename TypeName>
class ExternString: public ResourceType {
public:
~ExternString() override {
free(const_cast<TypeName*>(data_));
isolate()->AdjustAmountOfExternalAllocatedMemory(-byte_length());
}

const TypeName* data() const override {
return data_;
}
public:
~ExternString() override {
free(const_cast<TypeName*>(data_));
isolate()->AdjustAmountOfExternalAllocatedMemory(-byte_length());
}

size_t length() const override {
return length_;
}
const TypeName* data() const override {
return data_;
}

int64_t byte_length() const {
return length() * sizeof(*data());
}
size_t length() const override {
return length_;
}

static Local<String> NewFromCopy(Isolate* isolate,
const TypeName* data,
size_t length) {
EscapableHandleScope scope(isolate);
int64_t byte_length() const {
return length() * sizeof(*data());
}

if (length == 0)
return scope.Escape(String::Empty(isolate));
static Local<String> NewFromCopy(Isolate* isolate,
const TypeName* data,
size_t length) {
EscapableHandleScope scope(isolate);

TypeName* new_data =
static_cast<TypeName*>(malloc(length * sizeof(*new_data)));
if (new_data == nullptr) {
return Local<String>();
}
memcpy(new_data, data, length * sizeof(*new_data));
if (length == 0)
return scope.Escape(String::Empty(isolate));

return scope.Escape(ExternString<ResourceType, TypeName>::New(isolate,
new_data,
length));
TypeName* new_data =
static_cast<TypeName*>(malloc(length * sizeof(*new_data)));
if (new_data == nullptr) {
return Local<String>();
}
memcpy(new_data, data, length * sizeof(*new_data));

// uses "data" for external resource, and will be free'd on gc
static Local<String> New(Isolate* isolate,
const TypeName* data,
size_t length) {
EscapableHandleScope scope(isolate);
return scope.Escape(ExternString<ResourceType, TypeName>::New(isolate,
new_data,
length));
}

if (length == 0)
return scope.Escape(String::Empty(isolate));
// uses "data" for external resource, and will be free'd on gc
static Local<String> New(Isolate* isolate,
const TypeName* data,
size_t length) {
EscapableHandleScope scope(isolate);

ExternString* h_str = new ExternString<ResourceType, TypeName>(isolate,
data,
length);
MaybeLocal<String> str = NewExternal(isolate, h_str);
isolate->AdjustAmountOfExternalAllocatedMemory(h_str->byte_length());
if (length == 0)
return scope.Escape(String::Empty(isolate));

if (str.IsEmpty()) {
delete h_str;
return Local<String>();
}
ExternString* h_str = new ExternString<ResourceType, TypeName>(isolate,
data,
length);
MaybeLocal<String> str = NewExternal(isolate, h_str);
isolate->AdjustAmountOfExternalAllocatedMemory(h_str->byte_length());

return scope.Escape(str.ToLocalChecked());
if (str.IsEmpty()) {
delete h_str;
return Local<String>();
}

inline Isolate* isolate() const { return isolate_; }
return scope.Escape(str.ToLocalChecked());
}

inline Isolate* isolate() const { return isolate_; }

private:
ExternString(Isolate* isolate, const TypeName* data, size_t length)
: isolate_(isolate), data_(data), length_(length) { }
static MaybeLocal<String> NewExternal(Isolate* isolate,
ExternString* h_str);
private:
ExternString(Isolate* isolate, const TypeName* data, size_t length)
: isolate_(isolate), data_(data), length_(length) { }
static MaybeLocal<String> NewExternal(Isolate* isolate,
ExternString* h_str);

Isolate* isolate_;
const TypeName* data_;
size_t length_;
Isolate* isolate_;
const TypeName* data_;
size_t length_;
};


Expand Down
Loading

0 comments on commit 3fa643b

Please sign in to comment.