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