OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 class _NamespaceImpl extends NativeFieldWrapperClass1 implements _Namespace { |
| 6 _NamespaceImpl._(); |
| 7 |
| 8 static _NamespaceImpl _create(_NamespaceImpl namespace, var n) |
| 9 native "Namespace_Create"; |
| 10 static int _getPointer(_NamespaceImpl namespace) |
| 11 native "Namespace_GetPointer"; |
| 12 static int _getDefault() native "Namespace_GetDefault"; |
| 13 |
| 14 // If the platform supports "namespaces", this method is called by the |
| 15 // embedder with the platform-specific namespace information. |
| 16 static _NamespaceImpl _cachedNamespace = null; |
| 17 static void _setupNamespace(var namespace) { |
| 18 _cachedNamespace = _create(new _NamespaceImpl._(), namespace); |
| 19 } |
| 20 |
| 21 static _NamespaceImpl get _namespace { |
| 22 if (_cachedNamespace == null) { |
| 23 // The embedder has not supplied a namespace before one is needed, so |
| 24 // instead use a safe-ish default value. |
| 25 _cachedNamespace = _create(new _NamespaceImpl._(), _getDefault()); |
| 26 } |
| 27 return _cachedNamespace; |
| 28 } |
| 29 |
| 30 static int get _namespacePointer => _getPointer(_namespace); |
| 31 } |
| 32 |
| 33 @patch |
| 34 class _Namespace { |
| 35 @patch |
| 36 static void _setupNamespace(var namespace) { |
| 37 _NamespaceImpl._setupNamespace(namespace); |
| 38 } |
| 39 |
| 40 @patch |
| 41 static _Namespace get _namespace => _NamespaceImpl._namespace; |
| 42 |
| 43 @patch |
| 44 static int get _namespacePointer => _NamespaceImpl._namespacePointer; |
| 45 } |
OLD | NEW |