Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(575)

Unified Diff: runtime/bin/main.cc

Issue 24975002: - Implement a first cut for const String.env in the VM to allow (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/include/dart_api.h » ('j') | runtime/lib/integers_patch.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « no previous file | runtime/include/dart_api.h » ('j') | runtime/lib/integers_patch.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698