Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: vm/flags.h

Issue 9668034: Fix issue 1950: (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | vm/flags.cc » ('j') | vm/flags.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_FLAGS_H_ 5 #ifndef VM_FLAGS_H_
6 #define VM_FLAGS_H_ 6 #define VM_FLAGS_H_
7 7
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/globals.h" 9 #include "vm/globals.h"
10 10
11 typedef const char* charp; 11 typedef const char* charp;
12 12
13 #define DECLARE_FLAG(type, name) \ 13 #define DECLARE_FLAG(type, name) \
14 extern type FLAG_##name 14 extern type FLAG_##name
15 15
16 #define DEFINE_FLAG(type, name, default_value, comment) \ 16 #define DEFINE_FLAG(type, name, default_value, comment) \
17 type FLAG_##name = Flags::Register_##type(&FLAG_##name, \ 17 type FLAG_##name = Flags::Register_##type(&FLAG_##name, \
18 #name, \ 18 #name, \
19 default_value, \ 19 default_value, \
20 comment) 20 comment)
21 21
22 #define DEFINE_FLAG_HANDLER(handler, name, comment) \
23 bool DUMMY_##name = Flags::Register_func(handler, #name, comment)
24
22 25
23 #if defined(DEBUG) 26 #if defined(DEBUG)
24 #define DECLARE_DEBUG_FLAG(type, name) DECLARE_FLAG(type, name) 27 #define DECLARE_DEBUG_FLAG(type, name) DECLARE_FLAG(type, name)
25 #define DEFINE_DEBUG_FLAG(type, name, default_value, comment) \ 28 #define DEFINE_DEBUG_FLAG(type, name, default_value, comment) \
26 DEFINE_FLAG(type, name, default_value, comment) 29 DEFINE_FLAG(type, name, default_value, comment)
27 #else 30 #else
28 #define DECLARE_DEBUG_FLAG(type, name) 31 #define DECLARE_DEBUG_FLAG(type, name)
29 #define DEFINE_DEBUG_FLAG(type, name, default_value, comment) 32 #define DEFINE_DEBUG_FLAG(type, name, default_value, comment)
30 #endif 33 #endif
31 34
32 namespace dart { 35 namespace dart {
33 36
37 typedef void (*FlagHandler)(bool value);
38
34 // Forward declaration. 39 // Forward declaration.
35 class Flag; 40 class Flag;
36 41
37 class Flags { 42 class Flags {
38 public: 43 public:
39 static bool Register_bool(bool* addr, 44 static bool Register_bool(bool* addr,
40 const char* name, 45 const char* name,
41 bool default_value, 46 bool default_value,
42 const char* comment); 47 const char* comment);
43 48
44 static int Register_int(int* addr, 49 static int Register_int(int* addr,
45 const char* name, 50 const char* name,
46 int default_value, 51 int default_value,
47 const char* comment); 52 const char* comment);
48 53
49 static const char* Register_charp(charp* addr, 54 static const char* Register_charp(charp* addr,
50 const char* name, 55 const char* name,
51 const char* default_value, 56 const char* default_value,
52 const char* comment); 57 const char* comment);
53 58
59 static bool Register_func(FlagHandler handler,
60 const char* name,
61 const char* comment);
62
54 static bool ProcessCommandLineFlags(int argc, const char** argv); 63 static bool ProcessCommandLineFlags(int argc, const char** argv);
55 64
56 static Flag* Lookup(const char* name); 65 static Flag* Lookup(const char* name);
57 66
58 static bool Initialized() { return initialized_; } 67 static bool Initialized() { return initialized_; }
59 68
60 private: 69 private:
61 static Flag* flags_; 70 static Flag* flags_;
62 71
63 static bool initialized_; 72 static bool initialized_;
64 73
65 static void Parse(const char* option); 74 static void Parse(const char* option);
66 75
67 // Testing needs direct access to private methods. 76 // Testing needs direct access to private methods.
68 friend void Dart_TestParseFlags(); 77 friend void Dart_TestParseFlags();
69 78
70 DISALLOW_ALLOCATION(); 79 DISALLOW_ALLOCATION();
71 DISALLOW_IMPLICIT_CONSTRUCTORS(Flags); 80 DISALLOW_IMPLICIT_CONSTRUCTORS(Flags);
72 }; 81 };
73 82
74 } // namespace dart 83 } // namespace dart
75 84
76 #endif // VM_FLAGS_H_ 85 #endif // VM_FLAGS_H_
OLDNEW
« no previous file with comments | « no previous file | vm/flags.cc » ('j') | vm/flags.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698