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

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

Issue 9432024: Do not rename idl types to dart types at top level - this info is needed for native bindings genera… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update html frog system. Created 8 years, 10 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 | « client/dom/scripts/dartgenerator_test.py ('k') | client/dom/scripts/systemfrog.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/dom/scripts/generator.py
diff --git a/client/dom/scripts/generator.py b/client/dom/scripts/generator.py
index 971a91042e15771b69fb06e9203260c9d221c957..8d73ef63b6b87f8d4bb26b8a5c98c4aec439a8b9 100644
--- a/client/dom/scripts/generator.py
+++ b/client/dom/scripts/generator.py
@@ -182,7 +182,7 @@ def IsPrimitiveType(type_name):
def MaybeListElementTypeName(type_name):
"""Returns the List element type T from string of form "List<T>", or None."""
- match = re.match(r'List<(\w*)>$', type_name)
+ match = re.match(r'sequence<(\w*)>$', type_name)
if match:
return match.group(1)
return None
@@ -225,6 +225,11 @@ def MatchSourceFilter(filter, thing):
else:
return any(token in thing.annotations for token in filter)
+def DartType(idl_type_name):
+ match = re.match(r'sequence<(\w*)>$', idl_type_name)
+ if match:
+ return 'List<%s>' % GetIDLTypeInfoByName(match.group(1)).dart_type()
+ return GetIDLTypeInfoByName(idl_type_name).dart_type()
# Given a list of overloaded arguments, render a dart argument.
def _DartArg(args, interface):
@@ -234,7 +239,7 @@ def _DartArg(args, interface):
# Given a list of overloaded arguments, choose a suitable type.
def OverloadedType(args):
- typeIds = sorted(set(arg.type.id for arg in args))
+ typeIds = sorted(set(DartType(arg.type.id) for arg in args))
if len(typeIds) == 1:
return typeIds[0]
else:
@@ -266,7 +271,7 @@ def AnalyzeOperation(interface, operations):
info.declared_name = operations[0].id
info.name = operations[0].ext_attrs.get('DartName', info.declared_name)
info.js_name = info.declared_name
- info.type_name = operations[0].type.id # TODO: widen.
+ info.type_name = DartType(operations[0].type.id) # TODO: widen.
info.arg_infos = args
return info
@@ -316,7 +321,7 @@ def RecognizeCallback(interface):
return AnalyzeOperation(interface, handlers)
def IsDartListType(type):
- return type == 'List' or type.startswith('List<')
+ return type == 'List' or type.startswith('sequence<')
def IsDartCollectionType(type):
return IsDartListType(type)
@@ -439,10 +444,11 @@ def TypeName(typeIds, interface):
# ------------------------------------------------------------------------------
class IDLTypeInfo(object):
- def __init__(self, idl_type, native_type=None, ref_counted=True,
+ def __init__(self, idl_type, dart_type=None, native_type=None, ref_counted=True,
has_dart_wrapper=True, conversion_template=None,
custom_to_dart=False):
self._idl_type = idl_type
+ self._dart_type = dart_type
self._native_type = native_type
self._ref_counted = ref_counted
self._has_dart_wrapper = has_dart_wrapper
@@ -452,6 +458,11 @@ class IDLTypeInfo(object):
def idl_type(self):
return self._idl_type
+ def dart_type(self):
+ if self._dart_type:
+ return self._dart_type
+ return self._idl_type
+
def native_type(self):
if self._native_type:
return self._native_type
@@ -492,11 +503,11 @@ class IDLTypeInfo(object):
return self._custom_to_dart
class PrimitiveIDLTypeInfo(IDLTypeInfo):
- def __init__(self, idl_type, native_type=None, ref_counted=False,
+ def __init__(self, idl_type, dart_type, native_type=None, ref_counted=False,
conversion_template=None,
webcore_getter_name='getAttribute',
webcore_setter_name='setAttribute'):
- super(PrimitiveIDLTypeInfo, self).__init__(idl_type,
+ super(PrimitiveIDLTypeInfo, self).__init__(idl_type, dart_type=dart_type,
native_type=native_type, ref_counted=ref_counted,
conversion_template=conversion_template)
self._webcore_getter_name = webcore_getter_name
@@ -543,34 +554,49 @@ class SVGTearOffIDLTypeInfo(IDLTypeInfo):
_idl_type_registry = {
- # There is GC3Dboolean which is not a bool, but unsigned char for OpenGL compatibility.
- 'boolean': PrimitiveIDLTypeInfo('boolean', native_type='bool',
+ # There is GC3Dboolean which is not a bool, but unsigned char for OpenGL compatibility.
+ 'boolean': PrimitiveIDLTypeInfo('boolean', dart_type='bool', native_type='bool',
conversion_template='static_cast<bool>(%s)',
webcore_getter_name='hasAttribute',
webcore_setter_name='setBooleanAttribute'),
# Some IDL's unsigned shorts/shorts are mapped to WebCore C++ enums, so we
# use a static_cast<int> here not to provide overloads for all enums.
- 'short': PrimitiveIDLTypeInfo('short', native_type='int', conversion_template='static_cast<int>(%s)'),
- 'unsigned short': PrimitiveIDLTypeInfo('unsigned short', native_type='int', conversion_template='static_cast<int>(%s)'),
- 'int': PrimitiveIDLTypeInfo('int'),
- 'unsigned int': PrimitiveIDLTypeInfo('unsigned int', native_type='unsigned'),
- 'long': PrimitiveIDLTypeInfo('long', native_type='int',
+ 'short': PrimitiveIDLTypeInfo('short', dart_type='int', native_type='int',
+ conversion_template='static_cast<int>(%s)'),
+ 'unsigned short': PrimitiveIDLTypeInfo('unsigned short', dart_type='int',
+ native_type='int', conversion_template='static_cast<int>(%s)'),
+ 'int': PrimitiveIDLTypeInfo('int', dart_type='int'),
+ 'unsigned int': PrimitiveIDLTypeInfo('unsigned int', dart_type='int',
+ native_type='unsigned'),
+ 'long': PrimitiveIDLTypeInfo('long', dart_type='int', native_type='int',
webcore_getter_name='getIntegralAttribute',
webcore_setter_name='setIntegralAttribute'),
- 'unsigned long': PrimitiveIDLTypeInfo('unsigned long', native_type='unsigned',
+ 'unsigned long': PrimitiveIDLTypeInfo('unsigned long', dart_type='int',
+ native_type='unsigned',
webcore_getter_name='getUnsignedIntegralAttribute',
webcore_setter_name='setUnsignedIntegralAttribute'),
- 'long long': PrimitiveIDLTypeInfo('long long'),
- 'unsigned long long': PrimitiveIDLTypeInfo('unsigned long long'),
- 'double': PrimitiveIDLTypeInfo('double'),
-
- 'Date': PrimitiveIDLTypeInfo('Date', native_type='double'),
- 'DOMString': PrimitiveIDLTypeInfo('DOMString', native_type='String'),
- 'DOMTimeStamp': PrimitiveIDLTypeInfo('DOMTimeStamp'),
- 'object': PrimitiveIDLTypeInfo('object', native_type='ScriptValue'),
- 'SerializedScriptValue': PrimitiveIDLTypeInfo('SerializedScriptValue', ref_counted=True),
-
- 'DOMException': IDLTypeInfo('DOMCoreException'),
+ 'long long': PrimitiveIDLTypeInfo('long long', dart_type='int'),
+ 'unsigned long long': PrimitiveIDLTypeInfo('unsigned long long', dart_type='int'),
+ 'double': PrimitiveIDLTypeInfo('double', dart_type='num'),
+ 'float': PrimitiveIDLTypeInfo('float', dart_type='num'),
+
+ 'any': PrimitiveIDLTypeInfo('any', dart_type='Object'),
+ 'any[]': PrimitiveIDLTypeInfo('any[]', dart_type='List'),
+ 'Array': PrimitiveIDLTypeInfo('Array', dart_type='List'),
+ 'custom': PrimitiveIDLTypeInfo('custom', dart_type='Dynamic'),
+ 'Date': PrimitiveIDLTypeInfo('Date', dart_type='Date', native_type='double'),
+ 'DOMObject': PrimitiveIDLTypeInfo('DOMObject', dart_type='Object'),
+ 'DOMString': PrimitiveIDLTypeInfo('DOMString', dart_type='String', native_type='String'),
+ # TODO(sra): Flags is really a dictionary: {create:bool, exclusive:bool}
+ # http://dev.w3.org/2009/dap/file-system/file-dir-sys.html#the-flags-interface
+ 'Flags': PrimitiveIDLTypeInfo('Flags', dart_type='Object'),
+ 'List<String>': PrimitiveIDLTypeInfo('DOMStringList', dart_type='List<String>'),
+ 'DOMTimeStamp': PrimitiveIDLTypeInfo('DOMTimeStamp', dart_type='int'),
+ 'object': PrimitiveIDLTypeInfo('object', dart_type='Object', native_type='ScriptValue'),
+ 'SerializedScriptValue': PrimitiveIDLTypeInfo('SerializedScriptValue', dart_type='Dynamic', ref_counted=True),
+ 'WebKitFlags': PrimitiveIDLTypeInfo('WebKitFlags', dart_type='Object'),
+
+ 'DOMException': IDLTypeInfo('DOMCoreException', dart_type='DOMException'),
'DOMWindow': IDLTypeInfo('DOMWindow', custom_to_dart=True),
'Element': IDLTypeInfo('Element', custom_to_dart=True),
'EventListener': IDLTypeInfo('EventListener', has_dart_wrapper=False),
@@ -596,12 +622,8 @@ _idl_type_registry = {
'SVGTransformList': SVGTearOffIDLTypeInfo('SVGTransformList', native_type='SVGTransformListPropertyTearOff', ref_counted=False)
}
-original_idl_types = {
-}
-
def GetIDLTypeInfo(idl_type):
- idl_type_name = original_idl_types.get(idl_type, idl_type.id)
- return GetIDLTypeInfoByName(idl_type_name)
+ return GetIDLTypeInfoByName(idl_type.id)
def GetIDLTypeInfoByName(idl_type_name):
return _idl_type_registry.get(idl_type_name, IDLTypeInfo(idl_type_name))
« no previous file with comments | « client/dom/scripts/dartgenerator_test.py ('k') | client/dom/scripts/systemfrog.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698