OLD | NEW |
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 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1197 e.Emit('#ifndef DartWebkitClassIds_h\n'); | 1197 e.Emit('#ifndef DartWebkitClassIds_h\n'); |
1198 e.Emit('#define DartWebkitClassIds_h\n'); | 1198 e.Emit('#define DartWebkitClassIds_h\n'); |
1199 e.Emit('\n'); | 1199 e.Emit('\n'); |
1200 e.Emit('namespace WebCore {\n'); | 1200 e.Emit('namespace WebCore {\n'); |
1201 e.Emit('\n'); | 1201 e.Emit('\n'); |
1202 e.Emit('enum {\n'); | 1202 e.Emit('enum {\n'); |
1203 e.Emit(' _HistoryCrossFrameClassId = 0,\n'); | 1203 e.Emit(' _HistoryCrossFrameClassId = 0,\n'); |
1204 e.Emit(' _LocationCrossFrameClassId,\n'); | 1204 e.Emit(' _LocationCrossFrameClassId,\n'); |
1205 e.Emit(' _DOMWindowCrossFrameClassId,\n'); | 1205 e.Emit(' _DOMWindowCrossFrameClassId,\n'); |
1206 e.Emit(' _DateTimeClassId,\n'); | 1206 e.Emit(' _DateTimeClassId,\n'); |
| 1207 e.Emit(' _JsObjectClassId,\n'); |
| 1208 e.Emit(' _JsFunctionClassId,\n'); |
1207 e.Emit(' // New types that are not auto-generated should be added here.\n
'); | 1209 e.Emit(' // New types that are not auto-generated should be added here.\n
'); |
1208 e.Emit('\n'); | 1210 e.Emit('\n'); |
1209 for interface in database.GetInterfaces(): | 1211 for interface in database.GetInterfaces(): |
1210 interface_name = interface.id | 1212 interface_name = interface.id |
1211 e.Emit(' %sClassId,\n' % interface_name) | 1213 e.Emit(' %sClassId,\n' % interface_name) |
1212 e.Emit(' NumWebkitClassIds\n'); | 1214 e.Emit(' NumWebkitClassIds\n'); |
1213 e.Emit('};\n'); | 1215 e.Emit('};\n'); |
1214 | 1216 |
1215 e.Emit('typedef struct {\n'); | 1217 e.Emit('typedef struct {\n'); |
1216 e.Emit(' const char* class_name;\n'); | 1218 e.Emit(' const char* class_name;\n'); |
(...skipping 23 matching lines...) Expand all Loading... |
1240 e.Emit('\n'); | 1242 e.Emit('\n'); |
1241 e.Emit('#include "bindings/dart/DartLibraryIds.h"\n'); | 1243 e.Emit('#include "bindings/dart/DartLibraryIds.h"\n'); |
1242 e.Emit('\n'); | 1244 e.Emit('\n'); |
1243 e.Emit('namespace WebCore {\n'); | 1245 e.Emit('namespace WebCore {\n'); |
1244 e.Emit('\n'); | 1246 e.Emit('\n'); |
1245 e.Emit("_DartWebkitClassInfo DartWebkitClassInfo = {\n"); | 1247 e.Emit("_DartWebkitClassInfo DartWebkitClassInfo = {\n"); |
1246 e.Emit(' { "_HistoryCrossFrame", DartHtmlLibraryId, -1, false, false, fal
se },\n'); | 1248 e.Emit(' { "_HistoryCrossFrame", DartHtmlLibraryId, -1, false, false, fal
se },\n'); |
1247 e.Emit(' { "_LocationCrossFrame", DartHtmlLibraryId, -1, false, false, fa
lse },\n'); | 1249 e.Emit(' { "_LocationCrossFrame", DartHtmlLibraryId, -1, false, false, fa
lse },\n'); |
1248 e.Emit(' { "_DOMWindowCrossFrame", DartHtmlLibraryId, -1, false, false, t
rue },\n'); | 1250 e.Emit(' { "_DOMWindowCrossFrame", DartHtmlLibraryId, -1, false, false, t
rue },\n'); |
1249 e.Emit(' { "DateTime", DartCoreLibraryId, -1, false, false, false },\n'); | 1251 e.Emit(' { "DateTime", DartCoreLibraryId, -1, false, false, false },\n'); |
| 1252 e.Emit(' { "JsObject", DartJsLibraryId, -1, false, false, false },\n'); |
| 1253 e.Emit(' { "JsFunction", DartJsLibraryId, _JsObjectClassId, false, false,
false },\n'); |
1250 e.Emit(' // New types that are not auto-generated should be added here.\n
'); | 1254 e.Emit(' // New types that are not auto-generated should be added here.\n
'); |
1251 e.Emit('\n'); | 1255 e.Emit('\n'); |
1252 is_node_test = lambda interface: interface.id == 'Node' | 1256 is_node_test = lambda interface: interface.id == 'Node' |
1253 is_active_test = lambda interface: 'ActiveDOMObject' in interface.ext_attrs | 1257 is_active_test = lambda interface: 'ActiveDOMObject' in interface.ext_attrs |
1254 is_event_target_test = lambda interface: 'EventTarget' in interface.ext_attr
s | 1258 is_event_target_test = lambda interface: 'EventTarget' in interface.ext_attr
s |
1255 def TypeCheckHelper(test): | 1259 def TypeCheckHelper(test): |
1256 return 'true' if any(map(test, database.Hierarchy(interface))) else 'false
' | 1260 return 'true' if any(map(test, database.Hierarchy(interface))) else 'false
' |
1257 for interface in database.GetInterfaces(): | 1261 for interface in database.GetInterfaces(): |
1258 e.Emit(" {") | 1262 e.Emit(" {") |
1259 type_info = type_registry.TypeInfo(interface.id) | 1263 type_info = type_registry.TypeInfo(interface.id) |
(...skipping 13 matching lines...) Expand all Loading... |
1273 e.Emit('\n'); | 1277 e.Emit('\n'); |
1274 e.Emit('} // namespace WebCore\n'); | 1278 e.Emit('} // namespace WebCore\n'); |
1275 self._emitters.Flush() | 1279 self._emitters.Flush() |
1276 | 1280 |
1277 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): | 1281 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): |
1278 return ( | 1282 return ( |
1279 interface.id.endswith('Event') and | 1283 interface.id.endswith('Event') and |
1280 operation.id.startswith('init') and | 1284 operation.id.startswith('init') and |
1281 argument.ext_attrs.get('Default') == 'Undefined' and | 1285 argument.ext_attrs.get('Default') == 'Undefined' and |
1282 argument.type.id == 'DOMString') | 1286 argument.type.id == 'DOMString') |
OLD | NEW |