Chromium Code Reviews| 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 #include "vm/object.h" | 5 #include "vm/object.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
| 10 #include "vm/bigint_operations.h" | 10 #include "vm/bigint_operations.h" |
| (...skipping 9482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9493 } | 9493 } |
| 9494 ASSERT(str.IsFourByteString()); | 9494 ASSERT(str.IsFourByteString()); |
| 9495 const FourByteString& fourstr = FourByteString::Cast(str); | 9495 const FourByteString& fourstr = FourByteString::Cast(str); |
| 9496 return fourstr.EscapeSpecialCharacters(raw_str); | 9496 return fourstr.EscapeSpecialCharacters(raw_str); |
| 9497 } | 9497 } |
| 9498 | 9498 |
| 9499 | 9499 |
| 9500 RawString* String::NewFormatted(const char* format, ...) { | 9500 RawString* String::NewFormatted(const char* format, ...) { |
| 9501 va_list args; | 9501 va_list args; |
| 9502 va_start(args, format); | 9502 va_start(args, format); |
| 9503 intptr_t len = OS::VSNPrint(NULL, 0, format, args); | 9503 RawString* result = NewFormattedV(format, args); |
| 9504 NoGCScope no_gc; | |
| 9504 va_end(args); | 9505 va_end(args); |
| 9506 return result; | |
| 9507 } | |
| 9508 | |
| 9509 | |
| 9510 RawString* String::NewFormattedV(const char* format, va_list args) { | |
| 9511 va_list args_copy; | |
| 9512 va_copy(args_copy, args); | |
|
hausner
2012/09/11 16:11:14
I am not familiar with va_copy. Is va_start no lon
Ivan Posva
2012/09/11 16:14:39
va_copy creates a copy of the passed in va_list ar
| |
| 9513 intptr_t len = OS::VSNPrint(NULL, 0, format, args_copy); | |
| 9514 va_end(args_copy); | |
| 9505 | 9515 |
| 9506 Zone* zone = Isolate::Current()->current_zone(); | 9516 Zone* zone = Isolate::Current()->current_zone(); |
| 9507 char* buffer = zone->Alloc<char>(len + 1); | 9517 char* buffer = zone->Alloc<char>(len + 1); |
| 9508 va_list args2; | 9518 OS::VSNPrint(buffer, (len + 1), format, args); |
| 9509 va_start(args2, format); | |
| 9510 OS::VSNPrint(buffer, (len + 1), format, args2); | |
| 9511 va_end(args2); | |
| 9512 | 9519 |
| 9513 return String::New(buffer); | 9520 return String::New(buffer); |
| 9514 } | 9521 } |
| 9515 | 9522 |
| 9516 | 9523 |
| 9517 RawString* String::Concat(const String& str1, | 9524 RawString* String::Concat(const String& str1, |
| 9518 const String& str2, | 9525 const String& str2, |
| 9519 Heap::Space space) { | 9526 Heap::Space space) { |
| 9520 ASSERT(!str1.IsNull() && !str2.IsNull()); | 9527 ASSERT(!str1.IsNull() && !str2.IsNull()); |
| 9521 intptr_t char_size = Utils::Maximum(str1.CharSize(), str2.CharSize()); | 9528 intptr_t char_size = Utils::Maximum(str1.CharSize(), str2.CharSize()); |
| (...skipping 1974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11496 } | 11503 } |
| 11497 return result.raw(); | 11504 return result.raw(); |
| 11498 } | 11505 } |
| 11499 | 11506 |
| 11500 | 11507 |
| 11501 const char* WeakProperty::ToCString() const { | 11508 const char* WeakProperty::ToCString() const { |
| 11502 return "_WeakProperty"; | 11509 return "_WeakProperty"; |
| 11503 } | 11510 } |
| 11504 | 11511 |
| 11505 } // namespace dart | 11512 } // namespace dart |
| OLD | NEW |