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/bigint_operations.h" | |
9 #include "vm/dart_entry.h" | |
10 #include "vm/dart_api_impl.h" | |
11 #include "vm/exceptions.h" | |
12 #include "vm/isolate.h" | |
13 #include "vm/native_entry.h" | |
14 #include "vm/object.h" | |
15 #include "vm/object_store.h" | |
16 #include "vm/symbols.h" | |
17 | |
18 namespace dart { | |
19 | |
20 DEFINE_NATIVE_ENTRY(Bool_fromEnvironment, 3) { | |
21 GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(1)); | |
22 GET_NATIVE_ARGUMENT(Bool, default_value, arguments->NativeArgAt(2)); | |
23 // Call the embedder to supply us with the environment. | |
24 Dart_ConfigCallback callback = isolate->config_callback(); | |
25 if (callback != NULL) { | |
26 Dart_Handle result = callback(kBoolConfig, | |
27 Api::NewHandle(isolate, name.raw())); | |
28 if (Dart_IsString(result)) { | |
29 const char *chars; | |
30 Dart_StringToCString(result, &chars); | |
31 return (strcmp("false", chars) != 0) | |
Ivan Posva
2013/10/29 21:42:59
Only "true" is the true value in Dart, you should
Søren Gjesse
2013/10/29 22:44:39
One question here. I was a bit puzzeled about the
Ivan Posva
2013/10/30 05:08:21
I guess it would make the native API simpler and l
Søren Gjesse
2013/10/30 11:44:02
Changed so that only "true" is true.
Changed the
| |
32 ? Bool::True().raw() : Bool::False().raw(); | |
33 } | |
34 } | |
35 if (default_value.IsNull()) { | |
36 Exceptions::ThrowArgumentError( | |
37 String::Handle(String::New("Environment value does not have a value"))); | |
38 } | |
39 return default_value.raw(); | |
40 } | |
41 | |
42 } // namespace dart | |
OLD | NEW |