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

Side by Side Diff: tools/dom/scripts/systemnative.py

Issue 23064024: Attempt to land Dartium roll a second time. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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 | « tools/dom/scripts/htmlrenamer.py ('k') | no next file » | 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 the systems to generate 6 """This module provides shared functionality for the systems to generate
7 native binding from the IDL database.""" 7 native binding from the IDL database."""
8 8
9 import emitter 9 import emitter
10 import os 10 import os
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 for (type, member) in _cpp_overloaded_callback_map.keys(): 86 for (type, member) in _cpp_overloaded_callback_map.keys():
87 if type not in _cpp_partial_map: 87 if type not in _cpp_partial_map:
88 _cpp_partial_map[type] = set([]) 88 _cpp_partial_map[type] = set([])
89 _cpp_partial_map[type].add(_cpp_overloaded_callback_map[(type, member)]) 89 _cpp_partial_map[type].add(_cpp_overloaded_callback_map[(type, member)])
90 90
91 if interface_name in _cpp_partial_map: 91 if interface_name in _cpp_partial_map:
92 return _cpp_partial_map[interface_name] 92 return _cpp_partial_map[interface_name]
93 else: 93 else:
94 return set([]) 94 return set([])
95 95
96 def array_type(data_type):
97 matched = re.match(r'([\w\d_\s]+)\[\]', data_type)
98 if not matched:
99 return None
100 return matched.group(1)
101
96 def _GetCPPTypeName(interface_name, callback_name, cpp_name): 102 def _GetCPPTypeName(interface_name, callback_name, cpp_name):
97 # TODO(vsm): We need to track the original IDL file name in order to recover 103 # TODO(vsm): We need to track the original IDL file name in order to recover
98 # the proper CPP name. 104 # the proper CPP name.
99 105
100 cpp_tuple = (interface_name, callback_name) 106 cpp_tuple = (interface_name, callback_name)
101 if cpp_tuple in _cpp_callback_map: 107 if cpp_tuple in _cpp_callback_map:
102 cpp_type_name = _cpp_callback_map[cpp_tuple] 108 cpp_type_name = _cpp_callback_map[cpp_tuple]
103 elif (interface_name, cpp_name) in _cpp_overloaded_callback_map: 109 elif (interface_name, cpp_name) in _cpp_overloaded_callback_map:
104 cpp_type_name = _cpp_overloaded_callback_map[(interface_name, cpp_name)] 110 cpp_type_name = _cpp_overloaded_callback_map[(interface_name, cpp_name)]
105 else: 111 else:
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 ext_attrs.get('ConstructorCallWith') == 'Script Arguments') 713 ext_attrs.get('ConstructorCallWith') == 'Script Arguments')
708 if requires_script_arguments: 714 if requires_script_arguments:
709 raises_exceptions = True 715 raises_exceptions = True
710 cpp_arguments = ['scriptArguments.release()'] 716 cpp_arguments = ['scriptArguments.release()']
711 # WebKit uses scriptArguments to reconstruct last argument, so 717 # WebKit uses scriptArguments to reconstruct last argument, so
712 # it's not needed and should be just removed. 718 # it's not needed and should be just removed.
713 arguments = arguments[:-1] 719 arguments = arguments[:-1]
714 720
715 requires_script_execution_context = (ext_attrs.get('CallWith') == 'ScriptExe cutionContext' or 721 requires_script_execution_context = (ext_attrs.get('CallWith') == 'ScriptExe cutionContext' or
716 ext_attrs.get('ConstructorCallWith') == 'ScriptExecutionContext') 722 ext_attrs.get('ConstructorCallWith') == 'ScriptExecutionContext')
723
724 requires_document = ext_attrs.get('ConstructorCallWith') == 'Document'
725
717 if requires_script_execution_context: 726 if requires_script_execution_context:
718 raises_exceptions = True 727 raises_exceptions = True
719 cpp_arguments = ['context'] 728 cpp_arguments = ['context']
720 729
721 requires_script_state = (ext_attrs.get('CallWith') == 'ScriptState' or 730 requires_script_state = (ext_attrs.get('CallWith') == 'ScriptState' or
722 ext_attrs.get('ConstructorCallWith') == 'ScriptStat e') 731 ext_attrs.get('ConstructorCallWith') == 'ScriptStat e')
723 if requires_script_state: 732 if requires_script_state:
724 raises_exceptions = True 733 raises_exceptions = True
725 cpp_arguments = ['&state'] 734 cpp_arguments = ['&state']
726 735
727 requires_dom_window = 'NamedConstructor' in ext_attrs 736 requires_dom_window = 'NamedConstructor' in ext_attrs
728 if requires_dom_window: 737 if requires_dom_window or requires_document:
729 raises_exceptions = True 738 raises_exceptions = True
730 cpp_arguments = ['document'] 739 cpp_arguments = ['document']
731 740
732 if 'ImplementedBy' in ext_attrs: 741 if 'ImplementedBy' in ext_attrs:
733 assert needs_receiver 742 assert needs_receiver
734 self._cpp_impl_includes.add('"%s.h"' % ext_attrs['ImplementedBy']) 743 self._cpp_impl_includes.add('"%s.h"' % ext_attrs['ImplementedBy'])
735 cpp_arguments.append('receiver') 744 cpp_arguments.append('receiver')
736 745
737 if 'Reflect' in ext_attrs: 746 if 'Reflect' in ext_attrs:
738 cpp_arguments = [self._GenerateWebCoreReflectionAttributeName(node)] 747 cpp_arguments = [self._GenerateWebCoreReflectionAttributeName(node)]
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 812
804 if requires_script_state: 813 if requires_script_state:
805 body_emitter.Emit( 814 body_emitter.Emit(
806 ' ScriptState* currentState = ScriptState::current();\n' 815 ' ScriptState* currentState = ScriptState::current();\n'
807 ' if (!currentState) {\n' 816 ' if (!currentState) {\n'
808 ' exception = Dart_NewStringFromCString("Failed to retrieve a script state");\n' 817 ' exception = Dart_NewStringFromCString("Failed to retrieve a script state");\n'
809 ' goto fail;\n' 818 ' goto fail;\n'
810 ' }\n' 819 ' }\n'
811 ' ScriptState& state = *currentState;\n\n') 820 ' ScriptState& state = *currentState;\n\n')
812 821
813 if requires_dom_window: 822 if requires_dom_window or requires_document:
814 self._cpp_impl_includes.add('"DOMWindow.h"') 823 self._cpp_impl_includes.add('"DOMWindow.h"')
815 body_emitter.Emit( 824 body_emitter.Emit(
816 ' DOMWindow* domWindow = DartUtilities::domWindowForCurrentIsol ate();\n' 825 ' DOMWindow* domWindow = DartUtilities::domWindowForCurrentIsol ate();\n'
817 ' if (!domWindow) {\n' 826 ' if (!domWindow) {\n'
818 ' exception = Dart_NewStringFromCString("Failed to fetch do mWindow");\n' 827 ' exception = Dart_NewStringFromCString("Failed to fetch do mWindow");\n'
819 ' goto fail;\n' 828 ' goto fail;\n'
820 ' }\n' 829 ' }\n'
821 ' Document* document = domWindow->document();\n') 830 ' Document* document = domWindow->document();\n')
822 831
823 if needs_receiver: 832 if needs_receiver:
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu mentCount))\n' 1125 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu mentCount))\n'
1117 ' return func;\n', 1126 ' return func;\n',
1118 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) 1127 CLASS_NAME=os.path.splitext(os.path.basename(path))[0])
1119 1128
1120 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): 1129 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument):
1121 return ( 1130 return (
1122 interface.id.endswith('Event') and 1131 interface.id.endswith('Event') and
1123 operation.id.startswith('init') and 1132 operation.id.startswith('init') and
1124 argument.ext_attrs.get('Default') == 'Undefined' and 1133 argument.ext_attrs.get('Default') == 'Undefined' and
1125 argument.type.id == 'DOMString') 1134 argument.type.id == 'DOMString')
OLDNEW
« no previous file with comments | « tools/dom/scripts/htmlrenamer.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698