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

Side by Side Diff: lib/dom/scripts/generator.py

Issue 10657047: Stop using ParameterAdapter<String> in generated code. (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | lib/dom/templates/dom/native/cpp_implementation.template » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
3 # for details. All rights reserved. Use of this source code is governed by a 3 # for details. All rights reserved. Use of this source code is governed by a
4 # BSD-style license that can be found in the LICENSE file. 4 # BSD-style license that can be found in the LICENSE file.
5 5
6 """This module provides shared functionality for systems to generate 6 """This module provides shared functionality for systems to generate
7 Dart APIs from the IDL database.""" 7 Dart APIs from the IDL database."""
8 8
9 import copy 9 import copy
10 import re 10 import re
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 class PrimitiveIDLTypeInfo(IDLTypeInfo): 648 class PrimitiveIDLTypeInfo(IDLTypeInfo):
649 def __init__(self, idl_type, dart_type, native_type=None, 649 def __init__(self, idl_type, dart_type, native_type=None,
650 webcore_getter_name='getAttribute', 650 webcore_getter_name='getAttribute',
651 webcore_setter_name='setAttribute'): 651 webcore_setter_name='setAttribute'):
652 super(PrimitiveIDLTypeInfo, self).__init__(idl_type, dart_type=dart_type, 652 super(PrimitiveIDLTypeInfo, self).__init__(idl_type, dart_type=dart_type,
653 native_type=native_type) 653 native_type=native_type)
654 self._webcore_getter_name = webcore_getter_name 654 self._webcore_getter_name = webcore_getter_name
655 self._webcore_setter_name = webcore_setter_name 655 self._webcore_setter_name = webcore_setter_name
656 656
657 def emit_to_native(self, emitter, idl_node, name, handle, interface_name): 657 def emit_to_native(self, emitter, idl_node, name, handle, interface_name):
658 if self.native_type() == 'String': 658 function_name = 'dartTo%s' % self._capitalized_native_type()
659 arguments = [handle] 659 if idl_node.ext_attrs.get('Optional') == 'DefaultIsNullString':
660 if idl_node.ext_attrs.get('Optional') == 'DefaultIsNullString': 660 function_name += 'WithNullCheck'
661 arguments.append('DartUtilities::ConvertNullToDefaultValue') 661 type = self.native_type()
662 emitter.Emit( 662 if type == 'SerializedScriptValue':
663 ' const ParameterAdapter<String> $NAME($ARGUMENTS);\n' 663 type = 'RefPtr<%s>' % type
664 ' if (!$NAME.conversionSuccessful()) {\n' 664 if type == 'String':
665 ' exception = $NAME.exception();\n' 665 type = 'DartStringAdapter'
666 ' goto fail;\n' 666 emitter.Emit(
667 ' }\n', 667 '\n'
668 NAME=name, 668 ' $TYPE $NAME = DartUtilities::$FUNCTION_NAME($HANDLE, exception) ;\n'
669 ARGUMENTS=', '.join(arguments)) 669 ' if (exception)\n'
670 else: 670 ' goto fail;\n',
671 type = self.native_type() 671 TYPE=type,
672 if type == 'SerializedScriptValue': 672 NAME=name,
673 type = 'RefPtr<%s>' % type 673 FUNCTION_NAME=function_name,
674 emitter.Emit( 674 HANDLE=handle)
675 '\n'
676 ' $TYPE $NAME = DartUtilities::dartTo$CAPITALIZED_TYPE($HANDLE, exception);\n'
677 ' if (exception)\n'
678 ' goto fail;\n',
679 TYPE=type,
680 NAME=name,
681 CAPITALIZED_TYPE=self._capitalized_native_type(),
682 HANDLE=handle)
683 return name 675 return name
684 676
685 def parameter_type(self): 677 def parameter_type(self):
686 if self.native_type() == 'String': 678 if self.native_type() == 'String':
687 return 'const String&' 679 return 'const String&'
688 return self.native_type() 680 return self.native_type()
689 681
690 def conversion_includes(self): 682 def conversion_includes(self):
691 return [] 683 return []
692 684
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 839
848 match = re.match(r'sequence<(\w+)>$', idl_type_name) 840 match = re.match(r'sequence<(\w+)>$', idl_type_name)
849 if match: 841 if match:
850 return SequenceIDLTypeInfo(idl_type_name, GetIDLTypeInfo(match.group(1))) 842 return SequenceIDLTypeInfo(idl_type_name, GetIDLTypeInfo(match.group(1)))
851 843
852 match = re.match(r'(\w+)\[\]$', idl_type_name) 844 match = re.match(r'(\w+)\[\]$', idl_type_name)
853 if match: 845 if match:
854 return SequenceIDLTypeInfo(idl_type_name, GetIDLTypeInfo(match.group(1))) 846 return SequenceIDLTypeInfo(idl_type_name, GetIDLTypeInfo(match.group(1)))
855 847
856 return IDLTypeInfo(idl_type_name) 848 return IDLTypeInfo(idl_type_name)
OLDNEW
« no previous file with comments | « no previous file | lib/dom/templates/dom/native/cpp_implementation.template » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698