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

Unified Diff: lib/dom/scripts/generator.py

Issue 10662047: Remove ParameterAdapters for all types except for String. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 months 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/dom/scripts/generator.py
diff --git a/lib/dom/scripts/generator.py b/lib/dom/scripts/generator.py
index df7834690a9ae623dd15d292cfe46cf322370391..988a4daea2ed1ffc22bf522961d56c2442d9ded4 100644
--- a/lib/dom/scripts/generator.py
+++ b/lib/dom/scripts/generator.py
@@ -655,19 +655,31 @@ class PrimitiveIDLTypeInfo(IDLTypeInfo):
self._webcore_setter_name = webcore_setter_name
def emit_to_native(self, emitter, idl_node, name, handle, interface_name):
- arguments = [handle]
- if idl_node.ext_attrs.get('Optional') == 'DefaultIsNullString':
- arguments.append('DartUtilities::ConvertNullToDefaultValue')
- emitter.Emit(
- '\n'
- ' const ParameterAdapter<$TYPE> $NAME($ARGUMENTS);\n'
- ' if (!$NAME.conversionSuccessful()) {\n'
- ' exception = $NAME.exception();\n'
- ' goto fail;\n'
- ' }\n',
- TYPE=self.native_type(),
- NAME=name,
- ARGUMENTS=', '.join(arguments))
+ if self.native_type() == 'String':
Anton Muhin 2012/06/26 12:56:41 maybe introduce a separate typeinfo for String and
podivilov 2012/06/26 13:14:49 We need to refactor string conversions first. Then
Anton Muhin 2012/06/26 13:24:43 What do you mean be refactor string conversions?
+ arguments = [handle]
+ if idl_node.ext_attrs.get('Optional') == 'DefaultIsNullString':
+ arguments.append('DartUtilities::ConvertNullToDefaultValue')
+ emitter.Emit(
+ ' const ParameterAdapter<String> $NAME($ARGUMENTS);\n'
+ ' if (!$NAME.conversionSuccessful()) {\n'
+ ' exception = $NAME.exception();\n'
+ ' goto fail;\n'
+ ' }\n',
+ NAME=name,
+ ARGUMENTS=', '.join(arguments))
+ else:
+ type = self.native_type()
+ if type == 'SerializedScriptValue':
+ type = 'RefPtr<%s>' % type
+ emitter.Emit(
+ '\n'
+ ' $TYPE $NAME = DartUtilities::dartTo$CAPITALIZED_TYPE($HANDLE, exception);\n'
+ ' if (exception)\n'
+ ' goto fail;\n',
+ TYPE=type,
+ NAME=name,
+ CAPITALIZED_TYPE=self._capitalized_native_type(),
+ HANDLE=handle)
return name
def parameter_type(self):
@@ -685,7 +697,7 @@ class PrimitiveIDLTypeInfo(IDLTypeInfo):
conversion_arguments = [value]
if attributes and 'TreatReturnedNullStringAs' in attributes:
conversion_arguments.append('DartUtilities::ConvertNullToDefaultValue')
- function_name = re.sub(r' [a-z]', lambda x: x.group(0)[1:].upper(), self.native_type())
+ function_name = self._capitalized_native_type()
function_name = function_name[0].lower() + function_name[1:]
function_name = 'DartUtilities::%sToDart' % function_name
return '%s(%s)' % (function_name, ', '.join(conversion_arguments))
@@ -696,6 +708,12 @@ class PrimitiveIDLTypeInfo(IDLTypeInfo):
def webcore_setter_name(self):
return self._webcore_setter_name
+ def _capitalized_native_type(self):
+ def replace(match):
+ return match.group(2)[0].upper() + match.group(2)[1:]
+ return re.sub(r'(^| )([a-z]\w*)', replace, self.native_type())
Anton Muhin 2012/06/26 12:56:41 why it changed?
podivilov 2012/06/26 13:14:49 It's now used to generate both fooBarToDart and da
Anton Muhin 2012/06/26 13:24:43 What's the difference in semantics except for 1st
podivilov 2012/06/26 13:58:31 Done.
+
+
class SVGTearOffIDLTypeInfo(IDLTypeInfo):
def __init__(self, idl_type, native_type=''):
super(SVGTearOffIDLTypeInfo, self).__init__(idl_type,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698