| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 dart.dom.html; | 5 part of dart.dom.html; |
| 6 | 6 |
| 7 /// Dartium ElementUpgrader implementation. | 7 /// Dartium ElementUpgrader implementation. |
| 8 class _VMElementUpgrader implements ElementUpgrader { | 8 class _VMElementUpgrader implements ElementUpgrader { |
| 9 final Type _type; | 9 final Type _type; |
| 10 final Type _nativeType; | 10 final Type _nativeType; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 /// | 42 /// |
| 43 /// Then returns the native base class. | 43 /// Then returns the native base class. |
| 44 ClassMirror _validateCustomType(Type type) { | 44 ClassMirror _validateCustomType(Type type) { |
| 45 ClassMirror cls = reflectClass(type); | 45 ClassMirror cls = reflectClass(type); |
| 46 if (_isBuiltinType(cls)) { | 46 if (_isBuiltinType(cls)) { |
| 47 throw new UnsupportedError('Invalid custom element from ' | 47 throw new UnsupportedError('Invalid custom element from ' |
| 48 '${(cls.owner as LibraryMirror).uri}.'); | 48 '${(cls.owner as LibraryMirror).uri}.'); |
| 49 } | 49 } |
| 50 | 50 |
| 51 var className = MirrorSystem.getName(cls.simpleName); | 51 var className = MirrorSystem.getName(cls.simpleName); |
| 52 if (cls.isAbstract) { |
| 53 throw new UnsupportedError('Invalid custom element ' |
| 54 'class $className is abstract.'); |
| 55 } |
| 56 |
| 52 var createdConstructor = cls.declarations[new Symbol('$className.created')]; | 57 var createdConstructor = cls.declarations[new Symbol('$className.created')]; |
| 53 if (createdConstructor == null || | 58 if (createdConstructor == null || |
| 54 createdConstructor is! MethodMirror || | 59 createdConstructor is! MethodMirror || |
| 55 !createdConstructor.isConstructor) { | 60 !createdConstructor.isConstructor) { |
| 56 throw new UnsupportedError( | 61 throw new UnsupportedError( |
| 57 'Class is missing constructor $className.created'); | 62 'Class is missing constructor $className.created'); |
| 58 } | 63 } |
| 59 | 64 |
| 60 if (createdConstructor.parameters.length > 0) { | 65 if (createdConstructor.parameters.length > 0) { |
| 61 throw new UnsupportedError( | 66 throw new UnsupportedError( |
| (...skipping 17 matching lines...) Expand all Loading... |
| 79 return nativeClass; | 84 return nativeClass; |
| 80 } | 85 } |
| 81 | 86 |
| 82 | 87 |
| 83 bool _isBuiltinType(ClassMirror cls) { | 88 bool _isBuiltinType(ClassMirror cls) { |
| 84 // TODO(vsm): Find a less hackish way to do this. | 89 // TODO(vsm): Find a less hackish way to do this. |
| 85 LibraryMirror lib = cls.owner; | 90 LibraryMirror lib = cls.owner; |
| 86 String libName = lib.uri.toString(); | 91 String libName = lib.uri.toString(); |
| 87 return libName.startsWith('dart:'); | 92 return libName.startsWith('dart:'); |
| 88 } | 93 } |
| OLD | NEW |