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

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

Issue 9814012: Proper include forms. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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 | « client/dom/scripts/generator.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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 create_function = 'create' 266 create_function = 'create'
267 if 'NamedConstructor' in self._interface.ext_attrs: 267 if 'NamedConstructor' in self._interface.ext_attrs:
268 raises_exceptions = True 268 raises_exceptions = True
269 parameter_definitions_emitter.Emit( 269 parameter_definitions_emitter.Emit(
270 ' DOMWindow* domWindow = DartUtilities::domWindowForCurrentIs olate();\n' 270 ' DOMWindow* domWindow = DartUtilities::domWindowForCurrentIs olate();\n'
271 ' if (!domWindow) {\n' 271 ' if (!domWindow) {\n'
272 ' exception = Dart_NewString("Failed to fetch domWindow") ;\n' 272 ' exception = Dart_NewString("Failed to fetch domWindow") ;\n'
273 ' goto fail;\n' 273 ' goto fail;\n'
274 ' }\n' 274 ' }\n'
275 ' Document* document = domWindow->document();\n') 275 ' Document* document = domWindow->document();\n')
276 self._cpp_impl_includes.add('DOMWindow') 276 self._cpp_impl_includes.add('"DOMWindow.h"')
277 arguments.append('document') 277 arguments.append('document')
278 create_function = 'createForJSConstructor' 278 create_function = 'createForJSConstructor'
279 if 'CallWith' in self._interface.ext_attrs: 279 if 'CallWith' in self._interface.ext_attrs:
280 call_with = self._interface.ext_attrs['CallWith'] 280 call_with = self._interface.ext_attrs['CallWith']
281 if call_with == 'ScriptExecutionContext': 281 if call_with == 'ScriptExecutionContext':
282 raises_exceptions = True 282 raises_exceptions = True
283 parameter_definitions_emitter.Emit( 283 parameter_definitions_emitter.Emit(
284 ' ScriptExecutionContext* context = DartUtilities::scriptExec utionContext();\n' 284 ' ScriptExecutionContext* context = DartUtilities::scriptExec utionContext();\n'
285 ' if (!context) {\n' 285 ' if (!context) {\n'
286 ' exception = Dart_NewString("Failed to create an object" );\n' 286 ' exception = Dart_NewString("Failed to create an object" );\n'
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 if call_with == 'ScriptExecutionContext': 406 if call_with == 'ScriptExecutionContext':
407 parameter_definitions_emitter.Emit( 407 parameter_definitions_emitter.Emit(
408 '\n' 408 '\n'
409 ' ScriptExecutionContext* context = DartUtilities::scriptExecut ionContext();\n' 409 ' ScriptExecutionContext* context = DartUtilities::scriptExecut ionContext();\n'
410 ' if (!context)\n' 410 ' if (!context)\n'
411 ' return;\n') 411 ' return;\n')
412 arguments.append('context') 412 arguments.append('context')
413 return False 413 return False
414 414
415 if call_with == 'ScriptArguments|CallStack': 415 if call_with == 'ScriptArguments|CallStack':
416 self._cpp_impl_includes.add('DOMWindow') 416 self._cpp_impl_includes.add('"DOMWindow.h"')
417 self._cpp_impl_includes.add('ScriptArguments') 417 self._cpp_impl_includes.add('"ScriptArguments.h"')
418 self._cpp_impl_includes.add('ScriptCallStack') 418 self._cpp_impl_includes.add('"ScriptCallStack.h"')
419 self._cpp_impl_includes.add('V8Proxy') 419 self._cpp_impl_includes.add('"V8Proxy.h"')
420 self._cpp_impl_includes.add('v8') 420 self._cpp_impl_includes.add('"v8.h"')
421 parameter_definitions_emitter.Emit( 421 parameter_definitions_emitter.Emit(
422 '\n' 422 '\n'
423 ' v8::HandleScope handleScope;\n' 423 ' v8::HandleScope handleScope;\n'
424 ' v8::Context::Scope scope(V8Proxy::mainWorldContext(DartUtilit ies::domWindowForCurrentIsolate()->frame()));\n' 424 ' v8::Context::Scope scope(V8Proxy::mainWorldContext(DartUtilit ies::domWindowForCurrentIsolate()->frame()));\n'
425 ' Dart_Handle customArgument = Dart_GetNativeArgument(args, $IN DEX);\n' 425 ' Dart_Handle customArgument = Dart_GetNativeArgument(args, $IN DEX);\n'
426 ' RefPtr<ScriptArguments> scriptArguments(DartUtilities::create ScriptArguments(customArgument, exception));\n' 426 ' RefPtr<ScriptArguments> scriptArguments(DartUtilities::create ScriptArguments(customArgument, exception));\n'
427 ' if (!scriptArguments)\n' 427 ' if (!scriptArguments)\n'
428 ' goto fail;\n' 428 ' goto fail;\n'
429 ' RefPtr<ScriptCallStack> scriptCallStack(DartUtilities::create ScriptCallStack());\n' 429 ' RefPtr<ScriptCallStack> scriptCallStack(DartUtilities::create ScriptCallStack());\n'
430 ' if (!scriptCallStack->size())\n' 430 ' if (!scriptCallStack->size())\n'
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 763
764 return cpp_callback_name 764 return cpp_callback_name
765 765
766 def _GenerateWebCoreReflectionAttributeName(self, attr): 766 def _GenerateWebCoreReflectionAttributeName(self, attr):
767 namespace = 'HTMLNames' 767 namespace = 'HTMLNames'
768 svg_exceptions = ['class', 'id', 'onabort', 'onclick', 'onerror', 'onload', 768 svg_exceptions = ['class', 'id', 'onabort', 'onclick', 'onerror', 'onload',
769 'onmousedown', 'onmousemove', 'onmouseout', 'onmouseover', 769 'onmousedown', 'onmousemove', 'onmouseout', 'onmouseover',
770 'onmouseup', 'onresize', 'onscroll', 'onunload'] 770 'onmouseup', 'onresize', 'onscroll', 'onunload']
771 if self._interface.id.startswith('SVG') and not attr.id in svg_exceptions: 771 if self._interface.id.startswith('SVG') and not attr.id in svg_exceptions:
772 namespace = 'SVGNames' 772 namespace = 'SVGNames'
773 self._cpp_impl_includes.add(namespace) 773 self._cpp_impl_includes.add('"%s.h"' % namespace)
774 774
775 attribute_name = attr.ext_attrs['Reflect'] or attr.id.lower() 775 attribute_name = attr.ext_attrs['Reflect'] or attr.id.lower()
776 return 'WebCore::%s::%sAttr' % (namespace, attribute_name) 776 return 'WebCore::%s::%sAttr' % (namespace, attribute_name)
777 777
778 def _GenerateWebCoreFunctionExpression(self, function_name, idl_node): 778 def _GenerateWebCoreFunctionExpression(self, function_name, idl_node):
779 if 'ImplementedBy' in idl_node.ext_attrs: 779 if 'ImplementedBy' in idl_node.ext_attrs:
780 return '%s::%s' % (idl_node.ext_attrs['ImplementedBy'], function_name) 780 return '%s::%s' % (idl_node.ext_attrs['ImplementedBy'], function_name)
781 return '%s%s' % (self._interface_type_info.receiver(), function_name) 781 return '%s%s' % (self._interface_type_info.receiver(), function_name)
782 782
783 def _GenerateWebCoreInvocation(self, function_expression, arguments, 783 def _GenerateWebCoreInvocation(self, function_expression, arguments,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 ' ExceptionCode ec = 0;\n' 824 ' ExceptionCode ec = 0;\n'
825 '$INVOCATION' 825 '$INVOCATION'
826 ' if (UNLIKELY(ec)) {\n' 826 ' if (UNLIKELY(ec)) {\n'
827 ' exception = DartDOMWrapper::exceptionCodeToDartException( ec);\n' 827 ' exception = DartDOMWrapper::exceptionCodeToDartException( ec);\n'
828 ' goto fail;\n' 828 ' goto fail;\n'
829 ' }\n', 829 ' }\n',
830 INVOCATION=invocation_template) 830 INVOCATION=invocation_template)
831 831
832 if 'ImplementedBy' in attributes: 832 if 'ImplementedBy' in attributes:
833 arguments.insert(0, 'receiver') 833 arguments.insert(0, 'receiver')
834 self._cpp_impl_includes.add(attributes['ImplementedBy']) 834 self._cpp_impl_includes.add('"%s.h"' % attributes['ImplementedBy'])
835 835
836 return emitter.Format(invocation_template, 836 return emitter.Format(invocation_template,
837 FUNCTION_CALL='%s(%s)' % (function_expression, ', '.join(arguments))) 837 FUNCTION_CALL='%s(%s)' % (function_expression, ', '.join(arguments)))
838 838
839 def _GenerateCPPIncludes(includes): 839 def _GenerateCPPIncludes(includes):
840 return ''.join(['#include "%s.h"\n' % include for include in includes]) 840 return ''.join(['#include %s\n' % include for include in includes])
OLDNEW
« no previous file with comments | « client/dom/scripts/generator.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698