mirror of
https://github.com/dart-lang/sdk
synced 2024-09-20 17:21:20 +00:00
02fe9fabd8
Change-Id: Ic4a4c0e65d9b1a93528533c2c17dc10653d4ee4e Reviewed-on: https://dart-review.googlesource.com/c/84441 Reviewed-by: Ryan Macnak <rmacnak@google.com> Commit-Queue: Zach Anderson <zra@google.com>
49 lines
1.6 KiB
Dart
49 lines
1.6 KiB
Dart
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
|
|
// 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.
|
|
|
|
@pragma("vm:entry-point")
|
|
class _NamespaceImpl extends NativeFieldWrapperClass1 implements _Namespace {
|
|
_NamespaceImpl._();
|
|
|
|
static _NamespaceImpl _create(_NamespaceImpl namespace, var n)
|
|
native "Namespace_Create";
|
|
static int _getPointer(_NamespaceImpl namespace)
|
|
native "Namespace_GetPointer";
|
|
static int _getDefault() native "Namespace_GetDefault";
|
|
|
|
// If the platform supports "namespaces", this method is called by the
|
|
// embedder with the platform-specific namespace information.
|
|
static _NamespaceImpl _cachedNamespace = null;
|
|
static void _setupNamespace(var namespace) {
|
|
_cachedNamespace = _create(new _NamespaceImpl._(), namespace);
|
|
}
|
|
|
|
static _NamespaceImpl get _namespace {
|
|
if (_cachedNamespace == null) {
|
|
// The embedder has not supplied a namespace before one is needed, so
|
|
// instead use a safe-ish default value.
|
|
_cachedNamespace = _create(new _NamespaceImpl._(), _getDefault());
|
|
}
|
|
return _cachedNamespace;
|
|
}
|
|
|
|
static int get _namespacePointer => _getPointer(_namespace);
|
|
}
|
|
|
|
@patch
|
|
@pragma("vm:entry-point")
|
|
class _Namespace {
|
|
@patch
|
|
@pragma("vm:entry-point")
|
|
static void _setupNamespace(var namespace) {
|
|
_NamespaceImpl._setupNamespace(namespace);
|
|
}
|
|
|
|
@patch
|
|
static _Namespace get _namespace => _NamespaceImpl._namespace;
|
|
|
|
@patch
|
|
static int get _namespacePointer => _NamespaceImpl._namespacePointer;
|
|
}
|