OLD | NEW |
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 RUNTIME_BIN_UTILS_H_ | 5 #ifndef RUNTIME_BIN_UTILS_H_ |
6 #define RUNTIME_BIN_UTILS_H_ | 6 #define RUNTIME_BIN_UTILS_H_ |
7 | 7 |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 #include <string.h> | 9 #include <string.h> |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 } | 44 } |
45 } | 45 } |
46 | 46 |
47 SubSystem sub_system_; | 47 SubSystem sub_system_; |
48 int code_; | 48 int code_; |
49 char* message_; | 49 char* message_; |
50 | 50 |
51 DISALLOW_COPY_AND_ASSIGN(OSError); | 51 DISALLOW_COPY_AND_ASSIGN(OSError); |
52 }; | 52 }; |
53 | 53 |
54 | |
55 class StringUtils { | 54 class StringUtils { |
56 public: | 55 public: |
57 // The following methods convert the argument if needed. The | 56 // The following methods convert the argument if needed. The |
58 // conversions are only needed on Windows. If the methods returns a | 57 // conversions are only needed on Windows. If the methods returns a |
59 // pointer that is different from the input pointer, the returned | 58 // pointer that is different from the input pointer, the returned |
60 // pointer is allocated with malloc and should be freed using free. | 59 // pointer is allocated with malloc and should be freed using free. |
61 // | 60 // |
62 // If the len argument is passed then that number of characters are | 61 // If the len argument is passed then that number of characters are |
63 // converted. If len is -1, conversion will stop at the first NUL | 62 // converted. If len is -1, conversion will stop at the first NUL |
64 // character. If result_len is not NUL, it is used to set the number | 63 // character. If result_len is not NUL, it is used to set the number |
(...skipping 15 matching lines...) Expand all Loading... |
80 intptr_t* result_len = NULL); | 79 intptr_t* result_len = NULL); |
81 | 80 |
82 // Not all platforms support strndup. | 81 // Not all platforms support strndup. |
83 static char* StrNDup(const char* s, intptr_t n); | 82 static char* StrNDup(const char* s, intptr_t n); |
84 | 83 |
85 private: | 84 private: |
86 DISALLOW_ALLOCATION(); | 85 DISALLOW_ALLOCATION(); |
87 DISALLOW_IMPLICIT_CONSTRUCTORS(StringUtils); | 86 DISALLOW_IMPLICIT_CONSTRUCTORS(StringUtils); |
88 }; | 87 }; |
89 | 88 |
90 | |
91 class ShellUtils { | 89 class ShellUtils { |
92 public: | 90 public: |
93 // Convert all the arguments to UTF8. On Windows, the arguments are | 91 // Convert all the arguments to UTF8. On Windows, the arguments are |
94 // encoded in the current code page and not UTF8. | 92 // encoded in the current code page and not UTF8. |
95 // | 93 // |
96 // Returns true if the arguments are converted. In that case | 94 // Returns true if the arguments are converted. In that case |
97 // each of the arguments need to be deallocated using free. | 95 // each of the arguments need to be deallocated using free. |
98 static bool GetUtf8Argv(int argc, char** argv); | 96 static bool GetUtf8Argv(int argc, char** argv); |
99 | 97 |
100 private: | 98 private: |
101 DISALLOW_ALLOCATION(); | 99 DISALLOW_ALLOCATION(); |
102 DISALLOW_IMPLICIT_CONSTRUCTORS(ShellUtils); | 100 DISALLOW_IMPLICIT_CONSTRUCTORS(ShellUtils); |
103 }; | 101 }; |
104 | 102 |
105 | |
106 class TimerUtils { | 103 class TimerUtils { |
107 public: | 104 public: |
108 static void InitOnce(); | 105 static void InitOnce(); |
109 static int64_t GetCurrentMonotonicMicros(); | 106 static int64_t GetCurrentMonotonicMicros(); |
110 static int64_t GetCurrentMonotonicMillis(); | 107 static int64_t GetCurrentMonotonicMillis(); |
111 static void Sleep(int64_t millis); | 108 static void Sleep(int64_t millis); |
112 | 109 |
113 private: | 110 private: |
114 DISALLOW_ALLOCATION(); | 111 DISALLOW_ALLOCATION(); |
115 DISALLOW_IMPLICIT_CONSTRUCTORS(TimerUtils); | 112 DISALLOW_IMPLICIT_CONSTRUCTORS(TimerUtils); |
116 }; | 113 }; |
117 | 114 |
118 } // namespace bin | 115 } // namespace bin |
119 } // namespace dart | 116 } // namespace dart |
120 | 117 |
121 #endif // RUNTIME_BIN_UTILS_H_ | 118 #endif // RUNTIME_BIN_UTILS_H_ |
OLD | NEW |