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

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
Index: sdk/lib/html/scripts/systemhtml.py
diff --git a/sdk/lib/html/scripts/systemhtml.py b/sdk/lib/html/scripts/systemhtml.py
index dbdb4ccaa29d86cc75e6e1df969ab95cedf3030b..beebfe7a696ee74e28d807f64b13b2a6d57689a7 100644
--- a/sdk/lib/html/scripts/systemhtml.py
+++ b/sdk/lib/html/scripts/systemhtml.py
@@ -506,17 +506,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)
@@ -539,6 +542,7 @@ class Dart2JSBackend(HtmlDartGenerator):
if conversion:
return self._AddConvertingGetter(attr, html_name, conversion)
return_type = self.SecureOutputType(attr.type.id)
+ print '** ',attr.type.id, self._DartType(attr.type.id)
blois 2012/11/19 20:46:48 Debugging?
sra1 2012/11/19 23:15:07 Done.
self._members_emitter.Emit(
# TODO(sra): Use metadata to provide native name.
'\n $TYPE get $HTML_NAME => JS("$TYPE", "#.$NAME", this);'
@@ -618,8 +622,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,
@@ -627,13 +633,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))
@@ -735,7 +742,8 @@ class Dart2JSBackend(HtmlDartGenerator):
call_emitter.Emit('$(INDENT)return $CALL;\n', CALL=call)
self._members_emitter.Emit(
- ' $TYPE$TARGET($PARAMS) native "$NATIVE";\n',
+ ' $ANNOTATIONS$TYPE$TARGET($PARAMS) native "$NATIVE";\n',
+ ANNOTATIONS=self._Annotations(info.type_name, info.declared_name),
TYPE=TypeOrNothing(native_return_type),
TARGET=target,
PARAMS=', '.join(target_parameters),
@@ -819,6 +827,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

Powered by Google App Engine
This is Rietveld 408576698