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

Unified Diff: sdk/lib/html/scripts/systemhtml.py

Issue 11308075: Add custom annotations to some APIs for native tree shaking. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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 | « sdk/lib/html/scripts/generator.py ('k') | sdk/lib/html/src/dart2js_Conversions.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/html/scripts/systemhtml.py
diff --git a/sdk/lib/html/scripts/systemhtml.py b/sdk/lib/html/scripts/systemhtml.py
index 7d0262723481e2a56619058db092e74f943be5d7..9bb8186ba9337b07fa5e299d20fb71734b12ffa9 100644
--- a/sdk/lib/html/scripts/systemhtml.py
+++ b/sdk/lib/html/scripts/systemhtml.py
@@ -548,17 +548,20 @@ class Dart2JSBackend(HtmlDartGenerator):
output_type = self.SecureOutputType(attribute.type.id)
input_type = self._NarrowInputType(attribute.type.id)
+ annotations = self._Annotations(attribute.type.id, attribute.id)
self.EmitAttributeDocumentation(attribute)
if not read_only:
self._members_emitter.Emit(
- '\n $TYPE $NAME;'
+ '\n $ANNOTATIONS$TYPE $NAME;'
'\n',
+ ANNOTATIONS=annotations,
NAME=DartDomNameOfAttribute(attribute),
TYPE=output_type)
else:
self._members_emitter.Emit(
- '\n final $TYPE $NAME;'
+ '\n $(ANNOTATIONS)final $TYPE $NAME;'
'\n',
+ ANNOTATIONS=annotations,
NAME=DartDomNameOfAttribute(attribute),
TYPE=output_type)
@@ -660,8 +663,10 @@ class Dart2JSBackend(HtmlDartGenerator):
if html_name != info.declared_name:
return_type = self.SecureOutputType(info.type_name)
- operation_emitter = self._members_emitter.Emit('$!SCOPE',
+ operation_emitter = self._members_emitter.Emit(
+ '$!SCOPE',
MODIFIERS='static ' if info.IsStatic() else '',
+ ANNOTATIONS=self._Annotations(info.type_name, info.declared_name),
TYPE=return_type,
HTML_NAME=html_name,
NAME=info.declared_name,
@@ -669,13 +674,14 @@ class Dart2JSBackend(HtmlDartGenerator):
operation_emitter.Emit(
'\n'
- #' // @native("$NAME")\n;'
- ' $MODIFIERS$TYPE $(HTML_NAME)($PARAMS) native "$NAME";\n')
+ ' $ANNOTATIONS'
+ '$MODIFIERS$TYPE $(HTML_NAME)($PARAMS) native "$NAME";\n')
else:
self._members_emitter.Emit(
'\n'
- ' $MODIFIERS$TYPE $NAME($PARAMS) native;\n',
+ ' $ANNOTATIONS$MODIFIERS$TYPE $NAME($PARAMS) native;\n',
MODIFIERS='static ' if info.IsStatic() else '',
+ ANNOTATIONS=self._Annotations(info.type_name, info.declared_name),
TYPE=self.SecureOutputType(info.type_name),
NAME=info.name,
PARAMS=info.ParametersDeclaration(self._NarrowInputType))
@@ -777,8 +783,9 @@ class Dart2JSBackend(HtmlDartGenerator):
call_emitter.Emit('$(INDENT)return $CALL;\n', CALL=call)
self._members_emitter.Emit(
- ' $MODIFIERS$TYPE$TARGET($PARAMS) native "$NATIVE";\n',
+ ' $MODIFIERS$ANNOTATIONS$TYPE$TARGET($PARAMS) native "$NATIVE";\n',
MODIFIERS='static ' if info.IsStatic() else '',
+ ANNOTATIONS=self._Annotations(info.type_name, info.declared_name),
TYPE=TypeOrNothing(native_return_type),
TARGET=target,
PARAMS=', '.join(target_parameters),
@@ -862,6 +869,13 @@ class Dart2JSBackend(HtmlDartGenerator):
member_name)
return member_name in _js_custom_members
+ def _Annotations(self, idl_type, member_name):
+ annotations = FindAnnotations(idl_type, self._interface.id, member_name)
+ if annotations:
+ return '%s\n ' % annotations
+ else:
+ return ''
+
def CustomJSMembers(self):
return _js_custom_members
« no previous file with comments | « sdk/lib/html/scripts/generator.py ('k') | sdk/lib/html/src/dart2js_Conversions.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698