OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 #include "vm/bootstrap_natives.h" |
| 6 |
| 7 #include "include/dart_api.h" |
| 8 #include "vm/dart_api_impl.h" |
| 9 #include "vm/isolate.h" |
| 10 #include "vm/native_entry.h" |
| 11 #include "vm/object.h" |
| 12 |
| 13 namespace dart { |
| 14 |
| 15 DEFINE_NATIVE_ENTRY(Boolean_fromEnvironment, 3) { |
| 16 GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(1)); |
| 17 GET_NATIVE_ARGUMENT(Integer, default_value, arguments->NativeArgAt(2)); |
| 18 // Call the embedder to supply us with the environment. |
| 19 Dart_EnvironmentCallback callback = isolate->environment_callback(); |
| 20 if (callback != NULL) { |
| 21 Dart_Handle result = callback(kBoolEnvironment, |
| 22 Api::NewHandle(isolate, name.raw())); |
| 23 if (!Dart_IsError(result)) { |
| 24 const Object& value = Object::Handle(isolate, Api::UnwrapHandle(result)); |
| 25 if (value.IsBool()) { |
| 26 return value.raw(); |
| 27 } |
| 28 } |
| 29 } |
| 30 return default_value.raw(); |
| 31 } |
| 32 |
| 33 } // namespace dart |
OLD | NEW |