Fix fromEnvironment when called from isolates.

BUG=
R=sgjesse@google.com

Review URL: https://codereview.chromium.org//180243022

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@33363 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
ajohnsen@google.com
2014-03-06 09:16:41 +00:00
parent 74bb4aa334
commit c3dfdbe772
8 changed files with 51 additions and 18 deletions
+1
View File
@@ -21,6 +21,7 @@ DEFINE_NATIVE_ENTRY(Bool_fromEnvironment, 3) {
GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(1));
GET_NATIVE_ARGUMENT(Bool, default_value, arguments->NativeArgAt(2));
// Call the embedder to supply us with the environment.
Api::Scope api_scope(isolate);
Dart_EnvironmentCallback callback = isolate->environment_callback();
if (callback != NULL) {
Dart_Handle result = callback(Api::NewHandle(isolate, name.raw()));
+1
View File
@@ -239,6 +239,7 @@ DEFINE_NATIVE_ENTRY(Integer_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.
Api::Scope api_scope(isolate);
Dart_EnvironmentCallback callback = isolate->environment_callback();
if (callback != NULL) {
Dart_Handle response = callback(Api::NewHandle(isolate, name.raw()));
+1
View File
@@ -19,6 +19,7 @@ DEFINE_NATIVE_ENTRY(String_fromEnvironment, 3) {
GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(1));
GET_NATIVE_ARGUMENT(String, default_value, arguments->NativeArgAt(2));
// Call the embedder to supply us with the environment.
Api::Scope api_scope();
Dart_EnvironmentCallback callback = isolate->environment_callback();
if (callback != NULL) {
Dart_Handle result = callback(Api::NewHandle(isolate, name.raw()));
+14
View File
@@ -109,6 +109,20 @@ const char* CanonicalFunction(const char* func);
class Api : AllStatic {
public:
// Create on the stack to provide a new throw-safe api scope.
class Scope : public StackResource {
public:
explicit Scope(Isolate* isolate) : StackResource(isolate) {
Dart_EnterScope();
}
~Scope() {
Dart_ExitScope();
}
private:
DISALLOW_COPY_AND_ASSIGN(Scope);
};
// Creates a new local handle.
static Dart_Handle NewHandle(Isolate* isolate, RawObject* raw);
+1 -15
View File
@@ -4855,20 +4855,6 @@ void Parser::ParseTopLevelAccessor(TopLevel* top_level,
}
class DartApiScope : public StackResource {
public:
explicit DartApiScope(Isolate* isolate) : StackResource(isolate) {
Dart_EnterScope();
}
~DartApiScope() {
Dart_ExitScope();
}
private:
DISALLOW_COPY_AND_ASSIGN(DartApiScope);
};
RawObject* Parser::CallLibraryTagHandler(Dart_LibraryTag tag,
intptr_t token_pos,
const String& url) {
@@ -4885,7 +4871,7 @@ RawObject* Parser::CallLibraryTagHandler(Dart_LibraryTag tag,
// Block class finalization attempts when calling into the library
// tag handler.
isolate()->BlockClassFinalization();
DartApiScope api_scope(isolate());
Api::Scope api_scope(isolate());
Dart_Handle result = handler(tag,
Api::NewHandle(isolate(), library_.raw()),
Api::NewHandle(isolate(), url.raw()));
@@ -2,11 +2,21 @@
// 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.
import "dart:isolate";
import "package:expect/expect.dart";
main() {
void test(port) {
Expect.isFalse(const bool.fromEnvironment('NOT_FOUND'));
Expect.isTrue(const bool.fromEnvironment('NOT_FOUND', defaultValue: true));
Expect.isFalse(const bool.fromEnvironment('NOT_FOUND', defaultValue: false));
Expect.isNull(const bool.fromEnvironment('NOT_FOUND', defaultValue: null));
if (port != null) port.send(null);
}
main() {
test(null);
var port = new ReceivePort();
Isolate.spawn(test, port.sendPort);
port.listen((_) => port.close());
}
@@ -2,10 +2,20 @@
// 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.
import "dart:isolate";
import "package:expect/expect.dart";
main() {
void test(port) {
Expect.isNull(const int.fromEnvironment('NOT_FOUND'));
Expect.equals(12345, const int.fromEnvironment('NOT_FOUND',
defaultValue: 12345));
if (port != null) port.send(null);
}
main() {
test(null);
var port = new ReceivePort();
Isolate.spawn(test, port.sendPort);
port.listen((_) => port.close());
}
@@ -2,10 +2,20 @@
// 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.
import "dart:isolate";
import "package:expect/expect.dart";
main() {
void test(port) {
Expect.isNull(const String.fromEnvironment('NOT_FOUND'));
Expect.equals('x',
const String.fromEnvironment('NOT_FOUND', defaultValue: 'x'));
if (port != null) port.send(null);
}
main() {
test(null);
var port = new ReceivePort();
Isolate.spawn(test, port.sendPort);
port.listen((_) => port.close());
}