| Index: runtime/lib/bool.cc
|
| ===================================================================
|
| --- runtime/lib/bool.cc (revision 0)
|
| +++ runtime/lib/bool.cc (revision 0)
|
| @@ -0,0 +1,33 @@
|
| +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
| +// 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 "vm/bootstrap_natives.h"
|
| +
|
| +#include "include/dart_api.h"
|
| +#include "vm/dart_api_impl.h"
|
| +#include "vm/isolate.h"
|
| +#include "vm/native_entry.h"
|
| +#include "vm/object.h"
|
| +
|
| +namespace dart {
|
| +
|
| +DEFINE_NATIVE_ENTRY(Boolean_fromEnvironment, 3) {
|
| + GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(1));
|
| + GET_NATIVE_ARGUMENT(Integer, default_value, arguments->NativeArgAt(2));
|
| + // Call the embedder to supply us with the environment.
|
| + Dart_EnvironmentCallback callback = isolate->environment_callback();
|
| + if (callback != NULL) {
|
| + Dart_Handle result = callback(kBoolEnvironment,
|
| + Api::NewHandle(isolate, name.raw()));
|
| + if (!Dart_IsError(result)) {
|
| + const Object& value = Object::Handle(isolate, Api::UnwrapHandle(result));
|
| + if (value.IsBool()) {
|
| + return value.raw();
|
| + }
|
| + }
|
| + }
|
| + return default_value.raw();
|
| +}
|
| +
|
| +} // namespace dart
|
|
|