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

Side by Side Diff: Source/bindings/scripts/CodeGeneratorV8.pm

Issue 15821017: Use "Constructor" prefix for IDL extended attributes applying to the constructor (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 6 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 | « no previous file | Source/bindings/scripts/IDLAttributes.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 1 # Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
2 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com> 2 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com>
3 # Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> 3 # Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
4 # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org> 4 # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org>
5 # Copyright (C) 2006 Apple Computer, Inc. 5 # Copyright (C) 2006 Apple Computer, Inc.
6 # Copyright (C) 2007, 2008, 2009, 2012 Google Inc. 6 # Copyright (C) 2007, 2008, 2009, 2012 Google Inc.
7 # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> 7 # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au>
8 # Copyright (C) Research In Motion Limited 2010. All rights reserved. 8 # Copyright (C) Research In Motion Limited 2010. All rights reserved.
9 # Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 # Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 # Copyright (C) 2012 Ericsson AB. All rights reserved. 10 # Copyright (C) 2012 Ericsson AB. All rights reserved.
(...skipping 2489 matching lines...) Expand 10 before | Expand all | Expand 10 after
2500 my $function = shift; 2500 my $function = shift;
2501 2501
2502 my $implClassName = GetImplName($interface); 2502 my $implClassName = GetImplName($interface);
2503 my $v8ClassName = GetV8ClassName($interface); 2503 my $v8ClassName = GetV8ClassName($interface);
2504 my $overloadedIndexString = ""; 2504 my $overloadedIndexString = "";
2505 if ($function->{overloadedIndex} > 0) { 2505 if ($function->{overloadedIndex} > 0) {
2506 $overloadedIndexString .= $function->{overloadedIndex}; 2506 $overloadedIndexString .= $function->{overloadedIndex};
2507 } 2507 }
2508 2508
2509 my $raisesExceptions = $function->signature->extendedAttributes->{"RaisesExc eption"}; 2509 my $raisesExceptions = $function->signature->extendedAttributes->{"RaisesExc eption"};
2510 if ($interface->extendedAttributes->{"RaisesException"}) { 2510 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) {
2511 $raisesExceptions = 1; 2511 $raisesExceptions = 1;
2512 } 2512 }
2513 if (!$raisesExceptions) { 2513 if (!$raisesExceptions) {
2514 foreach my $parameter (@{$function->parameters}) { 2514 foreach my $parameter (@{$function->parameters}) {
2515 if ($parameter->extendedAttributes->{"IsIndex"}) { 2515 if ($parameter->extendedAttributes->{"IsIndex"}) {
2516 $raisesExceptions = 1; 2516 $raisesExceptions = 1;
2517 } 2517 }
2518 } 2518 }
2519 } 2519 }
2520 2520
(...skipping 11 matching lines...) Expand all
2532 2532
2533 if ($raisesExceptions) { 2533 if ($raisesExceptions) {
2534 AddToImplIncludes("core/dom/ExceptionCode.h"); 2534 AddToImplIncludes("core/dom/ExceptionCode.h");
2535 $code .= " ExceptionCode ec = 0;\n"; 2535 $code .= " ExceptionCode ec = 0;\n";
2536 } 2536 }
2537 2537
2538 # FIXME: Currently [Constructor(...)] does not yet support optional argument s without [Default=...] 2538 # FIXME: Currently [Constructor(...)] does not yet support optional argument s without [Default=...]
2539 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface, ""); 2539 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface, "");
2540 $code .= $parameterCheckString; 2540 $code .= $parameterCheckString;
2541 2541
2542 if ($interface->extendedAttributes->{"CallWith"} && $interface->extendedAttr ibutes->{"CallWith"} eq "ScriptExecutionContext") { 2542 if ($interface->extendedAttributes->{"ConstructorCallWith"} && $interface->e xtendedAttributes->{"ConstructorCallWith"} eq "ScriptExecutionContext") {
2543 push(@beforeArgumentList, "context"); 2543 push(@beforeArgumentList, "context");
2544 $code .= <<END; 2544 $code .= <<END;
2545 2545
2546 ScriptExecutionContext* context = getScriptExecutionContext(); 2546 ScriptExecutionContext* context = getScriptExecutionContext();
2547 END 2547 END
2548 } 2548 }
2549 2549
2550 if ($interface->extendedAttributes->{"RaisesException"}) { 2550 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) {
2551 push(@afterArgumentList, "ec"); 2551 push(@afterArgumentList, "ec");
2552 } 2552 }
2553 2553
2554 my @argumentList; 2554 my @argumentList;
2555 my $index = 0; 2555 my $index = 0;
2556 foreach my $parameter (@{$function->parameters}) { 2556 foreach my $parameter (@{$function->parameters}) {
2557 last if $index eq $paramIndex; 2557 last if $index eq $paramIndex;
2558 if ($replacements{$parameter->name}) { 2558 if ($replacements{$parameter->name}) {
2559 push(@argumentList, $replacements{$parameter->name}); 2559 push(@argumentList, $replacements{$parameter->name});
2560 } else { 2560 } else {
2561 push(@argumentList, $parameter->name); 2561 push(@argumentList, $parameter->name);
2562 } 2562 }
2563 $index++; 2563 $index++;
2564 } 2564 }
2565 2565
2566 my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterAr gumentList); 2566 my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterAr gumentList);
2567 $code .= "\n"; 2567 $code .= "\n";
2568 $code .= " RefPtr<${implClassName}> impl = ${implClassName}::create(${arg umentString});\n"; 2568 $code .= " RefPtr<${implClassName}> impl = ${implClassName}::create(${arg umentString});\n";
2569 $code .= " v8::Handle<v8::Object> wrapper = args.Holder();\n"; 2569 $code .= " v8::Handle<v8::Object> wrapper = args.Holder();\n";
2570 2570
2571 if ($interface->extendedAttributes->{"RaisesException"}) { 2571 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) {
2572 $code .= " if (ec) {\n"; 2572 $code .= " if (ec) {\n";
2573 $code .= " setDOMException(ec, args.GetIsolate());\n"; 2573 $code .= " setDOMException(ec, args.GetIsolate());\n";
2574 $code .= " return;\n"; 2574 $code .= " return;\n";
2575 $code .= " }\n"; 2575 $code .= " }\n";
2576 } 2576 }
2577 2577
2578 $code .= <<END; 2578 $code .= <<END;
2579 2579
2580 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &${v8ClassName}::in fo, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); 2580 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &${v8ClassName}::in fo, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent);
2581 args.GetReturnValue().Set(wrapper); 2581 args.GetReturnValue().Set(wrapper);
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
2724 } 2724 }
2725 2725
2726 sub GenerateNamedConstructor 2726 sub GenerateNamedConstructor
2727 { 2727 {
2728 my $function = shift; 2728 my $function = shift;
2729 my $interface = shift; 2729 my $interface = shift;
2730 2730
2731 my $implClassName = GetImplName($interface); 2731 my $implClassName = GetImplName($interface);
2732 my $v8ClassName = GetV8ClassName($interface); 2732 my $v8ClassName = GetV8ClassName($interface);
2733 my $raisesExceptions = $function->signature->extendedAttributes->{"RaisesExc eption"}; 2733 my $raisesExceptions = $function->signature->extendedAttributes->{"RaisesExc eption"};
2734 if ($interface->extendedAttributes->{"RaisesException"}) { 2734 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) {
2735 $raisesExceptions = 1; 2735 $raisesExceptions = 1;
2736 } 2736 }
2737 if (!$raisesExceptions) { 2737 if (!$raisesExceptions) {
2738 foreach my $parameter (@{$function->parameters}) { 2738 foreach my $parameter (@{$function->parameters}) {
2739 if ($parameter->extendedAttributes->{"IsIndex"}) { 2739 if ($parameter->extendedAttributes->{"IsIndex"}) {
2740 $raisesExceptions = 1; 2740 $raisesExceptions = 1;
2741 } 2741 }
2742 } 2742 }
2743 } 2743 }
2744 2744
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2787 if ($raisesExceptions) { 2787 if ($raisesExceptions) {
2788 AddToImplIncludes("core/dom/ExceptionCode.h"); 2788 AddToImplIncludes("core/dom/ExceptionCode.h");
2789 $code .= " ExceptionCode ec = 0;\n"; 2789 $code .= " ExceptionCode ec = 0;\n";
2790 } 2790 }
2791 2791
2792 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface); 2792 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface);
2793 $code .= $parameterCheckString; 2793 $code .= $parameterCheckString;
2794 2794
2795 push(@beforeArgumentList, "document"); 2795 push(@beforeArgumentList, "document");
2796 2796
2797 if ($interface->extendedAttributes->{"RaisesException"}) { 2797 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) {
2798 push(@afterArgumentList, "ec"); 2798 push(@afterArgumentList, "ec");
2799 } 2799 }
2800 2800
2801 my @argumentList; 2801 my @argumentList;
2802 my $index = 0; 2802 my $index = 0;
2803 foreach my $parameter (@{$function->parameters}) { 2803 foreach my $parameter (@{$function->parameters}) {
2804 last if $index eq $paramIndex; 2804 last if $index eq $paramIndex;
2805 if ($replacements{$parameter->name}) { 2805 if ($replacements{$parameter->name}) {
2806 push(@argumentList, $replacements{$parameter->name}); 2806 push(@argumentList, $replacements{$parameter->name});
2807 } else { 2807 } else {
2808 push(@argumentList, $parameter->name); 2808 push(@argumentList, $parameter->name);
2809 } 2809 }
2810 $index++; 2810 $index++;
2811 } 2811 }
2812 2812
2813 my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterAr gumentList); 2813 my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterAr gumentList);
2814 $code .= "\n"; 2814 $code .= "\n";
2815 $code .= " RefPtr<${implClassName}> impl = ${implClassName}::createForJSC onstructor(${argumentString});\n"; 2815 $code .= " RefPtr<${implClassName}> impl = ${implClassName}::createForJSC onstructor(${argumentString});\n";
2816 $code .= " v8::Handle<v8::Object> wrapper = args.Holder();\n"; 2816 $code .= " v8::Handle<v8::Object> wrapper = args.Holder();\n";
2817 2817
2818 if ($interface->extendedAttributes->{"RaisesException"}) { 2818 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) {
2819 $code .= " if (ec) {\n"; 2819 $code .= " if (ec) {\n";
2820 $code .= " setDOMException(ec, args.GetIsolate());\n"; 2820 $code .= " setDOMException(ec, args.GetIsolate());\n";
2821 $code .= " return;\n"; 2821 $code .= " return;\n";
2822 $code .= " }\n"; 2822 $code .= " }\n";
2823 } 2823 }
2824 2824
2825 $code .= <<END; 2825 $code .= <<END;
2826 2826
2827 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &${v8ClassName}Cons tructor::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); 2827 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &${v8ClassName}Cons tructor::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent);
2828 args.GetReturnValue().Set(wrapper); 2828 args.GetReturnValue().Set(wrapper);
(...skipping 3008 matching lines...) Expand 10 before | Expand all | Expand 10 after
5837 if ($currentInterface->extendedAttributes->{$extendedAttribute}) { 5837 if ($currentInterface->extendedAttributes->{$extendedAttribute}) {
5838 $found = 1; 5838 $found = 1;
5839 } 5839 }
5840 return 1 if $found; 5840 return 1 if $found;
5841 }, 0); 5841 }, 0);
5842 5842
5843 return $found; 5843 return $found;
5844 } 5844 }
5845 5845
5846 1; 5846 1;
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/scripts/IDLAttributes.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698