| Index: runtime/bin/main.cc
|
| ===================================================================
|
| --- runtime/bin/main.cc (revision 28427)
|
| +++ runtime/bin/main.cc (working copy)
|
| @@ -414,6 +414,32 @@
|
| } \
|
|
|
|
|
| +static Dart_Handle ConfigCallback(Dart_ConfigType type, Dart_Handle name) {
|
| + uint8_t* utf8_array;
|
| + intptr_t utf8_len;
|
| + Dart_Handle result = Dart_Null();
|
| + Dart_Handle handle = Dart_StringToUTF8(name, &utf8_array, &utf8_len);
|
| + if (Dart_IsError(handle)) {
|
| + handle = Dart_ThrowException(
|
| + DartUtils::NewDartArgumentError(Dart_GetError(handle)));
|
| + } else {
|
| + char* name_chars = reinterpret_cast<char*>(malloc(utf8_len + 1));
|
| + memmove(name_chars, utf8_array, utf8_len);
|
| + name_chars[utf8_len] = '\0';
|
| + const char* value = getenv(name_chars);
|
| + if (value != NULL) {
|
| + if ((type == kStringConfig) || (type == kIntegerConfig)) {
|
| + result = Dart_NewStringFromUTF8(reinterpret_cast<const uint8_t*>(value),
|
| + strlen(value));
|
| + } else if (type == kBoolConfig) {
|
| + UNIMPLEMENTED();
|
| + }
|
| + }
|
| + }
|
| + return result;
|
| +}
|
| +
|
| +
|
| // Returns true on success, false on failure.
|
| static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri,
|
| const char* main,
|
| @@ -438,6 +464,9 @@
|
| Dart_Handle result = Dart_SetLibraryTagHandler(DartUtils::LibraryTagHandler);
|
| CHECK_RESULT(result);
|
|
|
| + result = Dart_SetConfigCallback(ConfigCallback);
|
| + CHECK_RESULT(result);
|
| +
|
| // Load the specified application script into the newly created isolate.
|
|
|
| // Prepare builtin and its dependent libraries for use to resolve URIs.
|
|
|