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

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

Issue 10827046: Split to dart conversion and argument expression logic. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 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 | lib/dom/scripts/systemnative.py » ('j') | 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 aadb69b6392a5277e1513abe27b29499bec5c2ba..004d5390fce1b3cb517d6a51ea87352f7972e64b 100644
--- a/lib/dom/scripts/generator.py
+++ b/lib/dom/scripts/generator.py
@@ -483,7 +483,7 @@ class IDLTypeInfo(object):
def requires_v8_scope(self):
return self._data.requires_v8_scope
- def emit_to_native(self, emitter, idl_node, accept_null, name, handle, interface_name):
+ def emit_to_native(self, emitter, idl_node, accept_null, name, handle):
if 'Callback' in idl_node.ext_attrs:
function_name = 'create'
if accept_null:
@@ -498,16 +498,12 @@ class IDLTypeInfo(object):
FUNCTION_NAME=function_name,
IDL_TYPE=self.idl_type(),
HANDLE=handle)
- return name
+ return
- argument = name
if self.custom_to_native():
type = 'RefPtr<%s>' % self.native_type()
- argument = '%s.get()' % name
else:
type = '%s*' % self.native_type()
- if isinstance(self, SVGTearOffIDLTypeInfo) and not interface_name.endswith('List'):
- argument = '%s->propertyReference()' % name
emitter.Emit(
'\n'
' $TYPE $NAME = Dart$IDL_TYPE::toNative($HANDLE, exception);\n'
@@ -517,7 +513,9 @@ class IDLTypeInfo(object):
NAME=name,
IDL_TYPE=self.idl_type(),
HANDLE=handle)
- return argument
+
+ def argument_expression(self, name, interface_name):
+ return '%s.get()' % name if self.custom_to_native() else name
def custom_to_native(self):
return self._data.custom_to_native
@@ -595,7 +593,7 @@ class DOMStringArrayTypeInfo(SequenceIDLTypeInfo):
def __init__(self, data, item_info):
super(DOMStringArrayTypeInfo, self).__init__('DOMString[]', data, item_info)
- def emit_to_native(self, emitter, idl_node, accept_null, name, handle, interface_name):
+ def emit_to_native(self, emitter, idl_node, accept_null, name, handle):
assert not accept_null
emitter.Emit(
'\n'
@@ -604,7 +602,6 @@ class DOMStringArrayTypeInfo(SequenceIDLTypeInfo):
' goto fail;\n',
NAME=name,
HANDLE=handle)
- return name
def to_native_includes(self):
return ['"DartDOMStringList.h"']
@@ -614,7 +611,7 @@ class PrimitiveIDLTypeInfo(IDLTypeInfo):
def __init__(self, idl_type, data):
super(PrimitiveIDLTypeInfo, self).__init__(idl_type, data)
- def emit_to_native(self, emitter, idl_node, accept_null, name, handle, interface_name):
+ def emit_to_native(self, emitter, idl_node, accept_null, name, handle):
function_name = 'dartTo%s' % self._capitalized_native_type()
if accept_null:
function_name += 'WithNullCheck'
@@ -632,7 +629,6 @@ class PrimitiveIDLTypeInfo(IDLTypeInfo):
NAME=name,
FUNCTION_NAME=function_name,
HANDLE=handle)
- return name
def parameter_type(self):
if self.native_type() == 'String':
@@ -697,6 +693,9 @@ class SVGTearOffIDLTypeInfo(IDLTypeInfo):
conversion_cast = conversion_cast % (self.native_type(), value)
return 'Dart%s::toDart(%s)' % (self._idl_type, conversion_cast)
+ def argument_expression(self, name, interface_name):
+ return name if interface_name.endswith('List') else '%s->propertyReference()' % name
+
class TypeData(object):
def __init__(self, clazz, dart_type=None, native_type=None,
« no previous file with comments | « no previous file | lib/dom/scripts/systemnative.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698