Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Cleans up incorrect indentation

  • Loading branch information...
commit 34d927771e1baed100bb24497ea92b75c65d94f0 1 parent 314ab6c
@c4milo c4milo authored
Showing with 215 additions and 214 deletions.
  1. +59 −59 cpu_profiler.cc
  2. +16 −16 cpu_profiler.h
  3. +125 −124 heap_profiler.cc
  4. +15 −15 heap_profiler.h
View
118 cpu_profiler.cc
@@ -2,74 +2,74 @@
#include "profile.h"
namespace nodex {
- Persistent<ObjectTemplate> CpuProfiler::cpu_profiler_template_;
+ Persistent<ObjectTemplate> CpuProfiler::cpu_profiler_template_;
- void CpuProfiler::Initialize(Handle<Object> target) {
- HandleScope scope;
+ void CpuProfiler::Initialize(Handle<Object> target) {
+ HandleScope scope;
- cpu_profiler_template_ = Persistent<ObjectTemplate>::New(ObjectTemplate::New());
- cpu_profiler_template_->SetInternalFieldCount(1);
+ cpu_profiler_template_ = Persistent<ObjectTemplate>::New(ObjectTemplate::New());
+ cpu_profiler_template_->SetInternalFieldCount(1);
- Local<Object> cpuProfilerObj = cpu_profiler_template_->NewInstance();
+ Local<Object> cpuProfilerObj = cpu_profiler_template_->NewInstance();
- NODE_SET_METHOD(cpuProfilerObj, "getProfilesCount", CpuProfiler::GetProfilesCount);
- NODE_SET_METHOD(cpuProfilerObj, "getProfile", CpuProfiler::GetProfile);
- NODE_SET_METHOD(cpuProfilerObj, "findProfile", CpuProfiler::FindProfile);
- NODE_SET_METHOD(cpuProfilerObj, "startProfiling", CpuProfiler::StartProfiling);
- NODE_SET_METHOD(cpuProfilerObj, "stopProfiling", CpuProfiler::StopProfiling);
- NODE_SET_METHOD(cpuProfilerObj, "deleteAllProfiles", CpuProfiler::DeleteAllProfiles);
+ NODE_SET_METHOD(cpuProfilerObj, "getProfilesCount", CpuProfiler::GetProfilesCount);
+ NODE_SET_METHOD(cpuProfilerObj, "getProfile", CpuProfiler::GetProfile);
+ NODE_SET_METHOD(cpuProfilerObj, "findProfile", CpuProfiler::FindProfile);
+ NODE_SET_METHOD(cpuProfilerObj, "startProfiling", CpuProfiler::StartProfiling);
+ NODE_SET_METHOD(cpuProfilerObj, "stopProfiling", CpuProfiler::StopProfiling);
+ NODE_SET_METHOD(cpuProfilerObj, "deleteAllProfiles", CpuProfiler::DeleteAllProfiles);
- target->Set(String::NewSymbol("cpuProfiler"), cpuProfilerObj);
- }
+ target->Set(String::NewSymbol("cpuProfiler"), cpuProfilerObj);
+ }
- CpuProfiler::CpuProfiler() {}
- CpuProfiler::~CpuProfiler() {}
+ CpuProfiler::CpuProfiler() {}
+ CpuProfiler::~CpuProfiler() {}
- Handle<Value> CpuProfiler::GetProfilesCount(const Arguments& args) {
- HandleScope scope;
- return scope.Close(Integer::New(v8::CpuProfiler::GetProfilesCount()));
- }
+ Handle<Value> CpuProfiler::GetProfilesCount(const Arguments& args) {
+ HandleScope scope;
+ return scope.Close(Integer::New(v8::CpuProfiler::GetProfilesCount()));
+ }
- Handle<Value> CpuProfiler::GetProfile(const Arguments& args) {
- HandleScope scope;
- if (args.Length() < 1) {
- return ThrowException(Exception::Error(String::New("No index specified")));
- } else if (!args[0]->IsInt32()) {
- return ThrowException(Exception::TypeError(String::New("Argument must be an integer")));
- }
- int32_t index = args[0]->Int32Value();
- const CpuProfile* profile = v8::CpuProfiler::GetProfile(index);
- return scope.Close(Profile::New(profile));
- }
+ Handle<Value> CpuProfiler::GetProfile(const Arguments& args) {
+ HandleScope scope;
+ if (args.Length() < 1) {
+ return ThrowException(Exception::Error(String::New("No index specified")));
+ } else if (!args[0]->IsInt32()) {
+ return ThrowException(Exception::TypeError(String::New("Argument must be an integer")));
+ }
+ int32_t index = args[0]->Int32Value();
+ const CpuProfile* profile = v8::CpuProfiler::GetProfile(index);
+ return scope.Close(Profile::New(profile));
+ }
- Handle<Value> CpuProfiler::FindProfile(const Arguments& args) {
- HandleScope scope;
- if (args.Length() < 1) {
- return ThrowException(Exception::Error(String::New("No index specified")));
- } else if (!args[0]->IsInt32()) {
- return ThrowException(Exception::TypeError(String::New("Argument must be an integer")));
- }
- uint32_t uid = args[0]->Uint32Value();
- const CpuProfile* profile = v8::CpuProfiler::FindProfile(uid);
- return scope.Close(Profile::New(profile));
- }
+ Handle<Value> CpuProfiler::FindProfile(const Arguments& args) {
+ HandleScope scope;
+ if (args.Length() < 1) {
+ return ThrowException(Exception::Error(String::New("No index specified")));
+ } else if (!args[0]->IsInt32()) {
+ return ThrowException(Exception::TypeError(String::New("Argument must be an integer")));
+ }
+ uint32_t uid = args[0]->Uint32Value();
+ const CpuProfile* profile = v8::CpuProfiler::FindProfile(uid);
+ return scope.Close(Profile::New(profile));
+ }
- Handle<Value> CpuProfiler::StartProfiling(const Arguments& args) {
- HandleScope scope;
- Local<String> title = args.Length() > 0 ? args[0]->ToString() : String::New("");
- v8::CpuProfiler::StartProfiling(title);
- return Undefined();
- }
+ Handle<Value> CpuProfiler::StartProfiling(const Arguments& args) {
+ HandleScope scope;
+ Local<String> title = args.Length() > 0 ? args[0]->ToString() : String::New("");
+ v8::CpuProfiler::StartProfiling(title);
+ return Undefined();
+ }
- Handle<Value> CpuProfiler::StopProfiling(const Arguments& args) {
- HandleScope scope;
- Local<String> title = args.Length() > 0 ? args[0]->ToString() : String::New("");
- const CpuProfile* profile = v8::CpuProfiler::StopProfiling(title);
- return scope.Close(Profile::New(profile));
- }
+ Handle<Value> CpuProfiler::StopProfiling(const Arguments& args) {
+ HandleScope scope;
+ Local<String> title = args.Length() > 0 ? args[0]->ToString() : String::New("");
+ const CpuProfile* profile = v8::CpuProfiler::StopProfiling(title);
+ return scope.Close(Profile::New(profile));
+ }
- Handle<Value> CpuProfiler::DeleteAllProfiles(const Arguments& args) {
- v8::CpuProfiler::DeleteAllProfiles();
- return Undefined();
- }
-} //namespace nodex
+ Handle<Value> CpuProfiler::DeleteAllProfiles(const Arguments& args) {
+ v8::CpuProfiler::DeleteAllProfiles();
+ return Undefined();
+ }
+} //namespace nodex
View
32 cpu_profiler.h
@@ -8,24 +8,24 @@ using namespace v8;
using namespace node;
namespace nodex {
- class CpuProfiler {
- public:
- static void Initialize(Handle<Object> target);
+ class CpuProfiler {
+ public:
+ static void Initialize(Handle<Object> target);
- CpuProfiler();
- virtual ~CpuProfiler();
+ CpuProfiler();
+ virtual ~CpuProfiler();
- protected:
- static Handle<Value> GetProfilesCount(const Arguments& args);
- static Handle<Value> GetProfile(const Arguments& args);
- static Handle<Value> FindProfile(const Arguments& args);
- static Handle<Value> StartProfiling(const Arguments& args);
- static Handle<Value> StopProfiling(const Arguments& args);
- static Handle<Value> DeleteAllProfiles(const Arguments& args);
+ protected:
+ static Handle<Value> GetProfilesCount(const Arguments& args);
+ static Handle<Value> GetProfile(const Arguments& args);
+ static Handle<Value> FindProfile(const Arguments& args);
+ static Handle<Value> StartProfiling(const Arguments& args);
+ static Handle<Value> StopProfiling(const Arguments& args);
+ static Handle<Value> DeleteAllProfiles(const Arguments& args);
- private:
- static Persistent<ObjectTemplate> cpu_profiler_template_;
- };
+ private:
+ static Persistent<ObjectTemplate> cpu_profiler_template_;
+ };
} //namespace nodex
-#endif // NODE_CPU_PROFILER_H
+#endif // NODE_CPU_PROFILER_H
View
249 heap_profiler.cc
@@ -2,127 +2,128 @@
#include "snapshot.h"
namespace nodex {
- Persistent<ObjectTemplate> HeapProfiler::heap_profiler_template_;
-
- class ActivityControlAdapter : public v8::ActivityControl {
- public:
- ActivityControlAdapter(Handle<Value> progress)
- : reportProgress(Handle<Function>::Cast(progress)), abort(Local<Value>::New(Boolean::New(false))) {}
-
- ControlOption ReportProgressValue(int done, int total) {
- HandleScope scope;
-
- Local<Value> argv[2] = {
- Integer::New(done),
- Integer::New(total)
- };
-
- TryCatch try_catch;
-
- abort = reportProgress->Call(Context::GetCurrent()->Global(), 2, argv);
-
- if (try_catch.HasCaught()) {
- FatalException(try_catch);
- return kAbort;
- }
-
- fprintf(stderr, "here!\n");
-
- if (abort.IsEmpty() || !abort->IsBoolean()) {
- return kContinue;
- }
-
- return abort->IsTrue() ? kAbort : kContinue;
- }
-
- private:
- Local<Value> abort;
- Handle<Function> reportProgress;
- };
-
- void HeapProfiler::Initialize(Handle<Object> target) {
- HandleScope scope;
-
- heap_profiler_template_ = Persistent<ObjectTemplate>::New(ObjectTemplate::New());
- heap_profiler_template_->SetInternalFieldCount(1);
-
- Local<Object> heapProfilerObj = heap_profiler_template_->NewInstance();
-
- NODE_SET_METHOD(heapProfilerObj, "takeSnapshot", HeapProfiler::TakeSnapshot);
- NODE_SET_METHOD(heapProfilerObj, "getSnapshot", HeapProfiler::GetSnapshot);
- NODE_SET_METHOD(heapProfilerObj, "findSnapshot", HeapProfiler::FindSnapshot);
- NODE_SET_METHOD(heapProfilerObj, "getSnapshotsCount", HeapProfiler::GetSnapshotsCount);
- NODE_SET_METHOD(heapProfilerObj, "deleteAllSnapshots", HeapProfiler::DeleteAllSnapshots);
-
- target->Set(String::NewSymbol("heapProfiler"), heapProfilerObj);
- }
-
- HeapProfiler::HeapProfiler() {}
- HeapProfiler::~HeapProfiler() {}
-
- Handle<Value> HeapProfiler::GetSnapshotsCount(const Arguments& args) {
- HandleScope scope;
- return scope.Close(Integer::New(v8::HeapProfiler::GetSnapshotsCount()));
- }
-
- Handle<Value> HeapProfiler::GetSnapshot(const Arguments& args) {
- HandleScope scope;
- if (args.Length() < 1) {
- return ThrowException(Exception::Error(String::New("No index specified")));
- } else if (!args[0]->IsInt32()) {
- return ThrowException(Exception::TypeError(String::New("Argument must be an integer")));
- }
- int32_t index = args[0]->Int32Value();
- const v8::HeapSnapshot* snapshot = v8::HeapProfiler::GetSnapshot(index);
-
- return scope.Close(Snapshot::New(snapshot));
- }
-
- Handle<Value> HeapProfiler::FindSnapshot(const Arguments& args) {
- HandleScope scope;
- if (args.Length() < 1) {
- return ThrowException(Exception::Error(String::New("No uid specified")));
- }
-
- uint32_t uid = args[0]->Uint32Value();
- const v8::HeapSnapshot* snapshot = v8::HeapProfiler::FindSnapshot(uid);
-
- return scope.Close(Snapshot::New(snapshot));
- }
-
- Handle<Value> HeapProfiler::TakeSnapshot(const Arguments& args) {
- HandleScope scope;
- Local<String> title = String::New("");
- uint32_t len = args.Length();
-
- ActivityControlAdapter *control = NULL;
-
- if (len == 1) {
- if (args[0]->IsString()) {
- title = args[0]->ToString();
- } else if (args[0]->IsFunction()) {
- //control = new ActivityControlAdapter(args[0]);
- }
- }
-
- if (len == 2) {
- if (args[0]->IsString()) {
- title = args[0]->ToString();
- }
-
- if (args[1]->IsFunction()) {
- //control = new ActivityControlAdapter(args[1]);
- }
- }
-
- const v8::HeapSnapshot* snapshot = v8::HeapProfiler::TakeSnapshot(title, HeapSnapshot::kFull, control);
-
- return scope.Close(Snapshot::New(snapshot));
- }
-
- Handle<Value> HeapProfiler::DeleteAllSnapshots(const Arguments& args) {
- HandleScope scope;
- v8::HeapProfiler::DeleteAllSnapshots();
- return Undefined();
- }
-} //namespace nodex
+ Persistent<ObjectTemplate> HeapProfiler::heap_profiler_template_;
+
+ class ActivityControlAdapter : public v8::ActivityControl {
+ public:
+ ActivityControlAdapter(Handle<Value> progress)
+ : reportProgress(Handle<Function>::Cast(progress)),
+ abort(Local<Value>::New(Boolean::New(false))) {}
+
+ ControlOption ReportProgressValue(int done, int total) {
+ HandleScope scope;
+
+ Local<Value> argv[2] = {
+ Integer::New(done),
+ Integer::New(total)
+ };
+
+ TryCatch try_catch;
+
+ abort = reportProgress->Call(Context::GetCurrent()->Global(), 2, argv);
+
+ if (try_catch.HasCaught()) {
+ FatalException(try_catch);
+ return kAbort;
+ }
+
+ fprintf(stderr, "here!\n");
+
+ if (abort.IsEmpty() || !abort->IsBoolean()) {
+ return kContinue;
+ }
+
+ return abort->IsTrue() ? kAbort : kContinue;
+ }
+
+ private:
+ Local<Value> abort;
+ Handle<Function> reportProgress;
+ };
+
+ void HeapProfiler::Initialize(Handle<Object> target) {
+ HandleScope scope;
+
+ heap_profiler_template_ = Persistent<ObjectTemplate>::New(ObjectTemplate::New());
+ heap_profiler_template_->SetInternalFieldCount(1);
+
+ Local<Object> heapProfilerObj = heap_profiler_template_->NewInstance();
+
+ NODE_SET_METHOD(heapProfilerObj, "takeSnapshot", HeapProfiler::TakeSnapshot);
+ NODE_SET_METHOD(heapProfilerObj, "getSnapshot", HeapProfiler::GetSnapshot);
+ NODE_SET_METHOD(heapProfilerObj, "findSnapshot", HeapProfiler::FindSnapshot);
+ NODE_SET_METHOD(heapProfilerObj, "getSnapshotsCount", HeapProfiler::GetSnapshotsCount);
+ NODE_SET_METHOD(heapProfilerObj, "deleteAllSnapshots", HeapProfiler::DeleteAllSnapshots);
+
+ target->Set(String::NewSymbol("heapProfiler"), heapProfilerObj);
+ }
+
+ HeapProfiler::HeapProfiler() {}
+ HeapProfiler::~HeapProfiler() {}
+
+ Handle<Value> HeapProfiler::GetSnapshotsCount(const Arguments& args) {
+ HandleScope scope;
+ return scope.Close(Integer::New(v8::HeapProfiler::GetSnapshotsCount()));
+ }
+
+ Handle<Value> HeapProfiler::GetSnapshot(const Arguments& args) {
+ HandleScope scope;
+ if (args.Length() < 1) {
+ return ThrowException(Exception::Error(String::New("No index specified")));
+ } else if (!args[0]->IsInt32()) {
+ return ThrowException(Exception::TypeError(String::New("Argument must be an integer")));
+ }
+ int32_t index = args[0]->Int32Value();
+ const v8::HeapSnapshot* snapshot = v8::HeapProfiler::GetSnapshot(index);
+
+ return scope.Close(Snapshot::New(snapshot));
+ }
+
+ Handle<Value> HeapProfiler::FindSnapshot(const Arguments& args) {
+ HandleScope scope;
+ if (args.Length() < 1) {
+ return ThrowException(Exception::Error(String::New("No uid specified")));
+ }
+
+ uint32_t uid = args[0]->Uint32Value();
+ const v8::HeapSnapshot* snapshot = v8::HeapProfiler::FindSnapshot(uid);
+
+ return scope.Close(Snapshot::New(snapshot));
+ }
+
+ Handle<Value> HeapProfiler::TakeSnapshot(const Arguments& args) {
+ HandleScope scope;
+ Local<String> title = String::New("");
+ uint32_t len = args.Length();
+
+ ActivityControlAdapter *control = NULL;
+
+ if (len == 1) {
+ if (args[0]->IsString()) {
+ title = args[0]->ToString();
+ } else if (args[0]->IsFunction()) {
+ //control = new ActivityControlAdapter(args[0]);
+ }
+ }
+
+ if (len == 2) {
+ if (args[0]->IsString()) {
+ title = args[0]->ToString();
+ }
+
+ if (args[1]->IsFunction()) {
+ //control = new ActivityControlAdapter(args[1]);
+ }
+ }
+
+ const v8::HeapSnapshot* snapshot = v8::HeapProfiler::TakeSnapshot(title, HeapSnapshot::kFull, control);
+
+ return scope.Close(Snapshot::New(snapshot));
+ }
+
+ Handle<Value> HeapProfiler::DeleteAllSnapshots(const Arguments& args) {
+ HandleScope scope;
+ v8::HeapProfiler::DeleteAllSnapshots();
+ return Undefined();
+ }
+} //namespace nodex
View
30 heap_profiler.h
@@ -8,23 +8,23 @@ using namespace v8;
using namespace node;
namespace nodex {
- class HeapProfiler {
- public:
- static void Initialize(Handle<Object> target);
+ class HeapProfiler {
+ public:
+ static void Initialize(Handle<Object> target);
- HeapProfiler();
- virtual ~HeapProfiler();
+ HeapProfiler();
+ virtual ~HeapProfiler();
- protected:
- static Handle<Value> GetSnapshotsCount(const Arguments& args);
- static Handle<Value> GetSnapshot(const Arguments& args);
- static Handle<Value> FindSnapshot(const Arguments& args);
- static Handle<Value> TakeSnapshot(const Arguments& args);
- static Handle<Value> DeleteAllSnapshots(const Arguments& args);
+ protected:
+ static Handle<Value> GetSnapshotsCount(const Arguments& args);
+ static Handle<Value> GetSnapshot(const Arguments& args);
+ static Handle<Value> FindSnapshot(const Arguments& args);
+ static Handle<Value> TakeSnapshot(const Arguments& args);
+ static Handle<Value> DeleteAllSnapshots(const Arguments& args);
- private:
- static Persistent<ObjectTemplate> heap_profiler_template_;
- };
+ private:
+ static Persistent<ObjectTemplate> heap_profiler_template_;
+ };
} //namespace nodex
-#endif // NODE_HEAP_PROFILER_H
+#endif // NODE_HEAP_PROFILER_H
Please sign in to comment.
Something went wrong with that request. Please try again.