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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 8469004: Give up on using va_copy for now and get the build working. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/dart_api_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_impl.cc
===================================================================
--- runtime/vm/dart_api_impl.cc (revision 1416)
+++ runtime/vm/dart_api_impl.cc (working copy)
@@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-#include <stdarg.h>
-
#include "include/dart_api.h"
#include "vm/bigint_operations.h"
@@ -86,12 +84,26 @@
}
+// TODO(turnidge): This clonse Api::Error. I need to use va_copy to
cshapiro 2011/11/11 01:19:30 clones
+// fix this but not sure if it available on all of our builds.
cshapiro 2011/11/11 01:19:30 Is MSVC the only compiler without va_copy? If so,
DART_EXPORT Dart_Handle Dart_Error(const char* format, ...) {
+ Zone zone; // Setup a VM zone as we are creating some handles.
+ HandleScope scope; // Setup a VM handle scope.
+
va_list args;
va_start(args, format);
- Dart_Handle error = Api::VError(format, args);
+ intptr_t len = OS::VSNPrint(NULL, 0, format, args);
va_end(args);
- return error;
+
+ char* buffer = reinterpret_cast<char*>(zone.Allocate(len + 1));
+ va_list args2;
+ va_start(args2, format);
+ OS::VSNPrint(buffer, (len + 1), format, args2);
+ va_end(args2);
+
+ const String& message = String::Handle(String::New(buffer));
+ const Object& obj = Object::Handle(ApiFailure::New(message));
+ return Api::NewLocalHandle(obj);
}
@@ -2046,32 +2058,27 @@
}
-Dart_Handle Api::VError(const char* format, va_list args) {
+Dart_Handle Api::Error(const char* format, ...) {
Zone zone; // Setup a VM zone as we are creating some handles.
HandleScope scope; // Setup a VM handle scope.
- va_list args_copy;
- va_copy(args_copy, args);
- intptr_t len = OS::VSNPrint(NULL, 0, format, args_copy);
- va_end(args_copy);
+ va_list args;
+ va_start(args, format);
+ intptr_t len = OS::VSNPrint(NULL, 0, format, args);
+ va_end(args);
char* buffer = reinterpret_cast<char*>(zone.Allocate(len + 1));
- OS::VSNPrint(buffer, (len + 1), format, args);
+ va_list args2;
+ va_start(args2, format);
+ OS::VSNPrint(buffer, (len + 1), format, args2);
+ va_end(args2);
const String& message = String::Handle(String::New(buffer));
const Object& obj = Object::Handle(ApiFailure::New(message));
return Api::NewLocalHandle(obj);
}
-Dart_Handle Api::Error(const char* format, ...) {
- va_list args;
- va_start(args, format);
- Dart_Handle error = Api::VError(format, args);
- va_end(args);
- return error;
-}
-
Dart_Handle Api::Null() {
Isolate* isolate = Isolate::Current();
ASSERT(isolate != NULL);
« no previous file with comments | « runtime/vm/dart_api_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698