Chromium Code Reviews| Index: runtime/bin/main.cc |
| =================================================================== |
| --- runtime/bin/main.cc (revision 27984) |
| +++ runtime/bin/main.cc (working copy) |
| @@ -414,6 +414,34 @@ |
| } \ |
| +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) { |
| + result = Dart_NewStringFromUTF8(reinterpret_cast<const uint8_t*>(value), |
| + strlen(value)); |
| + } else if (type == kIntegerConfig) { |
| + UNIMPLEMENTED(); |
| + } else if (type == kBoolConfig) { |
| + UNIMPLEMENTED(); |
|
bakster
2013/09/27 07:44:39
Why not implement int and bool when you are at it?
Ivan Posva
2013/09/27 21:05:06
Because I wanted to get feedback on the initial ap
|
| + } |
| + } |
| + } |
| + return result; |
| +} |
| + |
| + |
| // Returns true on success, false on failure. |
| static Dart_Isolate CreateIsolateAndSetupHelper(const char* script_uri, |
| const char* main, |
| @@ -438,6 +466,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. |