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

Unified Diff: third_party/pkg/di/lib/reflected_type.dart

Issue 107003007: Adding Angular's DI package & Dart unittests which test it. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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 | « third_party/pkg/di/lib/module.dart ('k') | third_party/pkg/di/lib/static_injector.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/pkg/di/lib/reflected_type.dart
diff --git a/third_party/pkg/di/lib/reflected_type.dart b/third_party/pkg/di/lib/reflected_type.dart
new file mode 100644
index 0000000000000000000000000000000000000000..f58c5f0a94ec0edaee8972d08ce0160ad5ba09ed
--- /dev/null
+++ b/third_party/pkg/di/lib/reflected_type.dart
@@ -0,0 +1,27 @@
+library di.src.reflected_type;
+
+// These are used by _getReflectedTypeWorkaround, see http://dartbug.com/12607
+@MirrorsUsed(targets:
+ const ['_js_helper.createRuntimeType', 'dart._js_mirrors.JsClassMirror'],
+ override: 'di.src.reflected_type')
+import 'dart:mirrors';
+
+// Horrible hack to work around: http://dartbug.com/12607
+Type getReflectedTypeWorkaround(ClassMirror cls) {
+ // On Dart VM, just return reflectedType.
+ if (1.0 is! int) return cls.reflectedType;
+
+ var mangledName = reflect(cls).getField(_mangledNameField).reflectee;
+ Type type = _jsHelper.invoke(#createRuntimeType, [mangledName]).reflectee;
+ return type;
+}
+
+final LibraryMirror _jsHelper =
+ currentMirrorSystem().libraries[Uri.parse('dart:_js_helper')];
+
+final Symbol _mangledNameField = () {
+ var jsClassMirrorMirror = reflect(reflectClass(ClassMirror)).type;
+ for (var name in jsClassMirrorMirror.declarations.keys) {
+ if (MirrorSystem.getName(name) == '_mangledName') return name;
+ }
+}();
« no previous file with comments | « third_party/pkg/di/lib/module.dart ('k') | third_party/pkg/di/lib/static_injector.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698