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

Side by Side Diff: lib/object.cc

Issue 10874072: Use the return value of vm native methods to set the return value, (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 3 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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/bootstrap_natives.h" 5 #include "vm/bootstrap_natives.h"
6 6
7 #include "vm/exceptions.h" 7 #include "vm/exceptions.h"
8 #include "vm/native_entry.h" 8 #include "vm/native_entry.h"
9 #include "vm/object.h" 9 #include "vm/object.h"
10 10
11 namespace dart { 11 namespace dart {
12 12
13 DEFINE_NATIVE_ENTRY(Object_toString, 1) { 13 DEFINE_NATIVE_ENTRY(Object_toString, 1) {
14 const Instance& instance = Instance::CheckedHandle(arguments->At(0)); 14 const Instance& instance = Instance::CheckedHandle(arguments->At(0));
15 const char* c_str = instance.ToCString(); 15 const char* c_str = instance.ToCString();
16 arguments->SetReturn(String::Handle(String::New(c_str))); 16 return String::New(c_str);
17 } 17 }
18 18
19 19
20 DEFINE_NATIVE_ENTRY(Object_noSuchMethod, 3) { 20 DEFINE_NATIVE_ENTRY(Object_noSuchMethod, 3) {
21 const Instance& instance = Instance::CheckedHandle(arguments->At(0)); 21 const Instance& instance = Instance::CheckedHandle(arguments->At(0));
22 GET_NATIVE_ARGUMENT(String, function_name, arguments->At(1)); 22 GET_NATIVE_ARGUMENT(String, function_name, arguments->At(1));
23 GET_NATIVE_ARGUMENT(Array, func_args, arguments->At(2)); 23 GET_NATIVE_ARGUMENT(Array, func_args, arguments->At(2));
24 if (instance.IsNull()) { 24 if (instance.IsNull()) {
25 GrowableArray<const Object*> args; 25 GrowableArray<const Object*> args;
26 args.Add(&function_name); 26 args.Add(&function_name);
(...skipping 19 matching lines...) Expand all
46 const int total_num_parameters = 46 const int total_num_parameters =
47 function.num_fixed_parameters() + function.num_optional_parameters(); 47 function.num_fixed_parameters() + function.num_optional_parameters();
48 const Array& array = Array::Handle(Array::New(total_num_parameters - 1)); 48 const Array& array = Array::Handle(Array::New(total_num_parameters - 1));
49 // Skip receiver. 49 // Skip receiver.
50 for (int i = 1; i < total_num_parameters; i++) { 50 for (int i = 1; i < total_num_parameters; i++) {
51 array.SetAt(i - 1, String::Handle(function.ParameterNameAt(i))); 51 array.SetAt(i - 1, String::Handle(function.ParameterNameAt(i)));
52 } 52 }
53 dart_arguments.Add(&array); 53 dart_arguments.Add(&array);
54 } 54 }
55 Exceptions::ThrowByType(Exceptions::kNoSuchMethod, dart_arguments); 55 Exceptions::ThrowByType(Exceptions::kNoSuchMethod, dart_arguments);
56 return Object::null();
56 } 57 }
57 58
58 } // namespace dart 59 } // namespace dart
OLDNEW
« no previous file with comments | « lib/mirrors.cc ('k') | lib/regexp.cc » ('j') | vm/bootstrap_natives.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698