Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of polymer; | 5 part of polymer; |
| 6 | 6 |
| 7 /** Annotation used to automatically register polymer elements. */ | 7 /** Annotation used to automatically register polymer elements. */ |
| 8 class CustomTag { | 8 class CustomTag { |
| 9 final String tagName; | 9 final String tagName; |
| 10 const CustomTag(this.tagName); | 10 const CustomTag(this.tagName); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 173 // Search top-level functions marked with @initMethod | 173 // Search top-level functions marked with @initMethod |
| 174 for (var f in lib.declarations.values.where((d) => d is MethodMirror)) { | 174 for (var f in lib.declarations.values.where((d) => d is MethodMirror)) { |
| 175 _maybeInvoke(lib, f); | 175 _maybeInvoke(lib, f); |
| 176 } | 176 } |
| 177 | 177 |
| 178 for (var c in lib.declarations.values.where((d) => d is ClassMirror)) { | 178 for (var c in lib.declarations.values.where((d) => d is ClassMirror)) { |
| 179 // Search for @CustomTag on classes | 179 // Search for @CustomTag on classes |
| 180 for (var m in c.metadata) { | 180 for (var m in c.metadata) { |
| 181 var meta = m.reflectee; | 181 var meta = m.reflectee; |
| 182 if (meta is CustomTag) { | 182 if (meta is CustomTag) { |
| 183 Polymer.register(meta.tagName, getReflectedTypeWorkaround(c)); | 183 Polymer.register(meta.tagName, c.reflectedType); |
|
rmacnak
2013/12/07 02:34:10
Woe to the fool that puts @CustomTag on a generic
Jennifer Messerly
2013/12/09 19:00:50
haha :). yeah, no worries. They could always call
| |
| 184 } | 184 } |
| 185 } | 185 } |
| 186 | 186 |
| 187 // TODO(sigmund): check also static methods marked with @initMethod. | 187 // TODO(sigmund): check also static methods marked with @initMethod. |
| 188 // This is blocked on two bugs: | 188 // This is blocked on two bugs: |
| 189 // - dartbug.com/12133 (static methods are incorrectly listed as top-level | 189 // - dartbug.com/12133 (static methods are incorrectly listed as top-level |
| 190 // in dart2js, so they end up being called twice) | 190 // in dart2js, so they end up being called twice) |
| 191 // - dartbug.com/12134 (sometimes "method.metadata" throws an exception, | 191 // - dartbug.com/12134 (sometimes "method.metadata" throws an exception, |
| 192 // we could wrap and hide those exceptions, but it's not ideal). | 192 // we could wrap and hide those exceptions, but it's not ideal). |
| 193 } | 193 } |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 211 print("warning: methods marked with @initMethod should take no " | 211 print("warning: methods marked with @initMethod should take no " |
| 212 "arguments, ${method.simpleName} expects some."); | 212 "arguments, ${method.simpleName} expects some."); |
| 213 return; | 213 return; |
| 214 } | 214 } |
| 215 obj.invoke(method.simpleName, const []); | 215 obj.invoke(method.simpleName, const []); |
| 216 } | 216 } |
| 217 | 217 |
| 218 class _InitMethodAnnotation { | 218 class _InitMethodAnnotation { |
| 219 const _InitMethodAnnotation(); | 219 const _InitMethodAnnotation(); |
| 220 } | 220 } |
| OLD | NEW |