OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 ALLOW_TRAILING_JUNK = 4 | 89 ALLOW_TRAILING_JUNK = 4 |
90 }; | 90 }; |
91 | 91 |
92 | 92 |
93 // Convert from Number object to C integer. | 93 // Convert from Number object to C integer. |
94 static inline int32_t NumberToInt32(Object* number); | 94 static inline int32_t NumberToInt32(Object* number); |
95 static inline uint32_t NumberToUint32(Object* number); | 95 static inline uint32_t NumberToUint32(Object* number); |
96 | 96 |
97 | 97 |
98 // Converts a string into a double value according to ECMA-262 9.3.1 | 98 // Converts a string into a double value according to ECMA-262 9.3.1 |
| 99 double StringToDouble(String* str, int flags, double empty_string_val = 0); |
| 100 double StringToDouble(Vector<const char> str, |
| 101 int flags, |
| 102 double empty_string_val = 0); |
| 103 // This version expects a zero-terminated character array. |
99 double StringToDouble(const char* str, int flags, double empty_string_val = 0); | 104 double StringToDouble(const char* str, int flags, double empty_string_val = 0); |
100 double StringToDouble(String* str, int flags, double empty_string_val = 0); | |
101 | 105 |
102 // Converts a string into an integer. | 106 // Converts a string into an integer. |
103 double StringToInt(String* str, int radix); | 107 double StringToInt(String* str, int radix); |
104 | 108 |
105 // Converts a double to a string value according to ECMA-262 9.8.1. | 109 // Converts a double to a string value according to ECMA-262 9.8.1. |
106 // The buffer should be large enough for any floating point number. | 110 // The buffer should be large enough for any floating point number. |
107 // 100 characters is enough. | 111 // 100 characters is enough. |
108 const char* DoubleToCString(double value, Vector<char> buffer); | 112 const char* DoubleToCString(double value, Vector<char> buffer); |
109 | 113 |
110 // Convert an int to a null-terminated string. The returned string is | 114 // Convert an int to a null-terminated string. The returned string is |
111 // located inside the buffer, but not necessarily at the start. | 115 // located inside the buffer, but not necessarily at the start. |
112 const char* IntToCString(int n, Vector<char> buffer); | 116 const char* IntToCString(int n, Vector<char> buffer); |
113 | 117 |
114 // Additional number to string conversions for the number type. | 118 // Additional number to string conversions for the number type. |
115 // The caller is responsible for calling free on the returned pointer. | 119 // The caller is responsible for calling free on the returned pointer. |
116 char* DoubleToFixedCString(double value, int f); | 120 char* DoubleToFixedCString(double value, int f); |
117 char* DoubleToExponentialCString(double value, int f); | 121 char* DoubleToExponentialCString(double value, int f); |
118 char* DoubleToPrecisionCString(double value, int f); | 122 char* DoubleToPrecisionCString(double value, int f); |
119 char* DoubleToRadixCString(double value, int radix); | 123 char* DoubleToRadixCString(double value, int radix); |
120 | 124 |
121 } } // namespace v8::internal | 125 } } // namespace v8::internal |
122 | 126 |
123 #endif // V8_CONVERSIONS_H_ | 127 #endif // V8_CONVERSIONS_H_ |
OLD | NEW |