Chromium Code Reviews| Index: src/d8.h |
| diff --git a/src/d8.h b/src/d8.h |
| index 540c9cac509c2349e45a35c8c7155dd61249ee15..f547b2876affe387bc00f51d72eb7e81a568f0c5 100644 |
| --- a/src/d8.h |
| +++ b/src/d8.h |
| @@ -34,36 +34,41 @@ |
| namespace v8 { |
| - |
| namespace i = v8::internal; |
| - |
| // A single counter in a counter collection. |
| class Counter { |
| - public: |
| +public: |
|
Søren Thygesen Gjesse
2011/06/09 10:05:48
One space indent for public/private/protected (sev
|
| static const int kMaxNameSize = 64; |
| int32_t* Bind(const char* name, bool histogram); |
| - int32_t* ptr() { return &count_; } |
| - int32_t count() { return count_; } |
| - int32_t sample_total() { return sample_total_; } |
| - bool is_histogram() { return is_histogram_; } |
| + int32_t* ptr() { |
|
Søren Thygesen Gjesse
2011/06/09 10:05:48
Why did you re-format all these accessors?
|
| + return &count_; |
| + } |
| + int32_t count() { |
| + return count_; |
| + } |
| + int32_t sample_total() { |
| + return sample_total_; |
| + } |
| + bool is_histogram() { |
| + return is_histogram_; |
| + } |
| void AddSample(int32_t sample); |
| - private: |
| +private: |
| int32_t count_; |
| int32_t sample_total_; |
| bool is_histogram_; |
| uint8_t name_[kMaxNameSize]; |
| }; |
| - |
| // A set of counters and associated information. An instance of this |
| // class is stored directly in the memory-mapped counters file if |
| // the --map-counters options is used |
| class CounterCollection { |
| - public: |
| +public: |
| CounterCollection(); |
| Counter* GetNextCounter(); |
| - private: |
| +private: |
| static const unsigned kMaxCounters = 256; |
| uint32_t magic_number_; |
| uint32_t max_counters_; |
| @@ -72,68 +77,73 @@ class CounterCollection { |
| Counter counters_[kMaxCounters]; |
| }; |
| - |
| class CounterMap { |
| - public: |
| - CounterMap(): hash_map_(Match) { } |
| +public: |
| + CounterMap() : |
|
Søren Thygesen Gjesse
2011/06/09 10:05:48
If you want to format this on several lines the ':
|
| + hash_map_(Match) { |
| + } |
| Counter* Lookup(const char* name) { |
| - i::HashMap::Entry* answer = hash_map_.Lookup( |
| - const_cast<char*>(name), |
| - Hash(name), |
| - false); |
| - if (!answer) return NULL; |
| - return reinterpret_cast<Counter*>(answer->value); |
| + i::HashMap::Entry* answer = hash_map_.Lookup(const_cast<char*> (name), |
| + Hash(name), false); |
| + if (!answer) |
| + return NULL; |
| + return reinterpret_cast<Counter*> (answer->value); |
| } |
| void Set(const char* name, Counter* value) { |
| - i::HashMap::Entry* answer = hash_map_.Lookup( |
| - const_cast<char*>(name), |
| - Hash(name), |
| - true); |
| + i::HashMap::Entry* answer = hash_map_.Lookup(const_cast<char*> (name), |
| + Hash(name), true); |
| ASSERT(answer != NULL); |
| answer->value = value; |
| } |
| class Iterator { |
| - public: |
| - explicit Iterator(CounterMap* map) |
| - : map_(&map->hash_map_), entry_(map_->Start()) { } |
| - void Next() { entry_ = map_->Next(entry_); } |
| - bool More() { return entry_ != NULL; } |
| - const char* CurrentKey() { return static_cast<const char*>(entry_->key); } |
| - Counter* CurrentValue() { return static_cast<Counter*>(entry_->value); } |
| - private: |
| + public: |
| + explicit Iterator(CounterMap* map) : |
| + map_(&map->hash_map_), entry_(map_->Start()) { |
| + } |
| + void Next() { |
| + entry_ = map_->Next(entry_); |
| + } |
| + bool More() { |
| + return entry_ != NULL; |
| + } |
| + const char* CurrentKey() { |
| + return static_cast<const char*> (entry_->key); |
| + } |
| + Counter* CurrentValue() { |
| + return static_cast<Counter*> (entry_->value); |
| + } |
| + private: |
| i::HashMap* map_; |
| i::HashMap::Entry* entry_; |
| }; |
| - private: |
| +private: |
| static int Hash(const char* name); |
| static bool Match(void* key1, void* key2); |
| i::HashMap hash_map_; |
| }; |
| - |
| class Shell: public i::AllStatic { |
| - public: |
| - static bool ExecuteString(Handle<String> source, |
| - Handle<Value> name, |
| - bool print_result, |
| - bool report_exceptions); |
| +public: |
| + static bool ExecuteString(Handle<String> source, Handle<Value> name, |
|
Søren Thygesen Gjesse
2011/06/09 10:05:48
I think you should keep the original formatting of
|
| + bool print_result, bool report_exceptions); |
| static const char* ToCString(const v8::String::Utf8Value& value); |
| static void ReportException(TryCatch* try_catch); |
| - static void Initialize(); |
| static void OnExit(); |
| static int* LookupCounter(const char* name); |
| - static void* CreateHistogram(const char* name, |
| - int min, |
| - int max, |
| - size_t buckets); |
| + static void* CreateHistogram(const char* name, int min, int max, |
| + size_t buckets); |
| static void AddHistogramSample(void* histogram, int sample); |
| static void MapCounters(const char* name); |
| static Handle<String> ReadFile(const char* name); |
| static void RunShell(); |
| + static void RenewEvalContext(); |
| + static void Initialize(); |
| + static void InstallUtilScript(); |
| + static int RunMain(int argc, char* argv[]); |
| static int Main(int argc, char* argv[]); |
| - static Handle<Array> GetCompletions(Handle<String> text, |
| - Handle<String> full); |
| + static Handle<Array> GetCompletions(Handle<String> text, Handle<String> full); |
| + static Handle<ObjectTemplate> CreateGlobalTemplate(); |
| #ifdef ENABLE_DEBUGGER_SUPPORT |
| static Handle<Object> DebugMessageDetails(Handle<String> message); |
| static Handle<Value> DebugCommandToJSONRequest(Handle<String> command); |
| @@ -197,12 +207,14 @@ class Shell: public i::AllStatic { |
| static void AddOSMethods(Handle<ObjectTemplate> os_template); |
| - static Handle<Context> utility_context() { return utility_context_; } |
| + static Handle<Context> utility_context() { |
| + return utility_context_; |
| + } |
| static const char* kHistoryFileName; |
| static const char* kPrompt; |
| - private: |
| +private: |
| static Persistent<Context> utility_context_; |
| static Persistent<Context> evaluation_context_; |
| static CounterMap* counter_map_; |
| @@ -213,34 +225,41 @@ class Shell: public i::AllStatic { |
| static i::OS::MemoryMappedFile* counters_file_; |
| static Counter* GetCounter(const char* name, bool is_histogram); |
| static Handle<Value> CreateExternalArray(const Arguments& args, |
| - ExternalArrayType type, |
| - int element_size); |
| + ExternalArrayType type, int element_size); |
| static void ExternalArrayWeakCallback(Persistent<Value> object, void* data); |
| }; |
| - |
| class LineEditor { |
| - public: |
| - enum Type { DUMB = 0, READLINE = 1 }; |
| +public: |
| + enum Type { |
| + DUMB = 0, READLINE = 1 |
| + }; |
| LineEditor(Type type, const char* name); |
| - virtual ~LineEditor() { } |
| + virtual ~LineEditor() { |
| + } |
| virtual i::SmartPointer<char> Prompt(const char* prompt) = 0; |
| - virtual bool Open() { return true; } |
| - virtual bool Close() { return true; } |
| - virtual void AddHistory(const char* str) { } |
| + virtual bool Open() { |
| + return true; |
| + } |
| + virtual bool Close() { |
| + return true; |
| + } |
| + virtual void AddHistory(const char* str) { |
| + } |
| - const char* name() { return name_; } |
| + const char* name() { |
| + return name_; |
| + } |
| static LineEditor* Get(); |
| - private: |
| +private: |
| Type type_; |
| const char* name_; |
| LineEditor* next_; |
| static LineEditor* first_; |
| }; |
| - |
| -} // namespace v8 |
| +} // namespace v8 |
| #endif // V8_D8_H_ |