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

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

Issue 119543002: - Setup infrastructure to white list some native methods as not requiring (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years 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 | 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 ('DOMURL', 'createObjectUrlFromSourceCallback'): 'URLMediaSource', 82 ('DOMURL', 'createObjectUrlFromSourceCallback'): 'URLMediaSource',
83 ('DOMURL', 'createObjectUrlFromStreamCallback'): 'URLMediaStream', 83 ('DOMURL', 'createObjectUrlFromStreamCallback'): 'URLMediaStream',
84 ('DOMURL', '_createObjectUrlFromWebKitSourceCallback'): 'URLMediaSource', 84 ('DOMURL', '_createObjectUrlFromWebKitSourceCallback'): 'URLMediaSource',
85 ('DOMURL', '_createObjectURL_2Callback'): 'URLMediaSource', 85 ('DOMURL', '_createObjectURL_2Callback'): 'URLMediaSource',
86 ('DOMURL', '_createObjectURL_3Callback'): 'URLMediaSource', 86 ('DOMURL', '_createObjectURL_3Callback'): 'URLMediaSource',
87 ('DOMURL', '_createObjectURL_4Callback'): 'URLMediaStream', 87 ('DOMURL', '_createObjectURL_4Callback'): 'URLMediaStream',
88 } 88 }
89 89
90 _cpp_partial_map = {} 90 _cpp_partial_map = {}
91 91
92 _cpp_no_auto_scope_list = [
93 ['Node', 'firstChild', 'Getter'],
vsm 2013/12/20 18:18:56 More efficient to make this a set of tuples instea
siva 2013/12/20 18:46:00 Done.
94 ['Node', 'lastChild', 'Getter'],
95 ['Node', 'nextSibling', 'Getter'],
96 ['Node', 'previousSibling', 'Getter'],
97 ['Node', 'childNodes', 'Getter'],
98 ['NodeList', 'length', 'Getter'],
99 ['NodeList', 'item', 'Callback'],
100 ['Document', 'body', 'Getter'],
101 ]
102
92 def _GetCPPPartialNames(interface): 103 def _GetCPPPartialNames(interface):
93 interface_name = interface.ext_attrs.get('ImplementedAs', interface.id) 104 interface_name = interface.ext_attrs.get('ImplementedAs', interface.id)
94 if not _cpp_partial_map: 105 if not _cpp_partial_map:
95 for (type, member) in _cpp_callback_map.keys(): 106 for (type, member) in _cpp_callback_map.keys():
96 if type not in _cpp_partial_map: 107 if type not in _cpp_partial_map:
97 _cpp_partial_map[type] = set([]) 108 _cpp_partial_map[type] = set([])
98 109
99 name_with_path = _cpp_callback_map[(type, member)] 110 name_with_path = _cpp_callback_map[(type, member)]
100 if name_with_path in _cpp_import_map: 111 if name_with_path in _cpp_import_map:
101 name_with_path = _cpp_import_map[name_with_path] 112 name_with_path = _cpp_import_map[name_with_path]
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 ' static void returnToDart(Dart_NativeArguments args,\n' 442 ' static void returnToDart(Dart_NativeArguments args,\n'
432 ' NativeType* value)\n' 443 ' NativeType* value)\n'
433 ' {\n' 444 ' {\n'
434 ' if (value) {\n' 445 ' if (value) {\n'
435 ' DartDOMData* domData = static_cast<DartDOMData*>(\n' 446 ' DartDOMData* domData = static_cast<DartDOMData*>(\n'
436 ' Dart_GetNativeIsolateData(args));\n' 447 ' Dart_GetNativeIsolateData(args));\n'
437 ' Dart_WeakPersistentHandle result =\n' 448 ' Dart_WeakPersistentHandle result =\n'
438 ' DartDOMWrapper::lookupWrapper<Dart$(INTERFACE)>(domData , value);\n' 449 ' DartDOMWrapper::lookupWrapper<Dart$(INTERFACE)>(domData , value);\n'
439 ' if (result)\n' 450 ' if (result)\n'
440 ' Dart_SetWeakHandleReturnValue(args, result);\n' 451 ' Dart_SetWeakHandleReturnValue(args, result);\n'
441 ' else\n' 452 ' else {\n'
453 ' DartApiScope apiScope();\n'
442 ' Dart_SetReturnValue(args, createWrapper(domData, value) );\n' 454 ' Dart_SetReturnValue(args, createWrapper(domData, value) );\n'
455 ' }\n'
443 ' }\n' 456 ' }\n'
444 ' }\n', 457 ' }\n',
445 INTERFACE=self._interface.id) 458 INTERFACE=self._interface.id)
446 459
447 if ('CustomToV8' in ext_attrs or 460 if ('CustomToV8' in ext_attrs or
448 'PureInterface' in ext_attrs or 461 'PureInterface' in ext_attrs or
449 'CPPPureInterface' in ext_attrs or 462 'CPPPureInterface' in ext_attrs or
450 self._interface_type_info.custom_to_dart()): 463 self._interface_type_info.custom_to_dart()):
451 to_dart_emitter.Emit( 464 to_dart_emitter.Emit(
452 ' static Dart_Handle createWrapper(DartDOMData* domData, NativeType * value);\n') 465 ' static Dart_Handle createWrapper(DartDOMData* domData, NativeType * value);\n')
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 value_expression, 1066 value_expression,
1054 self._interface.id, 1067 self._interface.id,
1055 ext_attrs) 1068 ext_attrs)
1056 set_return_value = '%s' % (return_to_dart_conversion) 1069 set_return_value = '%s' % (return_to_dart_conversion)
1057 invocation_emitter.Emit( 1070 invocation_emitter.Emit(
1058 ' $RETURN_VALUE;\n', 1071 ' $RETURN_VALUE;\n',
1059 RETURN_VALUE=set_return_value) 1072 RETURN_VALUE=set_return_value)
1060 1073
1061 def _GenerateNativeBinding(self, idl_name, argument_count, dart_declaration, 1074 def _GenerateNativeBinding(self, idl_name, argument_count, dart_declaration,
1062 native_suffix, is_custom, emit_metadata=True): 1075 native_suffix, is_custom, emit_metadata=True):
1076
1077 def _GenerateAutoSetupScope(self, idl_name, native_suffix):
vsm 2013/12/20 18:18:56 With the above, this function can be: return (sel
siva 2013/12/20 18:46:00 Done.
1078 for no_scope in _cpp_no_auto_scope_list:
1079 if (self._interface.id == no_scope[0] and
1080 idl_name == no_scope[1] and
1081 native_suffix == no_scope[2]):
1082 return 'false'
1083 return 'true'
1084
1063 metadata = [] 1085 metadata = []
1064 if emit_metadata: 1086 if emit_metadata:
1065 metadata = self._metadata.GetFormattedMetadata( 1087 metadata = self._metadata.GetFormattedMetadata(
1066 self._renamer.GetLibraryName(self._interface), 1088 self._renamer.GetLibraryName(self._interface),
1067 self._interface, idl_name, ' ') 1089 self._interface, idl_name, ' ')
1068 1090
1069 native_binding = '%s_%s_%s' % (self._interface.id, idl_name, native_suffix) 1091 native_binding = '%s_%s_%s' % (self._interface.id, idl_name, native_suffix)
1070 self._members_emitter.Emit( 1092 self._members_emitter.Emit(
1071 '\n' 1093 '\n'
1072 ' $METADATA$DART_DECLARATION native "$NATIVE_BINDING";\n', 1094 ' $METADATA$DART_DECLARATION native "$NATIVE_BINDING";\n',
1073 DOMINTERFACE=self._interface.id, 1095 DOMINTERFACE=self._interface.id,
1074 METADATA=metadata, 1096 METADATA=metadata,
1075 DART_DECLARATION=dart_declaration, 1097 DART_DECLARATION=dart_declaration,
1076 NATIVE_BINDING=native_binding) 1098 NATIVE_BINDING=native_binding)
1077 1099
1078 cpp_callback_name = '%s%s' % (idl_name, native_suffix) 1100 cpp_callback_name = '%s%s' % (idl_name, native_suffix)
1101 auto_scope_setup = _GenerateAutoSetupScope(self, idl_name, native_suffix)
1079 1102
1080 self._cpp_resolver_emitter.Emit( 1103 self._cpp_resolver_emitter.Emit(
1081 ' if (argumentCount == $ARGC && name == "$NATIVE_BINDING") {\n' 1104 ' if (argumentCount == $ARGC && name == "$NATIVE_BINDING") {\n'
1082 ' *autoSetupScope = true;\n' 1105 ' *autoSetupScope = $AUTO_SCOPE_SETUP;\n'
1083 ' return Dart$(INTERFACE_NAME)Internal::$CPP_CALLBACK_NAME;\n' 1106 ' return Dart$(INTERFACE_NAME)Internal::$CPP_CALLBACK_NAME;\n'
1084 ' }\n', 1107 ' }\n',
1085 ARGC=argument_count, 1108 ARGC=argument_count,
1086 NATIVE_BINDING=native_binding, 1109 NATIVE_BINDING=native_binding,
1087 INTERFACE_NAME=self._interface.id, 1110 INTERFACE_NAME=self._interface.id,
1111 AUTO_SCOPE_SETUP=auto_scope_setup,
1088 CPP_CALLBACK_NAME=cpp_callback_name) 1112 CPP_CALLBACK_NAME=cpp_callback_name)
1089 1113
1090 if is_custom: 1114 if is_custom:
1091 self._cpp_declarations_emitter.Emit( 1115 self._cpp_declarations_emitter.Emit(
1092 '\n' 1116 '\n'
1093 'void $CPP_CALLBACK_NAME(Dart_NativeArguments);\n', 1117 'void $CPP_CALLBACK_NAME(Dart_NativeArguments);\n',
1094 CPP_CALLBACK_NAME=cpp_callback_name) 1118 CPP_CALLBACK_NAME=cpp_callback_name)
1095 1119
1096 return cpp_callback_name 1120 return cpp_callback_name
1097 1121
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 e.Emit("};\n"); 1305 e.Emit("};\n");
1282 e.Emit('\n'); 1306 e.Emit('\n');
1283 e.Emit('} // namespace WebCore\n'); 1307 e.Emit('} // namespace WebCore\n');
1284 1308
1285 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): 1309 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument):
1286 return ( 1310 return (
1287 interface.id.endswith('Event') and 1311 interface.id.endswith('Event') and
1288 operation.id.startswith('init') and 1312 operation.id.startswith('init') and
1289 argument.ext_attrs.get('Default') == 'Undefined' and 1313 argument.ext_attrs.get('Default') == 'Undefined' and
1290 argument.type.id == 'DOMString') 1314 argument.type.id == 'DOMString')
OLDNEW
« 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